[Haskell-cafe] Has anyone looked into adding subtyping to Haskell?

Dan Doel dan.doel at gmail.com
Thu May 31 13:19:09 EDT 2007


On Thursday 31 May 2007, Al Falloon wrote:
> OCaml has been getting a lot of mileage from its polymorphic variants
> (which allow structural subtyping on sum types) especially on problems
> relating to AST transformations and the infamous "expression problem".
>
> Has there been any work on extending Haskell's type system with
> structural subtyping?
>
> What is the canonical solution to the expression problem in Haskell?
>
> What techniques do Haskellers use to simulate subtyping where it is
> appropriate?
>
> I bring this up because I have been working on a Scheme compiler in
> Haskell for fun, and something like polymorphic variants would be quite
> convinent to allow you to specify versions of the AST (input ast, after
> closure conversion, after CPS transform, etc.), but allow you to write
> functions that work generically over all the ASTs (getting the free
> vars, pretty printing, etc.).

I'm not sure if it qualifies (as, I don't know OCaml), but you might want to 
look into some of the papers proposing extensible record systems for Haskell. 
Some of them note that the same type system extensions for records can be 
used for variants. Specifically, Daan Leijen's paper "Extensible records with 
scoped labels" goes into how they might work, although there may be other 
good papers on the subject.

Would such a proposal be comparable to what OCaml has?

Unfortunately, I don't think implementing such a proposal is high on the to-do 
list for any of the compilers currently. There's too little time in the day 
to build all the type system fanciness everyone could want, I guess. :)

-- Dan


More information about the Haskell-Cafe mailing list