Skip to content

Commit

Permalink
Merge pull request #134 from input-output-hk/coot/cleanup
Browse files Browse the repository at this point in the history
Readme update & stylish-haskell changes
  • Loading branch information
coot authored Jan 30, 2024
2 parents 432005c + 8c034e3 commit f6919ea
Show file tree
Hide file tree
Showing 67 changed files with 634 additions and 628 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-22.04

env:
STYLISH_HASKELL_VERSION: "0.14.4.0"
STYLISH_HASKELL_VERSION: "0.14.6.0"

steps:
- name: Set cache version
Expand Down
19 changes: 19 additions & 0 deletions .stylish-haskell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,25 @@ steps:
# Default: false
space_surround: false

# Post qualify option moves any qualifies found in import declarations
# to the end of the declaration. This also adjust padding for any
# unqualified import declarations.
#
# - true: Qualified as <module name> is moved to the end of the
# declaration.
#
# > import Data.Bar
# > import Data.Foo qualified as F
#
# - false: Qualified remains in the default location and unqualified
# imports are padded to align with qualified imports.
#
# > import Data.Bar
# > import qualified Data.Foo as F
#
# Default: false
post_qualify: true

# Language pragmas
- language_pragmas:
# We can generate different styles of language pragma lists.
Expand Down
40 changes: 21 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[![Haskell CI](https://img.shields.io/github/actions/workflow/status/input-output-hk/io-sim/haskell.yml?branch=main&label=Build&style=for-the-badge)](https://github.com/input-output-hk/io-sim/actions/workflows/haskell.yml)
[![handbook](https://img.shields.io/badge/policy-Cardano%20Engineering%20Handbook-informational?style=for-the-badge)](https://input-output-hk.github.io/cardano-engineering-handbook)

# io-sim
# [`io-sim`]

`IOSim` is a simulator monad that supports:
[`IOSim`] is a simulator monad that supports:

* asynchronous exceptions
* simulated time
Expand All @@ -18,16 +18,16 @@
* tracing committed changes to `TVar`, `TMVar`s, etc.
* labeling of threads, `TVar`'s, etc.

`io-classes` provides an interface, which allows writing code that can be run
in both real `IO` and `IOSim`. It is a drop-in replacement for `IO`, and
[`io-classes`] provides an interface, which allows writing code that can be run
in both real `IO` and [`IOSim`]. It is a drop-in replacement for `IO`, and
supports interfaces commonly known from `base`, `exceptions`, `stm`, `async`,
or `time` packages.

One of the principles of `io-classes` was to stay as close to `IO` as possible,
thus most of the `IO` instances are directly referring to `base` or `async`
API. However, we made some distinctions, which are reported below.

`io-classes` supports a novel hierarchy for error-handling monads as well as
[`io-classes`] supports a novel hierarchy for error-handling monads as well as
more familiar `exception` style. The new hierarchy provides `bracket` and
`finally` functions in the `MonadThrow` class, while `catch` style operators
are provided by a super-class `MonadCatch`. Both `bracket` and `finally` are
Expand All @@ -36,7 +36,7 @@ exposing them through the more basic `MonadThrow` class informs the reader
/ reviewer that no tricky error handling is done in that section of the code
base.

`IOSim` exposes a detailed trace, which can be enhanced by labeling threads, or
[`IOSim`] exposes a detailed trace, which can be enhanced by labeling threads, or
mutable variables, tracing `Dynamic` values (which can be recovered from the
trace), or simple `String` based tracing. Although it's agnostic concerning
the logging framework, it worked for us particularly well using
Expand All @@ -55,26 +55,28 @@ a complex, highly concurrent, distributed system

## Packages

* `io-sim`: provides two simulator interpreters: `IOSim` and `IOSimPOR` - an
enhanced `IOSim` version with schedule discovery capabilities.
* `io-classes`: class bases interface, which allows to to abstract over the
* [`io-sim`]: provides two simulator interpreters: [`IOSim`] and
`IOSimPOR` - an enhanced [`IOSim`] version with schedule discovery
capabilities.
* [`io-classes`]: class bases interface, which allows to to abstract over the
monad
* `strict-stm`: strict STM operations
* `si-timers`: non-standard timers API
* [`strict-stm`]: strict STM operations
* [`si-timers`]: non-standard timers API

### Issues

New issues should be reported in this repository, we still have a list
of issues opened in the `ouroboros-network` repository:
New issues should be reported in [this][io-sim-issues] repository.

* [io-sim issues][io-sim-issues]
* [io-classes issues][io-sim-issues]
[`io-classes`]: https://hackage.haskell.org/package/io-classes
[`io-sim`]: https://hackage.haskell.org/package/io-sim

[io-sim-por-how-to]: ./io-sim/how-to-use-IOSimPOR.md
[ouroboros-network]: https://github.com/input-output-hk/ouroboros-network
[io-sim-issues]: https://github.com/input-output-hk/ouroboros-network/issues?q=is%3Aopen+is%3Aissue+label%3Aio-sim
[io-classes-issues]: https://github.com/input-output-hk/ouroboros-network/issues?q=is%3Aopen+is%3Aissue+label%3Aio-classes
[contra-tracer]: https://hackage.haskell.org/package/contra-tracer
[io-sim-issues]: https://github.com/input-output-hk/io-sim/issues
[io-sim-por-how-to]: ./io-sim/how-to-use-IOSimPOR.md
[io-sim-por]: https://github.com/input-output-hk/io-sim/blob/main/io-sim/how-to-use-IOSimPOR.md
[ouroboros-network]: https://github.com/input-output-hk/ouroboros-network

[`IOSim`]: https://hackage.haskell.org/package/io-sim/docs/Control-Monad-IOSim.html#t:IOSim

[bob-conf]: https://youtu.be/uedUGeWN4ZM
[zuriHac-2022]: https://youtu.be/tKIYQgJnGkA
1 change: 1 addition & 0 deletions io-classes-mtl/io-classes-mtl.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ library

hs-source-dirs: src
default-language: Haskell2010
default-extensions: ImportQualifiedPost
1 change: 1 addition & 0 deletions io-classes/io-classes.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ library
Control.Monad.Class.MonadTimer
Control.Monad.Class.MonadTest
default-language: Haskell2010
default-extensions: ImportQualifiedPost
other-extensions: CPP
DataKinds
DefaultSignatures
Expand Down
10 changes: 5 additions & 5 deletions io-classes/src/Control/Concurrent/Class/MonadMVar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ module Control.Concurrent.Class.MonadMVar
, MonadInspectMVar (..)
) where

import qualified Control.Concurrent.MVar as IO
import Control.Monad.Class.MonadThrow
import Control.Concurrent.MVar qualified as IO
import Control.Monad.Class.MonadThrow

import Control.Monad.Reader (ReaderT (..))
import Control.Monad.Trans (lift)
import Control.Monad.Reader (ReaderT (..))
import Control.Monad.Trans (lift)

import Data.Kind (Type)
import Data.Kind (Type)


class Monad m => MonadMVar m where
Expand Down
14 changes: 7 additions & 7 deletions io-classes/src/Control/Concurrent/Class/MonadSTM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ module Control.Concurrent.Class.MonadSTM
(module STM)
where

import Control.Monad.Class.MonadSTM as STM
import Control.Concurrent.Class.MonadSTM.TVar as STM
import Control.Concurrent.Class.MonadSTM.TMVar as STM
import Control.Concurrent.Class.MonadSTM.TChan as STM
import Control.Concurrent.Class.MonadSTM.TQueue as STM
import Control.Concurrent.Class.MonadSTM.TBQueue as STM
import Control.Concurrent.Class.MonadSTM.TArray as STM
import Control.Monad.Class.MonadSTM as STM
import Control.Concurrent.Class.MonadSTM.TVar as STM
import Control.Concurrent.Class.MonadSTM.TMVar as STM
import Control.Concurrent.Class.MonadSTM.TChan as STM
import Control.Concurrent.Class.MonadSTM.TQueue as STM
import Control.Concurrent.Class.MonadSTM.TBQueue as STM
import Control.Concurrent.Class.MonadSTM.TArray as STM

2 changes: 1 addition & 1 deletion io-classes/src/Control/Concurrent/Class/MonadSTM/TArray.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
--
module Control.Concurrent.Class.MonadSTM.TArray (type TArray) where

import Control.Monad.Class.MonadSTM.Internal
import Control.Monad.Class.MonadSTM.Internal
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ module Control.Concurrent.Class.MonadSTM.TBQueue
, traceTBQueueIO
) where

import Control.Monad.Class.MonadSTM.Internal
import Control.Monad.Class.MonadSTM.Internal
2 changes: 1 addition & 1 deletion io-classes/src/Control/Concurrent/Class/MonadSTM/TChan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ module Control.Concurrent.Class.MonadSTM.TChan
, isEmptyTChan
) where

import Control.Monad.Class.MonadSTM.Internal
import Control.Monad.Class.MonadSTM.Internal
2 changes: 1 addition & 1 deletion io-classes/src/Control/Concurrent/Class/MonadSTM/TMVar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ module Control.Concurrent.Class.MonadSTM.TMVar
, traceTMVarIO
) where

