On Thu, 19 May 2005 [EMAIL PROTECTED] wrote:
G'day all.
Quoting J�r�my Bobbio <[EMAIL PROTECTED]>:
> One of the best bad example is the use of boolean as arguments.
Oh, yes. That's a pet peeve of mine. About 99% of boolean arguments
should be meaningful two-valued enumerated types. It's literally a
one-liner to create such an enumerated type, so there's no excuse.
The documentation effect and type safety provided by two-valued enumerated
types is indeed much greater. But one needs a conversion from Bool to the
enumeration if one wants to pass the result of a logic operation to the
function. What about records with named fields, especially if more options
are needed?
data CreateDirectoryOptions = Cons {createParents :: Bool}
createDirectory (Cons {createParents = True}) "dir"
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe