{"id":17250681,"url":"https://github.com/statusfailed/machines-io","last_synced_at":"2025-03-26T06:42:59.908Z","repository":{"id":31066781,"uuid":"34625652","full_name":"statusfailed/machines-io","owner":"statusfailed","description":null,"archived":false,"fork":false,"pushed_at":"2018-01-30T23:07:40.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-31T08:18:58.369Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/statusfailed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-26T18:42:31.000Z","updated_at":"2018-09-18T21:46:59.000Z","dependencies_parsed_at":"2022-08-03T15:16:35.617Z","dependency_job_id":null,"html_url":"https://github.com/statusfailed/machines-io","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statusfailed%2Fmachines-io","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statusfailed%2Fmachines-io/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statusfailed%2Fmachines-io/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statusfailed%2Fmachines-io/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/statusfailed","download_url":"https://codeload.github.com/statusfailed/machines-io/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245605709,"owners_count":20643030,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T06:49:19.653Z","updated_at":"2025-03-26T06:42:59.890Z","avatar_url":"https://github.com/statusfailed.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Concurrency utilities for `machines`\n\nNOTE: this is mostly an experiment. I advise against using it!\n\n# What is it for?\n\nSimple use case: if you have two sources of data (say sockets),\nand you want to do a blocking read on both, and merge the events\n\nExample code below. Note this will finish by crashing, because\nthere are no more processes writing to the `Chan`.\n\n    {-# LANGUAGE RankNTypes #-}\n    module Main where\n\n    import Data.Machine\n    import Data.Machine.IO.Concurrent\n    import Control.Monad.IO.Class\n    import Control.Concurrent (newChan, forkIO, threadDelay)\n\n    -- | Yield elements from a list with a specified delay in microseconds between each.\n    slowSource :: MonadIO m =\u003e Int -\u003e [a] -\u003e ProcessT m () a\n    slowSource t xs = construct $ go xs\n      where\n        go [] = return ()\n        go (x:xs) = do\n          liftIO $ threadDelay t -- wait 1 second\n          yield x\n          go xs\n\n    main = do\n      c \u003c- newChan\n      t1 \u003c- forkIO id (runT_ $ slowSource 500000  [1..4] ~\u003e toChan c)\n      t2 \u003c- forkIO id (runT_ $ slowSource 1000000 [1..4] ~\u003e toChan c)\n      runT_ $ fromChan c ~\u003e autoM print\n      print \"done\"\n\nRunning it:\n\n    *Main\u003e main\n    1\n    2\n    1\n    3\n    4\n    2\n    3\n    4\n    *** Exception: thread blocked indefinitely in an MVar operation\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatusfailed%2Fmachines-io","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstatusfailed%2Fmachines-io","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatusfailed%2Fmachines-io/lists"}