exception-hierarchy 0.0.0.2 → 0.1.0.0
raw patch · 2 files changed
+18/−10 lines, 2 filesdep ~template-haskellPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: template-haskell
API changes (from Hackage documentation)
Files
exception-hierarchy.cabal view
@@ -2,7 +2,7 @@ cabal-version: >= 1.8 name: exception-hierarchy-version: 0.0.0.2+version: 0.1.0.0 stability: Experimental author: Yoshikuni Jujo <PAF01143@nifty.ne.jp> maintainer: Yoshikuni Jujo <PAF01143@nifty.ne.jp>@@ -31,5 +31,5 @@ library hs-source-dirs: src exposed-modules: Control.Exception.Hierarchy- build-depends: base == 4.*, template-haskell >= 2.9 && < 2.11- ghc-options: -Wall+ build-depends: base == 4.*, template-haskell >= 2.12 && < 2.13+ ghc-options: -Wall -fno-warn-tabs
src/Control/Exception/Hierarchy.hs view
@@ -3,7 +3,7 @@ module Control.Exception.Hierarchy ( ExceptionHierarchy(..), exceptionHierarchy ) where -import Control.Applicative+-- import Control.Applicative import Control.Exception import Data.Typeable import Data.Char@@ -25,23 +25,31 @@ <$> maybe (defInstException e) (`instException` e) mc <*> if c then exceptionContainer e else return [] +myClassP :: Name -> [Q Type] -> Q Pred+myClassP cla tys = do+ tysl <- sequence tys+ return (foldl AppT (ConT cla) tysl)++myNotStrict :: Q Strict+myNotStrict = bang noSourceUnpackedness noSourceStrictness+ exceptionContainer :: Name -> DecsQ exceptionContainer ec = sequence [- dataD (cxt []) he []- [forallC [PlainTV e] (cxt [classP ''Exception [varT e]]) $- normalC he [strictType notStrict (varT e)]]- [''Typeable],+ dataD (cxt []) he [] Nothing+ [forallC [PlainTV e] (cxt [myClassP ''Exception [varT e]]) $+ normalC he [bangType myNotStrict (varT e)]]+ [derivClause Nothing [conT ''Typeable]], instanceD (cxt []) (conT ''Show `appT` conT he) [funD 'showsPrec [clause [varP d, conP he [varP e]] (normalB $ varE 'showsPrec `appE` varE d `appE` varE e) []]],- sigD toEx . forallT [PlainTV e] (cxt [classP ''Exception [varT e]]) $+ sigD toEx . forallT [PlainTV e] (cxt [myClassP ''Exception [varT e]]) $ varT e `arrT` conT ''SomeException, valD (varP toEx) (normalB $ infixE (Just $ varE 'toException) (varE '(.)) (Just $ conE he)) [],- sigD fromEx . forallT [PlainTV e] (cxt [classP ''Exception [varT e]]) $+ sigD fromEx . forallT [PlainTV e] (cxt [myClassP ''Exception [varT e]]) $ conT ''SomeException `arrT` (conT ''Maybe `appT` varT e), funD fromEx [clause [varP se]