[Haskell-cafe] Re: Combining Wouter's expressions with extensible records

Antoine Latter aslatter at gmail.com
Fri Jul 11 01:56:06 EDT 2008

2008/7/10 Ron Alford <ronwalf at volus.net>:
> Ok, I'm closer, but I'm running into a problem with typeOf and lists,
> of all things:
> *WouterTest> typeOf (eVar "v" :: TermExpr)
> Planning.Wouter.Expr (Planning.Wouter.:+: WouterTest.Const WouterTest.Var)
> *WouterTest> typeOf ([eVar "v"] :: [TermExpr])
> *** Exception: Prelude.undefined
> I'm pretty sure this is the culprit for getName:
> *WouterTest> getName testNamed
> "*** Exception: Prelude.undefined
> Any hints?
> Also, anyone have hints for how to get automatic derivation of Data (Expr f) ?
> I don't want to proliferate the last lines:
> deriving instance Data (Expr (And :+: Atomic (Expr (Const :+: Var))))
> deriving instance Data (Expr (Const :+: Var))

I screwed up the example code - it typechecks, but it'll fail at runtime.

If you say:

> Inr x = undefined

and then try to pass 'x' off to another function, you're trying to
evaluate the "undeifned", which is a runtime error.

You'll want something more like:

typeOf1 in@(InR f) = [...]
   where InL f = (InL undefined) `asTypeOf` in

This is approaching silliness, but I've tested the code this time
around - so it should even work.


More information about the Haskell-Cafe mailing list