Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Collection/mapCollection: preserve Discrete behavior of the mapped co…

…llection
  • Loading branch information...
commit 8932d5d6efe98b7bd68abe5d5aa5952d619fe3d2 1 parent d53382b
@JohnLato JohnLato authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 FRP/Euphoria/Collection.hs
View
7 FRP/Euphoria/Collection.hs
@@ -86,12 +86,13 @@ instance SignalSet (Collection k a) where
memoizeSignalSet (Collection dis)= Collection <$> memoD dis
+-- | Like 'fmap', but the Collection and interior 'Event' stream are memoized
mapCollection :: (a -> b) -> Collection k a -> SignalGen (Collection k b)
mapCollection f aC = do
- (cur,updateE) <- snapshotCollection aC
- let cur' = (fmap . fmap) f cur
+ updateE <- snd <$> snapshotCollection aC
+ newCurD <- memoD $ fmap ((fmap . fmap) f . fst) $ unCollection aC
newUpdateE <- memoE $ (fmap . fmap) f updateE
- Collection <$> (memoD $ pure (cur',newUpdateE))
+ makeCollection newCurD newUpdateE
-- | A collection whose items are created by an event, and removed by
-- another event.
Please sign in to comment.
Something went wrong with that request. Please try again.