Skip to content

Instantly share code, notes, and snippets.

@recloser

recloser/foo.nim Secret

Last active October 29, 2018 23:44
Show Gist options
  • Save recloser/6f1ebf3ca8b1a6027e1051d3849e9261 to your computer and use it in GitHub Desktop.
Save recloser/6f1ebf3ca8b1a6027e1051d3849e9261 to your computer and use it in GitHub Desktop.
static:
doAssert int is int
doAssert type(1) is int
# doAssert string is int # <- compile time error
match(either) # Either[string, int]
of int: ...
of string: ...
of bool:
static: # this block would be generated by the macro
# and inserted in each branch
var found = false
found = found or (bool is string) # first type is the ident, second is
found = found or (bool is int) # the properly typed sym extracted in your macro
if not found:
error("Bool is not a valid type!")
# user branch code goes here...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment