value-restriction

F# compiler error FS0030, problems with the Value Restriction

I've read the blurb at StrangeLights, I've read the passage from Expert F# (page 119), but I can't see how they apply to my code: For my tests, I want to check equality between floats, with a bit of tolerance. I'm converting everything to units of measure, but I want to be able to be 'generic': let toleq (e:float<_>) a b = (abs ( a - b...

Understanding F# Value Restriction Errors

I don't understand how the Value Restriction in F# works. I've read the explanation in the wiki as well as the MSDN documentation. What I don't understand is: Why, for example, this gives me a Value Restriction error (Taken from this question): let toleq (e:float<_>) a b = (abs ( a - b ) ) < e But ths doesn't: let toleq e (a:floa...

Keeping partially applied function generic

Is it possible to partially apply a function such as bprintf and prevent it from being restricted based on its initial use? I'd like to do the following: let builder = new System.Text.StringBuilder() let append = Printf.bprintf builder append "%i" 10 append "%s" string_value ...