I am learning elm, I've read the documentation and now I'm trying to annotate all the examples trying to explain what happens in each function.
This exercise is taking me quite some time to understand.
- What does the next type annotation mean? I get the first parameter is a
String
and the lastHtml
, but what about the middle one? Is it aResult
which is composed by aString
field and aList String
field?
view : String -> Result String (List String) -> Html
- Almost the same as the above, what does those nested types mean?
results : Signal.Mailbox (Result String (List String))
I'll leave the async bit for another question, many thanks in advance!
Result
abstracts an operation that could succeed or fail. It is defined asIf the operation succeeds the values will be
Ok value
, otherwise, if it fails, it will beErr error
. In your case, the suceed value will be a list of strings, while the error value will be a single message.For the second point, the thing is similar,
results
is a mailbox that contains aResult
, which will be eitherOk (List String)
orErr String