11Require Import Coq.Strings.String.
22Require Import Coq.Program .Wf.
3- Require Import Omega .
4-
3+ Require Import Coq.PArith.BinPos .
4+ Require Import Coq.ZArith.ZArith.
55Require Import ExtLib.Structures.Monoid.
66Require Import ExtLib.Structures.Reducible.
77Require Import ExtLib.Programming.Injection.
@@ -13,7 +13,7 @@ Require Import ExtLib.Core.RelDec.
1313Set Implicit Arguments .
1414Set Strict Implicit .
1515
16- Definition showM : Type :=
16+ Definition showM : Type :=
1717 forall m, Injection ascii m -> Monoid m -> m.
1818
1919Class ShowScheme (T : Type ) : Type :=
@@ -28,7 +28,7 @@ Global Instance ShowScheme_string : ShowScheme string :=
2828
2929Global Instance ShowScheme_string_compose : ShowScheme (string -> string) :=
3030{ show_mon := Monoid_compose string
31- ; show_inj := String
31+ ; show_inj := String
3232}.
3333
3434Definition runShow {T} {M : ShowScheme T} (m : showM) : T :=
@@ -39,7 +39,7 @@ Class Show T := show : T -> showM.
3939Definition to_string {T} {M : Show T} (v : T) : string :=
4040 runShow (show v) ""%string.
4141
42- Definition empty : showM :=
42+ Definition empty : showM :=
4343 fun _ _ m => monoid_unit m.
4444Definition cat (a b : showM) : showM :=
4545 fun _ i m => monoid_plus m (a _ i m) (b _ i m).
@@ -63,7 +63,7 @@ End ShowNotation.
6363
6464Definition indent (indent : showM) (v : showM) : showM :=
6565 let nl := Ascii.ascii_of_nat 10 in
66- fun _ inj mon =>
66+ fun _ inj mon =>
6767 v _ (fun a => if eq_dec a nl
6868 then monoid_plus mon (inj a) (indent _ inj mon)
6969 else inj a) mon.
@@ -91,15 +91,17 @@ Program Fixpoint nat_show (n:nat) {measure n} : showM :=
9191 (@nat_show n' _) << (inject (Char.digit2ascii (n - 10 * n'))).
9292Next Obligation .
9393 assert (NPeano.div n 10 < n) ; eauto .
94- eapply NPeano.Nat.div_lt ; omega.
94+ eapply NPeano.Nat.div_lt.
95+ inversion H; apply Lt.lt_O_Sn.
96+ repeat constructor.
9597Defined .
9698Global Instance nat_Show : Show nat := { show := nat_show }.
9799
98- Global Instance Show_pos : Show positive :=
100+ Global Instance Show_positive : Show positive :=
99101 fun x => nat_show (Pos.to_nat x).
100102
101103Global Instance Show_Z : Show Z :=
102- fun x =>
104+ fun x =>
103105 match x with
104106 | Z0 => "0"%char
105107 | Zpos p => show p
@@ -120,7 +122,7 @@ Section sepBy.
120122 Context {F : Foldable T showM}.
121123
122124 Definition sepBy (sep : showM) (ls : T) : showM :=
123- match
125+ match
124126 fold (fun s acc =>
125127 match acc with
126128 | None => Some s
@@ -138,7 +140,7 @@ Section sepBy_f.
138140 Variable (f : E -> showM).
139141
140142 Definition sepBy_f (sep : showM) (ls : T) : showM :=
141- match
143+ match
142144 fold (fun s acc =>
143145 match acc with
144146 | None => Some (f s)
@@ -148,7 +150,7 @@ Section sepBy_f.
148150 | None => empty
149151 | Some s => s
150152 end .
151- End sepBy_f.
153+ End sepBy_f.
152154
153155Definition wrap (before after : showM) (x : showM) : showM :=
154156 before << x << after.
@@ -192,5 +194,5 @@ Fixpoint iter_show (ss : list showM) : showM :=
192194(*
193195Examples:
194196Eval compute in (runShow (show (42,"foo"%string)) : string).
195- Eval compute in (runShow (show (inl true : bool+string))
197+ Eval compute in (runShow (show (inl true : bool+string))
196198 *)
0 commit comments