[Haskell-cafe] Bool as type class to serve EDSLs.
Henning Thielemann
lemming at henning-thielemann.de
Sun May 31 18:17:55 EDT 2009
On Thu, 28 May 2009, Bulat Ziganshin wrote:
> i use another approach which imho is somewhat closer to interpretation
> of logical operations in dynamic languages (lua, ruby, perl):
>
> a ||| b | isDefaultValue a = b
> | otherwise = a
>
> a &&& b | isDefaultValue a = defaultValue
> | otherwise = b
>
> -- Class of types having default value:
> class Defaults a where defaultValue :: a
> instance Defaults () where defaultValue = ()
> instance Defaults Bool where defaultValue = False
> instance Defaults [a] where defaultValue = []
The absence of such interpretations and thus the increased type safety was
one of the major the reasons for me to move from scripting languages to
Haskell.
More information about the Haskell-Cafe
mailing list