Commits

Bryan O'Sullivan committed 11e76c5

Fix compatibility with Cabal 1.18

  • Participants
  • Parent commits e5d138d

Comments (0)

Files changed (1)

 #!/usr/bin/env runhaskell
 
 \begin{code}
+{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
 {- OPTIONS_GHC -Wall #-}
 
 import Control.Monad (liftM2, mplus)
 import Distribution.Simple.Program
 import Distribution.Verbosity
 
+-- A Cabal 1.16 vs 1.18 compatibility hack, as in 1.18
+-- findProgramLocation 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
+
+
 main = defaultMainWithHooks simpleUserHooks {
   hookedPrograms = [mysqlConfigProgram],
 
 }
 
 mysqlConfigProgram = (simpleProgram "mysql_config") {
-    programFindLocation = \verbosity -> liftM2 mplus
+    programFindLocation = \verbosity -> constOrId $ liftM2 mplus
       (findProgramLocation verbosity "mysql_config")
       (findProgramLocation verbosity "mysql_config5")
   }