I eagerly awaited the Sep1999 hugs release because I hoped the MPTC
dependencies feature would allow a certain capability I was looking
for. I was disappointed. I think this is all best explained with an
example:
> class Zippable a b | a -> b, b -> a where
> zip' :: a -> [b]
>
> instance Zippable () () where
> zip' = repeat
>
> instance (Zippable b c) => Zippable ([a],b) (a,c) where
> zip' (h,t) = f (h, zip' t) where
> f (x:xs, y:ys) = ((x,y) : f (xs,ys))
> f _ = []
>
> test = zip' ("abcd",())
>
> -- This is what I want:
> -- zip' ("abcd",()) == [('a',()),('b',()),('c',()),('d',())]
> -- zip' ("abcd",([1,2,3],())) == [('a',(1,())),('b',(2,())),('c',(3,()))]
Hugs-Sep1999 gets the following error message:
> ERROR "Zippable.hs" (line 14): Unresolved top-level overloading
> *** Binding : test
> *** Outstanding context : Zippable () b
It works if I declare the type of test, but I want hugs to infer the
type.
Since I've already defined an instance (Zippable () ()), and I told hugs
that the parameters to Zippable are mapped 1:1, I thought that hugs
would be able to determine that (Zippable () ()) was the only possible
instance.
Am I missing something about the type system that makes this
impossible? Or, is this possible but just not implemented yet?
Thanks,
Matt Harden
P.S. yes, I did remember to use -98 to enable the hugs extensions