{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_HADDOCK hide #-}
module Data.Array.Accelerate.AST.Var
where
import Data.Array.Accelerate.Representation.Type
import Data.Array.Accelerate.AST.Idx
import Language.Haskell.TH.Extra
data Var s env t = Var (s t) (Idx env t)
type Vars s env = TupR (Var s env)
varsType :: Vars s env t -> TupR s t
varsType :: forall (s :: * -> *) env t. Vars s env t -> TupR s t
varsType TupR (Var s env) t
TupRunit = TupR s t
TupR s ()
forall (s :: * -> *). TupR s ()
TupRunit
varsType (TupRsingle (Var s t
t Idx env t
_)) = s t -> TupR s t
forall (s :: * -> *) a. s a -> TupR s a
TupRsingle s t
t
varsType (TupRpair TupR (Var s env) a1
a TupR (Var s env) b
b) = TupR s a1 -> TupR s b -> TupR s (a1, b)
forall (s :: * -> *) a1 b. TupR s a1 -> TupR s b -> TupR s (a1, b)
TupRpair (TupR (Var s env) a1 -> TupR s a1
forall (s :: * -> *) env t. Vars s env t -> TupR s t
varsType TupR (Var s env) a1
a) (TupR (Var s env) b -> TupR s b
forall (s :: * -> *) env t. Vars s env t -> TupR s t
varsType TupR (Var s env) b
b)
rnfVar :: (forall b. s b -> ()) -> Var s env t -> ()
rnfVar :: forall (s :: * -> *) env t.
(forall b. s b -> ()) -> Var s env t -> ()
rnfVar forall b. s b -> ()
f (Var s t
t Idx env t
idx) = s t -> ()
forall b. s b -> ()
f s t
t () -> () -> ()
forall a b. a -> b -> b
`seq` Idx env t -> ()
forall env t. Idx env t -> ()
rnfIdx Idx env t
idx
rnfVars :: (forall b. s b -> ()) -> Vars s env t -> ()
rnfVars :: forall (s :: * -> *) env t.
(forall b. s b -> ()) -> Vars s env t -> ()
rnfVars forall b. s b -> ()
f = (forall b. Var s env b -> ()) -> TupR (Var s env) t -> ()
forall (s :: * -> *) a. (forall b. s b -> ()) -> TupR s a -> ()
rnfTupR ((forall b. s b -> ()) -> Var s env b -> ()
forall (s :: * -> *) env t.
(forall b. s b -> ()) -> Var s env t -> ()
rnfVar s b -> ()
forall b. s b -> ()
f)
liftVar :: (forall b. s b -> CodeQ (s b)) -> Var s env t -> CodeQ (Var s env t)
liftVar :: forall (s :: * -> *) env t.
(forall b. s b -> CodeQ (s b))
-> Var s env t -> CodeQ (Var s env t)
liftVar forall b. s b -> CodeQ (s b)
f (Var s t
s Idx env t
idx) = [|| s t -> Idx env t -> Var s env t
forall (s :: * -> *) env t. s t -> Idx env t -> Var s env t
Var $$(s t -> CodeQ (s t)
forall b. s b -> CodeQ (s b)
f s t
s) $$(Idx env t -> CodeQ (Idx env t)
forall env t. Idx env t -> CodeQ (Idx env t)
liftIdx Idx env t
idx) ||]
liftVars :: (forall b. s b -> CodeQ (s b)) -> Vars s env t -> CodeQ (Vars s env t)
liftVars :: forall (s :: * -> *) env t.
(forall b. s b -> CodeQ (s b))
-> Vars s env t -> CodeQ (Vars s env t)
liftVars forall b. s b -> CodeQ (s b)
f = (forall b. Var s env b -> CodeQ (Var s env b))
-> TupR (Var s env) t -> CodeQ (TupR (Var s env) t)
forall (s :: * -> *) a.
(forall b. s b -> CodeQ (s b)) -> TupR s a -> CodeQ (TupR s a)
liftTupR ((forall b. s b -> CodeQ (s b))
-> Var s env b -> CodeQ (Var s env b)
forall (s :: * -> *) env t.
(forall b. s b -> CodeQ (s b))
-> Var s env t -> CodeQ (Var s env t)
liftVar s b -> CodeQ (s b)
forall b. s b -> CodeQ (s b)
f)