Add support for autoconf/configure chain.
[hadrian.git] / src / Base.hs
1 {-# LANGUAGE FlexibleInstances #-}
2
3 module Base (
4 module Development.Shake,
5 module Development.Shake.FilePath,
6 module Control.Applicative,
7 module Data.Monoid,
8 module Data.List,
9 Stage (..),
10 Args, arg, Condition,
11 joinArgs, joinArgsWithSpaces,
12 filterOut,
13 ) where
14
15 import Development.Shake hiding ((*>))
16 import Development.Shake.FilePath
17 import Control.Applicative
18 import Data.Monoid
19 import Data.List
20
21 data Stage = Stage0 | Stage1 | Stage2 | Stage3 deriving (Eq, Enum)
22
23 type Args = Action [String]
24
25 type Condition = Action Bool
26
27 instance Monoid a => Monoid (Action a) where
28 mempty = return mempty
29 mappend p q = mappend <$> p <*> q
30
31 arg :: [String] -> Args
32 arg = return
33
34 intercalateArgs :: String -> Args -> Args
35 intercalateArgs s args = do
36 as <- args
37 return [intercalate s as]
38
39 joinArgsWithSpaces :: Args -> Args
40 joinArgsWithSpaces = intercalateArgs " "
41
42 joinArgs :: Args -> Args
43 joinArgs = intercalateArgs ""
44
45 filterOut :: Args -> [String] -> Args
46 filterOut args list = filter (`notElem` list) <$> args