From 60dd5459283b0ef93d7809ffc093c1943d470b0a Mon Sep 17 00:00:00 2001 From: darkf Date: Fri, 25 Oct 2013 18:16:19 -0700 Subject: [PATCH] driver supports stdin --- lamb.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lamb.hs b/lamb.hs index 7606832..a331226 100644 --- a/lamb.hs +++ b/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 allExist :: [String] -> IO (Maybe String) allExist [] = return Nothing +allExist ("-":xs) = allExist xs allExist (x:xs) = do exists <- doesFileExist x if exists then allExist xs @@ -16,7 +17,7 @@ allExist (x:xs) = do evalFile :: String -> IO Value evalFile path = do - contents <- readFile path + contents <- if path == "-" then getContents else readFile path evalString contents main = do