reflex-vty/src-bin/example.hs

28 lines
719 B
Haskell
Raw Normal View History

{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
import Control.Monad.IO.Class
import Data.Time
import qualified Graphics.Vty as V
import Reflex
import Reflex.Vty
guest :: forall t m. VtyApp t m
guest e = do
now <- liftIO getCurrentTime
ticks <- fmap show <$> tickLossy 1 now
let shutdown = fforMaybe e $ \case
V.EvKey V.KEsc _ -> Just ()
_ -> Nothing
picture <- hold (V.picForImage $ V.string mempty "Initial") $ V.picForImage . V.string mempty <$>
leftmost [show <$> e, show <$> ticks]
return $ VtyResult
{ _vtyResult_picture = picture
, _vtyResult_shutdown = shutdown
}
main :: IO ()
2018-02-27 19:46:13 +03:00
main = runVtyApp guest