Skip to content

Instantly share code, notes, and snippets.

@Ciantic
Last active November 4, 2019 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ciantic/6d1bd5dd2842b71b233f0a6cb9233833 to your computer and use it in GitHub Desktop.
Save Ciantic/6d1bd5dd2842b71b233f0a6cb9233833 to your computer and use it in GitHub Desktop.
newtype Maybe' a = Maybe' {getMaybe' :: Maybe a}
deriving Show
-- $setup
-- >>> :set -XScopedTypeVariables
-- >>> :set -XFlexibleContexts
-- >>> import Test.QuickCheck
-- $
-- | Maybe
--
-- transitivity test:
--
-- prop> (\x y z -> (Maybe' x == Maybe' y && Maybe' y == Maybe' z) ==> (Maybe' x == Maybe' z))
--
-- above gives me `*** Gave up! Passed only 24 tests; 1000 discarded tests.`
--
-- Compared to:
--
-- >>> quickCheck (\x y z -> (Maybe' x == Maybe' y && Maybe' y == Maybe' z) ==> (Maybe' x == Maybe' z))
--
-- above gives me `OK, passed 100 tests; 144 discarded.`
--
instance Eq a => Eq (Maybe' a) where
(Maybe' (Just a)) == (Maybe' (Just a')) = a == a'
(Maybe' Nothing ) == (Maybe' Nothing ) = True
_ == _ = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment