Hi,

Suppose I have the following types:

> data Expr expr = Lit Nat | Add (expr, expr)
> newtype Fix f = Fix {unFix :: f (Fix f)}

I can construct a sample term:

> term :: Expr (Expr (Expr expr))
> term = Add (Lit 1, Add (Lit 2, Lit 3))

But isn't quite what I need. What I really need is:

> term' :: Fix Expr
> term' = Fix . Add $ (Fix . Lit $ 1, Fix . Add $ (Fix . Lit $ 2, Fix . Lit
$ 3))

I feel like there's a stupidly simple way to automatically produce term'
from term, but I'm not seeing it.

Any ideas?

Best,
Sebastien
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to