-
-
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
Problem with generic lambdas #3127
Comments
Very hard to implement. I think we might alternatively redesign 'map' to allow for better type inference instead of making the compiler even more complex. |
This is not about system.map function and it's design. It's about type inference in compiler itself. |
As if i don't know... |
After applying #3234 this code below works. However it is not the same as the original code posted above. import future
type Holder[T] = object
value*: T
proc newHolder[T](v: T): Holder[T] = Holder[T](value: v)
proc `$`[T](h: Holder[T]): string = "Holder(" & $h.value & ")"
proc map[T,U](h: Holder[T], f: T -> U): Holder[U] = newHolder[U](f(h.value))
proc myF[A,B](x: A): B = x * 2
echo(newHolder(100).map(myF)) |
@petermora An interesting thing happens with last devel. Here (https://github.com/vegansk/nimtests/blob/49dd3791380596e77874b0a4624bc9464764a9f6/fpinnim/Ch03/List.nim#L170) the type is required, and here (https://github.com/vegansk/nimtests/blob/49dd3791380596e77874b0a4624bc9464764a9f6/fpinnim/Ch03/List.nim#L171) is not required. |
Reopen if still a problem. |
This code won't compile:
with message
If I supply paramerer type like this:
, error disappears.
The text was updated successfully, but these errors were encountered: