on master help sign in
Merge pull request #3448 from BartAdv/maybe-dec

Add decision procedure for IsJust

commit898f30de94b4783a7af383b3ca9a9fb32047388e authorNiklas Larsson <metaniklas@gmail.com> dateFri 21 Oct 2016, 20:48 (10 years ago) parente31531e9751d6c
1 file changed+9
libs/prelude/Prelude/Maybe.idr+9
libs/prelude/Prelude/Maybe.idr+9
@@ -7,6 +7,7 @@ import Prelude.Bool
77import Prelude.Cast
88import Prelude.Interfaces
99import Prelude.Foldable
10+import Prelude.Uninhabited
1011
1112%access public export
1213%default total
@@ -38,6 +39,14 @@ isJust (Just j) = True
3839data IsJust : Maybe a -> Type where
3940 ItIsJust : IsJust (Just x)
4041
42+Uninhabited (IsJust Nothing) where
43+ uninhabited ItIsJust impossible
44+
45+||| Decide whether a 'Maybe' is 'Just'
46+isItJust : (v : Maybe a) -> Dec (IsJust v)
47+isItJust (Just x) = Yes ItIsJust
48+isItJust Nothing = No absurd
49+
4150--------------------------------------------------------------------------------
4251-- Misc
4352--------------------------------------------------------------------------------