Skip to content

Instantly share code, notes, and snippets.

@derrickturk
Created July 29, 2022 02:06
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 derrickturk/4da4046321b267246436d7a7ab5722b7 to your computer and use it in GitHub Desktop.
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
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