{"id":17252111,"url":"https://github.com/ppetr/freer","last_synced_at":"2025-03-26T07:23:12.725Z","repository":{"id":146160462,"uuid":"48904792","full_name":"ppetr/freer","owner":"ppetr","description":"An implementation of \"Freer Monads, More Extensible Effects\"","archived":false,"fork":false,"pushed_at":"2016-01-02T09:22:43.000Z","size":50,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-31T08:44:26.075Z","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":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ppetr.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-02T09:22:05.000Z","updated_at":"2019-12-05T06:34:28.000Z","dependencies_parsed_at":"2023-04-17T11:38:03.163Z","dependency_job_id":null,"html_url":"https://github.com/ppetr/freer","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/ppetr%2Ffreer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppetr%2Ffreer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppetr%2Ffreer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppetr%2Ffreer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ppetr","download_url":"https://codeload.github.com/ppetr/freer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245606548,"owners_count":20643199,"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:53:03.697Z","updated_at":"2025-03-26T07:23:12.700Z","avatar_url":"https://github.com/ppetr.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Freer: Extensible Effects with Freer Monads\n\nFreer is an implementation of\n[\"Freer Monads, More Extensible Effects\"](http://okmij.org/ftp/Haskell/extensible/more.pdf). Much\nof the implementation is a repackaging and cleaning up of the\nreference materials provided\n[here](http://okmij.org/ftp/Haskell/extensible/).\n\n# Features\n\nThe key features of Freer are:\n\n* An efficient effect system for Haskell as a library\n* Implementations for several common Haskell monad instances:\n  * Reader\n  * Writer\n  * State\n  * StateRW: State in terms of Reader/Writer\n  * Trace\n  * Exception\n* Core components for defining your own Effects\n\n# Example: Teletype DSL\n\nHere's what using Freer looks like:\n\n```haskell\n{-# LANGUAGE GADTs #-}\n{-# LANGUAGE FlexibleContexts #-}\n{-# LANGUAGE TypeOperators #-}\n{-# LANGUAGE DataKinds #-}\nmodule Teletype where\n\nimport Control.Monad.Freer\nimport Control.Monad.Freer.Internal\nimport System.Exit hiding (ExitSuccess)\n\n--------------------------------------------------------------------------------\n                          -- Effect Model --\n--------------------------------------------------------------------------------\ndata Teletype s where\n  PutStrLn    :: String -\u003e Teletype ()\n  GetLine     :: Teletype String\n  ExitSuccess :: Teletype ()\n\nputStrLn' :: Member Teletype r =\u003e String -\u003e Eff r ()\nputStrLn' = send . PutStrLn\n\ngetLine'  :: Member Teletype r =\u003e Eff r String\ngetLine' = send GetLine\n\nexitSuccess' :: Member Teletype r =\u003e Eff r ()\nexitSuccess' = send ExitSuccess\n\n--------------------------------------------------------------------------------\n                     -- Effectful Interpreter --\n--------------------------------------------------------------------------------\nrunTeletype :: Eff '[Teletype] w -\u003e IO w\nrunTeletype (Val x) = return x\nrunTeletype (E u q) = case decomp u of\n              Right (PutStrLn msg) -\u003e putStrLn msg  \u003e\u003e runTeletype (qApp q ())\n              Right GetLine        -\u003e getLine      \u003e\u003e= \\s -\u003e runTeletype (qApp q s)\n              Right ExitSuccess    -\u003e exitSuccess\n              Left  _              -\u003e error \"This cannot happen\"\n\n--------------------------------------------------------------------------------\n                        -- Pure Interpreter --\n--------------------------------------------------------------------------------\nrunTeletypePure :: [String] -\u003e Eff '[Teletype] w -\u003e [String]\nrunTeletypePure inputs req = reverse (go inputs req [])\n  where go :: [String] -\u003e Eff '[Teletype] w -\u003e [String] -\u003e [String]\n        go _      (Val _) acc = acc\n        go []     _       acc = acc\n        go (x:xs) (E u q) acc = case decomp u of\n          Right (PutStrLn msg) -\u003e go (x:xs) (qApp q ()) (msg:acc)\n          Right GetLine        -\u003e go xs     (qApp q x) acc\n          Right ExitSuccess    -\u003e go xs     (Val ())   acc\n          Left _               -\u003e go xs     (Val ())   acc\n```\n\n# Contributing\n\nContributions are welcome! Documentation, examples, code, and\nfeedback - they all help.\n\nBe sure to review the included code of conduct. This project adheres\nto the [Contributor's Covenant](http://contributor-covenant.org/). By\nparticipating in this project you agree to abide by its terms.\n\n## Developer Setup\n\nThe easiest way to start contributing is to install\n[stack](https://github.com/commercialhaskell/stack). stack can install\nGHC/Haskell for you, and automates common developer tasks.\n\nThe key commands are:\n\n* stack setup : install GHC\n* stack build\n* stack clean\n* stack haddock : builds documentation\n* stack test\n* stack bench\n* stack ghci : start a REPL instance\n\n# Licensing\n\nThis project is distrubted under a BSD3 license. See the included\nLICENSE file for more details.\n\n# Acknowledgements\n\nThis package would not be possible without the paper and the reference\nimplementation. In particular:\n\n* Data.Open.Union maps to [OpenUnion41.hs](http://okmij.org/ftp/Haskell/extensible/OpenUnion41.hs)\n* Data.FTCQueue maps to [FTCQueue1](http://okmij.org/ftp/Haskell/extensible/FTCQueue1.hs)\n* Control.Monad.Freer* maps to [Union1.hs](http://okmij.org/ftp/Haskell/extensible/Eff1.hs)\n\nThere will be deviations from the source.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppetr%2Ffreer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fppetr%2Ffreer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppetr%2Ffreer/lists"}