DomainParser: removed warnings.

beta
Philippe Pittoli 2023-07-24 12:32:57 +02:00
parent 1101ab70bd
commit f1f30c8bcd
1 changed files with 3 additions and 7 deletions

View File

@ -1,25 +1,21 @@
-- | `DomainParser` is a simple parser for domain names as described in RFC 1035. -- | `DomainParser` is a simple parser for domain names as described in RFC 1035.
module DomainParser where module DomainParser where
import Prelude (bind, discard, pure, show, ($), (+), (<>), (>), (-)) import Prelude (bind, discard, pure, show, ($), (<>), (>))
import Control.Alt ((<|>)) import Control.Alt ((<|>))
import Control.Lazy (defer) import Control.Lazy (defer)
import Data.Array (many, length, snoc)
import Data.Array.NonEmpty as NonEmpty import Data.Array.NonEmpty as NonEmpty
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Foldable (fold, foldl)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.String as S -- length import Data.String as S -- length
import Data.String.CodeUnits as CU import Data.String.CodeUnits as CU
-- import Data.String.Regex as R -- import Data.String.Regex as R
-- import Data.String.Regex.Flags as RF -- import Data.String.Regex.Flags as RF
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Parsing
import Parsing.Combinators.Array (many1) import Parsing.Combinators.Array (many1)
import Parsing.Combinators as PC import Parsing.Combinators as PC
import Parsing (Parser, runParser) import Parsing (Parser, fail, runParser)
import Parsing.String
import Parsing.String.Basic (alphaNum, letter) import Parsing.String.Basic (alphaNum, letter)
import Parsing.String (char, string, eof) import Parsing.String (char, string, eof)
@ -31,7 +27,7 @@ sub_eof :: Parser String String
sub_eof = do sub_eof = do
sub <- subdomain sub <- subdomain
-- TODO: non standard (RFC 1035). -- TODO: non standard (RFC 1035).
PC.option (PC.try $ char '.') PC.optional (char '.')
eof eof
if S.length sub > 255 if S.length sub > 255
then fail $ "domain length is > 255 bytes (" <> show (S.length sub) <> ")" then fail $ "domain length is > 255 bytes (" <> show (S.length sub) <> ")"