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

Stability | experimental
Maintainer | leon@melding-monads.com
Safe Haskell | Safe-Infered

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: `<|>` concatinates 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

Constructors

Errors [SomeException] |
Ok !a |

Instances

Monad Ok |
Functor Ok |
Typeable1 Ok |
MonadPlus Ok |
Applicative Ok |
Alternative Ok |
Eq a => Eq (Ok a) | Two `Errors` cases are considered equal, regardless of what the list of exceptions looks like.
Show a => Show (Ok a) |

newtype ManyErrors

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

Constructors

ManyErrors [SomeException] |

Instances

Show ManyErrors |
Typeable ManyErrors |
Exception ManyErrors |