Skip to content

Commit 38a9c14

Browse files
committed
Small simplification
1 parent 7f4d14e commit 38a9c14

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

containers-tests/tests/Utils/ArbitrarySetMap.hs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ module Utils.ArbitrarySetMap
1515
import Control.Monad (liftM, liftM3, liftM4)
1616
import Control.Monad.Trans.State.Strict
1717
import Control.Monad.Trans.Class
18+
import qualified Data.List as List
19+
import Data.Maybe (fromMaybe)
1820
import Test.QuickCheck
1921

2022
import Data.Set (Set)
@@ -68,13 +70,7 @@ mkArbSet step n
6870
setFromList :: [a] -> Gen (Set a)
6971
setFromList xs = flip evalStateT xs $ mkArbSet step (length xs)
7072
where
71-
step = do
72-
xxs <- get
73-
case xxs of
74-
x : xs -> do
75-
put xs
76-
pure x
77-
[] -> error "setFromList"
73+
step = state $ fromMaybe (error "setFromList") . List.uncons
7874

7975
{--------------------------------------------------------------------
8076
Map
@@ -117,11 +113,5 @@ mkArbMap step n
117113
mapFromKeysList :: Arbitrary a => [k] -> Gen (Map k a)
118114
mapFromKeysList xs = flip evalStateT xs $ mkArbMap step (length xs)
119115
where
120-
step = do
121-
xxs <- get
122-
case xxs of
123-
x : xs -> do
124-
put xs
125-
pure x
126-
[] -> error "mapFromKeysList"
116+
step = state $ fromMaybe (error "mapFromKeysList") . List.uncons
127117
{-# INLINABLE mapFromKeysList #-}

0 commit comments

Comments
 (0)