No, you still get the same issues caused by the seq
command, in that any monad used in the first argument of evaluate
will have its monad rules broken. Basing it off the rule in ertes's answer:
In the Kleisli category the monad gives rise to
return
is the identity morphism and(<=<)
is composition. Soreturn
must be an identity for(<=<)
:return <=< x = x
This means you should be able to replace return <=< x
with x
with any valid monad without changing the operation of the program.
Using that with the evaluate
function...
evaluate (return <=< undefined :: a -> Identity b) >> putStrLn "hello"
outputs hello. Using what should be an equivalent statement by replacing return <=< undefined
with undefined
:
evaluate (undefined :: a -> Identity b) >> putStrLn "hello"
instead causes an Prelude.undefined
exception.
This only happens with the evaluate function. Notice that return
has exactly the same type signature as evaluate
. If you replace evaluate
with return
in the above commands, the resulting action for both commands is the same (they output hello
).