transformations-0.2.0.0: Generic representation of tree transformations

Safe HaskellNone
LanguageHaskell98

Generics.MultiRec.Transformations.MemoTable

Documentation

type family Ixs phi :: [*] Source

data HList l where Source

Constructors

HNil :: HList [] 
HCons :: h -> HList t -> HList (h : t) 

type family HMap h f g l :: [*] Source

Instances

type HMap h f g ([] *) = [] * 
type HMap h f g ((:) * t ts) = (:) * (h (f t) (g t)) (HMap h f g ts) 

type MemoTable phi top ixs = HList (MemoTable' One phi top ixs) Source

data Type Source

Constructors

One 
Two 

type family MemoTable' x phi top ixs :: [*] Source

Instances

type MemoTable' x phi top ([] *) = [] * 
type MemoTable' x phi top ((:) * t ts) = (:) * (MemCell x phi top t) (MemoTable' x phi top ts) 

type family MemCell x phi top t :: * Source

Instances

type MemCell Two phi top t = [(Path phi t top, t)] 
type MemCell One phi top t = Map (MemKey t) (MemVal phi top t) 

type MemKey t = (Bool, t, t) Source

type MemVal phi top t = [Insert phi top t] Source

data Proxy t Source

Constructors

Proxy 

class Lookup phi ixs ix where Source

Methods

lookupMT :: Proxy `(phi, ixs)` -> MemoTable phi top ixs -> MemKey ix -> Maybe (MemVal phi top ix) Source

insertMT :: Proxy `(phi, ixs)` -> MemKey ix -> MemVal phi top ix -> MemoTable phi top ixs -> MemoTable phi top ixs Source

Instances

Lookup phi ([] *) ix 
Lookup phi ts ix => Lookup phi ((:) * t ts) ix 
Ord t => Lookup phi ((:) * t ts) t 

type Memo phi top a = State (MemoTable phi top (Ixs phi)) a Source

class EmptyMemo phi top ixs where Source

Methods

emptyMemo :: Proxy `(phi, top, ixs)` -> MemoTable phi top ixs Source

Instances

EmptyMemo phi top ([] *) 
EmptyMemo phi top t => EmptyMemo phi top ((:) * h t) 

runMemo :: forall phi top a. EmptyMemo phi top (Ixs phi) => Proxy `(phi, top)` -> Memo phi top a -> a Source

recMemo :: forall phi top ix. (Fam phi, Children phi (PF phi) ix, Lookup phi (Ixs phi) ix, Eq ix, GetChildrenTable phi (Ixs phi) ix) => (forall ix. (Children phi (PF phi) ix, Lookup phi (Ixs phi) ix, Eq ix, GetChildrenTable phi (Ixs phi) ix) => Bool -> phi ix -> ix -> ix -> Memo phi top [Insert phi top ix]) -> Bool -> phi ix -> ix -> ix -> Memo phi top [Insert phi top ix] Source

type ChildTable phi top ixs = MemoTable' Two phi top ixs Source

class ChildrenTable phi top ixs where Source

Methods

childrenTable :: Proxy `(phi, top, ixs)` -> top -> HList (ChildTable phi top ixs) Source

Instances

ChildrenTable phi top ([] *) 
(Fam phi, El phi h, El phi top, Children phi (PF phi) h, ChildrenTable phi top t) => ChildrenTable phi top ((:) * h t) 
(Fam phi, El phi top, Children phi (PF phi) top, ChildrenTable phi top t) => ChildrenTable phi top ((:) * top t) 

class GetChildrenTable phi ixs ix where Source

Methods

getChTable :: Proxy `(phi, top, ixs)` -> HList (ChildTable phi top ixs) -> MemCell Two phi top ix Source

Instances

GetChildrenTable phi ([] *) ix 
GetChildrenTable phi ts ix => GetChildrenTable phi ((:) * t ts) ix 
Ord t => GetChildrenTable phi ((:) * t ts) t