Monoids with holes. The
HoleyMonoid allows building monoidal values of which certain components are to be filled in later. For example:
> let holey = now "x = " . later show . now ", y = " . later show > run holey 3 5 "x = 3, y = 5"
This module is intended to be imported in qualified fashion, e.g.
import qualified Data.HoleyMonoid as HM
The type of a monoid with holes. The underlying monoid is represented by
r is the result type and stays polymorphic until the
very last moment when
run is called. The last argument
a is always a
function with zero or more arguments, finally resulting in
r. Ordering the
arguments in this order allows holey monoids to be composed using
., stacking the
expected arguments. Note that the
Monoid constraint is only used in the
HoleyMonoid and in composing two
Run the computation, resulting in a function that still expects some
arguments. The number of arguments that is still expected will be equal to the
laters the computation is built of.
Insert a monoidal value that is not specified until the computation is
run. The argument that is expected later is converted to the monoid type
using the given conversion function.