What's odd is that it works directly (typeOf ... (Expr (f :+: g))
returns a type), but if you enclose the expression in a list, it fails
with Prelude.undefined.  Do I also need a custom instance for
Typeable [Expr ...] ? (See previous message for code)

-Ron



On Fri, Jul 11, 2008 at 1:56 AM, Antoine Latter <[EMAIL PROTECTED]> wrote:
> 2008/7/10 Ron Alford <[EMAIL PROTECTED]>:
>> 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.
>
> -Antoine
>
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to