dump 0.2.0 → 0.2.1
raw patch · 3 files changed
+43/−3 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Internal.Parse: pExp :: String -> String
- Internal.Parse: pLeaf :: Char -> String -> String
- Internal.Parse: pUntil :: Int -> Char -> String -> String
- Internal.Parse: parseSimple :: String -> [String]
Files
- README.md +1/−1
- dump.cabal +2/−2
- src/Internal/Parse.hs +40/−0
README.md view
@@ -10,6 +10,6 @@ ``` which prints: - (a) = 2 (a+1) = 3 (map (+1) [1..3]) = [2,3,4]+ (a) = 2 (a+1) = 3 (map (+a) [1..3]) = [3,4,5]
dump.cabal view
@@ -2,7 +2,7 @@ -- see http://haskell.org/cabal/users-guide/ name: dump-version: 0.2.0+version: 0.2.1 synopsis: Dumps the names and values of expressions to ease debugging. description: Example: "let a=1 in [d|a, a+1|] == \"(a) = 1, (a+1) = 2\"" license: MIT@@ -21,7 +21,7 @@ library exposed-modules: Debug.Dump- other-modules: Utils+ other-modules: Utils, Internal.Parse -- other-extensions: build-depends: base >=4 && <5 , template-haskell
+ src/Internal/Parse.hs view
@@ -0,0 +1,40 @@+module Internal.Parse where++import Debug.Trace++parseSimple :: String -> [String]+parseSimple "" = []+parseSimple str = match : parseSimple rest+ where+ match = pExp str+ rest = drop (length match + 1) str++pExp :: String -> String+pExp = pUntil 0 ','++pUntil :: Int -> Char -> String -> String+pUntil _ _ "" = ""+pUntil i c (x : xs)+ | x == c = ""+ | x == '(' = x : matchAndRest ')'+ | x == '[' = x : matchAndRest ']'+ | x == '\'' = x : leaf '\''+ | x == '"' = x : leaf '"'+ | otherwise = x : pUntil i c xs+ where+ matchAndRest = factory $ pUntil $ i + 1+ leaf = factory pLeaf+ factory :: (Char -> String -> String) -> Char -> String+ factory f cc = match ++ [cc] ++ pUntil i c rest+ where+ match = f cc xs+ rest = drop (length match + 1) xs++pLeaf :: Char -> String -> String+pLeaf _ "" = ""+pLeaf cc (x:xs)+ | x == cc = ""+ | x == '\\' = x : case xs of+ "" -> ""+ (y:ys) -> y : pLeaf cc ys+ | otherwise = x : pLeaf cc xs