Skip to content

Commit b7770e8

Browse files
committed
[sc-39872] Add new renderConcat to Array functions
1 parent 026e789 commit b7770e8

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/DOM/Erumu/Array.purs

+16-4
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,22 @@ in the array Msg type and used for routing during processing.
1717
module DOM.Erumu.Array
1818
( Msg(..)
1919
, render
20+
, renderConcat
2021
, renderLift
2122
, update
22-
, updateF
2323
, updateArrayWith
24+
, updateF
2425
) where
2526

2627
import Prelude
2728

29+
import DOM.Erumu.Types ((!), HTML, Return(..), UpdateResult, liftReturn, liftUpdate)
30+
import Data.Array (mapWithIndex, updateAt, (!!))
31+
import Data.FoldableWithIndex (foldMapWithIndex)
2832
import Data.Identity (Identity(..))
29-
import Data.Array (updateAt, mapWithIndex, (!!))
3033
import Data.Maybe (Maybe(..), fromMaybe)
31-
import Data.Traversable (sequence)
3234
import Data.Newtype (unwrap)
33-
import DOM.Erumu.Types ((!), HTML, Return(..), UpdateResult, liftReturn, liftUpdate)
35+
import Data.Traversable (sequence)
3436

3537
data Msg msg = Msg Int msg
3638

@@ -62,6 +64,16 @@ renderLift renderItem items =
6264
where
6365
renderIdx idx item = renderItem (Msg idx) idx item
6466

67+
renderConcat ::
68+
forall msg model.
69+
(model -> Array (HTML msg)) ->
70+
Array model ->
71+
Array (HTML (Msg msg))
72+
renderConcat renderItem items =
73+
foldMapWithIndex renderIdx items
74+
where
75+
renderIdx idx item = map (Msg idx) <$> (renderItem item)
76+
6577
update ::
6678
forall m msg model.
6779
Applicative m =>

0 commit comments

Comments
 (0)