extensible-effects-concurrent: Message passing concurrency as extensible-effect

[ bsd3, concurrency, control, effect, library, program ] [ Propose Tags ]
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.1.0, 0.1.2.0, 0.1.2.1, 0.1.2.2, 0.1.3.0, 0.2.0.2, 0.2.0.3, 0.3.0.0, 0.3.0.1, 0.3.0.2, 0.4.0.0, 0.5.0.0, 0.5.0.1, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.8, 0.9.0, 0.9.2, 0.9.2.1, 0.9.2.2, 0.10.0, 0.11.1, 0.12.0, 0.12.1, 0.13.0, 0.13.2, 0.14.0, 0.14.1, 0.14.2, 0.14.3, 0.15.0, 0.16.0, 0.16.1, 0.17.0, 0.18.0, 0.18.1, 0.19.0, 0.19.1, 0.20.0, 0.21.0, 0.21.1, 0.22.0, 0.22.1, 0.23.0, 0.24.0, 0.24.1, 0.24.2, 0.24.3, 0.25.0, 0.25.1, 0.26.0, 0.26.1, 0.27.0, 0.28.0, 0.29.0, 0.29.1, 0.29.2, 0.30.0, 0.31.0, 0.32.0, 2.0.0
Change log ChangeLog.md
Dependencies async (>=2.2 && <3), base (>=4.12 && <5), containers (>=0.5.8 && <0.7), data-default (>=0.7 && <0.8), deepseq (>=1.4 && <1.5), directory, exceptions (>=0.10 && <0.11), extensible-effects (>=5 && <6), extensible-effects-concurrent, filepath (>=1.4 && <1.5), hostname, lens (>=4.14 && <4.18), monad-control (>=1.0 && <1.1), mtl (>=2.2 && <2.3), parallel (>=3.2 && <3.3), process (>=1.6 && <1.7), QuickCheck, safe-exceptions (>=0.1 && <0.2), stm (>=2.4.5 && <2.6), time (>=1.8 && <1.9), transformers-base (>=0.4 && <0.5) [details]
License BSD-3-Clause
Copyright Copyright Sven Heyll
Author Sven Heyll
Maintainer sven.heyll@gmail.com
Category Concurrency, Control, Effect
Home page https://github.com/sheyll/extensible-effects-concurrent#readme
Bug tracker https://github.com/sheyll/extensible-effects-concurrent/issues
Source repo head: git clone https://github.com/sheyll/extensible-effects-concurrent
Uploaded by SvenHeyll at 2019-04-06T03:27:28Z
Distributions
Executables extensible-effects-concurrent-example-4, extensible-effects-concurrent-example-3, extensible-effects-concurrent-example-2, extensible-effects-concurrent-example-1
Downloads 29438 total (153 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-04-06 [all 1 reports]

Readme for extensible-effects-concurrent-0.19.1

[back to package description]

extensible-effects-concurrent

Message passing concurrency with 'forkIO' and 'extensible-effects' inspired by Erlang.

Build Status

Hackage

Also included:

  • Logging

  • Memory Leak Free forever

GHC Extensions

In order to use the library you might need to activate some extension in order to fight some ambiguous types, stemming from the flexibility to choose different Scheduler implementations.

  • AllowAmbiguousTypes
  • TypeApplications

Example

module Main where

import           Control.Eff
import           Control.Eff.Concurrent
import           Data.Dynamic
import           Control.DeepSeq
import           GHC.Stack (HasCallStack)

main :: IO ()
main = defaultMain firstExample

newtype WhoAreYou = WhoAreYou ProcessId 
  deriving (Typeable, NFData, Show)

firstExample 
  :: (HasCallStack, Member Logs q) 
  => Eff (InterruptableProcess q) ()
firstExample = do
  person <- spawn
    (do
      logInfo "I am waiting for someone to ask me..."
      WhoAreYou replyPid <- receiveMessage
      sendMessage replyPid "Alice"
      logInfo (show replyPid ++ " just needed to know it.")
    )
  me <- self
  sendMessage person (WhoAreYou me)
  personName <- receiveMessage
  logInfo ("I just met " ++ personName)

Running this example causes this output:

DEBUG     scheduler loop entered                                                   ForkIOScheduler.hs line 157
DEBUG            !1 enter process                                                            ForkIOScheduler.hs line 549
NOTICE           !1 ++++++++ main process started ++++++++                                   ForkIOScheduler.hs line 461
DEBUG            !2 enter process                                                            ForkIOScheduler.hs line 549
INFO             !2 I am waiting for someone to ask me...                                               Main.hs line 26
INFO             !2 !1 just needed to know it.                                                          Main.hs line 29
DEBUG            !2 exit normally                                                            ForkIOScheduler.hs line 568
INFO             !1 I just met Alice                                                                    Main.hs line 34
NOTICE           !1 ++++++++ main process returned ++++++++                                  ForkIOScheduler.hs line 463
DEBUG            !1 exit normally                                                            ForkIOScheduler.hs line 568
DEBUG     scheduler loop returned                                                  ForkIOScheduler.hs line 159
DEBUG     scheduler cleanup begin                                                  ForkIOScheduler.hs line 154
NOTICE    cancelling processes: []                                                 ForkIOScheduler.hs line 168
NOTICE    all processes cancelled                                                  ForkIOScheduler.hs line 179

TODO

Stackage

Still todo...

extensible-effects-concurrent LTS

Other

  • Process Linking/Monitoring

  • Scheduler ekg Monitoring

  • Timers and Timeouts (e.g. in receive)

  • Rename stuff