[Haskell-cafe] Language complexity & beginners

MigMit miguelimo38 at yandex.ru
Tue Feb 9 18:33:19 UTC 2016


I think that's the reason why Python doesn't have multi-line lambdas: Guido believed they aren't readable enough without giving them names. It's wrong for exactly the same reasons.

> On 09 Feb 2016, at 19:11, Joachim Durchholz <jo at durchholz.org> wrote:
> 
> Am 09.02.2016 um 18:24 schrieb Kosyrev Serge:
>>>>   foo (thInt (fromIntegral (c2hsValueInt cexp))) (thInt (fromIntegral (c2hsValueInt cexp)))
>>> 
>> I clearly made a mistake of duplicating a real expression.. should have
>> picked two different expressions for an example.
> 
> The counterexamples still work.
> 
> This:
> 
> foo (thInt1 (fromIntegral1 (c2hsValueInt1 cexp1))) (thInt2 (fromIntegral2 (c2hsValueInt2 cexp2)))
> 
> can still become this:
> 
> let int1 = thInt1 (fromIntegral1 (c2hsValueInt1 cexp1))
>    int2 = thInt2 (fromIntegral2 (c2hsValueInt2 cexp2))
> in foo int1 int2
> 
> and that's perfectly readable in my book.
> 
> If you don't like the nested parentheses, use function composition:
> 
> let fn1 = thInt1 . fromIntegral1 . c2hsValueInt1
>    fn2 = thInt2 . fromIntegral2 . c2hsValueInt2
> in foo (fn1 int1) (fn2 int2)
> 
> Function composition isn't the main tool though; I found that naming subexpressions always works, plus the names can help with readability if they are chosen wisely.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list