new MonadRandom instance; and maintainership

Felipe Almeida Lessa felipe.lessa at gmail.com
Thu Apr 25 20:40:49 CEST 2013


So if r >= 1/2, then it loops?  Ouch!

On Thu, Apr 25, 2013 at 3:28 PM, Brent Yorgey <byorgey at seas.upenn.edu> wrote:
> On Thu, Apr 25, 2013 at 10:47:57AM -0400, Brent Yorgey wrote:
>> On Wed, Apr 24, 2013 at 02:38:01PM -0400, Brent Yorgey wrote:
>> > Hi all,
>> >
>> > I would like to add a derived MonadPlus instance for both Rand and
>> > RandT.  Also, since it seems that MonadRandom has no maintainer I
>> > propose to take on its maintainership.  Any
>> > comments/objections/etc. welcome.
>>
>> Also, ignore what I said about deriving an instance for Rand, that
>> does not make any sense. However, adding an instance for RandT does
>> still make sense.  A repository with the changes is here:
>>
>>   http://github.com/byorgey/MonadRandom
>>
>> I'll upload in a few days if no one objects.
>
> Puzzle time!  Can you explain the semantics of the following code
> (given a derived MonadPlus instance for RandT)?
>
>     maybeFail :: RandT StdGen Maybe ()
>     maybeFail = do
>       r <- getRandomR (0, 1 :: Double)
>       guard (r < 1/2)
>
>     succeed :: RandT StdGen Maybe ()
>     succeed = maybeFail `mplus` succeed
>
> I therefore rescind my proposal to add a MonadPlus instance for
> RandT.  However, I still volunteer to be the maintainer. =)
>
> -Brent
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries



-- 
Felipe.



More information about the Libraries mailing list