on master help sign in
Merge pull request #4387 from ChShersh/patch-1

Add 'Ord' instance to 'Maybe'

commite3036737f3dc56a79c2732cb90950e454a427c8e authorJan de Muijnck-Hughes <jfdm@users.noreply.github.com> dateThu 22 Mar 2018, 09:52 (9 years ago) parentbb9a1358e451a8
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|||