Created
June 27, 2015 17:42
-
-
Save munro/46ce80ad934cfb98a6aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-| | |
>>> uriToFTPPort <$> parseURI "ftp://foo:[email protected]:50021/hello" | |
Just 50021 | |
>>> uriToFTPPort <$> parseURI "ftp://foo:[email protected]/hello" | |
Just 21 | |
>>> uriToFTPPort <$> parseURI "ftp://192.168.1.11/hello" | |
Just 21 | |
-} | |
uriToFTPPort :: Num a => URI -> a | |
uriToFTPPort uri = port maybePort | |
where | |
port (Just (':' : portStr)) = read portStr | |
port _ = 21 | |
maybePort = uriPort <$> uriAuthority uri |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment