From 7f16ca95e37162584635bda66dfb97538c9590c0 Mon Sep 17 00:00:00 2001 From: darkf Date: Sat, 17 Jan 2015 03:14:17 -0800 Subject: [PATCH] Interp: implement freadcontents --- Interp.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Interp.hs b/Interp.hs index a7d535c..39fd7c0 100644 --- a/Interp.hs +++ b/Interp.hs @@ -128,6 +128,9 @@ _fgetline (StreamV handle) = do _freadbytes (TupleV [StreamV handle, IntV n]) = do liftIO $ StrV . T.take (fromIntegral n) <$> TIO.hGetContents handle +_freadcontents (StreamV handle) = do + liftIO $ StrV <$> TIO.hGetContents handle + _fopen (TupleV [StrV path, StrV mode]) = do let mode' = case T.unpack mode of "r" -> ReadMode @@ -251,6 +254,7 @@ initialState = [M.fromList $ map (\(k,v) -> (T.pack k, v)) $ [ ("fputbytes", bif _fputstr), ("fputstr", bif _fputstr), ("freadbytes", bif _freadbytes), + ("freadcontents", bif _freadcontents), ("feof", bif _feof), ("fclose", bif _fclose), ("fopen", bif _fopen),