The throwable-exceptions package

[ Tags: exception, library, mit ] [ Propose Tags ]

throwable-exceptions gives the easy way to throw exceptions


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.0.5, 0.1.0.6, 0.1.0.7, 0.1.0.8, 0.1.0.9
Dependencies base (>=4.7 && <5), safe-exceptions, template-haskell, throwable-exceptions [details]
License MIT
Copyright aiya000
Author aiya000
Maintainer aiya000.develop@gmail.com
Category Exception
Home page https://github.com/aiya000/hs-throwable-exceptions#README.md
Uploaded Wed Jun 21 10:58:44 UTC 2017 by aiya000
Distributions LTSHaskell:0.1.0.9, NixOS:0.1.0.9, Stackage:0.1.0.9
Executables throwable-exception-example
Downloads 364 total (33 in the last 30 days)
Rating 0.0 (0 ratings) [clear rating]
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-06-21 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for throwable-exceptions-0.1.0.6

[back to package description]

:diamonds: throwable-exceptions :diamonds:

Build Status Hackage

throwable-exceptions gives an easy way to create the data types of Exception instance with TemplateHaskell, and gives simple data types of Exception instance with its value constructor, for your haskell project :dog:

:books: Document is available in here :books:

:muscle: Why should we use this ? :muscle:

We want to throw some exception frequently, but the mostly throwable exceptions are not given by base.
throwable-exceptions complements it :+1:

Examples

  • vvv The summary of the exact examples is available here vvv

You can create a data type of Exception instance by a line :exclamation:

{-# LANGUAGE TemplateHaskell #-}
module Main where

declareException "MyException"
-- ^^^
-- This is same to write below line yourself
--     data MyException a = MyException
--      { myExceptionCause :: String
--      , MyExceptionClue  :: a --      } deriving (Show, Typeable)
--     instance (Typeable a, Show a) => Exception (MyException a)

main :: IO ()
main = do
  print $ MyException "hi" 10
  print $ myException "poi"

Several exceptions are defined by default :smile:

For example, IOException's value constructor is not given :cry:
But you can use Control.Exception.Throwable.IOException' instead :dog:

module Main where

main :: IO ()
main = do
  throwM $ IOException' "oops!" "in main"
  throwM $ ioException' "oops!"

:+1:

PR is welcome !