Commit Graph

494 Commits

Author SHA1 Message Date
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
8bd297fe49 Release polysemy 0.5.1.0 2019-06-28 16:19:33 -04:00
Sandy Maguire
77fd10494a
New error combinators (#138)
Introduction of `fromEither` and `fromEitherM`
2019-06-28 16:18:00 -04:00
Sandy Maguire
162d0cdf5b World's Better Logo 2019-06-27 02:51:36 -04:00
Sandy Maguire
01df83c6b7 Merge branch 'master' of github.com:isovector/polysemy 2019-06-27 00:37:16 -04:00
Sandy Maguire
4d360445ed Release polysemy 0.5.0.1 2019-06-27 00:36:43 -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
d2c8131cb8 Fix plugin badge 2019-06-26 10:23:06 -04:00
Sandy Maguire
6ca5b4f428 Release polysemy-plugin-0.2.1.1 2019-06-26 10:21:15 -04:00
Sandy Maguire
008a152097 hpack or cabal (or both) is a janky POS 2019-06-26 00:43:10 -04:00
Sandy Maguire
a2e39776ce Release polysemy 0.5.0.0 2019-06-26 00:29:26 -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
2654d35066
Forklift interpretations (#128)
This PR provides a single function withLowerToIO, which runs a desired Sem r effect all the way down to IO, without needing to know the natural transformation beforehand. It does it by running the desired code in a new thread, and shipping all of the unhandled effects back to the main thread. The main thread turns into an event loop for the duration of the withLowerToIO block.
2019-06-25 23:46:54 -04:00
Vladimir Semyonov
585aeb1224 Better runMonadicInput type order (#122) (#131) 2019-06-25 17:42:23 -04:00
Sandy Maguire
dc1489297a Fix build badge 2019-06-24 17:05:14 -04:00
TheMatten
2aa63ecc6c
Merge upstream 2019-06-20 21:37:04 +02:00
Sandy Maguire
29216ceb69
Improve CI coverage -- now on GHC 8.4! (#39) 2019-06-19 17:25:37 -04:00
Sandy Maguire
aab9cbccff
Faster hoist, cleaned up Union (#120)
After the clean up in #118, I realized that we no longer need to define hoist in terms of weave. This should save some allocations. After that, I realized it was sort of stupid to keep all of the *Yo functions around. Literally nobody should call them, so I just inlined them into the Union versions.

Red diffs, yeah!
2019-06-18 21:48:09 -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
78d0c4905a
Split out effect lib (#83)
This PR teases apart the reusable pieces of the current TH machinery. Doing so allows us to build other TH abstractions in polysemy --- such as an RPC effect.
2019-06-18 12:23:27 -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
b23f7d2561
Simplify the CI (#119)
This PR removes some things in the travis CI that I cargo culted and
didn't understand but am reasonably sure don't do anything except slow
down CI times.
2019-06-17 15:15:13 -04:00
Sandy Maguire
6c1a6575bb Add kind synonyms for effects and effect rows
Fixes #116
2019-06-17 12:47:58 -04:00
TheMatten
a92d7fd328
Merge upstream 2019-06-17 10:25:56 +02: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
Sandy Maguire
0a1ce2b837 Add hspec-discover to package build-tools
Fixes #111
2019-06-15 20:12:18 -04:00
Sandy Maguire
82f86add29
Custom type error testing (#113)
This PR adds doctests allowing us to write tests for the custom type errors. Having this stuff reified in the test suite means we can iterate on the implementations and give much better QA.
2019-06-15 20:04:11 -04:00
Sandy Maguire
b5d086b859 Release polysemy-plugin 0.2.1.0 2019-06-14 11:38:47 -04:00
Sandy Maguire
e90c745d7a
Allow bidirectional typechecking in the plugin (#105)
* Allow bidirectional typechecking in the plugin

The plugin used to choke on this:

```haskell
flipShouldBe 11 . sum . fst . run . runFoldMapOutput id $ do
  output [1]
  output $ replicate 2 5
```

because it would fail to unify `Output (t Int)` (the polymorphic
`Traversable` variable in `sum`) with `Output [Int]`.

In this case, there are no given constraints, so the plugin is
attempting to solve a `Member (Output (t Int)) '[Output [Int]]`. We
reuse the codepath for unifying wanted/givens, pretending like the
`Output (t Int)` is a given.[^1]

[^1]: Pretending it's a wanted breaks something else that I don't
remember right now. This code is brittle :(

So now we have a "wanted" `Output [Int]`, and a "given" `Output (t
Int)`. In general, this thing isn't OK to solve. Consider a real
example:

```haskell
foo :: Member (Output (t Int)) r => Sem r ()
foo = output [5]
```

This is a type error, because the polymorphism goes the wrong way. We
have no guarantees that `t` is supposed to be `[]`.

But in our original example, this isn't a problem, because our `t` isn't
actually in given position. It's just an artifact of reusing the code!
`mkWanted` now takes a new parameter for whether or not it's OK to allow
the givens to be polymorphic.

Such a thing necessitates a change though. We never want to unify
a polymorphic *effect* in given position. Doing so will break Haskell's
regular type inference that determines what the effect row should be,
based on the order in which the interpreters are run.
2019-06-14 11:28:14 -04:00
Sandy Maguire
18e16f68db Release polysemy-plugin 0.2.0.3 2019-06-13 15:39:57 -04:00
Sandy Maguire
fc88a961ad
Ensure wanted constraints are emitted only once. (#102)
* Ensure wanted constraints are emitted only once.

This is a fix for the "solveSimpleWanteds: too many iterations" problem
that people are running into. In these cases, the plugin is being asked
to solve the same `Member` constraint several times, and generating
a new wanted each time. In doing so, GHC thinks that work was done, so
it will ask the plugin to run again next time. This process diverges,
and produces the error.

Fixes #79
2019-06-13 14:39:49 -04:00
Sandy Maguire
416530b149
Use tySynInstDCompat for future compatibility with TH (#101)
Fixes #99
2019-06-12 11:45:26 -04:00
Sandy Maguire
e960ce1877 Release polysemy 0.4.0.0 2019-06-12 09:40:08 -04:00
Sandy Maguire
b7f2922c3a
Better Resource bracketing (#87) 2019-06-12 09:36:08 -04:00
Sandy Maguire
4ca49cba2b Ensure polysemy-plugin's package.yaml is correct 2019-06-12 09:32:09 -04:00
Silvan Mosberger
979413a5e1 Update polysemy-plugin version bound (#100)
The test suite is made for 0.3 and doesn't compile with earlier versions
due to Yo now taking another argument since
https://github.com/isovector/polysemy/pull/71
2019-06-11 18:47:57 -04:00
Sandy Maguire
1813b53750 Release polysemy-plugin 0.2.0.2 2019-06-09 00:27:18 -04:00
Sandy Maguire
eff97914f7 Release polysemy 0.3.0.1 2019-06-09 00:22:50 -04:00
Sandy Maguire
66be47036d
Perform recursive unification attempts in the plugin (#96) 2019-06-09 00:20:23 -04:00
Sandy Maguire
ca0c68e1c3 Fix benchmark
Fixes #92
2019-06-08 23:15:37 -04:00
Sandy Maguire
c57f79bce4 Simplify Combinators and Internal modules 2019-06-07 14:17:43 -04:00
Sandy Maguire
f5dcbe3c98
Fixes #54 (#85) 2019-06-05 09:44:34 -04:00
Sandy Maguire
0f41b3fddf Test for #47 2019-06-05 03:44:31 -04:00
Sandy Maguire
c937132caa Release polysemy 0.3.0.0 2019-06-01 23:43:41 -04:00
Sandy Maguire
cd074a4bd4
Move Random to polysemy-zoo (#78)
* Move Random to zoo

* Changelog
2019-06-01 18:42:12 -04:00
Sandy Maguire
e41b73bb55 Unnecessary import 2019-06-01 16:30:33 -04:00
TheMatten
974b8f11de Update smart constructors generation with tests and support for operators (#77) 2019-06-01 14:46:14 -04:00
Sandy Maguire
4350b675b8 Stupid typo 2019-05-31 00:13:45 -04:00
Sandy Maguire
601cbe8630 Release polysemy 0.2.2.0 2019-05-31 00:10:52 -04:00