[Haskell-cafe] Idiomatic Haskell equivalent of "keyword arguments" to functions

Paul Moore p.f.moore at gmail.com
Fri Dec 29 17:55:47 EST 2006


On 12/29/06, Neil Mitchell <ndmitchell at gmail.com> wrote:
> Records are your friend.
[...]
> The other alternative is:
>
> data EmailParams = Body String
>                             | Port Int
>                             | Mailserver String

Neat ideas. Thanks. I guess there could there be disadvantages
involved in using a list of arguments, rather than a curried function
(can't easily do partial application, for example) - but I don't know
if these would be a big deal in any practical program.

As I mentioned, I'm interested in trying to expand my brain, as well
as just solve a particular problem :-)

Thanks for the ideas - I'll ponder on them.

On 12/29/06, David House <dmhouse at gmail.com> wrote:
> On 29/12/06, Paul Moore <p.f.moore at gmail.com> wrote:
> > I looked at wxHaskell for inspiration

> This is actually a really nice solution, if you think about it:
[...]

Oh, in principle I agree (your 3 reasons are exactly why I like
keyword parameters in Python). I'm not particularly sure if it's a bit
over-complex for the sorts of things I have in mind, but it certainly
looks nice in wxHaskell.

> Try again to understand the typing, hopefully you'll see this is
> probably The Best Way. If you have any questions about the typing
> itself, just post them here.

I'm sure I can follow the typing with a bit of thinking, and it should
be educational to work it through.

Thanks to both of you for some useful ideas.

Paul.


More information about the Haskell-Cafe mailing list