Hi,
first, of all, let me just slightly modify the type signature (because the first argument is a function that takes unit as the argument and returns a value which is the overall result):

1
let inline retry (f : unit -> 'a) (count : int) (delay : int) (logger : ILog) : 'a = //...

The problem with the code is that you're calling the 'retry' function with a function of type 'unit -> unit' as the argument. This means that when the function f is called inside the retry loop, you'll assign value of type 'unit' to the 'result' mutable variable. However, when initializing the 'result' variable, you assign it the 'null' value, which isn't compatible with the 'unit' type.

To fix this, you can use 'Unchecked.defaultof<'a>' primitive that returns default value of some type (and works with any type):

1
2
 
let mutable result = Unchecked.defaultof<'a>
By on 5/27/2009 5:12 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper