File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 1
1
module Halogen.VDom.Types
2
2
( VDom (..)
3
+ , renderWidget
3
4
, Graft
4
5
, GraftX (..)
5
6
, graft
@@ -39,6 +40,18 @@ instance bifunctorVDom ∷ Bifunctor VDom where
39
40
bimap f g (Grafted a) = Grafted (bimap f g a)
40
41
bimap f g a = Grafted (graft (Graft f g a))
41
42
43
+ -- | Replaces "widgets" in the `VDom` with the ability to turn them into other
44
+ -- | `VDom` nodes.
45
+ -- |
46
+ -- | Using this function will fuse any `Graft`s present in the `VDom`.
47
+ renderWidget ∷ ∀ a b w x . (a → b ) → (w → VDom b x ) → VDom a w → VDom b x
48
+ renderWidget f g = case _ of
49
+ Text a → Text a
50
+ Elem ns n a ch → Elem ns n (f a) (map (renderWidget f g) ch)
51
+ Keyed ns n a ch → Keyed ns n (f a) (map (map (renderWidget f g)) ch)
52
+ Widget w → g w
53
+ Grafted gaw → renderWidget f g (runGraft gaw)
54
+
42
55
foreign import data Graft ∷ Type → Type → Type
43
56
44
57
instance functorGraft ∷ Functor (Graft a ) where
You can’t perform that action at this time.
0 commit comments