Haskell Is Ipv 4 Adress
isIPv4Address :: String -> Bool
isIPv4Address s = length parts == 4 && all valid parts
  where
    parts = splitOn '.' s

    splitOn c str = foldr step [""] str
      where
        step ch acc@(cur : rest)
          | ch == c   = "" : acc
          | otherwise = (ch : cur) : rest

    valid p =
      not (null p)
        && all (`elem` ['0' .. '9']) p
        && case reads p :: [(Int, String)] of
             [(n, "")] -> n <= 255 && show n == p
             _         -> False

This splits the string by dots and validates each part as a normal IPv4 octet.