Skip to content

Commit

Permalink
Update Gen.hs
Browse files Browse the repository at this point in the history
  • Loading branch information
ocharles authored and moodmosaic committed May 19, 2023
1 parent b22b0fb commit a7369cd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hedgehog/src/Hedgehog/Internal/Gen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1192,12 +1192,12 @@ constant =
-- /The input list must be non-empty./
--
element :: (Foldable f, MonadGen m) => f a -> m a
element = \case
element fa = case toList fa of
[] ->
error "Hedgehog.Gen.element: used with empty list"
xs -> do
n <- integral $ Range.constant 0 (length xs - 1)
pure $ toList xs !! n
pure $ xs !! n

-- | Randomly selects one of the elements in the list.
--
Expand Down

0 comments on commit a7369cd

Please sign in to comment.