[Haskell-cafe] Mutual scoping question
Todd Wilson
twilson at csufresno.edu
Thu Nov 23 00:39:52 UTC 2023
Hello, Cafe:
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:
fg = let f ... = ... f,g,h ...
g ... = ... f,g,h ...
h ... = ... h ...
in (f,g)
f = fst fg
g = snd fg
but is there something more elegant than this that I'm not seeing?
Todd Wilson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20231122/5b0db048/attachment.html>
More information about the Haskell-Cafe
mailing list