On May 24, 2005, at 5:28 PM, John Meacham wrote:

[various ways of capturing options passed to functions discussed...]

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.

Ah, but imagine I don't have the module source handy. Which corresponds to True and which to False?

Mostly, I stay away from enumerations whose order matters, making a particular exception for Bool and Ord.

If the names are (as above) DontDoSomething | DoSomething, using a newtype plus a boolean conveys the same sense without the forgetfulness:

newtype CreateParents = CreateParents Bool

createDirectory (CreateParents False)

-Jan-Willem Maessen
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to