haskell-github-trust / ulid

Haskell implementation of ULIDs (Unique Lexicographically Sortable Identifiers)
http://hackage.haskell.org/package/ulid
BSD 3-Clause "New" or "Revised" License
32 stars 11 forks source link

Make default lowercase everywhere #16

Open ad-si opened 8 months ago

ad-si commented 8 months ago

https://endtimes.dev/why-lowercase-letters-save-data/

TheInnerLight commented 1 week ago

The Crockford spec says "When encoding, only upper case letters are used." so I wouldn't expect this to be the default behaviour.

ad-si commented 1 week ago

It also says:

When decoding, upper and lower case letters are accepted,

Which I read as "pick whatever style you prefer". His is upper-case, mine is lower-case.

ad-si commented 1 week ago

He also says that it should "be human readable". I think lowercase is much more readable, because characters have different heights and some even extend beyond the baseline and therefore it's much easier to keep track of where you are.

TheInnerLight commented 1 week ago

It also says:

When decoding, upper and lower case letters are accepted,

Which I read as "pick whatever style you prefer". His is upper-case, mine is lower-case.

The spec is very clear that you should:

When decoding, the library already calls toUpper (https://github.com/haskell-github-trust/ulid/blob/b80ae2c2f2cb7b0c9c29973c762135623df23413/src/Data/ULID/Base32.hs#L36C31-L36C38) so lower case ULIDs would be decoded correctly.

ad-si commented 1 week ago

You can not have a spec where any casing can be decoded, but then request that it is encoded in a certain way. Either you allow any casing or you don't. Therefore I'm considering it a personal preference of him. One I don't agree on that is.

TheInnerLight commented 1 week ago

You can not have a spec where any casing can be decoded, but then request that it is encoded in a certain way. Either you allow any casing or you don't. Therefore I'm considering it a personal preference of him. One I don't agree on that is.

You're absolutely welcome to disagree and have whatever personal preference you like but if you want to diverge from the spec in the implementation, I would suggest you should either:

FWIW, this is not unusual. In something as ubiquitous as the URI syntax spec (RFC 3986), the section on % encoding says (emphasis mine):

The uppercase hexadecimal digits 'A' through 'F' are equivalent to the lowercase digits 'a' through 'f', respectively. If two URIs differ only in the case of hexadecimal digits used in percent-encoded octets, they are equivalent. For consistency, URI producers and normalizers should use uppercase hexadecimal digits for all percent- encodings.