2012-02-14 02:33:27 +00:00
|
|
|
{-# LANGUAGE FlexibleInstances #-}
|
|
|
|
|
2010-04-30 09:36:31 +00:00
|
|
|
module Types where
|
|
|
|
|
2012-02-13 11:31:36 +00:00
|
|
|
data OutputStyle = LispStyle | PlainStyle
|
2012-02-14 01:21:48 +00:00
|
|
|
|
2010-04-30 09:36:31 +00:00
|
|
|
data Options = Options {
|
2012-02-27 02:23:56 +00:00
|
|
|
outputStyle :: OutputStyle
|
|
|
|
, hlintOpts :: [String]
|
|
|
|
, ghcOpts :: [String]
|
|
|
|
, operators :: Bool
|
2013-03-01 00:43:50 +00:00
|
|
|
, detailed :: Bool
|
2012-02-27 02:23:56 +00:00
|
|
|
, expandSplice :: Bool
|
2012-04-09 19:39:58 +00:00
|
|
|
, sandbox :: Maybe String
|
2012-02-27 02:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
defaultOptions :: Options
|
|
|
|
defaultOptions = Options {
|
|
|
|
outputStyle = PlainStyle
|
|
|
|
, hlintOpts = []
|
|
|
|
, ghcOpts = []
|
|
|
|
, operators = False
|
2013-03-01 00:43:50 +00:00
|
|
|
, detailed = False
|
2012-02-27 02:23:56 +00:00
|
|
|
, expandSplice = False
|
2012-04-09 19:39:58 +00:00
|
|
|
, sandbox = Nothing
|
2010-04-30 09:36:31 +00:00
|
|
|
}
|
|
|
|
|
2012-02-14 02:33:27 +00:00
|
|
|
----------------------------------------------------------------
|
2012-02-14 07:09:53 +00:00
|
|
|
|
2012-02-14 02:33:27 +00:00
|
|
|
convert :: ToString a => Options -> a -> String
|
|
|
|
convert Options{ outputStyle = LispStyle } = toLisp
|
|
|
|
convert Options{ outputStyle = PlainStyle } = toPlain
|
|
|
|
|
|
|
|
class ToString a where
|
|
|
|
toLisp :: a -> String
|
|
|
|
toPlain :: a -> String
|
|
|
|
|
|
|
|
instance ToString [String] where
|
|
|
|
toLisp = addNewLine . toSexp True
|
|
|
|
toPlain = unlines
|
|
|
|
|
|
|
|
instance ToString [((Int,Int,Int,Int),String)] where
|
|
|
|
toLisp = addNewLine . toSexp False . map toS
|
|
|
|
where
|
|
|
|
toS x = "(" ++ tupToString x ++ ")"
|
|
|
|
toPlain = unlines . map tupToString
|
|
|
|
|
|
|
|
toSexp :: Bool -> [String] -> String
|
|
|
|
toSexp False ss = "(" ++ unwords ss ++ ")"
|
|
|
|
toSexp True ss = "(" ++ unwords (map quote ss) ++ ")"
|
|
|
|
|
|
|
|
tupToString :: ((Int,Int,Int,Int),String) -> String
|
|
|
|
tupToString ((a,b,c,d),s) = show a ++ " "
|
|
|
|
++ show b ++ " "
|
|
|
|
++ show c ++ " "
|
|
|
|
++ show d ++ " "
|
|
|
|
++ quote s
|
|
|
|
|
|
|
|
quote :: String -> String
|
|
|
|
quote x = "\"" ++ x ++ "\""
|
|
|
|
|
|
|
|
addNewLine :: String -> String
|
|
|
|
addNewLine = (++ "\n")
|
2013-03-01 12:17:52 +00:00
|
|
|
|
2013-03-02 03:18:55 +00:00
|
|
|
----------------------------------------------------------------
|
|
|
|
|
|
|
|
data Cradle = Cradle {
|
2013-03-04 09:11:09 +00:00
|
|
|
cradleCurrentDir :: FilePath
|
|
|
|
, cradleCabalDir :: Maybe FilePath
|
|
|
|
, cradleCabalFile :: Maybe FilePath
|
|
|
|
, cradlePackageConf :: Maybe FilePath
|
2013-03-05 01:22:33 +00:00
|
|
|
} deriving (Eq, Show)
|
2013-03-02 03:18:55 +00:00
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
2013-03-01 12:17:52 +00:00
|
|
|
type GHCOption = String
|
|
|
|
type IncludeDir = FilePath
|
|
|
|
type Package = String
|
2013-04-01 05:16:34 +00:00
|
|
|
|
|
|
|
data CheckSpeed = Slow | Fast
|