> On 15 February 2017 at 23:06 Harendra Kumar wrote:
>> On 16 February 2017 at 02:31, Anthony Clayden wrote:
For gathering params to a function, I see no need for
extensible records.
The params are known at compile time.
If for a DSL you want 'optional' fields, make them Maybe's,
with a default of Nothing.
>
> I am trying to write a program which provides a friendly
> high level DSL to the user.
'user' here seems to mean programmer,
if you're looking for static guarantees.
> I want a pure function like
> API but instead of passing positional parameters I want
> the user to be able to specify arguments based on keywords
> and be able to skip any optional arguments. Something like
> the following, name is mandatory and email is optional:
>
> maintainer (#name := "Harendra Kumar", #email :=
> "xyz@gmail.com")
>
> I can achieve this using rawr. The argument to the
> function is an anonymous record ...
OK. But I'm not seeing why it has to be anonymous.
Again, if it's for a specific function, it needs specific
parameters.
An anonymous record might provide keywords not valid,
as well as fail to provide keywords expected.