From 4202ca1ea20916c70ad83602decb0126de78b945 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Fri, 2 Apr 2010 14:40:06 +0900 Subject: [PATCH] supporting "lang" command. --- GHCMod.hs | 2 ++ Lang.hs | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 Lang.hs 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