Draft: Give a better implementation for (*>)#546
Open
L0neGamer wants to merge 2 commits intohedgehogqa:masterfrom
Open
Draft: Give a better implementation for (*>)#546L0neGamer wants to merge 2 commits intohedgehogqa:masterfrom
(*>)#546L0neGamer wants to merge 2 commits intohedgehogqa:masterfrom
Conversation
(*>)
Contributor
|
This doesn't look sound - what if I'm using |
Author
|
Damn, you've a point... I'll have another go |
(*>)(*>)
Author
|
@ocharles if you don't mind, why is mzip and (<*>) different for TreeT? I'm not sure why NodeT's applicative wasn't implemented like below. Could you shed some light? diff --git a/hedgehog/src/Hedgehog/Internal/Tree.hs b/hedgehog/src/Hedgehog/Internal/Tree.hs
index 0970ec1..d95aa62 100644
--- a/hedgehog/src/Hedgehog/Internal/Tree.hs
+++ b/hedgehog/src/Hedgehog/Internal/Tree.hs
@@ -428,9 +428,9 @@ instance (Eq1 m, Eq a) => Eq (TreeT m a) where
instance Applicative m => Applicative (NodeT m) where
pure x =
NodeT x []
- (<*>) (NodeT ab tabs) na@(NodeT a tas) =
- NodeT (ab a) $
- map (<*> (fromNodeT na)) tabs ++ map (fmap ab) tas
+ (<*>) nf@(NodeT f tfs) na@(NodeT a tas) =
+ NodeT (f a) $
+ map (<*> fromNodeT na) tfs ++ map (fromNodeT nf <*>) tas
instance Applicative m => Applicative (TreeT m) where
pure = |
Contributor
|
Sorry, I don't know why they are different - I'm not familiar with the underlying code. |
Member
|
I think this makes |
8bf5c2a to
8d4f684
Compare
Author
|
I've changed this to instead just cleanup some instances and add a comment. I can adjust the changelog if wanted, but this seems minor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
~~The default implementation of
(*>)uses(<*>)which tries to perform each branch in parallel. However, since we only get the value from the right argument, we should just return that argument.I don't implement
(>>)similarly due to my attempts with haskell/core-libraries-committee#333, but if that proposal falls through I'll be back.~~Simply cleanup some instance definitions and add a comment.