[commit: ghc] wip/nfs-locking: Add args -- a variadic version of arg. (6084342)
git at git.haskell.org
git at git.haskell.org
Thu Oct 26 23:18:14 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/nfs-locking
Link : http://ghc.haskell.org/trac/ghc/changeset/60843423d23b84928c2c1ce2725b5e293cb81061/ghc
>---------------------------------------------------------------
commit 60843423d23b84928c2c1ce2725b5e293cb81061
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date: Fri Jan 2 03:03:27 2015 +0000
Add args -- a variadic version of arg.
>---------------------------------------------------------------
60843423d23b84928c2c1ce2725b5e293cb81061
src/Base.hs | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/Base.hs b/src/Base.hs
index 77c2858..645d5dc 100644
--- a/src/Base.hs
+++ b/src/Base.hs
@@ -7,7 +7,7 @@ module Base (
module Data.Monoid,
module Data.List,
Stage (..),
- Args, arg,
+ Args, arg, args, ShowAction (..),
Condition (..),
joinArgs, joinArgsWithSpaces, splitArgs,
filterOut
@@ -38,6 +38,20 @@ instance ShowAction String where
arg :: ShowAction a => [a] -> Args
arg = mapM showAction
+class Collect a where
+ collect :: Args -> a
+
+instance Collect Args where
+ collect = id
+
+instance (ShowAction a, Collect r) => Collect (a -> r) where
+ collect prev next = collect $ do
+ next' <- showAction next
+ prev <> return [next']
+
+args :: Collect a => a
+args = collect mempty
+
intercalateArgs :: String -> Args -> Args
intercalateArgs s args = do
as <- args
More information about the ghc-commits
mailing list