network-uri
network-uri copied to clipboard
Why the : before the port in the URI record?
I see that putting a : character in front of the port is clearly intentional : https://github.com/haskell/network-uri/blob/master/Network/URI.hs#L602
Two questions:
- Could this be a Maybe Int instead of a string? Most URI implementations store this as an integer and it is far more convenient. Failing that..
- Why is there a : in front of the value? This makes it rather annoying to parse out.
-
I'm afraid that would be a too breaking change at this point. I agree that it would have been better.
-
I asked Graham Klyne, the original author of
Network.URI
, about this a while ago and he said thatThe inclusion of ":" in the scheme was, IIRC, to make recomposition of URIs and URI references from their components easier to do and more regular. I think there were some edge cases that became tricky to handle if the ":" was not part of the scheme.
The URI
module is quite crufty and we're really in need a of a modern replacement (faster, different data types, etc). I'm just keeping network-uri on life-support in the mean time, so don't expect any drastic improvements in this package.
I bumped my head on the same issue. If there's interest, @jonplussed and I are probably going to go off and make some minor type cleanups on a fork.
@twopoint718 see also #11
@twopoint718 I'd be interested in what yourself and @jonplussed are intending on doing. Are you planning on using Text
for URI processing, migrating away from String
?
@robstewart57 I was wondering if the port number should be a PortNumber
from the Network
package: https://hackage.haskell.org/package/network-2.6.0.2/docs/Network.html#t:PortNumber ? It seems that reading this as an Int
is weird. Why would someone want to add or subtract port numbers? My only idea was that very simple tweak.
@twopoint718 Note that PortNumber
implements Num
as well, so it doesn't solve that add/subtract problem.
@lfairy ah, I didn't see that! My intent behind the proposal was mostly for the documentation effect of using PortNumber
rather than Int
.