package base

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Applicative.Make_args

  • deprecated [since 2018-09] Use [ppx_let] instead.

Parameters

module X : S

Signature

type ('f, 'r) t

'f is the type of a function that consumes the list of arguments and returns an 'r.

val nil : ('r, 'r) t

the empty argument list *

val cons : 'a X.t -> ('f, 'r) t -> ('a -> 'f, 'r) t

prepend an argument

val (@>) : 'a X.t -> ('f, 'r) t -> ('a -> 'f, 'r) t

infix operator for cons

val step : ('f1, 'r) t -> f:('f2 -> 'f1) -> ('f2, 'r) t

Transform argument values in some way. For example, one can label a function argument like so:

  step ~f:(fun f x -> f ~foo: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
    )
val mapN : f:'f -> ('f, 'r) t -> 'r X.t
val applyN : 'f X.t -> ('f, 'r) t -> 'r X.t
OCaml

Innovation. Community. Security.