The tagged-exception-core package

[Tags:bsd3, library]

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

Versions 2.0.0.0, 2.1.0.0, 2.2.0.0
Change log ChangeLog.md
Dependencies base (>=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]
License BSD3
Copyright Copyright (c) 2009-2016, Peter Trško
Author Peter Trško
Maintainer peter.trsko@gmail.com
Category Control , Error Handling , Exceptions , Failure , Monad , Monads , Phantom Types
Home page https://github.com/trskop/tagged-exception-core
Bug tracker https://github.com/trskop/tagged-exception-core/issues
Source repository head: 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)
Uploaded Tue Feb 2 20:38:23 UTC 2016 by PeterTrsko
Distributions NixOS:2.2.0.0
Downloads 415 total (3 in the last 30 days)
Votes
0 []
Status Docs available [build log]
Last success reported on 2016-02-12 [all 1 reports]

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

Maintainer's Corner

For package maintainers and hackage trustees

Readme for tagged-exception-core

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.