Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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