Skip to content

Commit 63e6e56

Browse files
committed
Use single file hie-implicit
1 parent 475d62d commit 63e6e56

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ packages: .
33
source-repository-package
44
type: git
55
location: https://github.com/Avi-D-coder/implicit-hie.git
6-
tag: bacaa2350e388a32283e04b5d33bcdb05d10a673
6+
tag: e033a562a8b18878d354b91977dbcd33604ad554

src/HIE/Bios/Cradle.hs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import Control.Applicative ((<|>))
3737
import System.IO.Temp
3838
import System.IO.Error (isPermissionError)
3939
import Data.List
40+
import Data.Maybe
4041
import Data.Ord (Down(..))
4142

4243
import System.PosixCompat.Files
@@ -50,11 +51,11 @@ import qualified Data.Conduit as C
5051
import qualified Data.Conduit.Text as C
5152
import qualified Data.Text as T
5253
import qualified Data.Text.IO as T
53-
import Data.Maybe (fromMaybe)
5454
import GHC.Fingerprint (fingerprintString)
5555

5656
import Hie.Cabal.Parser
5757
import Hie.Yaml
58+
import Hie.Locate
5859
----------------------------------------------------------------
5960

6061
-- | Given root\/foo\/bar.hs, return root\/hie.yaml, or wherever the yaml file was found.
@@ -132,23 +133,22 @@ implicitConfig' fp = (\wdir ->
132133
(Bios (wdir </> ".hie-bios") Nothing, wdir)) <$> biosWorkDir fp
133134
-- <|> (Obelisk,) <$> obeliskWorkDir fp
134135
-- <|> (Bazel,) <$> rulesHaskellWorkDir fp
135-
<|> (cabalExecutable >> cabalProjectDir fp >> cabalDistDir fp >> cabal)
136-
<|> (stackExecutable >> stackYamlDir fp >> stackWorkDir fp >> stack)
137-
<|> (cabalExecutable >> cabalProjectDir fp >> cabal)
138-
<|> (stackExecutable >> stackYamlDir fp >> stack)
139-
<|> (cabalExecutable >> cabal)
136+
<|> (cabalExecutable >> cabalProjectDir fp >> cabalDistDir fp >>= cabal)
137+
<|> (stackExecutable >> stackYamlDir fp >> stackWorkDir fp >>= stack)
138+
<|> (cabalExecutable >> cabalProjectDir fp >>= cabal)
139+
<|> (stackExecutable >> stackYamlDir fp >>= stack)
140+
<|> (cabalExecutable >> cabalFile fp >>= cabal)
140141
where
141-
stack = pkg >>= mc StackMulti stackComponent
142-
cabal = pkg >>= mc CabalMulti cabalComponent
143-
mc c f (pkg', fp') = pure (c (components f pkg'), fp')
142+
readPkgs f p = do
143+
cfs <- nestedCabalFiles p
144+
pkgs <- catMaybes <$> mapM (nestedPkg p) cfs
145+
pure $ concatMap (components f) pkgs
146+
build cn cc p = do
147+
c <- liftIO $ cn <$> readPkgs cc p
148+
pure (c, p)
149+
cabal = build CabalMulti cabalComponent
150+
stack = build StackMulti stackComponent
144151
components f (Package n cs) = map (f n) cs
145-
pkg = do
146-
d <- cabalFile fp
147-
f <- liftIO $ findCabalFiles d
148-
t <- liftIO $ T.readFile $ d </> head f
149-
case parsePackage' t of
150-
Left _ -> fail "could not parse cabal file"
151-
Right p -> pure (p, fp)
152152

153153
yamlConfig :: FilePath -> MaybeT IO FilePath
154154
yamlConfig fp = do

0 commit comments

Comments
 (0)