Proofs
In this blog post, Tekmo makes the point that we can prove that ExitSuccess exits because (I presume) it's like the Const functor for that constructor (it doesn't carry the x so fmap behaves like const).
With the operational package, Tekmo's TeletypeF might be translated something like this:
data TeletypeI a where
PutStrLn :: String -> TeletypeI ()
GetLine :: TeletypeI String
ExitSuccess :: TeletypeI ()
I've read that operational is isomorphic to a free monad, but can we prove here that ExitSuccess exits? It seems to me that it suffers from exactly the same problem as exitSuccess :: IO () does, and in particular if we were to write an interpreter for it, we'd need to write it like as if it didn't exit:
eval (ExitSuccess :>>= _) = exitSuccess
Compare to the free monad version which doesn't involve any pattern wildcard:
run (Free ExitSuccess) = exitSuccess
Laziness
In the Operational Monad Tutorial apfelmus mentions a drawback:
The state monad represented as s -> (a,s) can cope with some infinite programs like
evalState (sequence . repeat . state $ \s -> (s,s+1)) 0whereas the list of instructions approach has no hope of ever handling that, since only the very last Return instruction can return values.
Is this true for free monads as well?
Free (Coyoneda f),Coyoneda fis isomorphic tof, soFree (Coyoneda f)is isomorphic toFree f. – Edward KMETT Jan 12 '13 at 21:26Coyoneda Const a ~= Identity a, which is not isomorphic toConst a. – Heinrich Apfelmus Jan 13 '13 at 9:41Coyoneda (Const m) ais isomorphic toConst m awhich is isomorphic tom. – Edward KMETT Jan 17 '13 at 17:35data Foo a = Foofunctor thenCoyoneda Foo a = exists b. (b -> a, Foo)which doesn't give you an extra element, since you don't have abto call the function with. – Edward KMETT Jan 17 '13 at 17:48