5 ms·
my biggest nit is that it has a single pass compiler. this means the compiler can't infer the type for a function argument event though I pass it an `int` later
by natchy 6y ago
my biggest nit is that it has a single pass compiler. this means the compiler can't infer the type for a function argument event though I pass it an `int` later in the file.
more info: https://fsharpforfunandprofit.com/troubleshooting-fsharp/#fs0072-lookup-on-object-of-indeterminate-type https://fsharpforfunandprofit.com/troubleshooting-fsharp/#fs...
OCaml is better at type inference but it doesn't benefit from .Net libraries (the only reason I'm using F# over OCaml).
- phillipcarter 6y ago> this means the compiler can't infer the type for a function argument event though I pass it an `int` later in the file. That's demonstrably untrue by the simplest of code snippets. let f x = () f 12 Here, 'f' is generic becuase 'x' isn't used in a way that would constrain it in any way. let inline f x = x + 1 f 12 Here, 'f' is constrained to be generic over any type that defines how '+' works for it. let f x = x + 1 f 12 Here, 'f' is constrained to be 'int' because that's what's passed in and assumed as the type given that it's not marked as 'inline'. The article you link to is referring to type inference for .NET Object types, because member lookup is not used as a means to inform how type constraints are solved. When any primitive or any F# type (records, unions, anonymous records, etc.) is passed in the lookup is not indeterminate.
- natchy 6y agothat makes sense. I was having this problem integrating with asp.net core APIs. Sucked figuring that out and having to explicitly type my args. Only been a doing f# for a couple months. Thanks for the explanation. Keep crushing it.