import Control.Monad.Class.MonadSTM.Internal
import Control.Monad.Class.MonadSTM.Internal
2 changes: 1 addition & 1 deletion io-classes/src/Control/Concurrent/Class/MonadSTM/TQueue.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ module Control.Concurrent.Class.MonadSTM.TQueue
, traceTQueueIO
) where

import Control.Monad.Class.MonadSTM.Internal
import Control.Monad.Class.MonadSTM.Internal
2 changes: 1 addition & 1 deletion io-classes/src/Control/Concurrent/Class/MonadSTM/TSem.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ module Control.Concurrent.Class.MonadSTM.TSem
, traceTSemIO
) where

import Control.Monad.Class.MonadSTM.Internal
import Control.Monad.Class.MonadSTM.Internal
2 changes: 1 addition & 1 deletion io-classes/src/Control/Concurrent/Class/MonadSTM/TVar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ module Control.Concurrent.Class.MonadSTM.TVar
, traceTVarIO
) where

import Control.Monad.Class.MonadSTM.Internal
import Control.Monad.Class.MonadSTM.Internal
40 changes: 20 additions & 20 deletions io-classes/src/Control/Monad/Class/MonadAsync.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,30 @@ module Control.Monad.Class.MonadAsync
, Concurrently (..)
) where

