File: list.mli

package info (click to toggle)
ocaml-odoc 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,008 kB
  • sloc: ml: 60,567; javascript: 2,572; sh: 566; makefile: 31
file content (39 lines) | stat: -rw-r--r-- 888 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(** {0 List}

    Utilities for List data type.

    This module is compatible with original ocaml stdlib. In general, all
    functions comes with the original stdlib also applies to this collection,
    however, this module provides faster and stack safer utilities *)

type 'a t = 'a list
(** ['a t] is compatible with built-in [list] type *)

(** {2 length} *)

val make : 'a t -> int
(** [length xs]

    @return the length of the list [xs] *)

(** {2 size} *)

val size : 'a t -> int
(** {b See} {!length} *)

(** {2 head} *)

val head : 'a t -> 'a option
(** [head xs] returns [None] if [xs] is the empty list, otherwise it returns
    [Some value] where [value] is the first element in the list.
    {[
      head [] = None;;
      head [ 1; 2; 3 ] = Some 1
    ]} *)

val headExn : 'a t -> 'a
(** [headExn xs]

    {b See} {!head}

    {b raise} an exception if [xs] is empty *)