Commit Graph

72 Commits

Author SHA1 Message Date
KingoftheHomeless
1ff567c1aa Fix scoped within scoped incoherency. Add runScopedNew (#466) 2022-12-28 16:21:33 +01:00
Torsten Schmits
2d88b937dd fix scoped interpreters automatically recursively interpreting 2022-12-28 16:21:33 +01:00
Torsten Schmits
1b6ae7b18b
Scoped without resource param (#462) 2022-10-16 23:12:00 +02:00
Xy Ren
8450bff3d8 Prevent errorToIOFinal from mixing errors up (#444) 2022-01-23 20:41:35 +01:00
Sandy Maguire
6ece463ea8
Remove lowering functions and forklift (#438)
* Remove forklift

* Remove lowerResource

* Changelog

* changelog

* Remove (@)

* Update documentation

* Remove the ancient benchmarks

* Remove fixpoint lowerings
2021-12-01 09:59:18 -08:00
Sandy Maguire
3f965b7947
Remove View (#439) 2021-11-29 09:30:38 -08:00
Sandy Maguire
5e638ebfb0
Remove Polysemy.Law (#437)
* Remove Polysemy.Law

* Beter changelog
2021-11-28 13:07:48 -08:00
Sandy Maguire
55150644c4
Remove custom type errors from Member (#429)
* Remove Member type errors

* Remove unused custom type errors

* Deprecate MemberWithError

* Remove readme notes about type errors

* Remove MemberWithError
2021-11-16 15:01:45 -08:00
Torsten Schmits
2ddc66bc78 release 1.6.0.0 2021-07-12 13:33:42 +02:00
Torsten Schmits
e25d1207d1 fix doctests on 9.0.1
Error messages changed, adapted to match both variants
2021-06-25 19:51:34 +02:00
KingoftheHomeless
478c86e080
Simple variants of runT and bindT (#393)
* Simple variants of runT and bindT

* Fix accidental removal of INLINE on reinterpretH

* Rename bindTH and runTH to -Simple instead. Improve docs on these.

* Update changelog and add @since TODOs
2020-11-18 20:46:14 +01:00
Jeremy Schlatter
235813da00
Small code simplifications (#360)
* Small code simplifications

These are all replacements of the form

    before: fmap f $ x
    after:  f <$> x

Minor change, but feels marginally easier to read to me.

Co-authored-by: TheMatten <matten@tuta.io>
2020-07-29 17:20:11 +02:00
KingoftheHomeless
8d49b677fc
Add lazy interpretations for Output and Writer (#311)
* Add lazy interpretations for Output and Writer

* INLINE the helper function of interpretViaLazyWriter

* Added strictness tests for runLazyWriter
2020-02-13 21:20:24 +01:00
KingoftheHomeless
a4868bddd4
Membership proof rewrite, membership testing, Bundle effect (#282)
* Union rewrite

* Exports, tests, and renamed KnownEffectRow

* Got rid of artifacts accidently introduced

* More documentation. tryMembership seperate from KnownRow

* 'expose' combinator

* Applied review suggestions, add Membership module

* Fixed a replace-all goof

* Scrap expose/Using in favor of interceptUsing/H

* Fixed Haddock failure
2019-12-08 13:52:37 +01:00
Sandy Maguire
5aa84c8757
Disable loopbreaker (#274)
* Disable loopbreaker

* "Fix" Fusion

* whoops
2019-11-01 22:11:57 +01:00
KingoftheHomeless
93f8054e05
Revert functorial state of runNonDet to [] (#273)
* Revert functorial state of runNonDet to []

* Added a shouldNotBe
2019-11-01 21:20:32 +01:00
Sandy Maguire
4cce80c043
Law Machinery (#269)
This PR adds machinery for writing easy laws that should hold for an effect. It gives an example of what they'd look like for State s.
2019-11-01 19:57:53 +01:00
Sandy Maguire
25874923b9
View effect (#271)
* Add Tagged Effect

* Add View effect
2019-11-01 19:30:30 +01:00
Sandy Maguire
10ecd396cd
Add fromException and fromExceptionVia (#270) 2019-11-01 17:54:54 +01:00
Samuel Evans-Powell
95b4b5508c Feature/cabal doctest and ghc 8.8.1 (#267)
* Use cabal-doctest

- Haskell build tools run in slightly different environments (meaning different
  package databases are available).
- The nixpkgs build for polysemy-plugin is failing due to a missing package
  database, which causes the doctest to fail (more information here:
  https://github.com/NixOS/nixpkgs/issues/71164).
- By using cabal-doctest we can expose the Haskell packages required to the
  doctests no matter the build tool we're using.

* Use cabal-doctest in polysemy, build on GHC 8.8.1

- Use @googleson78 's changes to build polysemy on GHC 8.8.1, with slight
  modifications. The source distribution is now found in "dist-newstyle/sdist",
  so we've updated the command to point at that folder. Additionally, cabal
  v2-install doesn't support installing .tar.gz files in the same way v1-install
  did, so updated the command to use "cabal v1-install".
- Modified polysemy to use "cabal-doctest" and so overcome issues with the
  doctest tests (see issue #258, PR #265).
2019-10-28 17:13:44 +01:00
Sandy Maguire
b00d451d1e Ensure IO Resource interpreters handle Sem failure
The IO Resource interpreters had a bug in `BracketOnError` that would
fail to run the finalizers if the error was a Sem error (as opposed to
an IO exception.)

This PR also reworks the bracket spec so that it runs each test for
every interpreter, hopefully keeping them all in sync in the future.

Fixes #262
2019-10-22 19:35:22 +02:00
KingoftheHomeless
4a5f2ce92a
Add Final Effect (#217)
* Add Final Effect

* Changes per review, Final at top-level, doc changes

* Update Changelog

* Final touches to Final

* Revert change to stack.yaml
2019-08-30 22:38:53 +02:00
KingoftheHomeless
d7d3d4bb4f Add AtomicState and atomic interpreters for Output/Writer (#206)
* Add AtomicState and atomic interpreters for Output/Writer

* Fixed a word in docs, moved test functions around

* Remove runWriterIORef and runWriterTVar
2019-08-15 14:23:06 -07:00
KingoftheHomeless
26a6d2e474 Add Fail effect (#199)
* Add Fail effect

* Add inlining to Fail interpreters, make Fail newtype

* Hide visibility of Polysemy.Fixpoint.bomb, fix changelog

* Revert "Hide visibility of Polysemy.Fixpoint.bomb, fix changelog"

This reverts commit 5b043ed215.

* Move Polysemy.Internal.Fail to Polysemy.Fail.Type. Fixed inconsistency in docs
2019-08-06 09:07:54 -04:00
KingoftheHomeless
829e3202fc Have AsyncSpec use locks instead of sleeps (#197) 2019-08-02 20:18:48 -04:00
KingoftheHomeless
5930ddf138 Fix strictness semantics of State and Writer (#194)
* Fix strictness semantics of State and Writer

* Made tests more rigorous

* Fixed inconsistency between Writer/Output tests

* Add more tests to cover the discrepancy between run and runM

* Use strict fmap to be on the safe side
2019-07-31 08:49:36 -04:00
KingoftheHomeless
4dc09e719b Improve semantics of Fixpoint (#187)
* Improve semantics of Fixpoint

* Add tests for Fixpoint, update docs

* Made the error test more rigorous

* Added references in the docs for 'runFixpoint'
2019-07-27 16:11:11 -04:00
TheMatten
d803c81054 Document change in semantics based on order of interpreters (#181)
* Polysemy.Internal: document change in semantics based on order of interpreters

* Polysemy.Internal: use new 'evalState' instead of mapping 'runState' in example

* Polysemy.Internal, DoctestSpec: properly support doctest

* Polysemy.Internal: small corrections
2019-07-24 09:50:56 -04:00
Sandy Maguire
de1607ea1b
Rename everything and its grandmother (#175) 2019-07-15 12:40:42 -04:00
KingoftheHomeless
d12adcd780 Make NonDet Higher-Order (#174)
* Higher-Order NonDet and runNonDetMaybe

* Fixed docs

* Fixed a word in AlternativeSpec docs

* Fixed tests and wrong documentation
2019-07-15 11:53:18 -04:00
Georgi Lyubenov
48b6768ad4 Rename Lift to Embed (#161)
* Move Polysemy.Internal.Lift to Polysemy.Lift.Type

* Add Polysemy.Lift module and runLift interpreter

* Add a Sandy reminder

* Add explicit foralls and split type signature

* Fix import spacing, for there is no "qualified"

* Implement runIO in terms of runLift

* Rename Lift -> Embed

* Replace sendM with embed

* Add a Sandy todo for embed version

* Rename runEmbed and related runEmbedded (from IO)

* runEmbedded -> runEmbeddedInIO
* runEmbed -> runEmbedded

* Update cabal
2019-07-11 11:02:26 -04:00
TheMatten
3e1f100341 Reenable data families and their tests 2019-07-09 07:43:07 +02:00
TheMatten
766ac0935d Remove data families tests completely 2019-07-08 22:35:23 +02:00
TheMatten
ec03b04e8e Fix ambiguously looking variables in smart constructors, refactor Polysemy.Internal.TH.Common 2019-07-08 21:52:29 +02:00
KingoftheHomeless
0d22cdaba0 Add Pass to Writer, replacing Censor. Fix semantics of listen (#169)
* Added Pass to Writer, replacing Censor. Fixed semantics of listen

* Swap order of elements in the Pass tuple

* Sometimes I'm bad! Fixed compile error.
2019-07-08 09:59:33 -04:00
Sandy Maguire
faaf1e3a96
Don't use Loopbreaker until GHC 8.7+ (#164)
Turns out haddocks have been broken forever, but because of haskell/cabal#5977 we never noticed. This PR fixes CI so it breaks (see 6f915b6), and then fixes it by changing the GHC versions under which we're allowed to use loopbreaker. Fixes #160
2019-07-07 11:27:18 -04:00
Sandy Maguire
9f3a476afd
Rename Yo ==> Weaving (#162)
The name Yo is objectively terrible. I changed it, and added some documentation.
2019-07-06 09:16:07 -04:00
Silvan Mosberger
210d8d6a35 Improve runBatchOutput (#158)
This function now transforms an Output o into Output [o], which only outputs elements once the specified number of o's have been collected. The only exception is the last element which contains the rest (if any).
2019-07-04 18:27:13 -04:00
Sandy Maguire
ef5ff1749a
Don't emit ambiguous effect errors for genuine type errors (#149)
This PR changes the plugin so it will notice an insoluble constraint of the form Sem r a ~ Foo, and mark that r takes part in a genuine type error. The plugin will then provide a bogus evidence term for IfStuck (IndexOf r _) _ _, which prevents the AmbiguousSend error message from firing.
2019-07-04 09:35:33 -04:00
Sandy Maguire
72e060ac79
Parenthesize r when it's a cons (#147)
When emitting messages for ambiguous sends: use `IfStuck` on `r` to
determine if we can compose it. This means `r` is in one of three
states, stuck, cons or nil. We want to wrap it in parentheses iff it's
a cons.
2019-07-04 07:45:09 -04:00
Sandy Maguire
482de98afe
Use type-errors for our type errors! (#144)
This PR has farmed out the type error machinery out to my new package https://github.com/isovector/type-errors. It's much nicer to work with, and a big red diff!
2019-07-03 16:05:51 -04:00
Sandy Maguire
d82d48cdf6
Improved errors (#143)
This shuffles around the error messages so they are only connected to code generated via makeSem. This means that badly-typed interpreters will no longer set off the eager error messages!
2019-06-29 23:37:56 -04:00
Georgi Lyubenov
5bc01e0af6 Add runOutputAsList and a test for it (#140)
* Add runOutputAsList and a test for it

* Also use runOutputAsList in runTraceAsList
2019-06-29 17:40:56 -04:00
Sandy Maguire
e4b711a1ed
Fix intercept not hoisting itself into embedded computations (#134)
Fixes #133
2019-06-27 00:35:52 -04:00
Sandy Maguire
33a6d95dab
runResource via forklift (#130)
This PR adds `runResourceBase` (which is a crap name, but naming things is hard), which interprets `Resource` without the ugly `Sem r ~> IO` parameter. It's a nice solution to #84!
2019-06-26 00:08:55 -04:00
Sandy Maguire
8f3a4bcf19
Async effect (#129)
Here's an Async effect that does exactly what you'd expect.

Fixes #80
2019-06-26 00:01:12 -04:00
Sandy Maguire
29216ceb69
Improve CI coverage -- now on GHC 8.4! (#39) 2019-06-19 17:25:37 -04:00
Sandy Maguire
c3d3cc24f8
Stop using stack in Travis (#121)
The travis cache appears to be broken (probably due to the nightly stack?), but it just means CI takes like half an hour now. Since I already build on stack, I'm pretty sure it's fine --- also this will give a sanity check against accidentally breaking cabal build plans.

This improves CI times from ~30 minutes down to ~2.
2019-06-18 12:36:38 -04:00
Sandy Maguire
6ffb4fd282
Remove Effect class (#118)
This thing was a vestige of the bad old days when you had to write
*instances* of classes things in Polysemy. It was a terrible experience,
and so we don't do that anymore. As a result, the only two instances of
`Effect` were for `Union` and `Yo` --- so I just inlined them.
2019-06-17 15:16:28 -04:00
Sandy Maguire
bba49aaeb8
Don't emit the FirstOrder error for unknown effects (#115)
This PR introduces the FCF machinery that will give us more control over writing type-level functions. It defines an IfStuck a b c tyfam that will leave b around if a is stuck, otherwise it will fcf-evaluate c. Everything is polykinded so we can stack these things together to make big logic chains to emit specific variables depending on what exactly is stuck.
2019-06-16 17:14:36 -04:00