File tree Expand file tree Collapse file tree 2 files changed +4
-14
lines changed Expand file tree Collapse file tree 2 files changed +4
-14
lines changed Original file line number Diff line number Diff line change 5353
5454 map :: forall a b. (a -> b) -> [a] -> [b]
5555
56+ mapMaybe :: forall a b. (a -> Maybe b) -> [a] -> [b]
57+
5658 nub :: forall a. (Eq a) => [a] -> [a]
5759
5860 nubBy :: forall a. (a -> a -> Prim.Boolean) -> [a] -> [a]
Original file line number Diff line number Diff line change @@ -200,20 +200,8 @@ foreign import map
200200 \ };\
201201 \}" :: forall a b . (a -> b ) -> [a ] -> [b ]
202202
203- foreign import mapMaybe
204- " function mapMaybe (f) {\
205- \ return function (arr) {\
206- \ var l = arr.length, n = 0;\
207- \ var result = new Array();\
208- \ for (var i = 0; i < l; i++) {\
209- \ var x = f(arr[i]);\
210- \ if (x.ctor === 'Data.Maybe.Just') {\
211- \ result[n++] = x.values[0];\
212- \ }\
213- \ }\
214- \ return result;\
215- \ };\
216- \}" :: forall a b . (a -> Maybe b ) -> [a ] -> [b ]
203+ mapMaybe :: forall a b . (a -> Maybe b ) -> [a ] -> [b ]
204+ mapMaybe f = concatMap (maybe [] singleton <<< f)
217205
218206foreign import filter
219207 " function filter (f) {\
You can’t perform that action at this time.
0 commit comments