package dune

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

Source file fdecl.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
type 'a state =
  | Unset
  | Set of 'a

type 'a t = { mutable state : 'a state }

let create () = { state = Unset }

let set t x =
  match t.state with
  | Unset -> t.state <- Set x
  | Set _ -> Exn.code_error "Fdecl.set: already set" []

let get t =
  match t.state with
  | Unset -> Exn.code_error "Fdecl.get: not set" []
  | Set x -> x
OCaml

Innovation. Community. Security.