-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ test ] Add some simpler tests with implicit args of derived types
- Loading branch information
Showing
10 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
tests/derivation/core/norec t-pi->.. noext 005/DerivedGen.idr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module DerivedGen | ||
|
||
import Data.Fin | ||
|
||
import Deriving.Show | ||
|
||
import RunDerivedGen | ||
|
||
%default total | ||
|
||
%language ElabReflection | ||
|
||
data FinEq : Fin n -> Fin n -> Type where | ||
Here : FinEq FZ FZ | ||
These : FinEq n m -> FinEq (FS n) (FS m) | ||
|
||
data X : (n : Nat) -> Fin n -> Fin n -> Type where | ||
MkX : (i1, i2 : Fin n) -> (i1 `FinEq` i2) -> X n i1 i2 | ||
|
||
%hint ShowFinEq : {0 a, b : Fin n} -> Show (FinEq a b); ShowFinEq = %runElab derive | ||
|
||
Show (X n i1 i2) where | ||
show $ MkX i1 i2 prf = "MkX \{show i1} \{show i2} \{show prf}" | ||
|
||
checkedGen : Fuel -> (n : Nat) -> (i1 : Fin n) -> (i2 : Fin n) -> Gen MaybeEmpty (X n i1 i2) | ||
checkedGen = deriveGen | ||
|
||
main : IO () | ||
main = runGs | ||
[ G $ \fl => checkedGen fl 3 0 1 | ||
, G $ \fl => checkedGen fl 3 1 1 | ||
, G $ \fl => checkedGen fl 3 2 1 | ||
, G $ \fl => checkedGen fl 3 2 2 | ||
] |
1 change: 1 addition & 0 deletions
1
tests/derivation/core/norec t-pi->.. noext 005/RunDerivedGen.idr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../_common/RunDerivedGen.idr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../_common/derive.ipkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
1/2: Building RunDerivedGen (RunDerivedGen.idr) | ||
2/2: Building DerivedGen (DerivedGen.idr) | ||
Error: While processing right hand side of checkedGen. Error during reflection: Named implicit applications (like to `DerivedGen.FinEq`) are not supported yet | ||
|
||
DerivedGen:14:11--14:22 | ||
10 | | ||
11 | %language ElabReflection | ||
12 | | ||
13 | data FinEq : Fin n -> Fin n -> Type where | ||
14 | Here : FinEq FZ FZ | ||
^^^^^^^^^^^ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../_common/run |
41 changes: 41 additions & 0 deletions
41
tests/derivation/core/norec t-pi->.. w_ext 003/DerivedGen.idr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module DerivedGen | ||
|
||
import Data.Fin | ||
|
||
import Deriving.Show | ||
|
||
import RunDerivedGen | ||
|
||
%default total | ||
|
||
%language ElabReflection | ||
|
||
data FinEq : Fin n -> Fin n -> Type where | ||
Here : FinEq FZ FZ | ||
These : FinEq n m -> FinEq (FS n) (FS m) | ||
|
||
data X : (n : Nat) -> Fin n -> Fin n -> Type where | ||
MkX : (i1, i2 : Fin n) -> (i1 `FinEq` i2) -> X n i1 i2 | ||
|
||
%hint ShowFinEq : {0 a, b : Fin n} -> Show (FinEq a b); ShowFinEq = %runElab derive | ||
|
||
Show (X n i1 i2) where | ||
show $ MkX i1 i2 prf = "MkX \{show i1} \{show i2} \{show prf}" | ||
|
||
checkedGen : Fuel -> (Fuel -> {n : Nat} -> (i1, i2 : Fin n) -> Gen MaybeEmpty $ FinEq i1 i2) => | ||
(n : Nat) -> (i1 : Fin n) -> (i2 : Fin n) -> Gen MaybeEmpty (X n i1 i2) | ||
checkedGen = deriveGen | ||
|
||
genFinEq : Fuel -> {n : Nat} -> (i1, i2 : Fin n) -> Gen MaybeEmpty $ FinEq i1 i2 | ||
genFinEq _ FZ FZ = pure Here | ||
genFinEq fl (FS y) (FS z) = These <$> genFinEq fl y z | ||
genFinEq _ FZ (FS _) = empty | ||
genFinEq _ (FS _) FZ = empty | ||
|
||
main : IO () | ||
main = runGs | ||
[ G $ \fl => checkedGen @{genFinEq} fl 3 0 1 | ||
, G $ \fl => checkedGen @{genFinEq} fl 3 1 1 | ||
, G $ \fl => checkedGen @{genFinEq} fl 3 2 1 | ||
, G $ \fl => checkedGen @{genFinEq} fl 3 2 2 | ||
] |
1 change: 1 addition & 0 deletions
1
tests/derivation/core/norec t-pi->.. w_ext 003/RunDerivedGen.idr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../_common/RunDerivedGen.idr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../_common/derive.ipkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
1/2: Building RunDerivedGen (RunDerivedGen.idr) | ||
2/2: Building DerivedGen (DerivedGen.idr) | ||
Error: While processing right hand side of checkedGen. Error during reflection: Target types with implicit type parameters are not supported yet | ||
|
||
DerivedGen:25:81--25:92 | ||
21 | | ||
22 | Show (X n i1 i2) where | ||
23 | show $ MkX i1 i2 prf = "MkX \{show i1} \{show i2} \{show prf}" | ||
24 | | ||
25 | checkedGen : Fuel -> (Fuel -> {n : Nat} -> (i1, i2 : Fin n) -> Gen MaybeEmpty $ FinEq i1 i2) => | ||
^^^^^^^^^^^ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../_common/run |