Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convenient ways to work with mtl stack #26

Closed
chshersh opened this issue Jan 14, 2017 · 3 comments
Closed

Convenient ways to work with mtl stack #26

chshersh opened this issue Jan 14, 2017 · 3 comments
Assignees

Comments

@chshersh
Copy link
Contributor

It's very inconvenient to use flip runReaderT r or (runReaderT r) to run monads from mtl stack because first argument of such functions is monad, not environment. I propose to add next functions:

usingReaderT :: r -> ReaderT r m a -> m a
usingReader  :: r -> Reader r a -> a

usingStateT :: s -> StateT s m a -> m a
usingState  :: s -> State s a -> a

Maybe it's better to somehow force introduction of such functions directly inside mtl.

@neongreen neongreen changed the title Conveninet ways to work with mtl stack Convenient ways to work with mtl stack Jan 14, 2017
@gromakovsky
Copy link
Member

gromakovsky commented Jan 16, 2017

usingStateT :: s -> StateT s m a -> m a

It's questionable what this function should return. It can be analogue of runStateT, execStateT, evalStateT.

@chshersh
Copy link
Contributor Author

@gromakovsky Agree. But by our convention (also works good with ReaderT) it returns m a. And in that case we need to introduce new nice names.

@chshersh chshersh self-assigned this Jan 17, 2017
@gromakovsky
Copy link
Member

Well, this convention is not obvious, another possible convention can be that using is flip run. I can't say that one is better than another one though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants