Permalink
Browse files

hlint fixes. Added HLint config.

  • Loading branch information...
1 parent 438cc40 commit 62c5c010a5375a0535b2c8c9d955daebf6363e19 @ekmett committed Jan 7, 2013
View
@@ -0,0 +1 @@
+import "hint" HLint.Default
View
@@ -70,6 +70,7 @@ import Text.Parser.Combinators
oneOf :: CharParsing m => [Char] -> m Char
oneOf xs = oneOfSet (CharSet.fromList xs)
{-# INLINE oneOf #-}
+{-# ANN oneOf "HLint: ignore Use String" #-}
-- | As the dual of 'oneOf', @noneOf cs@ succeeds if the current
-- character /not/ in the supplied list of characters @cs@. Returns the
@@ -79,6 +80,7 @@ oneOf xs = oneOfSet (CharSet.fromList xs)
noneOf :: CharParsing m => [Char] -> m Char
noneOf xs = noneOfSet (CharSet.fromList xs)
{-# INLINE noneOf #-}
+{-# ANN noneOf "HLint: ignore Use String" #-}
-- | @oneOfSet cs@ succeeds if the current character is in the supplied
-- set of characters @cs@. Returns the parsed character. See also
@@ -47,7 +47,6 @@ module Text.Parser.Combinators
, Parsing(..)
) where
-import Data.Traversable (sequenceA)
import Control.Applicative
import Control.Monad (MonadPlus(..))
import Control.Monad.Trans.Class
@@ -59,13 +58,15 @@ import Control.Monad.Trans.RWS.Lazy as Lazy
import Control.Monad.Trans.RWS.Strict as Strict
import Control.Monad.Trans.Reader
import Control.Monad.Trans.Identity
+import Data.Foldable (asum)
import Data.Monoid
+import Data.Traversable (sequenceA)
-- | @choice ps@ tries to apply the parsers in the list @ps@ in order,
-- until one of them succeeds. Returns the value of the succeeding
-- parser.
choice :: Alternative m => [m a] -> m a
-choice = foldr (<|>) empty
+choice = asum
{-# INLINE choice #-}
-- | @option x p@ tries to apply parser @p@. If @p@ fails without
@@ -91,7 +91,7 @@ buildExpressionParser :: (Parsing m, Monad m)
-> m a
-> m a
buildExpressionParser operators simpleExpr
- = foldl (makeParser) simpleExpr operators
+ = foldl makeParser simpleExpr operators
where
makeParser term ops
= let (rassoc,lassoc,nassoc,prefix,postfix) = foldr splitOp ([],[],[],[],[]) ops
@@ -28,6 +28,7 @@ module Text.Parser.Permutation
) where
import Control.Applicative
+import Data.Foldable (asum)
infixl 1 <||>, <|?>
infixl 2 <$$>, <$?>
@@ -119,7 +120,7 @@ instance Functor m => Functor (Branch m) where
-- transform a permutation tree into a normal parser
permute :: Alternative m => Permutation m a -> m a
permute (Permutation def xs)
- = foldr (<|>) empty (map branch xs ++ e)
+ = asum (map branch xs ++ e)
where
e = maybe [] (pure . pure) def
branch (Branch perm p) = flip id <$> p <*> permute perm
View
@@ -500,7 +500,7 @@ escapeCode = (charEsc <|> charNum <|> charAscii <|> charControl) <?> "escape cod
<|> (char 'x' *> number 16 hexDigit)
charEsc = choice $ parseEsc <$> escMap
parseEsc (c,code) = code <$ char c
- escMap = zip ("abfnrtv\\\"\'") ("\a\b\f\n\r\t\v\\\"\'")
+ escMap = zip "abfnrtv\\\"\'" "\a\b\f\n\r\t\v\\\"\'"
charAscii = choice $ parseAscii <$> asciiMap
parseAscii (asc,code) = try $ code <$ string asc
asciiMap = zip (ascii3codes ++ ascii2codes) (ascii3 ++ ascii2)
@@ -510,12 +510,9 @@ escapeCode = (charEsc <|> charNum <|> charAscii <|> charControl) <?> "escape cod
ascii3codes = ["NUL","SOH","STX","ETX","EOT","ENQ","ACK"
,"BEL","DLE","DC1","DC2","DC3","DC4","NAK"
,"SYN","ETB","CAN","SUB","ESC","DEL"]
- ascii2, ascii3 :: [Char]
- ascii2 = ['\BS','\HT','\LF','\VT','\FF','\CR','\SO','\SI'
- ,'\EM','\FS','\GS','\RS','\US','\SP']
- ascii3 = ['\NUL','\SOH','\STX','\ETX','\EOT','\ENQ','\ACK'
- ,'\BEL','\DLE','\DC1','\DC2','\DC3','\DC4','\NAK'
- ,'\SYN','\ETB','\CAN','\SUB','\ESC','\DEL']
+ ascii2, ascii3 :: String
+ ascii2 = "\BS\HT\LF\VT\FF\CR\SO\SI\EM\FS\GS\RS\US\SP"
+ ascii3 = "\NUL\SOH\STX\ETX\EOT\ENQ\ACK\BEL\DLE\DC1\DC2\DC3\DC4\NAK\SYN\ETB\CAN\SUB\ESC\DEL"
-- | This parser parses a natural number (a positive whole
-- number). Returns the value of the number. The number can be

0 comments on commit 62c5c01

Please sign in to comment.