[Haskell-cafe] Re: Has anyone looked into adding subtyping to
afalloon at synopsys.com
Thu May 31 12:46:38 EDT 2007
Jon Harrop wrote:
> 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
I kind of saw the overlapping enumeration case as just a common special
case of the AST problem. I can't think of a lightweight way to encode
overlapping enumerations in Haskell. If someone can come up with one, it
would probably shed some light on the right direction for the AST problem.
The other uses of PV, I hadn't been aware of, but it makes a lot of sense.
More information about the Haskell-Cafe