Skip to content

Conversation

@HaskellZhangSong
Copy link

@HaskellZhangSong HaskellZhangSong commented Feb 9, 2022

This commit adds following monadic query functions in issue #35:

everythingButM :: forall m r. Monad m => (r -> r -> r) -> GenericQ (m (r, Bool)) -> GenericQ (m r)
everythingMButM :: forall m r. Monad m => (m r -> m r -> m r) -> GenericQ (m (r, Bool)) -> GenericQ (m r)
everythingWithContextM :: forall m s r. Monad m => s -> (r -> r -> r) -> GenericQ (m (s -> (r, s))) -> GenericQ (m r)
everythingMWithContextM :: forall m s r. Monad m => s -> (m r -> m r -> m r) -> GenericQ (m (s -> (r, s))) -> GenericQ (m r)

which make query with unavoidable monadic query easier.

@sergv
Copy link
Collaborator

sergv commented Sep 9, 2022

@HaskellZhangSong I think everythingButM and everythingMButM are reasonable generalisations of what's already in the library (although I'd probably consider having GenericQ (m (Maybe r)) instead of GenericQ (m (r, Bool)) when designing from scratch) but signatures of everythingWithContextM and everythingMWithContextM look convoluted. Why can't the context in there (the s -> (..., s) bit) be passed a part of the monad?

@HaskellZhangSong
Copy link
Author

HaskellZhangSong commented Mar 16, 2024

I did not think this very carefully. I just extend everythingBut by lifting (r, Bool) to m (r, Bool). Similarly applied to everythingWithContext function too.

Why can't the context in there (the s -> (..., s) bit) be passed a part of the monad?

I am not quite sure about how and what exactly you mean. Do you mean to combine m with a state monad? Could you show the code? Here, I just think the m in (m r -> m r -> m r) should be coherent with the m in (m (s -> (r, s)))

Thanks

@sergv
Copy link
Collaborator

sergv commented Mar 16, 2024

I was thinking about something along the lines

everythingMWithContextM :: forall n s r. Monad n => (StateT s n r -> StateT s n r -> StateT s n r) -> GenericQ (StateT s n r)) -> GenericQ (StateT s n r)

I.e. to obtain everythingMWithContextM the user instantiates already defined everything funsction.

@HaskellZhangSong
Copy link
Author

I think this looks more complicated and need to bring mtl library into syb.

@sergv
Copy link
Collaborator

sergv commented Mar 17, 2024

syb doesn't have to depend on mtl (transformers would be enough) - user can instantiate existing functions themselves in their package.

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.

2 participants