[Haskell-cafe] Kind-agnostic type classes
Florian Weimer
fw at deneb.enyo.de
Fri Oct 3 06:22:02 EDT 2008
I'm trying to encode a well-known, informally-specified type system in
Haskell. What causes problems for me is that type classes force types
to be of a specific kind. The system I'm targeting however assumes that
its equivalent of type classes are kind-agnositic.
For instance, I've got
class Assignable a where
assign :: a -> a -> IO ()
class Swappable a where
swap :: a -> a -> IO ()
class CopyConstructible a where
copy :: a -> IO a
class (Assignable a, CopyConstructible a) => ContainerType a
class (Swappable c, Assignable c, CopyConstructible c) => Container c where
size :: (Num i, ContainerType t) => c t -> IO i
I suppose I could address this with creating aliases for the relevant
classes, but I wonder if there is a better workaround.
I see that the ML module system has a similar restriction on type
sharing. Is there a fundamental reasons behind this?
More information about the Haskell-Cafe
mailing list