Safe Haskell | Safe-Infered |
---|

A monadic library to build dataflow graphs for OM. Builder is only for Graph vector gauge () . Graphs with other annotation types can be created by fmap. This module exports everything, for writing other Builder modules.

- type Builder vector gauge anot val = State (BuilderState vector gauge anot) val
- data BuilderState vector gauge anot = BuilderState {}
- type B ret = forall v g a. Builder v g a ret
- type BuilderOf r c = forall v g a. Builder v g a (Value r c)
- buildKernel :: Setup v g a -> Name -> Builder v g a () -> Kernel v g a
- initState :: Setup v g a -> BuilderState v g a
- modifyG :: (Graph v g a -> Graph v g a) -> Builder v g a ()
- getG :: Builder v g a (Graph v g a)
- freeNode :: B Node
- addNode :: [Node] -> Node v g a -> Builder v g a Node
- addNodeE :: [Node] -> (a -> Node v g a) -> Builder v g a Node
- valueToNode :: (TRealm r, Typeable c) => Value r c -> B Node
- lookUpStatic :: Named DynValue -> B StaticIdx
- bind :: (Monad m, Functor m) => m a -> m (m a)
- load :: (TRealm r, Typeable c) => Named (StaticValue r c) -> B (Value r c)
- store :: (TRealm r, Typeable c) => Named (StaticValue r c) -> Builder v g a (Value r c) -> Builder v g a ()
- reduce :: Typeable c => Operator -> Builder v g a (Value TArray c) -> Builder v g a (Value TScalar c)
- broadcast :: Typeable c => Builder v g a (Value TScalar c) -> Builder v g a (Value TArray c)
- loadIndex :: Typeable g => Axis v -> Builder v g a (Value TArray g)
- loadSize :: Typeable g => Axis v -> Builder v g a (Value TScalar g)
- shift :: Typeable c => v g -> Builder v g a (Value TArray c) -> Builder v g a (Value TArray c)
- imm :: (TRealm r, Typeable c) => c -> B (Value r c)
- mkOp1 :: (TRealm r, Typeable c) => Operator -> Builder v g a (Value r c) -> Builder v g a (Value r c)
- mkOp2 :: (TRealm r, Typeable c) => Operator -> Builder v g a (Value r c) -> Builder v g a (Value r c) -> Builder v g a (Value r c)
- cast :: (TRealm r, Typeable c1, Typeable c2) => c2 -> Builder v g a (Value r c1) -> Builder v g a (Value r c2)
- annotate :: (TRealm r, Typeable c) => (a -> a) -> Builder v g a (Value r c) -> Builder v g a (Value r c)
- (<?>) :: (TRealm r, Typeable c) => (a -> a) -> Builder v g a (Value r c) -> Builder v g a (Value r c)
- withAnnotation :: (a -> a) -> Builder v g a ret -> Builder v g a ret

# Documentation

type Builder vector gauge anot val = State (BuilderState vector gauge anot) valSource

data BuilderState vector gauge anot Source

(Show anot, Show (vector gauge), Vector vector) => Show (BuilderState vector gauge anot) | |

Eq (Builder v g a ret) | |

(TRealm r, Typeable c, C c, Fractional c) => Fractional (Builder v g a (Value r c)) | you can convert GHC floating point immediates to |

(TRealm r, Typeable c, C c) => Num (Builder v g a (Value r c)) | you can convert GHC numeric immediates to |

Show (Builder v g a ret) | |

(TRealm r, Typeable c) => C (Builder v g a (Value r c)) | choose the larger or the smaller of the two. |

(TRealm r, Typeable c, C c) => C (Builder v g a (Value r c)) | |

(TRealm r, Typeable c, C c) => C (Builder v g a (Value r c)) | |

(TRealm r, Typeable c, C c) => C (Builder v g a (Value r c)) | |

(TRealm r, Typeable c, C c) => C (Builder v g a (Value r c)) | |

(TRealm r, Typeable c, C c) => C (Builder v g a (Value r c)) | Builder is Ring |

(TRealm r, Typeable c, C c) => C (Builder v g a (Value r c)) | |

(TRealm r, Typeable c) => C (Builder v g a (Value r c)) | |

(TRealm r, Typeable c, C c) => C (Builder v g a (Value r c)) | |

TRealm r => Boolean (Builder v g a (Value r Bool)) |

initState :: Setup v g a -> BuilderState v g aSource

:: (Graph v g a -> Graph v g a) | The graph modifying function. |

-> Builder v g a () | The state gets silently modified. |

Modify the dataflow graph stored in the `Builder`

.

:: [Node] | The list of dependent nodes. The order is recorded. |

-> Node v g a | The new node to be added. |

-> Builder v g a Node |

add a node to the graph.

:: [Node] | The list of dependent nodes. The order is recorded. |

-> (a -> Node v g a) | The new node to be added, with Annotation missing. |

-> Builder v g a Node |

add a node to the graph with an empty Annotation.

lookUpStatic :: Named DynValue -> B StaticIdxSource

look up the `Named`

`DynValue`

with the correct name and type
is included in the `staticValues`

of the `BuilderState`

bind :: (Monad m, Functor m) => m a -> m (m a)Source

run the given builder monad, get the result graph node,
and wrap it in a `return`

monad for later use.
it is like binding a value to a monad-level identifier.

:: (TRealm r, Typeable c) | |

=> Named (StaticValue r c) | the named static value to be loaded from. |

-> B (Value r c) | The loaded |

Load from a static value.

:: (TRealm r, Typeable c) | |

=> Named (StaticValue r c) | the named static value to be stored on. |

-> Builder v g a (Value r c) | The |

-> Builder v g a () | The result. |

Store to a static value.

:: (TRealm r, Typeable c) | |

=> Operator | The operator symbol |

-> Builder v g a (Value r c) | Input |

-> Builder v g a (Value r c) | Output |

Make a unary operator

:: (TRealm r, Typeable c) | |

=> Operator | The operator symbol |

-> Builder v g a (Value r c) | Input 1 |

-> Builder v g a (Value r c) | Input 2 |

-> Builder v g a (Value r c) | Output |

Make a binary operator

cast :: (TRealm r, Typeable c1, Typeable c2) => c2 -> Builder v g a (Value r c1) -> Builder v g a (Value r c2)Source

take a phantom object `c2`

, and perform the cast that keeps the realm while
change the content type from `c1`

to `c2`

.

annotate :: (TRealm r, Typeable c) => (a -> a) -> Builder v g a (Value r c) -> Builder v g a (Value r c)Source

Execute the builder, and annotate the very result with the givin function.

(<?>) :: (TRealm r, Typeable c) => (a -> a) -> Builder v g a (Value r c) -> Builder v g a (Value r c)Source

(?) = annotate

withAnnotation :: (a -> a) -> Builder v g a ret -> Builder v g a retSource

Execute the builder under modifed annotation.