theatre 1.0.0.1 → 1.0.0.2
raw patch · 4 files changed
+99/−121 lines, 4 filesdep −semigroupssetup-changedPVP ok
version bump matches the API change (PVP)
Dependencies removed: semigroups
API changes (from Hackage documentation)
Files
- Setup.hs +0/−2
- library/Theatre.hs +66/−60
- library/Theatre/Prelude.hs +14/−20
- theatre.cabal +19/−39
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
library/Theatre.hs view
@@ -1,34 +1,31 @@-{-|-Minimalistic actor library.--}+-- |+-- Minimalistic actor library. module Theatre-(- Actor,- -- * Construction- graceful,- disgraceful,- suicidal,- -- * Usage- tell,- kill,-)+ ( Actor,++ -- * Construction+ graceful,+ disgraceful,+ suicidal,++ -- * Usage+ tell,+ kill,+ ) where -import Theatre.Prelude import qualified Control.Concurrent.Chan.Unagi as E import qualified SlaveThread as F---{-|-Actor, which processes the messages of type @message@.+import Theatre.Prelude -An abstraction over the message channel, thread-forking and killing.--}-data Actor message =- Actor {- {-| Send a message to the actor -}+-- |+-- Actor, which processes the messages of type @message@.+--+-- An abstraction over the message channel, thread-forking and killing.+data Actor message = Actor+ { -- | Send a message to the actor tell :: message -> IO (),- {-| Kill the actor -}+ -- | Kill the actor kill :: IO () } @@ -74,50 +71,59 @@ kill = leftKill >> rightKill -{-|-An actor which cannot die by itself unless explicitly killed.--Given an interpreter of messages,-forks a thread to run the computation on and -produces a handle to address that actor.--Killing that actor will make it process all the messages in the queue first.-All the messages sent to it after killing won't be processed.--}-graceful :: (message -> IO ()) {-^ Interpreter of a message -} -> IO (Actor message)+-- |+-- An actor which cannot die by itself unless explicitly killed.+--+-- Given an interpreter of messages,+-- forks a thread to run the computation on and+-- produces a handle to address that actor.+--+-- Killing that actor will make it process all the messages in the queue first.+-- All the messages sent to it after killing won't be processed.+graceful ::+ -- | Interpreter of a message+ (message -> IO ()) ->+ IO (Actor message) graceful interpretMessage = do (inChan, outChan) <- E.newChan- F.fork $ fix $ \loop -> {-# SCC "graceful/loop" #-} do- message <- E.readChan outChan- case message of- Just payload ->- do- interpretMessage payload- loop- Nothing ->- return ()+ F.fork $+ fix $ \loop ->+ {-# SCC "graceful/loop" #-}+ do+ message <- E.readChan outChan+ case message of+ Just payload ->+ do+ interpretMessage payload+ loop+ Nothing ->+ return () return (Actor (E.writeChan inChan . Just) (E.writeChan inChan Nothing)) -{-|-An actor which cannot die by itself unless explicitly killed.--Given an interpreter of messages,-forks a thread to run the computation on and -produces a handle to address that actor.--}-disgraceful :: (message -> IO ()) {-^ Interpreter of a message -} -> IO (Actor message)+-- |+-- An actor which cannot die by itself unless explicitly killed.+--+-- Given an interpreter of messages,+-- forks a thread to run the computation on and+-- produces a handle to address that actor.+disgraceful ::+ -- | Interpreter of a message+ (message -> IO ()) ->+ IO (Actor message) disgraceful receiver = suicidal (\producer -> forever (producer >>= receiver)) -{-|-An actor, whose interpreter can decide that the actor should die.--Given an implementation of a receiver loop of messages,-forks a thread to run that receiver on and-produces a handle to address that actor.--}-suicidal :: (IO message -> IO ()) {-^ A message receiver loop. When the loop exits, the actor dies -} -> IO (Actor message)+-- |+-- An actor, whose interpreter can decide that the actor should die.+--+-- Given an implementation of a receiver loop of messages,+-- forks a thread to run that receiver on and+-- produces a handle to address that actor.+suicidal ::+ -- | A message receiver loop. When the loop exits, the actor dies+ (IO message -> IO ()) ->+ IO (Actor message) suicidal receiver = do (inChan, outChan) <- E.newChan
library/Theatre/Prelude.hs view
@@ -1,20 +1,17 @@ module Theatre.Prelude-(- module Exports,-)+ ( module Exports,+ ) where --- base-------------------------- import Control.Applicative as Exports import Control.Arrow as Exports hiding (first, second) import Control.Category as Exports import Control.Concurrent as Exports import Control.Exception as Exports-import Control.Monad as Exports hiding (fail, mapM_, sequence_, forM_, msum, mapM, sequence, forM)-import Control.Monad.IO.Class as Exports+import Control.Monad as Exports hiding (fail, forM, forM_, mapM, mapM_, msum, sequence, sequence_) import Control.Monad.Fail as Exports import Control.Monad.Fix as Exports hiding (fix)+import Control.Monad.IO.Class as Exports import Control.Monad.ST as Exports import Data.Bifunctor as Exports import Data.Bits as Exports@@ -30,11 +27,12 @@ import Data.Function as Exports hiding (id, (.)) import Data.Functor as Exports import Data.Functor.Contravariant as Exports-import Data.Int as Exports+import Data.Functor.Contravariant.Divisible as Exports import Data.IORef as Exports+import Data.Int as Exports import Data.Ix as Exports-import Data.List as Exports hiding (sortOn, isSubsequenceOf, uncons, concat, foldr, foldl1, maximum, minimum, product, sum, all, and, any, concatMap, elem, foldl, foldr1, notElem, or, find, maximumBy, minimumBy, mapAccumL, mapAccumR, foldl')-import Data.List.NonEmpty as Exports (NonEmpty(..))+import Data.List as Exports hiding (all, and, any, concat, concatMap, elem, find, foldl, foldl', foldl1, foldr, foldr1, isSubsequenceOf, mapAccumL, mapAccumR, maximum, maximumBy, minimum, minimumBy, notElem, or, product, sortOn, sum, uncons)+import Data.List.NonEmpty as Exports (NonEmpty (..)) import Data.Maybe as Exports import Data.Monoid as Exports hiding (Alt) import Data.Ord as Exports@@ -53,12 +51,11 @@ import Foreign.Ptr as Exports import Foreign.StablePtr as Exports import Foreign.Storable as Exports-import GHC.Conc as Exports hiding (withMVar, threadWaitWriteSTM, threadWaitWrite, threadWaitReadSTM, threadWaitRead)-import GHC.Exts as Exports (lazy, inline, sortWith, groupWith)+import GHC.Conc as Exports hiding (threadWaitRead, threadWaitReadSTM, threadWaitWrite, threadWaitWriteSTM, withMVar)+import GHC.Exts as Exports (groupWith, inline, lazy, sortWith) import GHC.Generics as Exports (Generic) import GHC.IO.Exception as Exports import Numeric as Exports-import Prelude as Exports hiding (fail, concat, foldr, mapM_, sequence_, foldl1, maximum, minimum, product, sum, all, and, any, concatMap, elem, foldl, foldr1, notElem, or, mapM, sequence, id, (.)) import System.Environment as Exports import System.Exit as Exports import System.IO as Exports (Handle, hClose)@@ -68,11 +65,8 @@ import System.Mem.StableName as Exports import System.Timeout as Exports import Text.ParserCombinators.ReadP as Exports (ReadP, ReadS, readP_to_S, readS_to_P)-import Text.ParserCombinators.ReadPrec as Exports (ReadPrec, readPrec_to_P, readP_to_Prec, readPrec_to_S, readS_to_Prec)-import Text.Printf as Exports (printf, hPrintf)-import Text.Read as Exports (Read(..), readMaybe, readEither)+import Text.ParserCombinators.ReadPrec as Exports (ReadPrec, readP_to_Prec, readPrec_to_P, readPrec_to_S, readS_to_Prec)+import Text.Printf as Exports (hPrintf, printf)+import Text.Read as Exports (Read (..), readEither, readMaybe) import Unsafe.Coerce as Exports---- contravariant---------------------------import Data.Functor.Contravariant.Divisible as Exports+import Prelude as Exports hiding (all, and, any, concat, concatMap, elem, fail, foldl, foldl1, foldr, foldr1, id, mapM, mapM_, maximum, minimum, notElem, or, product, sequence, sequence_, sum, (.))
theatre.cabal view
@@ -1,30 +1,17 @@-name:- theatre-version:- 1.0.0.1-category:- Concurrency, Actors-synopsis:- Minimalistic actor library-homepage:- https://github.com/nikita-volkov/theatre -bug-reports:- https://github.com/nikita-volkov/theatre/issues -author:- Nikita Volkov <nikita.y.volkov@mail.ru>-maintainer:- Nikita Volkov <nikita.y.volkov@mail.ru>-copyright:- (c) 2017, Nikita Volkov-license:- MIT-license-file:- LICENSE-build-type:- Simple-cabal-version:- >=1.10+cabal-version: 3.0 +name: theatre+version: 1.0.0.2+category: Concurrency, Actors+synopsis: Minimalistic actor library+homepage: https://github.com/nikita-volkov/theatre+bug-reports: https://github.com/nikita-volkov/theatre/issues+author: Nikita Volkov <nikita.y.volkov@mail.ru>+maintainer: Nikita Volkov <nikita.y.volkov@mail.ru>+copyright: (c) 2017, Nikita Volkov+license: MIT+license-file: LICENSE+ source-repository head type: git@@ -32,22 +19,15 @@ git://github.com/nikita-volkov/theatre.git library- hs-source-dirs:- library- default-extensions:- Arrows, BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, PatternSynonyms, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, TemplateHaskell, TupleSections, TypeFamilies, TypeOperators, UnboxedTuples- default-language:- Haskell2010+ hs-source-dirs: library+ default-extensions: Arrows, BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, PatternSynonyms, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, TemplateHaskell, TupleSections, TypeFamilies, TypeOperators, UnboxedTuples+ default-language: Haskell2010 exposed-modules: Theatre other-modules: Theatre.Prelude build-depends:- -- concurrency:- unagi-chan ==0.4.*,- slave-thread ==1.*,- -- control:+ base >=4.9 && <5, contravariant >=1.3 && <2,- semigroups >=0.18 && <0.20,- -- general:- base >=4.9 && <5+ slave-thread ==1.*,+ unagi-chan ==0.4.*,