The Quipper System

Safe HaskellNone

Libraries.Template.ErrorMsgQ

Description

This module provides a simple monad to encapsulate error messages within the Q monad.

Synopsis

Documentation

type ErrMsg a = Either String a Source #

Shortcut for 'Either String a'.

data ErrMsgQ a Source #

Type for the monad encapsulating error messages.

Constructors

ErrMsgQ (Q (ErrMsg a)) 

Instances

Monad ErrMsgQ # 

Methods

(>>=) :: ErrMsgQ a -> (a -> ErrMsgQ b) -> ErrMsgQ b #

(>>) :: ErrMsgQ a -> ErrMsgQ b -> ErrMsgQ b #

return :: a -> ErrMsgQ a #

fail :: String -> ErrMsgQ a #

Functor ErrMsgQ # 

Methods

fmap :: (a -> b) -> ErrMsgQ a -> ErrMsgQ b #

(<$) :: a -> ErrMsgQ b -> ErrMsgQ a #

Applicative ErrMsgQ # 

Methods

pure :: a -> ErrMsgQ a #

(<*>) :: ErrMsgQ (a -> b) -> ErrMsgQ a -> ErrMsgQ b #

(*>) :: ErrMsgQ a -> ErrMsgQ b -> ErrMsgQ b #

(<*) :: ErrMsgQ a -> ErrMsgQ b -> ErrMsgQ a #

errorMsg :: String -> ErrMsgQ a Source #

Set an error message, to be thrown. Usage:

errorMsg "an error happened"                 

embedQ :: Q a -> ErrMsgQ a Source #

Make a Q computation error-message aware.

extractQ :: String -> ErrMsgQ a -> Q a Source #

Throw the error that has been created, using the given string as a prefix. Usage:

extractQ "name of function: " $ do
  <<commands that may thow an error>>