DomainParser: removed warnings.

This commit is contained in:
Philippe Pittoli 2023-07-24 12:32:57 +02:00
parent 1101ab70bd
commit f1f30c8bcd

View File

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