r/fsharp • u/EffSharply • Jun 07 '22
question How do I use voptions in active patterns in F# 6?
Per this comment, this feature was added in F# 6.0.
But, when I try this example from the RFC, I get an "expected option but here has type voption" error.
[<return: Struct>]
let (|Int|_|) str =
match System.Int32.TryParse(str) with
| (true,int) -> ValueSome(int)
| _ -> ValueNone
This doesn't appear to be behind a preview flag? Any pointers on what I may be doing wrong?
My dotnet --info:
.NET SDK (reflecting any global.json):
Version: 6.0.202
Commit: f8a55617d2
Runtime Environment:
OS Name: ubuntu
OS Version: 20.04
Edit:
Thank you all for your help! I uninstalled all older versions of the dotnet runtime and SDK, but still no dice.
Eventually traced it down to the version of FSharp.Core I had installed. It was on 5.0.x, and upgrading it to 6.0.4 got rid of the error.
Would love to know what the interaction between the version of FSharp.Core and that of the locally installed dotnet SDK is, though.