[Haskell-cafe] lecture notes for Finally Tagless - benefit of
explicit fix combinator
wren ng thornton
wren at freegeek.org
Sat Jun 19 22:03:35 EDT 2010
Günther Schmidt wrote:
> Hi Stephen,
> I'm glad I asked. This sure sounds more interesting than I had
> anticipated. Is this an old hat for your off-the-shelf haskeller or
> something only found in the more seasoned haskellers tool box?
> I think it's pretty much the first time I encounter it.
It depends on what kind of seasoning you take :)
Another use case which is really common is to use open recursion for
things like memoization. That is, if we write an open-recursive
function, using `fix` turns it into a normal recursive function but we
can use a different fixed-point combinator in order to memoize the
results. Luke Palmer has packaged up a version of this on Hackage.
You can perform similar tricks on the type level. Wouter Swierstra
combats the expression problem by using open recursion to build ad-hoc
union types. Whereas Tim Sheard uses a somewhat different version of
open recursion to create parameterized modules, with a specific use
case being to separate variables from structure in unification
More information about the Haskell-Cafe