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 aSource

Shortcut for 'Either String a'.

data ErrMsgQ a Source

Type for the monad encapsulating error messages.

Constructors

ErrMsgQ (Q (ErrMsg a)) 

errorMsg :: String -> ErrMsgQ aSource

Set an error message, to be thrown. Usage:

 errorMsg "an error happened"                 

embedQ :: Q a -> ErrMsgQ aSource

Make a Q computation error-message aware.

extractQ :: String -> ErrMsgQ a -> Q aSource

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>>