import Prelude hiding (read)
import Prelude hiding (read)

#if MIN_VERSION_base(4,18,0)
import Control.Applicative (Alternative (..))
import Control.Applicative (Alternative (..))
#else
import Control.Applicative (Alternative (..), liftA2)
import Control.Applicative (Alternative (..), liftA2)
#endif
import Control.Monad (forever)
import Control.Monad.Class.MonadFork
import Control.Monad.Class.MonadSTM
import Control.Monad.Class.MonadThrow
import Control.Monad.Class.MonadTimer

import Control.Monad.Reader (ReaderT (..))
import Control.Monad.Trans (lift)

import Control.Concurrent.Async (AsyncCancelled (..))
import qualified Control.Concurrent.Async as Async
import qualified Control.Exception as E

import Data.Bifunctor (first)
import Data.Foldable (fold)
import Data.Functor (void)
import Data.Kind (Type)
import Control.Monad (forever)
import Control.Monad.Class.MonadFork
import Control.Monad.Class.MonadSTM
import Control.Monad.Class.MonadThrow
import Control.Monad.Class.MonadTimer

import Control.Monad.Reader (ReaderT (..))
import Control.Monad.Trans (lift)

import Control.Concurrent.Async (AsyncCancelled (..))
import Control.Concurrent.Async qualified as Async
import Control.Exception qualified as E

import Data.Bifunctor (first)
import Data.Foldable (fold)
import Data.Functor (void)
import Data.Kind (Type)

class ( MonadSTM m
, MonadThread m
Expand Down
8 changes: 3 additions & 5 deletions io-classes/src/Control/Monad/Class/MonadEventlog.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
module Control.Monad.Class.MonadEventlog
( MonadEventlog (..)
) where
module Control.Monad.Class.MonadEventlog (MonadEventlog (..)) where

import Control.Monad.Reader
import Control.Monad.Reader

import qualified Debug.Trace as IO (traceEventIO, traceMarkerIO)
import Debug.Trace qualified as IO (traceEventIO, traceMarkerIO)

class Monad m => MonadEventlog m where

Expand Down
11 changes: 6 additions & 5 deletions io-classes/src/Control/Monad/Class/MonadFork.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ module Control.Monad.Class.MonadFork
, MonadFork (..)
) where

import qualified Control.Concurrent as IO
import Control.Exception (AsyncException (ThreadKilled), Exception, SomeException)
import Control.Monad.Reader (ReaderT (..), lift)
import Data.Kind (Type)
import qualified GHC.Conc.Sync as IO (labelThread)
import Control.Concurrent qualified as IO
import Control.Exception (AsyncException (ThreadKilled), Exception,
SomeException)
import Control.Monad.Reader (ReaderT (..), lift)
import Data.Kind (Type)
import GHC.Conc.Sync qualified as IO (labelThread)


class (Monad m, Eq (ThreadId m),
Expand Down
4 changes: 2 additions & 2 deletions io-classes/src/Control/Monad/Class/MonadST.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{-# LANGUAGE RankNTypes #-}
module Control.Monad.Class.MonadST (MonadST (..)) where

import Control.Monad.Reader
import Control.Monad.Reader

import Control.Monad.ST (ST, stToIO)
import Control.Monad.ST (ST, stToIO)


-- | This class is for abstracting over 'stToIO' which allows running 'ST'
Expand Down
18 changes: 9 additions & 9 deletions io-classes/src/Control/Monad/Class/MonadSTM.hs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
-- | This module corresponds to "Control.Monad.STM" in "stm" package
--
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
-- undecidable instances needed for 'WrappedSTM' instances of 'MonadThrow' and
-- 'MonadCatch' type classes.
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UndecidableInstances #-}
module Control.Monad.Class.MonadSTM
( MonadSTM (STM, atomically, retry, orElse, check)
, throwSTM
Expand All @@ -22,7 +22,7 @@ module Control.Monad.Class.MonadSTM
, MonadInspectSTM (..)
) where

import Control.Monad.Class.MonadSTM.Internal
import Control.Monad.Class.MonadSTM.Internal

-- $non-standard-extensions
--
Expand Down
Loading

0 comments on commit f6919ea

Please sign in to comment.