[Haskell-cafe] File path programme

Keean Schupke k.schupke at imperial.ac.uk
Wed Jan 26 10:37:48 EST 2005


Simon Marlow wrote:

>
>Hmm, I deliberately didn't suggest using a type class.  Do you really
>want to expose Win32 paths and POSIX paths, and whatever else, as
>different types?  Maybe you do for extensibility, but you really want a
>single Path type too - otherwise portable code will have to use
>conditional compilation.  The Path type therefore has to be an
>existential wrapper:
>
>data Path = (CPath p) => Path p
>
>Maybe we do want to do this, but it causes portability issues with the
>Path library itself: nhc98 can't compile this code for example - you can
>rewrite it using an explicit record of operations, as long as none of
>the operations are polymorphic...
>  
>
Not at all. You just include some nice operation in the class:

emptyPath :: Path p => p
appendPath :: Path p => p -> String -> p

etc...

So it is an abstract datatype and class. The user never needs to touch
the concrete type, even though they use it... The types remain polymophic.

    Keean.


More information about the Libraries mailing list