[Haskell-cafe] What to call Occult Effects

Olaf Klinke olf at aatal-apotheke.de
Thu Nov 12 20:58:51 UTC 2020


> First, instead of `const id` I will use `const`, that is, we shall
> prove 
> 
> const = liftM2 const :: M a -> M b -> M a
> 
> which I believe should be equivalent to your property.

My belief was wrong, which is evident when using do-notation. 
Kim-Ee stated

do {_ <- b; x <- a; return x} = a

while I examined 

do {x <- a; _ <- b; return x} = a

Since do {x <- a; return x} = a holds for any monad, Kim-Ee's property
can be reduced to 

do {_ <- b; a} = a
or more concisely 
b >> a = a

which I called Kleisli-const in my previous post. As we seemed to have
settled for "occlusive" I suggest calling 
b >> a = a
"right-occlusive" or "occlusive from the right" because the right
action occludes the side-effects of the left action, and 
do {x <- a; _ <- b; return x} = a
should be called "left-occlusive" or "occlusive from the left" because
the left action hides the effect of the right action. Under
commutativity, both are the same but in general these might be
different properties. I do not have a distinguishing counterexample,
though, because all monads I come up with are commutative. 

David Feuer hinted at the possibility to define occlusiveness more
generally for Applicative functors. Commutativity might be stated for
Applicatives as 

liftA2 f a b = liftA2 (flip f) b a

So far I can only see two classes of occlusive monads: The reader-like
(Identity ~ Reader ()) and the set-like monads. 

Olaf



More information about the Haskell-Cafe mailing list