
* Derek Elkins:
On Fri, 2008-10-03 at 12:22 +0200, Florian Weimer wrote:
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
instane Container Maybe where...
What does copy :: Maybe -> IO Maybe mean?
Maybe is not an instance of CopyConstructible, so this shouldn't compile. On the other hand, for IORef a, copy = (>>= newIORef) . readIORef and for mutable arrays, copy = mapArray id (if I'm not mistaken).