I'm going through the Hopac documentation, and I came across this bizarre type error:
let create x = Job.delay <| fun () -> let c = {reqCh = Ch (); replyCh = Ch ()} Job.iterateServer x <| fun x -> c.reqCh >>= function | Get -> c.replyCh *<- x >>-. x | Put x -> Job.result x>>-. cScrapers.SC.fsx(48,10): error FS0001: Type mismatch. Expecting a''a'but given a'Cell<'a>'The types ''a' and 'Cell<'a>' cannot be unified.
c
is a Cell<'a>
. This code compiles just fine with the code from the page:
let create x = Job.delay <| fun () -> let c = {reqCh = Ch (); replyCh = Ch ()} Job.iterateServer x <| fun x -> c.reqCh >>= function | Get -> c.replyCh *<- x >>-. x | Put x -> Job.result x>>-. c
The only difference between these two is the depth of the first indent -- 2 as opposed to 4.
Normally, when there's a problem with indentation, I get a "Possibly incorrect indentation" warning -- not a type error. So it must be really confused.
I've been using F# for ten years now, and I still don't understand the indentation rules.
What am I missing?