slemi wrote: > oh well thats pretty straight-forward:) > > the next thing i don't understand is how ghci turns 1 into (Scalar 1). > 1 == (Scalar 1) returns True, which is logical in a way (NOT), but if i > change the type definition to > data Matrix a = Matr {unMatr :: [[a]]} | Lol a | Scalar a > then > 1 == (Scalar 1) still returns True, but > 1 == (Lol 1) returns False, no matter in what order I put them in the > definition... o.O
Numeric literals in Haskell are overloaded. 1 really means fromInteger 1. The function fromInteger is defined by instances of Num. This is why you can use a numeric literal wherever your program expects a Double, Int, Integer, and so on. This includes your own type. You have probably defined fromInteger = Scalar for your type. Cheers, Jochem -- Jochem Berndsen | joc...@functor.nl | joc...@牛在田里.com _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe