<div dir="ltr"><div>It seems (surprisingly to me) that such pattern matches are allowed at the top level, so that would simplify my kludge a bit by skipping the definition of fg. But is using pairs (or the equivalent) in this way the only solution? I was hoping that there might be some kind of top-level definition syntax like</div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>{f .. = ... ; g .. = ...} where h .. = ...</div></blockquote> that would correctly capture the scoping I'm looking for.<br></div><div><br></div><div>--Todd</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 22, 2023 at 5:43 PM Jeff Clites <<a href="mailto:jclites@mac.com">jclites@mac.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div dir="ltr"></div><div dir="ltr">Can you do:</div><div dir="ltr"><br></div><div dir="ltr"> (f, g) = let f’ = … in (f’, g’)</div><div dir="ltr"><br></div><div dir="ltr">or is a pattern match not allowed at top level?</div><div dir="ltr"><br></div><div dir="ltr">Jeff</div><div dir="ltr"><br><blockquote type="cite">On Nov 22, 2023, at 4:40 PM, Todd Wilson <<a href="mailto:twilson@csufresno.edu" target="_blank">twilson@csufresno.edu</a>> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><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:0px 0px 0px 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>
<span>_______________________________________________</span><br><span>Haskell-Cafe mailing list</span><br><span>To (un)subscribe, modify options or view archives go to:</span><br><span><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></span><br><span>Only members subscribed via the mailman list are allowed to post.</span></div></blockquote></div></blockquote></div></div>