diff --git a/src/FSharpPlus/Control/Functor.fs b/src/FSharpPlus/Control/Functor.fs index 70609fb6b..33857b3e5 100644 --- a/src/FSharpPlus/Control/Functor.fs +++ b/src/FSharpPlus/Control/Functor.fs @@ -45,7 +45,9 @@ type Iterate = static member Iterate (x: Choice<'T, 'E> , action) = match x with Choice1Of2 x -> action x | _ -> () static member Iterate (KeyValue(_: 'Key, x: 'T), action) = action x : unit static member Iterate (x: Map<'Key,'T> , action) = Map.iter (const' action) x + static member Iterate (x: IDictionary<'Key, 'T>, action) = Dict.iterValues action x static member Iterate (x: Dictionary<'Key, 'T> , action) = Dictionary.iterValues action x + static member Iterate (x: IReadOnlyDictionary<'Key, 'T>, action) = IReadOnlyDictionary.iterValues action x static member Iterate (x: _ ResizeArray , action) = ResizeArray.iter action x // Restricted diff --git a/tests/FSharpPlus.Tests/General.fs b/tests/FSharpPlus.Tests/General.fs index 6b393fe27..97d0d522c 100644 --- a/tests/FSharpPlus.Tests/General.fs +++ b/tests/FSharpPlus.Tests/General.fs @@ -487,6 +487,22 @@ module Functor = let nel = zip (NonEmptyList.ofList [1; 2]) (NonEmptyList.ofList ["a"; "b"; "c"]) CollectionAssert.AreEqual (NonEmptyList.ofList [1,"a"; 2,"b"], nel) + [] + let iterTests () = + let li = [1, 2; 3, 4] + let di: Dictionary = ofList li + let id = dict li + let ir = readOnlyDict li + let ma = Map.ofList li + + let r = ResizeArray [] + + iter (r.Add << string) di + iter (r.Add << string) id + iter (r.Add << string) ir + iter (r.Add << string) ma + CollectionAssert.AreEqual (ResizeArray ["2"; "4"; "2"; "4"; "2"; "4"; "2"; "4"], r) + module Foldable =