import Control.Applicative
data MyCoolIO a
= MCIO
(IO a
)
instance Applicative MyCoolIO where
pure = MCIO . pure
(MCIO fIO) <*> (MCIO xIO) = MCIO $ fIO <*> xIO
instance Monad MyCoolIO
where
(MCIO xIO) >>= f = MCIO $ xIO >>= \x -> (let (MCIO r) = f x in r)
(MCIO xIO
) >> (MCIO yIO
) = MCIO
$ yIO
>>= \y
-> (xIO
>> return y
)
myPutStrLn
:: String -> MyCoolIO
()
myMain
:: MyCoolIO
() -> IO ()myMain (MCIO io) = io
main = myMain $ do
myPutStrLn "first"
myPutStrLn "second"
myPutStrLn "third"
aW1wb3J0IENvbnRyb2wuQXBwbGljYXRpdmUKCmRhdGEgTXlDb29sSU8gYSA9IE1DSU8gKElPIGEpCgppbnN0YW5jZSBGdW5jdG9yIE15Q29vbElPIHdoZXJlCiAgZm1hcCBmIChNQ0lPIHhJTykgID0gIE1DSU8gJCBmbWFwIGYgeElPCgppbnN0YW5jZSBBcHBsaWNhdGl2ZSBNeUNvb2xJTyB3aGVyZQogIHB1cmUgPSBNQ0lPIC4gcHVyZQogIChNQ0lPIGZJTykgPCo+IChNQ0lPIHhJTykgID0gIE1DSU8gJCBmSU8gPCo+IHhJTwoKaW5zdGFuY2UgTW9uYWQgTXlDb29sSU8gd2hlcmUKICByZXR1cm4gPSBwdXJlCiAgCiAgKE1DSU8geElPKSA+Pj0gZiAgICAgICAgICA9ICBNQ0lPICQgeElPID4+PSBceCAtPiAobGV0IChNQ0lPIHIpID0gZiB4IGluIHIpCiAgKE1DSU8geElPKSA+PiAoTUNJTyB5SU8pICA9ICBNQ0lPICQgeUlPID4+PSBceSAtPiAoeElPID4+IHJldHVybiB5KQoKbXlQdXRTdHJMbiA6OiBTdHJpbmcgLT4gTXlDb29sSU8gKCkKbXlQdXRTdHJMbiBzID0gTUNJTyAkIHB1dFN0ckxuIHMKCm15TWFpbiA6OiBNeUNvb2xJTyAoKSAtPiBJTyAoKQpteU1haW4gKE1DSU8gaW8pID0gaW8KCm1haW4gPSBteU1haW4gJCBkbwogIG15UHV0U3RyTG4gImZpcnN0IgogIG15UHV0U3RyTG4gInNlY29uZCIKICBteVB1dFN0ckxuICJ0aGlyZCIK