Use stylish-haskell to format import lists.

This commit is contained in:
Michael Walker 2017-04-08 05:20:39 +01:00
parent d934222fe7
commit cc27e03d6d
35 changed files with 327 additions and 245 deletions

62
.stylish-haskell.yaml Normal file
View File

@ -0,0 +1,62 @@
# stylish-haskell configuration file
# https://github.com/jaspervdj/stylish-haskell
##########################
steps:
# Import cleanup
- imports:
# Align the import names and import list throughout the entire
# file.
align: global
# Import list is aligned with end of import including 'as' and
# 'hiding' keywords.
#
# > import qualified Data.List as List (concat, foldl, foldr, head,
# > init, last, length)
list_align: after_alias
# Put as many import specs on same line as possible.
long_list_align: inline
# () is right after the module name:
#
# > import Vector.Instances ()
empty_list_align: right_after
# Align import list on lines after the import under the start of
# the module name.
list_padding: module_name
# There is no space between classes and constructors and the
# list of it's members.
#
# > import Data.Foldable (Foldable(fold, foldl, foldMap))
separate_lists: false
# Language pragmas
- language_pragmas:
# Vertical-spaced language pragmas, one per line.
style: vertical
# Brackets are not aligned together. There is only one space
# between actual import and closing bracket.
align: false
# Remove redundant language pragmas.
remove_redundant: true
# Remove trailing whitespace
- trailing_whitespace: {}
# Maximum line length, used by some of the steps above.
columns: 80
# Convert newlines to LF ("\n").
newline: lf
# For some reason, stylish-haskell thinks I need these extensions
# turning on in order to parse the code.
language_extensions:
- MultiParamTypeClasses
- TemplateHaskell

View File

@ -29,10 +29,10 @@ module Control.Concurrent.Classy
, module Control.Concurrent.Classy.QSemN , module Control.Concurrent.Classy.QSemN
) where ) where
import Control.Monad.Conc.Class import Control.Concurrent.Classy.Chan
import Control.Concurrent.Classy.Chan import Control.Concurrent.Classy.CRef
import Control.Concurrent.Classy.CRef import Control.Concurrent.Classy.MVar
import Control.Concurrent.Classy.MVar import Control.Concurrent.Classy.QSem
import Control.Concurrent.Classy.STM import Control.Concurrent.Classy.QSemN
import Control.Concurrent.Classy.QSem import Control.Concurrent.Classy.STM
import Control.Concurrent.Classy.QSemN import Control.Monad.Conc.Class

View File

@ -77,18 +77,21 @@ module Control.Concurrent.Classy.Async
, Concurrently(..) , Concurrently(..)
) where ) where
import Control.Applicative import Control.Applicative
import Control.Concurrent.Classy.STM.TMVar (newEmptyTMVar, putTMVar, readTMVar) import Control.Concurrent.Classy.STM.TMVar (newEmptyTMVar, putTMVar,
import Control.Exception (AsyncException(ThreadKilled), BlockedIndefinitelyOnSTM(..), Exception, SomeException) readTMVar)
import Control.Monad import Control.Exception (AsyncException(ThreadKilled),
import Control.Monad.Catch (finally, try, onException) BlockedIndefinitelyOnSTM(..),
import Control.Monad.Conc.Class Exception, SomeException)
import Control.Monad.STM.Class import Control.Monad
import Data.Foldable (foldMap) import Control.Monad.Catch (finally, onException, try)
import Data.Traversable import Control.Monad.Conc.Class
import Control.Monad.STM.Class
import Data.Foldable (foldMap)
import Data.Traversable
#if MIN_VERSION_base(4,9,0) #if MIN_VERSION_base(4,9,0)
import Data.Semigroup (Semigroup(..)) import Data.Semigroup (Semigroup(..))
#endif #endif
----------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------

View File

@ -80,7 +80,7 @@ module Control.Concurrent.Classy.CRef
-- memory barrier. -- memory barrier.
) where ) where
import Control.Monad.Conc.Class import Control.Monad.Conc.Class
-- | Mutate the contents of a @CRef@. -- | Mutate the contents of a @CRef@.
-- --

View File

@ -27,9 +27,9 @@ module Control.Concurrent.Classy.Chan
, writeList2Chan , writeList2Chan
) where ) where
import Control.Concurrent.Classy.MVar import Control.Concurrent.Classy.MVar
import Control.Monad.Catch (mask_) import Control.Monad.Catch (mask_)
import Control.Monad.Conc.Class (MonadConc) import Control.Monad.Conc.Class (MonadConc)
-- | 'Chan' is an abstract type representing an unbounded FIFO -- | 'Chan' is an abstract type representing an unbounded FIFO
-- channel. -- channel.

View File

@ -48,9 +48,9 @@ module Control.Concurrent.Classy.MVar
, modifyMVarMasked , modifyMVarMasked
) where ) where
import Control.Monad.Catch (mask_, onException) import Control.Monad.Catch (mask_, onException)
import Control.Monad.Conc.Class import Control.Monad.Conc.Class
import Data.Maybe (isJust) import Data.Maybe (isJust)
-- | Swap the contents of a @MVar@, and return the value taken. This -- | Swap the contents of a @MVar@, and return the value taken. This
-- function is atomic only if there are no other producers fro this -- function is atomic only if there are no other producers fro this

View File

@ -15,8 +15,8 @@ module Control.Concurrent.Classy.QSem
, signalQSem , signalQSem
) where ) where
import Control.Concurrent.Classy.QSemN import Control.Concurrent.Classy.QSemN
import Control.Monad.Conc.Class (MonadConc) import Control.Monad.Conc.Class (MonadConc)
-- | @QSem@ is a quantity semaphore in which the resource is acquired -- | @QSem@ is a quantity semaphore in which the resource is acquired
-- and released in units of one. It provides guaranteed FIFO ordering -- and released in units of one. It provides guaranteed FIFO ordering

View File

@ -16,10 +16,11 @@ module Control.Concurrent.Classy.QSemN
, signalQSemN , signalQSemN
) where ) where
import Control.Monad.Conc.Class (MonadConc) import Control.Concurrent.Classy.MVar
import Control.Concurrent.Classy.MVar import Control.Monad.Catch (mask_, onException,
import Control.Monad.Catch (mask_, onException, uninterruptibleMask_) uninterruptibleMask_)
import Data.Maybe import Control.Monad.Conc.Class (MonadConc)
import Data.Maybe
-- | 'QSemN' is a quantity semaphore in which the resource is aqcuired -- | 'QSemN' is a quantity semaphore in which the resource is aqcuired
-- and released in units of one. It provides guaranteed FIFO ordering -- and released in units of one. It provides guaranteed FIFO ordering

View File

@ -17,10 +17,10 @@ module Control.Concurrent.Classy.STM
, module Control.Concurrent.Classy.STM.TArray , module Control.Concurrent.Classy.STM.TArray
) where ) where
import Control.Monad.STM.Class import Control.Concurrent.Classy.STM.TArray
import Control.Concurrent.Classy.STM.TVar import Control.Concurrent.Classy.STM.TBQueue
import Control.Concurrent.Classy.STM.TMVar import Control.Concurrent.Classy.STM.TChan
import Control.Concurrent.Classy.STM.TChan import Control.Concurrent.Classy.STM.TMVar
import Control.Concurrent.Classy.STM.TQueue import Control.Concurrent.Classy.STM.TQueue
import Control.Concurrent.Classy.STM.TBQueue import Control.Concurrent.Classy.STM.TVar
import Control.Concurrent.Classy.STM.TArray import Control.Monad.STM.Class

View File

@ -1,4 +1,5 @@
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} {-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
-- | -- |
-- Module : Control.Concurrent.Classy.STM. -- Module : Control.Concurrent.Classy.STM.
@ -15,12 +16,12 @@
-- an @Eq@ constraint. -- an @Eq@ constraint.
module Control.Concurrent.Classy.STM.TArray (TArray) where module Control.Concurrent.Classy.STM.TArray (TArray) where
import Data.Array (Array, bounds) import Data.Array (Array, bounds)
import Data.Array.Base (listArray, arrEleBottom, unsafeAt, MArray(..), import Data.Array.Base (IArray(numElements), MArray(..),
IArray(numElements)) arrEleBottom, listArray, unsafeAt)
import Data.Ix (rangeSize) import Data.Ix (rangeSize)
import Control.Monad.STM.Class import Control.Monad.STM.Class
-- | @TArray@ is a transactional array, supporting the usual 'MArray' -- | @TArray@ is a transactional array, supporting the usual 'MArray'
-- interface for mutable arrays. -- interface for mutable arrays.

View File

@ -33,7 +33,7 @@ module Control.Concurrent.Classy.STM.TBQueue
, isFullTBQueue , isFullTBQueue
) where ) where
import Control.Monad.STM.Class import Control.Monad.STM.Class
-- | 'TBQueue' is an abstract type representing a bounded FIFO -- | 'TBQueue' is an abstract type representing a bounded FIFO
-- channel. -- channel.

View File

@ -32,7 +32,7 @@ module Control.Concurrent.Classy.STM.TChan
, isEmptyTChan , isEmptyTChan
) where ) where
import Control.Monad.STM.Class import Control.Monad.STM.Class
-- | 'TChan' is an abstract type representing an unbounded FIFO -- | 'TChan' is an abstract type representing an unbounded FIFO
-- channel. -- channel.

View File

@ -29,9 +29,9 @@ module Control.Concurrent.Classy.STM.TMVar
, swapTMVar , swapTMVar
) where ) where
import Control.Monad (liftM, when, unless) import Control.Monad (liftM, unless, when)
import Control.Monad.STM.Class import Control.Monad.STM.Class
import Data.Maybe (isJust, isNothing) import Data.Maybe (isJust, isNothing)
-- | A @TMVar@ is like an @MVar@ or a @mVar@, but using transactional -- | A @TMVar@ is like an @MVar@ or a @mVar@, but using transactional
-- memory. As transactions are atomic, this makes dealing with -- memory. As transactions are atomic, this makes dealing with

View File

@ -36,7 +36,7 @@ module Control.Concurrent.Classy.STM.TQueue
, isEmptyTQueue , isEmptyTQueue
) where ) where
import Control.Monad.STM.Class import Control.Monad.STM.Class
-- | 'TQueue' is an abstract type representing an unbounded FIFO channel. -- | 'TQueue' is an abstract type representing an unbounded FIFO channel.
-- --

View File

@ -25,9 +25,9 @@ module Control.Concurrent.Classy.STM.TVar
, registerDelay , registerDelay
) where ) where
import Control.Monad.STM.Class import Control.Monad.Conc.Class
import Control.Monad.Conc.Class import Control.Monad.STM.Class
import Data.Functor (void) import Data.Functor (void)
-- * @TVar@s -- * @TVar@s

View File

@ -66,30 +66,32 @@ module Control.Monad.Conc.Class
) where ) where
-- for the class and utilities -- for the class and utilities
import Control.Exception (Exception, AsyncException(ThreadKilled), SomeException) import Control.Exception (AsyncException(ThreadKilled),
import Control.Monad.Catch (MonadCatch, MonadThrow, MonadMask) Exception, SomeException)
import qualified Control.Monad.Catch as Ca import Control.Monad.Catch (MonadCatch, MonadMask,
import Control.Monad.STM.Class (MonadSTM, TVar, readTVar) MonadThrow)
import Control.Monad.Trans.Control (MonadTransControl, StT, liftWith) import qualified Control.Monad.Catch as Ca
import Data.Proxy (Proxy(..)) import Control.Monad.STM.Class (MonadSTM, TVar, readTVar)
import Control.Monad.Trans.Control (MonadTransControl, StT, liftWith)
import Data.Proxy (Proxy(..))
-- for the 'IO' instance -- for the 'IO' instance
import qualified Control.Concurrent as IO import qualified Control.Concurrent as IO
import qualified Control.Concurrent.STM.TVar as IO import qualified Control.Concurrent.STM.TVar as IO
import qualified Control.Monad.STM as IO import qualified Control.Monad.STM as IO
import qualified Data.Atomics as IO import qualified Data.Atomics as IO
import qualified Data.IORef as IO import qualified Data.IORef as IO
-- for the transformer instances -- for the transformer instances
import Control.Monad.Reader (ReaderT) import Control.Monad.Reader (ReaderT)
import Control.Monad.Trans (lift) import qualified Control.Monad.RWS.Lazy as RL
import Control.Monad.Trans.Identity (IdentityT) import qualified Control.Monad.RWS.Strict as RS
import qualified Control.Monad.RWS.Lazy as RL import qualified Control.Monad.State.Lazy as SL
import qualified Control.Monad.RWS.Strict as RS import qualified Control.Monad.State.Strict as SS
import qualified Control.Monad.State.Lazy as SL import Control.Monad.Trans (lift)
import qualified Control.Monad.State.Strict as SS import Control.Monad.Trans.Identity (IdentityT)
import qualified Control.Monad.Writer.Lazy as WL import qualified Control.Monad.Writer.Lazy as WL
import qualified Control.Monad.Writer.Strict as WS import qualified Control.Monad.Writer.Strict as WS
-- | @MonadConc@ is an abstraction over GHC's typical concurrency -- | @MonadConc@ is an abstraction over GHC's typical concurrency
-- abstraction. It captures the interface of concurrency monads in -- abstraction. It captures the interface of concurrency monads in

View File

@ -31,21 +31,21 @@ module Control.Monad.STM.Class
, liftedOrElse , liftedOrElse
) where ) where
import Control.Exception (Exception) import Control.Exception (Exception)
import Control.Monad (unless) import Control.Monad (unless)
import Control.Monad.Reader (ReaderT) import Control.Monad.Reader (ReaderT)
import Control.Monad.Trans (lift) import Control.Monad.Trans (lift)
import Control.Monad.Trans.Control (MonadTransControl, StT, liftWith) import Control.Monad.Trans.Control (MonadTransControl, StT, liftWith)
import Control.Monad.Trans.Identity (IdentityT) import Control.Monad.Trans.Identity (IdentityT)
import qualified Control.Concurrent.STM as STM import qualified Control.Concurrent.STM as STM
import qualified Control.Monad.Catch as Ca import qualified Control.Monad.Catch as Ca
import qualified Control.Monad.RWS.Lazy as RL import qualified Control.Monad.RWS.Lazy as RL
import qualified Control.Monad.RWS.Strict as RS import qualified Control.Monad.RWS.Strict as RS
import qualified Control.Monad.State.Lazy as SL import qualified Control.Monad.State.Lazy as SL
import qualified Control.Monad.State.Strict as SS import qualified Control.Monad.State.Strict as SS
import qualified Control.Monad.Writer.Lazy as WL import qualified Control.Monad.Writer.Lazy as WL
import qualified Control.Monad.Writer.Strict as WS import qualified Control.Monad.Writer.Strict as WS
-- | @MonadSTM@ is an abstraction over 'STM'. -- | @MonadSTM@ is an abstraction over 'STM'.
-- --

View File

@ -1,2 +1,2 @@
import Distribution.Simple import Distribution.Simple
main = defaultMain main = defaultMain

View File

@ -1,2 +1,2 @@
import Distribution.Simple import Distribution.Simple
main = defaultMain main = defaultMain

View File

@ -242,19 +242,19 @@ module Test.DejaFu
, gives' , gives'
) where ) where
import Control.Arrow (first) import Control.Arrow (first)
import Control.DeepSeq (NFData(..)) import Control.DeepSeq (NFData(..))
import Control.Monad (when, unless) import Control.Monad (unless, when)
import Control.Monad.Ref (MonadRef) import Control.Monad.Ref (MonadRef)
import Control.Monad.ST (runST) import Control.Monad.ST (runST)
import Data.Function (on) import Data.Function (on)
import Data.List (intercalate, intersperse, minimumBy) import Data.List (intercalate, intersperse, minimumBy)
import Data.Ord (comparing) import Data.Ord (comparing)
import System.Random (RandomGen, StdGen) import System.Random (RandomGen, StdGen)
import Test.DejaFu.Common import Test.DejaFu.Common
import Test.DejaFu.Conc import Test.DejaFu.Conc
import Test.DejaFu.SCT import Test.DejaFu.SCT
------------------------------------------------------------------------------- -------------------------------------------------------------------------------

View File

@ -60,13 +60,13 @@ module Test.DejaFu.Common
, MemType(..) , MemType(..)
) where ) where
import Control.DeepSeq (NFData(..)) import Control.DeepSeq (NFData(..))
import Control.Exception (MaskingState(..)) import Control.Exception (MaskingState(..))
import Data.List (sort, nub, intercalate) import Data.List (intercalate, nub, sort)
import Data.List.NonEmpty (NonEmpty) import Data.List.NonEmpty (NonEmpty)
import Data.Maybe (fromMaybe, mapMaybe) import Data.Maybe (fromMaybe, mapMaybe)
import Data.Set (Set) import Data.Set (Set)
import qualified Data.Set as S import qualified Data.Set as S
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- Identifiers -- Identifiers

View File

@ -1,9 +1,9 @@
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-} {-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE TypeSynonymInstances #-}
-- | -- |
-- Module : Test.DejaFu.Conc -- Module : Test.DejaFu.Conc
@ -46,23 +46,23 @@ module Test.DejaFu.Conc
, module Test.DejaFu.Schedule , module Test.DejaFu.Schedule
) where ) where
import Control.Exception (MaskingState(..)) import Control.Exception (MaskingState(..))
import qualified Control.Monad.Base as Ba import qualified Control.Monad.Base as Ba
import qualified Control.Monad.Catch as Ca import qualified Control.Monad.Catch as Ca
import qualified Control.Monad.IO.Class as IO import qualified Control.Monad.IO.Class as IO
import Control.Monad.Ref (MonadRef) import Control.Monad.Ref (MonadRef)
import qualified Control.Monad.Ref as Re import qualified Control.Monad.Ref as Re
import Control.Monad.ST (ST) import Control.Monad.ST (ST)
import qualified Data.Foldable as F import qualified Data.Foldable as F
import Data.IORef (IORef) import Data.IORef (IORef)
import Data.STRef (STRef) import Data.STRef (STRef)
import Test.DejaFu.Schedule import Test.DejaFu.Schedule
import qualified Control.Monad.Conc.Class as C import qualified Control.Monad.Conc.Class as C
import Test.DejaFu.Common import Test.DejaFu.Common
import Test.DejaFu.Conc.Internal import Test.DejaFu.Conc.Internal
import Test.DejaFu.Conc.Internal.Common import Test.DejaFu.Conc.Internal.Common
import Test.DejaFu.STM import Test.DejaFu.STM
newtype Conc n r a = C { unC :: M n r a } deriving (Functor, Applicative, Monad) newtype Conc n r a = C { unC :: M n r a } deriving (Functor, Applicative, Monad)

View File

