driver supports stdin
This commit is contained in:
parent
ebcab6b75f
commit
60dd545928
1 changed files with 2 additions and 1 deletions
3
lamb.hs
3
lamb.hs
|
@ -9,6 +9,7 @@ import Interp (evalProgram, evalString, Value(UnitV))
|
||||||
-- returns Nothing if all files exist, or Just path for the first one that doesn't
|
-- returns Nothing if all files exist, or Just path for the first one that doesn't
|
||||||
allExist :: [String] -> IO (Maybe String)
|
allExist :: [String] -> IO (Maybe String)
|
||||||
allExist [] = return Nothing
|
allExist [] = return Nothing
|
||||||
|
allExist ("-":xs) = allExist xs
|
||||||
allExist (x:xs) = do
|
allExist (x:xs) = do
|
||||||
exists <- doesFileExist x
|
exists <- doesFileExist x
|
||||||
if exists then allExist xs
|
if exists then allExist xs
|
||||||
|
@ -16,7 +17,7 @@ allExist (x:xs) = do
|
||||||
|
|
||||||
evalFile :: String -> IO Value
|
evalFile :: String -> IO Value
|
||||||
evalFile path = do
|
evalFile path = do
|
||||||
contents <- readFile path
|
contents <- if path == "-" then getContents else readFile path
|
||||||
evalString contents
|
evalString contents
|
||||||
|
|
||||||
main = do
|
main = do
|
||||||
|
|
Loading…
Reference in a new issue