heredocs 0.1.0.0 → 0.1.1.0
raw patch · 2 files changed
+16/−9 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- heredocs.cabal +1/−1
- src/Text/Heredoc.hs +15/−8
heredocs.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: heredocs-version: 0.1.0.0+version: 0.1.1.0 synopsis: heredocument description: heredocument homepage: http://github.com/cutsea110/heredoc.git
src/Text/Heredoc.hs view
@@ -25,7 +25,7 @@ -- | C# code gen heredocFromString :: String -> Q Exp heredocFromString- = either err (concatToQExp . arrange) . parse doc "heredoc" . (<>"\n")+ = either err (concatToQExp . arrange) . parse doc "heredoc" where err = infixE <$> Just . pos <*> pure (varE '(++)) <*> Just . msg pos = litE <$> (stringL <$> show . errorPos)@@ -77,7 +77,7 @@ spaceTabs = many (oneOf " \t") doc :: Parser [(Indent, Line)]-doc = line `endBy` eol+doc = line `sepBy` eol line :: Parser (Indent, Line) line = (,) <$> indent <*> contents@@ -300,17 +300,17 @@ norm' :: Line' -> Line' norm' x@(_, Normal _) = x norm' (i, CtrlForall b e body)- = (i, CtrlForall b e (normsub i body))+ = (i, CtrlForall b e (normsub i body ++ blockEnd)) norm' (i, CtrlLet b e body)- = (i, CtrlLet b e (normsub i body))+ = (i, CtrlLet b e (normsub i body ++ blockEnd)) norm' (i, CtrlMaybe flg b e body alt)- = (i, CtrlMaybe flg b e (normsub i body) (normsub i alt))+ = (i, CtrlMaybe flg b e (normsub i body ++ blockEnd) (normsub i alt ++ blockEnd)) norm' (i, CtrlNothing) = error "orphan $nothing found" norm' (i, CtrlIf flg e body alt)- = (i, CtrlIf flg e (normsub i body) (normsub i alt))+ = (i, CtrlIf flg e (normsub i body ++ blockEnd) (normsub i alt ++ blockEnd)) norm' (i, CtrlElse) = error "orphan $else found" norm' (i, CtrlCase e alts)- = (i, CtrlCase e (map (id *** normsub i) alts))+ = (i, CtrlCase e (map (id *** (++ blockEnd) . normsub i) alts)) norm' (i, CtrlOf _) = error "orphan $of found" normsub :: Indent -> [Line'] -> [Line']@@ -318,6 +318,9 @@ deIndent n = i+(n-j) in norm $ map (deIndent *** id) body + blockEnd :: [Line']+ blockEnd = [(0, Normal [])]+ class ToQPat a where toQPat :: a -> Q Pat concatToQPat :: [a] -> Q Pat@@ -436,10 +439,14 @@ toQExp (n, x) = toQExp x -- Ctrl* concatToQExp [] = litE (stringL "")- concatToQExp (x@(_, Normal _):xs)+ concatToQExp (x@(_, Normal _):y:ys) = infixE (Just (infixE (Just (toQExp x)) (varE '(++)) (Just (litE (stringL "\n")))))+ (varE '(++))+ (Just (concatToQExp (y:ys)))+ concatToQExp (x@(_, Normal _):xs)+ = infixE (Just (toQExp x)) (varE '(++)) (Just (concatToQExp xs)) concatToQExp (x:xs) = infixE (Just (toQExp x))