dunai-test 0.8.3 → 0.9.0
raw patch · 5 files changed
+84/−13 lines, 5 filesdep ~dunaiPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: dunai
API changes (from Hackage documentation)
Files
- CHANGELOG +12/−4
- dunai-test.cabal +2/−2
- src/FRP/Dunai/Debug.hs +11/−0
- src/FRP/Dunai/LTLFuture.hs +15/−0
- src/FRP/Dunai/LTLPast.hs +44/−7
CHANGELOG view
@@ -1,7 +1,15 @@+2022-08-21 Ivan Perez <ivan.perez@keera.co.uk>+ * Version bump (0.9.0) (#313).+ * Document module FRP.Dunai.Debug (#306).+ * Document module FRP.Dunai.LTLFuture (#307).+ * Document module FRP.Dunai.LTLPast (#310).+ * Re-format CHANGELOG for readability (#311).+ * Deprecate the function FRP.Dunai.LTLPast.prev (#312).+ 2022-06-21 Ivan Perez <ivan.perez@keera.co.uk>- * dunai-test.cabal: Version bump (0.8.3) (#302).+ * Version bump (0.8.3) (#302). 2022-04-21 Ivan Perez <ivan.perez@keera.co.uk>- * dunai-test.cabal: Version bump (0.8.2) (#280), declare changelog file- (#273), declare subdir of source-repository (#272).- * CHANGELOG: Add CHANGELOG file (#273).+ * Version bump (0.8.2) (#280).+ * Add CHANGELOG file (#273).+ * Declare subdir of source-repository in Cabal file (#272).
dunai-test.cabal view
@@ -30,7 +30,7 @@ build-type: Simple name: dunai-test-version: 0.8.3+version: 0.9.0 author: Ivan Perez maintainer: ivan.perez@keera.co.uk homepage: https://github.com/ivanperez-keera/dunai@@ -74,7 +74,7 @@ build-depends: base >= 4 && < 5- , dunai >= 0.5 && < 0.9+ , dunai >= 0.5 && < 0.10 , normaldistribution , QuickCheck
src/FRP/Dunai/Debug.hs view
@@ -1,3 +1,9 @@+-- |+-- Copyright : (c) Ivan Perez, 2017+-- License : BSD3+-- Maintainer : ivan.perez@keera.co.uk+--+-- Debug FRP networks by inspecting their behaviour inside. module FRP.Dunai.Debug where import Debug.Trace@@ -6,16 +12,21 @@ -- ** Debugging +-- | Monadic Stream Function that prints the value passing through using+-- 'trace'. traceMSF :: Monad m => Show a => MSF m a a traceMSF = traceMSFWith show +-- | Monadic Stream Function that prints the value passing through using+-- 'trace', and a customizable 'show' function. traceMSFWith :: Monad m => (a -> String) -> MSF m a a traceMSFWith f = arr (\x -> trace (f x) x) +-- | Execute an IO action at every step, and ignore the result. traceMSFWithIO :: (a -> IO b) -> MSF IO a a traceMSFWithIO f = arrM (\x -> f x >> return x)
src/FRP/Dunai/LTLFuture.hs view
@@ -1,6 +1,21 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE ScopedTypeVariables #-}+-- |+-- Copyright : (c) Ivan Perez, 2017+-- License : BSD3+-- Maintainer : ivan.perez@keera.co.uk+--+-- Future-time linear temporal logic implemented on top of monadic stream+-- functions.+--+-- This module can be used to define LTL-like predicates on Monadic Stream+-- Functions, and to evaluate them. The main entry point is the function+-- 'evalT', which takes a temporal predicate, and a stream of inputs, and+-- evaluates the predicate against the stream. Evaluation takes place at time+-- 0, although it is possible to express conditions on future samples.+--+-- /Disclaimer/: This is not necessarily the same as LTL. module FRP.Dunai.LTLFuture ( TPred(..) , tPredMap
src/FRP/Dunai/LTLPast.hs view
@@ -1,41 +1,56 @@ {-# LANGUAGE Arrows #-}--- | Past LTL using MSFs.+-- | Past-time LTL using MSFs. ----- Add assertions inside MSFs.+-- This module provides ways of defining past-, discrete-time temporal+-- predicates with MSFs. ----- There are two ways of adding assertions to MSFs: piping the results of--- Boolean-carrying MSFs into other MSFs, or wrapping MSFs into other MSFs--- (using combinators).+-- There are two ways of doing so: piping the results of Boolean-carrying MSFs+-- into other MSFs (Past-time LTL using MSFs), or wrapping MSFs into other MSFs+-- (Past-time LTL as MSF combinators). module FRP.Dunai.LTLPast where import Control.Monad.Trans.MSF.Maybe import Data.Maybe import Data.MonadicStreamFunction --- * Past LTL as MSFs+-- * Past-time linear temporal logic using MSFs. -- ** Propositional MSFs +-- | Output True when both inputs are True. andSF :: Monad m => MSF m (Bool, Bool) Bool andSF = arr (uncurry (&&)) +-- | Output True when at least one input is True. orSF :: Monad m => MSF m (Bool, Bool) Bool orSF = arr (uncurry (||)) +-- | Output True when the input is False. notSF :: Monad m => MSF m Bool Bool notSF = arr not +-- | Output True when the second input is True or the first one is False. impliesSF :: Monad m => MSF m (Bool, Bool) Bool impliesSF = arr $ \(i,p) -> not i || p -- ** Temporal MSFs +-- | Output True when every input up until the current time has been True.+--+-- This corresponds to Historically, or the past-time version of Globally+-- or Always. sofarSF :: Monad m => MSF m Bool Bool sofarSF = feedback True $ arr $ \(n,o) -> let n' = o && n in (n', n') +-- | Output True when at least one input up until the current time has been+-- True.+--+-- This corresponds to Ever, or the past-time version of Eventually. everSF :: Monad m => MSF m Bool Bool everSF = feedback False $ arr $ \(n,o) -> let n' = o || n in (n', n') +-- | Output True if the first element has always been True, or the second has+-- been True ever since the first one became False. untilSF :: (Functor m, Monad m) => MSF m (Bool, Bool) Bool untilSF = catchMaybe (untilMaybeB (feedback True $ arr cond))@@ -52,6 +67,9 @@ where n = o && i +-- | Output True if the input was True at the last time.+--+-- False at time zero. lastSF :: Monad m => MSF m Bool Bool lastSF = iPre False @@ -71,41 +89,60 @@ -- clarifyResult (Possibly x) = x -- clarifyResult (Definitely x) = x --- * Past LTL combinators+-- * Past-time linear temporal logic as MSF combinators. -- | A signal predicate is an MSF whose output is a Boolean value. type SPred m a = MSF m a Bool -- ** Propositional MSFs++-- | Output True at times when the input is False. notSF' :: Monad m => SPred m a -> SPred m a notSF' sf = sf >>> arr not +-- | Output True at times when both inputs are True. andSF' :: Monad m => SPred m a -> SPred m a -> SPred m a andSF' sf1 sf2 = (sf1 &&& sf2) >>> arr (uncurry (&&)) +-- | Output True at times when at least one of the inputs is True. orSF' :: Monad m => SPred m a -> SPred m a -> SPred m a orSF' sf1 sf2 = (sf1 &&& sf2) >>> arr (uncurry (||)) +-- | Output True at times when the first input stream is False or the second+-- one is True. implySF' :: Monad m => SPred m a -> SPred m a -> SPred m a implySF' sf1 sf2 = orSF' sf2 (notSF' sf1) -- ** Temporal MSFs +-- | Output True at a time if the input has always been True up until that+-- time.+--+-- This corresponds to Historically, or the past-time version of Globally+-- or Always. history' :: Monad m => SPred m a -> SPred m a history' sf = feedback True $ proc (a, last) -> do b <- sf -< a let cur = last && b returnA -< (cur, cur) +-- | Output True at a time if the input has ever been True up until that+-- time.+--+-- This corresponds to Ever, or the past-time version of Eventually. ever' :: Monad m => SPred m a -> SPred m a ever' sf = feedback False $ proc (a, last) -> do b <- sf -< a let cur = last || b returnA -< (cur, cur) +-- | Output True at a time if the input at the last time was True. prev' :: Monad m => SPred m a -> SPred m a prev' = prev True +-- | Delay output of an MSF by one sample, using the provided argument for the+-- first sample.+{-# DEPRECATED prev "This function is deprecated in dunai-test 0.9 and will be removed." #-} prev :: Monad m => b -> MSF m a b -> MSF m a b prev b sf = feedback b $ proc (a, last) -> do b <- sf -< a