[Haskell-beginners] basic data types

Peter Hall peter.hall at memorphic.com
Sat Dec 31 04:55:00 CET 2011


A reasonable analogy (though it's not nearly the same thing) for
Haskell classes is Java interfaces. e.g. in Java, Boolean is a class
that implements Serializable and Comparable, while Haskell's Bool type
is an instance of all those classes you listed. In Haskell, the
equivalent of Java's 'class Boolean implements Comparable<Boolean>
...' is 'instance Eq Bool where ... '. In Java you declare the
interfaces that a class implements when the class is declared. In
Haskell, you can add class instances to any type later, not just in
the module that declared the type.

Peter


2011/12/30 Stanisław Findeisen <stf-list at eisenbits.com>:
> Hi
>
> What are those basic data type instances? For example here:
> http://www.haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Bool
> we have:
>
> Instances
>
> Bounded Bool
> Enum Bool
> Eq Bool
> Data Bool
> Ord Bool
> Read Bool
> Show Bool
> Ix Bool
> Typeable Bool
> Generic Bool
> Storable Bool
>
> What is the difference between, e.g., Bounded Bool and Enum Bool?
>
> --
> This e-mail address is invalid, see:
> http://people.eisenbits.com/~stf/public-email-note.html .
>
> OpenPGP: E3D9 C030 88F5 D254 434C  6683 17DD 22A0 8A3B 5CC0
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners



More information about the Beginners mailing list