Re: Coercible questions

2019-10-07 Thread Richard Eisenberg
Hi devs, In a perfect world, Coercible would relate any two types with the same representation. But the world is not perfect! So we fall well short of this goal. Specifically, Coercible allows conversions between a newtype and its representation, and additionally between datatypes where the

Re: Coercible questions

2019-10-05 Thread Brandon Allbery
I think there's some work going on to expose the representations, which would enable some ability to coerce. But possibly not this much, as they're separate RuntimeReps so you don't combine signed and unsigned numbers inadvertently; currently that's a little magical inside ghc iirc, with the

Re: Coercible questions

2019-10-05 Thread Michal Terepeta
Adding +ghc-devs to continue the thread Hi Sandy, Thanks for the answer! Do you think there is some fundamental reason for this? Or just a matter of implementing this in GHC? It seems to me that this should work just fine as long as the runtime representation is the same. And a related

Coercible questions

2019-10-05 Thread Michal Terepeta
Hi, I've started looking into using `Data.Coerce` (and the `Coercible` type-class) for a personal project and was wondering why coercing between `Int` and `Word` is not allowed? I don't see any fundamental reason why this shouldn't work... Perhaps, it's just a matter of GHC's implementation