@ -1,5 +1,5 @@
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-} {-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
-- | -- |
@ -15,24 +15,28 @@
-- interface of this library. -- interface of this library.
module Test.DejaFu.Conc.Internal where module Test.DejaFu.Conc.Internal where
import Control.Exception (MaskingState(..), toException) import Control.Exception (MaskingState(..),
import Control.Monad.Ref (MonadRef, newRef, readRef, writeRef) toException)
import qualified Data.Foldable as F import Control.Monad.Ref (MonadRef, newRef, readRef,
import Data.Functor (void) writeRef)
import Data.List (sort) import qualified Data.Foldable as F
import Data.List.NonEmpty (NonEmpty(..), fromList) import Data.Functor (void)
import qualified Data.Map.Strict as M import Data.List (sort)
import Data.Maybe (fromJust, isJust, isNothing) import Data.List.NonEmpty (NonEmpty(..), fromList)
import Data.Monoid ((<>)) import qualified Data.Map.Strict as M
import Data.Sequence (Seq, (<|)) import Data.Maybe (fromJust, isJust,
import qualified Data.Sequence as Seq isNothing)
import Data.Monoid ((<>))
import Data.Sequence (Seq, (<|))
import qualified Data.Sequence as Seq
import Test.DejaFu.Common import Test.DejaFu.Common
import Test.DejaFu.Conc.Internal.Common import Test.DejaFu.Conc.Internal.Common
import Test.DejaFu.Conc.Internal.Memory import Test.DejaFu.Conc.Internal.Memory
import Test.DejaFu.Conc.Internal.Threading import Test.DejaFu.Conc.Internal.Threading
import Test.DejaFu.Schedule import Test.DejaFu.Schedule
import Test.DejaFu.STM (Result(..), runTransaction) import Test.DejaFu.STM (Result(..),
runTransaction)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- * Execution -- * Execution

View File

@ -1,5 +1,5 @@
{-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE RankNTypes #-} {-# LANGUAGE RankNTypes #-}
-- | -- |
-- Module : Test.DejaFu.Conc.Internal.Common -- Module : Test.DejaFu.Conc.Internal.Common
@ -13,11 +13,11 @@
-- 'MonadConc' implementations. This module is NOT considered to form -- 'MonadConc' implementations. This module is NOT considered to form
module Test.DejaFu.Conc.Internal.Common where module Test.DejaFu.Conc.Internal.Common where
import Control.Exception (Exception, MaskingState(..)) import Control.Exception (Exception, MaskingState(..))
import Data.Map.Strict (Map) import Data.List.NonEmpty (NonEmpty, fromList)
import Data.List.NonEmpty (NonEmpty, fromList) import Data.Map.Strict (Map)
import Test.DejaFu.Common import Test.DejaFu.Common
import Test.DejaFu.STM (STMLike) import Test.DejaFu.STM (STMLike)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- * The @Conc@ Monad -- * The @Conc@ Monad

View File

@ -1,5 +1,5 @@
{-# LANGUAGE BangPatterns #-} {-# LANGUAGE BangPatterns #-}
{-# LANGUAGE GADTs #-} {-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiParamTypeClasses #-}
-- | -- |
@ -23,18 +23,20 @@
-- Memory Models/, N. Zhang, M. Kusano, and C. Wang (2015). -- Memory Models/, N. Zhang, M. Kusano, and C. Wang (2015).
module Test.DejaFu.Conc.Internal.Memory where module Test.DejaFu.Conc.Internal.Memory where
import Control.Monad (when) import Control.Monad (when)
import Control.Monad.Ref (MonadRef, readRef, writeRef) import Control.Monad.Ref (MonadRef, readRef,
import Data.Map.Strict (Map) writeRef)
import Data.Maybe (isJust, fromJust) import Data.Map.Strict (Map)
import Data.Monoid ((<>)) import Data.Maybe (fromJust, isJust)
import Data.Sequence (Seq, ViewL(..), (><), singleton, viewl) import Data.Monoid ((<>))
import Data.Sequence (Seq, ViewL(..), singleton,
viewl, (><))
import Test.DejaFu.Common import Test.DejaFu.Common
import Test.DejaFu.Conc.Internal.Common import Test.DejaFu.Conc.Internal.Common
import Test.DejaFu.Conc.Internal.Threading import Test.DejaFu.Conc.Internal.Threading
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- * Manipulating @CRef@s -- * Manipulating @CRef@s

View File

@ -1,5 +1,5 @@
{-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE RankNTypes #-} {-# LANGUAGE RankNTypes #-}
-- | -- |
-- Module : Test.DejaFu.Conc.Internal.Threading -- Module : Test.DejaFu.Conc.Internal.Threading
@ -13,15 +13,16 @@
-- form part of the public interface of this library. -- form part of the public interface of this library.
module Test.DejaFu.Conc.Internal.Threading where module Test.DejaFu.Conc.Internal.Threading where
import Control.Exception (Exception, MaskingState(..), SomeException, fromException) import Control.Exception (Exception, MaskingState(..),
import Data.List (intersect) SomeException, fromException)
import Data.Map.Strict (Map) import Data.List (intersect)
import Data.Maybe (fromMaybe, isJust) import Data.Map.Strict (Map)
import Data.Maybe (fromMaybe, isJust)
import Test.DejaFu.Common import Test.DejaFu.Common
import Test.DejaFu.Conc.Internal.Common import Test.DejaFu.Conc.Internal.Common
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- * Threads -- * Threads

View File

@ -90,17 +90,17 @@ module Test.DejaFu.SCT
, sctRandom , sctRandom
) where ) where
import Control.DeepSeq (NFData(..)) import Control.DeepSeq (NFData(..))
import Control.Monad.Ref (MonadRef) import Control.Monad.Ref (MonadRef)
import Data.List (foldl') import Data.List (foldl')
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
import Data.Set (Set) import Data.Set (Set)
import qualified Data.Set as S import qualified Data.Set as S
import System.Random (RandomGen) import System.Random (RandomGen)
import Test.DejaFu.Common import Test.DejaFu.Common
import Test.DejaFu.Conc import Test.DejaFu.Conc
import Test.DejaFu.SCT.Internal import Test.DejaFu.SCT.Internal
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- Running Concurrent Programs -- Running Concurrent Programs

View File

@ -11,24 +11,26 @@
-- interface of this library. -- interface of this library.
module Test.DejaFu.SCT.Internal where module Test.DejaFu.SCT.Internal where
import Control.DeepSeq (NFData(..)) import Control.DeepSeq (NFData(..))
import Control.Exception (MaskingState(..)) import Control.Exception (MaskingState(..))
import Data.Char (ord) import Data.Char (ord)
import Data.Function (on) import qualified Data.Foldable as F
import qualified Data.Foldable as F import Data.Function (on)
import Data.List (intercalate, nubBy, partition, sortOn) import Data.List (intercalate, nubBy, partition, sortOn)
import Data.List.NonEmpty (NonEmpty(..), toList) import Data.List.NonEmpty (NonEmpty(..), toList)
import Data.Map.Strict (Map) import Data.Map.Strict (Map)
import Data.Maybe (catMaybes, fromJust, isJust, isNothing, listToMaybe) import qualified Data.Map.Strict as M
import qualified Data.Map.Strict as M import Data.Maybe (catMaybes, fromJust, isJust, isNothing,
import Data.Set (Set) listToMaybe)
import qualified Data.Set as S import Data.Sequence (Seq, (|>))
import Data.Sequence (Seq, (|>)) import qualified Data.Sequence as Sq
import qualified Data.Sequence as Sq import Data.Set (Set)
import System.Random (RandomGen, randomR) import qualified Data.Set as S
import System.Random (RandomGen, randomR)
import Test.DejaFu.Common import Test.DejaFu.Common
import Test.DejaFu.Schedule (Decision(..), Scheduler, decisionOf, tidOf) import Test.DejaFu.Schedule (Decision(..), Scheduler, decisionOf,
tidOf)
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- * Dynamic partial-order reduction -- * Dynamic partial-order reduction

View File

@ -1,6 +1,6 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE RankNTypes #-} {-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
-- | -- |
-- Module : Test.DejaFu.STM -- Module : Test.DejaFu.STM
@ -26,17 +26,17 @@ module Test.DejaFu.STM
, runTransaction , runTransaction
) where ) where
import Control.Monad (unless) import Control.Monad (unless)
import Control.Monad.Catch (MonadCatch(..), MonadThrow(..)) import Control.Monad.Catch (MonadCatch(..), MonadThrow(..))
import Control.Monad.Cont (cont) import Control.Monad.Cont (cont)
import Control.Monad.Ref (MonadRef) import Control.Monad.Ref (MonadRef)
import Control.Monad.ST (ST) import Control.Monad.ST (ST)
import Data.IORef (IORef) import Data.IORef (IORef)
import Data.STRef (STRef) import Data.STRef (STRef)
import qualified Control.Monad.STM.Class as C import qualified Control.Monad.STM.Class as C
import Test.DejaFu.Common import Test.DejaFu.Common
import Test.DejaFu.STM.Internal import Test.DejaFu.STM.Internal
newtype STMLike n r a = S { runSTM :: M n r a } deriving (Functor, Applicative, Monad) newtype STMLike n r a = S { runSTM :: M n r a } deriving (Functor, Applicative, Monad)

View File

@ -15,13 +15,14 @@
-- public interface of this library. -- public interface of this library.
module Test.DejaFu.STM.Internal where module Test.DejaFu.STM.Internal where
import Control.DeepSeq (NFData(..)) import Control.DeepSeq (NFData(..))
import Control.Exception (Exception, SomeException, fromException, toException) import Control.Exception (Exception, SomeException, fromException,
import Control.Monad.Cont (Cont, runCont) toException)
import Control.Monad.Ref (MonadRef, newRef, readRef, writeRef) import Control.Monad.Cont (Cont, runCont)
import Data.List (nub) import Control.Monad.Ref (MonadRef, newRef, readRef, writeRef)
import Data.List (nub)
import Test.DejaFu.Common import Test.DejaFu.Common
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- The @STMLike@ monad -- The @STMLike@ monad

View File

@ -29,10 +29,10 @@ module Test.DejaFu.Schedule
, makeNonPreemptive , makeNonPreemptive
) where ) where
import Data.List.NonEmpty (NonEmpty(..), toList) import Data.List.NonEmpty (NonEmpty(..), toList)
import System.Random (RandomGen, randomR) import System.Random (RandomGen, randomR)
import Test.DejaFu.Common import Test.DejaFu.Common
-- | A @Scheduler@ drives the execution of a concurrent program. The -- | A @Scheduler@ drives the execution of a concurrent program. The
-- parameters it takes are: -- parameters it takes are:

