Skip to content

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