interpolate 0.0.2 → 0.0.3
raw patch · 3 files changed
+6/−3 lines, 3 filesdep ~haskell-src-meta
Dependency ranges changed: haskell-src-meta
Files
- interpolate.cabal +1/−1
- src/Data/String/Interpolate/Parse.hs +4/−2
- src/Data/String/Interpolate/Util.hs +1/−0
interpolate.cabal view
@@ -1,5 +1,5 @@ name: interpolate-version: 0.0.2+version: 0.0.3 license: MIT license-file: LICENSE copyright: (c) 2013 Simon Hengel
src/Data/String/Interpolate/Parse.hs view
@@ -7,12 +7,14 @@ parseNodes :: String -> [Node] parseNodes = go "" where+ go :: String -> String -> [Node] go acc input = case input of "" -> [(lit . reverse) acc]+ '\\':x:xs -> go (x:'\\':acc) xs '#':'{':xs -> case span (/= '}') xs of (ys, _:zs) -> (lit . reverse) acc : Expression ys : go "" zs- (_, "") -> [(Literal . unescape) (reverse acc ++ input)]+ (_, "") -> [lit (reverse acc ++ input)] x:xs -> go (x:acc) xs lit :: String -> Node- lit acc = (Literal . unescape) acc+ lit = Literal . unescape
src/Data/String/Interpolate/Util.hs view
@@ -28,6 +28,7 @@ '\\' : x : xs | isDigit x -> case span isDigit xs of (ys, zs) -> (chr . read $ x:ys) : go zs '\\' : input_ -> case input_ of+ '\\' : xs -> '\\' : go xs 'a' : xs -> '\a' : go xs 'b' : xs -> '\b' : go xs 'f' : xs -> '\f' : go xs