Skip to content

Commit

Permalink
Use MonadFail
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej committed Apr 26, 2019
1 parent 0618511 commit 3158633
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
24 changes: 21 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.3.20190326
# version: 0.3.20190425
#
language: c
dist: xenial
Expand Down Expand Up @@ -33,8 +33,11 @@ before_cache:
- rm -rfv $CABALHOME/packages/head.hackage
matrix:
include:
- compiler: ghc-8.6.4
addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.4","cabal-install-2.4"]}}
- compiler: ghc-8.8.1
addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.8.1","cabal-install-3.0"]}}
env: GHCHEAD=true
- compiler: ghc-8.6.5
addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.5","cabal-install-2.4"]}}
- compiler: ghc-8.4.4
addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.4.4","cabal-install-2.4"]}}
- compiler: ghc-8.2.2
Expand All @@ -47,6 +50,8 @@ matrix:
addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.8.4","cabal-install-2.4"]}}
- compiler: ghc-7.6.3
addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.6.3","cabal-install-2.4"]}}
allow_failures:
- compiler: ghc-8.8.1
before_install:
- HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')
- HCPKG="$HC-pkg"
Expand Down Expand Up @@ -92,12 +97,25 @@ install:
echo "world-file: $CABALHOME/world" >> $CABALHOME/config
echo "extra-prog-path: $CABALHOME/bin" >> $CABALHOME/config
echo "symlink-bindir: $CABALHOME/bin" >> $CABALHOME/config
echo "installdir: $CABALHOME/bin" >> $CABALHOME/config
echo "build-summary: $CABALHOME/logs/build.log" >> $CABALHOME/config
echo "store-dir: $CABALHOME/store" >> $CABALHOME/config
echo "install-dirs user" >> $CABALHOME/config
echo " prefix: $CABALHOME" >> $CABALHOME/config
echo "repository hackage.haskell.org" >> $CABALHOME/config
echo " url: http://hackage.haskell.org/" >> $CABALHOME/config
- |
if $GHCHEAD; then
echo "allow-newer: $($HCPKG list --simple-output | sed -E 's/([a-zA-Z-]+)-[0-9.]+/*:\1/g')" >> $CABALHOME/config
echo "repository head.hackage" >> $CABALHOME/config
echo " url: http://head.hackage.haskell.org/" >> $CABALHOME/config
echo " secure: True" >> $CABALHOME/config
echo " root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740" >> $CABALHOME/config
echo " 2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb" >> $CABALHOME/config
echo " 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e" >> $CABALHOME/config
echo " key-threshold: 3" >> $CABALHOME/config
fi
- cat $CABALHOME/config
- rm -fv cabal.project cabal.project.local cabal.project.freeze
- travis_retry ${CABAL} v2-update -v
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Version 0.6.2 (2019-04-26)

* Define `MonadFail Ok`.

### Version 0.6.1 (2019-03-04)

* Escape double '??' to a literal '?
Expand Down
8 changes: 5 additions & 3 deletions postgresql-simple.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Cabal-version: 1.12
Name: postgresql-simple
Version: 0.6.1
Version: 0.6.2

Synopsis: Mid-Level PostgreSQL client library
Description:
Expand Down Expand Up @@ -28,7 +28,8 @@ tested-with:
|| == 8.0.2
|| == 8.2.2
|| == 8.4.4
|| == 8.6.4
|| == 8.6.5
|| == 8.8.1

Library
default-language: Haskell2010
Expand Down Expand Up @@ -97,7 +98,8 @@ Library

if !impl(ghc >= 8.0)
Build-depends:
semigroups >=0.18.5 && <0.19
fail >=4.9.0.0 && <4.10,
semigroups >=0.18.5 && <0.19

if !impl(ghc >= 7.6)
Build-depends:
Expand Down
7 changes: 7 additions & 0 deletions src/Database/PostgreSQL/Simple/Ok.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import Control.Exception
import Control.Monad(MonadPlus(..))
import Data.Typeable

import qualified Control.Monad.Fail as Fail

-- FIXME: [SomeException] should probably be something else, maybe
-- a difference list (or a tree?)

Expand Down Expand Up @@ -77,6 +79,11 @@ instance Monad Ok where
Errors es >>= _ = Errors es
Ok a >>= f = f a

#if !(MIN_VERSION_base(4,13,0))
fail = Fail.fail
#endif

instance Fail.MonadFail Ok where
fail str = Errors [SomeException (ErrorCall str)]

-- | a way to reify a list of exceptions into a single exception
Expand Down

0 comments on commit 3158633

Please sign in to comment.