ocharles / virtual-dom

Haskell (GHCJS) bindings to the virtual-dom project
BSD 3-Clause "New" or "Revised" License
26 stars 6 forks source link

`into` and `with` are questionable wrt compositionality #3

Closed ocharles closed 7 years ago

ocharles commented 9 years ago

Consider the following

let section t = into div_ [into h1 [text t],into div_ []]
in into (section "Hello!") ["Hello, world!"]

It's probably expected that we get the following:

<div>
  <h1>Hello!</h1>
  <div>Hello, world!</div>
</div>

However, what we actually get is

<div>Hello, world!</div>

with and into set the immediate children of whatever they are given, whereas we'd really like the ability to "wrap up" a small tree and treat it as an atomic element. This might require a new combinator, but I'm hoping there's a way I can write the above and have it Just Work.