Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

simplify

  • Loading branch information...
commit 3fb77926c103d1551dce48631d35dfb3ec74bd3a 1 parent 5cc1872
@mikeplus64 authored
Showing with 8 additions and 6 deletions.
  1. +8 −6 src/Language/Haskell/Repl.hs
View
14 src/Language/Haskell/Repl.hs
@@ -67,8 +67,8 @@ prompt
-> String -- ^ Expression used for results.
-> IO [String]
prompt r xs x = do
- let trimLines = case lineLength r of
- Just l -> map (take l)
+ let trimLine = case lineLength r of
+ Just l -> take l
_ -> id
enter r xs x
lazyResults <- results r
@@ -82,9 +82,10 @@ prompt r xs x = do
threadDelay p
killThread tr
prog <- readIORef ir
- let hs = trimLines (take prog lazyResults)
- all ends hs `seq` putMVar final (trimLines hs)
- _ -> putMVar final (trimLines lazyResults)
+ let hs = map trimLine (take prog lazyResults)
+ ends hs `seq` putMVar final hs
+
+ _ -> putMVar final (map trimLine lazyResults)
fin <- takeMVar final
killThread timeout
@@ -106,8 +107,9 @@ ends (_:xs) = ends xs
-- | See 'how far' a lazy list has evaluated.
progress :: [a] -> IO (ThreadId, IORef Int)
+progress [] = (,) <$> forkIO (return ()) <*> newIORef 0
progress xs = do
- r <- newIORef 1
+ r <- newIORef 0
let go [] = return ()
go (_:ys) = modifyIORef r (+1) >> go ys
t <- forkIO (go xs)
Please sign in to comment.
Something went wrong with that request. Please try again.