Classes and interfaces, a naming restriction

Hi, Aparantly there's a restriction on having a class and a data type with the same name. A strange thing to want to do? Here's what I'd like to do: class IStream stream char where readStream :: stream -> Int -> IO [char] data IStream char = forall stream. IStream stream char => IStream stream instance IStream (IStream char) char where readStream (IStream stream) = readStream stream So here the *type* IStream is the representative member of the *class* IStream. An OOP analogy is that a particular 'stream' such that (IStream stream char) => stream is a particular concrete class that inherits from a virtual base class IStream, but a 'stream' that is of type IStream is a pointer/reference to something that inherits from the virtual base class (or a COM interface pointer) With the former we have (potentially) static binding, with the latter it is necessarily dynamic binding. So whenever I need a hetrogenious collection of streams I can apply: IStream :: forall c s. (IStream s c) => s -> IStream c Do I really have to use data IStreamWrapper = ... instead? :-( Duncan
participants (1)
-
Duncan Coutts