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 11module Halogen.VDom.Types
22 ( VDom (..)
3+ , renderWidget
34 , Graft
45 , GraftX (..)
56 , graft
@@ -39,6 +40,18 @@ 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+ -- | 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+
4255foreign import data Graft ∷ Type → Type → Type
4356
4457instance functorGraft ∷ Functor (Graft a ) where
You can’t perform that action at this time.
0 commit comments