aboutsummaryrefslogtreecommitdiffhomepage
path: root/kernel
diff options
context:
space:
mode:
authorGravatar Matej Kosik <m4tej.kosik@gmail.com>2016-08-30 11:47:35 +0200
committerGravatar Matej Kosik <m4tej.kosik@gmail.com>2016-08-30 11:47:35 +0200
commit4f21c45748816c9e0cd4f93fa6f6d167e9757f81 (patch)
treef22bde63a6522883782ada4c40fa6b5c1ff1cc4c /kernel
parent2ff6d31c7a6011b26dfa7f0b2bb593b356833058 (diff)
CLEANUP: switching from "right-to-left" to "left-to-right" function composition operator.
Short story: This pull-request: (1) removes the definition of the "right-to-left" function composition operator (2) adds the definition of the "left-to-right" function composition operator (3) rewrites the code relying on "right-to-left" function composition to rely on "left-to-right" function composition operator instead. Long story: In mathematics, function composition is traditionally denoted with ∘ operator. Ocaml standard library does not provide analogous operator under any name. Batteries Included provides provides two alternatives: _ % _ and _ %> _ The first operator one corresponds to the classical ∘ operator routinely used in mathematics. I.e.: (f4 % f3 % f2 % f1) x ≜ (f4 ∘ f3 ∘ f2 ∘ f1) x We can call it "right-to-left" composition because: - the function we write as first (f4) will be called as last - and the function write as last (f1) will be called as first. The meaning of the second operator is this: (f1 %> f2 %> f3 %> f4) x ≜ (f4 ∘ f3 ∘ f2 ∘ f1) x We can call it "left-to-right" composition because: - the function we write as first (f1) will be called first - and the function we write as last (f4) will be called last That is, the functions are written in the same order in which we write and read them. I think that it makes sense to prefer the "left-to-right" variant because it enables us to write functions in the same order in which they will be actually called and it thus better fits our culture (we read/write from left to right).
Diffstat (limited to 'kernel')
-rw-r--r--kernel/declareops.ml2
-rw-r--r--kernel/names.ml2
-rw-r--r--kernel/term_typing.ml4
3 files changed, 4 insertions, 4 deletions
diff --git a/kernel/declareops.ml b/kernel/declareops.ml
index 8943de404..0a822d6fa 100644
--- a/kernel/declareops.ml
+++ b/kernel/declareops.ml
@@ -147,7 +147,7 @@ let subst_const_body sub cb =
themselves. But would it really bring substantial gains ? *)
let hcons_rel_decl =
- RelDecl.map_type Term.hcons_types % RelDecl.map_value Term.hcons_constr % RelDecl.map_name Names.Name.hcons
+ RelDecl.map_name Names.Name.hcons %> RelDecl.map_value Term.hcons_constr %> RelDecl.map_type Term.hcons_types
let hcons_rel_context l = List.smartmap hcons_rel_decl l
diff --git a/kernel/names.ml b/kernel/names.ml
index d673c91e8..1313bae7b 100644
--- a/kernel/names.ml
+++ b/kernel/names.ml
@@ -89,7 +89,7 @@ struct
| Anonymous -> true
| Name _ -> false
- let is_name = not % is_anonymous
+ let is_name = is_anonymous %> not
let compare n1 n2 = match n1, n2 with
| Anonymous, Anonymous -> 0
diff --git a/kernel/term_typing.ml b/kernel/term_typing.ml
index 8db65e33c..7a5ac7a39 100644
--- a/kernel/term_typing.ml
+++ b/kernel/term_typing.ml
@@ -262,7 +262,7 @@ let record_aux env s_ty s_bo suggested_expr =
String.concat " "
(CList.map_filter (fun decl ->
let id = NamedDecl.get_id decl in
- if List.exists (Id.equal id % NamedDecl.get_id) in_ty then None
+ if List.exists (NamedDecl.get_id %> Id.equal id) in_ty then None
else Some (Id.to_string id))
(keep_hyps env s_bo)) in
Aux_file.record_in_aux "context_used" (v ^ ";" ^ suggested_expr)
@@ -285,7 +285,7 @@ let build_constant_declaration kn env (def,typ,proj,poly,univs,inline_code,ctx)
let sort evn l =
List.filter (fun decl ->
let id = NamedDecl.get_id decl in
- List.exists (Names.Id.equal id % NamedDecl.get_id) l)
+ List.exists (NamedDecl.get_id %> Names.Id.equal id) l)
(named_context env) in
(* We try to postpone the computation of used section variables *)
let hyps, def =