network-transport-tests-0.2.3.0: Unit tests for Network.Transport implementations

Safe HaskellSafe
LanguageHaskell98

Network.Transport.Tests.Traced

Description

Add tracing to the IO monad (see examples).

Usage
{-# LANGUAGE RebindableSyntax #-}
import Prelude hiding (catch, (>>=), (>>), return, fail)
import Traced
Example
test1 :: IO Int
test1 = do
  Left x  <- return (Left 1 :: Either Int Int)
  putStrLn "Hello world"
  Right y <- return (Left 2 :: Either Int Int)
  return (x + y)

outputs

Hello world
*** Exception: user error (Pattern match failure in do expression at Traced.hs:187:3-9)
Trace:
0  Left 2
1  Left 1
Guards

Use the following idiom instead of using guard:

test2 :: IO Int
test2 = do
  Left x <- return (Left 1 :: Either Int Int)
  True   <- return (x == 3)
  return x

The advantage of this idiom is that it gives you line number information when the guard fails:

*Traced> test2
*** Exception: user error (Pattern match failure in do expression at Traced.hs:193:3-6)
Trace:
0  Left 1

Synopsis

Documentation

class MonadS m where #

Like Monad but bind is only defined for Traceable instances

Minimal complete definition

returnS, bindS, failS, seqS

Methods

returnS :: a -> m a #

bindS :: Traceable a => m a -> (a -> m b) -> m b #

failS :: String -> m a #

seqS :: m a -> m b -> m b #

Instances

MonadS IO #

Add tracing to IO (see examples)

Methods

returnS :: a -> IO a #

bindS :: Traceable a => IO a -> (a -> IO b) -> IO b #

failS :: String -> IO a #

seqS :: IO a -> IO b -> IO b #

return :: MonadS m => a -> m a #

Redefinition of return

(>>=) :: (MonadS m, Traceable a) => m a -> (a -> m b) -> m b #

Redefinition of >>=

(>>) :: MonadS m => m a -> m b -> m b #

Redefinition of >>

fail :: MonadS m => String -> m a #

Redefinition of fail

ifThenElse :: Bool -> a -> a -> a #

Definition of ifThenElse for use with RebindableSyntax

data Showable #

Constructors

Show a => Showable a 

Instances

class Traceable a where #

Minimal complete definition

trace

Methods

trace :: a -> Maybe Showable #

Instances

Traceable Bool # 

Methods

trace :: Bool -> Maybe Showable #

Traceable Int # 

Methods

trace :: Int -> Maybe Showable #

Traceable Int32 # 

Methods

trace :: Int32 -> Maybe Showable #

Traceable Int64 # 

Methods

trace :: Int64 -> Maybe Showable #

Traceable Word32 # 

Methods

trace :: Word32 -> Maybe Showable #

Traceable Word64 # 

Methods

trace :: Word64 -> Maybe Showable #

Traceable () # 

Methods

trace :: () -> Maybe Showable #

Traceable IOException # 
Traceable ByteString # 
Traceable [Char] # 

Methods

trace :: [Char] -> Maybe Showable #

Traceable a => Traceable [a] # 

Methods

trace :: [a] -> Maybe Showable #

Traceable a => Traceable (Maybe a) # 

Methods

trace :: Maybe a -> Maybe Showable #

Traceable (MVar a) # 

Methods

trace :: MVar a -> Maybe Showable #

(Traceable a, Traceable b) => Traceable (Either a b) # 

Methods

trace :: Either a b -> Maybe Showable #

(Traceable a, Traceable b) => Traceable (a, b) # 

Methods

trace :: (a, b) -> Maybe Showable #

(Traceable a, Traceable b, Traceable c) => Traceable (a, b, c) # 

Methods

trace :: (a, b, c) -> Maybe Showable #