<div dir="ltr">I created a file with the dividedBy example from Chapter 8.5 of "Haskell Programming from first principles" :<div><div><br></div></div><div><div>dividedBy :: Integral a => a -> a -> (a, a)</div><div>dividedBy num denom = go num denom 0</div><div>  where go n d count</div><div>      | n < d = (count, n)</div><div>      | otherwise = go (n - d) d (count + 1)</div><div><br></div></div><div><br></div><div>I get the following error when I load into ghci:</div><div><br></div><div><div><div><div>$ ghci chapter8_5-IntegralDivision.hs </div><div>GHCi, version 8.2.1: <a href="http://www.haskell.org/ghc/">http://www.haskell.org/ghc/</a>  :? for help</div><div>Loaded GHCi configuration from /home/wink/.ghci</div><div>[1 of 1] Compiling Main             ( chapter8_5-IntegralDivision.hs, interpreted )</div><div><br></div><div>chapter8_5-IntegralDivision.hs:4:7: error:</div><div>    parse error (possibly incorrect indentation or mismatched brackets)</div><div>  |</div><div>4 |       | n < d = (count, n)</div><div>  |       ^</div><div>Failed, 0 modules loaded.</div><div>λ> </div></div></div></div><div><br></div><div><br></div><div>But if I put the "go" function on its own line:</div><div><br></div><div><div>dividedBy :: Integral a => a -> a -> (a, a)<br></div><div>dividedBy num denom = go num denom 0</div><div>  where</div><div>    go n d count</div><div>      | n < d = (count, n)</div><div>      | otherwise = go (n - d) d (count + 1)</div></div><div><br></div><div><br></div><div>It does compile:</div><div><br></div><div><div>$ ghci chapter8_5-IntegralDivision.hs </div><div>GHCi, version 8.2.1: <a href="http://www.haskell.org/ghc/" target="_blank">http://www.haskell.org/ghc/</a>  :? for help</div><div>Loaded GHCi configuration from /home/wink/.ghci</div><div>[1 of 1] Compiling IntegralDivision ( chapter8_5-IntegralDivision.hs, interpreted )</div><div>Ok, 1 module loaded.</div></div><div><br></div><div><br></div><div>Or I can put the "where" on the previous line:</div><div><br></div><div><div><div>dividedBy :: Integral a => a -> a -> (a, a)</div><div>dividedBy num denom = go num denom 0 where</div><div>    go n d count</div><div>      | n < d = (count, n)</div><div>      | otherwise = go (n - d) d (count + 1)</div></div></div><div><br></div><div><br></div><div>it also compiles:</div><div><br></div><div><div>$ ghci chapter8_5-IntegralDivision.hs </div><div>GHCi, version 8.2.1: <a href="http://www.haskell.org/ghc/">http://www.haskell.org/ghc/</a>  :? for help</div><div>Loaded GHCi configuration from /home/wink/.ghci</div><div>[1 of 1] Compiling Main             ( chapter8_5-IntegralDivision.hs, interpreted )</div><div>Ok, 1 module loaded.</div><div>λ> </div></div><div><br></div><div><br></div><div>Can someone shed light on what I've done wrong?</div><div><br></div><div>-- Wink</div></div>