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

Add a convenience function withEnv #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marmistrz
Copy link

It's useful when you're storing the environment in a data structure.

@chessai
Copy link
Member

chessai commented Jun 24, 2019

I agree that this seems useful. Perhaps others might as well, and chime in.

Can you add a changelog entry?

@andrewthad
Copy link

I agree that such a function is useful. However, if it's going be in mtl, I would rather see its monomorphic cousin appear in transformers first. The name feels a little disconnected. The function is closely related to local, and none of the existing reader functions mention with or Env in their name. A few ideas (not that I particularly like any of these): localEnv, localConst, local' (gross), local_.

@chessai
Copy link
Member

chessai commented Jun 24, 2019

I agree that such a function is useful. However, if it's going be in mtl, I would rather see its monomorphic cousin appear in transformers first. The name feels a little disconnected. The function is closely related to local, and none of the existing reader functions mention with or Env in their name. A few ideas (not that I particularly like any of these): localEnv, localConst, local' (gross), local_.

This makes sense. An issue should first be opened on transformers then.

@chessai
Copy link
Member

chessai commented Aug 10, 2019

btw, perhaps readerM is a good name? because we have

reader :: MonadReader r m => (r -> a) -> m a

so readerM makes a nice contrast, just indicating that the function is monadic:

readerM :: (r -> m a) -> m a
readerM f = ask >>= f

@chessai
Copy link
Member

chessai commented Jul 16, 2021

btw, perhaps readerM is a good name? because we have

reader :: MonadReader r m => (r -> a) -> m a

so readerM makes a nice contrast, just indicating that the function is monadic:

readerM :: (r -> m a) -> m a
readerM f = ask >>= f

I had something else in mind when writting this comment. disregard.

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

Successfully merging this pull request may close these issues.

3 participants