git.iko.soy/typeable/postgresql-simple
on master help sign in
Implement the Monad of No Return proposal
3a639f2Leon P Smith
src/Database/PostgreSQL/Simple/Internal.hs+4−2
@@ -4,7 +4,7 @@
4------------------------------------------------------------------------------
4------------------------------------------------------------------------------
5-- |
5-- |
6-- Module: Database.PostgreSQL.Simple.Internal
6-- Module: Database.PostgreSQL.Simple.Internal
7−-- Copyright: (c) 2011-2012 Leon P Smith
7+-- Copyright: (c) 2011-2015 Leon P Smith
8-- License: BSD3
8-- License: BSD3
9-- Maintainer: Leon P Smith <leon@melding-monads.com>
9-- Maintainer: Leon P Smith <leon@melding-monads.com>
10-- Stability: experimental
10-- Stability: experimental
@@ -476,7 +476,9 @@ instance Alternative Conversion where
476 Errors _ -> (oka <|>) <$> runConversion mb conn
476 Errors _ -> (oka <|>) <$> runConversion mb conn
477
477
478instance Monad Conversion where
478instance Monad Conversion where
479− return a = Conversion $ \_conn -> return (return a)
479+#if !(MIN_VERSION_base(4,8,0))
480+ return = pure
481+#endif
480 m >>= f = Conversion $ \conn -> do
482 m >>= f = Conversion $ \conn -> do
481 oka <- runConversion m conn
483 oka <- runConversion m conn
482 case oka of
484 case oka of
src/Database/PostgreSQL/Simple/Ok.hs+5−2
@@ -1,10 +1,11 @@
1{-# LANGUAGE DeriveDataTypeable #-}
1{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE DeriveFunctor #-}
2{-# LANGUAGE DeriveFunctor #-}
3+{-# LANGUAGE CPP #-}
3
4
4------------------------------------------------------------------------------
5------------------------------------------------------------------------------
5-- |
6-- |
6-- Module : Database.PostgreSQL.Simple.Ok
7-- Module : Database.PostgreSQL.Simple.Ok
7−-- Copyright : (c) 2012 Leon P Smith
8+-- Copyright : (c) 2012-2015 Leon P Smith
8-- License : BSD3
9-- License : BSD3
9--
10--
10-- Maintainer : leon@melding-monads.com
11-- Maintainer : leon@melding-monads.com
@@ -69,7 +70,9 @@ instance MonadPlus Ok where
69 mplus = (<|>)
70 mplus = (<|>)
70
71
71instance Monad Ok where
72instance Monad Ok where
73+#if !(MIN_VERSION_base(4,8,0))
72− return = Ok
74+ return = pure
75+#endif
73
76
74 Errors es >>= _ = Errors es
77 Errors es >>= _ = Errors es
75 Ok a >>= f = f a
78 Ok a >>= f = f a