Created
August 22, 2017 02:28
-
-
Save chris-martin/c3886eca3bc4dc7e4509f8cb130f8f72 to your computer and use it in GitHub Desktop.
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
data EqBy a = EqBy (a -> Bool) a | |
instance Eq (EqBy a) where | |
EqBy f _ == EqBy _ y = f y | |
eqBy :: (a -> a -> Bool) -> a -> EqBy a | |
eqBy f x = EqBy (f x) x | |
equalBy :: (a -> a -> Bool) -> [a] -> [a] -> Bool | |
equalBy f xs ys = fmap (eqBy f) xs == fmap (eqBy f) ys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment