module Applicative_intf:sig
..end
For more information, see:
Applicative Programming with Effects. Conor McBride and Ross Paterson. Journal of Functional Programming 18:1 (2008), pages 1-13. http://staff.city.ac.uk/~ross/papers/Applicative.pdf
For more information, see:
Applicative Programming with Effects. Conor McBride and Ross Paterson. Journal of Functional Programming 18:1 (2008), pages 1-13. http://staff.city.ac.uk/~ross/papers/Applicative.pdf
module type Basic =sig
..end
module type S =sig
..end
module type Args =sig
..end
module type Basic2 =sig
..end
module type S2 =sig
..end
module S_to_S2:
S2
and S
are in sync, but
actually calling it is occasionally useful.
module S2_to_S:
module type Args2 =sig
..end
module Args_to_Args2:
For more information, see:
Applicative Programming with Effects. Conor McBride and Ross Paterson. Journal of Functional Programming 18:1 (2008), pages 1-13. http://staff.city.ac.uk/~ross/papers/Applicative.pdf
return Fn.id <*> t = t
return Fn.compose <*> tf <*> tg <*> tx = tf <*> (tg <*> tx)
return f <*> return x = return (f x)
tf <*> return x = return (fun f -> f x) <*> tf
map
argument to Applicative.Make
says how to implement the applicative's
map
function. `Define_using_apply
means to define map t ~f = return f <*> t
.
`Custom
overrides the default implementation, presumably with something more
efficient.
Some other functions returned by Applicative.Make
are defined in terms of map
,
so passing in a more efficient map
will improve their efficiency as well.
same as apply
argument lists and associated N-ary map and apply functions
the underlying applicative
'f
is the type of a function that consumes the list of arguments and returns an
'r
.
the empty argument list *
prepend an argument
infix operator for cons
Transform argument values in some way. For example, one can label a function
argument like so:
step ~f:(fun f ~foo:x -> f x) : ('a -> 'r1, 'r2) t -> (foo:'a -> 'r1, 'r2) t
Args
sub-sequence:
let args =
Foo.Args.(
bar "A"
(* TODO: factor out the common baz qux sub-sequence *)
@> baz "B"
@> qux "C"
@> zap "D"
@> nil
)
is to write a function that prepends the sub-sequence:
let baz_qux remaining_args =
Foo.Args.(
baz "B"
@> qux "C"
@> remaining_args
)
and splice it back into the original sequence using @@
so that things line up
nicely:
let args =
Foo.Args.(
bar "A"
@> baz_qux
@@ zap "D"
@> nil
)
S2
and S
are in sync, but
actually calling it is occasionally useful.