Skip to content

Commit caaa65b

Browse files
committed
Fix quoting / unquoting of some opam fields
1 parent 9341915 commit caaa65b

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

src/Main.v

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Local Open Scope list.
1616

1717
Definition C := C.t Api.effect.
1818

19+
Definition unquote (field_content : LString.t) : LString.t :=
20+
List.removelast (List.tl field_content).
21+
1922
Definition get_version (name version : LString.t) : C Version.t :=
2023
let full_name := name ++ LString.s "." ++ version in
2124
let get_field field := Api.opam_field (LString.s field) full_name in
@@ -31,10 +34,10 @@ Definition get_version (name version : LString.t) : C Version.t :=
3134
ret @@ Version.New
3235
version
3336
description
34-
license
35-
homepage
36-
bug
37-
url
37+
(unquote license)
38+
(unquote homepage)
39+
(unquote bug)
40+
(unquote url)
3841
dependencies
3942
end.
4043

src/Run.v

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
Require Import Coq.Lists.List.
12
Require Import Io.All.
23
Require Io.List.
34
Require Import ListString.All.
@@ -7,16 +8,29 @@ Require Import Model.
78

89
Import Io.Run.
910

11+
Definition quote (field_content : LString.t) : LString.t :=
12+
LString.s """" ++ field_content ++ LString.s """".
13+
14+
Lemma unquote_quote (field_content : LString.t) : Main.unquote (quote field_content) = field_content.
15+
unfold Main.unquote, quote.
16+
simpl.
17+
rewrite List.removelast_app.
18+
- rewrite List.app_nil_r; reflexivity.
19+
- congruence.
20+
Qed.
21+
1022
Definition get_version (name : LString.t) (version : Version.t)
1123
: Run.t (Main.get_version name (Version.version version)) version.
1224
eapply Let.
1325
- eapply (Join (Api.Run.opam_field (LString.s "synopsis") _ (Version.description version))).
14-
eapply (Join (Api.Run.opam_field (LString.s "license:") _ (Version.license version))).
15-
eapply (Join (Api.Run.opam_field (LString.s "homepage:") _ (Version.homepage version))).
16-
eapply (Join (Api.Run.opam_field (LString.s "bug-reports:") _ (Version.bug version))).
17-
eapply (Join (Api.Run.opam_field (LString.s "url.src:") _ (Version.url version))).
26+
eapply (Join (Api.Run.opam_field (LString.s "license:") _ (quote (Version.license version)))).
27+
eapply (Join (Api.Run.opam_field (LString.s "homepage:") _ (quote (Version.homepage version)))).
28+
eapply (Join (Api.Run.opam_field (LString.s "bug-reports:") _ (quote (Version.bug version)))).
29+
eapply (Join (Api.Run.opam_field (LString.s "url.src:") _ (quote (Version.url version)))).
1830
apply (Api.Run.opam_field (LString.s "depends:") _ (Version.dependencies version)).
1931
- destruct version.
32+
simpl.
33+
repeat rewrite unquote_quote.
2034
apply Ret.
2135
Defined.
2236

0 commit comments

Comments
 (0)