Skip to content

Instantly share code, notes, and snippets.

@polypus74
Last active March 7, 2018 22:34
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 polypus74/901324fb2e125b057ac05d68b381c4d4 to your computer and use it in GitHub Desktop.
Save polypus74/901324fb2e125b057ac05d68b381c4d4 to your computer and use it in GitHub Desktop.
default params with type classes
let i: int64 = 0
let j: float64 = 1.1
proc g(x: distinct SomeNumber = 1, y: distinct SomeNumber = 1.1) = discard
g(i,j) # OK
g(j,i) # Error
# I have tried other combinations without use of distinct. Not sure
# why the compiler complains about this, seems it should be ok?
# How does one give default args when type classes are involved?
# Ideally I would like to give a default arg of some concrete
# type but still have g(i, j) work given i and j as both arbitrary
# types independently satisfying SomeNumber constraint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment