Rename and remodularise

This commit is contained in:
Michael Walker 2015-01-31 15:50:54 +00:00
parent 304df27a35
commit fbc262c361
14 changed files with 80 additions and 76 deletions

View File

@ -1,28 +1,29 @@
monad-conc [![Build Status][build-status]][build-log]
==========
dejafu [![Build Status][build-status]][build-log]
======
Concurrency is nice, deadlocks and race conditions not so much. The
`Par` monad family, as defined in [abstract-par][] provides
deterministic parallelism, but sometimes we can tolerate a bit of
nondeterminism.
This package provides a family of monads for potentially
This package provides a class of monads for potentially
nondeterministic concurrency, with an interface very much in the
spirit of `Par`, but slightly more relaxed. Specifically, `Conc`'s
`IVar` equivalent, `CVar`s, can be written to multiple times.
spirit of `Par`, but slightly more relaxed. Specifically,
`MonadConc`'s `IVar` equivalent, `CVar`s, can be written to multiple
times.
The documentation of the latest developmental version is
[available online][docs].
`Conc` and `IO`
---------------
`MonadConc` and `IO`
--------------------
The intention of the `Conc` monads is to provide concurrency where any
apparent nondeterminism arises purely from the scheduling
behaviour. To put it another way, a given `Conc` computation,
parametrised with a fixed set of scheduling decisions, is
deterministic. This assumption is used by the testing functionality
provided by Control.Monad.Conc.SCT.
The intention of the `MonadConc` class is to provide concurrency where
any apparent nondeterminism arises purely from the scheduling
behaviour. To put it another way, a given computation, parametrised
with a fixed set of scheduling decisions, is deterministic. This
assumption is used by the testing functionality provided by
Control.Monad.Conc.SCT.
Whilst this assumption may not hold in general when `IO` is involved,
you should strive to produce test cases where it does.
@ -35,7 +36,7 @@ Bug reports, pull requests, and comments are very welcome!
Feel free to contact me on GitHub, through IRC (#haskell on freenode),
or email (mike@barrucadu.co.uk).
[build-status]: https://travis-ci.org/barrucadu/monad-conc.svg?branch=master
[build-log]: https://travis-ci.org/barrucadu/monad-conc
[build-status]: https://travis-ci.org/barrucadu/dejafu.svg?branch=master
[build-log]: https://travis-ci.org/barrucadu/dejafu
[abstract-par]: https://hackage.haskell.org/package/abstract-par/docs/Control-Monad-Par-Class.html
[docs]: https://barrucadu.github.io/monad-conc
[docs]: https://barrucadu.github.io/dejafu

View File

@ -2,7 +2,7 @@
-- | Useful functions for writing SCT test cases for @Conc@
-- computations.
module Control.Monad.Conc.SCT.Tests
module Test.DejaFu
( doTests
, doTests'
, autocheck
@ -33,16 +33,16 @@ import Control.Applicative ((<$>))
import Control.Arrow (first)
import Control.DeepSeq (NFData(..))
import Control.Monad (when, void)
import Control.Monad.Conc.Fixed
import Control.Monad.Conc.SCT.Internal
import Control.Monad.Conc.SCT.Bounding
import Control.Monad.Conc.SCT.Shrink
import Data.Function (on)
import Data.List (foldl')
import Data.List.Extra
import Data.Maybe (mapMaybe, isJust, isNothing)
import Test.DejaFu.Deterministic
import Test.DejaFu.SCT.Internal
import Test.DejaFu.SCT.Bounding
import Test.DejaFu.Shrink
import qualified Control.Monad.Conc.Fixed.IO as CIO
import qualified Test.DejaFu.Deterministic.IO as CIO
-- * Test suites

View File

@ -3,7 +3,7 @@
{-# LANGUAGE TypeFamilies #-}
-- | Concurrent monads with a fixed scheduler.
module Control.Monad.Conc.Fixed
module Test.DejaFu.Deterministic
( -- * The Conc Monad
Conc
, Trace
@ -23,15 +23,15 @@ module Control.Monad.Conc.Fixed
, tryTakeCVar
-- * Schedulers
, module Control.Monad.Conc.Fixed.Schedulers
, module Test.DejaFu.Deterministic.Schedulers
) where
import Control.Applicative (Applicative(..), (<$>))
import Control.Monad.Conc.Fixed.Internal
import Control.Monad.Conc.Fixed.Schedulers
import Control.Monad.Cont (cont, runCont)
import Control.Monad.ST (ST, runST)
import Data.STRef (STRef, newSTRef, readSTRef, writeSTRef)
import Test.DejaFu.Deterministic.Internal
import Test.DejaFu.Deterministic.Schedulers
import qualified Control.Monad.Conc.Class as C

View File

@ -10,7 +10,7 @@
-- You should therefore keep 'IO' blocks small, and only perform
-- blocking operations with the supplied primitives, insofar as
-- possible.
module Control.Monad.Conc.Fixed.IO
module Test.DejaFu.Deterministic.IO
( -- * The Conc Monad
Conc
, Trace
@ -31,14 +31,14 @@ module Control.Monad.Conc.Fixed.IO
, tryTakeCVar
-- * Schedulers
, module Control.Monad.Conc.Fixed.Schedulers
, module Test.DejaFu.Deterministic.Schedulers
) where
import Control.Applicative (Applicative(..), (<$>))
import Control.Monad.Conc.Fixed.Internal
import Control.Monad.Conc.Fixed.Schedulers
import Control.Monad.Cont (cont, runCont)
import Data.IORef (IORef, newIORef, readIORef, writeIORef)
import Test.DejaFu.Deterministic.Internal
import Test.DejaFu.Deterministic.Schedulers
import qualified Control.Monad.Conc.Class as C
import qualified Control.Monad.IO.Class as IO

View File

@ -3,7 +3,7 @@
-- | Concurrent monads with a fixed scheduler: internal types and
-- functions.
module Control.Monad.Conc.Fixed.Internal where
module Test.DejaFu.Deterministic.Internal where
import Control.DeepSeq (NFData(..))
import Control.Monad (liftM, mapAndUnzipM)

View File

@ -1,5 +1,5 @@
-- | Schedulers for the fixed @Conc@ monads.
module Control.Monad.Conc.Fixed.Schedulers
module Test.DejaFu.Deterministic.Schedulers
( -- * Types
Scheduler
, ThreadId
@ -15,9 +15,9 @@ module Control.Monad.Conc.Fixed.Schedulers
, toList
) where
import Control.Monad.Conc.Fixed.Internal
import Data.List.Extra
import System.Random (RandomGen, randomR)
import Test.DejaFu.Deterministic.Internal
-- | A simple random scheduler which, at every step, picks a random
-- thread to run.

View File

@ -29,7 +29,7 @@
-- thread 1 will have lock @a@ and be waiting on @b@, and thread 2
-- will have @b@ and be waiting on @a@.
module Control.Monad.Conc.SCT
module Test.DejaFu.SCT
( -- * Types
SCTScheduler
, SchedTrace
@ -66,10 +66,10 @@ module Control.Monad.Conc.SCT
, showTrace
) where
import Control.Monad.Conc.Fixed
import Control.Monad.Conc.SCT.Internal
import Control.Monad.Conc.SCT.Bounding
import System.Random (RandomGen)
import Test.DejaFu.Deterministic
import Test.DejaFu.SCT.Internal
import Test.DejaFu.SCT.Bounding
-- * Random Schedulers

View File

@ -2,14 +2,14 @@
-- Building blocks for SCT runners based on schedule bounding, with
-- implementations of pre-emption bounding and delay bounding.
module Control.Monad.Conc.SCT.Bounding where
module Test.DejaFu.SCT.Bounding where
import Control.DeepSeq (NFData(..), force)
import Control.Monad.Conc.Fixed
import Control.Monad.Conc.SCT.Internal
import Data.List.Extra
import Test.DejaFu.Deterministic
import Test.DejaFu.SCT.Internal
import qualified Control.Monad.Conc.Fixed.IO as CIO
import qualified Test.DejaFu.Deterministic.IO as CIO
-- * Pre-emption bounding

View File

@ -2,14 +2,14 @@
-- | A runner for concurrent monads to systematically detect
-- concurrency errors such as data races and deadlocks: internal definitions.
module Control.Monad.Conc.SCT.Internal where
module Test.DejaFu.SCT.Internal where
import Control.DeepSeq (NFData(..))
import Control.Monad.Conc.Fixed
import Control.Monad.Loops (unfoldrM)
import Data.List (unfoldr)
import Test.DejaFu.Deterministic
import qualified Control.Monad.Conc.Fixed.IO as CIO
import qualified Test.DejaFu.Deterministic.IO as CIO
-- * Types

View File

@ -2,7 +2,7 @@
-- | Functions for attempting to find maximally simple traces
-- producing a given result.
module Control.Monad.Conc.SCT.Shrink
module Test.DejaFu.Shrink
( -- * Trace shrinking
shrink
, shrink'
@ -20,16 +20,16 @@ module Control.Monad.Conc.SCT.Shrink
) where
import Control.Applicative ((<$>))
import Control.Monad.Conc.Fixed
import Control.Monad.Conc.SCT.Bounding
import Control.Monad.Conc.SCT.Internal
import Data.Function (on)
import Data.List (sortBy, isPrefixOf)
import Data.List.Extra
import Data.Maybe (fromJust, listToMaybe)
import Data.Ord (comparing)
import Test.DejaFu.Deterministic
import Test.DejaFu.SCT.Bounding
import Test.DejaFu.SCT.Internal
import qualified Control.Monad.Conc.Fixed.IO as CIO
import qualified Test.DejaFu.Deterministic.IO as CIO
-- | Attempt to find a trace with a minimal number of pre-emptions
-- that gives rise to the desired output.

View File

@ -1,9 +1,9 @@
-- Initial monad-conc.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
name: monad-conc
name: dejafu
version: 0.0.0.0
synopsis: Overloadable primitives for potentially non-deterministic concurrency.
synopsis: Overloadable primitives for testable, potentially non-deterministic, concurrency.
description:
Concurrency is nice, deadlocks and race conditions not so much. The
@ -12,27 +12,28 @@ description:
provides deterministic parallelism, but sometimes we can tolerate a
bit of nondeterminism.
.
This package provides a family of monads for potentially
This package provides a class of monads for potentially
nondeterministic concurrency, with an interface very much in the
spirit of @Par@, but slightly more relaxed. Specifically, @Conc@'s
@IVar@ equivalent, @CVar@s, can be written to multiple times.
spirit of @Par@, but slightly more relaxed. Specifically,
@MonadConc@'s @IVar@ equivalent, @CVar@s, can be written to multiple
times.
.
== @Conc@ monads with 'IO':
== @MonadConc@ with 'IO':
.
The intention of the @Conc@ monads is to provide concurrency where
any apparent nondeterminism arises purely from the scheduling
behaviour. To put it another way, a given @Conc@ computation,
parametrised with a fixed set of scheduling decisions, is
deterministic. This assumption is used by the testing functionality
provided by Control.Monad.Conc.SCT.
The intention of the @MonadConc@ class is to provide concurrency
where any apparent nondeterminism arises purely from the scheduling
behaviour. To put it another way, a given computation, parametrised
with a fixed set of scheduling decisions, is deterministic. This
assumption is used by the testing functionality provided by
Test.DejaFu.
.
Whilst this assumption may not hold in general when 'IO' is
involved, you should strive to produce test cases where it does.
.
See the <https://github.com/barrucadu/monad-conc README> for more
See the <https://github.com/barrucadu/dejafu README> for more
details.
homepage: https://github.com/barrucadu/monad-conc
homepage: https://github.com/barrucadu/dejafu
license: WTFPL
license-file: LICENSE
author: Michael Walker
@ -49,17 +50,19 @@ library
, Control.Concurrent.CVar
, Control.Concurrent.CVar.Strict
, Control.Monad.Conc.Fixed
, Control.Monad.Conc.Fixed.IO
, Control.Monad.Conc.Fixed.Schedulers
, Control.Monad.Conc.SCT
, Control.Monad.Conc.SCT.Shrink
, Control.Monad.Conc.SCT.Tests
, Test.DejaFu
, Test.DejaFu.Deterministic
, Test.DejaFu.Deterministic.IO
, Test.DejaFu.Deterministic.Schedulers
, Test.DejaFu.SCT
, Test.DejaFu.Shrink
other-modules: Test.DejaFu.Deterministic.Internal
, Test.DejaFu.SCT.Bounding
, Test.DejaFu.SCT.Internal
other-modules: Control.Monad.Conc.Fixed.Internal
, Control.Monad.Conc.SCT.Bounding
, Control.Monad.Conc.SCT.Internal
, Data.List.Extra
-- other-extensions:
build-depends: base >=4.6 && <5
, containers
@ -76,5 +79,5 @@ test-suite tests
hs-source-dirs: tests
type: exitcode-stdio-1.0
main-is: Tests.hs
build-depends: monad-conc, base
build-depends: dejafu, base
default-language: Haskell2010

View File

@ -1,6 +1,6 @@
module Main (main) where
import Control.Monad.Conc.SCT.Tests (doTests')
import Test.DejaFu (doTests')
import Tests.Cases
import System.Exit (exitFailure, exitSuccess)

View File

@ -5,7 +5,7 @@ import Control.Applicative ((<$>))
import Control.Monad (replicateM)
import Control.Concurrent.CVar
import Control.Monad.Conc.Class
import Control.Monad.Conc.SCT.Tests
import Test.DejaFu
import qualified Tests.Logger as L

View File

@ -11,7 +11,7 @@ module Tests.Logger
import Control.Concurrent.CVar
import Control.Monad.Conc.Class
import Control.Monad.Conc.SCT.Tests
import Test.DejaFu
data Logger m = Logger (CVar m LogCommand) (CVar m [String])