-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type inference with lambdas doesn't work (requires explicit types) #7435
Comments
Not on the roadmap as I can't figure out how to infer this type myself. Use a template instead, maybe.
We managed so far to do without it. Btw "generic" is not a synonym for "bizarre". |
I have problems to figure out the type as well! :-D For context, Nim's type inference does not perform unification - such as Hindley-Milner languages - but propagates type information forward only. |
Unification is forward only. |
Maybe we are talking about different things, but it is not forward only. To give an example, here is a definition of fizzbuzz without any type annotation in Haskell fizz n | n `mod` 15 == 0 = "FizzBuzz"
| n `mod` 3 == 0 = "Fizz"
| n `mod` 5 == 0 = "Buzz"
| otherwise = show n If I enter this in GHCi and ask for its type I get
Notice that it has propagated back the constraint that |
Yes, Haskell and ML use a more complex scheme which propagates back. But the term "unification" is perfectly fine with forward only. Nim does perform unification. |
in D this works:
in nim apparently this doesn't unless explicit types are provided:
This pattern is heavily used and quite useful for generic code.
Is there any fundamental reason why this can't work in nim?
if not, is that on the roadmap?
potentially related
The text was updated successfully, but these errors were encountered: