Commit d09e5f4a authored by rl@cse.unsw.edu.au's avatar rl@cse.unsw.edu.au
Browse files

Rename utility functions

parent bb726d81
module Data.Array.Parallel.Lifted.Closure (
(:->)(..), PArray(..),
($:), ($:^), closurePA
mkClosure, mkClosureP, ($:), ($:^), closurePA
) where
import Data.Array.Parallel.Lifted.PArray
......@@ -15,9 +15,17 @@ data a :-> b = forall e. Clo !(PA e)
!(PArray e -> PArray a -> PArray b)
e
-- |Closure construction
--
mkClosure :: forall a b e.
PA e -> (e -> a -> b) -> (PArray e -> PArray a -> PArray b) -> e
-> (a :-> b)
{-# INLINE mkClosure #-}
mkClosure = Clo
-- |Closure application
--
($:) :: (a :-> b) -> a -> b
($:) :: forall a b. (a :-> b) -> a -> b
{-# INLINE ($:) #-}
Clo _ f _ e $: a = f e a
......@@ -29,24 +37,32 @@ data instance PArray (a :-> b) = forall e.
!(PArray e -> PArray a -> PArray b)
!(PArray e)
-- |Lifted closure construction
--
mkClosureP :: forall a b e.
PA e -> (e -> a -> b) -> (PArray e -> PArray a -> PArray b)
-> PArray e -> PArray (a :-> b)
{-# INLINE mkClosureP #-}
mkClosureP = AClo
-- |Lifted closure application
--
($:^) :: PArray (a :-> b) -> PArray a -> PArray b
($:^) :: forall a b. PArray (a :-> b) -> PArray a -> PArray b
{-# INLINE ($:^) #-}
AClo _ _ f es $:^ as = f es as
closure_lengthP :: PArray (a :-> b) -> Int
{-# INLINE closure_lengthP #-}
closure_lengthP (AClo pa _ _ es) = lengthP pa es
closure_lengthPA :: PArray (a :-> b) -> Int
{-# INLINE closure_lengthPA #-}
closure_lengthPA (AClo pa _ _ es) = lengthPA pa es
closure_replicateP :: Int -> (a :-> b) -> PArray (a :-> b)
{-# INLINE closure_replicateP #-}
closure_replicateP n (Clo pa f f' e) = AClo pa f f' (replicateP pa n e)
closure_replicatePA :: Int -> (a :-> b) -> PArray (a :-> b)
{-# INLINE closure_replicatePA #-}
closure_replicatePA n (Clo pa f f' e) = AClo pa f f' (replicatePA pa n e)
-- |Closure dictionary
closurePA :: PA (a :-> b)
closurePA = PA {
lengthP = closure_lengthP
, replicateP = closure_replicateP
lengthPA = closure_lengthPA
, replicatePA = closure_replicatePA
}
......@@ -9,7 +9,7 @@ data family PArray a
-- |Dictionaries
--
data PA a = PA {
lengthP :: PArray a -> Int
, replicateP :: Int -> a -> PArray a
lengthPA :: PArray a -> Int
, replicatePA :: Int -> a -> PArray a
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment