Is it possible to extend free monad interpreters?
问题 Given a free monad DSL such as: data FooF x = Foo String x | Bar Int x deriving (Functor) type Foo = Free FooF And a random interpreter for Foo : printFoo :: Foo -> IO () printFoo (Free (Foo s n)) = print s >> printFoo n printFoo (Free (Bar i n)) = print i >> printFoo n It appears to me that it should be possible to intersperse something into each iteration of printFoo without resorting to doing it manually: printFoo' :: Foo -> IO () printFoo' (Free (Foo s n)) = print s >> print "extra info"