packages feed

storable-tuple (empty) → 0.0.1

raw patch · 4 files changed

+160/−0 lines, 4 filesdep +basedep +special-functorsdep +storable-recordsetup-changed

Dependencies added: base, special-functors, storable-record, utility-ht

Files

+ LICENSE view
@@ -0,0 +1,27 @@+Copyright (c) Henning Thielemann 2009++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions+are met:+1. Redistributions of source code must retain the above copyright+   notice, this list of conditions and the following disclaimer.+2. 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.+3. Neither the name of the author nor the names of his contributors+   may be used to endorse or promote products derived from this software+   without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 AUTHORS 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.lhs view
@@ -0,0 +1,3 @@+#! /usr/bin/env runhaskell+> import Distribution.Simple+> main = defaultMain
+ src/Foreign/Storable/Tuple.hs view
@@ -0,0 +1,80 @@+{-+This should be in the standard library.+-}+module Foreign.Storable.Tuple where++import Foreign.Storable (Storable (..), )+import qualified Foreign.Storable.Record as Store+import Control.Applicative (liftA2, liftA3, pure, (<*>), )++import Data.Tuple.HT (fst3, snd3, thd3, )+++instance (Storable a, Storable b) => Storable (a,b) where+   sizeOf    = Store.sizeOf storePair+   alignment = Store.alignment storePair+   peek      = Store.peek storePair+   poke      = Store.poke storePair++storePair ::+   (Storable a, Storable b) =>+   Store.Dictionary (a,b)+storePair =+   Store.run $+   liftA2 (,)+      (Store.element fst)+      (Store.element snd)+++instance (Storable a, Storable b, Storable c) => Storable (a,b,c) where+   sizeOf    = Store.sizeOf storeTriple+   alignment = Store.alignment storeTriple+   peek      = Store.peek storeTriple+   poke      = Store.poke storeTriple++storeTriple ::+   (Storable a, Storable b, Storable c) =>+   Store.Dictionary (a,b,c)+storeTriple =+   Store.run $+   liftA3 (,,)+      (Store.element fst3)+      (Store.element snd3)+      (Store.element thd3)++instance (Storable a, Storable b, Storable c, Storable d) => Storable (a,b,c,d) where+   sizeOf    = Store.sizeOf storeQuadruple+   alignment = Store.alignment storeQuadruple+   peek      = Store.peek storeQuadruple+   poke      = Store.poke storeQuadruple++storeQuadruple ::+   (Storable a, Storable b, Storable c, Storable d) =>+   Store.Dictionary (a,b,c,d)+storeQuadruple =+   Store.run $+   pure (,,,)+      <*> (Store.element $ \(x,_,_,_) -> x)+      <*> (Store.element $ \(_,x,_,_) -> x)+      <*> (Store.element $ \(_,_,x,_) -> x)+      <*> (Store.element $ \(_,_,_,x) -> x)+{-+   liftA4 (,,,)+      (Store.element $ \(x,_,_,_) -> x)+      (Store.element $ \(_,x,_,_) -> x)+      (Store.element $ \(_,_,x,_) -> x)+      (Store.element $ \(_,_,_,x) -> x)+-}+++{-+{- Why is this allowed? -}+test :: Char+test = const 'a' undefined++{- Why is type defaulting applied here? The type of 'c' should be fixed. -}+test1 :: (Integral a, RealField.C a) => a+test1 =+   let c = undefined+   in  asTypeOf (round c) c+-}
+ storable-tuple.cabal view
@@ -0,0 +1,50 @@+Name:         storable-tuple+Version:      0.0.1+Category:     Data, Foreign+Synopsis:     Storable instance for pairs and triples+Description:+  Provides a Storable instance for pair and triple+  which should be binary compatible with C99 and C++.++  The only purpose of this package is to provide a standard location+  for this instance so that other packages needing this instance+  can play nicely together. +License:             BSD3+License-file:        LICENSE+Author:              Henning Thielemann <storable@henning-thielemann.de>+Maintainer:          Henning Thielemann <storable@henning-thielemann.de>+Homepage:            http://code.haskell.org/~thielema/storable-tuple/+Stability:           Experimental+Build-Type:          Simple+Tested-With:         GHC==6.8.2+Cabal-Version:       >=1.6++Source-Repository head+  Type:     darcs+  Location: http://code.haskell.org/~thielema/storable-tuple/++Source-Repository this+  Type:     darcs+  Location: http://code.haskell.org/~thielema/storable-tuple/+  Tag:      0.0.1++Flag splitBase+  description: Choose the new smaller, split-up base package.++Library+  Build-Depends:+    storable-record >=0.0.1 && <0.1,+    utility-ht >=0.0.1 && <0.1+  If flag(splitBase)+    Build-Depends:+      base >= 3 && <5+  Else+    Build-Depends:+      special-functors >= 1.0 && <1.1,+      base >= 1.0 && < 2++  GHC-Options:         -Wall+  Hs-Source-Dirs:      src++  Exposed-Modules:+    Foreign.Storable.Tuple