git.iko.soy/typeable/reflex-dom-extra
on master help sign in
add joinEE
2514d9dDmitry Olshansky
reflex-dom-extra.cabal+1
@@ -21,6 +21,7 @@ library
21 , jsaddle
21 , jsaddle
22 , lens
22 , lens
23 , reflex-dom
23 , reflex-dom
24+ , semialign
24 , text
25 , text
25 if impl(ghcjs)
26 if impl(ghcjs)
26 build-depends:
27 build-depends:
src/Reflex/Dom/Extra.hs+9−4
@@ -3,12 +3,15 @@ module Reflex.Dom.Extra where
3
3
4import Control.Lens
4import Control.Lens
5import Control.Monad.Fix
5import Control.Monad.Fix
6+import Data.Bitraversable
6import Data.Char
7import Data.Char
7import Data.Either
8import Data.Either
8import Data.Map as M
9import Data.Map as M
9import Data.Maybe
10import Data.Maybe
10import Data.Text as T hiding (zip, map)
11import Data.Text as T hiding (zip, map)
12+import Data.Zip as Z
11import Language.Javascript.JSaddle
13import Language.Javascript.JSaddle
14+import Prelude hiding (zip, unzip, zipWith)
12import Reflex.Dom
15import Reflex.Dom
13import JavaScript.Object.Internal as JS
16import JavaScript.Object.Internal as JS
14
17
@@ -180,12 +183,14 @@ form :: DomBuilder t m => Map Text Text -> m a -> m a
180form attrs = elAttr "form" attrs
183form attrs = elAttr "form" attrs
181
184
182-- | Join event of event into single event.
185-- | Join event of event into single event.
183−joinE
184− :: (Reflex t, MonadHold t m)
186+joinE :: (Reflex t, MonadHold t m) => Event t (Event t a) -> m (Event t a)
185− => Event t (Event t a)
186− -> m (Event t a)
187joinE = switchHold never
187joinE = switchHold never
188
188
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+
189-- | Separate an event to two sequences based on given predicate.
194-- | Separate an event to two sequences based on given predicate.
190-- The first element of resulting pair keeps events for which the predicate
195-- The first element of resulting pair keeps events for which the predicate
191-- holds, the second -- those for which it doesn't.
196-- holds, the second -- those for which it doesn't.