First, for clarity, note that

   const id = flip const

Consider a (right-)occlusive functor. We immediately see that

liftA2 (flip const) m (pure x) = pure x

Using the Applicative laws, we can restate this:

x <$ m = pure x

We get the same sort of result for a left-occlusive effect.

So an occlusive effect can't have any *observable* side effects. It must be "read only".

On Thu, Nov 12, 2020, 3:59 PM Olaf Klinke <olf@aatal-apotheke.de> wrote:
> 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

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.