mgsloan / store

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

Natural instance for Store? #154

Closed patrickt closed 3 years ago

patrickt commented 3 years ago

Unless there’s some reason why this doesn’t already exist, I imagine this can just piggyback atop the Integer instance. If anyone else needs this, I’m happy to send a patch.

mgsloan commented 3 years ago

Feel free to send a patch! I do not have a need for it, but it seems good to add. Reusing Integer's encoding makes sense.

On Sat, Nov 14, 2020 at 5:12 PM Patrick Thomson notifications@github.com wrote:

Unless there’s some reason why this doesn’t already exist, I imagine this can just piggyback atop the Integer instance. If anyone else needs this, I’m happy to send a patch.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mgsloan/store/issues/154, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAFQKTZUHW5ZRMEVWUJXF3SP4MHPANCNFSM4TV2625A .

patrickt commented 3 years ago

Does this look acceptable to you, @mgsloan? If so, I’ll send a patch.

instance Store Natural where
  size = contramap fromIntegral (size :: Size Integer)
  poke = poke . toInteger
  peek = fmap fromIntegral (peek :: Peek Integer)
mgsloan commented 3 years ago

Looks great, thanks Patrick!

On Sun, Nov 22, 2020 at 5:29 AM Patrick Thomson notifications@github.com wrote:

Does this look acceptable to you, @mgsloan https://github.com/mgsloan? If so, I’ll send a patch.

instance Store Natural where

size = contramap fromIntegral (size :: Size Integer)

poke = poke . toInteger

peek = fmap fromIntegral (peek :: Peek Integer)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mgsloan/store/issues/154#issuecomment-731740533, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAFQKXJ2TG7TLAYH37EP3LSRD737ANCNFSM4TV2625A .