add Applicative and Monad instances for Label#164
add Applicative and Monad instances for Label#164subttle wants to merge 1 commit into
Conversation
|
Thanks @subttle! While the instances look reasonable, it's not obvious to me that Applicative and Monad laws hold. Could you give some intuition about why you chose this particular implementation, and why it satisfies the expected laws? |
|
@subttle Strange: I received an email notification with your comment about using QuickCheck, but it doesn't seem to be here. Have you deleted it, or is it a GitHub glitch? Regarding using QuickCheck: this requires an |
|
Hi! Thank you for considering this PR. The notification was because I went to shift-enter for a newline but instead entered the comment, doh! While not a substitute for a proof (I will try to do one which considers the appropriate graph laws), I had done some basic checks with QuickCheck and checkers. instance (Arbitrary a) => Arbitrary (Label a) where
-- This particular instance may be large or even not terminate
arbitrary = oneof [ pure Zero
, pure One
, fmap Symbol arbitrary
, fmap Star arbitrary
, liftA2 (:+:) arbitrary arbitrary
, liftA2 (:*:) arbitrary arbitrary
]And also adding a Although, I had only used an instance of |
|
Thanks @subttle! One simple thing to do to at least resolve the question about the validity of the Applicative instance is to use |
No description provided.