State monads don't respect the monad laws in Haskell
Janis Voigtlaender
voigt@orchid.inf.tu-dresden.de
Thu, 16 May 2002 08:44:54 +0200
John Launchbury wrote:
>
> I watched with interest the discussion about the ravages of `seq`.
>
> In the old days, we protected uses of `seq` with a type class, to keep it at
> bay. There was no function instance (so no problem with the state monads, or
> lifting of functions in general), and the type class prevented interference
> with foldr/build.
> ...
Just a further remark: During discussion with Olaf about consequences of
`seq` for foldr/build, respectively his type-inference based
deforestation, I had the impression that there could very well be a
function instance for `seq` not interfering with shortcut deforestation,
provided this instance is restricted in the following way:
class Eval a where seq :: a -> b -> b
instance Eval d => Eval (c -> d)
I have no idea what would be a semantic justification for this instance
declaration, except that it allows use of `seq` on at least some
function types, but seems to outlaw all the critical cases where use of
`seq` falsifies the foldr/build-rule.
--
Janis Voigtlaender
http://wwwtcs.inf.tu-dresden.de/~voigt/
mailto:voigt@tcs.inf.tu-dresden.de