Hi Lewis,

Though I can't be sure, this looks like a complier bug to me. Extracting the operator from the class seems to get around this error:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module Monads.Core


type Identity<'a>(v: 'a) =
    static member Return x = Identity<'a>(x)
    static member Bind ( a: Identity<'a>, f )  : Identity<'a> = a.Value |> f
    member x.Value = v


module Test =
    let ( >>= ) m f = Identity<_>.Bind (m, f)
    let v =      3 |> Identity<_>.Return >>= fun x -> Identity<_>.Return (x + 1) // This typechecks.


type Identity with static member ( >>= ) (m, f) = Identity<'a>.Bind (m, f)
   

// Error: This function takes too many arguments, or is used in a context where a function is not expected.
let v =      3 |> Identity<_>.Return >>= fun x -> Identity<_>.Return (x + 1)


// Explicitly calling Identity's operator typechecks though.
let w =    Identity.(>>=) ( 3 |> Identity<_>.Return, fun x -> Identity<_>.Return <| x + 1 )

If you verify this would you please report this to fsbugs@microsoft.com including a link to this thread.

Regards,

Danny

By on 9/7/2008 6:22 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