Talk:Bruijndejx
Jump to navigation
Jump to search
I/O Monad
Maybe it can make a codensity monad to use as I/O monad (including the same definitions for fmap/return/join as codensity monads have):
stop = [*]; putZero = [[]0./]; putOne = [[]0.\]; getBit = [EOF 0.One 0.Zero 0.?];
In Haskell the corresponding thing would be like:
data BruijndejxIO = Stop | PutZero BruijndejxIO | PutOne BruijndejxIO | GetBit BruijndejxIO BruijndejxIO BruijndejxIO; data BruijndejxBit = Zero | One | EOF; type BruijndejxIO_Monad = Cont BruijndejxIO; stop = cont $ const Stop; putZero = cont $ \f -> PutZero (f ()); putOne = cont $ \f -> PutOne (f ()); getBit = cont $ \f -> GetBit (f Zero) (f One) (f EOF);