[Haskell-beginners] Real world example of Typeclasses > Interfaces
Alec Benzer
alecbenzer at gmail.com
Sat Sep 4 13:41:44 EDT 2010
I was speaking more generally, not specifically about the Haskell
typeclasses Num and Enum (although actually irrational numbers aren't
enumerable now that I think of it, but I also guess that's a
relatively moot point since you can't really represent irrational
numbers in a programming language)
On Sat, Sep 4, 2010 at 1:26 PM, Ozgur Akgun <ozgurakgun at gmail.com> wrote:
>
> 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
>
>
> --
> Ozgur Akgun
>
More information about the Beginners
mailing list