>>> one True :: [Bool] [True] >>> one 'a' :: Text "a" >>> one (3, "hello") :: HashMap Int String fromList [(3,"hello")]
>>> import Control.Monad.Except
>>> canFail = throwError "it failed" :: Except String Int >>> final = return 42 :: Except String IntCan be combined by allowing the first function to fail:
>>> runExcept $ canFail *> final Left "it failed" >>> runExcept $ optional canFail *> final Right 42
>>> concat (Just [1, 2, 3]) [1,2,3]
>>> concat (Left 42) []
>>> concat [[1, 2, 3], [4, 5], [6], []] [1,2,3,4,5,6]