fsprojects / fsprojects/FSharpPlus

Is it possible to add concrete implementation of monad for IObservable<'a> ?

Open
#459 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
F#
Stars
941
Forks
106
PR merge metrics
No merged PRs in 30d

Description

Currently IObservable<'a> works fine with map / |>>, but does not work with monad CE.

Since IObservable<'a> has LINQ extension methods IObservable.Select, IObservable.SelectMany and Observable.Return. It seems that it might be nature to have monad instance just following System.Reactive.Linq 's implementation.

As discussed in here, adding concrete implementation for IObservable<'a> in FSharpPlu.Control might be the easiest way to achieve this.

Is it possible to add monad instance concrete implementation directly to F#+?

If there is no other constrains, adding concreate implementation in Control/Monad.fs might be as easy as several lines of code to direct call IObservable<'a>'s corresponding extension methods.

But there might be some problems, like introduce dependency to System.Reactive, and maybe Using / Defer and other methods needs also be considered. But considering IObservable<'a> is already provided in System namespace, and Rx.Net is an popular functional style library, solving these problems might have enough benefits.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Control/Monad.fs and compare the existing monad CE support with System.Reactive.Linq's IObservable.Select, SelectMany, and Observable.Return. Determine whether a concrete IObservable<'a> instance belongs there without an unplanned System.Reactive dependency, and consider the mentioned Using and Defer methods. Done means the supported scope and dependency approach are resolved.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.