[Haskell-cafe] Using fundeps to resolve polymorphic types to
pablo at babel.ls.fi.upm.es
Tue Jul 29 05:07:34 EDT 2008
Wren ng thornton wrote:
> It compiles just fine with (DeriveType A b => b -> b) after all, which resolves directly to (B -> B)
That's not the case:
simpleNarrow :: DeriveType A b => b -> b
simpleNarrow = id
Couldn't match expected type `b' (a rigid variable)
against inferred type `B'
`b' is bound by the type signature for `simpleNarrow' ...
When using functional dependencies to combine
DeriveType A B, arising from the instance declaration ...
DeriveType A b, arising from is bound by the type signature for
I think Bryan got the order in which type inference/checking works
wrong. The dependency is not "resolved" before calculating the type as
>*Main> someDestructor (SomeConstructor undefined undefined :: ComplexType A)
Why not this:
*Main> someDestructor (SomeConstructor A B)
> But if you have actual values rather than just unit types, note that this
> won't work:
> > instance DeriveType A B where
> > someDestructor (SomeConstructor _ b) = b
I couldn't understand the sentence "actual values rather than unit
types". What do you have in mind?
More information about the Haskell-Cafe