git.iko.soy/rowtype-yoga/purescript-docs-search
on master help sign in
minor parser improvements
commit426f23644826d4f185b4bb0ca130bd922407d5e4 authorklntsky <klntsky@gmail.com> dateSat 29 Jun 2019, 02:31 (7 years ago) parent62bd942
2 files changed+35−2
src/Spago/Search/TypeQuery.purs+2−2 test/Test/TypeQuery.purs+33
src/Spago/Search/TypeQuery.purs+2−2
@@ -51,7 +51,7 @@ typeQueryParser = fix \typeQuery ->
5151 record = QApp (QConst "Record") <$> (string "{" *> rowFields <* string "}")
5252
5353 binders =
54− string "forall" *> some space *> sepEndBy1 ident (some space) <* string "." <* skipSpaces
54+ string "forall" *> some space *> sepEndBy1 ident skipSpaces <* string "." <* skipSpaces
5555
5656 for_all = QForAll <$> binders <*> typeQuery
5757
@@ -74,7 +74,7 @@ typeQueryParser = fix \typeQuery ->
7474 foldr1 QFun <$> sepBy1 apps (string "->" *> skipSpaces)
7575
7676 constrained =
77− QConstraint <$> (upperCaseIdent <* some space) <*>
77+ QConstraint <$> (upperCaseIdent <* skipSpaces) <*>
7878 (sepEndBy ((QVar <$> ident) <|> parens) (many space) <* string "=>" <* skipSpaces) <*>
7979 typeQuery
8080 in
test/Test/TypeQuery.purs+33
@@ -162,6 +162,39 @@ tests = do
162162 (QApp (QVar "f")
163163 (QApp (QConst "List") (QVar "a")))))))
164164
165+ test "test #28" do
166+ let input = "forall f a. Alternative f => Lazy(f (List a))=>f a -> f (List a)"
167+ assertRight (parseTypeQuery input) ((QForAll (nl "f" ["a"]))
168+ (QConstraint "Alternative" (l [QVar "f"])
169+ (QConstraint "Lazy" (l [QApp (QVar "f")
170+ (QApp (QConst "List") (QVar "a"))])
171+ (QFun (QApp (QVar "f") (QVar "a"))
172+ (QApp (QVar "f")
173+ (QApp (QConst "List") (QVar "a")))))))
174+
175+ test "test #29" do
176+ let input = "{a::Int,b::Int}"
177+ assertRight (parseTypeQuery input)
178+ (QApp (QConst "Record") (QRow (List.fromFoldable [ Tuple "a" (QConst "Int"), Tuple "b" (QConst "Int")])))
179+
180+ test "test #30" do
181+ let input = "{record''' :: Int}"
182+ assertRight (parseTypeQuery input)
183+ (QApp (QConst "Record") (QRow (List.fromFoldable [ Tuple "record'''" (QConst "Int")])))
184+
185+ test "test #31" do
186+ let input = "(row''' :: Int)"
187+ assertRight (parseTypeQuery input)
188+ (QRow (List.fromFoldable [ Tuple "row'''" (QConst "Int")]))
189+
190+ test "test #32" do
191+ let input = "(row1 :: Int, row2 :: (),row3::(row4::{}))"
192+ assertRight (parseTypeQuery input)
193+ (QRow (l [ Tuple "row1" (QConst "Int")
194+ , Tuple "row2" (QRow Nil)
195+ , Tuple "row3" (QRow (l [ Tuple "row4" (QApp (QConst "Record") (QRow Nil)) ])) ]))
196+
197+
165198 suite "polish notation" do
166199
167200 test "test #1" do