{"id":13647007,"url":"https://github.com/lexi-lambda/freer-simple","last_synced_at":"2025-04-04T07:05:53.339Z","repository":{"id":27336202,"uuid":"96348279","full_name":"lexi-lambda/freer-simple","owner":"lexi-lambda","description":"A friendly effect system for Haskell","archived":false,"fork":false,"pushed_at":"2024-05-16T14:26:15.000Z","size":283,"stargazers_count":228,"open_issues_count":19,"forks_count":20,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-10-30T04:50:25.357Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://hackage.haskell.org/package/freer-simple","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/lexi-lambda.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-05T18:14:52.000Z","updated_at":"2024-10-29T07:47:08.000Z","dependencies_parsed_at":"2024-11-19T20:50:03.638Z","dependency_job_id":null,"html_url":"https://github.com/lexi-lambda/freer-simple","commit_stats":{"total_commits":206,"total_committers":23,"mean_commits":8.956521739130435,"dds":0.7961165048543689,"last_synced_commit":"5304190c1deae1fa8905144ed79774e90d9c7247"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lexi-lambda%2Ffreer-simple","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lexi-lambda%2Ffreer-simple/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lexi-lambda%2Ffreer-simple/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lexi-lambda%2Ffreer-simple/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lexi-lambda","download_url":"https://codeload.github.com/lexi-lambda/freer-simple/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247135143,"owners_count":20889420,"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-08-02T01:03:18.208Z","updated_at":"2025-04-04T07:05:53.318Z","avatar_url":"https://github.com/lexi-lambda.png","language":"Haskell","readme":"# freer-simple — a friendly effect system for Haskell [![Build Status](https://img.shields.io/github/workflow/status/lexi-lambda/freer-simple/build/master)](https://github.com/lexi-lambda/freer-simple/actions/workflows/build.yml) [![Hackage](https://img.shields.io/badge/hackage-1.2.1.2-5e5184)][hackage]\n\nThe `freer-simple` library is an implementation of an *extensible effect system* for Haskell, a general-purpose way of tracking effects at the type level and handling them in different ways. The concept of an “effect” is very general: it encompasses the things most people consider side-effects, like generating random values, interacting with the file system, and mutating state, but it also includes things like access to an immutable global environment and exception handling.\n\nThe key features of `freer-simple` are:\n\n  - An efficient effect system for Haskell as a library.\n\n  - Implementations for several common Haskell monads as effects, including `Reader`, `Writer`, `State`, `Error`, and others.\n\n  - A combinator language for defining your own effects, designed to make simple, common use cases easy to read and write.\n\n[**For more details, see the package documentation on Hackage.**][hackage]\n\n## Code example\n\n```haskell\n{-# LANGUAGE DataKinds #-}\n{-# LANGUAGE FlexibleContexts #-}\n{-# LANGUAGE GADTs #-}\n{-# LANGUAGE LambdaCase #-}\n{-# LANGUAGE TemplateHaskell #-}\n{-# LANGUAGE TypeOperators #-}\n\nimport qualified Prelude\nimport qualified System.Exit\n\nimport Prelude hiding (putStrLn, getLine)\n\nimport Control.Monad.Freer\nimport Control.Monad.Freer.TH\nimport Control.Monad.Freer.Error\nimport Control.Monad.Freer.State\nimport Control.Monad.Freer.Writer\n\n--------------------------------------------------------------------------------\n                               -- Effect Model --\n--------------------------------------------------------------------------------\ndata Console r where\n  PutStrLn    :: String -\u003e Console ()\n  GetLine     :: Console String\n  ExitSuccess :: Console ()\nmakeEffect ''Console\n\n--------------------------------------------------------------------------------\n                          -- Effectful Interpreter --\n--------------------------------------------------------------------------------\nrunConsole :: Eff '[Console, IO] a -\u003e IO a\nrunConsole = runM . interpretM (\\case\n  PutStrLn msg -\u003e Prelude.putStrLn msg\n  GetLine -\u003e Prelude.getLine\n  ExitSuccess -\u003e System.Exit.exitSuccess)\n\n--------------------------------------------------------------------------------\n                             -- Pure Interpreter --\n--------------------------------------------------------------------------------\nrunConsolePure :: [String] -\u003e Eff '[Console] w -\u003e [String]\nrunConsolePure inputs req = snd . fst $\n    run (runWriter (runState inputs (runError (reinterpret3 go req))))\n  where\n    go :: Console v -\u003e Eff '[Error (), State [String], Writer [String]] v\n    go (PutStrLn msg) = tell [msg]\n    go GetLine = get \u003e\u003e= \\case\n      [] -\u003e error \"not enough lines\"\n      (x:xs) -\u003e put xs \u003e\u003e pure x\n    go ExitSuccess = throwError ()\n```\n\n## Acknowledgements\n\nThe `freer-simple` package began as a fork of [freer-effects](http://hackage.haskell.org/package/freer-effects) by Ixperta Solutions, which in turn is a fork of [freer](http://hackage.haskell.org/package/freer) by Allele Dev. All implementations are based on the [paper and reference implementation by Oleg Kiselyov](http://okmij.org/ftp/Haskell/extensible/more.pdf).\n\n[hackage]: https://hackage.haskell.org/package/freer-simple\n","funding_links":[],"categories":["Haskell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flexi-lambda%2Ffreer-simple","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flexi-lambda%2Ffreer-simple","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flexi-lambda%2Ffreer-simple/lists"}