Skip to content

Instantly share code, notes, and snippets.

@mrwonko
Created March 31, 2018 18:51
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 mrwonko/315f3cf6c6c6357193998cdefc14396f to your computer and use it in GitHub Desktop.
Save mrwonko/315f3cf6c6c6357193998cdefc14396f to your computer and use it in GitHub Desktop.
type
Boolable = concept x
if x: discard
Bool = concept x
x is bool
when isMainModule:
type MyInt = distinct int
converter toBool(x: MyInt): bool = int(x) != 0
doAssert(MyInt is Boolable)
doAssert(not (MyInt is Bool))
doAssert(bool is Boolable)
doAssert(bool is Bool)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment