Cabal-3.10.1.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
Monoid fail => Alternative (Progress step fail) Source # 
Instance details

Defined in Distribution.Utils.Progress

Methods

empty :: Progress step fail a Source #

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

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

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

Applicative (Progress step fail) Source # 
Instance details

Defined in Distribution.Utils.Progress

Methods

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 #

Functor (Progress step fail) Source # 
Instance details

Defined in Distribution.Utils.Progress

Methods

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

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

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 Source #

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

return :: a -> Progress step fail a Source #

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