The tagged-exception-core package

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.

[maintain]

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]

Properties

Versions2.0.0.0, 2.1.0.0, 2.2.0.0, 2.2.0.0
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]
LicenseBSD3
CopyrightCopyright (c) 2009-2016, Peter Trško
AuthorPeter Trško
Maintainerpeter.trsko@gmail.com
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 2.2.0.0)
UploadedTue Feb 2 20:35:32 UTC 2016 by PeterTrsko

Modules

[Index]

Flags

NameDescriptionDefaultType
pedanticPass additional flags to GHC.DisabledManual

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

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for tagged-exception-core-2.2.0.0

Tagged Exception Core

Hackage Hackage Dependencies Haskell Programming Language BSD3 License

Build

Description

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

License

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

Contributions

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