Safe Haskell | Safe-Inferred |
---|
The Build type, and associated operations.
Build monad
The Build monad represents computations that can be in one of three states:
- Complete
- Partial
- Broken
It extends the Either monad with an additional Partial value to describe a valid computation flagged with a Partial context. The Build monad is useful when you describe computations where parts of the computation are either complete, partially complete or broken. Combining only Complete computations will produce a Complete result. However, if one of the computations is Partial, the whole computation will be Partial as well. And if some computation is Broken, the whole computation will be broken as well.
The Build monad is used by Haskoin to describe the state of the transaction signing computation. To sign a transaction, all input scripts need to be signed. The whole transaction will be completely signed only if all the input scripts are completely signed. If any of the inputs is partially signed, then the whole transaction will be partially signed as well. And the whole transaction is broken if one of the inputs failed to parse or is broken.
isComplete :: Build a -> BoolSource
Returns True if the Build value is Complete
eitherToBuild :: Either String a -> Build aSource
Transforms an Either String value into a Build value. Right is mapped to Complete and Left is mapped to Broken
buildToEither :: Build a -> Either String aSource
Transforms a Build value into an Either String value. Complete and Partial are mapped to Right and Broken is mapped to Left.
guardPartial :: Bool -> Build ()Source
Binds a Partial value to the computation when the predicate is False.
BuildT transformer monad
BuildT transformer monad