Skip to content

Instantly share code, notes, and snippets.

@bigs
Created August 13, 2020 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigs/441f0e2229e00ecc01df95f0678abff5 to your computer and use it in GitHub Desktop.
Save bigs/441f0e2229e00ecc01df95f0678abff5 to your computer and use it in GitHub Desktop.
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