Base.hs 1.03 KB
Newer Older
1
2
3
4
5
module Base (
    module Development.Shake,
    module Development.Shake.FilePath,
    module Control.Applicative,
    module Data.Monoid,
6
    module Data.List,
7
    Stage (..),
8
    Args, arg,
9
    joinArgs, joinArgsWithSpaces, splitArgs,
10
    filterOut
11
12
    ) where

Andrey Mokhov's avatar
Andrey Mokhov committed
13
import Development.Shake
14
import Development.Shake.FilePath
Andrey Mokhov's avatar
Andrey Mokhov committed
15
import Control.Applicative hiding ((*>))
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import Data.Monoid
import Data.List

data Stage = Stage0 | Stage1 | Stage2 | Stage3 deriving (Eq, Enum)

type Args = Action [String]

instance Monoid a => Monoid (Action a) where
    mempty = return mempty
    mappend p q = mappend <$> p <*> q

arg :: [String] -> Args
arg = return

intercalateArgs :: String -> Args -> Args
intercalateArgs s args = do
    as <- args
    return [intercalate s as]

joinArgsWithSpaces :: Args -> Args
joinArgsWithSpaces = intercalateArgs " "

joinArgs :: Args -> Args
joinArgs = intercalateArgs ""

41
42
43
splitArgs :: Args -> Args
splitArgs = fmap (concatMap words)

44
45
filterOut :: Args -> [String] -> Args
filterOut args list = filter (`notElem` list) <$> args