Base.hs 1.06 KB
Newer Older
1
2
3
4
5
6
7
{-# LANGUAGE FlexibleInstances #-}

module Base (
    module Development.Shake,
    module Development.Shake.FilePath,
    module Control.Applicative,
    module Data.Monoid,
8
    module Data.List,
9
    Stage (..),
10
    Args, arg,
11
    joinArgs, joinArgsWithSpaces, splitArgs,
12
    filterOut
13
14
15
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
41
42
    ) where

import Development.Shake hiding ((*>))
import Development.Shake.FilePath
import Control.Applicative
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 ""

43
44
45
splitArgs :: Args -> Args
splitArgs = fmap (concatMap words)

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