Safe Haskell | None |
---|---|
Language | Haskell2010 |
A progress monad, which we use to report failure and logging from otherwise pure code.
Synopsis
- data Progress step fail done
- stepProgress :: step -> Progress step fail ()
- failProgress :: fail -> Progress step fail done
- foldProgress :: (step -> a -> a) -> (fail -> a) -> (done -> a) -> Progress step fail done -> a
Documentation
data Progress step fail done #
A type to represent the unfolding of an expensive long running calculation that may fail (or maybe not expensive, but complicated!) We may get intermediate steps before the final result which may be used to indicate progress and/or logging messages.
TODO: Apply Codensity to avoid left-associativity problem. See http://comonad.com/reader/2011/free-monads-for-less/ and http://blog.ezyang.com/2012/01/problem-set-the-codensity-transformation/
Instances
Monad (Progress step fail) # | |
Functor (Progress step fail) # | |
Applicative (Progress step fail) # | |
pure :: a -> Progress step fail a # (<*>) :: Progress step fail (a -> b) -> Progress step fail a -> Progress step fail b # liftA2 :: (a -> b -> c) -> Progress step fail a -> Progress step fail b -> Progress step fail c # (*>) :: Progress step fail a -> Progress step fail b -> Progress step fail b # (<*) :: Progress step fail a -> Progress step fail b -> Progress step fail a # | |
Monoid fail => Alternative (Progress step fail) # | |
stepProgress :: step -> Progress step fail () #
Emit a step and then continue.
failProgress :: fail -> Progress step fail done #
Fail the computation.
foldProgress :: (step -> a -> a) -> (fail -> a) -> (done -> a) -> Progress step fail done -> a #