[Haskell-cafe] Convert a function to a string of operators?
Erik Hesselink
hesselink at gmail.com
Fri Mar 11 10:28:16 CET 2011
On Thu, Mar 10, 2011 at 13:34, Lyndon Maydwell <maydwell at gmail.com> wrote:
>> Will methods explained here work for boolean expressions?
>
> The convenience of defining using specialised datatypes for
> serialising numeric operations comes from Num being a typeclass. This
> is not the case for Bool:
>
> Prelude> :info Num
> class (Eq a, Show a) => Num a where
> (+) :: a -> a -> a
> ... -- Defined in GHC.Num
>
> Prelude> :info Bool
> data Bool = False | True -- Defined in GHC.Bool
If you want something like this for Bool (and other standard data
types) have a look at the Awesome Prelude [1]. It is an implementation
of the prelude where each data type is a type class.
Erik
[1] http://tom.lokhorst.eu/2010/02/awesomeprelude-presentation-video
More information about the Haskell-Cafe
mailing list