packages feed

indents 0.1.0 → 0.1.1

raw patch · 2 files changed

+15/−12 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Text.Parsec.Indent: manyLine :: (Stream s (StateT SourcePos m) Char, Monad m) => IndentParserT s u m a -> IndentParserT s u m [a]
+ Text.Parsec.Indent: type IndentParserT s u m a = ParsecT s u (StateT SourcePos m) a

Files

Text/Parsec/Indent.hs view
@@ -1,5 +1,8 @@ {-# LANGUAGE FlexibleContexts #-}-module Text.Parsec.Indent (block, lineFold, runIndent) where+module Text.Parsec.Indent (+    IndentParserT, block, lineFold,+    manyLine, runIndent+    ) where import Text.Parsec import Text.Parsec.Pos import Control.Monad.State@@ -39,7 +42,7 @@ block :: (Stream s (StateT SourcePos m) Char, Monad m) => IndentParserT s u m a -> IndentParserT s u m [a] block p = do     a <- setStart-    r <- many1 (checkIndent >> p)+    r <- many (checkIndent >> p)     put a     return r @@ -53,16 +56,18 @@  blockOrNewLine :: (Stream s (StateT SourcePos m) Char, Monad m) => IndentParserT s u m a -> IndentParserT s u m [a] blockOrNewLine p = do+    a <- p     s <- get     pos <- getPosition-    liftM2 (:) p $ if biAp sourceLine (==) pos s then blockOrNewLine p else liftM concat (block (manyLine p))+    liftM (a:) $ if biAp sourceLine (==) pos s then blockOrNewLine p else liftM concat (block (manyLine p))  -- | Parses many occurances of p without using more than one line manyLine :: (Stream s (StateT SourcePos m) Char, Monad m) => IndentParserT s u m a -> IndentParserT s u m [a]-manyLine p = do-    s <- liftM ((+1) . sourceLine) get-    pos <- liftM sourceLine getPosition-    if pos == s then many (char ' ') >> return [] else liftM2 (:) p (manyLine p)+manyLine p = setStart >> f where+    f = do+        s <- get+        pos <- getPosition+        if biAp sourceLine (==) pos s then liftM2 (:) p f else many (char ' ') >> return []  setStart :: (Stream s (StateT SourcePos m) Char, Monad m) => IndentParserT s u m SourcePos setStart = do@@ -77,8 +82,6 @@     p <- getPosition     if biAp sourceColumn (==) p s then return () else mzero --- | Run the result of an indentation sensative parse+-- | Run the result of an indentation sensitive parse runIndent :: Monad m => SourceName -> StateT SourcePos m a -> m a runIndent s = flip evalStateT (initialPos s)---- for tests, assemble random indent-using functions, their inputs and outputs in tandem, then test to see they all fit as planned
indents.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version:             0.1.0+Version:             0.1.1  -- A short (one-line) description of the package. Synopsis:            indentation sensitive parser-combinators for parsec@@ -34,7 +34,7 @@ -- A copyright notice. -- Copyright:            -Category:            Text+Category:            Text, Parsing  Build-type:          Simple