Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Handle-a-signal/Haskell/handle-a-signal.hs
Normal file
15
Task/Handle-a-signal/Haskell/handle-a-signal.hs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import Prelude hiding (catch)
|
||||
import Control.Exception (catch, throwIO, AsyncException(UserInterrupt))
|
||||
import Data.Time.Clock (getCurrentTime, diffUTCTime)
|
||||
import Control.Concurrent (threadDelay)
|
||||
|
||||
main = do t0 <- getCurrentTime
|
||||
catch (loop 0)
|
||||
(\e -> if e == UserInterrupt
|
||||
then do t1 <- getCurrentTime
|
||||
putStrLn ("\nTime: " ++ show (diffUTCTime t1 t0))
|
||||
else throwIO e)
|
||||
|
||||
loop i = do print i
|
||||
threadDelay 500000 {- µs -}
|
||||
loop (i + 1)
|
||||
Loading…
Add table
Add a link
Reference in a new issue