Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
Allow fold_map to map underlying type for Any/Plus
Browse files Browse the repository at this point in the history
  • Loading branch information
mlms13 committed Dec 13, 2019
1 parent 70e0ba3 commit b59328c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/interfaces/Interface.re
Expand Up @@ -95,9 +95,9 @@ module type FOLDABLE = {

module Fold_Map: (M: MONOID) => {let fold_map: ('a => M.t, t('a)) => M.t;};
module Fold_Map_Any:
(M: MONOID_ANY) => {let fold_map: ('a => M.t('a), t('a)) => M.t('a);};
(M: MONOID_ANY) => {let fold_map: ('a => M.t('b), t('a)) => M.t('b);};
module Fold_Map_Plus:
(P: PLUS) => {let fold_map: ('a => P.t('a), t('a)) => P.t('a);};
(P: PLUS) => {let fold_map: ('a => P.t('b), t('a)) => P.t('b);};
};

module type UNFOLDABLE = {
Expand Down
6 changes: 6 additions & 0 deletions test/Test_List.re
Expand Up @@ -114,6 +114,12 @@ describe("List", () => {
expect(fold_map(List.Applicative.pure, [[1, 2, 3], [4, 5]]))
|> to_be([[1, 2, 3], [4, 5]]);
});

it("should do a map fold ('a => array('b))", () => {
let fold_map = ListF.Array.Fold_Map_Plus.fold_map;
expect(fold_map(Array.Applicative.pure <. Int.Show.show, [1, 2, 3]))
|> to_be([|"1", "2", "3"|])
});
});

describe("Unfoldable", () => {
Expand Down

0 comments on commit b59328c

Please sign in to comment.