Skip to content

Commit 9a7e7cb

Browse files
committed
Add "renderWidget"
1 parent 14ec580 commit 9a7e7cb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Halogen/VDom/Types.purs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Halogen.VDom.Types
22
( VDom(..)
3+
, renderWidget
34
, Graft
45
, GraftX(..)
56
, graft
@@ -39,6 +40,15 @@ instance bifunctorVDom ∷ Bifunctor VDom where
3940
bimap f g (Grafted a) = Grafted (bimap f g a)
4041
bimap f g a = Grafted (graft (Graft f g a))
4142

43+
renderWidget a w x. (w VDom a x) VDom a w VDom a x
44+
renderWidget f = case _ of
45+
Text a → Text a
46+
Elem ns n a ch → Elem ns n a (map (renderWidget f) ch)
47+
Keyed ns n a ch → Keyed ns n a (map (map (renderWidget f)) ch)
48+
Widget w → f w
49+
Grafted g → Grafted $ unGraft (\(Graft fa fw v) →
50+
graft (Graft identity identity (renderWidget f (bimap fa fw v)))) g
51+
4252
foreign import data GraftType Type Type
4353

4454
instance functorGraftFunctor (Graft a) where

0 commit comments

Comments
 (0)