<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>It seems like you need your write-state to be a monoid in order
      to infer a `MonadRandom` instance. Based on your code, I'm
      guessing the compiler can't infer that.<br>
      <br>
      Have a look at
<a class="moz-txt-link-freetext" href="https://hackage.haskell.org/package/MonadRandom-0.5.1.1/docs/Control-Monad-Random-Class.html#t:MonadRandom">https://hackage.haskell.org/package/MonadRandom-0.5.1.1/docs/Control-Monad-Random-Class.html#t:MonadRandom</a><br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 08/03/2018 07:31 AM, Sergiu Ivanov
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:87600rskm7.fsf@colimite.fr">
      <pre wrap="">Dear Café,

I would like to use random-fu to do some pseudo-random simulations for a
given StdGen (so that I can run the same simulation multiple times, if
needed).

The following works:

  testState :: StdGen -> Int
  testState = evalState (sampleRVar $ uniform 1 10)

The following doesn't:

  testRWS :: StdGen -> Int
  testRWS = fst . evalRWS (sampleRVar $ uniform 1 10) ()
  
I get

  <interactive>:2:26: error:
  • No instance for (MonadRandom (RWST () b0 StdGen Identity)) arising from a use of ‘sampleRVar’
  • In the first argument of ‘evalRWS’, namely ‘(sampleRVar $ uniform 1 10)’
  In the second argument of ‘(.)’, namely ‘evalRWS (sampleRVar $ uniform 1 10) ()’
  In the expression: fst . evalRWS (sampleRVar $ uniform 1 10) ()

Indeed, I do see a MonadRandom instance for StateT, but none for RWST [0].

Is there a reason to not have a MonadRandom instance for RWST?

Am I looking in the wrong place?

-
Sergiu

[0] <a class="moz-txt-link-freetext" href="https://hackage.haskell.org/package/random-source-0.3.0.6/docs/Data-Random-Source.html">https://hackage.haskell.org/package/random-source-0.3.0.6/docs/Data-Random-Source.html</a>
</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a>
Only members subscribed via the mailman list are allowed to post.</pre>
    </blockquote>
    <br>
    <div class="moz-signature">-- <br>
      <br>
      <br>
      <br>
      <strong
        style="color:#000;font-family:Helvetica,Arial;font-size:116%;">Vanessa
        McHale</strong><br>
      <span
        style="color:#000;font-family:Helvetica,Arial;font-size:100%;"><span
          style="color:#f00">Functional Compiler Engineer |</span>
        Chicago, IL</span>
      <br>
      <br>
      <span
        style="color:#999;font-family:Helvetica,Arial;font-size:85%;">Website:
        <a href="http://iohk.io" style="color:#f00;">www.iohk.io</a></span><br>
      <span
        style="color:#999;font-family:Helvetica,Arial;font-size:85%;">Twitter:
        @vamchale</span><br>
      <span
        style="color:#999;font-family:Helvetica,Arial;font-size:85%;">PGP
        Key ID: 4209B7B5</span><br>
      <br>
      <a href="http://iohk.io"><img
          src="https://static.iohk.io/logo/logo-email.png" alt="Input
          Output" height="46" width="200"></a>
      <br>
      <br>
      <a href="https://twitter.com/InputOutputHK"><img
          src="https://static.iohk.io/images/ic-tw.png" alt="Twitter"
          height="16" width="18"></a>
      <a href="https://github.com/input-output-hk"><img
          src="https://static.iohk.io/images/ic-gh.png" alt="Github"
          height="16" width="21"></a>
      <a href="https://www.linkedin.com/company/input-output-global"><img
          src="https://static.iohk.io/images/ic-li.png" alt="LinkedIn"
          height="16" width="19"></a>
      <br>
      <br>
      <br>
      <span
        style="color:#444;font-family:Helvetica,Arial;font-size:77%;"><small>This
          e-mail and any file transmitted with it are confidential and
          intended solely for the use of the recipient(s) to whom it is
          addressed. Dissemination, distribution, and/or copying of the
          transmission by anyone other than the intended recipient(s) is
          prohibited. If you have received this transmission in error
          please notify IOHK immediately and delete it from your system.
          E-mail transmissions cannot be guaranteed to be secure or
          error free. We do not accept liability for any loss, damage,
          or error arising from this transmission</small></span></div>
  </body>
</html>