Standarize GHC.Prim.Any
Isaac Dupree
ml at isaac.cedarswampstudios.org
Mon Aug 17 19:52:26 EDT 2009
Maciej Piechotka wrote:
> I'm so sorry if I've done it wrong - it's my first contact with Haskell
> standardization and I base on
> http://hackage.haskell.org/trac/haskell-prime/wiki/Process . I hope it
> is not too late as well.
Do not worry about that, we have decided to have a yearly
standardization process.
> Any from GHC.Prim makes unsafeCoerce much useful and safe. Can it be
> included in Unsafe.Coerce module?
>
> Pros:
> - unsafeCoerce is much more useful with Any (it's a safe placeholder for
> any value and therefore can be passed simply in/out FFI).
Yes it's a safe placeholder, but so is an existential, I believe...
data ContainsAny = forall a. ContainsAny a
to put in the container:
"ContainsAny x"
to remove from the container:
"case ... of ContainsAny x -> unsafeCoerce x"
Albeit, there might be a slight performance penalty for the extra box,
which can't be removed in all haskell implementations.
Also, what do you mean about "FFI"? I don't think you can pass the
"Any" type to foreign functions through the FFI...
Also, can/do all compilers that implement unsafeCoerce implement a safe Any?
Hugs can do it with just "data Any = Ignored" I believe, not sure about
nhc, yhc or jhc...
-Isaac
More information about the Haskell-prime
mailing list