storable-complex-0.2.1/0000755000000000000000000000000011323660541013161 5ustar0000000000000000storable-complex-0.2.1/Setup.lhs0000644000000000000000000000011411323660541014765 0ustar0000000000000000#!/usr/bin/env runhaskell > import Distribution.Simple > main = defaultMain storable-complex-0.2.1/LICENSE0000644000000000000000000000275011323660541014172 0ustar0000000000000000Copyright 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. storable-complex-0.2.1/storable-complex.cabal0000644000000000000000000000127511323660541017432 0ustar0000000000000000name: storable-complex version: 0.2.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: build-Depends: base >= 3 && < 5 exposed-modules: Foreign.Storable.Complex build-type: Simple storable-complex-0.2.1/Foreign/0000755000000000000000000000000011323660541014552 5ustar0000000000000000storable-complex-0.2.1/Foreign/Storable/0000755000000000000000000000000011323660541016325 5ustar0000000000000000storable-complex-0.2.1/Foreign/Storable/Complex.hs0000644000000000000000000000242311323660541020271 0ustar0000000000000000----------------------------------------------------------------------------- -- | -- 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 = alignment (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