Skip to content

Instantly share code, notes, and snippets.

@oliver-batchelor
Created August 7, 2019 07:53
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 oliver-batchelor/f3514b6a5c5e58fb7f4ca30b709fa141 to your computer and use it in GitHub Desktop.
Save oliver-batchelor/f3514b6a5c5e58fb7f4ca30b709fa141 to your computer and use it in GitHub Desktop.
data ApplyKey b a where
F :: ApplyKey (a -> b)
A :: ApplyKey a
instance Reflex t => Apply (Event t) where
evf <.> evx = fmapMaybe fromDMap e' where
e' merge (DMap.fromList [F :=> evf, A :=> evx])
fromDMap m = case (DMap.lookup F m, DMap.lookup A m) of
(Just (Identity f), Just (Identity a)) -> Just (f a)
_ -> Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment