{-# LANGUAGE GADTs #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_HADDOCK hide #-}
module Data.Array.Accelerate.AST.Idx
where
import Language.Haskell.TH
data Idx env t where
ZeroIdx :: Idx (env, t) t
SuccIdx :: Idx env t -> Idx (env, s) t
data PairIdx p a where
PairIdxLeft :: PairIdx (a, b) a
PairIdxRight :: PairIdx (a, b) b
idxToInt :: Idx env t -> Int
idxToInt ZeroIdx = 0
idxToInt (SuccIdx idx) = 1 + idxToInt idx
rnfIdx :: Idx env t -> ()
rnfIdx ZeroIdx = ()
rnfIdx (SuccIdx ix) = rnfIdx ix
liftIdx :: Idx env t -> Q (TExp (Idx env t))
liftIdx ZeroIdx = [|| ZeroIdx ||]
liftIdx (SuccIdx ix) = [|| SuccIdx $$(liftIdx ix) ||]