
Hi all, I was wondering if it's possible to have a class declaration that would except both unlifted types and lifted types as instances. For instance, I'm looking for something like class Foo a b where bar :: a -> b instance Foo Int Int where bar = id instance Foo Int# Int where bar = iBox Regards, Phyx

Hi Phyx,
instance Foo Int# Int where bar = iBox
What you want is not currently possible, for many of the same reasons that you cannot instantiate polymorphic types (e.g. that of id) at unboxed types. Because you can't then be polymorphic in the "a" in "Foo a b" if a might be an unboxed type, writing such a type class would be slightly less useful than normal - you would get name overloading, but not the ability to abstract over the type class in a meaningful way. Cheers, Max
participants (2)
-
Max Bolingbroke
-
Phyx