X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=utils%2FmkUserGuidePart%2FMain.hs;fp=utils%2FmkUserGuidePart%2FMain.hs;h=114114ca1cee13fa07a99c769d57e138a555d1f0;hb=ab90e5fa171913fe777b2b6909030e3967e72bc6;hp=0000000000000000000000000000000000000000;hpb=c07d7849d440a1ff371690654205c02c06b56fd0;p=ghc-hetmet.git diff --git a/utils/mkUserGuidePart/Main.hs b/utils/mkUserGuidePart/Main.hs new file mode 100644 index 0000000..114114c --- /dev/null +++ b/utils/mkUserGuidePart/Main.hs @@ -0,0 +1,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 -> "" ++ [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 +