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

Copyright(c) 2012-2015 Leon P Smith
LicenseBSD3
Maintainerleon@melding-monads.com
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell98

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 SomeExceptions 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

Documentation

data Ok a Source #

Constructors

Errors [SomeException] 
Ok !a 

Instances

Monad Ok Source # 

Methods

(>>=) :: Ok a -> (a -> Ok b) -> Ok b #

(>>) :: Ok a -> Ok b -> Ok b #

return :: a -> Ok a #

fail :: String -> Ok a #

Functor Ok Source # 

Methods

fmap :: (a -> b) -> Ok a -> Ok b #

(<$) :: a -> Ok b -> Ok a #

Applicative Ok Source # 

Methods

pure :: a -> Ok a #

(<*>) :: Ok (a -> b) -> Ok a -> Ok b #

(*>) :: Ok a -> Ok b -> Ok b #

(<*) :: Ok a -> Ok b -> Ok a #

Alternative Ok Source # 

Methods

empty :: Ok a #

(<|>) :: Ok a -> Ok a -> Ok a #

some :: Ok a -> Ok [a] #

many :: Ok a -> Ok [a] #

MonadPlus Ok Source # 

Methods

mzero :: Ok a #

mplus :: Ok a -> Ok a -> Ok a #

Eq a => Eq (Ok a) Source #

Two Errors cases are considered equal, regardless of what the list of exceptions looks like.

Methods

(==) :: Ok a -> Ok a -> Bool #

(/=) :: Ok a -> Ok a -> Bool #

Show a => Show (Ok a) Source # 

Methods

showsPrec :: Int -> Ok a -> ShowS #

show :: Ok a -> String #

showList :: [Ok a] -> ShowS #

newtype ManyErrors Source #

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

Constructors

ManyErrors [SomeException]