You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I figured it would be fun and interesting to try running the F# tutorial code that comes as a new project type with Visual Studio, in the 'try F# in your browser' example at https://tryfsharp.fsbolero.io/
There's a few compile errors. I chopped out just the failing bits for brevity.
Code:
module TutorialFails =
let rnd = System.Random()
let rec randomWalk x =
seq { yield x
yield! randomWalk (x + rnd.NextDouble() - 0.5) }
let private parseHelper f = f >> function
| (true, item) -> Some item
| (false, _) -> None
let parseDateTimeOffset = parseHelper DateTimeOffset.TryParse
let result = parseDateTimeOffset "1970-01-01"
let parseInt = parseHelper Int32.TryParse
let parseDouble = parseHelper Double.TryParse
let parseTimeSpan = parseHelper TimeSpan.TryParse
let (|Int|_|) = parseInt
let (|Double|_|) = parseDouble
let (|Date|_|) = parseDateTimeOffset
let (|TimeSpan|_|) = parseTimeSpan
/// Pattern Matching via 'function' keyword and Active Patterns often looks like this.
let printParseResult = function
| Int x -> printfn "%d" x
| Double x -> printfn "%f" x
| Date d -> printfn "%s" (d.ToString())
| TimeSpan t -> printfn "%s" (t.ToString())
| _ -> printfn "Nothing was parse-able!"
(7,41)-(7,51) The field, constructor or member 'NextDouble' is not defined. Maybe you want one of the following:
Next
(15,37)-(15,49) This expression was expected to have type
'string * 'a * Globalization.DateTimeStyles'
but here has type
'string'
(30,10)-(30,16) Type mismatch. Expecting a
'string -> 'a option'
but given a
'string * 'b * Globalization.DateTimeStyles -> DateTimeOffset option'
The type 'string' does not match the type 'string * 'a * Globalization.DateTimeStyles'
(31,10)-(31,20) Type mismatch. Expecting a
'string -> 'a option'
but given a
'string * 'b -> TimeSpan option'
The type 'string' does not match the type 'string * 'a'
The latter three errors look like a difference in how globalization is handled for datetimes between this version of .NET and what VS is using. (VS Community 2019 16.25.3 if that helps.) Probably not a big deal.
But .NextDouble() being missing from System.Random is rather odd. .Next() is there but of course it produces an int not a float.
I'm pretty sure the presence of System.Random.NextDouble() is something that should be available consistently.
The text was updated successfully, but these errors were encountered:
This looks like a linkage issue: assemblies are stripped of unused code during compilation, unless they're listed here. We should keep the whole mscorlib, not just some specific type in it.
I figured it would be fun and interesting to try running the F# tutorial code that comes as a new project type with Visual Studio, in the 'try F# in your browser' example at https://tryfsharp.fsbolero.io/
There's a few compile errors. I chopped out just the failing bits for brevity.
Code:
Compile Errors from https://tryfsharp.fsbolero.io/ :
The latter three errors look like a difference in how globalization is handled for datetimes between this version of .NET and what VS is using. (VS Community 2019 16.25.3 if that helps.) Probably not a big deal.
But .NextDouble() being missing from System.Random is rather odd. .Next() is there but of course it produces an int not a float.
I'm pretty sure the presence of System.Random.NextDouble() is something that should be available consistently.
The text was updated successfully, but these errors were encountered: