package travesty

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

An expanded version of Core's associative list module.

include module type of Core_kernel.List.Assoc
type ('a, 'b) t = ('a, 'b) Base.List.Assoc.t
include Bin_prot.Binable.S2 with type ('a, 'b) t := ('a, 'b) t
val bin_size_t : ('a, 'b, ('a, 'b) t) Bin_prot.Size.sizer2
val bin_write_t : ('a, 'b, ('a, 'b) t) Bin_prot.Write.writer2
val bin_read_t : ('a, 'b, ('a, 'b) t) Bin_prot.Read.reader2
val __bin_read_t__ : ('a, 'b, int -> ('a, 'b) t) Bin_prot.Read.reader2
val bin_writer_t : ('a, 'b, ('a, 'b) t) Bin_prot.Type_class.S2.writer
val bin_reader_t : ('a, 'b, ('a, 'b) t) Bin_prot.Type_class.S2.reader
val bin_t : ('a, 'b, ('a, 'b) t) Bin_prot.Type_class.S2.t
val compare : ('a -> 'a -> Base.Int.t) -> ('b -> 'b -> Base.Int.t) -> ('a, 'b) t -> ('a, 'b) t -> Base.Int.t
  • deprecated [since 2016-06] This does not respect the equivalence class promised by List.Assoc. Use List.compare directly if that's what you want.
include module type of struct include Base.List.Assoc end with type ('a, 'b) t := ('a, 'b) t

Interpret a list of (key, value) pairs as a map in which only the first occurrence of a key affects the semantics, i.e.:

List.Assoc.xxx alist ...args... 

is always the same as (or at least sort of isomorphic to):

Map.xxx (alist |> Map.of_alist_multi |> Map.map ~f:List.hd) ...args... 

Interpret a list of (key, value) pairs as a map in which only the first occurrence of a key affects the semantics, i.e.:

List.Assoc.xxx alist ...args... 

is always the same as (or at least sort of isomorphic to):

Map.xxx (alist |> Map.of_alist_multi |> Map.map ~f:List.hd) ...args... 
include Sexplib0.Sexpable.S2 with type ('a, 'b) t := ('a, 'b) t
val t_of_sexp : (Sexplib0.Sexp.t -> 'a) -> (Sexplib0.Sexp.t -> 'b) -> Sexplib0.Sexp.t -> ('a, 'b) t
val sexp_of_t : ('a -> Sexplib0.Sexp.t) -> ('b -> Sexplib0.Sexp.t) -> ('a, 'b) t -> Sexplib0.Sexp.t
val add : ('a, 'b) t -> equal:('a -> 'a -> bool) -> 'a -> 'b -> ('a, 'b) t
val find : ('a, 'b) t -> equal:('a -> 'a -> bool) -> 'a -> 'b option
val find_exn : ('a, 'b) t -> equal:('a -> 'a -> bool) -> 'a -> 'b
val mem : ('a, 'b) t -> equal:('a -> 'a -> bool) -> 'a -> bool
val remove : ('a, 'b) t -> equal:('a -> 'a -> bool) -> 'a -> ('a, 'b) t
val map : ('a, 'b) t -> f:('b -> 'c) -> ('a, 'c) t
val inverse : ('a, 'b) t -> ('b, 'a) t

Bijectivity is not guaranteed because we allow a key to appear more than once.

val group : ('a * 'b) list -> equal:('a -> 'a -> bool) -> ('a, 'b list) t

Converts an association list with potential consecutive duplicate keys into an association list of (non-empty) lists with no (consecutive) duplicate keys. Any non-consecutive duplicate keys in the input will remain in the output.

val sort_and_group : ('a * 'b) list -> compare:('a -> 'a -> int) -> ('a, 'b list) t

Converts an association list with potential duplicate keys into an association list of (non-empty) lists with no duplicate keys.

Associative lists are bi-mappable; the left type is keys, and the right type is values.

include Bi_mappable.S2_with_extensions with type ('l, 'r) t := ('l, 'r) t
include Bi_mappable.S2 with type ('l, 'r) t := ('l, 'r) t

Type of containers.

include Base.T2 with type ('l, 'r) t := ('l, 'r) t
include Bi_mappable.Generic with type ('l, 'r) t := ('l, 'r) t and type 'l left := 'l and type 'r right := 'r
include Types_intf.Bi_generic with type ('l, 'r) t := ('l, 'r) t with type 'l left := 'l with type 'r right := 'r
val bi_map : ('l1, 'r1) t -> left:('l1 -> 'l2) -> right:('r1 -> 'r2) -> ('l2, 'r2) t

bi_map c ~left ~right maps left over every 'l1 left, and right over every 'r1 right, in c.

include Bi_mappable.Extensions2 with type ('l, 'r) t := ('l, 'r) t
include Base.T2 with type ('l, 'r) t := ('l, 'r) t
include Bi_mappable.Generic_extensions with type ('l, 'r) t := ('l, 'r) t and type 'l left := 'l and type 'r right := 'r
include Types_intf.Bi_generic with type ('l, 'r) t := ('l, 'r) t with type 'l left := 'l with type 'r right := 'r
val map_left : ('l1, 'r) t -> f:('l1 -> 'l2) -> ('l2, 'r) t

map_left c ~f maps f over the left type of c only.

val map_right : ('l, 'r1) t -> f:('r1 -> 'r2) -> ('l, 'r2) t

map_right c ~f maps f over the right type of c only.

To fix both types, use T.Fix_left(Left).Fix_right(right).

module Fix_left (Left : Base.T) : Bi_mappable.S1_right_with_extensions with type 'r t := (Left.t, 'r) t and type left := Left.t

Fixes the left type of this container to Left.t.

module Fix_right (Right : Base.T) : Bi_mappable.S1_left_with_extensions with type 'l t := ('l, Right.t) t and type right := Right.t

Fixes the right type of this container to Right.t.

OCaml

Innovation. Community. Security.