on develop help sign in
Add back fail method for before base 4.13
c2346caJohn Ericson
src/Reflex/Class.hs+3
@@ -663,6 +663,9 @@ instance Reflex t => Monad (Behavior t) where
663 a >>= f = pull $ sample a >>= sample . f
663 a >>= f = pull $ sample a >>= sample . f
664 -- Note: it is tempting to write (_ >> b = b); however, this would result in (fail x >> return y) succeeding (returning y), which violates the law that (a >> b = a >>= \_ -> b), since the implementation of (>>=) above actually will fail. Since we can't examine 'Behavior's other than by using sample, I don't think it's possible to write (>>) to be more efficient than the (>>=) above.
664 -- Note: it is tempting to write (_ >> b = b); however, this would result in (fail x >> return y) succeeding (returning y), which violates the law that (a >> b = a >>= \_ -> b), since the implementation of (>>=) above actually will fail. Since we can't examine 'Behavior's other than by using sample, I don't think it's possible to write (>>) to be more efficient than the (>>=) above.
665 return = constant
665 return = constant
666+#if !MIN_VERSION_base(4,13,0)
667+ fail = error "Monad (Behavior t) does not support fail"
668+#endif
666
669
667instance (Reflex t, Monoid a) => Monoid (Behavior t a) where
670instance (Reflex t, Monoid a) => Monoid (Behavior t a) where
668 mempty = constant mempty
671 mempty = constant mempty