projects
/
coq-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add treeToString method to General
[coq-hetmet.git]
/
src
/
General.v
diff --git
a/src/General.v
b/src/General.v
index
3c82528
..
e1e5791
100644
(file)
--- a/
src/General.v
+++ b/
src/General.v
@@
-129,7
+129,14
@@
Lemma mapOptionTree_compose : forall A B C (f:A->B)(g:B->C)(l:Tree ??A),
reflexivity.
Qed.
reflexivity.
Qed.
-
+Open Scope string_scope.
+Fixpoint treeToString {T}{TT:ToString T}(t:Tree ??T) : string :=
+match t with
+ | T_Leaf None => "[]"
+ | T_Leaf (Some s) => "["+++s+++"]"
+ | T_Branch b1 b2 => treeToString b1 +++ ",," +++ treeToString b2
+end.
+Instance TreeToString {T}{TT:ToString T} : ToString (Tree ??T) := { toString := treeToString }.
(*******************************************************************************)
(* Lists *)
(*******************************************************************************)
(* Lists *)
@@
-633,6
+640,12
@@
Definition map2 {A}{B}(f:A->B)(t:A*A) : (B*B) := ((f (fst t)), (f (snd t))).
Variable eol : string.
Extract Constant eol => "'\n':[]".
Variable eol : string.
Extract Constant eol => "'\n':[]".
+Class Monad {T:Type->Type} :=
+{ returnM : forall {a}, a -> T a
+; bindM : forall {a}{b}, T a -> (a -> T b) -> T b
+}.
+Implicit Arguments Monad [ ].
+Notation "a >>>= b" := (@bindM _ _ _ _ a b) (at level 50, left associativity).
(* the Error monad *)
Inductive OrError (T:Type) :=
(* the Error monad *)
Inductive OrError (T:Type) :=
@@
-709,3
+722,9
@@
Lemma list2vecOrFail {T}(l:list T)(n:nat)(error_message:nat->nat->string) : ???(
rewrite e in v; apply OK; apply v.
apply (Error (error_message (length l) n)).
Defined.
rewrite e in v; apply OK; apply v.
apply (Error (error_message (length l) n)).
Defined.
+
+
+
+
+
+Variable Prelude_error : forall {A}, string -> A. Extract Inlined Constant Prelude_error => "Prelude.error".