storable-complex (empty) → 0.1
raw patch · 4 files changed
+86/−0 lines, 4 filesdep +basesetup-changed
Dependencies added: base
Files
- Foreign/Storable/Complex.hs +35/−0
- LICENSE +31/−0
- Setup.lhs +3/−0
- storable-complex.cabal +17/−0
+ Foreign/Storable/Complex.hs view
@@ -0,0 +1,35 @@+-----------------------------------------------------------------------------+-- |+-- Module : Data.Array.CArray.Base+-- Copyright : (c) 2008 Jed Brown+-- License : BSD-style+-- +-- Maintainer : jed@59A2.org+-- Stability : provisional+-- Portability : portable+--+-- This module provides a Storable instance for Complex which is binary+-- compatible with C99, C++ and Fortran complex data types. It's only purpose+-- is to provide a standard location for this instance so that other packages+-- needing this instance can play nicely together.+--+-----------------------------------------------------------------------------++module Foreign.Storable.Complex () where++import Data.Complex+import Foreign.Storable+import Foreign.Ptr++-- This Storable instance for Complex is binary compatible with C99, C++ and+-- Fortran complex data types.+instance (RealFloat a, Storable a) => Storable (Complex a) where+ sizeOf z = 2 * sizeOf (realPart z)+ alignment z = sizeOf (realPart z)+ peek p = do let q = castPtr p+ r <- peek q+ i <- peekElemOff q 1+ return (r :+ i)+ poke p (r :+ i) = do let q = (castPtr p)+ poke q r+ pokeElemOff q 1 i
+ LICENSE view
@@ -0,0 +1,31 @@+Copyright Jed Brown 2008++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 Jed Brown 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.lhs view
@@ -0,0 +1,3 @@+#!/usr/bin/env runhaskell+> import Distribution.Simple+> main = defaultMain
+ storable-complex.cabal view
@@ -0,0 +1,17 @@+name: storable-complex+version: 0.1+synopsis: Storable instance for Complex+description: Provides a Storable instance for Complex which is binary+ compatible with C99, C++ and Fortran complex data types.+ .+ 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.+category: Data+license: BSD3+license-file: LICENSE+author: Jed Brown +maintainer: <jed@59A2.org>+build-Depends: base+exposed-modules: Foreign.Storable.Complex+build-type: Simple