postgresql-simple-0.7.0.1: Mid-Level PostgreSQL client library

Copyright | (c) 2012-2015 Leon P Smith
License | BSD3
Maintainer | leon@melding-monads.com
Stability | experimental
Safe Haskell | Safe-Inferred
Language | Haskell2010

Database.PostgreSQL.Simple.Ok

Description

The `Ok` type is a simple error handler, basically equivalent to `Either [SomeException]`. This type (without the list) was used to handle conversion errors in early versions of postgresql-simple.

One of the primary reasons why this type was introduced is that `Either SomeException` had not been provided an instance for `Alternative`, and it would have been a bad idea to provide an orphaned instance for a commonly-used type and typeclass included in `base`.

Extending the failure case to a list of `SomeException`s enables a more sensible `Alternative` instance definitions: `<|>` concatenates the list of exceptions when both cases fail, and `empty` is defined as 'Errors []'. Though `<|>` one could pick one of two exceptions, and throw away the other, and have `empty` provide a generic exception, this avoids cases where `empty` overrides a more informative exception and allows you to see all the different ways your computation has failed.

Synopsis

- data Ok a
  - = Errors [SomeException]
  - | Ok !a
- newtype ManyErrors = ManyErrors [SomeException]

# Documentation

data Ok a Source #

Constructors

Errors [SomeException] |
Ok !a |

#### Instances

Instances details

Alternative Ok Source # |
Instance details Defined in Database.PostgreSQL.Simple.Ok Methods empty :: Ok a Source # (<|>) :: Ok a -> Ok a -> Ok a Source # some :: Ok a -> Ok [a] Source # many :: Ok a -> Ok [a] Source #
Applicative Ok Source # |
Instance details Defined in Database.PostgreSQL.Simple.Ok Methods pure :: a -> Ok a Source # (<*>) :: Ok (a -> b) -> Ok a -> Ok b Source # liftA2 :: (a -> b -> c) -> Ok a -> Ok b -> Ok c Source # (*>) :: Ok a -> Ok b -> Ok b Source # (<*) :: Ok a -> Ok b -> Ok a Source #
Functor Ok Source # |
Instance details Defined in Database.PostgreSQL.Simple.Ok Methods fmap :: (a -> b) -> Ok a -> Ok b Source # (<$) :: a -> Ok b -> Ok a Source #
Monad Ok Source # |
Instance details Defined in Database.PostgreSQL.Simple.Ok Methods (>>=) :: Ok a -> (a -> Ok b) -> Ok b Source # (>>) :: Ok a -> Ok b -> Ok b Source # return :: a -> Ok a Source #
MonadPlus Ok Source # |
Instance details Defined in Database.PostgreSQL.Simple.Ok Methods mzero :: Ok a Source # mplus :: Ok a -> Ok a -> Ok a Source #
MonadFail Ok Source # |
Instance details Defined in Database.PostgreSQL.Simple.Ok Methods fail :: String -> Ok a Source #
Show a => Show (Ok a) Source # |
Instance details Defined in Database.PostgreSQL.Simple.Ok Methods showsPrec :: Int -> Ok a -> ShowS Source # show :: Ok a -> String Source # showList :: [Ok a] -> ShowS Source #
Eq a => Eq (Ok a) Source # | Two `Errors` cases are considered equal, regardless of what the list of exceptions looks like.
Instance details Defined in Database.PostgreSQL.Simple.Ok Methods (==) :: Ok a -> Ok a -> Bool Source # (/=) :: Ok a -> Ok a -> Bool Source #

newtype ManyErrors Source #

a way to reify a list of exceptions into a single exception

Constructors

ManyErrors [SomeException] |

#### Instances

Instances details

Exception ManyErrors Source # |
Instance details Defined in Database.PostgreSQL.Simple.Ok Methods toException :: ManyErrors -> SomeException Source # fromException :: SomeException -> Maybe ManyErrors Source # displayException :: ManyErrors -> String Source # backtraceDesired :: ManyErrors -> Bool Source #
Show ManyErrors Source # |
Instance details Defined in Database.PostgreSQL.Simple.Ok Methods showsPrec :: Int -> ManyErrors -> ShowS Source # show :: ManyErrors -> String Source # showList :: [ManyErrors] -> ShowS Source #