I want to create something like that :
<ul>
<li>menu1
<ul>
<li>sub-menu1</li>
</ul>
</li>
<li>menu2</li>
</ul>
So i write the following code using WebSharper :
let el =
UL [
LI [
Text "menu1"
UL [
LI [Text "sub-menu1"]
]
]
LI [Text "menu2"]
]
But it says that
UL [
LI [Text "sub-menu1"]
]
should have the type IPagelet
but currently have the type Element
.
Does anyone have an idea on how to put a text + something else under an li element using WebSharper ?
Edit: Just to say that I have a bug on stakc, I can't comment or accepted the answer of @Tarmil...
The issue here is that two elements in the same list, Text "menu1"
and UL [...]
, have types IPagelet
and Element
respectively. Element
is a subtype of IPagelet
, so this should work, but unfortunately the F# type inference has some difficulties with this situation. So you need to help it by casting UL [...]
to IPagelet
:
let el =
UL [
LI [
Text "menu1"
UL [
LI [Text "sub-menu1"]
] :> IPagelet
]
LI [Text "menu2"]
]
In fact, this problem would be eliminated if the combinators had type seq<IPagelet> -> Element
instead of seq<#IPagelet> -> Element
. We will probably change them to that in the future, but since it would be a breaking change, we're keeping it for the next major version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With