-
Notifications
You must be signed in to change notification settings - Fork 52
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 joining functions #131
base: main
Are you sure you want to change the base?
Conversation
@@ -1 +1 @@ | |||
resolver: lts-7.14 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The project was no-longer buildable under this, so I updated it to a fairly recent one.
{-| Join two 'Fold's by applying joining functions to their inputs and | ||
outputs. | ||
-} | ||
joinWith :: (e -> a) -> (e -> c) -> (b -> d -> f) -> Fold a b -> Fold c d -> Fold e f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example: joinWith fst snd (,)
will give you a Fold a b -> Fold c d -> Fold (a,c) (b,d)
I don't think these joining functions are necessary because they can be implemented in terms of existing type class methods concisely. For example: joinOutputsWith = liftA2
joinWith inL inR out foldL foldR = liftA2 out (lmap inL foldL) (lmap inR foldR) I think there is something still worth adding, which is a utility of the following type: postMapM :: (a -> m b) -> FoldM m i a -> FoldM m i b ... because then that would dmake joinOutputsWithM f foldL foldR = postMapM id (liftA2 f foldL foldR)
joinWIthM inL inR out = postMapM id (liftA2 f (lmap inL foldL) (lmap inR folddR)) |
No description provided.