14
14
import Control.Applicative ((<|>) )
15
15
import Control.Exception (handleJust )
16
16
import Control.Monad
17
+ import Control.Monad.Extra (ifM )
17
18
import Control.Monad.IO.Class
18
19
import Control.Monad.Trans.Maybe
19
20
import Data.Maybe
@@ -27,6 +28,7 @@ import Hie.Yaml
27
28
import System.Directory hiding (findFile )
28
29
import System.FilePath
29
30
import System.IO.Error (isPermissionError )
31
+ import System.Process (readProcess )
30
32
31
33
-- | Given root\/foo\/bar.hs, load an implicit cradle
32
34
loadImplicitHieCradle :: FilePath -> IO (Cradle a )
@@ -64,7 +66,7 @@ implicitConfig' fp =
64
66
c <- cn <$> readPkgs cc gp p
65
67
pure (c, p)
66
68
cabal :: FilePath -> MaybeT IO (CradleType a , FilePath )
67
- cabal = build (CabalMulti mempty ) cabalComponent' cabalPkgs
69
+ cabal = ifM (( >= " 3.4 " ) <$> liftIO cabalVersion) ( pure ( Cabal mempty , mempty )) . build (CabalMulti mempty ) cabalComponent' cabalPkgs
68
70
stack :: FilePath -> MaybeT IO (CradleType a , FilePath )
69
71
stack = build (StackMulti mempty ) stackComponent' stackYamlPkgs
70
72
components f (Package n cs) = map (f n) cs
@@ -157,3 +159,6 @@ findContent p dir = do
157
159
158
160
biosWorkDir :: FilePath -> MaybeT IO FilePath
159
161
biosWorkDir = findFileUpwards (" .hie-bios" == )
162
+
163
+ cabalVersion :: IO String
164
+ cabalVersion = (!! 2 ) . words <$> readProcess " cabal" [" --version" ] " "
0 commit comments