Skip to content

Instantly share code, notes, and snippets.

@crappygraphix
Created October 22, 2019 16:06
Show Gist options
  • Save crappygraphix/55a43a143e3e75b3466ec7f6808ca551 to your computer and use it in GitHub Desktop.
Save crappygraphix/55a43a143e3e75b3466ec7f6808ca551 to your computer and use it in GitHub Desktop.
Fun with dynamics
example
:: MonadWidget t m
=> Dynamic t Thing
-> m (Dynamic t ValidThing)
example dyThing =
return $ runMaybeT $ do -- the Dynamic monad
name <- lift (thing_name <$> dyThing)
-- Name must be non-empty
guard $ name /= ""
ValidThing <$> pure name
<*> lift (thing_property dyThing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment