Skip to content

Commit

Permalink
Merge pull request #44 from i-am-tom/master
Browse files Browse the repository at this point in the history
Add `extend` instance for `Array`
  • Loading branch information
garyb authored May 29, 2017
2 parents c393ee5 + e2ce8e0 commit efaccc9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Control/Extend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use strict";

exports.arrayExtend = function(f) {
return function(xs) {
return xs.map(function (_, i, xs) {
return f(xs.slice(i));
});
};
};
5 changes: 5 additions & 0 deletions src/Control/Extend.purs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class Functor w <= Extend w where
instance extendFn :: Semigroup w => Extend ((->) w) where
extend f g w = f \w' -> g (w <> w')

foreign import arrayExtend :: forall a b. (Array a -> b) -> Array a -> Array b

instance extendArray :: Extend Array where
extend = arrayExtend

infixr 1 extend as <<=

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

0 comments on commit efaccc9

Please sign in to comment.