name: partial-handler version: 1.0.3 synopsis: A composable exception handler description: If you have ever had to compose an exception handler for exceptions of multiple types, you know how frustraiting it can get. This library approaches this issue by providing a composable exception handler type, which has instances of the standard classes. . Composability means that you can define custom partial handlers and reuse them by composing other handlers from them. . Here is an example of a composable partial handler, which only defines what to do in case of a ThreadKilled exception (the code uses the LambdaCase extension): . >ignoreThreadKilled :: PartialHandler () >ignoreThreadKilled = > typed $ \case > ThreadKilled -> Just $ return () > _ -> Nothing . Here's how you can construct a handler of type @SomeException -> IO ()@ using this library: . >totalizeRethrowing $ > ignoreThreadKilled <> > onAlreadyExists (putStrLn "Already exists") . and here is how you would do it traditionally (with the MultiWayIf extension): . >\e -> if > | Just ThreadKilled <- fromException e -> > return () > | Just e' <- fromException e, isAlreadyExistsError e' -> > putStrLn "Already exists" > | otherwise -> > throwIO e . Putting all the syntactic trickery to make it shorter aside, this handler is a monolith block of code. Unlike with PartialHandler you can neither decompose it into simpler ones, nor compose it with other handlers to form a more complex one. category: Exceptions, Error Handling, Failure homepage: https://github.com/nikita-volkov/partial-handler bug-reports: https://github.com/nikita-volkov/partial-handler/issues author: Nikita Volkov maintainer: Nikita Volkov copyright: (c) 2014, Nikita Volkov license: MIT license-file: LICENSE build-type: Simple cabal-version: >=1.10 source-repository head type: git location: git://github.com/nikita-volkov/partial-handler.git library hs-source-dirs: library other-modules: exposed-modules: PartialHandler build-depends: base >= 4.6 && < 5 if !impl(ghc >= 8.0) build-depends: semigroups >= 0.11 && < 0.19 default-extensions: Arrows, BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, TemplateHaskell, TupleSections, TypeFamilies, TypeOperators, UnboxedTuples default-language: Haskell2010