title: Examples of "undoable" applicative functors?
body: <p>I declared a group on applicative functors. Judging by what we usually call &quot;actions&quot;, it seems that such group would enable the action to be <strong>undone</strong>:</p>
  <pre><code>import Control.Applicative
  
  class Alternative f =&gt; Undoable f where
      undo :: f a -&gt; f a
  </code></pre>
  <p>Being a group, for all <code>x :: Undoable f =&gt; f a</code>, the following laws shall satisfy:</p>
  <pre><code>x &lt;|&gt; undo x ≡ empty
  undo x &lt;|&gt; x ≡ empty
  </code></pre>
  <p>Some instances:</p>
  <pre><code>import Control.Arrow
  import Data.Functor.Compose
  import Data.Functor.Product
  import Data.Proxy
  
  instance Undoable Proxy where
      undo _ = Proxy
  
  instance (Undoable f, Applicative g) =&gt; Undoable (Compose f g) where
      undo (Compose x) = Compose (undo x)
  
  instance (Undoable f, Undoable g) =&gt; Undoable (Product f g) where
      undo (Pair x y) = Pair (undo x) (undo y)
  
  instance Undoable m =&gt; Undoable (Kleisli m a) where
      undo (Kleisli f) = Kleisli (undo . f)
  </code></pre>
  <p>At least for me, these instances are of no interest. Some non-instances include:</p>
  <ul>
  <li><p><code>Maybe</code>: Once successful, it will be always a success regardless of other options.</p>
  </li>
  <li><p><code>[]</code> and <code>ZipList</code>: Options always add nondeterminism, not subtract from it.</p>
  <ul>
  <li><code>ReadP</code> and <code>ReadPrec</code>: As implied by above.</li>
  </ul>
  </li>
  <li><p><code>IO</code>: Taken literally, this instance would be a time machine. Even though we may take the quotient of the reality over time-space, there is a practical counterexample: A new <code>IORef</code> cannot be forgotten.</p>
  </li>
  </ul>
  <p>Is there any particularly interesting instance of <code>Undoable</code>?</p>