From: PHO Date: Thu, 25 Aug 2011 16:19:14 +0000 (+0900) Subject: Removed unnecessary 'try' X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=b923d454928e3d01134b15d6072b6d3edf7a15ca;p=Lucu.git Removed unnecessary 'try' Ditz-issue: 8959dadc07db1bd363283dee401073f6e48dc7fa --- diff --git a/Network/HTTP/Lucu/Authorization.hs b/Network/HTTP/Lucu/Authorization.hs index 64183ff..11de199 100644 --- a/Network/HTTP/Lucu/Authorization.hs +++ b/Network/HTTP/Lucu/Authorization.hs @@ -59,8 +59,7 @@ printAuthChallenge (BasicAuthChallenge realm) authCredentialP ∷ Parser AuthCredential authCredentialP - = try $ - do _ ← string "Basic" + = do _ ← string "Basic" skipMany1 lws b64 ← takeWhile1 base64 case C8.break (≡ ':') (B64.decodeLenient b64) of diff --git a/Network/HTTP/Lucu/ETag.hs b/Network/HTTP/Lucu/ETag.hs index 056f14f..acc496f 100644 --- a/Network/HTTP/Lucu/ETag.hs +++ b/Network/HTTP/Lucu/ETag.hs @@ -58,8 +58,7 @@ weakETag ∷ Ascii → ETag weakETag = ETag True eTagP ∷ Parser ETag -eTagP = try $ - do isWeak ← option False (string "W/" ≫ return True) +eTagP = do isWeak ← option False (string "W/" ≫ return True) str ← quotedStr return $ ETag isWeak str diff --git a/Network/HTTP/Lucu/Headers.hs b/Network/HTTP/Lucu/Headers.hs index 4241455..400e49b 100644 --- a/Network/HTTP/Lucu/Headers.hs +++ b/Network/HTTP/Lucu/Headers.hs @@ -101,17 +101,16 @@ fromHeaders (Headers m) = M.toList m -} headersP ∷ Parser Headers {-# INLINEABLE headersP #-} -headersP = do xs ← P.many header +headersP = do xs ← P.many $ try header crlf return $ toHeaders xs where header ∷ Parser (CIAscii, Ascii) - header = try $ - do name ← A.toCIAscii <$> token + header = do name ← A.toCIAscii <$> token _ ← char ':' skipMany lws - values ← sepBy content lws - skipMany lws + values ← sepBy content (try lws) + skipMany (try lws) crlf return (name, joinValues values) diff --git a/Network/HTTP/Lucu/MultipartForm.hs b/Network/HTTP/Lucu/MultipartForm.hs index 10d1f64..db32a4c 100644 --- a/Network/HTTP/Lucu/MultipartForm.hs +++ b/Network/HTTP/Lucu/MultipartForm.hs @@ -62,8 +62,7 @@ printContDispo d multipartFormP ∷ Ascii → Parser [(Text, FormData)] multipartFormP boundary - = try $ - do parts ← many (partP boundary) + = do parts ← many $ try $ partP boundary _ ← string "--" _ ← string $ A.toByteString boundary _ ← string "--" @@ -72,8 +71,7 @@ multipartFormP boundary partP ∷ Ascii → Parser Part partP boundary - = try $ - do _ ← string "--" + = do _ ← string "--" _ ← string $ A.toByteString boundary crlf hs ← headersP @@ -83,8 +81,7 @@ partP boundary bodyP ∷ Ascii → Parser LS.ByteString bodyP boundary - = try $ - do body ← manyCharsTill anyChar $ + = do body ← manyCharsTill anyChar $ try $ do crlf _ ← string "--" diff --git a/Network/HTTP/Lucu/Parser/Http.hs b/Network/HTTP/Lucu/Parser/Http.hs index 4138db2..5200342 100644 --- a/Network/HTTP/Lucu/Parser/Http.hs +++ b/Network/HTTP/Lucu/Parser/Http.hs @@ -87,8 +87,7 @@ isToken !c listOf ∷ Parser a → Parser [a] {-# INLINEABLE listOf #-} listOf p - = try $ - do skipMany lws + = do skipMany lws sepBy p $ do skipMany lws _ <- char ',' skipMany lws @@ -111,10 +110,9 @@ sp = char '\x20' ≫ return () -- |HTTP LWS: crlf? (sp | ht)+ lws ∷ Parser () {-# INLINEABLE lws #-} -lws = try $ - do option () crlf - _ ← satisfy isSPHT - skipWhile isSPHT +lws = do option () crlf + _ ← takeWhile1 isSPHT + return () -- |Returns 'True' for SP and HT. isSPHT ∷ Char → Bool diff --git a/Network/HTTP/Lucu/Request.hs b/Network/HTTP/Lucu/Request.hs index 8b516cc..b690c3e 100644 --- a/Network/HTTP/Lucu/Request.hs +++ b/Network/HTTP/Lucu/Request.hs @@ -85,8 +85,7 @@ methodP = choice ] uriP ∷ Parser URI -uriP = try $ - do bs ← takeWhile1 (\c → (¬) (isCtl c ∨ c ≡ '\x20')) +uriP = do bs ← takeWhile1 (\c → (¬) (isCtl c ∨ c ≡ '\x20')) let str = C8.unpack bs case parseURIReference str of Nothing -> fail ("Unparsable URI: " ⧺ str)