-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
match syntax sugar (emulates Agda's with)
Consider Agda programs that match on intermediate values: main : ∀(P : Bool -> Set) -> (F : Bool -> Bool) -> (x : Bool) -> P (F x) main P F x with F x main P F x | True = {!!} -- GOAL: P True main P F x | False = {!!} -- GOAL: P False Previously, to emulate it on Kind, we needed to use an explicit 'Bool/match' function, and annotate both the type of the matched argument, and the return type. Now, we can use 'match' instead: use Base/Pair/ as P/ use Base/Bool/ as B/ Main : ∀(P: ∀(x: B/Bool) *) ∀(F: ∀(x: B/Bool) B/Bool) ∀(x: B/Bool) (P (F x)) = λP λF λx match (F x) { #True: ?a // GOAL: (P #True{}) #False: ?b // GOAL: (P #False{}) } This will correctly specialize the goal to the concrete values. Note that, to do so, we need an ugly "search-and-replace" type level computation. Seems like that is how it is done in Agda too. I don't think this is healthy and I believe it can be extremely slow, so, I'd recommend avoiding 'match', but that's not really practical (we need it even to project pairs, maybes, etc.). See this log to understand: https://gist.github.com/VictorTaelin/48eed41a8eca3500721c06dfec72d48c NOTE: (match x {...}) merely desugars to: (λ{...} x) which is now treated by the type checker (previously it would complain of not enough annotations)
- Loading branch information
1 parent
117e725
commit 257c93f
Showing
4 changed files
with
193 additions
and
37 deletions.
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
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