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

Jon Harrop jon at ffconsultancy.com
Thu May 31 11:21:02 EDT 2007


On Thursday 31 May 2007 15:36:13 Al Falloon wrote:
> 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.).

Although this is the theoretical justification for OCaml's polymorphic 
variants, it is not their most common use.

They are more commonly used to implement overlapping enumerations (see 
LablGL), to avoid sum type declarations with short scope (e.g. [`Some|`None|
`Maybe] inside a single function) and when sum types keep changing during 
development.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists/?e


More information about the Haskell-Cafe mailing list