Skip to content

Instantly share code, notes, and snippets.

@amalloy
Created February 13, 2018 19:17
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 amalloy/dfc8ee5769be6e20c1791d02df680cd2 to your computer and use it in GitHub Desktop.
Save amalloy/dfc8ee5769be6e20c1791d02df680cd2 to your computer and use it in GitHub Desktop.
instance Monad Signal where
return = pure
(Signal s) >>= f = Signal $ \t -> let Signal s' = f (s t)
in s' t
-- or, equivalently but less readably:
-- s >>= f = Signal $ join (func . f . func s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment