<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">OK, I changed the operator from (&gt;&gt;) to (~&gt;&gt;). When I try to use it I get this:<br><br>[michael@localhost ~]$ ghci rand<br>GHCi, version 6.10.1: http://www.haskell.org/ghc/&nbsp; :? for help<br>Loading package ghc-prim ... linking ... done.<br>Loading package integer ... linking ... done.<br>Loading package base ... linking ... done.<br>[1 of 1] Compiling Main&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( rand.hs, interpreted )<br>Ok, modules loaded: Main.<br>*Main&gt; rollDie ~&gt;&gt; (rollDie ~&gt;&gt; rollDie)<br><br>&lt;interactive&gt;:1:0:<br>&nbsp;&nbsp;&nbsp; No instance for (Show (Seed -&gt; (Int, Seed)))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arising from a use of `print' at &lt;interactive&gt;:1:0-32<br>&nbsp;&nbsp;&nbsp; Possible fix:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; add an instance declaration for (Show (Seed
 -&gt; (Int, Seed)))<br>&nbsp;&nbsp;&nbsp; In a stmt of a 'do' expression: print it<br>*Main&gt; <br><br>Michael<br><br><br>--- On <b>Wed, 4/22/09, Luke Palmer <i>&lt;lrpalmer@gmail.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Luke Palmer &lt;lrpalmer@gmail.com&gt;<br>Subject: Re: [Haskell-cafe] Overriding a Prelude function?<br>To: "michael rice" &lt;nowgate@yahoo.com&gt;<br>Cc: "Ross Mellgren" &lt;rmm-haskell@z.odi.ac&gt;, "Dan Weston" &lt;westondan@imageworks.com&gt;, "haskell-cafe@haskell.org" &lt;haskell-cafe@haskell.org&gt;<br>Date: Wednesday, April 22, 2009, 5:02 PM<br><br><div id="yiv602338219"><div class="gmail_quote">On Wed, Apr 22, 2009 at 1:47 PM, michael rice <span dir="ltr">&lt;<a rel="nofollow" ymailto="mailto:nowgate@yahoo.com" target="_blank" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>&gt;</span> wrote:<br><blockquote
 class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit; -x-system-font: none;" valign="top">Here's what I get:<br><br>[michael@localhost ~]$ ghci<br>GHCi, version 6.10.1: <a rel="nofollow" target="_blank" href="http://www.haskell.org/ghc/">http://www.haskell.org/ghc/</a>&nbsp; :? for help<br>
Loading package ghc-prim ... linking ... done.<br>Loading package integer ... linking ... done.<br>Loading package base ... linking ... done.<br>Prelude&gt; import Prelude hiding ((&gt;&gt;))</td></tr></tbody></table></blockquote>
<div><br></div><div>You know, to avoid this nonsense you could just name the operator something else, like &gt;&gt;~, or ~&gt;&gt;, or $@**!. &nbsp;Operators are just names.</div><div><br></div><div>Luke</div><div>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit; -x-system-font: none;" valign="top"><br><br>&lt;interactive&gt;:1:0: parse error on input `import'<br>Prelude&gt; <br><br>=====<br><br>I was passing seed0 to rollDie and getting back (r1,seed1)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; passing seed1 to rollDie and getting back (r2,seed2)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; passing seed2 to rollDie and getting back (r3,seed3)<br><br>Just based on the problem text, I would guess that<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; passing rollDie and seed0 to (&gt;&gt;) I would get back (r3,seed3),<br>
losing the
 intermediate random numbers r1 and r2 along the way, at<br>least that's what I understood it to say.<br><br>So, I know that next I'm probably going to have to do something to <br>remedy that, but I haven't gotten to that next step yet. What is unsugar?<br>
<br>Thanks in advance for your patience.<br><br>Michael<br><br><br>--- On <b>Wed, 4/22/09, Dan Weston <i>&lt;<a rel="nofollow" ymailto="mailto:westondan@imageworks.com" target="_blank" href="/mc/compose?to=westondan@imageworks.com">westondan@imageworks.com</a>&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">
<br>From: Dan Weston &lt;<a rel="nofollow" ymailto="mailto:westondan@imageworks.com" target="_blank" href="/mc/compose?to=westondan@imageworks.com">westondan@imageworks.com</a>&gt;<br>Subject: Re: [Haskell-cafe] Overriding a Prelude function?<br>To: "Ross Mellgren" &lt;<a rel="nofollow" ymailto="mailto:rmm-haskell@z.odi.ac" target="_blank" href="/mc/compose?to=rmm-haskell@z.odi.ac">rmm-haskell@z.odi.ac</a>&gt;<br>
Cc: "michael rice" &lt;<a rel="nofollow" ymailto="mailto:nowgate@yahoo.com" target="_blank" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>&gt;, "<a rel="nofollow" ymailto="mailto:haskell-cafe@haskell.org" target="_blank" href="/mc/compose?to=haskell-cafe@haskell.org">haskell-cafe@haskell.org</a>" &lt;<a rel="nofollow" ymailto="mailto:haskell-cafe@haskell.org" target="_blank" href="/mc/compose?to=haskell-cafe@haskell.org">haskell-cafe@haskell.org</a>&gt;<br>
Date: Wednesday, April 22, 2009, 12:37 PM<br><br><div><div class="im">Be aware that the do unsugars to (Prelude.&gt;&gt;), not your (&gt;&gt;), even if you hide
 (Prelude.&gt;&gt;):<br><br>import Prelude hiding ((&gt;&gt;))<br>m &gt;&gt; f = error "Call me!"<br>main = putStrLn . show $ do [3,4]<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [5]<br><br>The desugaring of the do { [3,4]; [5] } is (Prelude.&gt;&gt;) [3,4] [5] = [5,5], whereas you might have hoped for [3,4] &gt;&gt; [5] = error "Call me!"<br>
<br>Dan<br><br>Ross Mellgren wrote:<br>&gt; I think<br>&gt; <br>&gt; import Prelude hiding ((&gt;&gt;))<br>&gt; <br>&gt; does that.<br>&gt; <br>&gt; -Ross<br>&gt; <br></div><div><div></div><div class="h5">&gt; On Apr 22, 2009, at 11:44 AM, michael rice wrote:<br>
&gt; <br>&gt;&gt; I've been working through this example from: <a rel="nofollow" target="_blank" href="http://en.wikibooks.org/wiki/Haskell/Understanding_monads">http://en.wikibooks.org/wiki/Haskell/Understanding_monads</a><br>&gt;&gt; <br>
&gt;&gt; I understand what they're doing all the way up to the definition of (&gt;&gt;), which duplicates Prelude
 function (&gt;&gt;). To continue following the example, I need to know how to override the Prelude (&gt;&gt;) with the (&gt;&gt;) definition in my file rand.hs.<br>&gt;&gt; <br>&gt;&gt; Michael<br>&gt;&gt; <br>&gt;&gt; ==============<br>
&gt;&gt; <br>&gt;&gt; [michael@localhost ~]$ cat rand.hs<br>&gt;&gt; import System.Random<br>&gt;&gt; <br>&gt;&gt; type Seed = Int<br>&gt;&gt; <br>&gt;&gt; randomNext :: Seed -&gt; Seed<br>&gt;&gt; randomNext rand = if newRand &gt; 0 then newRand else newRand + 2147483647<br>
&gt;&gt;&nbsp; &nbsp;&nbsp;&nbsp;where newRand = 16807 * lo - 2836 * hi<br>&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;(hi,lo) = rand `divMod` 127773<br>&gt;&gt; <br>&gt;&gt; toDieRoll :: Seed -&gt; Int<br>&gt;&gt; toDieRoll seed = (seed `mod` 6) + 1<br>&gt;&gt; <br>
&gt;&gt; rollDie :: Seed -&gt; (Int, Seed)<br>&gt;&gt; rollDie seed = ((seed `mod` 6) + 1, randomNext seed)<br>&gt;&gt; <br>&gt;&gt; sumTwoDice :: Seed -&gt; (Int,
 Seed)<br>&gt;&gt; sumTwoDice seed0 =<br>&gt;&gt;&nbsp;&nbsp;&nbsp;let (die1, seed1) = rollDie seed0<br>&gt;&gt;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;(die2, seed2) = rollDie seed1<br>&gt;&gt;&nbsp;&nbsp;&nbsp;in (die1 + die2, seed2)<br>&gt;&gt; <br>&gt;&gt; (&gt;&gt;) m n = \seed0 -&gt;<br>
&gt;&gt;&nbsp;&nbsp;&nbsp;let (result1, seed1) = m seed0<br>&gt;&gt;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;(result2, seed2) = n seed1<br>&gt;&gt;&nbsp;&nbsp;&nbsp;in (result2, seed2)<br>&gt;&gt; <br>&gt;&gt; [michael@localhost ~]$<br>&gt;&gt; <br>&gt;&gt; <br>&gt;&gt; _______________________________________________<br>
&gt;&gt; Haskell-Cafe mailing list<br></div></div>&gt;&gt; <a rel="nofollow" target="_blank" href="http://mc/compose?to=Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a> &lt;mailto:<a rel="nofollow" target="_blank" href="http://mc/compose?to=Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a>&gt;<div class="im">
<br>&gt;&gt; <a rel="nofollow" target="_blank" href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>&gt; <br><br></div></div></blockquote></td></tr></tbody></table><br>

      <br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a rel="nofollow" ymailto="mailto:Haskell-Cafe@haskell.org" target="_blank" href="/mc/compose?to=Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a rel="nofollow" target="_blank" href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br>
</div></blockquote></td></tr></table><br>