Skip to content

Instantly share code, notes, and snippets.

@pchiusano
Last active November 24, 2015 22:18
Show Gist options
  • Save pchiusano/2e7984cb0be47bda0cb4 to your computer and use it in GitHub Desktop.
Save pchiusano/2e7984cb0be47bda0cb4 to your computer and use it in GitHub Desktop.
Handy Reflex function for running IO actions
module ReflexHelpers where
import Control.Monad.IO.Class
import Reflex
import Reflex.Dom
evaluate :: (MonadWidget t m, Reflex t) => (a -> IO b) -> Event t a -> m (Event t b)
evaluate f actions = performEvent $ fmap (liftIO . f) actions
now :: (MonadWidget t m, Reflex t) => a -> m (Event t a)
now a = fmap (const a) <$> getPostBuild
@pchiusano
Copy link
Author

Updated with simpler implementation (than old revision) suggested by Ryan:

evaluate :: (MonadWidget t m, Reflex t) => (a -> IO b) -> Event t a -> m (Event t b)
evaluate f actions = performEvent $ fmap (liftIO . f) actions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment