on master help sign in
Merge pull request #4521 from doofin/master

add eitherToMaybe

commitc6c087f43702dfae3b05c16d44294ba5f5094e1b authorNiklas Larsson <metaniklas@gmail.com> dateSat 21 Jul 2018, 19:17 (8 years ago) parent2642556dce3380
1 file changed+4
libs/prelude/Prelude/Either.idr+4
libs/prelude/Prelude/Either.idr+4
@@ -87,6 +87,10 @@ maybeToEither : (def : Lazy e) -> Maybe a -> Either e a
8787maybeToEither def (Just j) = Right j
8888maybeToEither def Nothing = Left def
8989
90+||| Convert an Either to a Maybe from Right injection
91+eitherToMaybe : Either e a -> Maybe a
92+eitherToMaybe (Left _) = Nothing
93+eitherToMaybe (Right x) = Just x
9094
9195--------------------------------------------------------------------------------
9296-- Implementations