frpnow-vty 0.2.0.0 → 0.2.0.1
raw patch · 3 files changed
+29/−8 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +5/−0
- frpnow-vty.cabal +3/−3
- src/Control/FRPNow/Vty.hs +21/−5
ChangeLog.md view
@@ -1,6 +1,11 @@ # Revision history for frpnow-vty +## 0.2.0.1 -- 2018-03-19++* Shutdown vty even if exceptions are thrown.+ ## 0.2.0.0 -- 2018-03-18+ * Added basic 'runNowVty' and 'runNowVtyPure' functions. * Added 'demos/Demo.hs' mostly copied from [vty's Demo.hs](https://github.com/jtdaugherty/vty/blob/6f4edc0228660fb407f48c070ba3cee8c7dc7615/demos/Demo.hs).
frpnow-vty.cabal view
@@ -2,10 +2,10 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: frpnow-vty-version: 0.2.0.0+version: 0.2.0.1 synopsis: Program terminal applications with vty and frpnow!-description: - This package allows you to create vty terminal +description:+ This package allows you to create vty terminal applications using frpnow's frp interface. . A demo executable is also included to show how to
src/Control/FRPNow/Vty.hs view
@@ -1,28 +1,44 @@+-- |+-- Module : Control.FRPNow.Vty+-- Copyright : (c) Jaro Reinders, 2018+-- License : GPL-3+-- Maintainer : jaro.reinders@gmail.com+--+-- This module provides interoperability of FRPNow and the vty terminal UI+-- library. module Control.FRPNow.Vty where import Control.FRPNow import qualified Graphics.Vty as Vty import Control.Monad (forever)+import Control.Exception (bracket) +-- | Alias for 'Vty.Event' to prevent name clash with 'Event'. type VEvent = Vty.Event +-- | Run a Now computation which produces a behavior of type Picture, and draw+-- that on the screen. runNowVty- :: Vty.Config+ :: Vty.Config -- ^ The vty configuration to use. -> (EvStream VEvent -> Now (BehaviorEnd Vty.Picture a))+ -- ^ A now computation that takes a stream of vty events and produces+ -- a behavior of pictures and an ending event. -> IO a-runNowVty conf m = do- vty <- Vty.mkVty conf+runNowVty conf m = bracket (Vty.mkVty conf) Vty.shutdown $ \vty -> runNowMaster $ do (evs, cbk) <- callbackStream async (forever (Vty.nextEvent vty >>= cbk)) (b `Until` e) <- m evs sync . Vty.update vty =<< sample b callIOStream (Vty.update vty) (toChanges b)- plan ((<$ sync (Vty.shutdown vty)) <$> e)+ pure e +-- | Like 'runNowVty', but does not allow IO. runNowVtyPure- :: Vty.Config+ :: Vty.Config -- ^ The vty configuration to use. -> (EvStream VEvent -> Behavior (BehaviorEnd Vty.Picture a))+ -- ^ A computation that takes a stream of vty events and produces+ -- a behavior of pictures and an ending event. -> IO a runNowVtyPure conf b = runNowVty conf (sample . b)