Created
June 23, 2017 02:29
-
-
Save robertjlooby/b1af43dc8af1759bad4e4c12b9cc0304 to your computer and use it in GitHub Desktop.
A bifunctor class checker to be used with https://hackage.haskell.org/package/checkers-0.4.7
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
{-# LANGUAGE ScopedTypeVariables #-} | |
bifunctor :: forall m a b c d e f. | |
( Bifunctor m | |
, Arbitrary a, Arbitrary b, Arbitrary c | |
, Arbitrary d, Arbitrary e, Arbitrary f | |
, CoArbitrary a, CoArbitrary d | |
, Show (m a d), Arbitrary (m a d), EqProp (m a d), EqProp (m c f) | |
) => | |
m (a,b,c) (d,e,f) -> TestBatch | |
bifunctor = const ( "bifunctor" | |
, [ ("bimap identity", property bimapIdentityP) | |
, ("first identity" , property firstIdP) | |
, ("second identity" , property secondIdP) | |
, ("compose" , property composeP) | |
] | |
) | |
where | |
bimapIdentityP :: Property | |
bimapIdentityP = bimap id id =-= (id :: m a d -> m a d) | |
firstIdP :: Property | |
firstIdP = first id =-= (id :: m a d -> m a d) | |
secondIdP :: Property | |
secondIdP = second id =-= (id :: m a d -> m a d) | |
composeP :: (a -> c) -> (d -> f) -> Property | |
composeP f g = bimap f g =-= (first f . second g :: m a d -> m c f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment