package devkit

  1. Overview
  2. Docs

Useful shortcuts

module U = ExtUnix.Specific
module Enum = ExtEnum
val ($) : ('a -> 'b) -> ('c -> 'a) -> 'c -> 'b

function composition : f $ g is equivalent to (fun x -> f (g x))

val ($$) : ('a -> 'a -> 'b) -> ('c -> 'a) -> 'c -> 'c -> 'b

2-function composition : f $$ g is equivalent to (fun x y -> f (g x) (g y))

val id : 'a -> 'a

identity

val identity : 'a -> 'a

idem

val flip : ('a -> 'b -> 'c) -> 'b -> 'a -> 'c

reverse arguments, flip f x y is equivalent to f y x

val apply2 : ('a -> 'b) -> ('a * 'a) -> 'b * 'b

map over 2-tuple

val some : 'a -> 'a option

some x is equivalent to Some x

val const : 'a -> unit -> 'a
  • returns

    function returning given value

val curry : (('a * 'b) -> 'c) -> 'a -> 'b -> 'c
  • returns

    curried version from function of tuple

val uncurry : ('a -> 'b -> 'c) -> ('a * 'b) -> 'c
  • returns

    function of tuple from curried function

val (!!) : 'a Lazy.t -> 'a

Lazy.force

val printfn : ('a, unit, string, unit) format4 -> 'a

printf to stdout with newline

val eprintfn : ('a, unit, string, unit) format4 -> 'a

printf to stderr with newline

module Fresh (T : sig ... end) () : sig ... end

abstract type generator

val tuck : 'a list ref -> 'a -> unit
val cons : 'a list -> 'a -> 'a list
val (+=) : int ref -> int -> unit
val (-=) : int ref -> int -> unit
val round : float -> float
val atoi : string -> string -> int

atoi name value

  • returns

    integer of string value

  • raises Failure

    if value is not an integer (with name and value in exception message)

val call_me_maybe : ('a -> unit) option -> 'a -> unit
OCaml

Innovation. Community. Security.