on master help sign in
Merge pull request #772 from david-christiansen/either-eq

Add Eq instance for Either

commitcf2eae88bdb656f499d3f5a29b39d4e6445081c1 authorEdwin Brady <edwin.brady@gmail.com> dateThu 9 Jan 2014, 04:31 (13 years ago) parent6808ce5f5451ce
1 file changed+11
libs/prelude/Prelude/Either.idr+11
libs/prelude/Prelude/Either.idr+11
@@ -63,6 +63,17 @@ maybeToEither def (Just j) = Right j
6363maybeToEither def Nothing = Left def
6464
6565
66+--------------------------------------------------------------------------------
67+-- Instances
68+--------------------------------------------------------------------------------
69+
70+instance (Eq a, Eq b) => Eq (Either a b) where
71+ (==) (Left x) (Left y) = x == y
72+ (==) (Right x) (Right y) = x == y
73+ (==) _ _ = False
74+
75+
76+
6677--------------------------------------------------------------------------------
6778-- Injectivity of constructors
6879--------------------------------------------------------------------------------