Brent Yorgey | 24 Apr 20:38 2013

new MonadRandom instance; and maintainership

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.

-Brent
Brent Yorgey | 25 Apr 16:47 2013

Re: new MonadRandom instance; and maintainership

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.

-Brent
Brent Yorgey | 25 Apr 20:28 2013

Re: new MonadRandom instance; and maintainership

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. =)
(Continue reading)

Felipe Almeida Lessa | 25 Apr 20:40 2013
Picon

Re: new MonadRandom instance; and maintainership

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
(Continue reading)

Sjoerd Visscher | 26 Apr 00:02 2013

Re: new MonadRandom instance; and maintainership

Maybe a derived Alternative instance for RandT still makes sense?

Sjoerd

On Apr 25, 2013, at 8: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)
(Continue reading)

Felipe Almeida Lessa | 26 Apr 00:22 2013
Picon

Re: new MonadRandom instance; and maintainership

Wouldn't Alternative lead to the same bug?

On Thu, Apr 25, 2013 at 7:02 PM, Sjoerd Visscher <sjoerd <at> w3future.com> wrote:
> Maybe a derived Alternative instance for RandT still makes sense?
>
> Sjoerd
>
> On Apr 25, 2013, at 8: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 ()
(Continue reading)

Sjoerd Visscher | 26 Apr 00:30 2013

Re: new MonadRandom instance; and maintainership

Uhm, yeah, I forgot that you can still use monadic bind together with the Alternative methods.

Never mind me!

Sjoerd

On Apr 26, 2013, at 12:22 AM, Felipe Almeida Lessa <felipe.lessa <at> gmail.com> wrote:

> Wouldn't Alternative lead to the same bug?
> 
> On Thu, Apr 25, 2013 at 7:02 PM, Sjoerd Visscher <sjoerd <at> w3future.com> wrote:
>> Maybe a derived Alternative instance for RandT still makes sense?
>> 
>> Sjoerd
>> 
>> On Apr 25, 2013, at 8: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:
>>>> 
(Continue reading)

Brent Yorgey | 26 Apr 21:43 2013

Re: new MonadRandom instance; and maintainership

Right, the solution is that with RandT Maybe, upon failure the seed
gets thrown away.  That is, mplus runs both its arguments with the
same seed.  What I actually wanted was MaybeT Rand.  That requires a
MonadRandom instance for MaybeT, which I will add.

-Brent

On Fri, Apr 26, 2013 at 12:30:51AM +0200, Sjoerd Visscher wrote:
> Uhm, yeah, I forgot that you can still use monadic bind together with the Alternative methods.
> 
> Never mind me!
> 
> Sjoerd
> 
> On Apr 26, 2013, at 12:22 AM, Felipe Almeida Lessa <felipe.lessa <at> gmail.com> wrote:
> 
> > Wouldn't Alternative lead to the same bug?
> > 
> > On Thu, Apr 25, 2013 at 7:02 PM, Sjoerd Visscher <sjoerd <at> w3future.com> wrote:
> >> Maybe a derived Alternative instance for RandT still makes sense?
> >> 
> >> Sjoerd
> >> 
> >> On Apr 25, 2013, at 8: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
(Continue reading)


Gmane