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 53
53
54
54
map :: forall a b. (a -> b) -> [a] -> [b]
55
55
56
+ mapMaybe :: forall a b. (a -> Maybe b) -> [a] -> [b]
57
+
56
58
nub :: forall a. (Eq a) => [a] -> [a]
57
59
58
60
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
200
200
\ };\
201
201
\}" :: forall a b . (a -> b ) -> [a ] -> [b ]
202
202
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)
217
205
218
206
foreign import filter
219
207
" function filter (f) {\
You can’t perform that action at this time.
0 commit comments