On Thu, Jan 1, 2009 at 1:31 PM, David Menendez <span dir="ltr"><<a href="mailto:dave@zednenem.com">dave@zednenem.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
2009/1/1 Luke Palmer <<a href="mailto:lrpalmer@gmail.com">lrpalmer@gmail.com</a>>:<br>
<div class="Ih2E3d">><br>
> So that's the answer: there already is a Strict monad. And an attempt to<br>
> make a lazier one strict just results in breaking the monad laws.<br>
<br>
</div>There is at least one transformer that will make a strict monad out of<br>
a non-strict monad.<br>
<br>
newtype CPS m a = CPS { unCPS :: forall b. (a -> m b) -> m b }</blockquote><div><br>I have heard this called the "codensity monad" (and it appears under that name in category-extras). Good observation.<br>
<br>In my reply I missed the important consideration of the strictness of (>>=), irrsepective of the values. While you can not force values to be strict in a monad without breaking a law, (>>=) is "up for grabs", and that's what people are referring to when they refer to strict and lazy monads. <br>
<br>So I guess "strict monad" means (>>= f) is strict for all f. Right?<br><br>Luke<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
> There's another answer though, regarding your question for why we don't just<br>
> use StrictT State instead of a separate State.Strict. This message is<br>
> already too long, and I suspect this will be the popular reply anyway, but<br>
> the short answer is that Strict State is called that because it is strict in<br>
> its state, not in its value.<br>
<br>
</div>No, Control.Monad.State.Strict and Control.Monad.State.Lazy never<br>
force evaluation of their states.<br>
<br>
Control.Monad.State.Strict> evalState (put undefined) '0'<br>
()</blockquote><div><br>My mistake. <br><br>Luke<br></div></div><br>