on master help sign in
Add 'Ord' instance to 'Maybe'
commit8e451a8b847681e4074268da35576a8f3a7b6d1c authorDmitry Kovanikov <kovanikov@gmail.com> dateMon 19 Mar 2018, 16:24 (9 years ago) parent9fc97f9
1 file changed+6
libs/prelude/Prelude/Maybe.idr+6
libs/prelude/Prelude/Maybe.idr+6
@@ -100,6 +100,12 @@ maybe_bind (Just x) k = k x
100100 (Just _) == Nothing = False
101101 (Just a) == (Just b) = a == b
102102
103+(Ord a) => Ord (Maybe a) where
104+ compare Nothing Nothing = EQ
105+ compare Nothing (Just _) = LT
106+ compare (Just _) Nothing = GT
107+ compare (Just a) (Just b) = compare a b
108+
103109||| Prioritised choice. Just like the `Alternative` implementation, the
104110||| `Semigroup` for `Maybe a` keeps the first succeeding computation.
105111|||