I'm using the FSharpPlus library and there is a discrepancy between
#r "nuget: FSharpPlus"
open FSharpPlus
memoizeN (fun x y -> x,y) // error FS0073: internal error: recursive class hierarchy (detected in TypeFeasiblySubsumesType), ty1 = MemoizeN
(fun x y -> x,y) |> memoizeN // OK
Why does this happen, and is there a way to use the former?
It's not because of the lambda, this is kind of a corner type inference case.
F# type inference works from left to right, so in some cases it's not able to infer the correct type of a generic function, unless the type information of its argument is already inferred.
A simpler case could be this:
let x = (fun lst -> lst.Length) [0]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With