Experimental JSON decoding API

I’m really surprised that’s your impression! To me these are night-and-day different.

  • The first one says “You’re passing a String -> Decoder User function to <| but it expects an Int -> Decoder b function instead.” That tells me the \email -> function is taking a String where an Int is expected. I understand all of that!
  • The second one says “You’re passing a Decoder (Int -> b) when you should be passing a Decoder (String -> String -> Bool -> UserModel) instead.” In the previous example I know what a String -> Decoder User function is, and I can see at a glance that the \email -> anonymous function fits that description. In this one, which of these expressions is the Decoder (Int -> b) exactly? Which one is the Decoder (String -> String -> Bool -> UserModel)? What is the root mismatch here, Int ≠ String or Int ≠ String -> String -> Bool?

Granted, both errors are helpful in that they draw attention to the broken require. (The former has it on the first line of the error message; the latter has it on the last line.) It’s also certainly more helpful that the second one underlines the problematic thing.

But to me, I can only read one of these errors and actually understand what the types in the message are telling me - and I wrote both of the libraries in question! :sweat_smile:

2 Likes