diff options
author | Yann Herklotz <git@yannherklotz.com> | 2020-03-31 19:40:21 +0100 |
---|---|---|
committer | Yann Herklotz <git@yannherklotz.com> | 2020-03-31 19:40:21 +0100 |
commit | 0b4808a3705317c96387de036381e4e6add4e956 (patch) | |
tree | 3da3067ebee6ca85d68fc2c7c0d8b87d9eb18082 /src/common/Coquplib.v | |
parent | 580cfdf676931f8b590f6f1eb84e42da17569393 (diff) | |
download | vericert-0b4808a3705317c96387de036381e4e6add4e956.tar.gz vericert-0b4808a3705317c96387de036381e4e6add4e956.zip |
Add documentation and fix makefile for Compcert
Diffstat (limited to 'src/common/Coquplib.v')
-rw-r--r-- | src/common/Coquplib.v | 32 |
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. |