
Hi, I'm reading about the Lens package, and I'm scared by the imperative style that it enables. I know the limits of imperative programming, and despite the fact that lens are purely functional by themself, I'm scared about limits in readability of code. I'm afraid of writing "write-only" code. I guess I'm wrong, but I'd like to know your opinions. Giacomo

On Fri, May 24, 2013 at 9:15 PM, Giacomo Tesio
I know the limits of imperative programming, and despite the fact that lens are purely functional by themself, I'm scared about limits in readability of code. I'm afraid of writing "write-only" code.
Without any example or further details about the exact nature of this fear, I think it's really difficult for anyone to do this question justice. As a start, try divvying up the issue into syntax and semantics. Semantically, lenses remain purely functional, as you say. Syntax-wise, it appears problematic. One path forward is to flesh out what you mean by the latter. -- Kim-Ee

For example I'm scared by += a function compositions.
For example here
units.traversed.health -= 3
(from
http://www.haskellforall.com/2013/05/program-imperatively-using-haskell.html)
I've some difficult to grasp the type. I can calculate it (or ask ghci :-D)
, but it looks complex to grasp.
May be I'm just too new to Haskell tools... but... I fear that in the long
run, this could become unreadable.
Am I wrong?
Giacomo
On Fri, May 24, 2013 at 5:10 PM, Kim-Ee Yeoh
On Fri, May 24, 2013 at 9:15 PM, Giacomo Tesio
wrote: I know the limits of imperative programming, and despite the fact that lens are purely functional by themself, I'm scared about limits in readability of code. I'm afraid of writing "write-only" code.
Without any example or further details about the exact nature of this fear, I think it's really difficult for anyone to do this question justice.
As a start, try divvying up the issue into syntax and semantics. Semantically, lenses remain purely functional, as you say. Syntax-wise, it appears problematic. One path forward is to flesh out what you mean by the latter.
-- Kim-Ee
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On Fri, May 24, 2013 at 06:41:27PM +0200, Giacomo Tesio wrote:
For example I'm scared by += a function compositions.
For example here
units.traversed.health -= 3
(from http://www.haskellforall.com/2013/05/program-imperatively-using-haskell.html) I've some difficult to grasp the type. I can calculate it (or ask ghci :-D) , but it looks complex to grasp.
May be I'm just too new to Haskell tools... but... I fear that in the long run, this could become unreadable.
You could already do exactly the same thing without the lens package. It uses the State monad. The lens package just makes it much simpler to write this code. If you think that overuse of the State monad will lead to bad, unmaintainable code, you are right. But that has nothing to do with lenses. Lenses can also be used in many contexts which do not involve the State monad. -Brent

+= carries expectation of specific behavioural properties in popular
circles, making it a devious moniker. In an attempt to bridge programming
paradigms with Haskell this problem is common. There be dragons here:
Always question your assumptions about familiar names and symbols.
On 2013-05-24 11:15 AM, "Brent Yorgey"
On Fri, May 24, 2013 at 06:41:27PM +0200, Giacomo Tesio wrote:
For example I'm scared by += a function compositions.
For example here
units.traversed.health -= 3
(from
http://www.haskellforall.com/2013/05/program-imperatively-using-haskell.html )
I've some difficult to grasp the type. I can calculate it (or ask ghci :-D) , but it looks complex to grasp.
May be I'm just too new to Haskell tools... but... I fear that in the long run, this could become unreadable.
You could already do exactly the same thing without the lens package. It uses the State monad. The lens package just makes it much simpler to write this code.
If you think that overuse of the State monad will lead to bad, unmaintainable code, you are right. But that has nothing to do with lenses.
Lenses can also be used in many contexts which do not involve the State monad.
-Brent
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
participants (4)
-
Brent Yorgey
-
Darren Grant
-
Giacomo Tesio
-
Kim-Ee Yeoh