Skip to content

Commit

Permalink
Merge pull request #32 from scrive/master
Browse files Browse the repository at this point in the history
Add a hack to support both Cabal-1.16 and Cabal-1.18 Setup.hs script
  • Loading branch information
zenzike committed Sep 20, 2013
2 parents a3fd22e + ce6001d commit 69602ba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion HDBC-postgresql.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: HDBC-postgresql
Version: 2.3.2.1
Version: 2.3.2.2
License: BSD3
Maintainer: Nicolas Wu <nicolas.wu@gmail.com>
Author: John Goerzen
Expand Down
16 changes: 15 additions & 1 deletion Setup.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env runhaskell
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}

import Distribution.Simple
import Distribution.PackageDescription
Expand Down Expand Up @@ -26,8 +27,21 @@ main = defaultMainWithHooks simpleUserHooks {
}
}

-- 'ConstOrId' is a @Cabal-1.16@ vs @Cabal-1.18@ compatibility hack,
-- 'programFindLocation' has a new (unused in this case)
-- parameter. 'ConstOrId' adds this parameter when types say it is
-- mandatory.
class ConstOrId a b where
constOrId :: a -> b

instance ConstOrId a a where
constOrId = id

instance ConstOrId a (b -> a) where
constOrId = const

pgconfigProgram = (simpleProgram "pgconfig or pg_config") {
programFindLocation = \verbosity -> do
programFindLocation = \verbosity -> constOrId $ do
pgconfig <- findProgramLocation verbosity "pgconfig"
pg_config <- findProgramLocation verbosity "pg_config"
return (pgconfig `mplus` pg_config)
Expand Down

0 comments on commit 69602ba

Please sign in to comment.