Copyright | (c) Sebastian Graf 2018 |
---|---|

License | ISC |

Maintainer | sgraf1337@gmail.com |

Portability | portable |

Safe Haskell | None |

Language | Haskell2010 |

Helpers for allocating `Node`

s in an ergonomic manner, e.g.
taking care to get `mfix`

right under the hood for allocation
in recursive bindings groups through the key primitive `allocateNode`

.

- data NodeAllocator v a
- allocateNode :: (Node -> NodeAllocator v (a, v)) -> NodeAllocator v a
- runAllocator :: NodeAllocator v a -> (a, Array v)

# Documentation

data NodeAllocator v a Source #

A state monad wrapping a mapping from `Node`

to some `v`

which we will instantiate to appropriate `LiftedFunc`

s.

Monad (NodeAllocator v) Source # | |

Functor (NodeAllocator v) Source # | |

Applicative (NodeAllocator v) Source # | |

allocateNode :: (Node -> NodeAllocator v (a, v)) -> NodeAllocator v a Source #

Allocates the next `Node`

, which is greater than any
nodes requested before.

The value stored at that node is the result of a `NodeAllocator`

computation which may already access the `Node`

associated
with that value. This is important for the case of recursive
let, where the denotation of an expression depends on itself.

runAllocator :: NodeAllocator v a -> (a, Array v) Source #

Runs the allocator, beginning with an empty mapping.