Cabal-3.6.2.0: A framework for packaging Haskell software
Safe HaskellSafe-Inferred
LanguageHaskell2010

Distribution.Utils.Progress

Description

A progress monad, which we use to report failure and logging from otherwise pure code.

Synopsis

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

Instances details
Monad (Progress step fail) Source # 
Instance details

Defined in Distribution.Utils.Progress

Methods

(>>=) :: Progress step fail a -> (a -> Progress step fail b) -> Progress step fail b #

(>>) :: Progress step fail a -> Progress step fail b -> Progress step fail b #

return :: a -> Progress step fail a #

Functor (Progress step fail) Source # 
Instance details

Defined in Distribution.Utils.Progress

Methods

fmap :: (a -> b) -> Progress step fail a -> Progress step fail b #

(<$) :: a -> Progress step fail b -> Progress step fail a #

Applicative (Progress step fail) Source # 
Instance details

Defined in Distribution.Utils.Progress

Methods

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) Source # 
Instance details

Defined in Distribution.Utils.Progress

Methods

empty :: Progress step fail a #

(<|>) :: Progress step fail a -> Progress step fail a -> Progress step fail a #

some :: Progress step fail a -> Progress step fail [a] #

many :: Progress step fail a -> Progress step fail [a] #

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 #

Consume a Progress calculation. Much like foldr for lists but with two base cases, one for a final result and one for failure.

Eg to convert into a simple Either result use:

foldProgress (flip const) Left Right