Skip to content

Instantly share code, notes, and snippets.

@oliver-batchelor
Created August 7, 2019 07:53
Show Gist options
  • Save oliver-batchelor/79b4e34a7e60ebc6c0fc7a4a8cd2805d to your computer and use it in GitHub Desktop.
Save oliver-batchelor/79b4e34a7e60ebc6c0fc7a4a8cd2805d 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