explicit signatures and default for integer literals

Dinko Tenev dinko.tenev at gmail.com
Tue May 31 02:48:28 EDT 2005


On 5/31/05, Daniel Fischer <daniel.is.fischer at web.de> wrote:
> > > 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).

There could be such an instance, but that's obviously not the case. 
At the point where g is defined, GHC only knows about New [(a,b)] (Map
a b), and New [(a,Double)] (Map a Int) doesn't fit.

Consider this:

*Main> :type new . flip zip [0..]
new . flip zip [0..] :: (New [(a, b1)] b, Num b1, Enum b1) => [a] -> b

Trying to infer

    New [(u, v)] w

out of all that we know, i.e.

    New [(a,b)] (Map a b)

should give us

    w === Map u v --->
    New [(u, v)] (Map u v)

so finally

    v === Int --->
    New [(u, Int)] (Map u Int)

to infer the context of g.

Is there any good reason not to do this?


Cheers,

D. Tenev


More information about the Glasgow-haskell-users mailing list