Meta tags:
Headings (most frequently used words):
polysemy, and, tl, dr, higher, order, low, boilerplate, free, monads, modules, downloads, readme, for, overview, features, tutorials, resources, examples, friendly, error, messages, necessary, language, extensions, building, with, nix, what, about, performance, acknowledgements, citations, related, work, maintainer, corner,
Text of the page (most frequently used words):
#polysemy (87), the (35), and (30), internal (17), effects (16), nix (15), for (13), effect (13), with (13), package (13), this (12), that (11), writetty (11), implementation (10), but (10), your (10), input (10), teletype (10), performance (9), you (9), library (9), import (9), sem (9), string (9), cabal (8), use (8), mtl (7), ghc (7), about (7), order (7), language (7), plugin (7), all (6), what (6), main (6), readme (6), shell (6), build (6), resource (6), case (6), output (6), echo (6), boilerplate (6), other (5), more (5), work (5), libraries (5), features (5), will (5), some (5), details (5), type (5), higher (5), can (5), code (5), like (5), pure (5), dependencies (5), interpret (5), error (5), customexception (5), readtty (5), embed (5), https (5), github (5), com (5), freer (4), free (4), monads (4), even (4), sandy (4), maguire (4), new (4), problem (4), first (4), are (4), run (4), from (4), program (4), bracket (4), teletypetoio (4), msg (4), low (4), research (4), hackage (3), contributors (3), simple (3), list (3), have (3), may (3), talk (3), should (3), maybe (3), specific (3), one (3), while (3), just (3), develop (3), flake (3), version (3), extensions (3), datakinds (3), flexiblecontexts (3), gadts (3), lambdacase (3), polykinds (3), typeoperators (3), file (3), yaml (3), runteletypepure (3), our (3), echopure (3), has (3), source (3), description (3), tek (3), alexis (2), king (2), fused (2), nicolas (2), tom (2), schrijvers (2), handlers (2), oleg (2), kiselyov (2), extensible (2), monad (2), following (2), had (2), basically (2), current (2), including (2), got (2), wrong (2), allow (2), probably (2), require (2), breaking (2), changes (2), see (2), proposal (2), how (2), comes (2), resolve (2), issues (2), make (2), same (2), problems (2), proposed (2), not (2), compared (2), much (2), out (2), zero (2), cost (2), factor (2), very (2), abstraction (2), though (2), these (2), doing (2), small (2), don (2), systems (2), being (2), visible (2), versions (2), their (2), haddock (2), haskell (2), start (2), unagi (2), chan (2), building (2), default (2), options (2), scopedtypevariables (2), typeapplications (2), into (2), necessary (2), interpreth (2), helpful (2), runresource (2), combinators (2), back (2), well (2), messages (2), friendly (2), templatehaskell (2), blockarguments (2), data (2), thisexception (2), thatexception (2), show (2), where (2), throw (2), member (2), each (2), pureoutput (2), gave (2), author (2), wrote (2), transformers (2), meaning (2), pattern (2), class (2), section (2), fplugin (2), turn (2), errors (2), less (2), uploaded (2), user (2), status (2), rating (2), downloads (2), revised (2), maintainer (2), async (2), maintainers (2), revisions (2), browse (2), writer (2), scoped (2), nondet (2), index (2), fixpoint (2), customerrors (2), bundle (2), fail (2), produced, rob, rix, patrick, thomson, andy, gill, fusion, efficient, algebraic, ralf, hinze, scope, hiromi, ishii, amr, sabry, cameron, swords, alternative, transfomers, non, exhaustive, people, works, significant, impact, directly, indirectly, design, acknowledgements, citations, related, there, ongoing, extending, creation, stable, strong, choose, point, few, interested, adds, needed, followup, relates, when, once, lands, consider, option, switching, based, easier, luckily, person, uncovered, set, primops, interpretation, runtime, minimal, overhead, hoped, negligible, real, life, solutions, predictable, behaviour, try, experimental, uses, here, solution, optimizer, good, general, optimizing, sorts, relatively, complex, hard, predict, authors, deemed, location, relevant, big, end, tell, ourselves, many, used, production, they, fine, because, maximum, usually, matters, controlled, areas, often, doesn, matter, why, did, nobody, notice, interesting, ended, bitten, variation, way, another, resulting, equivalent, without, drop, popular, isn, previous, mentioned, having, was, original, motivation, turned, showing, amazing, results, benchmarks, greatly, limits, usefulness, bigger, multi, module, programs, depend, optimizations, enter, server, wrapper, hls, ide, ghcid, command, environment, repl, inspect, dependency, project, provides, basic, config, development, defined, backwards, compatibility, stubs, flate, specialise, fspecialise, aggressively, rankntypes, typefamilies, going, want, stick, help, only, fix, instead, expression, makes, suggestion, forall, example, exposes, both, aren, known, ease, shoes, takes, serious, stance, providing, easy, using, above, deriving, members, catch, caught, const, exiting, entering, explode, weird, stuff, exceptions, either, runfinal, embedtofinal, resourcetoiofinal, errortoiofinal, makesem, getline, putstrln, consume, appending, runoutputmonoid, treat, element, strings, line, runinputlist, reinterpret, terms, reinterpret2, let, pretend, flip, fst, forever, runm, sure, read, before, trying, yourself, examples, also, written, blog, posts, paweł, szulc, thinking, great, post, style, porting, raghu, kaippully, beginner, tutorial, tutorials, resources, create, single, digit, number, lines, interpreters, nothing, functions, matching, trivial, write, local, adding, options_ghc, concerned, inference, its, companion, which, helps, perform, add, then, pragma, files, additionally, unlike, functional, multiple, copies, alleviates, need, band, aids, nicely, solves, trouble, typed, readert, classy, lenses, ugly, hacks, magnitude, powerful, composes, better, requires, avoids, instances, writing, high, power, domain, languages, allows, separate, business, logic, lets, reusable, overview, docs, unknown, reports, yet, votes, estimated, bayesian, average, 21602, total, 130, last, days, direct, indirect, reverse, arch, ltshaskell, stackage, distributions, head, git, clone, repo, bug, tracker, home, page, category, made, 2025, 15t12, 23z, revision, 2024, 03t19, 17z, funprog, zulipchat, narrow, stream, 216942, 2019, 2023, lounge, copyright, bsd, clause, license, unsupported, template, syb, stm, families, containers, base, changelog, change, log, info, rss, candidates, edit, information, trustees, kingofthehomeless, thematten, isovector, corner, note, newer, than, included, tarball, unpack, get, metadata, tar, trace, tagged, state, reader, opaque, membership, union, tactics, common, strategy, sing, kind, redefined, final, atomicstate, quick, jump, modules, skip, please, report, vulnerability, propose, tags, bsd3, accounts, upload, search,
Text of the page (random words):
polysemy higher order low boilerplate free monads hackage package search browse what s new upload user accounts polysemy higher order low boilerplate free monads bsd3 language library propose tags report a vulnerability please see the readme on github at https github com polysemy research polysemy readme skip to readme modules index quick jump polysemy polysemy async polysemy atomicstate polysemy bundle polysemy embed polysemy embed type polysemy error polysemy fail polysemy fail type polysemy final polysemy fixpoint polysemy io polysemy input polysemy internal polysemy internal bundle polysemy internal combinators polysemy internal customerrors polysemy internal customerrors redefined polysemy internal fixpoint polysemy internal index polysemy internal kind polysemy internal nondet polysemy internal scoped polysemy internal sing polysemy internal strategy th polysemy internal th common polysemy internal th effect polysemy internal tactics polysemy internal union polysemy internal writer polysemy membership polysemy nondet polysemy opaque polysemy output polysemy reader polysemy resource polysemy scoped polysemy state polysemy tagged polysemy trace polysemy writer downloads polysemy 1 9 2 0 tar gz browse cabal source package package description revised from the package note this package has metadata revisions in the cabal description newer than included in the tarball to unpack the package including the revisions use cabal get maintainer s corner package maintainers isovector tek thematten kingofthehomeless for package maintainers and hackage trustees edit package information candidates 1 3 0 0 1 6 0 0 versions rss 0 1 0 0 0 1 1 0 0 1 2 0 0 1 2 1 0 2 0 0 0 2 1 0 0 2 2 0 0 3 0 0 0 3 0 1 0 4 0 0 0 5 0 0 0 5 0 1 0 5 1 0 0 6 0 0 0 7 0 0 1 0 0 0 1 1 0 0 1 2 0 0 1 2 1 0 1 2 2 0 1 2 3 0 1 3 0 0 1 4 0 0 1 5 0 0 1 6 0 0 1 7 0 0 1 7 1 0 1 8 0 0 1 9 0 0 1 9 1 0 1 9 1 1 1 9 1 2 1 9 1 3 1 9 2 0 info change log changelog md dependencies async 2 2 3 base 4 9 5 containers 0 5 0 8 first class families 0 5 0 0 0 9 mtl 2 2 2 3 stm 2 3 syb 0 7 0 8 template haskell 2 12 0 0 3 th abstraction 0 3 1 0 0 8 transformers 0 5 2 0 0 7 type errors 0 2 0 0 unagi chan 0 4 0 0 0 5 unsupported ghc version 0 details license bsd 3 clause copyright 2019 2023 the polysemy lounge author sandy maguire maintainer https funprog zulipchat com narrow stream 216942 polysemy uploaded by tek at 2024 06 03t19 01 17z revised revision 5 made by tek at 2025 03 15t12 16 23z category language home page https github com polysemy research polysemy readme bug tracker https github com polysemy research polysemy issues source repo head git clone https github com polysemy research polysemy distributions arch 1 9 2 0 ltshaskell 1 9 2 0 stackage 1 9 2 0 reverse dependencies 79 direct 4 indirect details downloads 21602 total 130 in the last 30 days rating 2 75 votes 9 estimated by bayesian average your rating λ λ λ status docs uploaded by user build status unknown no reports yet readme for polysemy 1 9 2 0 back to package description polysemy overview polysemy is a library for writing high power low boilerplate domain specific languages it allows you to separate your business logic from your implementation details and in doing so polysemy lets you turn your implementation code into reusable library code it s like mtl but composes better requires less boilerplate and avoids the o n 2 instances problem it s like freer simple but more powerful it s like fused effects but with an order of magnitude less boilerplate additionally unlike mtl polysemy has no functional dependencies so you can use multiple copies of the same effect this alleviates the need for ugly hacks band aids like classy lenses the readert pattern and nicely solves the trouble with typed errors concerned about type inference polysemy comes with its companion polysemy plugin which helps it perform just as well as mtl s add polysemy plugin to your package yaml or cabal file s dependencies section to use then turn it on with a pragma in your source files options_ghc fplugin polysemy plugin or by adding fplugin polysemy plugin to your package yaml cabal file ghc options section features effects are higher order meaning it s trivial to write bracket and local as first class effects effects are low boilerplate meaning you can create new effects in a single digit number of lines new interpreters are nothing but functions and pattern matching tutorials and resources raghu kaippully wrote a beginner friendly tutorial sandy maguire the author wrote a post about porting to polysemy from transformers mtl style monads paweł szulc gave a great talk on how to start thinking about polysemy sandy maguire gave a talk on some of the performance implementation he has also written some blog posts on other implementation details examples make sure you read the necessary language extensions before trying these yourself teletype effect language templatehaskell lambdacase blockarguments gadts flexiblecontexts typeoperators datakinds polykinds scopedtypevariables import polysemy import polysemy input import polysemy output data teletype m a where readtty teletype m string writetty string teletype m makesem teletype teletypetoio member embed io r sem teletype r a sem r a teletypetoio interpret case readtty embed getline writetty msg embed putstrln msg runteletypepure string sem teletype r a sem r string a runteletypepure i for each writetty in our program consume an output by appending it to the list in a string a runoutputmonoid pure treat each element of our list of strings as a line of input runinputlist i reinterpret our effect in terms of input and output reinterpret2 case readtty maybe id input writetty msg output msg echo member teletype r sem r echo do i readtty case i of pure _ writetty i echo let s pretend echopure string sem string echopure flip runteletypepure echo pureoutput string string pureoutput fst run echopure echo forever main io main runm teletypetoio echo resource effect language templatehaskell lambdacase blockarguments gadts flexiblecontexts typeoperators datakinds polykinds typeapplications import polysemy import polysemy input import polysemy output import polysemy error import polysemy resource using teletype effect from above data customexception thisexception thatexception deriving show program members resource teletype error customexception r sem r program catch customexception work e writetty caught show e where work bracket readtty const writetty exiting bracket input do writetty entering bracket case input of explode throw thisexception weird stuff writetty input throw thatexception _ writetty input writetty no exceptions main io either customexception main runfinal embedtofinal io resourcetoiofinal errortoiofinal customexception teletypetoio program easy friendly error messages free monad libraries aren t well known for their ease of use but following in the shoes of freer simple polysemy takes a serious stance on providing helpful error messages for example the library exposes both the interpret and interpreth combinators if you use the wrong one the library s got your back runresource forall r a sem resource r a sem r a runresource interpret case makes the helpful suggestion resource is higher order but interpret can help only with first order effects fix use interpreth instead in the expression interpret case necessary language extensions you re going to want to stick all of this into your package yaml file ghc options o2 flate specialise fspecialise aggressively default extensions datakinds flexiblecontexts gadts lambdacase polykinds rankntypes scopedtypevariables typeapplications typeoperators typefamilies building with nix the project provides a basic nix config for building in development it is defined as a flake with backwards compatibility stubs in default nix and shell nix to build the main library or plugin nix build a polysemy nix build a polysemy plugin flake version nix build nix build polysemy plugin to inspect a dependency nix repl p import p unagi chan to run a shell command with all dependencies in the environment nix shell pure nix shell pure run cabal v2 haddock polysemy nix shell pure run ghcid flake version nix develop i just enter a shell nix develop i c cabal v2 haddock polysemy nix develop i c haskell language server wrapper start hls for your ide what about performance tl dr previous versions of this readme mentioned the library being zero cost as in having no visible effect on performance while this was the original motivation and main factor in implementation of this library it turned out that optimizations we depend on while showing amazing results in small benchmarks don t work in bigger multi module programs what greatly limits their usefulness what s more interesting though is that this isn t a polysemy specific problem basically all popular effects libraries ended up being bitten by variation of this problem in one way or another resulting in visible drop in performance compared to equivalent code without use of effect systems why did nobody notice this one factor may be that while ghc s optimizer is very very good in general in optimizing all sorts of abstraction it s relatively complex and hard to predict authors of libraries may have not deemed location of code relevant even though it had big effect at the end the other is that maybe it doesn t matter as much as we like to tell ourselves many of these effects libraries are used in production and they re doing just fine because maximum performance usually matters in small controlled areas of code that often don t use features of effect systems at all what can we do about this luckily the same person that uncovered this problems proposed a solution set of primops that will allow interpretation of effects at runtime with minimal overhead it s not zero cost as we hoped for with polysemy at first but it should have negligible effect on performance in real life and compared to current solutions it should be much more predictable and even resolve some problems with behaviour of specific effects you can try out experimental library that uses proposed features here when it comes to polysemy once ghc proposal lands we will consider the option of switching to an implementation based on it this will probably require some breaking changes but should resolve performance issues and maybe even make implementation of higher order effects easier if you re interested in more details see alexis king s talk about the problem sandy maguire s followup about how it relates to polysemy and ghc proposal that adds features needed for new type of implementation tl dr basically all current effects libraries including polysemy and even mtl got performance wrong but there s ongoing work on extending ghc with features that will allow for creation of effects implementation with stable and strong performance it s what polysemy may choose at some point but it will probably require few breaking changes acknowledgements citations and related work the following is a non exhaustive list of people and works that have had a significant impact directly or indirectly on polysemy s design and implementation oleg kiselyov amr sabry and cameron swords extensible effects an alternative to monad transfomers oleg kiselyov and hiromi ishii freer monads more extensible effects nicolas wu tom schrijvers and ralf hinze effect handlers in scope nicolas wu and tom schrijvers fusion for free efficient algebraic effect handlers andy gill and other contributors mtl rob rix patrick thomson and other contributors fused effects alexis king and other contributors freer simple produced by hackage and cabal 3 16 1 0
|