module ADP.Fusion.SynVar.Indices.Classes where
import Data.Proxy (Proxy(..))
import Data.Vector.Fusion.Stream.Monadic (map,Stream,head,mapM,flatten,Step(..))
import Prelude hiding (map,head,mapM)
import Data.PrimitiveArray hiding (map)
import ADP.Fusion.Core.Classes
import ADP.Fusion.Core.Multi
import ADP.Fusion.Core.TyLvlIx
class AddIndexDense s u c i where
addIndexDenseGo
:: (Monad m)
=> c -> Context i -> u -> u -> i -> i -> Stream m (SvState s a Z Z) -> Stream m (SvState s a u i)
instance AddIndexDense a Z Z Z where
addIndexDenseGo _ _ _ _ _ _ = id
data SvState s a u i = SvS
{ sS :: !s
, tx :: !u
, iIx :: !(RunningIndex i)
}
addIndexDense
:: ( Monad m
, AddIndexDense s u c i
, s ~ Elm x0 i0
, Element x0 i0
)
=> c -> Context i -> u -> u -> i -> i -> Stream m s -> Stream m (s,u,RunningIndex i)
addIndexDense t c lb ub u i = map (\(SvS s z i') -> (s,z,i')) . addIndexDenseGo t c lb ub u i . map (\s -> (SvS s Z RiZ))
addIndexDense1
:: ( Monad m
, AddIndexDense (Elm (SynVar1 (Elm x0 a)) (Z:.i)) (Z:.u) (Z:.c) (Z:.i)
, GetIndex (Z:.a) (Z:.i)
, s ~ Elm x0 a
, Element x0 a
)
=> c -> Context i -> u -> u -> i -> i -> Stream m s -> Stream m (s,u,RunningIndex i)
addIndexDense1 t c lb ub u i = map (\(SvS (ElmSynVar1 s) (Z:.z) (RiZ:.:i')) -> (s,z,i'))
. addIndexDenseGo (Z:.t) (Z:.c) (Z:.lb) (Z:.ub) (Z:.u) (Z:.i)
. map (\s -> (SvS (elmSynVar1 s i) Z RiZ))
newtype SynVar1 s = SynVar1 s
elmSynVar1 :: s -> i -> Elm (SynVar1 s) (Z:.i)
elmSynVar1 s _ = ElmSynVar1 s
instance (s ~ Elm x0 i, Element x0 i) => Element (SynVar1 s) (Z:.i) where
newtype Elm (SynVar1 s) (Z:.i) = ElmSynVar1 s
getIdx (ElmSynVar1 s) = RiZ :.: getIdx s
type IndexHdr s x0 i0 us u cs c is i =
( AddIndexDense s us cs is
, GetIndex (RunningIndex i0) (RunningIndex (is:.i))
, GetIx (RunningIndex i0) (RunningIndex (is:.i)) ~ (RunningIndex i)
, Element x0 i0
, s ~ Elm x0 i0
)