packages feed

ats-storable 0.2.0.0 → 0.2.0.1

raw patch · 3 files changed

+16/−17 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

README.md view
@@ -1,5 +1,5 @@-# ats-generic--## Installation+# ats-storable -## Configuration+Resuscitation of+[generic-storable](hackage.haskell.org/package/generic-storable) altered to+work with ATS' algebraic data types.
ats-storable.cabal view
@@ -1,5 +1,5 @@ name:                ats-storable-version:             0.2.0.0+version:             0.2.0.1 synopsis:            Marshal ATS types into Haskell description:         Facilities for sharing types between ATS and Haskell homepage:            https://github.com//ats-generic#readme
src/Foreign/Storable/ATS.hs view
@@ -63,8 +63,6 @@     alignment' = undefined     sizeOf' = undefined --- TODO closed type families?- instance (Storable' a, Storable' b) => Storable' (a :*: b) where     sizeOf' _ = sizeOf' (undefined :: a x) + sizeOf' (undefined :: b x)     alignment' _ = gcd (alignment' (undefined :: a x)) (alignment' (undefined :: b x))@@ -85,22 +83,23 @@     peek :: Ptr a -> IO a     peek = C.peek --- FIXME this doesn't use reference types properly+-- FIXME use reference types instance (Storable' a, Storable' b) => Storable' (a :+: b) where-    sizeOf' _ = 4 + max (sizeOf' (undefined :: a x)) (sizeOf' (undefined :: b x))-    alignment' _ = gcd 4 $ gcd (alignment' (undefined :: a x)) (alignment' (undefined :: b x))+    sizeOf' _ = 1 + max (sizeOf' (undefined :: a x)) (sizeOf' (undefined :: b x))+    alignment' _ = 1     peek' ptr = do         tag <- peek (castPtr ptr)-        if (tag :: Word32) == 0-            then pure L1 <*> peekByteOff' (castPtr ptr) 4-            else pure R1 <*> peekByteOff' (castPtr ptr) 4+        if (tag :: Word8) == 0+            then pure L1 <*> peekByteOff' (castPtr ptr) 1+            else pure R1 <*> peekByteOff' (castPtr ptr) 1     poke' ptr (L1 val) = mconcat-        [ poke (castPtr ptr) (0 :: Word32)-        , pokeByteOff' (castPtr ptr) 4 val ]+        [ poke (castPtr ptr) (0 :: Word8)+        , pokeByteOff' (castPtr ptr) 1 val ]     poke' ptr (R1 val) = mconcat-        [ poke (castPtr ptr) (1 :: Word32)-        , pokeByteOff' (castPtr ptr) 4 val ]+        [ poke (castPtr ptr) (1 :: Word8)+        , pokeByteOff' (castPtr ptr) 1 val ] +-- instance (ATSStorable a) => Storable' (K1 i a) where     sizeOf' _ = sizeOf (undefined :: a)     alignment' _ = alignment (undefined :: a)