#include "fusion-phases.h"
module Data.Array.Parallel.PArray.PRepr.Instances where
import Data.Array.Parallel.PArray.Types
import Data.Array.Parallel.PArray.PRepr.Base
import Data.Array.Parallel.PArray.PData.Base
import Data.Array.Parallel.PArray.PData.Void
import Data.Array.Parallel.PArray.PData.Sum2
import Data.Array.Parallel.PArray.PData.Word8
import Data.Array.Parallel.PArray.PData.Wrap ()
import Data.Array.Parallel.PArray.PData.Unit ()
import Data.Array.Parallel.PArray.PData.Nested ()
import Data.Array.Parallel.PArray.PData.Tuple2 ()
import Data.Array.Parallel.PArray.PData.Int ()
import Data.Array.Parallel.PArray.PData.Double ()
import qualified Data.Array.Parallel.Unlifted as U
import qualified Data.Vector as V
import Data.Word
type instance PRepr Void = Void
instance PA Void where
toPRepr = id
fromPRepr = id
toArrPRepr = id
fromArrPRepr = id
toArrPReprs = id
fromArrPReprs = id
type instance PRepr () = ()
instance PA () where
toPRepr = id
fromPRepr = id
toArrPRepr = id
fromArrPRepr = id
toArrPReprs = id
fromArrPReprs = id
type instance PRepr Int = Int
instance PA Int where
toPRepr = id
fromPRepr = id
toArrPRepr = id
fromArrPRepr = id
toArrPReprs = id
fromArrPReprs = id
type instance PRepr Word8 = Word8
instance PA Word8 where
toPRepr = id
fromPRepr = id
toArrPRepr = id
fromArrPRepr = id
toArrPReprs = id
fromArrPReprs = id
type instance PRepr Double = Double
instance PA Double where
toPRepr = id
fromPRepr = id
toArrPRepr = id
fromArrPRepr = id
toArrPReprs = id
fromArrPReprs = id
type instance PRepr Bool
= Sum2 Void Void
data instance PData Bool
= PBool U.Sel2
data instance PDatas Bool
= PBools (V.Vector U.Sel2)
instance PA Bool where
toPRepr False = Alt2_1 void
toPRepr True = Alt2_2 void
fromPRepr (Alt2_1 _) = False
fromPRepr (Alt2_2 _) = True
toArrPRepr (PBool sel)
= PSum2 sel pvoid pvoid
fromArrPRepr (PSum2 sel _ _)
= PBool sel
toArrPReprs (PBools sels)
= PSum2s sels
(pvoids $ V.length sels)
(pvoids $ V.length sels)
fromArrPReprs (PSum2s sels _ _)
= PBools sels
type instance PRepr Ordering
= Word8
data instance PData Ordering
= POrdering (U.Array Word8)
data instance PDatas Ordering
= POrderings (U.Arrays Word8)
instance PA Ordering where
toPRepr LT = 0
toPRepr EQ = 1
toPRepr GT = 2
fromPRepr 0 = LT
fromPRepr 1 = EQ
fromPRepr 2 = GT
fromPRepr _ = error "dph-prim-vseg: bad value converting Word8 to Ordering"
toArrPRepr (POrdering arr)
= PWord8 arr
fromArrPRepr (PWord8 arr)
= POrdering arr
toArrPReprs (POrderings arrs)
= PWord8s arrs
fromArrPReprs (PWord8s arrs)
= POrderings arrs
type instance PRepr (Either a b)
= Sum2 a b
data instance PData (Either a b)
= PEither U.Sel2 (PData a) (PData b)
data instance PDatas (Either a b)
= PEithers (V.Vector U.Sel2) (PDatas a) (PDatas b)
instance (PR a, PR b) => PA (Either a b) where
toPRepr xx
= case xx of
Left x -> Alt2_1 x
Right y -> Alt2_2 y
fromPRepr (Alt2_1 x) = Left x
fromPRepr (Alt2_2 x) = Right x
toArrPRepr (PEither sel pdata1 pdata2)
= PSum2 sel pdata1 pdata2
fromArrPRepr (PSum2 sel pdata1 pdata2)
= PEither sel pdata1 pdata2
toArrPReprs (PEithers sels pdatas1 pdatas2)
= PSum2s sels pdatas1 pdatas2
fromArrPReprs (PSum2s sels pdatas1 pdatas2)
= PEithers sels pdatas1 pdatas2