Merge branch 'mem-leak'
This commit is contained in:
+5
-5
@@ -28,14 +28,14 @@ sec n = UTCTime (toEnum 0) (fromIntegral n)
|
||||
runPure :: Mealy Identity a b -> [a] -> [b]
|
||||
runPure _ [] = []
|
||||
runPure m (a : as) = case runIdentity (AFRP.runMealy m id fakeRequest a) of
|
||||
(b, m') -> b : runPure m' as
|
||||
Pair b m' -> b : runPure m' as
|
||||
|
||||
-- | Run a Mealy with a per-step wall clock (seconds since the day-0 epoch).
|
||||
runTimed :: Mealy Identity a b -> [(Integer, a)] -> [b]
|
||||
runTimed _ [] = []
|
||||
runTimed m ((s, a) : as) =
|
||||
case runIdentity (AFRP.runMealy m id (Request (sec s) utc nil) a) of
|
||||
(b, m') -> b : runTimed m' as
|
||||
Pair b m' -> b : runTimed m' as
|
||||
|
||||
-- | A minimal State monad for observing effectful arrows (e.g. whenA gating).
|
||||
newtype St a = St { unSt :: Int -> (a, Int) }
|
||||
@@ -59,7 +59,7 @@ runStEff m s0 as = go m s0 as
|
||||
go _ s [] = ([], s)
|
||||
go m' s (a : rest) =
|
||||
case unSt (AFRP.runMealy m' id fakeRequest a) s of
|
||||
((b, m''), s') -> let (bs, s'') = go m'' s' rest in (b : bs, s'')
|
||||
(Pair b m'', s') -> let (bs, s'') = go m'' s' rest in (b : bs, s'')
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "AFRP" $ do
|
||||
@@ -569,11 +569,11 @@ sampleSpec = describe "sample" $ do
|
||||
|
||||
-- | A stateless arrow carrying a fixed entity set, for testing propagation.
|
||||
subscribed :: S.Set T.Text -> Mealy Identity Int Int
|
||||
subscribed ents = Mealy ents $ \_ _ a -> pure (a, subscribed ents)
|
||||
subscribed ents = Mealy ents $ \_ _ a -> pure (Pair a (subscribed ents))
|
||||
|
||||
-- | Same as 'subscribed' but yields a function, for testing '<*>'.
|
||||
subscribedF :: S.Set T.Text -> Mealy Identity Int (Int -> Int)
|
||||
subscribedF ents = Mealy ents $ \_ _ a -> pure ((a +), subscribedF ents)
|
||||
subscribedF ents = Mealy ents $ \_ _ a -> pure (Pair (a +) (subscribedF ents))
|
||||
|
||||
entitiesSpec :: Spec
|
||||
entitiesSpec = describe "entities" $ do
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ import Data.Aeson (Value, object, (.=))
|
||||
import qualified Data.Text as T
|
||||
import Data.Time (UTCTime (..), utc)
|
||||
import Data.UUID (nil)
|
||||
import AFRP (Mealy (..), Request (..))
|
||||
import AFRP (Mealy (..), Pair (..), Request (..))
|
||||
import HomeAssistant.Controller (HASSEff (..), Service)
|
||||
|
||||
fakeRequest :: Request
|
||||
@@ -52,7 +52,7 @@ runHASS :: Mealy HASSEff a b -> [a] -> [(b, [Service])]
|
||||
runHASS _ [] = []
|
||||
runHASS m (a : as) =
|
||||
case runAcc (runMealy m interp fakeRequest a) [] of
|
||||
((b, m'), svcs) -> (b, svcs) : runHASS m' as
|
||||
(Pair b m', svcs) -> (b, svcs) : runHASS m' as
|
||||
|
||||
services :: [(b, [Service])] -> [[Service]]
|
||||
services = map snd
|
||||
|
||||
Reference in New Issue
Block a user