monad-transformers Questions

3

Solved

Let's say I have these two data records, X and Y and following two functions: f1 :: IO (Maybe [X]) f2 :: X -> IO (Maybe Y) I need to call the f1 first and then, for each element of returned l...
Thoracoplasty asked 10/9, 2019 at 9:6

1

Solved

I've looked over https://www.fpcomplete.com/blog/2017/06/tale-of-two-brackets, though skimming some parts, and I still don't quite understand the core issue "StateT is bad, IO is OK", other than va...
Sandysandye asked 20/2, 2019 at 4:46

2

Solved

So I have a certain function which I need to call only if a certain condition is true. If it's false, I consider it as Right. I would use EitherT.cond, but the thing is my function's return type ...

1

Solved

I'm refactoring some old code, which is in a polymorphic, but type-class constrained, monad: class ( MonadIO m , MonadLogger m , MonadLoggerIO m , MonadThrow m , MonadCatch m , MonadMask m ,...
Coccus asked 3/7, 2019 at 5:59

1

In Adjoint functors determine monad transformers, but where's lift?, Simon C has shown us the construction... newtype Three u f m a = Three { getThree :: u (m (f a)) } ... which, as the answers ...
Richert asked 23/6, 2019 at 18:43

2

Solved

I'm trying to use Scalaz EitherT with a scala.concurrent.Future. When trying to use it in a for-comprehension: import scalaz._ import Scalaz._ val et1:EitherT[Future, String, Int] = EitherT(Futur...
Tonguing asked 22/12, 2015 at 1:34

6

I need to write a state monad that can also support error handling. I was thinking of using the Either monad for this purpose because it can also provide details about what caused the error. I foun...
Leede asked 31/10, 2010 at 14:58

1

Solved

While I was learning Composing Types chapter from Haskell Book, I was given tasks to write Functor and Applicative instances for the following type. newtype Compose f g a = Compose { getCompose :: ...
Lissotrichous asked 7/3, 2019 at 12:53

4

So far, every monad (that can be represented as a data type) that I have encountered had a corresponding monad transformer, or could have one. Is there such a monad that can't have one? Or do all m...
Gospodin asked 1/7, 2014 at 17:12

2

I was trying to write my own monad transformers where it would make sense to have multiple of the same monad transformer on the stack with different types. The issue can be illustrated with the rea...
Banebrudge asked 11/1, 2019 at 19:42

2

Solved

The streaming package offers a zipsWith function zipsWith :: (Monad m, Functor h) => (forall x y. f x -> g y -> h (x, y)) -> Stream f m r -> Stream g m r -> Stream h m r and...
Ellipsoid asked 24/11, 2018 at 20:19

1

Solved

I understand (I think) that there is a close relationship between Either and Except in Haskell, and that it is easy to convert from one to the other. But I'm a bit confused about best practices for...
Corinnacorinne asked 23/11, 2018 at 23:42

1

I have a Logger type of kind * -> * which can take any type and log the value in a file. I am trying to implement this in a monadic way so that I log and keep working the same. My code looks lik...
Fin asked 18/8, 2018 at 8:46

5

Solved

I am attempting to define an API to express a particular type of procedure in my program. newtype Procedure a = { runProcedure :: ? } There is state, consisting of a mapping of IDs to records: ...
Circassian asked 22/2, 2011 at 8:15

2

Solved

The streaming package defines a Stream type that looks like the following: data Stream f m r = Step !(f (Stream f m r)) | Effect (m (Stream f m r)) | Return r There is a comment on the Stream...
Trimurti asked 29/5, 2018 at 13:17

1

Solved

In a previous question, I asked Why is there no MonadMask instance for ExceptT? and got a number of compelling answers, including from the library author, why there cannot exist a lawful instance...
Mandell asked 13/5, 2018 at 16:52

1

Monad transformers are known for all standard monads (Reader, Writer, State, Cont, List, etc.), but each of these monad transformers works in a slightly different way. There is no general met...

0

In their paper on profunctor optics, Pickering et al. state that The term ‘profunctor’ comes from category theory, although much of the categorical structure gets lost in translation. That see...

2

Solved

I'm using a library that takes the results as two-track values (success and failure).In the Observable.map function bodies I often get an observable from success track of a function, and I don't kn...

3

Solved

I'm using the servant library for my JSON API. I need some help to get a ServerT MyAPI (ReaderT a IO) monad stack working. Here's an example using ReaderT, but without integrating it with servant...
Analcite asked 7/7, 2015 at 21:49

2

Solved

I'm intrigued by the construction described here for determining a monad transformer from adjoint functors. Here's some code that summarizes the basic idea: {-# LANGUAGE MultiParamTypeClasses #-} ...
Letendre asked 16/3, 2018 at 13:45

2

Solved

I'm currently stacking Futures and Eithers using EitherT: type ErrorOr[A] = Either[Error, A] def getAge: Future[ErrorOr[Int]] = ??? def getDob(age: Int): ErrorOr[LocalDate] = ??? for { age <...
Richardo asked 12/2, 2018 at 10:24

3

I'm writing a very simple two-pass assembler in Haskell and I've come across a scenario that I don't yet have the experience to solve. I think the solution is likely to involve monad transformers, ...
Leith asked 18/11, 2017 at 23:20

1

Say I have a function function1 :: (MonadError String m, MonadIO m) => m Int function2 :: (MonadError Int m, MonadIO m) => m Int and a function to transform Int into a String renderExcep...
Egress asked 25/10, 2017 at 11:38

1

Solved

I can't grasp the correct way of interrupting lengthy pure computation on SIGINT signal. In the simple example below, I have slowFib function that simulates lengthy computation. When it is run ju...
Biquarterly asked 14/10, 2017 at 14:54

© 2022 - 2025 — McMap. All rights reserved.