-
-
Save Javran/aef0895f58048e1234b883afc8623f32 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE ExplicitForAll, TypeApplications, ScopedTypeVariables #-} | |
import Control.Monad.Except | |
import Data.Coerce | |
import Data.Functor.Identity | |
maybeToEither :: e -> Maybe a -> Either e a | |
maybeToEither v m = case m of | |
Nothing -> Left v | |
Just r -> Right r | |
m2e :: forall e a. e -> Maybe a -> Except e a | |
m2e = coerce (maybeToEither @e @a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment