Unboxed Vectors of newtype'd values
Bas van Dijk
v.dijk.bas at gmail.com
Wed Jun 6 00:46:26 CEST 2012
On 5 June 2012 22:45, Simon Peyton-Jones <simonpj at microsoft.com> wrote:
> So Andres has explained how to do what Johan asks. Does that mean that
> Bas’s problem is solved?
My problem can't be solved with GeneralizedNewtypeDeriving since a
UUID is not a newtype but an abstract data type defined in another
package[1].
However, the template-haskell from the vector-th-unbox package which
Reiner mentioned does the job perfectly:
derivingUnbox "UUID"
[d| instance Unbox' UUID (Word32, Word32, Word32, Word32) |]
[| \ uuid -> UUID.toWords uuid|]
[| \ (a,b,c,d) -> UUID.fromWords a b c d |]
Thanks Reiner for pointing me to this package!
Cheers,
Bas
[1] http://hackage.haskell.org/packages/archive/uuid/latest/doc/html/src/Data-UUID-Internal.html#UUID
More information about the Libraries
mailing list