-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not filter implicit args in internal to core translation (#1728)
The internal to core translation was removing implicit arguments from function definitions and applications. This is incorrect as the implicit bindings are required when translating the following (in `csuc`, the binding of the implicit argument is required in an application on the rhs): ``` Num : Type; Num := {A : Type} → (A → A) → A → A; csuc : Num → Num; csuc n {_} f := f ∘ n {_} f; ``` Apart from removing this filter from function and application translation, this required the following changes: ConstructorInfo: The _constructorArgsNum field must include the number of type parameters of its inductive type. PatternConstructorApp: The pattern arguments must include wildcards for the implicit type parameters passed to the constructor. BuiltinIf: The BuiltinIf expression is passed an implicit type argument that must be removed when translating to Core if. LitString: A literal string is a function with an implcit type argument. So this must be a translated to a lambda where the type argument is ignored. Fixes #1714
- Loading branch information
1 parent
0ac9eb1
commit ff748b9
Showing
6 changed files
with
87 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Church; | ||
|
||
open import Stdlib.Prelude; | ||
|
||
Num : Type; | ||
Num := {A : Type} → (A → A) → A → A; | ||
|
||
czero : Num; | ||
czero {_} f x := x; | ||
|
||
csuc : Num → Num; | ||
csuc n {_} f := f ∘ n {_} f; | ||
|
||
toNat : Num → Nat; | ||
toNat n := n {_} ((+) one) zero; | ||
|
||
main : IO; | ||
main := | ||
printNatLn (toNat (csuc (czero))); | ||
|
||
end; |
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 @@ | ||
suc zero |
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 |
---|---|---|
@@ -1 +1 @@ | ||
:: (suc (suc zero)) (:: (suc (suc (suc zero))) (:: (suc (suc (suc (suc zero)))) (:: (suc (suc (suc (suc (suc zero))))) (:: (suc (suc (suc (suc (suc (suc zero)))))) (:: (suc (suc (suc (suc (suc (suc (suc zero))))))) nil))))) | ||
:: (Nat) (suc (suc zero)) (:: (Nat) (suc (suc (suc zero))) (:: (Nat) (suc (suc (suc (suc zero)))) (:: (Nat) (suc (suc (suc (suc (suc zero))))) (:: (Nat) (suc (suc (suc (suc (suc (suc zero)))))) (:: (Nat) (suc (suc (suc (suc (suc (suc (suc zero))))))) (nil (Nat))))))) |