Skip to content

Instantly share code, notes, and snippets.

@et4te
Created October 6, 2015 16:57
Show Gist options
  • Select an option

  • Save et4te/54272174040d1a76f9ff to your computer and use it in GitHub Desktop.

Select an option

Save et4te/54272174040d1a76f9ff to your computer and use it in GitHub Desktop.
Gives 'non-exhaustive pattern' in Basic at Console
listItemAttrDyn False =
"class" =: "list-item"
listItemAttrDyn True =
"class" =: "list-item highlight"
listItem :: (MonadWidget t m) => (String -> String) -> m (ListItem t)
listItem mkUrl = do
rec highlightDyn <- foldDyn (\a _ -> a) False highlightE
itemAttributesDyn <- mapDyn listItemAttrDyn highlightDyn
(li, deleteBtn) <- elDynAttr' "li" itemAttributesDyn $ do
el "span" $ do
text "UUID"
el "span" $ do
text "Label"
el "span" $ do
button "Delete"
let mouseOverE = fmap (const True) $ domEvent Mouseover li
let mouseOutE = fmap (const False) $ domEvent Mouseout li
let highlightE = mergeWith (\ _ _ -> True) [mouseOverE, mouseOutE]
return $ ListItem {
listItemClick = fmap (const $ mkUrl "/create") $ domEvent Click li
, listItemDelete = fmap (const $ mkUrl "/delete") deleteBtn
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment