Created
November 27, 2011 09:17
-
-
Save elderica/1397285 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.Cmd (system) | |
import System.Environment (getArgs) | |
import Data.Text (breakOn, pack, unpack) | |
import Data.Maybe (fromJust) | |
compilers = [ | |
(".hs", "ghc"), | |
(".c", "make") | |
] | |
main = do | |
args <- getArgs | |
if null args | |
then error "no input filename" | |
else do | |
let (mod, ext) = breakOn (pack ".") $ pack $ head args | |
let mod' = unpack mod | |
let ext' = unpack ext | |
if null ext' | |
then error "no extension" | |
else do | |
let compiler = fromJust $ lookup ext' compilers | |
let command = unwords [compiler, mod'] | |
putStrLn command | |
system command | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment