Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
- data ConnectionDetail a
- = IPv4Address a
- | IPv6Address a
- | HostName a
- type RemoteAddr = ConnectionDetail String
- isIPv4Address :: String -> Bool
- isIPv6Address :: String -> Bool
- hostAndPort :: String -> Either String (String, Maybe String)
- detailedHostAndPort :: String -> Either String (RemoteAddr, Maybe String)
- maybeHostAndPort :: String -> Maybe (String, Maybe String)
- defaultHostAndPort :: String -> String -> Maybe (String, String)
Documentation
data ConnectionDetail a Source
IPv4Address a | |
IPv6Address a | |
HostName a |
Eq a => Eq (ConnectionDetail a) | |
Ord a => Ord (ConnectionDetail a) | |
Show a => Show (ConnectionDetail a) |
type RemoteAddr = ConnectionDetail String Source
isIPv4Address :: String -> Bool Source
This function will validate ipv4 address and return True if string is valid adress
isIPv6Address :: String -> Bool Source
Function validates ipv6 address
detailedHostAndPort :: String -> Either String (RemoteAddr, Maybe String) Source
This function will parse it's argument and return either
String
(Left
) in case of error or (`ConnectionDetail String`, Maybe Port)
tuple (Right
).
Examples:
>>>
detailedHostAndPort "localhost"
Right (HostName "localhost",Nothing)>>>
detailedHostAndPort "[::1]:3030"
Right (IPv6Address "::1",Just "3030")>>>
detailedHostAndPort "127.0.0.1:1080"
Right (IPv4Address "127.0.0.1",Just "1080")
Since 0.2
maybeHostAndPort :: String -> Maybe (String, Maybe String) Source
Function will parse argument and return Maybe (Host, Maybe Port)
Examples:
>>>
maybeHostAndPort "192.168.10.12"
Just ("192.168.10.12",Nothing)>>>
maybeHostAndPort "192.168.10.12:7272"
Just ("192.168.10.12",Just "7272")
Function will take default port and connection string and returns Just (Host, Port) for valid input and Nothing for invalid.
Examples:
>>>
defaultHostAndPort "22" "my.server.com"
Just ("my.server.com","22")>>>
defaultHostAndPort "22" "my.otherserver.com:54022"
Just ("my.otherserver.com","54022")>>>
defaultHostAndPort "22" "porttobig.com:500022"
Nothing