[commit: ghc] wip/nfs-locking: Add prefixArgs function. (4c715ac)
git at git.haskell.org
git at git.haskell.org
Thu Oct 26 23:48:37 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/nfs-locking
Link : http://ghc.haskell.org/trac/ghc/changeset/4c715acd811aef3c2be59375280c586e22fc0ecc/ghc
>---------------------------------------------------------------
commit 4c715acd811aef3c2be59375280c586e22fc0ecc
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date: Sat Jan 10 19:13:55 2015 +0000
Add prefixArgs function.
>---------------------------------------------------------------
4c715acd811aef3c2be59375280c586e22fc0ecc
src/Base.hs | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/Base.hs b/src/Base.hs
index de0c3d6..ffb2bbb 100644
--- a/src/Base.hs
+++ b/src/Base.hs
@@ -10,7 +10,8 @@ module Base (
Args, arg, ShowArgs (..),
Condition (..),
(<+>),
- filterOut
+ filterOut,
+ prefixArgs
) where
import Development.Shake
@@ -47,13 +48,20 @@ instance ShowArgs a => ShowArgs (Action a) where
arg :: ShowArgs a => a -> Args
arg = showArgs
--- Combine two heterogeneous ShowArgs values.
+-- Combine two heterogeneous ShowArgs values
(<+>) :: (ShowArgs a, ShowArgs b) => a -> b -> Args
a <+> b = (<>) <$> showArgs a <*> showArgs b
infixr 6 <+>
+-- Filter out given arg(s) from a collection
filterOut :: ShowArgs a => Args -> a -> Args
filterOut as exclude = do
exclude' <- showArgs exclude
filter (`notElem` exclude') <$> as
+
+-- Prefix each arg in a collection with a given prefix
+prefixArgs :: (ShowArgs a, ShowArgs b) => a -> b -> Args
+prefixArgs prefix as = do
+ prefix' <- showArgs prefix
+ concatMap (\a -> prefix' ++ [a]) <$> showArgs as
More information about the ghc-commits
mailing list