diff --git a/GHCMod.hs b/GHCMod.hs index fdb7830..a26cc3f 100644 --- a/GHCMod.hs +++ b/GHCMod.hs @@ -5,6 +5,7 @@ import Check import Control.Exception hiding (try) import List import Param +import Lang import Prelude hiding (catch) import System.Console.GetOpt import System.Environment (getArgs) @@ -63,6 +64,7 @@ main = flip catch handler $ do "browse" -> browseModule opt (cmdArg !! 1) "list" -> listModules opt "check" -> checkSyntax opt (cmdArg !! 1) + "lang" -> listLanguages opt _ -> error usage putStr res where diff --git a/Lang.hs b/Lang.hs new file mode 100644 index 0000000..423f6c9 --- /dev/null +++ b/Lang.hs @@ -0,0 +1,14 @@ +module Lang where + +import Control.Applicative +import Param +import System.IO +import System.Process + +listLanguages :: Options -> IO String +listLanguages opt = convert opt . lines <$> getLangs opt + +getLangs :: Options -> IO String +getLangs opt = do + (_,hout,_,_) <- runInteractiveProcess (ghc opt) ["--supported-languages"] Nothing Nothing + hGetContents hout