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

[ bsd3, control, error-handling, exceptions, failure, library, monad, monads, phantom-types ] [ Propose Tags ] [ Report a vulnerability ]

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]

Flags

Manual Flags

NameDescriptionDefault
pedantic

Pass additional flags to GHC.

Disabled

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

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 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 BSD-3-Clause
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 repo 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 by PeterTrsko at 2016-02-02T20:38:23Z
Distributions
Reverse Dependencies 2 direct, 0 indirect [details]
Downloads 2514 total (14 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-02-12 [all 1 reports]

Readme for tagged-exception-core-2.2.0.0

[back to package description]

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.