text-postgresql 0.0.2.1 → 0.0.2.2
raw patch · 3 files changed
+8/−57 lines, 3 filesdep +transformers-compat
Dependencies added: transformers-compat
Files
- src/Control/Monad/Either/Plus.hs +0/−48
- src/Text/Parser/List.hs +6/−7
- text-postgresql.cabal +2/−2
− src/Control/Monad/Either/Plus.hs
@@ -1,48 +0,0 @@-{-# OPTIONS_GHC -fno-warn-orphans #-}--module Control.Monad.Either.Plus- ( EitherP (..)- , eitherP, emap- , leftP, rightP- ) where--import Control.Applicative ((<$>), Applicative (..), Alternative (..))-import Control.Monad (MonadPlus (..))-import Data.Monoid (Monoid (..), (<>))---newtype EitherP e a = EitherP { unEitherP :: Either e a }--eitherP :: (a -> c) -> (b -> c) -> EitherP a b -> c-eitherP f g = either f g . unEitherP--emap :: (e0 -> e1) -> EitherP e0 a -> EitherP e1 a-emap f = EitherP . eitherP (Left . f) Right--leftP :: e -> EitherP e a-leftP = EitherP . Left--rightP :: a -> EitherP e a-rightP = EitherP . Right--instance Functor (EitherP e) where- fmap f (EitherP e) = EitherP $ f <$> e--instance Applicative (EitherP e) where- pure = EitherP . pure- EitherP a <*> EitherP b = EitherP $ a <*> b--instance Monad (EitherP e) where- (EitherP e) >>= f = EitherP (e >>= unEitherP . f)- return = EitherP . return--instance Monoid e => Alternative (EitherP e) where- empty = EitherP $ Left mempty- EitherP a <|> EitherP b = EitherP $ a `plus` b where- x@(Right _) `plus` _ = x- Left _ `plus` y@(Right _) = y- Left e1 `plus` Left e2 = Left $ e1 <> e2--instance Monoid e => MonadPlus (EitherP e) where- mzero = empty- mplus = (<|>)
src/Text/Parser/List.hs view
@@ -8,27 +8,26 @@ import Control.Applicative (pure) import Control.Monad (guard) import Control.Monad.Trans.State.Strict (StateT (..), evalStateT, get, put)+import Control.Monad.Trans.Except (Except, runExcept, withExcept, throwE) import Data.Monoid (Last (..)) import Data.Maybe (fromMaybe) -import Control.Monad.Either.Plus (EitherP (..), emap, leftP) - type Error = Last String unError :: String -> Error -> String unError s = fromMaybe s . getLast -type Parser t = StateT [t] (EitherP Error)+type Parser t = StateT [t] (Except Error) runParser :: Parser t a -> [t] -> Either String (a, [t])-runParser p = unEitherP . emap (unError "runParser: parse error.") . runStateT p+runParser p = runExcept . withExcept (unError "runParser: parse error.") . runStateT p evalParser :: Parser t a -> [t] -> Either String a-evalParser p = unEitherP . emap (unError "evalParser: parse error.") . evalStateT p+evalParser p = runExcept . withExcept (unError "evalParser: parse error.") . evalStateT p -errorE :: String -> EitherP Error a-errorE = leftP . Last . Just+errorE :: String -> Except Error a+errorE = throwE . Last . Just errorP :: String -> Parser t a errorP = StateT . const . errorE
text-postgresql.cabal view
@@ -1,5 +1,5 @@ name: text-postgresql-version: 0.0.2.1+version: 0.0.2.2 synopsis: Parser and Printer of PostgreSQL extended types description: This package involves parser and printer for text expressions of PostgreSQL extended types.@@ -26,12 +26,12 @@ Database.PostgreSQL.Parser Database.PostgreSQL.Printer other-modules:- Control.Monad.Either.Plus Text.Parser.List Text.Printer.List build-depends: base <5 , transformers+ , transformers-compat , dlist hs-source-dirs: src default-language: Haskell2010