ADPfusion-0.4.0.1: Efficient, high-level dynamic programming.

Safe HaskellNone
LanguageHaskell2010

ADP.Fusion.SynVar.Fill

Contents

Synopsis

Specialized table-filling wrapper for MTbls

runFreezeMTbls :: (ExposeTables t1, PrimMonad m, IndexStream sh, FreezeTables m (OnlyTables t1), MPrimArrayOps arr sh elm, WriteCell m ((:.) tail (MutArr m (arr sh elm), t)) sh, (~) * (TableFun t1) ((:.) tail (MutArr m (arr sh elm), t))) => t1 -> m (Frozen (OnlyTables t1)) Source

Run and freeze MTbls. Since actually running the table-filling part is usually the last thing to do, we can freeze as well.

Expose inner mutable tables

class ExposeTables t where Source

Expose the actual mutable table with an MTbl. (Should be temporary until MTbls get a more thorough treatment for auto-filling.

Associated Types

type TableFun t :: * Source

type OnlyTables t :: * Source

Methods

expose :: t -> TableFun t Source

onlyTables :: t -> OnlyTables t Source

Instances

Unsafely mutate ITbls and similar tables in the forward phase.

class MutateCell s im om i where Source

Mutate a cell in a stack of syntactic variables.

TODO generalize to monad morphism via mmorph package. This will allow more interesting mrph functions that can, for example, track some state in the forward phase. (Note that this can be dangerous, we do not want to have this state influence forward results, unless that can be made deterministic, or we'll break Bellman)

Methods

mutateCell :: Int -> Int -> (forall a. im a -> om a) -> s -> i -> i -> om () Source

Instances

Monad om => MutateCell Z im om i 
(PrimArrayOps arr i x, MPrimArrayOps arr i x, MutateCell ts im om i, PrimMonad om, Show x, Show i) => MutateCell ((:.) ts (ITbl im arr i x)) im om i 

class MutateTables s im om where Source

Methods

mutateTables :: (forall a. im a -> om a) -> s -> om s Source

Instances

(Monad om, MutateCell ((:.) ts (ITbl im arr i x)) im om i, PrimArrayOps arr i x, Show i, IndexStream i, TableOrder ((:.) ts (ITbl im arr i x))) => MutateTables ((:.) ts (ITbl im arr i x)) im om 

class TableOrder s where Source

Instances

TableOrder Z 
TableOrder ts => TableOrder ((:.) ts (ITbl im arr i x)) 

individual instances for filling a *single cell*

individual instances for filling a complete table and extracting the

mutateTablesDefault :: MutateTables t Id IO => t -> t Source

Default table filling, assuming that the forward monad is just IO.

TODO generalize to MonadIO or MonadPrim.