Lets say I have a function
let makeMonitoredFun f =
let c = ref 0
(fun x -> c := !c+1; printf "Called %d times.\n" !c; f x);;
Why I am not allowed to do this.
let mrev = makeMonitoredFun List.rev
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
So presumably you are referring to the value type restriction you get when you try to compile the code. If you add a type annotation it will work fine/. For the details of value type errors see this article http://blogs.msdn.com/b/mulambda/archive/2010/05/01/value-restriction-in-f.aspx from one of the F# developers