I think I got it:

1
2
3
4
5
6
member Bind : M 'a * ('a -> M 'b) -> M 'b   

member Return : 'a -> M 'a 

member ReturnFrom: 'a -> 'a

What would be the typical use case?

By on 10/27/2009 1:25 PM ()

I thought ReturnFrom had the same signature as Return

1
2
abstract member ReturnFrom : 'a -> M<'a>

At least, that's how its listed in Programming F#. Of course, the implementation of AsyncBuilder in Control.fs would lead one to believe the signature is

1
2
abstract member ReturnFrom : M<'a> -> M<'a>

Maybe someone from the team will weight-in on this? Or perhaps the updated language spec will hold the answers?

Anyway, as for typical usage, if we don't know the signature, I don't think we can meaningfully reason about its (intended/optimal) usage. Having said that... perhaps its for nesting computation expressions?

By on 10/27/2009 3:21 PM ()

I think the common signatures of ReturnFrom/YieldFrom would be Ma->Ma, and a typical implementation would be the identity function.

That said, these are just syntactic sugar translations, you can give them weird types that completely diverge for the common case. When we update the language spec for this release, it will show the translation logic, like in "6.4.10 Computation Expressions" now:

[link:research.microsoft.com]

As a crazy example, Don coded up a prototype of an 'observable' monad whose 'For' looped over observables (rather than sequences), and whose let! bound Asyncs (rather than IObservables). Like LINQ, the translation is specified with a great deal of flexibility, which creates opportunities to do weird useful stuff (outside of 'intended'/'optimal' usage). I expect sometime in the next month or so someone will blog about all that.

By on 10/27/2009 4:33 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