Created
September 30, 2021 16:39
-
-
Save bollu/4abd1723f5381affb51bd6c4e0ca6ed7 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
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