danyx23 / elm-uuid

Generate and parse UUIDs in Elm
BSD 3-Clause "New" or "Revised" License
48 stars 13 forks source link

Roundtripping through Uuid should normalize capitalization #2

Closed waldheinz closed 8 years ago

waldheinz commented 8 years ago

I'm using UUIDs as keys in a Dict. As it stands, Elm does not support sum types as Dict keys, so I'm forced to convert those UUIDs to String using the Uuid.fromString function. But this is not sufficient because

"1A571A57-0000-4000-B000-000000000000" |> Uuid.fromString |> Uuid.toString
    == "1A571A57-0000-4000-B000-000000000000"
-- and
"1a571a57-0000-4000-b000-000000000000" |> Uuid.fromString |> Uuid.toString
    == "1a571a57-0000-4000-b000-000000000000"

so the capitalization is preserved (which in my case makes Dict keys unequal which should be equal). But per RFC 4122:

Each field is treated as an integer and has its value printed as a zero-filled hexadecimal digit string with the most significant digit first. The hexadecimal values "a" through "f" are output as lower case characters and are case insensitive on input.

So both inputs should produce 1a571a57-0000-4000-b000-000000000000 as output.

danyx23 commented 8 years ago

Thank you for the report! I agree that fromString should force the internal representation to lower case. I will merge and publish this immediately.

danyx23 commented 8 years ago

Merged and published. Thank your for the PR!