Skip to content

Commit

Permalink
Fix running stack ghci with no targets #3309
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsloan committed Aug 22, 2017
1 parent f996855 commit 3883e37
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Stack/Ghci.hs
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,23 @@ ghci opts@GhciOpts{..} = do

preprocessTargets :: HasEnvConfig env => BuildOptsCLI -> [Text] -> RIO env (Either [Path Abs File] (Map PackageName Target))
preprocessTargets buildOptsCLI rawTargets = do
let (fileTargetsRaw, otherTargets) =
let (fileTargetsRaw, normalTargetsRaw) =
partition (\t -> ".hs" `T.isSuffixOf` t || ".lhs" `T.isSuffixOf` t)
rawTargets
case otherTargets of
[] -> do
-- Only use file targets if we have no normal targets.
if not (null fileTargetsRaw) && null normalTargetsRaw
then do
fileTargets <- forM fileTargetsRaw $ \fp0 -> do
let fp = T.unpack fp0
mpath <- liftIO $ forgivingAbsence (resolveFile' fp)
case mpath of
Nothing -> throwM (MissingFileTarget fp)
Just path -> return path
return (Left fileTargets)
_ -> do
else do
-- Try parsing targets before checking if both file and
-- module targets are specified (see issue#3342).
(_,_,normalTargets) <- parseTargets AllowNoTargets buildOptsCLI { boptsCLITargets = otherTargets }
(_,_,normalTargets) <- parseTargets AllowNoTargets buildOptsCLI { boptsCLITargets = normalTargetsRaw }
`catch` \ex -> case ex of
TargetParseException xs -> throwM (GhciTargetParseException xs)
_ -> throwM ex
Expand Down

0 comments on commit 3883e37

Please sign in to comment.