[Haskell-beginners] Can fields in a record be optional?
Michael Snoyman
michael at snoyman.com
Mon Jul 18 08:52:38 CEST 2011
On Mon, Jul 18, 2011 at 9:44 AM, Yitzchak Gale <gale at sefer.org> wrote:
> Christopher Done wrote:
>> For this there is Data.Default in data-default:
>> http://hackage.haskell.org/packages/archive/data-default/0.2.0.1/doc/html/Data-Default.html
>
> You don't need the added complexity of a type class for
> this - just define the default value.
I don't think it's a case of necessity. It just happens to be very
convenient to be able to use the three letters "def" instead of
"defaultFrobnicatorSettings" or something like that.
Michael
> The case where you need a class for default values is when you're using
> generics. See, for example, System.Console.CmdArgs.Default in
> Neil Mitchell's cmdards package[1].
>
> Regards,
> Yitz
>
> [1] http://hackage.haskell.org/package/cmdargs
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
More information about the Beginners
mailing list