Skip to content

Instantly share code, notes, and snippets.

@epsilonhalbe
Created January 16, 2017 00:24
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 epsilonhalbe/e4dede0bf021b1209806d23f0feb5d7a to your computer and use it in GitHub Desktop.
Save epsilonhalbe/e4dede0bf021b1209806d23f0feb5d7a to your computer and use it in GitHub Desktop.
listWidget :: MonadWidget t m => m ()
listWidget = do
rec oldlist :: Dynamic t [Event t Int]
<- simpleList newlist ((sample . current) >=> button')
clicked :: Event t Int <- leftmost <$> (sample $ current oldlist)
newlist :: Dynamic t [Int] <- holdDyn [0..10] ((enumFromTo 0 . succ) <$> clicked)
val :: Dynamic t Int <- (holdDyn 0 clicked)
divClass "container" $ (dynText $ fmap (("Last clicked value: " <>) . pack . show) val)
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment