Skip to content

Commit

Permalink
Add a hack to support both Cabal-1.16 and Cabal-1.18 Setup.hs script …
Browse files Browse the repository at this point in the history
…(fixed number of arguments for programFindLocation). Taken from hdbc-postgresql commit e9b2fbab07b8f55ae6a9e120ab0b98c433842a8b.
  • Loading branch information
egonSchiele committed Feb 6, 2014
1 parent 58366d2 commit c2292f0
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Setup.lhs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env runhaskell

\begin{code}
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
import Distribution.Simple
import Distribution.PackageDescription
import Distribution.Version
Expand All @@ -26,8 +27,24 @@ 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


mysqlConfigProgram = (simpleProgram "mysql_config") {
programFindLocation = \verbosity -> do
programFindLocation = \verbosity -> constOrId $ do
mysql_config <- findProgramOnPath "mysql_config" verbosity
mysql_config5 <- findProgramOnPath "mysql_config5" verbosity
return (mysql_config `mplus` mysql_config5)
Expand Down Expand Up @@ -55,5 +72,4 @@ split xs cs = split' $ dropWhile (`elem` xs) cs
let (run, cs1) = span (`notElem` xs) cs0
cs2 = dropWhile (`elem` xs) cs1
in run:(split' cs2)

\end{code}

0 comments on commit c2292f0

Please sign in to comment.