Questions tagged [haskell-polysemy]

Questions about Polysemy, a Haskell effect system library.

14 questions
6
votes
1 answer

Hint.interpret gives a compiler error when used on a Polysemy.Sem value

I'm trying to compile Polysemy monad values at runtime using Hint (Language.Haskell.Interpreter). When I try to do this I reliably get an error about improper use of the : operator in "interactive" code; it seems as if the text hint is passing to…
ShapeOfMatter
  • 991
  • 6
  • 25
4
votes
1 answer

Extracting multiple IO exceptions into polysemy

Let's say I have some very complex set of computations of the form computation :: IO a that I cannot modify, due to it being from some library code or other reasons. Let's also say I want to provide some type-level guarantees that we aren't able to…
3
votes
0 answers

How to define MonadBaseControl for Polysemy's Sem Monad?

I wanted to use RabbitMQ with Polysemy. To consume messages from the queues I need to provide a function of type MonadBaseControl IO m => (Message, Envelope) -> m (). Since I use Polysemy for all of my effects it would be great if I could use the…
Lando-L
  • 843
  • 6
  • 19
3
votes
1 answer

How to incorporate MTL-style, CPS-style higher-order effect into polysemy?

I am converting a codebase to use polysemy, and have run into trouble converting my uses of the LFresh typeclass from unbound-generics. The two operations I need have signatures avoid :: LFresh m => [AnyName] -> m a -> m a lunbind :: (LFresh m,…
Brent Yorgey
  • 2,043
  • 16
  • 17
3
votes
0 answers

Lazy mutual recursive evaluation of Polysemy expressions

NB: I don't think the problem here is with Polysemy per se. The Goal: I'm trying to write a single-thread simulation of multiple parties communicating synchronously. More specifically, the goal is to write the program that one party will run* in…
ShapeOfMatter
  • 991
  • 6
  • 25
2
votes
0 answers

Interpret a `Sem (x ': r) a` into a `Sem (y ': r) b`?

I'm trying to put together the machinery to write something like secret-sharing (e.g.) using algebraic effects. More specifically I'd like to be able to write the protocol in terms of the actions of each individual party, and then handle that…
2
votes
1 answer

polysemy does not detect a member

I am trying to write a bunch of statements with Hspec inside a single polysemy's Sem Monad as such: {-# OPTIONS_GHC -fplugin=Polysemy.Plugin #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs …
GlinesMome
  • 1,549
  • 1
  • 22
  • 35
2
votes
1 answer

Running the NonDet effect once in Polysemy

I'm relatively new to Polysemy, and I'm trying to wrap my head around how to use NonDet correctly. Specifically, let's say I've got this computation generate :: Member NonDet r => Sem r Int generate = msum $ fmap pure [0..] computation :: (Member…
Silvio Mayolo
  • 62,821
  • 6
  • 74
  • 116
2
votes
1 answer

Converting a monadic value to an IO in Polysemy

I am trying to build an automated feature testing suite using webdriver and polysemy in Haskell. I've gotten as far as defining proper effects and interpreting them into a webdriver WD monad, but now I'm stuck. I have a value of type Member…
SkyWriter
  • 1,454
  • 10
  • 17
1
vote
1 answer

How to modify the type of a Reader effect in Haskell Polysemy?

The Reader effect provides a local method which modifies the value to be read within a local scope: local :: Member (Reader i) r => (i -> i) -> Sem r a -> Sem r a The function passed to local must not change the type of the data. I would like to be…
1
vote
1 answer

Implement higher-order effect interpreter

I am trying to implement the interpreter of in higher-order effect. I have a base effect: {-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -fplugin=Polysemy.Plugin #-} module Hetchr.Commons.Cat where import Polysemy import…
GlinesMome
  • 1,549
  • 1
  • 22
  • 35
1
vote
1 answer

Unable to raiseUnder

I try to use raiseUnder (with polysemy 1.6.0) to introduce effects to use other interpreters, such that: {-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -fplugin=Polysemy.Plugin #-} module Memoization where import Data.Kind import qualified…
GlinesMome
  • 1,549
  • 1
  • 22
  • 35
0
votes
1 answer

Haskell/Polysemy print to StdOut

I am using Haskell's Polysemy library and having a huge headache just trying to print to StdOut. Here's my code: apiServer :: (Member Trace r, Member (Embed IO) r) => ServerT Api (Sem r) apiServer = test :<|> values where test :: Sem r String …
Nimrod Sadeh
  • 183
  • 9
0
votes
2 answers

Using pooledMapConcurrentlyN in polysemy

I'm currently playing around with Polysemy, rewriting a small toy project of mine to get used to it. I'm stumbling upon a piece of code that uses pooledMapConcurrentlyN, so basically a parallel version of traverse with bounded concurrency. I can…
l7r7
  • 1,134
  • 1
  • 7
  • 23