Skip to content

Commit 40b8167

Browse files
committed
fix resize
1 parent cf7342a commit 40b8167

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/Test/QuickCheck/Gen.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import Control.Monad.Eff (Eff)
3737
import Control.Monad.Eff.Random (RANDOM)
3838
import Control.Monad.Rec.Class (class MonadRec, Step(..), tailRecM)
3939
import Control.Monad.State (State, runState, evalState)
40-
import Control.Monad.State.Class (state, modify)
40+
import Control.Monad.State.Class (state, get, modify)
4141
import Control.Monad.Gen.Class (class MonadGen)
4242
import Control.Lazy (class Lazy)
4343

@@ -83,7 +83,7 @@ instance monadGenGen :: MonadGen Gen where
8383
chooseInt = chooseInt
8484
chooseFloat = choose
8585
chooseBool = (_ < 0.5) <$> uniform
86-
resize f g = stateful \state -> resize (f state.size) g
86+
resize f g = sized \s -> resize (f s) g
8787
sized = sized
8888

8989
-- | Exposes the underlying State implementation.
@@ -118,7 +118,7 @@ sized f = stateful (\s -> f s.size)
118118

119119
-- | Modify a random generator by setting a new size parameter.
120120
resize :: forall a. Size -> Gen a -> Gen a
121-
resize sz g = Gen $ state \s -> runGen g s { size = sz }
121+
resize sz g = Gen $ fst <<< runGen g <<< (_ { size = sz }) <$> get
122122

123123
-- | Create a random generator which samples a range of `Number`s i
124124
-- | with uniform probability.

0 commit comments

Comments
 (0)