Tue Jul 24 20:48:13 EDT 2018

The point

is this:

integral :: (Num t, Causal f) => t -> f t -> f t
integral = close $ \s i -> (s + i, s)
counter s = integral s (pure 1)

class Applicative f => Causal f where
  close :: (s -> i -> (s, o)) -> s -> f i -> f o

and implement it in a way that all the machinery goes into f.

It doesn't look like this is possible.  So I'm removing it.
This is an entirely different problem.

That monad is in the way.