logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Documentation

       Module Option
        : sigend

       Option values.

       Option values explicitly indicate the presence or absence of a value.

       Since 4.08

   Optionstype'at = 'aoption =
        | None
        | Some of'a

       The type for option values. Either None or a value Somev .

       valnone : 'aoptionnone is None .

       valsome : 'a->'aoptionsomev is Somev .

       valvalue : 'aoption->default:'a->'avalueo~default is v if o is Somev and default otherwise.

       valget : 'aoption->'ageto is v if o is Somev and raise otherwise.

       RaisesInvalid_argument if o is None .

       valbind : 'aoption->('a->'boption)->'boptionbindof is fv if o is Somev and None if o is None .

       valjoin : 'aoptionoption->'aoptionjoinoo is Somev if oo is Some(Somev) and None otherwise.

       valmap : ('a->'b)->'aoption->'boptionmapfo is None if o is None and Some(fv) if o is Somev .

       valfold : none:'a->some:('b->'a)->'boption->'afold~none~someo is none if o is None and somev if o is Somev .

       valiter : ('a->unit)->'aoption->unititerfo is fv if o is Somev and () otherwise.

   Predicatesandcomparisonsvalis_none : 'aoption->boolis_noneo is true if and only if o is None .

       valis_some : 'aoption->boolis_someo is true if and only if o is Someo .

       valequal : ('a->'a->bool)->'aoption->'aoption->boolequaleqo0o1 is true if and only if o0 and o1 are both None or if they are Somev0 and Somev1 and eqv0v1 is true .

       valcompare : ('a->'a->int)->'aoption->'aoption->intcomparecmpo0o1 is a total order on options using cmp to compare values wrapped by Some_  .   None  is
       smaller than Some_ values.

   Convertingvalto_result : none:'e->'aoption->('a,'e)resultto_result~noneo is Okv if o is Somev and Errornone otherwise.

       valto_list : 'aoption->'alistto_listo is [] if o is None and [v] if o is Somev .

       valto_seq : 'aoption->'aSeq.tto_seqo is o as a sequence.  None is the empty sequence and Somev is the singleton sequence containing
       v .

OCamldoc                                           2025-06-12                                         Option(3o)

Module

       Module   Option

Name

       Option - Option values.

See Also