From e9b2fbab07b8f55ae6a9e120ab0b98c433842a8b Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Wed, 11 Sep 2013 13:29:22 +0300 Subject: [PATCH] Add a hack to support both Cabal-1.16 and Cabal-1.18 Setup.hs script (fixed number of arguments for programFindLocation) --- Setup.hs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Setup.hs b/Setup.hs index 76d7605..7cbd484 100755 --- a/Setup.hs +++ b/Setup.hs @@ -1,4 +1,5 @@ #!/usr/bin/env runhaskell +{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-} import Distribution.Simple import Distribution.PackageDescription @@ -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) -- 1.8.4