Benjamin Pierce wrote: > For someone coming to Haskell from an OCaml background, one of the hardest > things to get used to is the somewhat more bare bones module system that > Haskell provides. > ... > This works fine as long as what you're exporting is just values, but it's > awkward for types, since there is no way to *declare* a type (e.g., giving > just its kind) without *defining* it.
Actually Haskell fully matches the module system of OCaml -- and then adds some. Haskell provides both generative and applicative (recursive) functors. The following two messages elucidate the correspondence http://www.haskell.org/pipermail/haskell/2004-August/014463.html http://www.haskell.org/pipermail/haskell/2004-September/014515.html The end of the first message gives the translation dictionary: from OCaml/ML module terminology to Haskell terminology. I have recently found out that the translation works the other way around, too. Both messages are doubly-literate code: messages can be loaded into OCaml or into a Haskell system. Regarding the specific question of hiding a type: oftentimes declaring a class and exporting it suffices. (forall a.C a => a) is an `abstract' type in Haskell. If the type to abstract has a kind *->*, we can write (forall a.C a => a b), etc. If we really want to prevent the user from ever knowing the details of the implementation, existential quantification (along with the typeclass) does the trick. That trick incidentally permits `self-tuned' data structures, the simple example of which is http://www.haskell.org/pipermail/haskell/2005-February/015356.html _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe