on master help sign in
Fix EOF handling of replWith
commitb402e1dc222fa96558f586c1f16748eaea22aa01 authorKevin Boulain <kevinboulain@gmail.com> dateSat 10 Mar 2018, 20:02 (9 years ago) parent86615f0
1 file changed+8−6
libs/prelude/Prelude/Interactive.idr+8−6
libs/prelude/Prelude/Interactive.idr+8−6
@@ -160,12 +160,14 @@ partial
160160replWith : (state : a) -> (prompt : String) ->
161161 (onInput : a -> String -> Maybe (String, a)) -> IO ()
162162replWith acc prompt fn
163− = do putStr prompt
164− x <- getLine
165− case fn acc x of
166− Just (out, acc') => do putStr out
167− replWith acc' prompt fn
168− Nothing => pure ()
163+ = if !(fEOF stdin)
164+ then pure ()
165+ else do putStr prompt
166+ x <- getLine
167+ case fn acc x of
168+ Just (out, acc') => do putStr out
169+ replWith acc' prompt fn
170+ Nothing => pure ()
169171
170172||| A basic read-eval-print loop
171173||| @ prompt the prompt to show