Paste: exception +laziness weirdness

Author: vegai
Mode: haskell
Date: Sat, 24 Jan 2009 08:41:04
Plain Text |
{-# LANGUAGE DeriveDataTypeable #-}

module TestCase where

import Data.Typeable
import Control.Exception 
import Prelude hiding (catch)

data MyException = MyException deriving (Show, Typeable)
instance Exception MyException

test :: IO String
test = do let a="1"
          let b=throw MyException
          let c="3"
          return (a++b++c)

main :: IO ()
main = do
  a <- catch test myHandler
  putStrLn a
  return ()

  where myHandler :: MyException -> IO String
        myHandler MyException = do putStrLn "IM IN YOUR EXCEPTION, HANDLING IT"
                                   return ""

New Annotation

Summary:
Author:
Mode:
Body: