Skip to content

Commit 8266462

Browse files
committed
Handle other-modules in exe
1 parent 575b0f9 commit 8266462

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/Hie/Cabal/Parser.hs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Data.Char
99
import Data.Maybe
1010
import Data.Text (Text)
1111
import qualified Data.Text as T
12+
import System.FilePath.Posix ((</>))
1213

1314
type Name = Text
1415

@@ -75,7 +76,7 @@ parseBench = parseSecMain (Comp Bench) "benchmark"
7576
parseSecMain :: (Name -> Path -> Component) -> Text -> Indent -> Parser [Component]
7677
parseSecMain c s i = do
7778
n <- componentHeader i s
78-
p <- pathMain (i + 1) ["./"] ""
79+
p <- pathMain (i + 1) ["./"] "" []
7980
pure $ map (c n) p
8081

8182
parseQuoted :: Parser Text
@@ -105,12 +106,18 @@ parseList i = items <|> (emptyOrComLine >> indent i >> items)
105106
<|> pure []
106107
pure $ h : t
107108

108-
pathMain :: Indent -> [Text] -> Text -> Parser [Text]
109-
pathMain i p m =
110-
(hsSourceDir i >>= (\p' -> pathMain i p' m))
111-
<|> (field i "main-is" (const parseString) >>= pathMain i p)
112-
<|> (skipBlockLine i >> pathMain i p m)
113-
<|> pure (map (<> "/" <> m) p)
109+
pathMain :: Indent -> [Text] -> Text -> [Text] -> Parser [Text]
110+
pathMain i p m o =
111+
(hsSourceDir i >>= (\p' -> pathMain i p' m o))
112+
<|> (field i "main-is" (const parseString) >>= flip (pathMain i p) o)
113+
<|> (field i "other-modules" parseList >>= pathMain i p m)
114+
<|> (skipBlockLine i >> pathMain i p m o)
115+
<|> pure (map (<//> m) p <> [p' <//> (o' <> ".hs") | p' <- p, o' <- o])
116+
117+
118+
(<//>) :: Text -> Text -> Text
119+
a <//> b = T.pack (T.unpack a </> T.unpack b)
120+
infixr 5 <//>
114121

115122
parseSec :: Indent -> Text -> (Name -> Path -> Component) -> Parser [Component]
116123
parseSec i compType compCon = do

0 commit comments

Comments
 (0)