| 1 |
|
| 2 |
(* Bug report 4844 (and 4824): |
| 3 |
The Haskell extraction was erroneously considering [Any] and |
| 4 |
[()] as convertible ([Tunknown] an [Tdummy] internally). *) |
| 5 |
|
| 6 |
(* A value with inner logical parts. |
| 7 |
Its extracted type will be [Sum () ()]. *) |
| 8 |
|
| 9 |
Definition semilogic : True + True := inl I. |
| 10 |
|
| 11 |
(* Higher-order record, whose projection [ST] isn't expressible |
| 12 |
as an Haskell (or OCaml) type. Hence [ST] is extracted as the |
| 13 |
unknown type [Any] in Haskell. *) |
| 14 |
|
| 15 |
Record SomeType := { ST : Type }. |
| 16 |
|
| 17 |
Definition SomeTrue := {| ST := True |}. |
| 18 |
|
| 19 |
(* A first version of the issue: |
| 20 |
[abstrSum] is extracted as [Sum Any Any], so an unsafeCoerce |
| 21 |
is required to cast [semilogic] into [abstrSum SomeTrue]. *) |
| 22 |
|
| 23 |
Definition abstrSum (t : SomeType) := ((ST t) + (ST t))%type. |
| 24 |
|
| 25 |
Definition semilogic' : abstrSum SomeTrue := semilogic. |
| 26 |
|
| 27 |
(* A deeper version of the issue. |
| 28 |
In the previous example, the extraction could have reduced |
| 29 |
[abstrSum SomeTrue] into [True+True], solving the issue. |
| 30 |
It might do so in future versions. But if we put an inductive |
| 31 |
in the way, a reduction isn't helpful. *) |
| 32 |
|
| 33 |
Inductive box (t : SomeType) := Box : ST t + ST t -> box t. |
| 34 |
|
| 35 |
Definition boxed_semilogic : box SomeTrue := |
| 36 |
Box SomeTrue semilogic. |
| 37 |
|
| 38 |
Require Extraction. |
| 39 |
Extraction Language Haskell. |
| 40 |
Recursive Extraction semilogic' boxed_semilogic. |
| 41 |
(* Warning! To fully check that this bug is still closed, |
| 42 |
you should run ghc on the extracted code: |
| 43 |
|
| 44 |
Extraction "bug4844.hs" semilogic' boxed_semilogic. |
| 45 |
ghc bug4844.hs |
| 46 |
|
| 47 |
*) |