-
Notifications
You must be signed in to change notification settings - Fork 56
Description
What I expect the signatures of these utilities to be:
-
random-fu
implements the random element utility asrandomElement :: [a] -> RVar a
, though it doesn't have to be that specifically. Maybe a morerandom
implementation would berandomElement :: RandomGen g => [a] -> g -> a
? -
shuffle :: RandomGen g => [a] -> g -> [a]
.
I know that there was an issue precisely about this about 3 years ago, but honestly, I think this should be heavily rethought.
These two functionalities are repeatedly provided and reimplemented in many other libraries, with a varying interface, which makes it all the more confusing whether it should be manually implemented by the user, or whether they should add in these libraries (which depend on random
anyway) just to use these 2 utilities that aren't in random
.
Forgive me if I'm making assumptions but this seems like this doesn't add many maintenance burdens, and makes dealing with randomness much easier than it is right now. This doesn't seem like it's introducing any sort of feature creep either, it's well within the scope of what random
does, or at least to me.
There are only a few criticisms of this in the other issue, mainly
- Too opinionated
- Performance and laziness
- Already implemented by other libraries
For the first point, I think that being opinionated in this scenario is the better option than not. So far many libraries have implemented this and we have an overview of how performant/convenient different approaches are. This is aside from the fact that no matter what implementation we choose, we'll be giving a better experience for people than they're having right now. With pretty much an imperceptible number of downsides. If the opinion we make for the user doesn't suit them, then at that point they can make it on their own.
For the second point, I think this is something that most Haskellers have come to expect. Yes, bottoms and laziness will affect implementations. Yes, using linked lists is not recommended as the most performant collection. Even only providing it for linked list will, again, improve people's situations.
For the third point, random
has already reimplemented behavior from other libraries. It seems to me way more than simply adding two utilities.
I'm not really a library maintainer, but as a Haskell programmer... To me, this addition is only an improvement, and it has no downsides.