<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 16 February 2017 at 07:22, Anthony Clayden <span dir="ltr"><<a href="mailto:anthony_clayden@clear.net.nz" target="_blank">anthony_clayden@clear.net.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> On 15 February 2017 at 23:06 Harendra Kumar wrote:<br>
<span class=""><br>
>> On 16 February 2017 at 02:31, Anthony Clayden wrote:<br></span><br>
For gathering params to a function, I see no need for<br>
extensible records.<br>
The params are known at compile time.<br>
If for a DSL you want 'optional' fields, make them Maybe's,<br>
with a default of Nothing.<br></blockquote><div><br></div><div>The point is - I do not want the user to specify all parameters explicitly. There may be a whole bunch of optional parameters in the record but only a few are to be specified in general. I do not want 2 values and 10 Nothings or explicit defaults there.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
><br>
> I am trying to write a program which provides a friendly<br>
> high level DSL to the user.<br>
<br>
</span>'user' here seems to mean programmer,<br>
if you're looking for static guarantees.<br></blockquote><div><br></div><div>Yes, but more of a declarative programmer.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
> I want a pure function like<br>
> API but instead of passing positional parameters I want<br>
> the user to be able to specify arguments based on keywords<br>
> and be able to skip any optional arguments. Something like<br>
> the following, name is mandatory and email is optional:<br>
><br>
> maintainer  (#name  := "Harendra Kumar",  #email :=<br>
> "<a href="mailto:xyz@gmail.com">xyz@gmail.com</a>")<br>
><br>
> I can achieve this using rawr. The argument to the<br>
</span>> function is an anonymous record ...<br>
<br>
OK. But I'm not seeing why it has to be anonymous.<br>
Again, if it's for a specific function, it needs specific<br>
parameters.<br>
An anonymous record might provide keywords not valid,<br>
as well as fail to provide keywords expected.<br></blockquote><div><br></div><div>It does not necessarily have to be anonymous. But I see no problem if it is anonymous. Type checking catches missing keywords or invalid keywords. The example I gave does not have correct type constraints but by fixing it you cannot give it incorrect keywords, I just tested it.</div><div> </div><div>-harendra</div></div></div></div>