[Haskell-cafe] Typed DSL compiler,
or converting from an existential to a concrete type
Roberto Zunino
zunino at di.unipi.it
Sat Oct 6 13:12:46 EDT 2007
oleg at pobox.com wrote:
> we might attempt to write
>
>> testr = either (error) (ev) (typecheck env0 te3)
>> where ev (TypedTerm t e) = sin (eval e)
>
> We know that it should work.
If we know it has to be a Double, we can express that:
> testr = either (error) (ev) (typecheck env0 te3)
> where ev (TypedTerm TDouble e) = sin (eval e)
and this compiles. Of course, we can consider the other types as well:
> testr = either (error) (ev) (typecheck env0 te3)
> where ev (TypedTerm TDouble e) = Right $ sin (eval e)
> ev _ = Left "not a Double"
Zun.
More information about the Haskell-Cafe
mailing list