Created
July 29, 2022 02:06
-
-
Save derrickturk/4da4046321b267246436d7a7ab5722b7 to your computer and use it in GitHub Desktop.
Extensible variant types (I think? they're not documented except in the grammar) in Koka
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
open type openvar | |
A | |
B | |
extend type openvar | |
C | |
fun do_it_try_it(v: openvar): console () | |
match v | |
A -> println("got an A") | |
B -> println("got an B") | |
C -> println("got a C") | |
// worth nothing: we could match on D here, though | |
_ -> println("got something else") | |
extend type openvar | |
D | |
fun main(): console () | |
do_it_try_it(C) | |
do_it_try_it(D) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment