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 Source #
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) # | |
Defined in Distribution.Utils.Progress pure :: a -> Progress step fail a Source # (<*>) :: Progress step fail (a -> b) -> Progress step fail a -> Progress step fail b Source # liftA2 :: (a -> b -> c) -> Progress step fail a -> Progress step fail b -> Progress step fail c Source # (*>) :: Progress step fail a -> Progress step fail b -> Progress step fail b Source # (<*) :: Progress step fail a -> Progress step fail b -> Progress step fail a Source # | |
Monoid fail => Alternative (Progress step fail) # | |
stepProgress :: step -> Progress step fail () Source #
Emit a step and then continue.
failProgress :: fail -> Progress step fail done Source #
Fail the computation.
foldProgress :: (step -> a -> a) -> (fail -> a) -> (done -> a) -> Progress step fail done -> a Source #