throwable-exceptions: throwable-exceptions gives the easy way to throw exceptions

[ exception, library, mit ] [ Propose Tags ]

throwable-exceptions gives the easy way to throw exceptions

[Skip to Readme]
Versions [faq],,,,,,,,,
Dependencies base (>=4.7 && <5), safe-exceptions, template-haskell, throwable-exceptions [details]
License MIT
Copyright aiya000
Author aiya000
Category Exception
Home page
Uploaded by aiya000 at Wed Jun 21 10:58:44 UTC 2017
Distributions LTSHaskell:, NixOS:, Stackage:
Executables throwable-exception-example
Downloads 2460 total (110 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2017-06-21 [all 1 reports]




Maintainer's Corner

For package maintainers and hackage trustees

Readme for throwable-exceptions-

[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:


  • 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!"


PR is welcome !