TSFoster/elm-uuid

function to create the nil uuid

Closed this issue · 3 comments

I am using an older version of your library and using the nil uuid as a placeholder. I would like to upgrade to the newest version but I still need the nil uuid. Is there a way to generate it? If possible I would like to avoid changing every UUID to Maybe UUID

Hi,

Leaving the nil UUID out of the package was very intentional, and I feel pretty good about that decision so far. As you said, it's basically a placeholder, and I think that allowing the nil UUID to be a valid UUID provides a place for bugs to lurk. I think it's a lot more useful to be able to assume that any given UUID is intentioned to actually be able to identify an object. It also saves having to remember to check everywhere you handle a UUID that the given value is not nil.

I am open to arguments for changing the API of this package, including how the nil UUID is handled, but at the moment I am strongly for disallowing the nil UUID as a value. The package still provides plenty of functions for dealing with the nil UUID, as well as an Error case, IsNil.

I don't want to make any assumptions about your requirements or preferences are, or to think I can give you any suggestions that are better than what you've already considered, but if what you're writing is publicly available, I'd love to have a look. I've never seen anybody use this package other than me, so it would be good to see how it is used "in the wild" 😃

Edit: accidentally pressed "comment & close" while trying to click the smiley face 😅

Hi,
I removed all occurrences of the nil uuid from my code. I had default template for records with a uuid field and I used it as a placeholder, only creating the real uuid when saving to the backend. You are right about it being a potential source of bugs though, and I probably should not have used it like it in the first place.

I think the way it is now is better.

I used your package in a few files for this project:
https://github.com/eniac314/murol2.0

Thanks, cool to see it being used, and glad the new version helped make an improvement :-)