[<<][meta][>>][..]
Tue Aug 2 10:53:41 CEST 2011

SymExpr: compiling to type-stripped recursive data structure

The problem is that the language doesn't fit into a recursive data
structure like:

data Expr t = Lit String
            | Op String [Expr t]
            deriving (Eq, Show)

Because of functions like

i2f :: r Tint -> r Tfloat

If t would be a phantom type this works fine.  Wait, maybe a level of
indirection would help here:

data Term = Lit String
          | Op String [Term]
          deriving (Eq, Show)
data Expr t = Expr Term                   


Yep.  This works.  EDIT: this is essentially the example in [1] "The
use of a type system to guarantee well-formedness".

[1] http://www.haskell.org/haskellwiki/Phantom_type


[Reply][About]
[<<][meta][>>][..]