import Data.Maybe import Control.Applicative import Control.Monad.Trans.Maybe data Result = Result getEnv :: String -> IO (Maybe String) getEnv = undefined readFileLines :: String -> IO [String] readFileLines = undefined result1 :: String -> Result result1 = undefined result2 :: String -> Result result2 = undefined def :: Result def = undefined main = fmap (maybe def id) $ runMaybeT $ asum [result1 <$> MaybeT (getEnv "path1") ,result2 <$> MaybeT (getEnv "path2")]