tagged-exception-core: Reflect exceptions using phantom types.

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.


This library provides interface similar to extensible-exceptions. It introduces Throws monad transformer that uses phantom type to tag code that may raise exception. Intention is to make exceptions explicit and to enforce exception handling.

[Skip to ReadMe]


Change logChangeLog.md
Dependenciesbase (>=4.5 && <5), exceptions (>0.6 && <0.9), ghc-prim, mmorph (>=1.0.0 && <1.1), mtl (>=2.1 && <2.3), transformers (>=0.3 && <0.6) [details]
CopyrightCopyright (c) 2009-2016, Peter Trško
AuthorPeter Trško
CategoryControl , Error Handling , Exceptions , Failure , Monad , Monads , Phantom Types
Home pagehttps://github.com/trskop/tagged-exception-core
Bug trackerhttps://github.com/trskop/tagged-exception-core/issues
Source repositoryhead: git clone git://github.com/trskop/tagged-exception-core.git
this: git clone git://github.com/trskop/tagged-exception-core.git(tag
UploadedTue Feb 2 20:35:32 UTC 2016 by PeterTrsko





Pass additional flags to GHC.


Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Maintainers' corner

For package maintainers and hackage trustees

Readme for tagged-exception-core-

[back to package description]

Tagged Exception Core

Hackage Hackage Dependencies Haskell Programming Language BSD3 License



Reflect exceptions using phantom types. This library provides core API and others may build on top of it.

Usage Example

Example of reflecting reised exception in type:

{-# LANGUAGE DeriveDataTypeable #-}

import Control.Exception (Exception)

import Control.Monad.TaggedException (Throws)
import qualified Control.Monad.TaggedException as E (liftT, throw)
import Data.Typeable (Typeable)

data NotReady = NotReady String
    deriving (Show, Typeable)
        -- Both required by Exception class

instance Exception NotReady

myFunction :: Input -> Throws NotReady IO Output
myFunction input = do

    -- ... some stuff ...

    -- isReady :: Input -> IO Bool
    ready <- E.liftT $ isReady input
    unless ready
        . E.throw $ NotReady "Resource of myFunction is not ready."

    -- ... some other stuff ...


The BSD 3-Clause License, see LICENSE file for details.


Contributions, pull requests and bug reports are welcome! Please don't be afraid to contact author using GitHub or by e-mail.