From cc27e03d6d3a146e95bd777319c6ce53f45391d1 Mon Sep 17 00:00:00 2001 From: Michael Walker Date: Sat, 8 Apr 2017 05:20:39 +0100 Subject: [PATCH] Use stylish-haskell to format import lists. --- .stylish-haskell.yaml | 62 +++++++++++++++++++ concurrency/Control/Concurrent/Classy.hs | 14 ++--- .../Control/Concurrent/Classy/Async.hs | 23 ++++--- concurrency/Control/Concurrent/Classy/CRef.hs | 2 +- concurrency/Control/Concurrent/Classy/Chan.hs | 6 +- concurrency/Control/Concurrent/Classy/MVar.hs | 6 +- concurrency/Control/Concurrent/Classy/QSem.hs | 4 +- .../Control/Concurrent/Classy/QSemN.hs | 9 +-- concurrency/Control/Concurrent/Classy/STM.hs | 14 ++--- .../Control/Concurrent/Classy/STM/TArray.hs | 13 ++-- .../Control/Concurrent/Classy/STM/TBQueue.hs | 2 +- .../Control/Concurrent/Classy/STM/TChan.hs | 2 +- .../Control/Concurrent/Classy/STM/TMVar.hs | 6 +- .../Control/Concurrent/Classy/STM/TQueue.hs | 2 +- .../Control/Concurrent/Classy/STM/TVar.hs | 6 +- concurrency/Control/Monad/Conc/Class.hs | 42 +++++++------ concurrency/Control/Monad/STM/Class.hs | 28 ++++----- concurrency/Setup.hs | 2 +- dejafu/Setup.hs | 2 +- dejafu/Test/DejaFu.hs | 24 +++---- dejafu/Test/DejaFu/Common.hs | 14 ++--- dejafu/Test/DejaFu/Conc.hs | 42 ++++++------- dejafu/Test/DejaFu/Conc/Internal.hs | 40 ++++++------ dejafu/Test/DejaFu/Conc/Internal/Common.hs | 12 ++-- dejafu/Test/DejaFu/Conc/Internal/Memory.hs | 24 +++---- dejafu/Test/DejaFu/Conc/Internal/Threading.hs | 17 ++--- dejafu/Test/DejaFu/SCT.hs | 20 +++--- dejafu/Test/DejaFu/SCT/Internal.hs | 36 ++++++----- dejafu/Test/DejaFu/STM.hs | 24 +++---- dejafu/Test/DejaFu/STM/Internal.hs | 13 ++-- dejafu/Test/DejaFu/Schedule.hs | 6 +- hunit-dejafu/Setup.hs | 2 +- hunit-dejafu/Test/HUnit/DejaFu.hs | 21 ++++--- tasty-dejafu/Setup.hs | 2 +- tasty-dejafu/Test/Tasty/DejaFu.hs | 30 ++++----- 35 files changed, 327 insertions(+), 245 deletions(-) create mode 100644 .stylish-haskell.yaml diff --git a/.stylish-haskell.yaml b/.stylish-haskell.yaml new file mode 100644 index 0000000..81caf2d --- /dev/null +++ b/.stylish-haskell.yaml @@ -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 diff --git a/concurrency/Control/Concurrent/Classy.hs b/concurrency/Control/Concurrent/Classy.hs index 1820a77..86b3dac 100644 --- a/concurrency/Control/Concurrent/Classy.hs +++ b/concurrency/Control/Concurrent/Classy.hs @@ -29,10 +29,10 @@ module Control.Concurrent.Classy , module Control.Concurrent.Classy.QSemN ) where -import Control.Monad.Conc.Class -import Control.Concurrent.Classy.Chan -import Control.Concurrent.Classy.CRef -import Control.Concurrent.Classy.MVar -import Control.Concurrent.Classy.STM -import Control.Concurrent.Classy.QSem -import Control.Concurrent.Classy.QSemN +import Control.Concurrent.Classy.Chan +import Control.Concurrent.Classy.CRef +import Control.Concurrent.Classy.MVar +import Control.Concurrent.Classy.QSem +import Control.Concurrent.Classy.QSemN +import Control.Concurrent.Classy.STM +import Control.Monad.Conc.Class diff --git a/concurrency/Control/Concurrent/Classy/Async.hs b/concurrency/Control/Concurrent/Classy/Async.hs index 99d1ee4..eea6b9e 100644 --- a/concurrency/Control/Concurrent/Classy/Async.hs +++ b/concurrency/Control/Concurrent/Classy/Async.hs @@ -77,18 +77,21 @@ module Control.Concurrent.Classy.Async , Concurrently(..) ) where -import Control.Applicative -import Control.Concurrent.Classy.STM.TMVar (newEmptyTMVar, putTMVar, readTMVar) -import Control.Exception (AsyncException(ThreadKilled), BlockedIndefinitelyOnSTM(..), Exception, SomeException) -import Control.Monad -import Control.Monad.Catch (finally, try, onException) -import Control.Monad.Conc.Class -import Control.Monad.STM.Class -import Data.Foldable (foldMap) -import Data.Traversable +import Control.Applicative +import Control.Concurrent.Classy.STM.TMVar (newEmptyTMVar, putTMVar, + readTMVar) +import Control.Exception (AsyncException(ThreadKilled), + BlockedIndefinitelyOnSTM(..), + Exception, SomeException) +import Control.Monad +import Control.Monad.Catch (finally, onException, try) +import Control.Monad.Conc.Class +import Control.Monad.STM.Class +import Data.Foldable (foldMap) +import Data.Traversable #if MIN_VERSION_base(4,9,0) -import Data.Semigroup (Semigroup(..)) +import Data.Semigroup (Semigroup(..)) #endif ----------------------------------------------------------------------------------------- diff --git a/concurrency/Control/Concurrent/Classy/CRef.hs b/concurrency/Control/Concurrent/Classy/CRef.hs index 7d05ba7..f70bd37 100644 --- a/concurrency/Control/Concurrent/Classy/CRef.hs +++ b/concurrency/Control/Concurrent/Classy/CRef.hs @@ -80,7 +80,7 @@ module Control.Concurrent.Classy.CRef -- memory barrier. ) where -import Control.Monad.Conc.Class +import Control.Monad.Conc.Class -- | Mutate the contents of a @CRef@. -- diff --git a/concurrency/Control/Concurrent/Classy/Chan.hs b/concurrency/Control/Concurrent/Classy/Chan.hs index 166a38a..9169a2e 100644 --- a/concurrency/Control/Concurrent/Classy/Chan.hs +++ b/concurrency/Control/Concurrent/Classy/Chan.hs @@ -27,9 +27,9 @@ module Control.Concurrent.Classy.Chan , writeList2Chan ) where -import Control.Concurrent.Classy.MVar -import Control.Monad.Catch (mask_) -import Control.Monad.Conc.Class (MonadConc) +import Control.Concurrent.Classy.MVar +import Control.Monad.Catch (mask_) +import Control.Monad.Conc.Class (MonadConc) -- | 'Chan' is an abstract type representing an unbounded FIFO -- channel. diff --git a/concurrency/Control/Concurrent/Classy/MVar.hs b/concurrency/Control/Concurrent/Classy/MVar.hs index 96efc87..e98cf7c 100644 --- a/concurrency/Control/Concurrent/Classy/MVar.hs +++ b/concurrency/Control/Concurrent/Classy/MVar.hs @@ -48,9 +48,9 @@ module Control.Concurrent.Classy.MVar , modifyMVarMasked ) where -import Control.Monad.Catch (mask_, onException) -import Control.Monad.Conc.Class -import Data.Maybe (isJust) +import Control.Monad.Catch (mask_, onException) +import Control.Monad.Conc.Class +import Data.Maybe (isJust) -- | Swap the contents of a @MVar@, and return the value taken. This -- function is atomic only if there are no other producers fro this diff --git a/concurrency/Control/Concurrent/Classy/QSem.hs b/concurrency/Control/Concurrent/Classy/QSem.hs index 2d52ed4..26c7094 100644 --- a/concurrency/Control/Concurrent/Classy/QSem.hs +++ b/concurrency/Control/Concurrent/Classy/QSem.hs @@ -15,8 +15,8 @@ module Control.Concurrent.Classy.QSem , signalQSem ) where -import Control.Concurrent.Classy.QSemN -import Control.Monad.Conc.Class (MonadConc) +import Control.Concurrent.Classy.QSemN +import Control.Monad.Conc.Class (MonadConc) -- | @QSem@ is a quantity semaphore in which the resource is acquired -- and released in units of one. It provides guaranteed FIFO ordering diff --git a/concurrency/Control/Concurrent/Classy/QSemN.hs b/concurrency/Control/Concurrent/Classy/QSemN.hs index 873f397..2093345 100644 --- a/concurrency/Control/Concurrent/Classy/QSemN.hs +++ b/concurrency/Control/Concurrent/Classy/QSemN.hs @@ -16,10 +16,11 @@ module Control.Concurrent.Classy.QSemN , signalQSemN ) where -import Control.Monad.Conc.Class (MonadConc) -import Control.Concurrent.Classy.MVar -import Control.Monad.Catch (mask_, onException, uninterruptibleMask_) -import Data.Maybe +import Control.Concurrent.Classy.MVar +import Control.Monad.Catch (mask_, onException, + uninterruptibleMask_) +import Control.Monad.Conc.Class (MonadConc) +import Data.Maybe -- | 'QSemN' is a quantity semaphore in which the resource is aqcuired -- and released in units of one. It provides guaranteed FIFO ordering diff --git a/concurrency/Control/Concurrent/Classy/STM.hs b/concurrency/Control/Concurrent/Classy/STM.hs index a207a4d..4c7b67f 100644 --- a/concurrency/Control/Concurrent/Classy/STM.hs +++ b/concurrency/Control/Concurrent/Classy/STM.hs @@ -17,10 +17,10 @@ module Control.Concurrent.Classy.STM , module Control.Concurrent.Classy.STM.TArray ) where -import Control.Monad.STM.Class -import Control.Concurrent.Classy.STM.TVar -import Control.Concurrent.Classy.STM.TMVar -import Control.Concurrent.Classy.STM.TChan -import Control.Concurrent.Classy.STM.TQueue -import Control.Concurrent.Classy.STM.TBQueue -import Control.Concurrent.Classy.STM.TArray +import Control.Concurrent.Classy.STM.TArray +import Control.Concurrent.Classy.STM.TBQueue +import Control.Concurrent.Classy.STM.TChan +import Control.Concurrent.Classy.STM.TMVar +import Control.Concurrent.Classy.STM.TQueue +import Control.Concurrent.Classy.STM.TVar +import Control.Monad.STM.Class diff --git a/concurrency/Control/Concurrent/Classy/STM/TArray.hs b/concurrency/Control/Concurrent/Classy/STM/TArray.hs index a851e5e..4ef00ba 100644 --- a/concurrency/Control/Concurrent/Classy/STM/TArray.hs +++ b/concurrency/Control/Concurrent/Classy/STM/TArray.hs @@ -1,4 +1,5 @@ -{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MultiParamTypeClasses #-} -- | -- Module : Control.Concurrent.Classy.STM. @@ -15,12 +16,12 @@ -- an @Eq@ constraint. module Control.Concurrent.Classy.STM.TArray (TArray) where -import Data.Array (Array, bounds) -import Data.Array.Base (listArray, arrEleBottom, unsafeAt, MArray(..), - IArray(numElements)) -import Data.Ix (rangeSize) +import Data.Array (Array, bounds) +import Data.Array.Base (IArray(numElements), MArray(..), + arrEleBottom, listArray, unsafeAt) +import Data.Ix (rangeSize) -import Control.Monad.STM.Class +import Control.Monad.STM.Class -- | @TArray@ is a transactional array, supporting the usual 'MArray' -- interface for mutable arrays. diff --git a/concurrency/Control/Concurrent/Classy/STM/TBQueue.hs b/concurrency/Control/Concurrent/Classy/STM/TBQueue.hs index b74c1ed..2e95d94 100644 --- a/concurrency/Control/Concurrent/Classy/STM/TBQueue.hs +++ b/concurrency/Control/Concurrent/Classy/STM/TBQueue.hs @@ -33,7 +33,7 @@ module Control.Concurrent.Classy.STM.TBQueue , isFullTBQueue ) where -import Control.Monad.STM.Class +import Control.Monad.STM.Class -- | 'TBQueue' is an abstract type representing a bounded FIFO -- channel. diff --git a/concurrency/Control/Concurrent/Classy/STM/TChan.hs b/concurrency/Control/Concurrent/Classy/STM/TChan.hs index ce5af42..59bd4ff 100644 --- a/concurrency/Control/Concurrent/Classy/STM/TChan.hs +++ b/concurrency/Control/Concurrent/Classy/STM/TChan.hs @@ -32,7 +32,7 @@ module Control.Concurrent.Classy.STM.TChan , isEmptyTChan ) where -import Control.Monad.STM.Class +import Control.Monad.STM.Class -- | 'TChan' is an abstract type representing an unbounded FIFO -- channel. diff --git a/concurrency/Control/Concurrent/Classy/STM/TMVar.hs b/concurrency/Control/Concurrent/Classy/STM/TMVar.hs index 035daec..056f884 100755 --- a/concurrency/Control/Concurrent/Classy/STM/TMVar.hs +++ b/concurrency/Control/Concurrent/Classy/STM/TMVar.hs @@ -29,9 +29,9 @@ module Control.Concurrent.Classy.STM.TMVar , swapTMVar ) where -import Control.Monad (liftM, when, unless) -import Control.Monad.STM.Class -import Data.Maybe (isJust, isNothing) +import Control.Monad (liftM, unless, when) +import Control.Monad.STM.Class +import Data.Maybe (isJust, isNothing) -- | A @TMVar@ is like an @MVar@ or a @mVar@, but using transactional -- memory. As transactions are atomic, this makes dealing with diff --git a/concurrency/Control/Concurrent/Classy/STM/TQueue.hs b/concurrency/Control/Concurrent/Classy/STM/TQueue.hs index ad600f6..9f439cb 100644 --- a/concurrency/Control/Concurrent/Classy/STM/TQueue.hs +++ b/concurrency/Control/Concurrent/Classy/STM/TQueue.hs @@ -36,7 +36,7 @@ module Control.Concurrent.Classy.STM.TQueue , isEmptyTQueue ) where -import Control.Monad.STM.Class +import Control.Monad.STM.Class -- | 'TQueue' is an abstract type representing an unbounded FIFO channel. -- diff --git a/concurrency/Control/Concurrent/Classy/STM/TVar.hs b/concurrency/Control/Concurrent/Classy/STM/TVar.hs index df5940e..42d895f 100755 --- a/concurrency/Control/Concurrent/Classy/STM/TVar.hs +++ b/concurrency/Control/Concurrent/Classy/STM/TVar.hs @@ -25,9 +25,9 @@ module Control.Concurrent.Classy.STM.TVar , registerDelay ) where -import Control.Monad.STM.Class -import Control.Monad.Conc.Class -import Data.Functor (void) +import Control.Monad.Conc.Class +import Control.Monad.STM.Class +import Data.Functor (void) -- * @TVar@s diff --git a/concurrency/Control/Monad/Conc/Class.hs b/concurrency/Control/Monad/Conc/Class.hs index d72c36a..33f2a9c 100755 --- a/concurrency/Control/Monad/Conc/Class.hs +++ b/concurrency/Control/Monad/Conc/Class.hs @@ -66,30 +66,32 @@ module Control.Monad.Conc.Class ) where -- for the class and utilities -import Control.Exception (Exception, AsyncException(ThreadKilled), SomeException) -import Control.Monad.Catch (MonadCatch, MonadThrow, MonadMask) -import qualified Control.Monad.Catch as Ca -import Control.Monad.STM.Class (MonadSTM, TVar, readTVar) -import Control.Monad.Trans.Control (MonadTransControl, StT, liftWith) -import Data.Proxy (Proxy(..)) +import Control.Exception (AsyncException(ThreadKilled), + Exception, SomeException) +import Control.Monad.Catch (MonadCatch, MonadMask, + MonadThrow) +import qualified Control.Monad.Catch as Ca +import Control.Monad.STM.Class (MonadSTM, TVar, readTVar) +import Control.Monad.Trans.Control (MonadTransControl, StT, liftWith) +import Data.Proxy (Proxy(..)) -- for the 'IO' instance -import qualified Control.Concurrent as IO -import qualified Control.Concurrent.STM.TVar as IO -import qualified Control.Monad.STM as IO -import qualified Data.Atomics as IO -import qualified Data.IORef as IO +import qualified Control.Concurrent as IO +import qualified Control.Concurrent.STM.TVar as IO +import qualified Control.Monad.STM as IO +import qualified Data.Atomics as IO +import qualified Data.IORef as IO -- for the transformer instances -import Control.Monad.Reader (ReaderT) -import Control.Monad.Trans (lift) -import Control.Monad.Trans.Identity (IdentityT) -import qualified Control.Monad.RWS.Lazy as RL -import qualified Control.Monad.RWS.Strict as RS -import qualified Control.Monad.State.Lazy as SL -import qualified Control.Monad.State.Strict as SS -import qualified Control.Monad.Writer.Lazy as WL -import qualified Control.Monad.Writer.Strict as WS +import Control.Monad.Reader (ReaderT) +import qualified Control.Monad.RWS.Lazy as RL +import qualified Control.Monad.RWS.Strict as RS +import qualified Control.Monad.State.Lazy as SL +import qualified Control.Monad.State.Strict as SS +import Control.Monad.Trans (lift) +import Control.Monad.Trans.Identity (IdentityT) +import qualified Control.Monad.Writer.Lazy as WL +import qualified Control.Monad.Writer.Strict as WS -- | @MonadConc@ is an abstraction over GHC's typical concurrency -- abstraction. It captures the interface of concurrency monads in diff --git a/concurrency/Control/Monad/STM/Class.hs b/concurrency/Control/Monad/STM/Class.hs index 837f026..eab3af3 100755 --- a/concurrency/Control/Monad/STM/Class.hs +++ b/concurrency/Control/Monad/STM/Class.hs @@ -31,21 +31,21 @@ module Control.Monad.STM.Class , liftedOrElse ) where -import Control.Exception (Exception) -import Control.Monad (unless) -import Control.Monad.Reader (ReaderT) -import Control.Monad.Trans (lift) -import Control.Monad.Trans.Control (MonadTransControl, StT, liftWith) -import Control.Monad.Trans.Identity (IdentityT) +import Control.Exception (Exception) +import Control.Monad (unless) +import Control.Monad.Reader (ReaderT) +import Control.Monad.Trans (lift) +import Control.Monad.Trans.Control (MonadTransControl, StT, liftWith) +import Control.Monad.Trans.Identity (IdentityT) -import qualified Control.Concurrent.STM as STM -import qualified Control.Monad.Catch as Ca -import qualified Control.Monad.RWS.Lazy as RL -import qualified Control.Monad.RWS.Strict as RS -import qualified Control.Monad.State.Lazy as SL -import qualified Control.Monad.State.Strict as SS -import qualified Control.Monad.Writer.Lazy as WL -import qualified Control.Monad.Writer.Strict as WS +import qualified Control.Concurrent.STM as STM +import qualified Control.Monad.Catch as Ca +import qualified Control.Monad.RWS.Lazy as RL +import qualified Control.Monad.RWS.Strict as RS +import qualified Control.Monad.State.Lazy as SL +import qualified Control.Monad.State.Strict as SS +import qualified Control.Monad.Writer.Lazy as WL +import qualified Control.Monad.Writer.Strict as WS -- | @MonadSTM@ is an abstraction over 'STM'. -- diff --git a/concurrency/Setup.hs b/concurrency/Setup.hs index 9a994af..4467109 100755 --- a/concurrency/Setup.hs +++ b/concurrency/Setup.hs @@ -1,2 +1,2 @@ -import Distribution.Simple +import Distribution.Simple main = defaultMain diff --git a/dejafu/Setup.hs b/dejafu/Setup.hs index 9a994af..4467109 100755 --- a/dejafu/Setup.hs +++ b/dejafu/Setup.hs @@ -1,2 +1,2 @@ -import Distribution.Simple +import Distribution.Simple main = defaultMain diff --git a/dejafu/Test/DejaFu.hs b/dejafu/Test/DejaFu.hs index 21e8715..6e07b20 100644 --- a/dejafu/Test/DejaFu.hs +++ b/dejafu/Test/DejaFu.hs @@ -242,19 +242,19 @@ module Test.DejaFu , gives' ) where -import Control.Arrow (first) -import Control.DeepSeq (NFData(..)) -import Control.Monad (when, unless) -import Control.Monad.Ref (MonadRef) -import Control.Monad.ST (runST) -import Data.Function (on) -import Data.List (intercalate, intersperse, minimumBy) -import Data.Ord (comparing) -import System.Random (RandomGen, StdGen) +import Control.Arrow (first) +import Control.DeepSeq (NFData(..)) +import Control.Monad (unless, when) +import Control.Monad.Ref (MonadRef) +import Control.Monad.ST (runST) +import Data.Function (on) +import Data.List (intercalate, intersperse, minimumBy) +import Data.Ord (comparing) +import System.Random (RandomGen, StdGen) -import Test.DejaFu.Common -import Test.DejaFu.Conc -import Test.DejaFu.SCT +import Test.DejaFu.Common +import Test.DejaFu.Conc +import Test.DejaFu.SCT ------------------------------------------------------------------------------- diff --git a/dejafu/Test/DejaFu/Common.hs b/dejafu/Test/DejaFu/Common.hs index 13196bb..0af44e4 100644 --- a/dejafu/Test/DejaFu/Common.hs +++ b/dejafu/Test/DejaFu/Common.hs @@ -60,13 +60,13 @@ module Test.DejaFu.Common , MemType(..) ) where -import Control.DeepSeq (NFData(..)) -import Control.Exception (MaskingState(..)) -import Data.List (sort, nub, intercalate) -import Data.List.NonEmpty (NonEmpty) -import Data.Maybe (fromMaybe, mapMaybe) -import Data.Set (Set) -import qualified Data.Set as S +import Control.DeepSeq (NFData(..)) +import Control.Exception (MaskingState(..)) +import Data.List (intercalate, nub, sort) +import Data.List.NonEmpty (NonEmpty) +import Data.Maybe (fromMaybe, mapMaybe) +import Data.Set (Set) +import qualified Data.Set as S ------------------------------------------------------------------------------- -- Identifiers diff --git a/dejafu/Test/DejaFu/Conc.hs b/dejafu/Test/DejaFu/Conc.hs index 0737748..0d4e14e 100755 --- a/dejafu/Test/DejaFu/Conc.hs +++ b/dejafu/Test/DejaFu/Conc.hs @@ -1,9 +1,9 @@ -{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeSynonymInstances #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeSynonymInstances #-} -- | -- Module : Test.DejaFu.Conc @@ -46,23 +46,23 @@ module Test.DejaFu.Conc , module Test.DejaFu.Schedule ) where -import Control.Exception (MaskingState(..)) -import qualified Control.Monad.Base as Ba -import qualified Control.Monad.Catch as Ca -import qualified Control.Monad.IO.Class as IO -import Control.Monad.Ref (MonadRef) -import qualified Control.Monad.Ref as Re -import Control.Monad.ST (ST) -import qualified Data.Foldable as F -import Data.IORef (IORef) -import Data.STRef (STRef) -import Test.DejaFu.Schedule +import Control.Exception (MaskingState(..)) +import qualified Control.Monad.Base as Ba +import qualified Control.Monad.Catch as Ca +import qualified Control.Monad.IO.Class as IO +import Control.Monad.Ref (MonadRef) +import qualified Control.Monad.Ref as Re +import Control.Monad.ST (ST) +import qualified Data.Foldable as F +import Data.IORef (IORef) +import Data.STRef (STRef) +import Test.DejaFu.Schedule -import qualified Control.Monad.Conc.Class as C -import Test.DejaFu.Common -import Test.DejaFu.Conc.Internal -import Test.DejaFu.Conc.Internal.Common -import Test.DejaFu.STM +import qualified Control.Monad.Conc.Class as C +import Test.DejaFu.Common +import Test.DejaFu.Conc.Internal +import Test.DejaFu.Conc.Internal.Common +import Test.DejaFu.STM newtype Conc n r a = C { unC :: M n r a } deriving (Functor, Applicative, Monad) diff --git a/dejafu/Test/DejaFu/Conc/Internal.hs b/dejafu/Test/DejaFu/Conc/Internal.hs index ecc909c..a13cb28 100755 --- a/dejafu/Test/DejaFu/Conc/Internal.hs +++ b/dejafu/Test/DejaFu/Conc/Internal.hs @@ -1,5 +1,5 @@ {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} -- | @@ -15,24 +15,28 @@ -- interface of this library. module Test.DejaFu.Conc.Internal where -import Control.Exception (MaskingState(..), toException) -import Control.Monad.Ref (MonadRef, newRef, readRef, writeRef) -import qualified Data.Foldable as F -import Data.Functor (void) -import Data.List (sort) -import Data.List.NonEmpty (NonEmpty(..), fromList) -import qualified Data.Map.Strict as M -import Data.Maybe (fromJust, isJust, isNothing) -import Data.Monoid ((<>)) -import Data.Sequence (Seq, (<|)) -import qualified Data.Sequence as Seq +import Control.Exception (MaskingState(..), + toException) +import Control.Monad.Ref (MonadRef, newRef, readRef, + writeRef) +import qualified Data.Foldable as F +import Data.Functor (void) +import Data.List (sort) +import Data.List.NonEmpty (NonEmpty(..), fromList) +import qualified Data.Map.Strict as M +import Data.Maybe (fromJust, isJust, + isNothing) +import Data.Monoid ((<>)) +import Data.Sequence (Seq, (<|)) +import qualified Data.Sequence as Seq -import Test.DejaFu.Common -import Test.DejaFu.Conc.Internal.Common -import Test.DejaFu.Conc.Internal.Memory -import Test.DejaFu.Conc.Internal.Threading -import Test.DejaFu.Schedule -import Test.DejaFu.STM (Result(..), runTransaction) +import Test.DejaFu.Common +import Test.DejaFu.Conc.Internal.Common +import Test.DejaFu.Conc.Internal.Memory +import Test.DejaFu.Conc.Internal.Threading +import Test.DejaFu.Schedule +import Test.DejaFu.STM (Result(..), + runTransaction) -------------------------------------------------------------------------------- -- * Execution diff --git a/dejafu/Test/DejaFu/Conc/Internal/Common.hs b/dejafu/Test/DejaFu/Conc/Internal/Common.hs index b451bf6..485ad9a 100755 --- a/dejafu/Test/DejaFu/Conc/Internal/Common.hs +++ b/dejafu/Test/DejaFu/Conc/Internal/Common.hs @@ -1,5 +1,5 @@ {-# LANGUAGE ExistentialQuantification #-} -{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE RankNTypes #-} -- | -- Module : Test.DejaFu.Conc.Internal.Common @@ -13,11 +13,11 @@ -- 'MonadConc' implementations. This module is NOT considered to form module Test.DejaFu.Conc.Internal.Common where -import Control.Exception (Exception, MaskingState(..)) -import Data.Map.Strict (Map) -import Data.List.NonEmpty (NonEmpty, fromList) -import Test.DejaFu.Common -import Test.DejaFu.STM (STMLike) +import Control.Exception (Exception, MaskingState(..)) +import Data.List.NonEmpty (NonEmpty, fromList) +import Data.Map.Strict (Map) +import Test.DejaFu.Common +import Test.DejaFu.STM (STMLike) -------------------------------------------------------------------------------- -- * The @Conc@ Monad diff --git a/dejafu/Test/DejaFu/Conc/Internal/Memory.hs b/dejafu/Test/DejaFu/Conc/Internal/Memory.hs index 408270f..bfb3a27 100755 --- a/dejafu/Test/DejaFu/Conc/Internal/Memory.hs +++ b/dejafu/Test/DejaFu/Conc/Internal/Memory.hs @@ -1,5 +1,5 @@ {-# LANGUAGE BangPatterns #-} -{-# LANGUAGE GADTs #-} +{-# LANGUAGE GADTs #-} {-# LANGUAGE MultiParamTypeClasses #-} -- | @@ -23,18 +23,20 @@ -- Memory Models/, N. Zhang, M. Kusano, and C. Wang (2015). module Test.DejaFu.Conc.Internal.Memory where -import Control.Monad (when) -import Control.Monad.Ref (MonadRef, readRef, writeRef) -import Data.Map.Strict (Map) -import Data.Maybe (isJust, fromJust) -import Data.Monoid ((<>)) -import Data.Sequence (Seq, ViewL(..), (><), singleton, viewl) +import Control.Monad (when) +import Control.Monad.Ref (MonadRef, readRef, + writeRef) +import Data.Map.Strict (Map) +import Data.Maybe (fromJust, isJust) +import Data.Monoid ((<>)) +import Data.Sequence (Seq, ViewL(..), singleton, + viewl, (><)) -import Test.DejaFu.Common -import Test.DejaFu.Conc.Internal.Common -import Test.DejaFu.Conc.Internal.Threading +import Test.DejaFu.Common +import Test.DejaFu.Conc.Internal.Common +import Test.DejaFu.Conc.Internal.Threading -import qualified Data.Map.Strict as M +import qualified Data.Map.Strict as M -------------------------------------------------------------------------------- -- * Manipulating @CRef@s diff --git a/dejafu/Test/DejaFu/Conc/Internal/Threading.hs b/dejafu/Test/DejaFu/Conc/Internal/Threading.hs index 1c2757d..e3d13c3 100644 --- a/dejafu/Test/DejaFu/Conc/Internal/Threading.hs +++ b/dejafu/Test/DejaFu/Conc/Internal/Threading.hs @@ -1,5 +1,5 @@ {-# LANGUAGE ExistentialQuantification #-} -{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE RankNTypes #-} -- | -- Module : Test.DejaFu.Conc.Internal.Threading @@ -13,15 +13,16 @@ -- form part of the public interface of this library. module Test.DejaFu.Conc.Internal.Threading where -import Control.Exception (Exception, MaskingState(..), SomeException, fromException) -import Data.List (intersect) -import Data.Map.Strict (Map) -import Data.Maybe (fromMaybe, isJust) +import Control.Exception (Exception, MaskingState(..), + SomeException, fromException) +import Data.List (intersect) +import Data.Map.Strict (Map) +import Data.Maybe (fromMaybe, isJust) -import Test.DejaFu.Common -import Test.DejaFu.Conc.Internal.Common +import Test.DejaFu.Common +import Test.DejaFu.Conc.Internal.Common -import qualified Data.Map.Strict as M +import qualified Data.Map.Strict as M -------------------------------------------------------------------------------- -- * Threads diff --git a/dejafu/Test/DejaFu/SCT.hs b/dejafu/Test/DejaFu/SCT.hs index 5b7cc7f..a1302e9 100755 --- a/dejafu/Test/DejaFu/SCT.hs +++ b/dejafu/Test/DejaFu/SCT.hs @@ -90,17 +90,17 @@ module Test.DejaFu.SCT , sctRandom ) where -import Control.DeepSeq (NFData(..)) -import Control.Monad.Ref (MonadRef) -import Data.List (foldl') -import qualified Data.Map.Strict as M -import Data.Set (Set) -import qualified Data.Set as S -import System.Random (RandomGen) +import Control.DeepSeq (NFData(..)) +import Control.Monad.Ref (MonadRef) +import Data.List (foldl') +import qualified Data.Map.Strict as M +import Data.Set (Set) +import qualified Data.Set as S +import System.Random (RandomGen) -import Test.DejaFu.Common -import Test.DejaFu.Conc -import Test.DejaFu.SCT.Internal +import Test.DejaFu.Common +import Test.DejaFu.Conc +import Test.DejaFu.SCT.Internal ------------------------------------------------------------------------------- -- Running Concurrent Programs diff --git a/dejafu/Test/DejaFu/SCT/Internal.hs b/dejafu/Test/DejaFu/SCT/Internal.hs index a9d5bd5..26fd1fa 100644 --- a/dejafu/Test/DejaFu/SCT/Internal.hs +++ b/dejafu/Test/DejaFu/SCT/Internal.hs @@ -11,24 +11,26 @@ -- interface of this library. module Test.DejaFu.SCT.Internal where -import Control.DeepSeq (NFData(..)) -import Control.Exception (MaskingState(..)) -import Data.Char (ord) -import Data.Function (on) -import qualified Data.Foldable as F -import Data.List (intercalate, nubBy, partition, sortOn) -import Data.List.NonEmpty (NonEmpty(..), toList) -import Data.Map.Strict (Map) -import Data.Maybe (catMaybes, fromJust, isJust, isNothing, listToMaybe) -import qualified Data.Map.Strict as M -import Data.Set (Set) -import qualified Data.Set as S -import Data.Sequence (Seq, (|>)) -import qualified Data.Sequence as Sq -import System.Random (RandomGen, randomR) +import Control.DeepSeq (NFData(..)) +import Control.Exception (MaskingState(..)) +import Data.Char (ord) +import qualified Data.Foldable as F +import Data.Function (on) +import Data.List (intercalate, nubBy, partition, sortOn) +import Data.List.NonEmpty (NonEmpty(..), toList) +import Data.Map.Strict (Map) +import qualified Data.Map.Strict as M +import Data.Maybe (catMaybes, fromJust, isJust, isNothing, + listToMaybe) +import Data.Sequence (Seq, (|>)) +import qualified Data.Sequence as Sq +import Data.Set (Set) +import qualified Data.Set as S +import System.Random (RandomGen, randomR) -import Test.DejaFu.Common -import Test.DejaFu.Schedule (Decision(..), Scheduler, decisionOf, tidOf) +import Test.DejaFu.Common +import Test.DejaFu.Schedule (Decision(..), Scheduler, decisionOf, + tidOf) ------------------------------------------------------------------------------- -- * Dynamic partial-order reduction diff --git a/dejafu/Test/DejaFu/STM.hs b/dejafu/Test/DejaFu/STM.hs index 4dfd008..3fb3df8 100755 --- a/dejafu/Test/DejaFu/STM.hs +++ b/dejafu/Test/DejaFu/STM.hs @@ -1,6 +1,6 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeFamilies #-} -- | -- Module : Test.DejaFu.STM @@ -26,17 +26,17 @@ module Test.DejaFu.STM , runTransaction ) where -import Control.Monad (unless) -import Control.Monad.Catch (MonadCatch(..), MonadThrow(..)) -import Control.Monad.Cont (cont) -import Control.Monad.Ref (MonadRef) -import Control.Monad.ST (ST) -import Data.IORef (IORef) -import Data.STRef (STRef) +import Control.Monad (unless) +import Control.Monad.Catch (MonadCatch(..), MonadThrow(..)) +import Control.Monad.Cont (cont) +import Control.Monad.Ref (MonadRef) +import Control.Monad.ST (ST) +import Data.IORef (IORef) +import Data.STRef (STRef) -import qualified Control.Monad.STM.Class as C -import Test.DejaFu.Common -import Test.DejaFu.STM.Internal +import qualified Control.Monad.STM.Class as C +import Test.DejaFu.Common +import Test.DejaFu.STM.Internal newtype STMLike n r a = S { runSTM :: M n r a } deriving (Functor, Applicative, Monad) diff --git a/dejafu/Test/DejaFu/STM/Internal.hs b/dejafu/Test/DejaFu/STM/Internal.hs index af83e39..6c2f8c4 100755 --- a/dejafu/Test/DejaFu/STM/Internal.hs +++ b/dejafu/Test/DejaFu/STM/Internal.hs @@ -15,13 +15,14 @@ -- public interface of this library. module Test.DejaFu.STM.Internal where -import Control.DeepSeq (NFData(..)) -import Control.Exception (Exception, SomeException, fromException, toException) -import Control.Monad.Cont (Cont, runCont) -import Control.Monad.Ref (MonadRef, newRef, readRef, writeRef) -import Data.List (nub) +import Control.DeepSeq (NFData(..)) +import Control.Exception (Exception, SomeException, fromException, + toException) +import Control.Monad.Cont (Cont, runCont) +import Control.Monad.Ref (MonadRef, newRef, readRef, writeRef) +import Data.List (nub) -import Test.DejaFu.Common +import Test.DejaFu.Common -------------------------------------------------------------------------------- -- The @STMLike@ monad diff --git a/dejafu/Test/DejaFu/Schedule.hs b/dejafu/Test/DejaFu/Schedule.hs index 63c8f09..a3752af 100644 --- a/dejafu/Test/DejaFu/Schedule.hs +++ b/dejafu/Test/DejaFu/Schedule.hs @@ -29,10 +29,10 @@ module Test.DejaFu.Schedule , makeNonPreemptive ) where -import Data.List.NonEmpty (NonEmpty(..), toList) -import System.Random (RandomGen, randomR) +import Data.List.NonEmpty (NonEmpty(..), toList) +import System.Random (RandomGen, randomR) -import Test.DejaFu.Common +import Test.DejaFu.Common -- | A @Scheduler@ drives the execution of a concurrent program. The -- parameters it takes are: diff --git a/hunit-dejafu/Setup.hs b/hunit-dejafu/Setup.hs index 9a994af..4467109 100755 --- a/hunit-dejafu/Setup.hs +++ b/hunit-dejafu/Setup.hs @@ -1,2 +1,2 @@ -import Distribution.Simple +import Distribution.Simple main = defaultMain diff --git a/hunit-dejafu/Test/HUnit/DejaFu.hs b/hunit-dejafu/Test/HUnit/DejaFu.hs index 84377c5..39b3daa 100755 --- a/hunit-dejafu/Test/HUnit/DejaFu.hs +++ b/hunit-dejafu/Test/HUnit/DejaFu.hs @@ -59,19 +59,20 @@ module Test.HUnit.DejaFu , MemType(..) ) where -import Control.Monad.Catch (try) -import Control.Monad.ST (runST) -import Data.List (intercalate, intersperse) -import System.Random (RandomGen) -import Test.HUnit (Assertable(..), Test(..), Testable(..), assertString) -import Test.HUnit.Lang (HUnitFailure(..)) -import Test.DejaFu -import qualified Test.DejaFu.Conc as Conc -import qualified Test.DejaFu.SCT as SCT +import Control.Monad.Catch (try) +import Control.Monad.ST (runST) +import Data.List (intercalate, intersperse) +import System.Random (RandomGen) +import Test.DejaFu +import qualified Test.DejaFu.Conc as Conc +import qualified Test.DejaFu.SCT as SCT +import Test.HUnit (Assertable(..), Test(..), Testable(..), + assertString) +import Test.HUnit.Lang (HUnitFailure(..)) -- Can't put the necessary forall in the @Assertable Conc.ConcST t@ -- 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 way memtype conc = runST (SCT.runSCT way memtype conc) diff --git a/tasty-dejafu/Setup.hs b/tasty-dejafu/Setup.hs index 9a994af..4467109 100755 --- a/tasty-dejafu/Setup.hs +++ b/tasty-dejafu/Setup.hs @@ -1,2 +1,2 @@ -import Distribution.Simple +import Distribution.Simple main = defaultMain diff --git a/tasty-dejafu/Test/Tasty/DejaFu.hs b/tasty-dejafu/Test/Tasty/DejaFu.hs index 77f182d..1be718e 100755 --- a/tasty-dejafu/Test/Tasty/DejaFu.hs +++ b/tasty-dejafu/Test/Tasty/DejaFu.hs @@ -56,23 +56,25 @@ module Test.Tasty.DejaFu , MemType(..) ) where -import Control.Monad.ST (runST) -import Data.Char (toUpper) -import Data.List (intercalate, intersperse) -import Data.Proxy (Proxy(..)) -import Data.Tagged (Tagged(..)) -import Data.Typeable (Typeable) -import System.Random (RandomGen, StdGen, mkStdGen) -import Test.DejaFu -import qualified Test.DejaFu.Conc as Conc -import qualified Test.DejaFu.SCT as SCT -import Test.Tasty (TestName, TestTree, testGroup) -import Test.Tasty.Options (OptionDescription(..), IsOption(..), lookupOption) -import Test.Tasty.Providers (IsTest(..), singleTest, testPassed, testFailed) +import Control.Monad.ST (runST) +import Data.Char (toUpper) +import Data.List (intercalate, intersperse) +import Data.Proxy (Proxy(..)) +import Data.Tagged (Tagged(..)) +import Data.Typeable (Typeable) +import System.Random (RandomGen, StdGen, mkStdGen) +import Test.DejaFu +import qualified Test.DejaFu.Conc as Conc +import qualified Test.DejaFu.SCT as SCT +import Test.Tasty (TestName, TestTree, testGroup) +import Test.Tasty.Options (IsOption(..), OptionDescription(..), + lookupOption) +import Test.Tasty.Providers (IsTest(..), singleTest, testFailed, + testPassed) -- Can't put the necessary forall in the @IsTest ConcST t@ -- 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 way memtype conc = runST (SCT.runSCT way memtype conc)