[Haskell-beginners] Real world example of Typeclasses > Interfaces
ozgurakgun at gmail.com
Sat Sep 4 13:26:25 EDT 2010
On 4 September 2010 18:04, Alec Benzer <alecbenzer at gmail.com> wrote:
> What I mean is, if you had a function: something n =
> [1..n], and your type was a -> [a], a needs to be declared as (Num a,
> Enum a), even though this is sort of redundant, since you can't really
> have a number that isn't also enumerable.
Well, you can actually have a Num that isn't Enum.
ghci> :info Num
class (Eq a, Show a) => Num a where
(+) :: a -> a -> a
(*) :: a -> a -> a
(-) :: a -> a -> a
negate :: a -> a
abs :: a -> a
signum :: a -> a
fromInteger :: Integer -> a
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners