[Haskell-cafe] Proposal: Non-recursive let

Andreas Abel andreas.abel at ifi.lmu.de
Mon Jul 22 16:24:55 CEST 2013


On 22.07.2013 10:50, MigMit wrote:
>
> On Jul 22, 2013, at 12:27 PM, Andreas Abel <andreas.abel at ifi.lmu.de>
> wrote:
>
>> On 20.07.13 9:36 PM, Evan Laforge wrote:
>>> However, I'm also not agitating for a non-recursive let, I think
>>> that ship has sailed.  Besides, if it were added people would
>>> start wondering about non-recursive where, and it would introduce
>>> an exception to haskell's pretty consistently order-independent
>>> declaration style.
>>
>> For functions, recursive-by-default let makes sense.  But for
>> *values*, intended recursion is rather the exception.  It is useful
>> for infinite lists and the like.  For values of atomic type like
>> Int or Bool, recursive let is a bug.
>
> It seems hard to distinguish between them. What about values that
> contain functions, like data T = T Int (Int -> Int)? What about
> polymorphic values, that could be functions and could be not?

I agree.  It cannot be implemented like that.  A thing that could be 
implemented is that

   let x = e

is an error if x appears strictly in e.  In practice, this could catch 
some unintended cases of recursion like

   let x = x +1

, but not all of them.

Cheers,
Andreas

-- 
Andreas Abel  <><      Du bist der geliebte Mensch.

Theoretical Computer Science, University of Munich
Oettingenstr. 67, D-80538 Munich, GERMANY

andreas.abel at ifi.lmu.de
http://www2.tcs.ifi.lmu.de/~abel/




More information about the Haskell-Cafe mailing list