Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Control.Concurrent (threadDelay)
- data Time = Micros Int | Millis Int | Seconds Int | Minutes Int | Hours Int
- deriving Show
- -- unit relationships
- inMicros = id
- inMillis = inMicros . (* 1000)
- inSeconds = inMillis . (* 1000)
- inMinutes = inSeconds . (* 60)
- inHours = inMinutes . (* 60)
- toMicros time = case time of
- (Micros x) -> inMicros x
- (Millis x) -> inMillis x
- (Seconds x) -> inSeconds x
- (Minutes x) -> inMinutes x
- (Hours x) -> inHours x
- sleep x unit = threadDelay . fromIntegral . toMicros . unit $ x
- dosleep = sleep 5 Micros
Advertisement
Add Comment
Please, Sign In to add comment