View File

@ -1,2 +1,2 @@
import Distribution.Simple import Distribution.Simple
main = defaultMain main = defaultMain

View File

@ -59,19 +59,20 @@ module Test.HUnit.DejaFu
, MemType(..) , MemType(..)
) where ) where
import Control.Monad.Catch (try) import Control.Monad.Catch (try)
import Control.Monad.ST (runST) import Control.Monad.ST (runST)
import Data.List (intercalate, intersperse) import Data.List (intercalate, intersperse)
import System.Random (RandomGen) import System.Random (RandomGen)
import Test.HUnit (Assertable(..), Test(..), Testable(..), assertString) import Test.DejaFu
import Test.HUnit.Lang (HUnitFailure(..)) import qualified Test.DejaFu.Conc as Conc
import Test.DejaFu import qualified Test.DejaFu.SCT as SCT
import qualified Test.DejaFu.Conc as Conc import Test.HUnit (Assertable(..), Test(..), Testable(..),
import qualified Test.DejaFu.SCT as SCT assertString)
import Test.HUnit.Lang (HUnitFailure(..))
-- Can't put the necessary forall in the @Assertable Conc.ConcST t@ -- Can't put the necessary forall in the @Assertable Conc.ConcST t@
-- instance :( -- instance :(
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
runSCTst :: RandomGen g => Way g -> MemType -> (forall t. Conc.ConcST t a) -> [(Either Failure a, Conc.Trace)] runSCTst :: RandomGen g => Way g -> MemType -> (forall t. Conc.ConcST t a) -> [(Either Failure a, Conc.Trace)]
runSCTst way memtype conc = runST (SCT.runSCT way memtype conc) runSCTst way memtype conc = runST (SCT.runSCT way memtype conc)

View File

@ -1,2 +1,2 @@
import Distribution.Simple import Distribution.Simple
main = defaultMain main = defaultMain

View File

@ -56,23 +56,25 @@ module Test.Tasty.DejaFu
, MemType(..) , MemType(..)
) where ) where
import Control.Monad.ST (runST) import Control.Monad.ST (runST)
import Data.Char (toUpper) import Data.Char (toUpper)
import Data.List (intercalate, intersperse) import Data.List (intercalate, intersperse)
import Data.Proxy (Proxy(..)) import Data.Proxy (Proxy(..))
import Data.Tagged (Tagged(..)) import Data.Tagged (Tagged(..))
import Data.Typeable (Typeable) import Data.Typeable (Typeable)
import System.Random (RandomGen, StdGen, mkStdGen) import System.Random (RandomGen, StdGen, mkStdGen)
import Test.DejaFu import Test.DejaFu
import qualified Test.DejaFu.Conc as Conc import qualified Test.DejaFu.Conc as Conc
import qualified Test.DejaFu.SCT as SCT import qualified Test.DejaFu.SCT as SCT
import Test.Tasty (TestName, TestTree, testGroup) import Test.Tasty (TestName, TestTree, testGroup)
import Test.Tasty.Options (OptionDescription(..), IsOption(..), lookupOption) import Test.Tasty.Options (IsOption(..), OptionDescription(..),
import Test.Tasty.Providers (IsTest(..), singleTest, testPassed, testFailed) lookupOption)
import Test.Tasty.Providers (IsTest(..), singleTest, testFailed,
testPassed)
-- Can't put the necessary forall in the @IsTest ConcST t@ -- Can't put the necessary forall in the @IsTest ConcST t@
-- instance :( -- instance :(
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
runSCTst :: RandomGen g => Way g -> MemType -> (forall t. Conc.ConcST t a) -> [(Either Failure a, Conc.Trace)] runSCTst :: RandomGen g => Way g -> MemType -> (forall t. Conc.ConcST t a) -> [(Either Failure a, Conc.Trace)]
runSCTst way memtype conc = runST (SCT.runSCT way memtype conc) runSCTst way memtype conc = runST (SCT.runSCT way memtype conc)