hedn 0.1.5.1 → 0.1.5.2
raw patch · 5 files changed
+17/−8 lines, 5 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Data.EDN.Types: instance Functor Tagged
Files
- hedn.cabal +1/−1
- src/Data/EDN/Encode.hs +1/−0
- src/Data/EDN/Parser.hs +10/−7
- src/Data/EDN/Types.hs +4/−0
- tests/Main.hs +1/−0
hedn.cabal view
@@ -2,7 +2,7 @@ -- see http://haskell.org/cabal/users-guide/ name: hedn-version: 0.1.5.1+version: 0.1.5.2 synopsis: EDN parsing and encoding homepage: https://bitbucket.org/dpwiz/hedn license: BSD3
src/Data/EDN/Encode.hs view
@@ -71,6 +71,7 @@ quoteChar :: Char -> Builder quoteChar c = case c of '\n' -> string "newline"+ '\r' -> string "return" '\t' -> string "tab" ' ' -> string "space" _ -> singleton c
src/Data/EDN/Parser.hs view
@@ -73,6 +73,7 @@ x <- string "newline" <|> string "space" <|> string "tab" <|> A.take 1 return . Character $! case x of "newline" -> '\n'+ "return" -> '\r' "space" -> ' ' "tab" -> '\t' _ -> BS.head x@@ -80,26 +81,28 @@ parseSymbol :: Parser Value parseSymbol = do skipSoC- c <- satisfy (inClass "a-zA-Z.*/!?+_-")+ c <- satisfy (inClass "a-zA-Z.*/!?$%&=+_-") (ns, val) <- withNS c <|> withoutNS c return $! Symbol ns val where withNS c = do- ns <- takeWhile1 (inClass "a-zA-Z0-9#:.*!?+_-")+ ns <- takeWhile1 (inClass "a-zA-Z0-9#:.*!?$%&=+_-") char '/'- val <- takeWhile1 (inClass "a-zA-Z0-9#:.*!?+_-")- return (c `BS.cons` ns, val)+ vc <- satisfy (inClass "a-zA-Z.*/!?$%&=+_-")+ val <- takeWhile1 (inClass "a-zA-Z0-9#:.*!?$%&=+_-")+ return (c `BS.cons` ns, vc `BS.cons` val) withoutNS c = do- val <- takeWhile (inClass "a-zA-Z0-9#:.*!?+_-")+ val <- takeWhile (inClass "a-zA-Z0-9#:.*!?$%&=+_-") return ("", c `BS.cons` val) parseKeyword :: Parser Value parseKeyword = do skipSoC char ':'- x <- takeWhile1 (inClass "a-zA-Z0-9.*/!?+_-")- return $! Keyword x+ c <- satisfy (inClass "a-zA-Z.*/!?$%&=+_-")+ x <- takeWhile (inClass "a-zA-Z0-9#:.*/!?$%&=+_-")+ return $! Keyword (c `BS.cons` x) parseNumber :: Parser Value parseNumber = do
src/Data/EDN/Types.hs view
@@ -38,6 +38,10 @@ | Tagged !a !ByteString !ByteString deriving (Eq, Ord, Show) +instance Functor Tagged where+ fmap f (NoTag v) = NoTag (f v)+ fmap f (Tagged v ns t) = Tagged (f v) ns t+ type TaggedValue = Tagged Value type EDNList = [TaggedValue]
tests/Main.hs view
@@ -103,6 +103,7 @@ , (E.char 'c', "\\c") , (E.char '\\', "\\\\") , (E.char '\n', "\\newline")+ , (E.char '\r', "\\return") , (E.char '\t', "\\tab") , (E.char ' ', "\\space")