mirror of
https://github.com/barrucadu/dejafu.git
synced 2024-11-22 03:52:12 +03:00
Use stylish-haskell to format import lists.
This commit is contained in:
parent
d934222fe7
commit
cc27e03d6d
62
.stylish-haskell.yaml
Normal file
62
.stylish-haskell.yaml
Normal 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
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
@ -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@.
|
||||
--
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
--
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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'.
|
||||
--
|
||||
|
@ -1,2 +1,2 @@
|
||||
import Distribution.Simple
|
||||
import Distribution.Simple
|
||||
main = defaultMain
|
||||
|
@ -1,2 +1,2 @@
|
||||
import Distribution.Simple
|
||||
import Distribution.Simple
|
||||
main = defaultMain
|
||||
|
@ -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
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -1,2 +1,2 @@
|
||||
import Distribution.Simple
|
||||
import Distribution.Simple
|
||||
main = defaultMain
|
||||
|
@ -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)
|
||||
|
@ -1,2 +1,2 @@
|
||||
import Distribution.Simple
|
||||
import Distribution.Simple
|
||||
main = defaultMain
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user