
| Aparantly there's a restriction on having a class and a data type with | the same name. A strange thing to want to do? Maybe not, but illegal in Haskell. I think the main reason is distinguishing classes from instances in export and import lists: module Foo( IStream(..) ) where ... What gets exported, the class IStream or the data type IStream? The best you can do is put them in separate modules. Then you can name them as M1.IStream and M2.IStream if you want. Simon | 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 | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users