State monads don't respect the monad laws in Haskell
Dylan Thurston
dpt@math.harvard.edu
Wed, 15 May 2002 11:15:21 -0400
--huq684BweRXVnRxX
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Tue, May 14, 2002 at 12:32:30PM -0400, Jan-Willem Maessen wrote:
> Chalk me up as someone in favor of laws without exceptions.
Do you ever use floating point addition?
I rarely use floating point, but it is sometimes more useful than the
alternatives, as long as you bear in mind its limitations.
In general, programmers should be allowed to do unsafe things, as long
as they explicitly ask for it (by, say, using floating point). I
guess these monad laws are not such a case.
I'm very interested by your ideas to make Haskell better behaved:
=20
> ...
> That said, "seq" is a big wart on Haskell to begin with. I might be
> willing to allow "nice" rules like the monad laws to apply *as long as
> the results are not passed (directly or indirectly) to seq*. But I'm
> not willing to go from "the IO monad disobeys the laws in the presence
> of seq, and that might be OK" to "my monad disobeys the laws in code
> that never uses seq, and that's OK because even IO breaks the monad
> laws". And I'd really much rather we cleaned up the semantics of
> seq---or better yet, fixed the problems with lazy evaluation which
> make seq necessary in the first place. [Let me be clear: I believe
> hybrid eager/lazy evaluation, the subject of my dissertation, does
> eliminate the need for seq in most cases---so I'm a bit biased here.]
This sounds very interesting! Is your dissertation available?
My main complaint about Haskell at the moment is that it seems
remarkably difficult to avoid space leaks due to laziness issues; your
approach seems like a promising way to avoid that.
Best,
Dylan Thurston
--huq684BweRXVnRxX
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE84nuIVeybfhaa3tcRAlW9AJ9lVBq+YRKRWUH05oyPUyj0BJlH9gCeNazr
PRVJs/c8fR3CWRm2vWXZ/KA=
=32/P
-----END PGP SIGNATURE-----
--huq684BweRXVnRxX--