tags:

views:

137

answers:

3

Events work much like sequences in F#. You can use sequence expressions with sequences. Is there a similar builder for events? I couldn't find it.

If it doesn't exist, then why not? (is it imposssible or not suitable?) If the answer is that it's just not implemented yet then I'm going to give it a try.

Jules

A: 

While for sequences it makes sense to create a group of objects to process, for events it would be totally pointless. Please consider that events are just means to provide a reaction to something going on externally, so you should never need an event builder. If you've got an event handler doing some processing, you can easily split the logic and the event processing into separate functions and apply the function to data you're actually able to generate in advance or according to known rules and in a known order (for which you could actually use a sequence expression).

emaster70
+1  A: 

Maybe this helps:

Check Events in F# on how to create custom events. Then you could create a sequence and map, filter and iterate them.

+1  A: 

Tomas has done some research here, and this does seem a fruitful avenue.

Brian
Thanks, that looks good. I didn't think of providing functionality inside the Async builder, that's smart! Also thanks for the link, Tomas' website if filled with excellent material.Can you define a Bind and Return specifically for Events? I thought about if for a bit but didn't find a satisfactory answer. For example `event { let! a = eventA in a+2}` would do the same as `map (fun a -> a+1) eventA`. But what would `event { let! a = eventA in let! b = eventB in return a+b}` mean?I did find however that if you cache the last event that arrived you get time varying values as in Cells or FRP.
Jules
And for these Cells I could define a builder. Here is what I have so far: http://fsharpcells.codeplex.com/. I'd love to hear any comments.
Jules