Last active
March 7, 2018 22:34
-
-
Save polypus74/901324fb2e125b057ac05d68b381c4d4 to your computer and use it in GitHub Desktop.
default params with type classes
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
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