Haskell time library: Weekday and Month
gale at sefer.org
Thu Apr 15 08:53:31 EDT 2010
Henning Thielemann wrote:
> ...for instance weekdays and months are handled as plain numbers.
> Wouldn't it be better to make them enumerations or newtypes
I agree, I would also like some built-in types for these.
Type safety would be good.
I vote for enumerations for code clarity - fromEnum and toEnum
have negligible cost in efficiency.
> In case of weekdays and months a custom type would also
> make it irrelevant for the user, whether you count days and
> months starting from zero or one.
Well, this would force the API to make some choices about those
kinds of things. Until now it has tried to be agnostic. But that's a
good thing in my opinion - simplicity is more important.
More information about the Libraries