explicit signatures and default for integer literals

Daniel Fischer daniel.is.fischer at web.de
Mon May 30 19:00:14 EDT 2005


Am Montag, 30. Mai 2005 11:48 schrieb Mirko Rahn:
> >>> {-# 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,

It wasn't actually private, I accidentally sent it to haskell-cafe, sorry.

Cheers,
Daniel


More information about the Glasgow-haskell-users mailing list