packages feed

sdp-binary (empty) → 0.2

raw patch · 4 files changed

+132/−0 lines, 4 filesdep +basedep +binarydep +sdpsetup-changed

Dependencies added: base, binary, sdp

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Andrey Mulik (c) 2020++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Andrey Mulik nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ sdp-binary.cabal view
@@ -0,0 +1,45 @@+name:          sdp-binary+version:       0.2+category:      Data Structures++synopsis:      Binary instances for SDP+description:   SDP extension for binary serialisation.++author:        Andrey Mulik+maintainer:    work.a.mulik@gmail.com+bug-reports:   https://github.com/andreymulik/sdp-binary/issues++copyright:     2020 Andrey Mulik+license-file:  LICENSE+license:       BSD3++build-type:    Simple+cabal-version: >=1.10++source-repository head+  type: git+  location: https://github.com/andreymulik/sdp-binary++---            _      _____ ______ ______   ___  ______ __   __              ---+---           | |    |_   _|| ___ \| ___ \ / _ \ | ___ \\ \ / /              ---+---           | |      | |  | |_/ /| |_/ // /_\ \| |_/ / \ V /               ---+---           | |      | |  | ___ \|    / |  _  ||    /   \ /                ---+---           | |____ _| |_ | |_/ /| |\ \ | | | || |\ \   | |                ---+---           \_____/ \___/ \____/ \_| \_|\_| |_/\_| \_|  \_/                ---++Library+  default-language: Haskell2010+  hs-source-dirs:   src+  +  build-depends:+    base         >= 4.12 && < 5,+    sdp          >= 0.2  && < 1,+    binary       >= 0.8  && < 1+  +  ghc-options: -Wall -Wno-orphans -Wcompat+  +  exposed-modules:+    SDP.Binary+++
+ src/SDP/Binary.hs view
@@ -0,0 +1,55 @@+{-# LANGUAGE FlexibleInstances, MagicHash #-}++{- |+    Module      :  SDP.Binary+    Copyright   :  (c) Andrey Mulik 2020+    License     :  BSD-style+    Maintainer  :  work.a.mulik@gmail.com+    Portability :  portable+    +    @SDP.Binary@ provides @sdp@ instances for binary.+-}+module SDP.Binary+(+  -- * Export+  module Data.Binary+)+where++import Prelude ()+import SDP.SafePrelude+import SDP.Unboxed+import SDP.Linear++import SDP.Templates.AnyBorder+import SDP.Templates.AnyChunks++import SDP.Prim.SArray+import SDP.Prim.SBytes++import Data.Binary++default ()++--------------------------------------------------------------------------------++instance (Binary e) => Binary (SArray# e)+  where+    get = do n <- get; fromListN n <$> replicateM n get+    put = putList . listL++instance (Binary e, Unboxed e) => Binary (SBytes# e)+  where+    get = do n <- get; fromListN n <$> replicateM n get+    put = putList . listL++instance (Nullable (rep e), Binary (rep e)) => Binary (AnyChunks rep e)+  where+    put = \ es -> let cs = toChunks es in do put (sizeOf cs); putList cs+    get = do n <- get; fromChunks <$> replicateM n get++instance (Binary i, Index i, Binary (rep e)) => Binary (AnyBorder rep i e)+  where+    put = \ (AnyBorder l u es) -> do put l; put u; put es+    get = liftA3 AnyBorder get get get+