explicit signatures and default for integer literals
Mirko Rahn
rahn at ira.uka.de
Mon May 30 05:48:08 EDT 2005
>>> {-# 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/ ---
More information about the Glasgow-haskell-users
mailing list