[Haskell-cafe] APIs

ajb at spamcop.net ajb at spamcop.net
Tue May 24 20:32:48 EDT 2005


G'day all.

Quoting John Meacham <john at repetae.net>:

> I think it is easier just to declare it as Enum..
>
> data ParentsFlag = DontCreateParents | CreateParents
>         deriving(Enum)
>
> now (toEnum . fromEnum) will convert between ParentsFlag and Bool.

Except that it's still not clear whether True corresponds to CreateParents
or not.

I'd do it by providing functions with meaningful names, like this:

    createParentsIfTrue :: Bool -> ParentsFlag

Cheers,
Andrew Bromage


More information about the Haskell-Cafe mailing list