packages feed

neat-interpolation 0.3.2.1 → 0.3.2.2

raw patch · 2 files changed

+46/−16 lines, 2 filesdep +megaparsecdep −parsecPVP ok

version bump matches the API change (PVP)

Dependencies added: megaparsec

Dependencies removed: parsec

API changes (from Hackage documentation)

Files

library/NeatInterpolation/Parsing.hs view
@@ -1,28 +1,58 @@+{-# LANGUAGE CPP       #-}+{-# LANGUAGE EmptyCase #-}+ module NeatInterpolation.Parsing where -import BasePrelude hiding (try, (<|>), many)-import Text.Parsec hiding (Line)+import BasePrelude hiding (many, some, try, (<|>))+import Data.Text (Text, pack)+import Text.Megaparsec hiding (Line)+import Text.Megaparsec.Char -data Line = +data Line =   Line {lineIndent :: Int, lineContents :: [LineContent]}   deriving (Show) -data LineContent = +data LineContent =   LineContentText [Char] |   LineContentIdentifier [Char]   deriving (Show) -parseLines :: [Char] -> Either ParseError [Line]-parseLines = parse lines "NeatInterpolation.Parsing.parseLines"+#if ( __GLASGOW_HASKELL__ < 710 )+data Void++instance Eq Void where+    _ == _ = True++instance Ord Void where+    compare _ _ = EQ++instance ShowErrorComponent Void where+   showErrorComponent = absurd++absurd :: Void -> a+absurd a = case a of {}+#endif++type Parser = Parsec Void String++-- | Pretty parse exception for parsing lines.+newtype ParseException = ParseException Text+    deriving (Show, Eq)++parseLines :: [Char] -> Either ParseException [Line]+parseLines input = case parse lines "NeatInterpolation.Parsing.parseLines" input of+    Left err     -> Left $ ParseException $ pack $ parseErrorPretty' input err+    Right output -> Right output   where+    lines :: Parser [Line]     lines = sepBy line newline <* eof     line = Line <$> countIndent <*> many content     countIndent = fmap length $ try $ lookAhead $ many $ char ' '     content = try escapedDollar <|> try identifier <|> contentText-    identifier = fmap LineContentIdentifier $ +    identifier = fmap LineContentIdentifier $       char '$' *> (try identifier' <|> between (char '{') (char '}') identifier')     escapedDollar = fmap LineContentText $ char '$' *> count 1 (char '$')-    identifier' = many1 (alphaNum <|> char '\'' <|> char '_')+    identifier' = some (alphaNumChar <|> char '\'' <|> char '_')     contentText = do       text <- manyTill anyChar end       if null text@@ -31,6 +61,6 @@       where         end =           (void $ try $ lookAhead escapedDollar) <|>-          (void $ try $ lookAhead identifier) <|> -          (void $ try $ lookAhead newline) <|> +          (void $ try $ lookAhead identifier) <|>+          (void $ try $ lookAhead newline) <|>           eof
neat-interpolation.cabal view
@@ -1,16 +1,16 @@ name:   neat-interpolation version:-  0.3.2.1+  0.3.2.2 synopsis:   A quasiquoter for neat and simple multiline text interpolation description:   A quasiquoter for producing Text values with support for-  a simple interpolation of input values. -  It removes the excessive indentation from the input and -  accurately manages the indentation of all lines of the interpolated variables. +  a simple interpolation of input values.+  It removes the excessive indentation from the input and+  accurately manages the indentation of all lines of the interpolated variables. category:-  String, QuasiQoutes+  String, QuasiQuotes license:   MIT license-file:@@ -48,7 +48,7 @@     NeatInterpolation.String   build-depends:     text == 1.*,-    parsec >= 3 && < 4,+    megaparsec >= 6.5 && < 7,     template-haskell >= 2.8 && < 3,     base-prelude < 2,     base >= 4.6 && < 5