2 module Main (main) where
7 import System.Environment
10 main = do args <- getArgs
12 [] -> error "Need to give filename to generate as an argument"
15 "docs/users_guide/what_glasgow_exts_does.gen.xml" ->
16 writeFile f whatGlasgowExtsDoes
18 error ("Don't know what to do for " ++ show f)
21 whatGlasgowExtsDoes :: String
22 whatGlasgowExtsDoes = case maybeInitLast glasgowExtsFlags of
24 let xs' = map mkInitLine xs
26 in unlines (xs' ++ [x'])
28 error "glasgowExtsFlags is empty?"
29 where mkInitLine = mkLine ','
30 mkLastLine = mkLine '.'
31 mkLine c f = case stripPrefix "Opt_" (show f) of
32 Just ext -> "<option>-X" ++ ext ++ "</option>" ++ [c]
33 Nothing -> error ("Can't parse extension: " ++ show f)
35 maybeInitLast :: [a] -> Maybe ([a], a)
36 maybeInitLast xs = case reverse xs of
37 (y : ys) -> Just (reverse ys, y)