From 933cfd2852d4f4321c03564a9cc351e3508ba73c Mon Sep 17 00:00:00 2001 From: Danny Navarro Date: Sun, 18 Dec 2016 12:19:59 -0300 Subject: Tokenize number parser The essential change hidden behind the code golfing is using the `tok` combinator. This was making fail the Kitchen Sink test. --- Data/GraphQL/Parser.hs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'Data/GraphQL/Parser.hs') diff --git a/Data/GraphQL/Parser.hs b/Data/GraphQL/Parser.hs index 26902d4..160efad 100644 --- a/Data/GraphQL/Parser.hs +++ b/Data/GraphQL/Parser.hs @@ -148,7 +148,8 @@ typeCondition = namedType -- explicit types use the `typedValue` parser. value :: Parser Value value = ValueVariable <$> variable - <|> number + -- TODO: Handle maxBound, Int32 in spec. + <|> tok (either ValueFloat ValueInt . floatingOrInteger <$> scientific) <|> ValueBoolean <$> booleanValue <|> ValueString <$> stringValue -- `true` and `false` have been tried before @@ -156,13 +157,6 @@ value = ValueVariable <$> variable <|> ValueList <$> listValue <|> ValueObject <$> objectValue "value error!" - where - number = do - v <- scientific - case floatingOrInteger v of - Left r -> pure (ValueFloat r) - -- TODO: Handle maxBound, Int32 in spec. - Right i -> pure (ValueInt i) booleanValue :: Parser Bool booleanValue = True <$ tok "true" -- cgit v1.2.3