aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/Coquplib.v
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/Coquplib.v')
-rw-r--r--src/common/Coquplib.v32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/common/Coquplib.v b/src/common/Coquplib.v
index c633874..666d740 100644
--- a/src/common/Coquplib.v
+++ b/src/common/Coquplib.v
@@ -23,6 +23,8 @@ From Coq Require Export
List
Bool.
+From coqup Require Import Show.
+
(* Depend on CompCert for the basic library, as they declare and prove some
useful theorems. *)
From compcert.lib Require Export Coqlib.
@@ -42,3 +44,33 @@ Ltac solve_by_invert := solve_by_inverts 1.
(* Definition const (A B : Type) (a : A) (b : B) : A := a.
Definition compose (A B C : Type) (f : B -> C) (g : A -> B) (x : A) : C := f (g x). *)
+
+Module Option.
+
+Definition default {T : Type} (x : T) (u : option T) : T :=
+ match u with
+ | Some y => y
+ | _ => x
+ end.
+
+Definition map {S : Type} {T : Type} (f : S -> T) (u : option S) : option T :=
+ match u with
+ | Some y => Some (f y)
+ | _ => None
+ end.
+
+Definition liftA2 {T : Type} (f : T -> T -> T) (a : option T) (b : option T) : option T :=
+ match a with
+ | Some x => map (f x) b
+ | _ => None
+ end.
+
+End Option.
+
+Parameter debug_print : string -> unit.
+
+Definition debug_show {A B : Type} `{Show A} (a : A) (b : B) : B :=
+ let unused := debug_print (show a) in b.
+
+Definition debug_show_msg {A B : Type} `{Show A} (s : string) (a : A) (b : B) : B :=
+ let unused := debug_print (s ++ show a) in b.