-- My goal here is to be able to parse a string like "678767". -- However, this same parser needs to be able to handle a string like "18.1.2.4" -- My strategy is this: I parse the input as an integer. -- If the parser has reached the end of the string, tag the chomped value as XXXXXX (see Index type below) -- If the parser instead reaches a `.`, continue and recursively capture every integer following a `.` -- Tag the resulting Int and List Int with XX. (see Index type below) -- Also, I'm not sure, but I think line 16 needs this type: -- dotDigit : List String -> Parser.Parser (Step (List Int) (List Int)) type Index = XXXXXX (Parser.Parser Int) | XX (Parser.Parser ( Int, List Int )) | Unknown String dotDigit : List String -> Parser.Parser (Step (List String) (List String)) dotDigit nums = let checkNum numsSoFar num = if String.length num > 0 then Loop (num :: numsSoFar) else Done (List.reverse numsSoFar) in succeed (checkNum nums) |. symbol "." |= (getChompedString <| chompWhile Char.isDigit) parseIndex = succeed identity |= Parser.int |. Parser.oneOf [ succeed XXXXXX |. Parser.end , succeed XX |. Parser.andThen (\value -> if value >= 1 && value <= 64 then Parser.loop [] dotDigit |> Parser.map (\digits -> ( value, digits )) else Parser.problem "out of range" ) ]