on develop help sign in
Explain why there's no Functor instance of Dynamic
commit19777e9f918c9732662e1236fb9e078ceb22c01c authorMichael Snoyman <michael@snoyman.com> dateWed 6 Jan 2016, 20:22 (11 years ago) parent7cbc8dc
1 file changed+5
src/Reflex/Dynamic.hs+5
src/Reflex/Dynamic.hs+5
@@ -93,6 +93,11 @@ instance HBuild' (a ': l) r
9393-- | A container for a value that can change over time and allows notifications on changes.
9494-- Basically a combination of a 'Behavior' and an 'Event', with a rule that the Behavior will
9595-- change if and only if the Event fires.
96+--
97+-- Although @Dynamic@ logically has a 'Functor' instance, currently it can\'t
98+-- be implemented without potentially requiring the mapped function to be
99+-- evaluated twice. Instead, you can use 'mapDyn', which runs in a 'MonadHold'
100+-- instance, to achieve the same result.
96101data Dynamic t a
97102 = Dynamic (Behavior t a) (Event t a)
98103