Skip to content

Commit

Permalink
Use single file hie-implicit
Browse files Browse the repository at this point in the history
  • Loading branch information
Avi-D-coder committed May 9, 2020
1 parent 475d62d commit 63e6e56
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ packages: .
source-repository-package
type: git
location: https://github.com/Avi-D-coder/implicit-hie.git
tag: bacaa2350e388a32283e04b5d33bcdb05d10a673
tag: e033a562a8b18878d354b91977dbcd33604ad554
32 changes: 16 additions & 16 deletions src/HIE/Bios/Cradle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import Control.Applicative ((<|>))
import System.IO.Temp
import System.IO.Error (isPermissionError)
import Data.List
import Data.Maybe
import Data.Ord (Down(..))

import System.PosixCompat.Files
Expand All @@ -50,11 +51,11 @@ import qualified Data.Conduit as C
import qualified Data.Conduit.Text as C
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Data.Maybe (fromMaybe)
import GHC.Fingerprint (fingerprintString)

import Hie.Cabal.Parser
import Hie.Yaml
import Hie.Locate
----------------------------------------------------------------

-- | Given root\/foo\/bar.hs, return root\/hie.yaml, or wherever the yaml file was found.
Expand Down Expand Up @@ -132,23 +133,22 @@ implicitConfig' fp = (\wdir ->
(Bios (wdir </> ".hie-bios") Nothing, wdir)) <$> biosWorkDir fp
-- <|> (Obelisk,) <$> obeliskWorkDir fp
-- <|> (Bazel,) <$> rulesHaskellWorkDir fp
<|> (cabalExecutable >> cabalProjectDir fp >> cabalDistDir fp >> cabal)
<|> (stackExecutable >> stackYamlDir fp >> stackWorkDir fp >> stack)
<|> (cabalExecutable >> cabalProjectDir fp >> cabal)
<|> (stackExecutable >> stackYamlDir fp >> stack)
<|> (cabalExecutable >> cabal)
<|> (cabalExecutable >> cabalProjectDir fp >> cabalDistDir fp >>= cabal)
<|> (stackExecutable >> stackYamlDir fp >> stackWorkDir fp >>= stack)
<|> (cabalExecutable >> cabalProjectDir fp >>= cabal)
<|> (stackExecutable >> stackYamlDir fp >>= stack)
<|> (cabalExecutable >> cabalFile fp >>= cabal)
where
stack = pkg >>= mc StackMulti stackComponent
cabal = pkg >>= mc CabalMulti cabalComponent
mc c f (pkg', fp') = pure (c (components f pkg'), fp')
readPkgs f p = do
cfs <- nestedCabalFiles p
pkgs <- catMaybes <$> mapM (nestedPkg p) cfs
pure $ concatMap (components f) pkgs
build cn cc p = do
c <- liftIO $ cn <$> readPkgs cc p
pure (c, p)
cabal = build CabalMulti cabalComponent
stack = build StackMulti stackComponent
components f (Package n cs) = map (f n) cs
pkg = do
d <- cabalFile fp
f <- liftIO $ findCabalFiles d
t <- liftIO $ T.readFile $ d </> head f
case parsePackage' t of
Left _ -> fail "could not parse cabal file"
Right p -> pure (p, fp)

yamlConfig :: FilePath -> MaybeT IO FilePath
yamlConfig fp = do
Expand Down

0 comments on commit 63e6e56

Please sign in to comment.