blob: 9f8d84974e7405e3917429b00b5355621eaa0735 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
{-# LANGUAGE OverloadedStrings #-}
module CommandLineOptions
( Options(..)
, parseOptions
) where
import Data.Text (Text)
data Options = Options
{ materials :: [Text]
, ignoreMaterials :: [Text]
} deriving (Eq, Show)
parseOptions :: [Text] -> Options
parseOptions args =
case splitWhere (== "--without") args of
(materials, ignoredMaterials) -> Options materials ignoredMaterials
splitWhere :: (a -> Bool) -> [a] -> ([a], [a])
splitWhere match (x:xs) | match x = ([], xs)
splitWhere match (x:xs) =
case (splitWhere match xs) of
(ys, zs) -> (x:ys, zs)
splitWhere _ [] = ([], [])
|