module Data.Array.Parallel.Base.Hyperstrict (
(:*:)(..),
fstS, sndS, pairS, unpairS, curryS, uncurryS,
unsafe_pairS, unsafe_unpairS,
EitherS(..),
MaybeS(..), maybeS, fromMaybeS,
Lazy(..),
HS
) where
import GHC.Word ( Word8 )
infixl 2 :*:
data (:*:) a b = !a :*: !b deriving(Eq,Ord,Show,Read)
fstS :: a :*: b -> a
fstS (x :*: _) = x
sndS :: a :*: b -> b
sndS (_ :*: y) = y
pairS :: (a,b) -> a :*: b
pairS = uncurry (:*:)
unpairS :: a :*: b -> (a,b)
unpairS (x :*: y) = (x,y)
curryS :: (a :*: b -> c) -> a -> b -> c
curryS f x y = f (x :*: y)
uncurryS :: (a -> b -> c) -> a :*: b -> c
uncurryS f (x :*: y) = f x y
unsafe_pairS :: (a,b) -> a :*: b
unsafe_pairS (a,b) = a :*: b
unsafe_unpairS :: a :*: b -> (a,b)
unsafe_unpairS (x :*: y) = (x,y)
data EitherS a b = LeftS !a | RightS !b
data MaybeS a = NothingS | JustS !a
instance Functor MaybeS where
fmap f (JustS x) = JustS (f x)
fmap f NothingS = NothingS
maybeS :: b -> (a -> b) -> MaybeS a -> b
maybeS b f (JustS a) = f a
maybeS b f NothingS = b
fromMaybeS :: a -> MaybeS a -> a
fromMaybeS x (JustS y) = y
fromMaybeS x NothingS = x
data Lazy a = Lazy a deriving(Eq, Ord, Show, Read)
instance Functor Lazy where
fmap f (Lazy x) = Lazy (f x)
class HS a
instance HS ()
instance HS Bool
instance HS Char
instance HS Int
instance HS Word8
instance HS Float
instance HS Double
instance (HS a, HS b) => HS (a :*: b)
instance (HS a, HS b) => HS (EitherS a b)
instance HS a => HS (MaybeS a)