git.iko.soy/typeable/reflex-dom-extra
on master help sign in
add joinEE
commit2514d9d71974526d7a3f007621aea1f3f28c1b27 authorDmitry Olshansky <olshanskydr@gmail.com> dateThu 10 Nov 2022, 13:56 (4 years ago) parent67ce72a
2 files changed+10−4
reflex-dom-extra.cabal+1 src/Reflex/Dom/Extra.hs+9−4
reflex-dom-extra.cabal+1
@@ -21,6 +21,7 @@ library
2121 , jsaddle
2222 , lens
2323 , reflex-dom
24+ , semialign
2425 , text
2526 if impl(ghcjs)
2627 build-depends:
src/Reflex/Dom/Extra.hs+9−4
@@ -3,12 +3,15 @@ module Reflex.Dom.Extra where
33
44import Control.Lens
55import Control.Monad.Fix
6+import Data.Bitraversable
67import Data.Char
78import Data.Either
89import Data.Map as M
910import Data.Maybe
1011import Data.Text as T hiding (zip, map)
12+import Data.Zip as Z
1113import Language.Javascript.JSaddle
14+import Prelude hiding (zip, unzip, zipWith)
1215import Reflex.Dom
1316import JavaScript.Object.Internal as JS
1417
@@ -180,12 +183,14 @@ form :: DomBuilder t m => Map Text Text -> m a -> m a
180183form attrs = elAttr "form" attrs
181184
182185-- | Join event of event into single event.
183−joinE
184− :: (Reflex t, MonadHold t m)
185− => Event t (Event t a)
186− -> m (Event t a)
186+joinE :: (Reflex t, MonadHold t m) => Event t (Event t a) -> m (Event t a)
187187joinE = switchHold never
188188
189+joinEE
190+ :: (Reflex t, MonadHold t m)
191+ => Event t (Event t a, Event t b) -> m (Event t a, Event t b)
192+joinEE = bitraverse joinE joinE . Z.unzip
193+
189194-- | Separate an event to two sequences based on given predicate.
190195-- The first element of resulting pair keeps events for which the predicate
191196-- holds, the second -- those for which it doesn't.