Module Applicative_intf

module Applicative_intf: sig .. end
Applicatives model computations in which values computed by subcomputations cannot affect what subsequent computations will take place. Relative to monads, this restriction takes power away from the user of the interface and gives it to the implementation. In particular, because the structure of the entire computation is known, one can augment its definition with some description of that structure.

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
   



Applicatives model computations in which values computed by subcomputations cannot affect what subsequent computations will take place. Relative to monads, this restriction takes power away from the user of the interface and gives it to the implementation. In particular, because the structure of the entire computation is known, one can augment its definition with some description of that structure.

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
argument lists and associated N-ary map and apply functions
module type Basic2 = sig .. end
module type S2 = sig .. end
module S_to_S2: 
functor (X : S) -> sig .. end
This module serves mostly as a partial check that S2 and S are in sync, but actually calling it is occasionally useful.
module S2_to_S: 
functor (X : S2) -> sig .. end
module type Args2 = sig .. end
module Args_to_Args2: 
functor (X : Args) -> sig .. end

Applicatives model computations in which values computed by subcomputations cannot affect what subsequent computations will take place. Relative to monads, this restriction takes power away from the user of the interface and gives it to the implementation. In particular, because the structure of the entire computation is known, one can augment its definition with some description of that structure.

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
   


The following identities ought to hold for every Applicative (for some value of =):

Note: <*> is the infix notation for apply.

The 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
      


The preferred way to factor out an 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
          )
      


This module serves mostly as a partial check that S2 and S are in sync, but actually calling it is occasionally useful.