@@ -0,0 +1,122 @@
1+# Reflex Quick Reference
2+
3+Note that function signatures have been simplified by removing most typeclass constraints.
4+
5+Functions annotated with "[ ]" are *pure*: They operate on Events, Behaviors, or Dynamics uniformly without regard to the "current time".
6+
7+Other functions must operate in some monadic context, because they produce a result "as of now". Functions annotated with "[H]" run in any monad supporting MonadHold. For Reflex-Dom users, this will typically be MonadWidget. Functions with "[S]" (of which there is only one) operate in MonadSample. Again, for Reflex-Dom users this is likely MonadWidget (because any MonadHold context also supports MonadSample).
8+
9+### Functions producing Event
10+
11+```haskell
12+-- Trivial Event
13+[ ] never :: Event t a
14+-- Extract Event from Dynamic
15+[ ] updated :: Dynamic t a -> Event t a
16+-- Transform Event to Event using function
17+[ ] fmap :: (a -> b) -> Event t a -> Event t b
18+[ ] fmapMaybe :: (a -> Maybe b) -> Event t a -> Event t b
19+[ ] ffor :: Event t a -> (a -> b) -> Event t b
20+[ ] fforMaybe :: Event t a -> (a -> Maybe b) -> Event t b
21+[ ] ffilter :: (a -> Bool) -> Event t a -> Event t a
22+[ ] splitE :: Event t (a, b) -> (Event t a, Event t b)
23+-- Event to identical Event with debug trace.
24+[ ] traceEvent :: Show a => String -> Event t a -> Event t a
25+[ ] traceEventWith :: (a -> String) -> Event t a -> Event t a
26+-- Transform Event to Event by sampling Behavior or Dynamic
27+[ ] tag :: Behavior t b -> Event t a -> Event t b
28+[ ] tagDyn :: Dynamic t a -> Event t b -> Event t a
29+[ ] gate :: Behavior t Bool -> Event t a -> Event t a
30+[ ] attach :: Behavior t a -> Event t b -> Event t (a, b)
31+[ ] attachDyn :: Dynamic t a -> Event t b -> Event t (a, b)
32+[ ] attachWith :: (a -> b -> c) -> Behavior t a -> Event t b -> Event t c
33+[ ] attachDynWith :: (a -> b -> c) -> Dynamic t a -> Event t b -> Event t c
34+[ ] attachWithMaybe :: (a -> b -> Maybe c) -> Behavior t a -> Event t b -> Event t c
35+[ ] attachDynWithMaybe :: (a -> b -> Maybe c) -> Dynamic t a -> Event t b -> Event t c
36+-- Combine multiple Events
37+[ ] <> :: Monoid a => Event t a -> Event t a -> Event t a
38+[ ] mergeWith :: (a -> a -> a) -> [Event t a] -> Event t a
39+[ ] leftmost :: [Event t a] -> Event t a
40+[ ] mergeList :: [Event t a] -> Event t (NonEmpty a)
41+[ ] merge :: GCompare k => DMap (WrapArg (Event t) k) -> Event t (DMap k)
42+[ ] mergeMap :: Ord k => Map k (Event t a) -> Event t (Map k a)
43+-- Unwrap Event-of-Event to Event
44+[ ] coincidence :: Event t (Event t a) -> Event t a
45+-- Unwrap Behavior-of-Event to Event
46+[ ] switch :: Behavior t (Event t a) -> Event t a
47+-- Unwrap Dyanmic-of-Event to Event
48+[ ] switchPromptlyDyn :: Dynamic t (Event t a) -> Event t a
49+-- Efficient one-to-many fanout
50+[ ] fan :: GCompare k => Event t (DMap k) -> EventSelector t k
51+[ ] fanMap :: Ord k => Event t (Map k a) -> EventSelector t (Const2 k a)
52+[ ] select :: EventSelector t k -> k a -> Event t a
53+-- Event to Event via monadic function
54+[ ] push :: (a -> m (Maybe b)) -> Event t a -> Event t b
55+[ ] pushAlways :: (a -> m b) -> Event t a -> Event t b
56+ -- Note supplied function operates in [H] context
57+-- Event to monadic Event
58+[H] headE :: Event t a -> m (Event t a)
59+[H] tailE :: Event t a -> m (Event t a)
60+[H] headTailE :: Event t a -> m (Event t a, Event t a)
61+-- Event-of-Event to monadic Event
62+[H] switchPromptly :: Event t a -> Event t (Event t a) -> m (Event t a)
63+```
64+
65+### Functions producing Behavior
66+
67+```haskell
68+-- Trivial Behavior
69+[ ] constant :: a -> Behavior t a
70+-- Extract Behavior from Dynamic
71+[ ] current :: Dynamic t a -> Behavior t a
72+-- Transform Behavior to Behavior using function
73+[ ] fmap :: (a -> b) -> Behavior t a -> Behavior t b
74+[ ] ffor :: Behavior t a -> (a -> b) -> Behavior t b
75+[ ] <*> :: Behavior t (a -> b) -> Behavior t a -> Behavior t b
76+[ ] >>= :: Behavior t a -> (a -> Behavior t b) -> Behavior t b
77+[ ] <> :: Monoid a => Behavior t a -> Behavior t a -> Behavior t a
78+-- Monadic value to Behavior
79+[ ] pull :: m a -> Behavior t a
80+ -- Note supplied value is in [S] context
81+-- Behavior to monadic value
82+[S] sample :: Behavior t a -> m a
83+-- Event to monadic Behavior
84+[H] hold :: a -> Event t a -> m (Behavior t a)
85+-- Unwrap Event-of-Behavior to monadic Behavior
86+[H] switcher :: Behavior t a -> Event t (Behavior t a) -> m (Behavior t a)
87+```
88+
89+### Functions producing Dynamic
90+
91+```haskell
92+-- Trivial Dynamic
93+[ ] constDyn :: a -> Dynamic t a
94+-- Construct monadic Dynamic from Event
95+[H] holdDyn :: a -> Event t a -> m (Dynamic t a)
96+[H] foldDyn :: (a -> b -> b) -> b -> Event t a -> m (Dynamic t b)
97+[H] foldDynM :: (a -> b -> m' b) -> b -> Event t a -> m (Dynamic t b)
98+ -- Note supplied function operates in [H] context
99+[H] count :: Num b => Event t a -> m (Dynamic t b)
100+[H] toggle :: Bool -> Event t a -> m (Dynamic t Bool)
101+-- Transform Dynamic to monadic Dynamic using function
102+[H] mapDyn :: (a -> b) -> Dynamic t a -> m (Dynamic t b)
103+[H] forDyn :: Dynamic t a -> (a -> b) -> m (Dynamic t b)
104+[H] mapDynM :: (a -> m' b) -> Dynamic t a -> m (Dynamic t b)
105+ -- Note supplied function runs in [S] context
106+[H] splitDyn :: Dynamic t (a, b) -> m (Dynamic t a, Dynamic t b)
107+-- Combine multiple Dynamics
108+[H] mconcatDyn :: Monoid a => [Dynamic t a] -> m (Dynamic t a)
109+[H] distributeDMapOverDyn :: GCompare k => DMap (WrapArg (Dynamic t) k) -> m (Dynamic t (DMap k))
110+[H] combineDyn :: (a -> b -> c) -> Dynamic t a -> Dynamic t b -> m (Dynamic t c)
111+-- Unwrap Dynamic-of-Dynamic to Dynamic
112+[ ] joinDyn :: Dynamic t (Dynamic t a) -> Dynamic t a
113+[ ] joinDynThroughMap :: Ord k => Dynamic t (Map k (Dynamic t a)) -> Dynamic t (Map k a)
114+-- Efficient one-to-many fanout
115+[ ] demux :: Ord k => Dynamic t k -> Demux t k
116+[H] getDemuxed :: Eq k => Demux t k -> k -> m (Dynamic t Bool)
117+-- Dynamic to Dynamic, removing Event occurrences w/o value change
118+[ ] nubDyn :: Eq a => Dynamic t a -> Dynamic t a
119+-- Dynamic to identical Dynamic with debug trace.
120+[ ] traceDyn :: Show a => String -> Dynamic t a -> Dynamic t a
121+[ ] traceDynWith :: (a -> String) -> Dynamic t a -> Dynamic t a
122+```