on master help sign in
Add Eq instance for Either
commitf5451ce2f4007269c7c011baa441092afcf566ae authorDavid Raymond Christiansen <david@davidchristiansen.dk> dateTue 7 Jan 2014, 15:32 (13 years ago) parent6808ce5
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--------------------------------------------------------------------------------