diff options
| author | Emilio Jesus Gallego Arias | 2017-12-15 18:51:45 +0100 |
|---|---|---|
| committer | Emilio Jesus Gallego Arias | 2017-12-23 19:20:30 +0100 |
| commit | 5ffa147bd2fe548df3ac9053fe497d0871a5f6df (patch) | |
| tree | cc62882184c34e33e2995a5a4ff4ebfcbd0defe0 /lib/trie.ml | |
| parent | dea75d74c222c25f6aa6c38506ac7a51b339e9c6 (diff) | |
[lib] Split auxiliary libraries into Coq-specific and general.
Up to this point the `lib` directory contained two different library
archives, `clib.cma` and `lib.cma`, which a rough splitting between
Coq-specific libraries and general-purpose ones.
We know split the directory in two, as to make the distinction clear:
- `clib`: contains libraries that are not Coq specific and implement
common data structures and programming patterns. These libraries
could be eventually replace with external dependencies and the rest
of the code base wouldn't notice much.
- `lib`: contains Coq-specific common libraries in widespread use
along the codebase, but that are not considered part of other
components. Examples are printing, error handling, or flags.
In some cases we have coupling due to utility files depending on Coq
specific flags, however this commit doesn't modify any files, but only
moves them around, further cleanup is welcome, as indeed a few files
in `lib` should likely be placed in `clib`.
Also note that `Deque` is not used ATM.
Diffstat (limited to 'lib/trie.ml')
| -rw-r--r-- | lib/trie.ml | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/lib/trie.ml b/lib/trie.ml deleted file mode 100644 index 0b0ba27613..0000000000 --- a/lib/trie.ml +++ /dev/null @@ -1,89 +0,0 @@ -(************************************************************************) -(* v * The Coq Proof Assistant / The Coq Development Team *) -(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2017 *) -(* \VV/ **************************************************************) -(* // * This file is distributed under the terms of the *) -(* * GNU Lesser General Public License Version 2.1 *) -(************************************************************************) - -module type S = -sig - type label - type data - type t - val empty : t - val get : t -> data - val next : t -> label -> t - val labels : t -> label list - val add : label list -> data -> t -> t - val remove : label list -> data -> t -> t - val iter : (label list -> data -> unit) -> t -> unit -end - -module type Grp = -sig - type t - val nil : t - val is_nil : t -> bool - val add : t -> t -> t - val sub : t -> t -> t -end - -module Make (Y : Map.OrderedType) (X : Grp) = -struct - -module T_codom = Map.Make(Y) - -type data = X.t -type label = Y.t -type t = Node of X.t * t T_codom.t - -let codom_for_all f m = - let fold key v accu = f v && accu in - T_codom.fold fold m true - -let empty = Node (X.nil, T_codom.empty) - -let next (Node (_,m)) lbl = T_codom.find lbl m - -let get (Node (hereset,_)) = hereset - -let labels (Node (_,m)) = - (** FIXME: this is order-dependent. Try to find a more robust presentation? *) - List.rev (T_codom.fold (fun x _ acc -> x::acc) m []) - -let is_empty_node (Node(a,b)) = (X.is_nil a) && (T_codom.is_empty b) - -let assure_arc m lbl = - if T_codom.mem lbl m then - m - else - T_codom.add lbl (Node (X.nil,T_codom.empty)) m - -let cleanse_arcs (Node (hereset,m)) = - let m = if codom_for_all is_empty_node m then T_codom.empty else m in - Node(hereset, m) - -let rec at_path f (Node (hereset,m)) = function - | [] -> - cleanse_arcs (Node(f hereset,m)) - | h::t -> - let m = assure_arc m h in - cleanse_arcs (Node(hereset, - T_codom.add h (at_path f (T_codom.find h m) t) m)) - -let add path v tm = - at_path (fun hereset -> X.add v hereset) tm path - -let remove path v tm = - at_path (fun hereset -> X.sub hereset v) tm path - -let iter f tlm = - let rec apprec pfx (Node(hereset,m)) = - let path = List.rev pfx in - f path hereset; - T_codom.iter (fun l tm -> apprec (l::pfx) tm) m - in - apprec [] tlm - -end |
