Skip to content

Commit cdb81a3

Browse files
authored
Align filterM filter type with iterM action type
1 parent e6f8549 commit cdb81a3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/FSharpPlus/List.fs

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ module ListT =
124124
else return Nil }
125125
loop count (input: ListT<'MT>)
126126

127-
let inline filterM (f: 'T -> ListT<'``M<bool>``>) (input: ListT<'MT>) : ListT<'MT> =
128-
input |> bind (fun v -> f v |> bind (fun b -> if b then singleton v else empty ()))
127+
let inline filterM (f: 'T -> '``M<bool>``) (input: ListT<'MT>) : ListT<'MT> =
128+
input |> bind (fun v -> lift (f v) |> bind (fun b -> if b then singleton v else empty ()))
129129

130-
let inline filter f (input: ListT<'MT>) : ListT<'MT> = filterM (f >> singleton) input
130+
let inline filter f (input: ListT<'MT>) : ListT<'MT> = filterM (f >> result) input
131131

132132
let inline run (lst: ListT<'MT>) : '``Monad<list<'T>>`` =
133133
let rec loop acc x = unwrap x >>= function

0 commit comments

Comments
 (0)