on ebff8c6 help sign in
reflex-vty/src-bin/example.hs
27 lines 719 B history raw
1{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE GADTs #-}
3{-# LANGUAGE LambdaCase #-}
4{-# LANGUAGE RankNTypes #-}
6import Control.Monad.IO.Class
7import Data.Time
8import qualified Graphics.Vty as V
9import Reflex
10import Reflex.Vty
12guest :: forall t m. VtyApp t m
13guest e = do
14 now <- liftIO getCurrentTime
15 ticks <- fmap show <$> tickLossy 1 now
16 let shutdown = fforMaybe e $ \case
17 V.EvKey V.KEsc _ -> Just ()
18 _ -> Nothing
19 picture <- hold (V.picForImage $ V.string mempty "Initial") $ V.picForImage . V.string mempty <$>
20 leftmost [show <$> e, show <$> ticks]
21 return $ VtyResult
22 { _vtyResult_picture = picture
23 , _vtyResult_shutdown = shutdown
24 }
26main :: IO ()
27main = runVtyApp guest