Commit 60843423 authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Add args -- a variadic version of arg.

parent 1495a2d6
......@@ -7,7 +7,7 @@ module Base (
module Data.Monoid,
module Data.List,
Stage (..),
Args, arg,
Args, arg, args, ShowAction (..),
Condition (..),
joinArgs, joinArgsWithSpaces, splitArgs,
filterOut
......@@ -33,11 +33,25 @@ class ShowAction a where
showAction :: a -> Action String
instance ShowAction String where
showAction = return
showAction = return
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment