Beginner thought process on type mismatch error

This is how interpret the error message:

“In the type annotation, you’ve said that this function can produce any type of message.

But in the function body, I see that this function only ever will produce messages of a type called Msg!

This means either:

  • That you have a misleading type annotation. It says any message, but only produces Msg messages. If so, change the type annotation to Msg instead of msg!
  • That you’ve accidentally used a specific message in this function, but you intended it to be generic. If so, replace SearchFor with something of a generic type!
9 Likes