[Haskell-cafe] Rebindable 'let' for observable sharing?

Bas van Dijk v.dijk.bas at gmail.com
Mon Feb 28 23:05:59 CET 2011


On 28 February 2011 10:38, Henning Thielemann
<lemming at henning-thielemann.de> wrote:
> Now that almost every syntax can be redirected to custom functions
> (RebindableSyntax, OverloadedStrings), would it make sense to map 'let'
> to 'fix' ?

For the record: are you talking about rewriting:

let f = e in b

into something like:

(\f -> e) `letin` (\f -> b)

where `letin` can be overloaded ("rebinded" is probably the better
term) and has the default implementation:

letin :: (a -> a) -> (a -> b) -> b
fe `letin` fb = fb (fix fe)

For example the following:

let fac = \n -> if n == 0
                then 1
                else n * fac (n-1)
in (fac 3, fac 5)

would be translated into:

(\fac -> \n -> if n == 0
               then 1
               else n * fac (n-1))
`letin`
(\fac -> (fac 3, fac 5))

Bas



More information about the Haskell-Cafe mailing list