mgsloan / store

Fast binary serialization in Haskell
MIT License
109 stars 35 forks source link

Compatibility with integer-simple #135

Closed nh2 closed 4 years ago

nh2 commented 6 years ago

Currently store hard-depends on integer-gmp. Its .Internal module is used.

integer-gmp implies gmp which is LGPL which means currently store cannot be used to statically link proprietary products.

It would be great if store could offer a flag to use integer-simple instead, like text (via its integer-simple flag) and cryptonite (via its integer-gmp flag) do.

Could somebody estimate how much effort it would be to write the code that currently uses import qualified GHC.Integer.GMP.Internals as I for integer-simple?

mgsloan commented 6 years ago

@nh2 Hey, good idea! Probably pretty easy, though a little bit of boilerplate. Would be nice if the TH generation would work for it, but it is using unboxed types, so they'll need to be re-wrapped. So, for example, the definition of poke would probably be something like this untested / uncompiled code:

poke = \case
  S# x -> poke (0 :: Word8) >> poke (I# x)
  Jp# (BN# x) -> poke (1 :: Word8) >> poke (ByteArray x)
  Jn# (BN# x) -> poke (2 :: Word8) >> poke (ByteArray x)