[Haskell-cafe] Proposal: Non-recursive let
Edward Kmett
ekmett at gmail.com
Mon Jul 22 16:54:35 CEST 2013
let x = x +1
is perfectly cromulent when x is sufficiently lazy, e.g. in the one point compactification of the naturals:
data Conat = S Conat | Z
There it represents infinity with proper sharing.
-Edward
On Jul 22, 2013, at 10:24 AM, Andreas Abel <andreas.abel at ifi.lmu.de> wrote:
> 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/
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list