Can I modify my state using IO via the Scotty API? Currently, I have a state transformer inside IO monad to modify state with user input. But I want t ...
Can I modify my state using IO via the Scotty API? Currently, I have a state transformer inside IO monad to modify state with user input. But I want t ...
In Haskell, is there a way to simplify the following code to remove the repeating of "hello world"? In other words, applying f, g, and h to hello worl ...
I've got this type alias: I know that StateT has the kind * -> (* -> *) -> * -> * so it should get three parameters. But in the above e ...
I'm learning Monad Transformers, and one of the exercises asks to implement the Monad instance for StateT. I want to test that my implementation admit ...
There's an asynchronous client that returns Futures of Lists. To iterate over results I need to use nested map and flatMap. Is there a way to create a ...
The codensity monad on a type constructor f is defined by: It is well known that C f is a monad for any type constructor f (not necessarily covaria ...
I'm just trying to understand the logic behind the implementation of Scala's List[A] map[B] Scala 2.12 describes it as such: I am confused as to h ...
I am trying to make a parser that will be able to parse expressions such as 2<3 succesfully as Oper Less (Const (IntVal 2)) (Const (IntVal 3)) whil ...
I know you can lift functions to monads with liftM, but I it doesn't seem to work with binary functions. I tried to lift (+) but it didn't work ...
I'm working on the Alphametics puzzle A set of words is written down in the form of an ordinary "long-hand" addition sum, and it is required that ...
It seems to be that this may be useful: And whilst the above compiles, h is unusable, because once one attempts to define two instances of MonadErr ...
I've been dissecting this one-liner solution for aoc day 14 and came across an elegant impure recursive solution: def s(x,y): if y>h: return T ...
As an exercise, I tried to construct an infinite, lazy list, recursively, inside a monad. Basically, the equivalent of nat, but monadic, monat: nat ...
Can one reasonably implement MonadError threw a newtype wrapping ExceptT? So far I have: I know catchError = const will compile, but that's not wha ...
For the MVE code below it outputs [] rather than the expected Not (Oper Eq 2 2)) for the input parseString "2+2" which is supposed to call pOper. My g ...
Let's assume I've got below monad class: Why in this combination I'm getting strange error of: ...
I am trying to create a parser in Haskell using the readP library that is left associative in it's (arithmetic) output. In the simplified code below I ...
I am trying to get a better intution of the readP library : Why does this: return: When this Returns: In both cases some value should be ...
Up front: I know how to just write a custom function that will do this, but I swear there's a built-in thing whose name I'm just forgetting, to handle ...
I'm trying to create a calculator with an integer state which allows the user to update this state using commands. This is what I've got so far. No ...