The throwable-exceptions package

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

throwable-exceptions gives the easy way to throw exceptions

[Skip to Readme]


Dependencies base (>=4.7 && <5), safe-exceptions, template-haskell, throwable-exceptions [details]
License MIT
Copyright aiya000
Author aiya000
Category Exception
Home page
Uploaded Wed Jun 21 10:58:44 UTC 2017 by aiya000
Distributions LTSHaskell:, NixOS:, Stackage:
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




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 !