Skip to content

Commit 6013a3c

Browse files
authored
Merge pull request #169 from purescript-contrib/module-rename
Rename Text.Parsing.Parser to Parsing
2 parents 9467576 + 8d3c659 commit 6013a3c

File tree

13 files changed

+74
-77
lines changed

13 files changed

+74
-77
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Breaking changes:
2525
`<|>` was made right associative. Decreasing these two operators
2626
prevents a compiler error (i.e. `MixedAssociativityError`)
2727
without causing issues with `<$>`.
28+
- Rename module prefix from `Text.Parsing.Parser` to `Parsing` (#169 by @jamesdbrock)
2829

2930
New features:
3031

bench/Json/Parsing.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import Data.List (List)
88
import Data.Maybe (Maybe(..))
99
import Data.Number as Number
1010
import Data.Tuple (Tuple(..))
11-
import Text.Parsing.Parser (ParserT, fail)
12-
import Text.Parsing.Parser.Combinators (between, choice, sepBy, try)
13-
import Text.Parsing.Parser.String (regex, skipSpaces, string)
11+
import Parsing (ParserT, fail)
12+
import Parsing.Combinators (between, choice, sepBy, try)
13+
import Parsing.String (regex, skipSpaces, string)
1414

1515
json :: forall m. Monad m => ParserT String m Json
1616
json = defer \_ ->

bench/Main.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ import Effect.Console (log)
7070
import Effect.Exception (throw)
7171
import Effect.Unsafe (unsafePerformEffect)
7272
import Performance.Minibench (benchWith)
73-
import Text.Parsing.Parser (Parser, runParser, runParserT)
74-
import Text.Parsing.Parser.String (string)
75-
import Text.Parsing.Parser.String.Basic (digit)
73+
import Parsing (Parser, runParser, runParserT)
74+
import Parsing.String (string)
75+
import Parsing.String.Basic (digit)
7676
import StringParser as StringParser
7777
import StringParser.CodePoints as StringParser.CodePoints
7878
import StringParser.CodeUnits as StringParser.CodeUnits

src/Text/Parsing/Parser.purs renamed to src/Parsing.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Text.Parsing.Parser
1+
module Parsing
22
( ParseError(..)
33
, parseErrorMessage
44
, parseErrorPosition
@@ -33,7 +33,7 @@ import Data.Identity (Identity)
3333
import Data.Lazy as Lazy
3434
import Data.Newtype (unwrap)
3535
import Data.Tuple (Tuple(..), fst)
36-
import Text.Parsing.Parser.Pos (Position, initialPos)
36+
import Parsing.Pos (Position, initialPos)
3737

3838
-- | A parsing error, consisting of a message and position information.
3939
data ParseError = ParseError String Position

src/Text/Parsing/Parser/Combinators.purs renamed to src/Parsing/Combinators.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
-- | return a parser `replicateA n p :: Parser s (Array a)` which will
4141
-- | repeat parser `p` exactly `n` times. `replicateA n p` will only succeed
4242
-- | if it can match parser `p` exactly `n` consecutive times.
43-
module Text.Parsing.Parser.Combinators
43+
module Parsing.Combinators
4444
( (<?>)
4545
, (<??>)
4646
, (<~?>)
@@ -110,7 +110,7 @@ import Data.Tuple (Tuple(..))
110110
import Data.Tuple.Nested (type (/\), (/\))
111111
import Data.Unfoldable (replicateA)
112112
import Data.Unfoldable1 (replicate1A)
113-
import Text.Parsing.Parser (ParseError(..), ParseState(..), ParserT(..), fail)
113+
import Parsing (ParseError(..), ParseState(..), ParserT(..), fail)
114114

115115
-- | Provide an error message in the case of failure.
116116
withErrorMessage :: forall m s a. ParserT s m a -> String -> ParserT s m a

src/Text/Parsing/Parser/Expr.purs renamed to src/Parsing/Expr.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- | [__Text.Parsec.Expr__](https://hackage.haskell.org/package/parsec/docs/Text-Parsec-Expr.html)
33
-- | module.
44

5-
module Text.Parsing.Parser.Expr
5+
module Parsing.Expr
66
( Assoc(..)
77
, Operator(..)
88
, OperatorTable()
@@ -14,8 +14,8 @@ import Prelude hiding (between)
1414
import Control.Alt ((<|>))
1515
import Data.Foldable (foldl, foldr)
1616
import Data.List (List(..), (:))
17-
import Text.Parsing.Parser (ParserT)
18-
import Text.Parsing.Parser.Combinators (choice, (<?>))
17+
import Parsing (ParserT)
18+
import Parsing.Combinators (choice, (<?>))
1919

2020
data Assoc = AssocNone | AssocLeft | AssocRight
2121

src/Text/Parsing/Parser/Indent.purs renamed to src/Parsing/Indent.purs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
-- | a sequence of lines need to be /folded/ to a single line. An example
3030
-- | is MIME headers. Line folding based binding separation is used in
3131
-- | Haskell as well.
32-
module Text.Parsing.Indent
32+
module Parsing.Indent
3333
( IndentParser
3434
, runIndent
3535
, withBlock
@@ -61,25 +61,20 @@ import Prelude
6161

6262
import Control.Alt ((<|>))
6363
import Control.Apply (lift2)
64-
import Control.Monad.State (State, evalState, gets)
64+
import Control.Monad.State (State, evalState)
6565
import Control.Monad.State.Trans (get, put)
6666
import Control.Monad.Trans.Class (lift)
6767
import Data.List (List(..), many)
6868
import Data.Maybe (Maybe(..))
69-
import Text.Parsing.Parser (ParseState(ParseState), ParserT, fail)
70-
import Text.Parsing.Parser.Combinators (option, optionMaybe)
71-
import Text.Parsing.Parser.Pos (Position(..), initialPos)
72-
import Text.Parsing.Parser.String (oneOf, string)
69+
import Parsing (ParserT, fail, position)
70+
import Parsing.Combinators (option, optionMaybe)
71+
import Parsing.Pos (Position(..), initialPos)
72+
import Parsing.String (oneOf, string)
7373

7474
-- | Indentation sensitive parser type. Usually @ m @ will
7575
-- | be @ Identity @ as with any @ ParserT @
7676
type IndentParser s a = ParserT s (State Position) a
7777

78-
-- | @ getPosition @ returns current position
79-
-- | should probably be added to Text.Parsing.Parser.Pos
80-
getPosition :: forall m s. ParserT s m Position
81-
getPosition = gets \(ParseState _ pos _) -> pos
82-
8378
-- | simple helper function to avoid typ-problems with MonadState instance
8479
get' :: forall s. IndentParser s Position
8580
get' = do
@@ -102,7 +97,6 @@ setSourceLine (Position { line: _, column: c }) l = Position { line: l, column:
10297
biAp :: forall a b c. (a -> b) -> (b -> b -> c) -> a -> a -> c
10398
biAp f c v1 v2 = c (f v1) (f v2)
10499

105-
-- | @ many1 @ should prabably be inside Text.Parsing.Parser.Combinators
106100
many1 :: forall s m a. ParserT s m a -> ParserT s m (List a)
107101
many1 p = lift2 Cons p (many p)
108102

@@ -127,7 +121,7 @@ withBlock' = withBlock (flip const)
127121
-- | Parses only when indented past the level of the reference
128122
indented :: forall s. IndentParser s Unit
129123
indented = do
130-
pos <- getPosition
124+
pos <- position
131125
s <- get'
132126
if biAp sourceColumn (<=) pos s then fail "not indented"
133127
else do
@@ -137,7 +131,7 @@ indented = do
137131
-- | Same as `indented`, but does not change internal state
138132
indented' :: forall s. IndentParser s Unit
139133
indented' = do
140-
pos <- getPosition
134+
pos <- position
141135
s <- get'
142136
if biAp sourceColumn (<=) pos s then fail "not indented" else pure unit
143137

@@ -148,7 +142,7 @@ sameOrIndented = sameLine <|> indented
148142
-- | Parses only on the same line as the reference
149143
sameLine :: forall s. IndentParser s Unit
150144
sameLine = do
151-
pos <- getPosition
145+
pos <- position
152146
s <- get'
153147
if biAp sourceLine (==) pos s then pure unit else fail "over one line"
154148

@@ -168,15 +162,15 @@ block p = withPos $ do
168162
withPos :: forall s a. IndentParser s a -> IndentParser s a
169163
withPos x = do
170164
a <- get'
171-
p <- getPosition
165+
p <- position
172166
r <- put' p *> x
173167
put' a *> pure r
174168

175169
-- | Ensures the current indentation level matches that of the reference
176170
checkIndent :: forall s. IndentParser s Unit
177171
checkIndent = do
178172
s <- get'
179-
p <- getPosition
173+
p <- position
180174
if biAp sourceColumn (==) p s then pure unit else fail "indentation doesn't match"
181175

182176
-- | Run the result of an indentation sensitive parse

src/Text/Parsing/Parser/Language.purs renamed to src/Parsing/Language.purs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- | This module is a port of the Haskell
22
-- | [__Text.Parsec.Language__](https://hackage.haskell.org/package/parsec/docs/Text-Parsec-Language.html)
33
-- | module.
4-
module Text.Parsing.Parser.Language
4+
module Parsing.Language
55
( haskellDef
66
, haskell
77
, emptyDef
@@ -12,10 +12,10 @@ module Text.Parsing.Parser.Language
1212
import Prelude
1313

1414
import Control.Alt ((<|>))
15-
import Text.Parsing.Parser (ParserT)
16-
import Text.Parsing.Parser.String (char, oneOf)
17-
import Text.Parsing.Parser.String.Basic (alphaNum, letter)
18-
import Text.Parsing.Parser.Token (GenLanguageDef(..), LanguageDef, TokenParser, makeTokenParser, unGenLanguageDef)
15+
import Parsing (ParserT)
16+
import Parsing.String (char, oneOf)
17+
import Parsing.String.Basic (alphaNum, letter)
18+
import Parsing.Token (GenLanguageDef(..), LanguageDef, TokenParser, makeTokenParser, unGenLanguageDef)
1919

2020
-----------------------------------------------------------
2121
-- Styles: haskellStyle, javaStyle

src/Text/Parsing/Parser/Pos.purs renamed to src/Parsing/Pos.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Text.Parsing.Parser.Pos where
1+
module Parsing.Pos where
22

33
import Prelude
44

src/Text/Parsing/Parser/String.purs renamed to src/Parsing/String.purs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
-- | The other primitive parsers, which return `CodePoint` and `String` types,
2020
-- | can parse the full Unicode character set. All of the primitive parsers
2121
-- | in this module can be used together.
22-
module Text.Parsing.Parser.String
22+
module Parsing.String
2323
( string
2424
, eof
2525
, rest
@@ -60,9 +60,9 @@ import Data.Tuple (Tuple(..), fst)
6060
import Partial.Unsafe (unsafePartial)
6161
import Prim.Row (class Nub, class Union)
6262
import Record (merge)
63-
import Text.Parsing.Parser (ParseError(..), ParseState(..), ParserT(..), fail)
64-
import Text.Parsing.Parser.Combinators ((<?>), (<~?>))
65-
import Text.Parsing.Parser.Pos (Position(..))
63+
import Parsing (ParseError(..), ParseState(..), ParserT(..), fail)
64+
import Parsing.Combinators ((<?>), (<~?>))
65+
import Parsing.Pos (Position(..))
6666

6767
-- | Match “end-of-file,” the end of the input stream.
6868
eof :: forall m. ParserT String m Unit

0 commit comments

Comments
 (0)