[Haskell-beginners] Can fields in a record be optional?

Yitzchak Gale gale at sefer.org
Mon Jul 18 08:44:26 CEST 2011


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.

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



More information about the Beginners mailing list