Skip to content

Commit 0bd3646

Browse files
authored
+Dict overload for <*>
1 parent 6c30108 commit 0bd3646

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/FSharpPlus/Control/Applicative.fs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ type Apply =
4747
| true, vx -> dct.Add (k, vf vx)
4848
| _ -> ()
4949
dct
50+
51+
static member ``<*>`` (f: IDictionary<'Key,_>, x: IDictionary<'Key,'T> , [<Optional>]_output: IDictionary<'Key,'U> , [<Optional>]_mthd: Apply) : IDictionary<'Key,'U> =
52+
let dct = Dictionary ()
53+
for KeyValue(k, vx) in x do
54+
match f.TryGetValue k with
55+
| true, vf -> dct.Add (k, vf vx)
56+
| _ -> ()
57+
dct :> IDictionary<'Key,'U>
5058

5159
static member ``<*>`` (f: Expr<'T->'U>, x: Expr<'T>, [<Optional>]_output: Expr<'U>, [<Optional>]_mthd: Apply) = Expr.Cast<'U> (Expr.Application (f, x))
5260
static member ``<*>`` (f: ('T->'U) ResizeArray, x: 'T ResizeArray, [<Optional>]_output: 'U ResizeArray, [<Optional>]_mthd: Apply) = ResizeArray.apply f x : 'U ResizeArray
@@ -131,4 +139,4 @@ type IsLeftZero with
131139
static member inline IsLeftZero (t: ref<'``Applicative<'T>``> , _mthd: Default1) = (^``Applicative<'T>`` : (static member IsLeftZero : _ -> _) t.Value)
132140
static member inline IsLeftZero (_: ref< ^t> when ^t: null and ^t: struct, _: Default1) = ()
133141

134-
#endif
142+
#endif

0 commit comments

Comments
 (0)