[Haskell-cafe] Re: A bit of a shock - Memoizing functions
dave at zednenem.com
Fri Mar 27 18:11:15 EDT 2009
2009/3/27 Kirk Martinez <kirk.martinez at gmail.com>:
> It seems there is a very close correspondence between data structures and
> functions in Haskell. Your powersOfTwo function, since it gets memoized
> automatically (is this the case for all functions of zero arguments?), seems
> exactly like a data structure.
That's because it is. It's an array whose elements are computed on demand.
> This harks back to my Scheme days when we
> learned about the close relationship between code and data.
> I wonder: does the converse exist? Haskell data constructors which are
> really functions? How and for what might one use those?
Sure. You can use Church encoding to represent any Haskell data type
as a function.
Dave Menendez <dave at zednenem.com>
More information about the Haskell-Cafe