Created
March 5, 2015 09:13
-
-
Save MiyamonY/cefa30d2cbdcbf5a0a40 to your computer and use it in GitHub Desktop.
haskell error
This file contains hidden or 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
import Test.HUnit | |
import Control.Monad.Except | |
-- instance (Error e) => Monad (Either e) where | |
-- return x = Right x | |
-- Right x >>= f = f x | |
-- Left err >>= f = Left err | |
-- fail msg = Left (strMsg msg) | |
tests = ["Either1" ~: (Left "boom" >>= (\ x -> return . succ $ x)) ~?= (Left "boom" :: Either String Int), | |
"Either2" ~: (Left "boom" >>= \ x -> (Left "no way!" :: Either String Int) ) ~?= Left "boom", | |
"Either3" ~: (Right 100 >>= \ x -> (Left "no way" :: Either String Int)) ~?= Left "no way"] | |
runTests = do | |
runTestTT $ TestList tests |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment