{"id":16825110,"url":"https://github.com/safareli/free","last_synced_at":"2025-07-29T23:34:09.903Z","repository":{"id":143788508,"uuid":"61940236","full_name":"safareli/free","owner":"safareli","description":"Combination of a free applicative functor and free monad","archived":false,"fork":false,"pushed_at":"2020-08-09T12:27:35.000Z","size":53,"stargazers_count":58,"open_issues_count":8,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-17T14:06:01.547Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/safareli.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-06-25T11:28:11.000Z","updated_at":"2024-11-14T03:13:16.000Z","dependencies_parsed_at":"2023-03-27T17:16:59.455Z","dependency_job_id":null,"html_url":"https://github.com/safareli/free","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/safareli/free","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/safareli%2Ffree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/safareli%2Ffree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/safareli%2Ffree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/safareli%2Ffree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/safareli","download_url":"https://codeload.github.com/safareli/free/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/safareli%2Ffree/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267780216,"owners_count":24143202,"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","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-13T11:12:55.306Z","updated_at":"2025-07-29T23:34:09.873Z","avatar_url":"https://github.com/safareli.png","language":"JavaScript","funding_links":[],"categories":["Libraries"],"sub_categories":["[Javascript](https://developer.mozilla.org/en-US/docs/Web/JavaScript)"],"readme":"# Free [![Build Status][build-image]][build] [![npm Version][version-image]][version] [![Code Coverage][coverage-image]][coverage] [![Code Climate][climate-image]][climate] [![License][license-image]][license]\n\n\u003e Combination of a Free applicative functor and Free monad.\n\n\n## API\n\n### Types\n```hs\ndata Par f a where\n  Pure :: a -\u003e Par f a\n  Lift :: f a -\u003e Par f a\n  Ap :: Par f (a -\u003e b) -\u003e Par f a -\u003e Par f b\n\ndata Seq f a where\n  Pure :: a -\u003e Seq f a\n  Lift :: f a -\u003e Seq f a\n  Roll :: Seq f a -\u003e (a -\u003e Seq f b) -\u003e Seq f b\n\ndata Concurrent f a where\n  Lift :: f a -\u003e Concurrent f a\n  Seq  :: Seq (Concurrent f) a -\u003e Concurrent f a\n  Par  :: Par (Concurrent f) a -\u003e Concurrent f a\n\ndata Interpreter f g m = Interpreter\n  { runSeq :: Ɐ x. f x -\u003e m x\n  , runPar :: Ɐ x. f x -\u003e g x\n  , seqToPar :: Ɐ x. m x -\u003e g x\n  , parToSeq :: Ɐ x. g x -\u003e m x\n  , Par :: TypeRep g\n  , Seq :: TypeRep m\n  }\n\n```\n\n\n\n### Asymptotic complexity\n\nOn all structures, complexity of:\n- `chain`, `ap` and `map` is **constant**\n- `fold`, `hoist`, `retract` and `graft` is **linear**\n\n### Concurrent\n\nImplements [Functor][], [Applicative][], [ChainRec][] and [Monad][] specifications.\n\nIt holds `Par`allel or `Seq`uential computations which are itself holding Concurrent computations. When operating on Concurrent structures it's behaving as Sequential. but in cases you want Parallel behaviour you can call `.par()` on it and it will return `Par` object which is only Applicative. then you can move back to `Concurrent` using `Concurrent.fromPar`.\n\n\n#### Functor, Applicative, ChainRec and Monad functions:\n\n- Concurrent.prototype.`map :: Concurrent f a ~\u003e (a -\u003e b) -\u003e Concurrent f b`\n- Concurrent.prototype.`ap :: Concurrent f a ~\u003e Concurrent f (a -\u003e b) -\u003e Concurrent f b`\n- Concurrent.prototype.`chain :: Concurrent f a ~\u003e (a -\u003e Concurrent f b) -\u003e Concurrent f b`\n- Concurrent.`chainRec :: ((a -\u003e c, b -\u003e c, a) -\u003e Concurrent f c, a) -\u003e Concurrent f b`\n- Concurrent.`of :: a -\u003e Concurrent f a`\n\n#### other functions:\n\n- Concurrent.`lift :: f a -\u003e Concurrent f a`\n- Concurrent.`fromSeq :: Seq (Concurrent f) a -\u003e Concurrent f a`\n- Concurrent.`fromPar :: Par (Concurrent f) a -\u003e Concurrent f a`\n- Concurrent.prototype.`seq :: Concurrent f a ~\u003e Seq (Concurrent f) a`\n- Concurrent.prototype.`par :: Concurrent f a ~\u003e Par (Concurrent f) a`\n- Concurrent.prototype.`interpret :: (Monad m, ChainRec m, Applicative g) =\u003e Concurrent f a ~\u003e Interpreter f g m -\u003e m a`\n- Concurrent.prototype.`fold :: (Monad m, ChainRec m) =\u003e Concurrent f a ~\u003e (Ɐ x. f x -\u003e m x, TypeRep m) -\u003e m a`\n- Concurrent.prototype.`hoist :: Concurrent f a ~\u003e (Ɐ x. f x -\u003e g x) -\u003e Concurrent g a`\n- Concurrent.prototype.`retract :: (Monad m, ChainRec m) =\u003e Concurrent m a ~\u003e TypeRep m -\u003e m a`\n- Concurrent.prototype.`graft :: Concurrent f a ~\u003e (Ɐ x. f x -\u003e Concurrent g x) -\u003e Concurrent g a`\n\n\n\n### Seq\n\nImplements [Functor][], [Applicative][], [ChainRec][] and [Monad][] specifications.\n\n#### Functor, Applicative, ChainRec and Monad functions:\n\n- Seq.prototype.`map :: Seq f a ~\u003e (a -\u003e b) -\u003e Seq f b`\n- Seq.prototype.`ap :: Seq f a ~\u003e Seq f (a -\u003e b) -\u003e Seq f b`\n- Seq.prototype.`chain :: Seq f a ~\u003e (a -\u003e Seq f b) -\u003e Seq f b`\n- Seq.`chainRec :: ((a -\u003e c, b -\u003e c, a) -\u003e Seq f c, a) -\u003e Seq f b`\n- Seq.`of :: a -\u003e Seq f a`\n\n#### other functions:\n\n- Seq.`lift :: f a -\u003e Seq f a`\n- Seq.prototype.`foldSeq :: (Monad m, ChainRec m) =\u003e Seq f a ~\u003e (Ɐ x. f x -\u003e m x, TypeRep m) -\u003e m a`\n- Seq.prototype.`hoistSeq :: Seq f a ~\u003e (Ɐ x. f x -\u003e g x) -\u003e Seq g a`\n- Seq.prototype.`retractSeq :: (Monad m, ChainRec m) =\u003e Seq m a ~\u003e TypeRep m -\u003e m a`\n- Seq.prototype.`graftSeq :: Seq f a ~\u003e (Ɐ x. f x -\u003e Seq g x) -\u003e Seq g a`\n\n\n\n### Par\n\nImplements [Functor][] and [Applicative][] specifications.\n\n#### Functor, Applicative, ChainRec and Monad functions:\n\n- Par.prototype.`map :: Par f a ~\u003e (a -\u003e b) -\u003e Par f b`\n- Par.prototype.`ap :: Par f a ~\u003e Par f (a -\u003e b) -\u003e Par f b`\n- Par.`of :: a -\u003e Par f a`\n\n#### other functions:\n\n- Par.`lift :: f a -\u003e Par f a`\n- Par.prototype.`foldPar :: (Applicative g) =\u003e Par f a ~\u003e (Ɐ x. f x -\u003e g x, TypeRep g) -\u003e g a`\n- Par.prototype.`hoistPar :: Par f a ~\u003e (Ɐ x. f x -\u003e g x) -\u003e Par g a`\n- Par.prototype.`retractPar :: (Applicative f) =\u003e Par f a ~\u003e TypeRep f -\u003e f a`\n- Par.prototype.`graftPar :: Par f a ~\u003e (Ɐ x. f x -\u003e Par g x) -\u003e Par g a`\n\n\n\n### graft, hoist, retract and fold relations:\n\n\u003e same for graftPar, graftSeq ... variations\n\n- `a.graft(f) ≡ a.fold(f, a.constructor)`\n- `a.hoist(f) ≡ a.fold(compose(a.constructor.lift, f), a.constructor)`\n- `a.retract(M) ≡ a.fold(id, M)`\n- `a.fold(f, M) ≡ compose(a.retract(M), a.hoist(f))`\n\n---\n\nThis initial version of this module was based on a bit older version of [srijs/haskell-free-concurrent][haskell-free-concurrent-old], but it was not lawful, and from v2 it's based on more resent lawful [version][haskell-free-concurrent-resent].\n\n\n[Functor]: https://github.com/fantasyland/fantasy-land#functor\n[Applicative]: https://github.com/fantasyland/fantasy-land#applicative\n[ChainRec]: https://github.com/fantasyland/fantasy-land#chainrec\n[Monad]: https://github.com/fantasyland/fantasy-land#monad\n\n[build-image]: https://img.shields.io/travis/safareli/free/master.svg\n[build]: https://travis-ci.org/safareli/free\n\n[version-image]: https://img.shields.io/npm/v/@safareli/free.svg\n[version]: https://www.npmjs.com/package/@safareli/free\n\n[coverage-image]: https://img.shields.io/codecov/c/github/safareli/free/master.svg\n[coverage]: https://codecov.io/gh/safareli/free/branch/master\n\n[climate-image]: https://img.shields.io/codeclimate/github/safareli/free.svg\n[climate]: https://codeclimate.com/github/safareli/free\n\n[license-image]: https://img.shields.io/github/license/safareli/free.svg\n[license]: https://github.com/safareli/free/blob/master/LICENSE\n\n[haskell-free-concurrent-old]: https://github.com/srijs/haskell-free-concurrent/blob/1a56280e8d63e037cf8f9e57aa17ac6a8ac817a5/src/Control/Concurrent/Free.hs\n\n[haskell-free-concurrent-resent]: https://github.com/srijs/haskell-free-concurrent/blob/1a56280e8d63e037cf8f9e57aa17ac6a8ac817a5/src/Control/Concurrent/Free.hs\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsafareli%2Ffree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsafareli%2Ffree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsafareli%2Ffree/lists"}