Skip to content

Instantly share code, notes, and snippets.

@bollu
Created September 30, 2021 16:39
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 bollu/4abd1723f5381affb51bd6c4e0ca6ed7 to your computer and use it in GitHub Desktop.
Save bollu/4abd1723f5381affb51bd6c4e0ca6ed7 to your computer and use it in GitHub Desktop.
nductive Foo
| mk: Int -> Foo
instance : Inhabited Foo where
default := Foo.mk 42
constant odd : Int -> Foo
constant even : Int -> Foo
-- | in reality these are partial mutually defined functions.
-- | We use `constant` to evade
-- | `partial mutual...end`
def odd_impl (i: Int): Foo :=
match i with
| 0 => Foo.mk 0
| n => even (n - 1)
end
attribute [implementedBy odd_impl] odd
attribute [implementedBy even_impl] even
-- | expected output: 1
def main : IO Unit :=
match even 10 with
| Foo.mk k => IO.println k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment