<html><head></head><body><div class="ydpb81d881yahoo-style-wrap" style="font-family:courier new, courier, monaco, monospace, sans-serif;font-size:13px;"><div></div>
<div dir="ltr" data-setdir="false">What about</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">let h ... = ... h ...</div><div dir="ltr" data-setdir="false">in let f ... = ... f,g,h ...</div><div dir="ltr" data-setdir="false"> g ... = ... f,g,h ...</div><div dir="ltr" data-setdir="false"> in ... (main body that uses f and g) ...</div><div><br></div><div dir="ltr" data-setdir="false">This makes the dependencies clear. h stands on its own, f and g use each other together with h, and the main body can use f, g, and h.</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">I believe what you wanted, however, was to express that the main body *cannot* (will not, should not) use h. This version does not express that.</div>
</div><div id="yahoo_quoted_0896897052" class="yahoo_quoted">
<div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
<div>
On Wednesday, November 22, 2023 at 07:40:25 PM EST, Todd Wilson <twilson@csufresno.edu> wrote:
</div>
<div><br></div>
<div><br></div>
<div><div id="yiv1415212935"><div dir="ltr">Hello, Cafe:<div><br></div><div>Is there a preferred way to define two top-level mutually recursive functions, f and g, that both use a common local function h such that h is (1) only defined once and (2) does not escape the scope of f and g? I suppose it could be done like this:</div><div><br></div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px;"><font face="monospace">fg = let f ... = ... f,g,h ...<br> g ... = ... f,g,h ...<br> h ... = ... h ...<br> in (f,g)<br></font><font face="monospace">f = fst fg<br>g = snd fg<br></font> </blockquote>but is there something more elegant than this that I'm not seeing?<br></div><div><br></div><div>Todd Wilson</div></div>
</div>_______________________________________________<br>Haskell-Cafe mailing list<br>To (un)subscribe, modify options or view archives go to:<br><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>Only members subscribed via the mailman list are allowed to post.</div>
</div>
</div></body></html>