Hi
I wanted to write
tableCell : a -> Html
tableCell data =
td [] [text (toString data)]
but I got an error so I had to write
tableCell : a -> Html b
tableCell data =
td [] [text (toString data)]
This makes sense because in the REPL we see
> td
<function> : List (Html.Attribute a) -> List (Html.Html a) -> Html.Html a
Now ignoring the fact that the type variable seems silly, even though I am
sure somewhere there is a good reason for it (yes, Html aliases
VirtualDom.Node), I was really baffled to find out in the Html module
itself that td was defined **without** the extra type variable! Straight
from the source:
{-| Represents a data cell in a table. -}
td : List Attribute -> List Html -> Html
td =
node "td"
In fact the documentation for the Html module is full of those kinds of
type signatures. So two questions:
1. How the heck did they get away with that?
2. Is there any way we can do this in our own code? I mean, I wanted to
just say the type of the tableCell function is `a -> Html`. The thing is
"just a node." What is the extra type variable for anyway? Like I say, I am
sure it is useful or necessary but it looks kinda weird. Why can't we just
have something that is "just a node"? If Html is not that thing, what is?
Thanks!
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.