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

Al Falloon afalloon at synopsys.com
Thu May 31 12:43:47 EDT 2007


Thomas Schilling 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.).
> 
> Proper subtyping or at least extendable ADTs would be nicer, but you
> can have type-checked progress flags using phantom types, e.g.:
<snip>

I thought that phantom types might be a solution, but how to you 
statically ensure that the AST has only the constructors that are 
appropriate for each phase?

GADTS maybe. Constructors allowed in all phases, or in just one can be 
encoded easily enough. But then how do you encode a constructor that can 
be in two out of three phases? Maybe two phantom types? It all starts 
getting a little hairy.

I will have to go through the papers that the others have provided to 
see if someone has already explored this direction. I have an inkling 
that there is a good idea here, it just might take some time to tease it 
out.

Thanks for the replies.




More information about the Haskell-Cafe mailing list