repa-scalar 4.2.1.1 → 4.2.2.1
raw patch · 4 files changed
+50/−6 lines, 4 files
Files
- Data/Repa/Scalar/Box.hs +22/−5
- Data/Repa/Scalar/Option.hs +24/−0
- Data/Repa/Scalar/Product.hs +3/−0
- repa-scalar.cabal +1/−1
Data/Repa/Scalar/Box.hs view
@@ -1,6 +1,7 @@ module Data.Repa.Scalar.Box- ( Box (..))+ ( Box (..)+ , box, unbox) where import qualified Data.Vector as V import qualified Data.Vector.Unboxed as U@@ -8,6 +9,7 @@ import qualified Data.Vector.Generic.Mutable as GM + -- | Strict, boxed wrapper for a value. -- -- Useful as a default case when defining instances for polytypic @@ -17,6 +19,23 @@ deriving (Eq, Show) +-- | Put a value in a box.+box :: a -> Box a+box !x = Box x+{-# INLINE box #-}+++-- | Take the value from the box.+unbox :: Box a -> a+unbox (Box x) = x+{-# INLINE unbox #-}+++instance Functor Box where+ fmap f (Box x) = Box (f x)+ {-# INLINE fmap #-}++ -- Unboxed ---------------------------------------------------------------------------------------- -- Unboxed instance adapted from: -- http://code.haskell.org/vector/internal/unbox-tuple-instances@@ -33,8 +52,7 @@ !(V.MVector s a) -instance U.Unbox a- => GM.MVector U.MVector (Box a) where+instance GM.MVector U.MVector (Box a) where basicLength (MV_Box n _as) = n {-# INLINE basicLength #-}@@ -88,8 +106,7 @@ {-# INLINE basicUnsafeGrow #-} -instance U.Unbox a- => G.Vector U.Vector (Box a) where+instance G.Vector U.Vector (Box a) where basicUnsafeFreeze (MV_Box n as) = do as' <- G.basicUnsafeFreeze as
Data/Repa/Scalar/Option.hs view
@@ -44,6 +44,12 @@ {-# INLINE fromOption #-} +instance Functor Option where+ fmap _ None = None+ fmap f (Some x) = Some (f x)+ {-# INLINE fmap #-}++ ------------------------------------------------------------------------------- -- | A strict `Maybe` type, with two parameters. data Option2 a b@@ -66,6 +72,12 @@ {-# INLINE fromOption2 #-} +instance Functor (Option2 a) where+ fmap _ None2 = None2+ fmap f (Some2 x y) = Some2 x (f y)+ {-# INLINE fmap #-}++ ------------------------------------------------------------------------------- -- | A strict `Maybe` type with three parameters. data Option3 a b c@@ -88,6 +100,12 @@ {-# INLINE fromOption3 #-} +instance Functor (Option3 a b) where+ fmap _ None3 = None3+ fmap f (Some3 x y z) = Some3 x y (f z)+ {-# INLINE fmap #-}++ ------------------------------------------------------------------------------- -- | A strict `Maybe` type with four parameters. data Option4 a b c d@@ -108,4 +126,10 @@ fromOption4 None4 = Nothing fromOption4 (Some4 x1 x2 x3 x4) = Just (x1, x2, x3, x4) {-# INLINE fromOption4 #-}+++instance Functor (Option4 a b c) where+ fmap _ None4 = None4+ fmap f (Some4 x y z a) = Some4 x y z (f a)+ {-# INLINE fmap #-}
Data/Repa/Scalar/Product.hs view
@@ -30,6 +30,9 @@ infixr :*: +instance Functor ((:*:) a) where+ fmap f ((:*:) x y) = (:*:) x (f y)+ -- | Sequences of products that form a valid list, -- using () for the nil value.
repa-scalar.cabal view
@@ -1,5 +1,5 @@ Name: repa-scalar-Version: 4.2.1.1+Version: 4.2.2.1 License: BSD3 License-file: LICENSE Author: The Repa Development Team