explicit signatures and default for integer literals

Seth Kurtzberg seth at cql.com
Tue May 31 02:51:39 EDT 2005


Dinko Tenev wrote:

>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?
>  
>
Because I'm not smart enough to understand it?

;-)

>
>Cheers,
>
>D. Tenev
>_______________________________________________
>Glasgow-haskell-users mailing list
>Glasgow-haskell-users at haskell.org
>http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>
>  
>



More information about the Glasgow-haskell-users mailing list