Conversation
| -- | `fromEnum bottom` and `fromEnum top`. | ||
| genBoundedEnum :: forall m a. MonadGen m => BoundedEnum a => m a | ||
| genBoundedEnum = | ||
| unsafePartial fromJust <<< toEnum |
There was a problem hiding this comment.
This unsafePartial is only safe if the Enum instance is valid, I think.
Another option is oneOf (bottom .. top), or something along those lines, right?
There was a problem hiding this comment.
This generator I lifted from QuickCheck actually, it was recently added there, so it suffers from any of the same problems that that one has.
Can you explain what you're thinking with oneOf (bottom .. top), I'm not sure I follow?
There was a problem hiding this comment.
It does say in the comment that toEnum must be well behaved too 😉
There was a problem hiding this comment.
By bottom .. top, I meant to say enumFromTo bottom top, which must be safe, I think.
There was a problem hiding this comment.
Ahh yeah, that'd work. It'll be kinda expensive if used for large enums, but can revisit if we have a case where it's obviously terrible. :)
|
How's this? A slight bias to |
|
👍 Thanks! |
No description provided.