blob: 114114ca1cee13fa07a99c769d57e138a555d1f0 (
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
module Main (main) where
import DynFlags
import Data.List
import System.Environment
main :: IO ()
main = do args <- getArgs
case args of
[] -> error "Need to give filename to generate as an argument"
[f] ->
case f of
"docs/users_guide/what_glasgow_exts_does.gen.xml" ->
writeFile f whatGlasgowExtsDoes
_ ->
error ("Don't know what to do for " ++ show f)
_ -> error "Bad args"
whatGlasgowExtsDoes :: String
whatGlasgowExtsDoes = case maybeInitLast glasgowExtsFlags of
Just (xs, x) ->
let xs' = map mkInitLine xs
x' = mkLastLine x
in unlines (xs' ++ [x'])
Nothing ->
error "glasgowExtsFlags is empty?"
where mkInitLine = mkLine ','
mkLastLine = mkLine '.'
mkLine c f = case stripPrefix "Opt_" (show f) of
Just ext -> "<option>-X" ++ ext ++ "</option>" ++ [c]
Nothing -> error ("Can't parse extension: " ++ show f)
maybeInitLast :: [a] -> Maybe ([a], a)
maybeInitLast xs = case reverse xs of
(y : ys) -> Just (reverse ys, y)
_ -> Nothing
|