Created
August 13, 2020 20:36
-
-
Save bigs/441f0e2229e00ecc01df95f0678abff5 to your computer and use it in GitHub Desktop.
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
module IndexedTypes | |
data Foo i = MkFoo | |
data FooInt i = MkFooInt Integer | |
mkFooInt : Foo i -> Integer -> FooInt i | |
mkFooInt _ = MkFooInt | |
addFoos : Foo i -> FooInt i -> FooInt i -> FooInt i | |
addFoos f (MkFooInt x) (MkFooInt y) = mkFooInt f (x + y) | |
-- Does not compile | |
bad : {i : Type} -> {j : Type} -> FooInt i | |
bad = let foo1 : Foo i = MkFoo | |
foo2 : Foo j = MkFoo | |
int1 = mkFooInt foo1 3 | |
int2 = mkFooInt foo2 4 in | |
addFoos foo1 int1 int2 | |
-- Compile | |
good : {i : Type} -> FooInt i | |
good = let foo1 : Foo i = MkFoo | |
foo2 : Foo i = MkFoo | |
int1 = mkFooInt foo1 3 | |
int2 = mkFooInt foo2 4 in | |
addFoos foo1 int1 int2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment