packages feed

haskus-binary 1.0 → 1.1

raw patch · 2 files changed

+106/−93 lines, 2 filesdep +haskus-utils-datadep +haskus-utils-typesdep ~QuickCheckdep ~basedep ~bytestring

Dependencies added: haskus-utils-data, haskus-utils-types

Dependency ranges changed: QuickCheck, base, bytestring, cereal, criterion, haskus-utils, mtl, tasty, tasty-quickcheck

Files

haskus-binary.cabal view
@@ -1,96 +1,109 @@-name: haskus-binary-version: 1.0-cabal-version: >=1.20-build-type: Simple-license: BSD3-license-file: LICENSE-copyright: Sylvain Henry 2017-maintainer: sylvain@haskus.fr-homepage: http://www.haskus.org/system-synopsis: Haskus binary format manipulation+name:                haskus-binary+version:             1.1+synopsis:            Haskus binary format manipulation+license:             BSD3+license-file:        LICENSE+author:              Sylvain Henry+maintainer:          sylvain@haskus.fr+homepage:            http://www.haskus.org/system+copyright:           Sylvain Henry 2017+category:            System+build-type:          Simple+cabal-version:       1.20+ description:-    A set of types and tools to manipulate binary data, memory, etc. In-    particular to interface Haskell data types with foreign data types (C-    structs, unions, enums, etc.).-category: System-author: Sylvain Henry+   A set of types and tools to manipulate binary data, memory, etc. In+   particular to interface Haskell data types with foreign data types (C+   structs, unions, enums, etc.).  source-repository head-    type: git-    location: git://github.com/haskus/haskus-binary.git+  type: git+  location: git://github.com/haskus/haskus-binary.git  library-    exposed-modules:-        Haskus.Format.Binary.Bits-        Haskus.Format.Binary.Bits.Finite-        Haskus.Format.Binary.Bits.Index-        Haskus.Format.Binary.Bits.Bitwise-        Haskus.Format.Binary.Bits.Reverse-        Haskus.Format.Binary.Bits.Rotate-        Haskus.Format.Binary.Bits.Shift-        Haskus.Format.Binary.Bits.Order-        Haskus.Format.Binary.Bits.Get-        Haskus.Format.Binary.Bits.Put-        Haskus.Format.Binary.BitSet-        Haskus.Format.Binary.BitField-        Haskus.Format.Binary.Buffer-        Haskus.Format.Binary.BufferList-        Haskus.Format.Binary.BufferBuilder-        Haskus.Format.Binary.Char-        Haskus.Format.Binary.Enum-        Haskus.Format.Binary.Endianness-        Haskus.Format.Binary.FixedPoint-        Haskus.Format.Binary.Get-        Haskus.Format.Binary.Put-        Haskus.Format.Binary.VariableLength-        Haskus.Format.Binary.Vector-        Haskus.Format.Binary.Union-        Haskus.Format.Binary.Unum-        Haskus.Format.Binary.Posit-        Haskus.Format.Binary.Record-        Haskus.Format.Binary.Storable-        Haskus.Format.Binary.Word-        Haskus.Format.Binary.Ptr-        Haskus.Format.Binary.Layout-        Haskus.Utils.Memory-    build-depends:-        base >=4.9 && <4.12,-        haskus-utils >=0.6 && <1.1,-        cereal ==0.5.*,-        bytestring ==0.10.*,-        mtl ==2.2.*-    default-language: Haskell2010-    hs-source-dirs: src/lib-    ghc-options: -Wall+  exposed-modules: -test-suite  tests-    type: exitcode-stdio-1.0-    main-is: Main.hs-    build-depends:-        base >=4.11.1.0 && <4.12,-        haskus-binary -any,-        haskus-utils ==1.0.*,-        tasty >=0.11 && <1.2,-        tasty-quickcheck >=0.8 && <0.11,-        QuickCheck >=2.8 && <2.12,-        bytestring >=0.10.8.2 && <0.11-    default-language: Haskell2010-    hs-source-dirs: src/tests/-    other-modules:-        Haskus.Tests.Format.Binary-        Haskus.Tests.Common-        Haskus.Tests.Format.Binary.Bits-        Haskus.Tests.Format.Binary.GetPut-        Haskus.Tests.Format.Binary.Vector-    ghc-options: -O2 -Wall -threaded+    Haskus.Format.Binary.Bits+    Haskus.Format.Binary.Bits.Finite+    Haskus.Format.Binary.Bits.Index+    Haskus.Format.Binary.Bits.Bitwise+    Haskus.Format.Binary.Bits.Reverse+    Haskus.Format.Binary.Bits.Rotate+    Haskus.Format.Binary.Bits.Shift+    Haskus.Format.Binary.Bits.Order+    Haskus.Format.Binary.Bits.Get+    Haskus.Format.Binary.Bits.Put -benchmark  bench-BitReverse-    type: exitcode-stdio-1.0-    main-is: BitReverse.hs-    build-depends:-        base >=4.11.1.0 && <4.12,-        haskus-binary -any,-        criterion >=1.4.1.0 && <1.5-    default-language: Haskell2010-    hs-source-dirs: src/bench-    ghc-options: -Wall -threaded -O3+    Haskus.Format.Binary.BitSet+    Haskus.Format.Binary.BitField+    Haskus.Format.Binary.Buffer+    Haskus.Format.Binary.BufferList+    Haskus.Format.Binary.BufferBuilder+    Haskus.Format.Binary.Char+    Haskus.Format.Binary.Enum+    Haskus.Format.Binary.Endianness+    Haskus.Format.Binary.FixedPoint+    Haskus.Format.Binary.Get+    Haskus.Format.Binary.Put+    Haskus.Format.Binary.VariableLength+    Haskus.Format.Binary.Vector+    Haskus.Format.Binary.Union+    Haskus.Format.Binary.Unum+    Haskus.Format.Binary.Posit+    Haskus.Format.Binary.Record+    Haskus.Format.Binary.Storable+    Haskus.Format.Binary.Word+    Haskus.Format.Binary.Ptr++    Haskus.Format.Binary.Layout++    Haskus.Utils.Memory++  other-modules:++  build-depends:       +         base                      >= 4.9 && <5.0+      ,  haskus-utils-types        >= 1.3+      ,  haskus-utils-data         >= 1.1+      ,  haskus-utils              >= 1.3+      ,  cereal                    >= 0.5+      ,  bytestring                >= 0.10+      ,  mtl                       >= 2.2++  build-tools: +  ghc-options:          -Wall+  default-language:     Haskell2010+  hs-source-dirs:       src/lib++test-suite tests+   type:                exitcode-stdio-1.0+   main-is:             Main.hs+   hs-source-dirs:      src/tests/+   ghc-options:         -Wall -threaded+   default-language:    Haskell2010+   other-modules:+         Haskus.Tests.Format.Binary+      ,  Haskus.Tests.Common+      ,  Haskus.Tests.Format.Binary.Bits+      ,  Haskus.Tests.Format.Binary.GetPut+      ,  Haskus.Tests.Format.Binary.Vector++   build-depends:    +         base+      ,  haskus-binary+      ,  haskus-utils+      ,  tasty                   >= 0.11+      ,  tasty-quickcheck        >= 0.8+      ,  QuickCheck              >= 2.8+      ,  bytestring++Benchmark bench-BitReverse+   type:               exitcode-stdio-1.0+   main-is:            BitReverse.hs+   hs-source-dirs:     src/bench+   ghc-options:         -Wall -threaded+   default-language:     Haskell2010+   build-depends:+         base+      ,  haskus-binary+      ,  criterion
src/lib/Haskus/Format/Binary/Union.hs view
@@ -78,20 +78,20 @@ newtype Union (x :: [*]) = Union (ForeignPtr ()) deriving (Show)  -- | Retrieve a union member from its type-fromUnion :: (Storable a, IsMember a l ~ 'True) => Union l -> a+fromUnion :: (Storable a, Member a l) => Union l -> a fromUnion (Union fp) = unsafePerformIO $ withForeignPtr fp (peek . castPtr)  -- | Create a new union from one of the union types-toUnion :: forall a l . (Storable (Union l), Storable a, IsMember a l ~ 'True) => a -> Union l+toUnion :: forall a l . (Storable (Union l), Storable a, Member a l) => a -> Union l toUnion = toUnion' False  -- | Like 'toUnion' but set the remaining bytes to 0-toUnionZero :: forall a l . (Storable (Union l), Storable a, IsMember a l ~ 'True) => a -> Union l+toUnionZero :: forall a l . (Storable (Union l), Storable a, Member a l) => a -> Union l toUnionZero = toUnion' True   -- | Create a new union from one of the union types-toUnion' :: forall a l . (Storable (Union l), Storable a, IsMember a l ~ 'True) => Bool -> a -> Union l+toUnion' :: forall a l . (Storable (Union l), Storable a, Member a l) => Bool -> a -> Union l toUnion' zero v = unsafePerformIO $ do    let sz = sizeOfT @(Union l)    fp <- mallocForeignPtrBytes (fromIntegral sz)