Skip to content

Commit

Permalink
Merge pull request #116 from abailly-iohk/abailly-iohk/document-monad…
Browse files Browse the repository at this point in the history
…-delay

Provide minimal haddock comments for MonadDelay
  • Loading branch information
bolt12 authored Oct 11, 2023
2 parents 892076e + 66d2e7e commit 38222f6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions io-classes/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
`io-sim`, since the underlying monad is `ST`. `IO` has no underlying monad, so
the provided instance for `IO` defaults `inspectMVar` to `tryReadMVar`.

* Add some Haddock documentation to `MonadDelay`

## 1.1.0.0

### Breaking changes
Expand Down
10 changes: 10 additions & 0 deletions io-classes/src/Control/Monad/Class/MonadTimer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}

-- | Provides classes to handle delays and timeouts.
module Control.Monad.Class.MonadTimer
( MonadDelay (..)
, MonadTimer (..)
Expand All @@ -18,13 +19,22 @@ import Control.Monad.Trans (lift)

import qualified System.Timeout as IO

-- | A typeclass to delay current thread.
class Monad m => MonadDelay m where

-- | Suspends the current thread for a given number of microseconds
-- (GHC only).
--
-- See `IO.threadDelay`.
threadDelay :: Int -> m ()

-- | A typeclass providing utilities for /timeouts/.
class (MonadDelay m, MonadSTM m) => MonadTimer m where

-- | See `STM.registerDelay`.
registerDelay :: Int -> m (TVar m Bool)

-- | See `IO.timeout`.
timeout :: Int -> m a -> m (Maybe a)

--
Expand Down

0 comments on commit 38222f6

Please sign in to comment.