-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ base ] Show example of using the last change + allow holes in
isType
- Loading branch information
Showing
7 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
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
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
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,29 @@ | ||
module ConView | ||
|
||
import Data.Fin | ||
|
||
import Deriving.Common | ||
|
||
import Language.Reflection | ||
|
||
%default total | ||
|
||
%language ElabReflection | ||
|
||
data X : Fin n -> Type where | ||
MkX1 : (fn : _) -> X fn | ||
MkX2 : (fn : Fin n) -> X {n} fn | ||
MkX3 : (fn : Fin n) -> X fn {n} | ||
|
||
consParams : a -> Elab () | ||
consParams t = do | ||
t <- isType !(quote t) | ||
logMsg "elab" 0 "the type \{show t.typeConstructor}" | ||
for_ t.dataConstructors $ \(conName, conTy) => do | ||
let Just conView = constructorView conTy | ||
| Nothing => failAt (getFC conTy) "cannot intepret as a constructor" | ||
logMsg "elab" 0 "- constructor \{show conName}" | ||
for_ conView.params $ \(conParam, conIdx) => do | ||
logMsg "elab" 0 " - param (arg #\{show conIdx}): \{show conParam}" | ||
|
||
%runElab consParams X |
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,21 @@ | ||
1/1: Building ConView (ConView.idr) | ||
LOG elab:0: the type ConView.X | ||
LOG elab:0: - constructor ConView.MkX1 | ||
LOG elab:0: - param (arg #0): {n = {n:3537}} | ||
LOG elab:0: - param (arg #1): fn | ||
LOG elab:0: - constructor ConView.MkX2 | ||
LOG elab:0: - param (arg #0): {n = n} | ||
LOG elab:0: - param (arg #1): fn | ||
LOG elab:0: - constructor ConView.MkX3 | ||
LOG elab:0: - param (arg #0): {n = n} | ||
LOG elab:0: - param (arg #1): fn | ||
Error: Unsolved holes: | ||
ConView.{n:3773} introduced at: | ||
ConView:29:21--29:22 | ||
25 | logMsg "elab" 0 "- constructor \{show conName}" | ||
26 | for_ conView.params $ \(conParam, conIdx) => do | ||
27 | logMsg "elab" 0 " - param (arg #\{show conIdx}): \{show conParam}" | ||
28 | | ||
29 | %runElab consParams X | ||
^ | ||
|
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,3 @@ | ||
. ../../testutils.sh | ||
|
||
check ConView.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 @@ | ||
package a-test |
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