[Haskell-cafe] QuickCheck

Nickolay Kudasov nickolay.kudasov at gmail.com
Fri Nov 8 08:40:10 UTC 2013


Hi Tony,

​​Take a look at monad-loops package [1].
Seems like you reinvented a version of untilJust [2].
​​
Your version can be obtained by:

yourUntilJust :: (Monad m) => m a -> (a -> Maybe b) -> m
byourUntilJust m f = untilJust (liftM f m)

 Best,
Nick

[1] <http://hackage.haskell.org/package/monad-loops>
http://hackage.haskell.org/package/monad-loops
[2]
<http://hackage.haskell.org/package/monad-loops-0.4.2/docs/Control-Monad-Loops.html#v:untilJust>
http://hackage.haskell.org/package/monad-loops-0.4.2/docs/Control-Monad-Loops.html#v:untilJust
​


2013/11/8 Tony Morris <tonymorris at gmail.com>

> Hello,
> I have implemented a function for QuickCheck:
>
> untilJust :: Gen a -> (a -> Maybe b) -> Gen b
>
> I based it on the code for suchThat[1] and suchThatMaybe[2].
>
> I am wondering if I have potentially re-implemented an existing function
> in part or full. In other words, is there an easier way of achieving
> this function without pulling the generator apart as much as I have in
> this implementation: http://lpaste.net/95317
>
> [1]
> suchThat :: Gen a -> (a -> Bool) -> Gen a
>
> http://hackage.haskell.org/package/QuickCheck-2.6/docs/src/Test-QuickCheck-Gen.html#suchThat
>
> [2]
> suchThatMaybe :: Gen a -> (a -> Bool) -> Gen (Maybe a)
>
> http://hackage.haskell.org/package/QuickCheck-2.6/docs/src/Test-QuickCheck-Gen.html#suchThatMaybe
>
> --
> Tony Morris
> http://tmorris.net/
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20131108/d21021c9/attachment.html>


More information about the Haskell-Cafe mailing list