[Haskell-cafe] Dynamic types through unsafeCoerce
Taral
taralx at gmail.com
Sun Dec 10 13:14:36 EST 2006
On 12/10/06, Alfonso Acosta <alfonso.acosta at gmail.com> wrote:
> On 12/10/06, Taral <taralx at gmail.com> wrote:
> > Sure it is. The type you gave (MyType Int Char -> MyType a b) can
> > easily crash your program.
>
> Ok I see. Why would that happen? I'm (maybe wrongly) taking as granted
> that the compiler/interpreter uses the same internal representation
> for both types. But that makes me think it shouldn't be that dangerous
> if nothing is later assumed about the type parameters "a" and "b".
1. The Haskell Report does not guarantee that these things have the
same representation.
2. Assuming that a polymorphic type will never be made monomorphic is
like running without a safety net. The typecheck will not save you,
and it'll be a pain to debug if it goes wrong. If you're not using
those type parameters, then wrap it up so they can't be used.
Why not post some code snippets so we can see what you're doing?
--
Taral <taralx at gmail.com>
"You can't prove anything."
-- Gödel's Incompetence Theorem
More information about the Haskell-Cafe
mailing list