On 5/31/05, Seth Kurtzberg <[EMAIL PROTECTED]> wrote:
> Because I'm not smart enough to understand it?
>
> ;-)
OK, sorry about the notation (I just didn't feel like doing so much
typing, you know :)
Here goes...
First we observe that, g = new . flip zip [0..], so, without the type
specification, it has the general type (New [(a, b1)] b, Num b1, Enum
b1) => [a] -> b, as reported by GHC.
Then we infer from
(1) g :: (New [(u, v)] w, Num v, Enum v) => [u] -> w
and
(2) instance New [(a, b)] (Map a b)
that in (New [(u, v)] w), w can only be (Map u v), so subst (Map u v)
for w to obtain
(3) g :: (New [(u, v)] (Map u v), Num v, Enum v) => [u] -> Map u v
Furthermore, for g we have already specified
(4) g :: Ord a => [a] -> Map a Int
so finally substituting Int for v should give us
(5) g :: (New [(u, Int)] (Map u Int), Num Int, Enum Int, Ord Int)
=> [u] -> Map u Int
Is there any good reason why GHC won't do this? Particularly, is
there any good reason not to infer (New [(u, v)] (Map u v)) from (New
[(u, v)] w) as in (1), (2) --> (3) above?
Cheers,
D. Tenev
_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users