Skip to content

Instantly share code, notes, and snippets.

@lspitzner
Created September 24, 2018 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lspitzner/a0178ccb10a96f5bfa2517fa27844fef to your computer and use it in GitHub Desktop.
Save lspitzner/a0178ccb10a96f5bfa2517fa27844fef to your computer and use it in GitHub Desktop.
createLimitedList
:: (MonadHold t m, MonadFix m, Adjustable t m)
=> IntMapS.Key
-> Event t (m ())
-> m ()
createLimitedList elemLimit e = do
let f a (_, i) =
( PatchIntMap $ IntMapS.fromList [(i - elemLimit, Nothing), (i, Just a)]
, i + 1
)
d <- foldDyn f (mempty, 0) e
_ <- traverseIntMapWithKeyWithAdjust (\_ -> id) mempty $ fst <$> updated d
pure ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment