sqlite-simple-0.4.19.0: Mid-Level SQLite client library

Copyright | (c) 2012 Leon P Smith (c) 2012-2013 Janne Hellsten
License | BSD3
Maintainer | Janne Hellsten <jjhellst@gmail.com>
Safe Haskell | Safe-Inferred
Language | Haskell2010

Database.SQLite.Simple.Ok

Description

The `Ok` type is a simple error handler, basically equivalent to `Either [SomeException]`.

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 #

Constructors

Errors [SomeException] |
Ok !a |

#### Instances

Instances details

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

newtype ManyErrors #

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

Constructors

ManyErrors [SomeException] |

#### Instances

Instances details

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