mirror of
https://github.com/Avi-D-coder/implicit-hie.git
synced 2024-11-26 00:04:23 +03:00
fix up
This commit is contained in:
parent
a3c3360bbc
commit
93cd9c7d93
@ -21,6 +21,6 @@ main = do
|
|||||||
| otherwise -> stackHieYaml
|
| otherwise -> stackHieYaml
|
||||||
when (null path) $ error "No .cabal file found!\n You may need to run stack build."
|
when (null path) $ error "No .cabal file found!\n You may need to run stack build."
|
||||||
file <- T.readFile $ head path
|
file <- T.readFile $ head path
|
||||||
case parseOnly parseSec file of
|
case parseOnly parsePackage file of
|
||||||
Right r -> T.writeFile "hie.yaml" $ sOrC r
|
Right r -> T.writeFile "hie.yaml" $ sOrC r
|
||||||
_ -> error "Could not parse *.cabal file"
|
_ -> error "Could not parse *.cabal file"
|
||||||
|
@ -24,19 +24,19 @@ data Component = Lib Path | Exe Name Path | Test Name Path
|
|||||||
parseName :: Parser Text
|
parseName :: Parser Text
|
||||||
parseName = "name" >> skipSpace >> char ':' >> parseString
|
parseName = "name" >> skipSpace >> char ':' >> parseString
|
||||||
|
|
||||||
parseSec :: Parser Package
|
parsePackage :: Parser Package
|
||||||
parseSec =
|
parsePackage =
|
||||||
( do
|
( do
|
||||||
n <- parseName
|
n <- parseName
|
||||||
(Package _ t) <- parseSec
|
(Package _ t) <- parsePackage
|
||||||
pure $ Package n t
|
pure $ Package n t
|
||||||
)
|
)
|
||||||
<|> ( do
|
<|> ( do
|
||||||
h <- parseComponent 0
|
h <- parseComponent 0
|
||||||
(Package n t) <- parseSec
|
(Package n t) <- parsePackage
|
||||||
pure $ Package n (h : t)
|
pure $ Package n (h : t)
|
||||||
)
|
)
|
||||||
<|> (skipToNextLine >> parseSec)
|
<|> (skipToNextLine >> parsePackage)
|
||||||
<|> pure (Package "" [])
|
<|> pure (Package "" [])
|
||||||
|
|
||||||
parseComponent :: Indent -> Parser Component
|
parseComponent :: Indent -> Parser Component
|
||||||
|
22
test/Spec.hs
22
test/Spec.hs
@ -26,23 +26,23 @@ spec = do
|
|||||||
$ libSection ~> parseLib 0
|
$ libSection ~> parseLib 0
|
||||||
`shouldParse` Lib "src"
|
`shouldParse` Lib "src"
|
||||||
describe "Should Succeed"
|
describe "Should Succeed"
|
||||||
$ it "successfully parses library section"
|
$ it "successfully parses package"
|
||||||
$ fullFile ~> parseSec
|
$ fullFile ~> parsePackage
|
||||||
`shouldParse` Package
|
`shouldParse` Package
|
||||||
"implicit-hie"
|
"implicit-hie"
|
||||||
[ Lib "src",
|
[ Lib "src",
|
||||||
Exe "implicit-hie-exe" "app",
|
Exe "implicit-hie-exe" "app",
|
||||||
Test "implicit-hie-test" "test"
|
Test "implicit-hie-test" "test"
|
||||||
]
|
]
|
||||||
describe "Should Succeed"
|
describe "Should Succeed"
|
||||||
$ it
|
$ it
|
||||||
"successfully parses library section"
|
"skips to end of block section"
|
||||||
$ let r = "test\n"
|
$ let r = "test\n"
|
||||||
in (libSection <> r) ~?> parseLib 0
|
in (libSection <> r) ~?> parseLib 0
|
||||||
`leavesUnconsumed` r
|
`leavesUnconsumed` r
|
||||||
describe "Should Succeed"
|
describe "Should Succeed"
|
||||||
$ it "successfully generates stack hie.yaml"
|
$ it "successfully generates stack hie.yaml"
|
||||||
$ (stackHieYaml <$> parseOnly parseSec fullFile) `shouldBe` Right stackHie
|
$ (stackHieYaml <$> parseOnly parsePackage fullFile) `shouldBe` Right stackHie
|
||||||
|
|
||||||
fullFile :: Text
|
fullFile :: Text
|
||||||
fullFile = "name: implicit-hie\n" <> libSection <> exeSection <> testSection
|
fullFile = "name: implicit-hie\n" <> libSection <> exeSection <> testSection
|
||||||
|
Loading…
Reference in New Issue
Block a user