Skip to content

Commit 4b97aae

Browse files
committed
Add >>= and >=> for Reader
1 parent c525bcb commit 4b97aae

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/FSharpPlus/Data/Reader.fs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,18 @@ type ReaderT<'r,'``monad<'t>``> with
155155
/// <category index="2">Applicative</category>
156156
static member inline (<* ) (x: ReaderT<'R, '``Monad<'U>``>, y: ReaderT<'R, '``Monad<'T>``>) : ReaderT<'R, '``Monad<'U>``> = ((fun (k: 'U) (_: 'T) -> k ) </ReaderT.map/> x : ReaderT<'R, '``Monad<'T->'U>``>) </ReaderT.apply/> y
157157

158+
/// <summary>
159+
/// Takes a Reader value and a function from a plain type to a Reader value, and returns a new Reader value.
160+
/// </summary>
161+
/// <category index="2">Monad</category>
158162
static member inline (>>=) (x: ReaderT<_,'``Monad<'T>``>, f: 'T->ReaderT<'R,'``Monad<'U>``>) = ReaderT.bind f x : ReaderT<'R, '``Monad<'U>``>
159-
163+
164+
/// <summary>
165+
/// Composes left-to-right two Reader functions (Kleisli composition).
166+
/// </summary>
167+
/// <category index="2">Monad</category>
168+
static member inline (>=>) (f: 'T -> ReaderT<_,'``Monad<'U>``>, g: 'U -> ReaderT<'R,'``Monad<'V>``>) : 'T -> ReaderT<'R,'``Monad<'V>``> = fun x -> ReaderT.bind g (f x)
169+
160170
static member inline get_Empty () = ReaderT (fun _ -> getEmpty ()) : ReaderT<'R, '``MonadPlus<'T>``>
161171
static member inline (<|>) (ReaderT m, ReaderT n) = ReaderT (fun r -> m r <|> n r) : ReaderT<'R, '``MonadPlus<'T>``>
162172

0 commit comments

Comments
 (0)