<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def bind(self, func: Callable[[Any], 'Writer']) -> 'Writer': """Flat is better than nested. Haskell: (Writer (x, v)) >>= f = let (Writer (y, v')) = f x in Writer (y, v `append` v') """

        a, w = self.run()
        b, w_ = func(a).run()

        if isinstance(w_, Monoid):
            w__ = cast(Monoid, w).append(w_)
        else:
            w__ = w + w_

        return Writer(b, w__)