
30 May
2005
30 May
'05
5:48 a.m.
{-# OPTIONS -fglasgow-exts #-}
import Data.Map
class New a b where new :: a -> b
instance Ord a => New [(a,b)] (Map a b) where new = fromList
g :: Ord a => [a] -> Map a Int g xs = new $ zip xs [0..]
Why is ghc unable the determine the type of the Literal 0 in the definition of g?
Answer: Since somewhere an instance e.g. New [(a,Double)] (Map a Int) could be defined, leading to problems when threating 0 as (0::Int). Thanks to private communication, Cheers, -- -- Mirko Rahn -- Tel +49-721 608 7504 -- --- http://liinwww.ira.uka.de/~rahn/ ---