Skip to content

Commit 480ee6e

Browse files
committed
Use (:) binder, remove unnecessary ($) usage
1 parent fc4ee44 commit 480ee6e

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/Text/Parsing/Parser.purs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ unParserT (ParserT p) = p
4141
-- | Apply a parser, keeping only the parsed result.
4242
runParserT :: forall m s a. Monad m => PState s -> ParserT s m a -> m (Either ParseError a)
4343
runParserT s p = do
44-
(Result _ result _ _) <- unParserT p s
44+
Result _ result _ _ <- unParserT p s
4545
pure result
4646

4747
-- | The `Parser` monad is a synonym for the parser monad transformer applied to the `Identity` monad.
@@ -52,19 +52,19 @@ runParser :: forall s a. s -> Parser s a -> Either ParseError a
5252
runParser s = runIdentity <<< runParserT (PState s initialPos)
5353

5454
instance functorParserT :: (Functor m) => Functor (ParserT s m) where
55-
map f p = ParserT $ \s -> f' <$> unParserT p s
55+
map f p = ParserT \s -> f' <$> unParserT p s
5656
where
5757
f' (Result input result consumed pos) = Result input (f <$> result) consumed pos
5858

5959
instance applyParserT :: Monad m => Apply (ParserT s m) where
6060
apply = ap
6161

6262
instance applicativeParserT :: Monad m => Applicative (ParserT s m) where
63-
pure a = ParserT $ \(PState s pos) -> do
63+
pure a = ParserT \(PState s pos) -> do
6464
pure (Result s (Right a) false pos)
6565

6666
instance altParserT :: Monad m => Alt (ParserT s m) where
67-
alt p1 p2 = ParserT $ \s -> do
67+
alt p1 p2 = ParserT \s -> do
6868
(o@(Result input result consumed pos)) <- unParserT p1 s
6969
case result of
7070
Left _ | not consumed -> unParserT p2 s
@@ -76,7 +76,7 @@ instance plusParserT :: Monad m => Plus (ParserT s m) where
7676
instance alternativeParserT :: Monad m => Alternative (ParserT s m)
7777

7878
instance bindParserT :: Monad m => Bind (ParserT s m) where
79-
bind p f = ParserT $ \s -> do
79+
bind p f = ParserT \s -> do
8080
(Result input result consumed pos) <- unParserT p s
8181
case result of
8282
Left err -> pure (Result input (Left err) consumed pos)
@@ -91,23 +91,23 @@ instance monadZeroParserT :: Monad m => MonadZero (ParserT s m)
9191
instance monadPlusParserT :: Monad m => MonadPlus (ParserT s m)
9292

9393
instance monadTransParserT :: MonadTrans (ParserT s) where
94-
lift m = ParserT $ \(PState s pos) -> (\a -> Result s (Right a) false pos) <$> m
94+
lift m = ParserT \(PState s pos) -> (\a -> Result s (Right a) false pos) <$> m
9595

9696
instance monadStateParserT :: Monad m => MonadState s (ParserT s m) where
97-
state f = ParserT $ \(PState s pos) ->
97+
state f = ParserT \(PState s pos) ->
9898
pure $ case f s of
9999
Tuple a s' -> Result s' (Right a) false pos
100100

101101
instance lazyParserT :: Lazy (ParserT s m a) where
102-
defer f = ParserT $ \s -> unParserT (f unit) s
102+
defer f = ParserT \s -> unParserT (f unit) s
103103

104104
-- | Set the consumed flag.
105105
consume :: forall s m. Monad m => ParserT s m Unit
106-
consume = ParserT $ \(PState s pos) -> pure (Result s (Right unit) true pos)
106+
consume = ParserT \(PState s pos) -> pure (Result s (Right unit) true pos)
107107

108108
-- | Fail with a message.
109109
fail :: forall m s a. Monad m => String -> ParserT s m a
110-
fail message = ParserT $ \(PState s pos) -> pure $ parseFailed s pos message
110+
fail message = ParserT \(PState s pos) -> pure $ parseFailed s pos message
111111

112112
-- | Creates a failed parser state for the remaining input `s` and current position
113113
-- | with an error message.

src/Text/Parsing/Parser/Token.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import Data.Either (Either(..))
3434
import Data.Foldable (foldl, foldr)
3535
import Data.Identity (Identity)
3636
import Data.Int (toNumber)
37-
import Data.List (List(..))
37+
import Data.List (List(..), (:))
3838
import Data.List as List
3939
import Data.Maybe (Maybe(..), maybe)
4040
import Data.String (toCharArray, null, toLower, fromCharArray, singleton, uncons)
@@ -51,7 +51,7 @@ import Text.Parsing.Parser.String (satisfy, oneOf, noneOf, string, char)
5151
token :: forall m a. Monad m => (a -> Position) -> ParserT (List a) m a
5252
token tokpos = ParserT $ \(PState toks pos) ->
5353
pure $ case toks of
54-
Cons x xs -> Result xs (Right x) true (tokpos x)
54+
x : xs -> Result xs (Right x) true (tokpos x)
5555
_ -> parseFailed toks pos "expected token, met EOF"
5656

5757
-- | Create a parser which matches any token satisfying the predicate.
@@ -400,7 +400,7 @@ makeTokenParser (LanguageDef languageDef)
400400

401401
folder :: Maybe Char -> List Char -> List Char
402402
folder Nothing chars = chars
403-
folder (Just c) chars = Cons c chars
403+
folder (Just c) chars = c : chars
404404

405405

406406
stringChar :: ParserT String m (Maybe Char)

0 commit comments

Comments
 (0)