Skip to content

Commit

Permalink
Small simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
meooow25 committed Oct 23, 2024
1 parent 7f4d14e commit 38a9c14
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions containers-tests/tests/Utils/ArbitrarySetMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module Utils.ArbitrarySetMap
import Control.Monad (liftM, liftM3, liftM4)
import Control.Monad.Trans.State.Strict
import Control.Monad.Trans.Class
import qualified Data.List as List
import Data.Maybe (fromMaybe)
import Test.QuickCheck

import Data.Set (Set)
Expand Down Expand Up @@ -68,13 +70,7 @@ mkArbSet step n
setFromList :: [a] -> Gen (Set a)
setFromList xs = flip evalStateT xs $ mkArbSet step (length xs)
where
step = do
xxs <- get
case xxs of
x : xs -> do
put xs
pure x
[] -> error "setFromList"
step = state $ fromMaybe (error "setFromList") . List.uncons

{--------------------------------------------------------------------
Map
Expand Down Expand Up @@ -117,11 +113,5 @@ mkArbMap step n
mapFromKeysList :: Arbitrary a => [k] -> Gen (Map k a)
mapFromKeysList xs = flip evalStateT xs $ mkArbMap step (length xs)
where
step = do
xxs <- get
case xxs of
x : xs -> do
put xs
pure x
[] -> error "mapFromKeysList"
step = state $ fromMaybe (error "mapFromKeysList") . List.uncons
{-# INLINABLE mapFromKeysList #-}

0 comments on commit 38a9c14

Please sign in to comment.