module ADP.Fusion.Term.Chr.Type where
import Data.Strict.Tuple
import qualified Data.Vector.Generic as VG
import Data.PrimitiveArray
import ADP.Fusion.Core.Classes
import ADP.Fusion.Core.Multi
data Chr r x where
Chr :: VG.Vector v x
=> (v x -> Int -> r)
-> !(v x)
-> Chr r x
chr :: VG.Vector v x => v x -> Chr x x
chr = Chr VG.unsafeIndex
chrLeft xs = Chr f xs where
f xs k = ( xs VG.!? (k1)
, VG.unsafeIndex xs k
)
instance Build (Chr r x)
instance
( Element ls i
) => Element (ls :!: Chr r x) i where
data Elm (ls :!: Chr r x) i = ElmChr !r !(RunningIndex i) !(Elm ls i)
type Arg (ls :!: Chr r x) = Arg ls :. r
getArg (ElmChr x _ ls) = getArg ls :. x
getIdx (ElmChr _ i _ ) = i
deriving instance (Show i, Show (RunningIndex i), Show r, Show (Elm ls i)) => Show (Elm (ls :!: Chr r x) i)
type instance TermArg (Chr r x) = r