-

   rss_forum_sources_ru

 - e-mail

 

 -

 LiveInternet.ru:
: 29.07.2007
:
:
: 80

:


, 30 2021 . 00:22 +
korvin:
applegame @
, ! ? :
, , .

:facepalm: , -, .

    import Control.Applicative
    import Data.Time.Clock.POSIX (getPOSIXTime)
    data MyCoolIO a = MCIO (IO a)
    instance Functor MyCoolIO where
    fmap f (MCIO xIO) = MCIO $ fmap f xIO
    instance Applicative MyCoolIO where
    pure = MCIO . pure
    (MCIO fIO) <*> (MCIO xIO) = MCIO $ fIO <*> xIO
    instance Monad MyCoolIO where
    return = pure
    (MCIO xIO) >>= f = MCIO $ xIO >>= \x -> (let (MCIO r) = f x in r)
    (MCIO xIO) >> (MCIO yIO) = MCIO $ do
    now <- getPOSIXTime
    if even (round now) then xIO >> yIO
    else yIO >>= \y -> (xIO >> return y)
    myPutStrLn :: String -> MyCoolIO ()
    myPutStrLn s = MCIO $ putStrLn s
    myMain :: MyCoolIO () -> IO ()
    myMain (MCIO io) = io
    main = myMain $ do
    myPutStrLn "first"
    myPutStrLn "second"
    myPutStrLn "third"



applegame @
.

? , .


applegame @
, .

,
1) ,
2) ,
3) ,
4)

https://forum.sources.ru/index.php?showtopic=421266&view=findpost&p=3846987

:  

: [1] []
 

:
: 

: ( )

:

  URL