on develop help sign in
Add Num instance for Dynamic
6a450ddAli Abrar
src/Reflex/Class.hs+9
@@ -548,6 +548,15 @@ instance (Reflex t, Num a) => Num (Behavior t a) where
548 negate = fmap negate
548 negate = fmap negate
549 signum = fmap signum
549 signum = fmap signum
550
550
551+instance (Num a, Reflex t) => Num (Dynamic t a) where
552+ (+) = liftA2 (+)
553+ (*) = liftA2 (*)
554+ abs = fmap abs
555+ signum = fmap signum
556+ fromInteger = pure . fromInteger
557+ negate = fmap negate
558+ (-) = liftA2 (-)
559+
551instance (Reflex t, Semigroup a) => Semigroup (Behavior t a) where
560instance (Reflex t, Semigroup a) => Semigroup (Behavior t a) where
552 a <> b = pull $ liftM2 (<>) (sample a) (sample b)
561 a <> b = pull $ liftM2 (<>) (sample a) (sample b)
553 sconcat = pull . fmap sconcat . mapM sample
562 sconcat = pull . fmap sconcat . mapM sample