I am looking through the Hopac documentation and I came across this weird error like:
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
Scrapers.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.
cis Cell<'a>. This code compiles 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 the two is the depth of the first indent - 2, not 4.
Usually, when there is a problem with indentation, I get a warning “Perhaps indentation is incorrect”, and not a type error. Therefore, it must be really confusing.
I've been using F # for ten years now, and I still don't understand the indentation rules.
What am I missing?
source
share