X-Git-Url: http://git.megacz.com/?p=coq-hetmet.git;a=blobdiff_plain;f=src%2FGeneral.v;h=ae27b9f99cc725f7b68a5a2cf719e83421825146;hp=f97989d2677f6c1cbafc6783ea70b1423901a9fc;hb=57e387249da84dac0f1c5a9411e3900831ce2d81;hpb=794719aadd55d760c0514f45c23b9cb450d92d9f diff --git a/src/General.v b/src/General.v index f97989d..ae27b9f 100644 --- a/src/General.v +++ b/src/General.v @@ -478,6 +478,7 @@ Fixpoint listToString {T:Type}{tst:ToString T}(l:list T) : string := Instance ListToString {T:Type}{tst:ToString T} : ToString (list T) := { toString := @listToString _ _ }. + (*******************************************************************************) (* Tree Flags *) @@ -865,6 +866,8 @@ Definition map2 {A}{B}(f:A->B)(t:A*A) : (B*B) := ((f (fst t)), (f (snd t))). (* boolean "not" *) Definition bnot (b:bool) : bool := if b then false else true. +Definition band (b1 b2:bool) : bool := if b1 then b2 else false. +Definition bor (b1 b2:bool) : bool := if b1 then true else b2. (* string stuff *) Variable eol : string. @@ -952,6 +955,16 @@ Lemma list2vecOrFail {T}(l:list T)(n:nat)(error_message:nat->nat->string) : ???( apply (Error (error_message (length l) n)). Defined. +(* this makes a type function application, ensuring not to oversaturate it (though if it was undersaturated we can't fix that) *) +Fixpoint split_list {T}(l:list T)(n:nat) : ???(list T * list T) := + match n with + | O => OK (nil , l) + | S n' => match l with + | nil => Error "take_list failed" + | h::t => split_list t n' >>= fun t' => let (t1,t2) := t' in OK ((h::t1),t2) + end + end. + (* Uniques *) Variable UniqSupply : Type. Extract Inlined Constant UniqSupply => "UniqSupply.UniqSupply". Variable Unique : Type. Extract Inlined Constant Unique => "Unique.Unique".