Skip to content

Commit efaccc9

Browse files
authored
Merge pull request #44 from i-am-tom/master
Add `extend` instance for `Array`
2 parents c393ee5 + e2ce8e0 commit efaccc9

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Control/Extend.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"use strict";
2+
3+
exports.arrayExtend = function(f) {
4+
return function(xs) {
5+
return xs.map(function (_, i, xs) {
6+
return f(xs.slice(i));
7+
});
8+
};
9+
};

src/Control/Extend.purs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ class Functor w <= Extend w where
2727
instance extendFn :: Semigroup w => Extend ((->) w) where
2828
extend f g w = f \w' -> g (w <> w')
2929

30+
foreign import arrayExtend :: forall a b. (Array a -> b) -> Array a -> Array b
31+
32+
instance extendArray :: Extend Array where
33+
extend = arrayExtend
34+
3035
infixr 1 extend as <<=
3136

3237
-- | A version of `extend` with its arguments flipped.

0 commit comments

Comments
 (0)