You just need to get the order/indentation right. Check it out below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 

type IMonad<'a> =
    abstract Bind : ('a -> 'b) -> 'b
    abstract Unit : 'a -> IMonad<'a>

type Identity<'a> = 
  |Id of 'a
  with
    member m.foo() = match m with Id(a) -> a
    interface IMonad<'a> with
      member m.Bind f = match m with Id(a) -> f a
      member m.Unit x = Id(x):>IMonad<'a>

By on 2/12/2010 11:29 PM ()

ah, thanks. Though it is a bit confusing as the following seems to be ok. Or may be it is now what I think it is.

1
2
3
4
5
6
7
8
9
10
 

type Identity<'a>(x) = 
  let v = x
  interface IMonad<'a> with
    member m.Bind f = f v
    member m.Unit x = Identity(x):>IMonad<'a>
  with
    member m.foo() = x
By on 2/12/2010 11:40 PM ()
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