datafix-0.0.0.2: Fixing data-flow problems

Copyright(c) Sebastian Graf 2018
LicenseISC
Maintainersgraf1337@gmail.com
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Datafix.NodeAllocator

Description

Helpers for allocating Nodes 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.

Synopsis

Documentation

data NodeAllocator v a Source #

A state monad wrapping a mapping from Node to some v which we will instantiate to appropriate LiftedFuncs.

Instances

Monad (NodeAllocator v) Source # 

Methods

(>>=) :: NodeAllocator v a -> (a -> NodeAllocator v b) -> NodeAllocator v b #

(>>) :: NodeAllocator v a -> NodeAllocator v b -> NodeAllocator v b #

return :: a -> NodeAllocator v a #

fail :: String -> NodeAllocator v a #

Functor (NodeAllocator v) Source # 

Methods

fmap :: (a -> b) -> NodeAllocator v a -> NodeAllocator v b #

(<$) :: a -> NodeAllocator v b -> NodeAllocator v a #

Applicative (NodeAllocator v) Source # 

Methods

pure :: a -> NodeAllocator v a #

(<*>) :: NodeAllocator v (a -> b) -> NodeAllocator v a -> NodeAllocator v b #

liftA2 :: (a -> b -> c) -> NodeAllocator v a -> NodeAllocator v b -> NodeAllocator v c #

(*>) :: NodeAllocator v a -> NodeAllocator v b -> NodeAllocator v b #

(<*) :: NodeAllocator v a -> NodeAllocator v b -> NodeAllocator v a #

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.