Skip to content

Commit 3350d7c

Browse files
committed
Remove autogen-modules from other-modules + Update tests
1 parent 4513e50 commit 3350d7c

File tree

5 files changed

+28
-34
lines changed

5 files changed

+28
-34
lines changed

hie.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,5 @@ cradle:
66
- path: "app/Main.hs"
77
component: "implicit-hie:exe:gen-hie"
88

9-
- path: "app/Paths_implicit_hie.hs"
10-
component: "implicit-hie:exe:gen-hie"
11-
129
- path: "test"
1310
component: "implicit-hie:test:implicit-hie-test"

src/Hie/Cabal/Parser.hs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ parseBench = parseSecMain (Comp Bench) "benchmark"
7676
parseSecMain :: (Name -> Path -> Component) -> Text -> Indent -> Parser [Component]
7777
parseSecMain c s i = do
7878
n <- componentHeader i s
79-
p <- pathMain (i + 1) ["./"] "" []
79+
p <- pathMain (i + 1) ["./"] "" [] []
8080
pure $ map (c n) p
8181

8282
parseQuoted :: Parser Text
@@ -106,17 +106,24 @@ parseList i = items <|> (emptyOrComLine >> indent i >> items)
106106
<|> pure []
107107
pure $ h : t
108108

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-
109+
pathMain :: Indent -> [Text] -> Text -> [Text] -> [Text] -> Parser [Text]
110+
pathMain i p m o a =
111+
(hsSourceDir i >>= (\p' -> pathMain i p' m o a))
112+
<|> (field i "main-is" (const parseString) >>= (\m' -> pathMain i p m' o a))
113+
<|> (field i "other-modules" parseList >>= flip (pathMain i p m) a)
114+
<|> (field i "autogen-modules" parseList >>= pathMain i p m o)
115+
<|> (skipBlockLine i >> pathMain i p m o a)
116+
<|> pure
117+
( map (<//> m) p
118+
<> [ p' <//> (o' <> ".hs")
119+
| p' <- p,
120+
o' <- filter (`notElem` a) o
121+
]
122+
)
117123

118124
(<//>) :: Text -> Text -> Text
119125
a <//> b = T.pack (T.unpack a </> T.unpack b)
126+
120127
infixr 5 <//>
121128

122129
parseSec :: Indent -> Text -> (Name -> Path -> Component) -> Parser [Component]

test/Spec.hs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ spec = do
1717
describe "Should Succeed"
1818
$ it "successfully parses executable section"
1919
$ exeSection ~> parseExe 0
20-
`shouldParse` [ Comp Exe "implicit-hie-exe" "app/Main.hs",
21-
Comp Exe "implicit-hie-exe" "app/Paths_implicit_hie.hs"
22-
]
20+
`shouldParse` [Comp Exe "gen-hie" "app/Main.hs"]
2321
describe "Should Succeed"
2422
$ it "successfully parses test section"
2523
$ testSection ~> parseTestSuite 0
@@ -50,8 +48,7 @@ spec = do
5048
`shouldParse` Package
5149
"implicit-hie"
5250
[ Comp Lib "" "src",
53-
Comp Exe "implicit-hie-exe" "app/Main.hs",
54-
Comp Exe "implicit-hie-exe" "app/Paths_implicit_hie.hs",
51+
Comp Exe "gen-hie" "app/Main.hs",
5552
Comp Test "implicit-hie-test" "test"
5653
]
5754
describe "Should Succeed"
@@ -92,9 +89,11 @@ spec = do
9289

9390
exeSection :: Text
9491
exeSection =
95-
"executable implicit-hie-exe\n\
92+
"executable gen-hie\n\
9693
\ other-modules:\n\
9794
\ Paths_implicit_hie\n\
95+
\ autogen-modules:\n\
96+
\ Paths_implicit_hie\n\
9897
\ hs-source-dirs:\n\
9998
\ app\n\
10099
\ ghc-options: -O2\n\

test/hie.yaml.cbl

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
11
cradle:
22
cabal:
3-
- path: "src"
3+
- path: "./src"
44
component: "lib:haskell-language-server"
55

6-
- path: "exe/Main.hs"
6+
- path: "./exe/Main.hs"
77
component: "haskell-language-server:exe:haskell-language-server"
88

9-
- path: "exe/Arguments.hs"
9+
- path: "./exe/Arguments.hs"
1010
component: "haskell-language-server:exe:haskell-language-server"
1111

12-
- path: "exe/Paths_haskell_language_server.hs"
13-
component: "haskell-language-server:exe:haskell-language-server"
14-
15-
- path: "exe/Wrapper.hs"
16-
component: "haskell-language-server:exe:haskell-language-server-wrapper"
17-
18-
- path: "exe/Arguments.hs"
12+
- path: "./exe/Wrapper.hs"
1913
component: "haskell-language-server:exe:haskell-language-server-wrapper"
2014

21-
- path: "exe/Paths_haskell_language_server.hs"
15+
- path: "./exe/Arguments.hs"
2216
component: "haskell-language-server:exe:haskell-language-server-wrapper"
2317

24-
- path: "test/functional"
18+
- path: "./test/functional"
2519
component: "haskell-language-server:test:func-test"
2620

27-
- path: "test/utils"
21+
- path: "./test/utils"
2822
component: "haskell-language-server:lib:hls-test-utils"

test/stackHie.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,5 @@ cradle:
66
- path: "./app/Main.hs"
77
component: "implicit-hie:exe:gen-hie"
88

9-
- path: "./app/Paths_implicit_hie.hs"
10-
component: "implicit-hie:exe:gen-hie"
11-
129
- path: "./test"
1310
component: "implicit-hie:test:implicit-hie-test"

0 commit comments

Comments
 (0)