Skip to content

Commit

Permalink
Import orphan Storable (Complex a) instance from base-orphans
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanGlScott committed Jun 8, 2015
1 parent 7d8355a commit c06658d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
17 changes: 1 addition & 16 deletions Numeric/Jalla/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module Numeric.Jalla.Types (
) where

import Data.Complex
import Data.Orphans ()
import Foreign.C.Types
import Foreign.Marshal.Array
import Foreign
Expand Down Expand Up @@ -90,22 +91,6 @@ class LAPACKEEnum e le where
f :: Complex a -> a
f _ = undefined

instance (RealFloat a, Storable a) => Storable (Complex a) where
-- sizeOf c = s where s = 2 * (sizeOf (f c))
sizeOf = (2 *) . sizeOf . f
alignment = alignment . f

peek p = peek p1 >>= \r -> peek p2 >>= \i -> return $ r :+ i
where
p1 = castPtr p
p2 = advancePtr p1 1

poke p c = poke p' r >> poke (advancePtr p' 1) i
where p' = castPtr p
r = realPart c
i = imagPart c


{-| Defines a scalar type for each field type. Those are 'Complex' 'CFloat'
and 'CFloat', as well as 'Complex' 'CDouble' and 'CDouble'. -}
class (Num e, Floating e, Show e) => Field1 e where
Expand Down
2 changes: 1 addition & 1 deletion jalla.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Library
Numeric.Jalla.Types
Numeric.Jalla.Test

build-depends: base > 4.0.0 && < 4.7.1, mtl -any,
build-depends: base > 4.0.0 && < 4.7.1, base-orphans (>= 0.3.2), mtl -any,
convertible -any, random (>=1.0.1), QuickCheck (>= 2.4.2)

buildable: True
Expand Down

0 comments on commit c06658d

Please sign in to comment.