<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Here's what I get:<br><br>[michael@localhost ~]$ ghci<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>Prelude&gt; import Prelude hiding ((&gt;&gt;))<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;westondan@imageworks.com&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;westondan@imageworks.com&gt;<br>Subject: Re: [Haskell-cafe] Overriding a Prelude function?<br>To: "Ross Mellgren" &lt;rmm-haskell@z.odi.ac&gt;<br>Cc: "michael rice" &lt;nowgate@yahoo.com&gt;, "haskell-cafe@haskell.org" &lt;haskell-cafe@haskell.org&gt;<br>Date: Wednesday, April 22, 2009, 12:37 PM<br><br><div class="plainMail">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>&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 href="http://en.wikibooks.org/wiki/Haskell/Understanding_monads" target="_blank">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>&gt;&gt; <a ymailto="mailto:Haskell-Cafe@haskell.org" href="/mc/compose?to=Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a> &lt;mailto:<a ymailto="mailto:Haskell-Cafe@haskell.org" href="/mc/compose?to=Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a>&gt;<br>&gt;&gt; <a
 href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>&gt; <br><br></div></blockquote></td></tr></table><br>