Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upInt value implicitly converted to String? #479
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jan 12, 2016
Contributor
In a type correct program, id will have only one type. But your original program is not type correct. You use id as a String in one line, but as an Int in another line.
One could wish for the compiler to give you a clearer message about this. See elm/error-message-catalog#70 and related issues.
But the main point here is that no silent conversion happens (what you feared). There is no bug in compiler or libraries here, just an imperfect error message produced by the compiler.
|
In a type correct program, One could wish for the compiler to give you a clearer message about this. See elm/error-message-catalog#70 and related issues. But the main point here is that no silent conversion happens (what you feared). There is no bug in compiler or libraries here, just an imperfect error message produced by the compiler. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jan 12, 2016
Contributor
The way you should probably have written your function is:
deleteArtist : Int -> Task Http.Error ()
deleteArtist id =
Http.send Http.defaultSettings
{ verb = "DELETE"
, headers = []
, url = "http://localhost:4000/api/artists/" ++ toString id
, body = Http.empty
}
`andThen` (\_ -> Signal.send actions.address (DeleteArtist id))
`onError` (\error -> Signal.send actions.address NoOp)|
The way you should probably have written your function is: deleteArtist : Int -> Task Http.Error ()
deleteArtist id =
Http.send Http.defaultSettings
{ verb = "DELETE"
, headers = []
, url = "http://localhost:4000/api/artists/" ++ toString id
, body = Http.empty
}
`andThen` (\_ -> Signal.send actions.address (DeleteArtist id))
`onError` (\error -> Signal.send actions.address NoOp) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
simonewebdesign
Jan 12, 2016
Yes, that worked, thank you.
Looks like I got very confused by the error message, so it's probably worth improving it.
Alternatively I think would be nice to have an implicit toString call every time one tries to append some value to a String. But I don't know if that's feasible or even if makes sense at all.
simonewebdesign
commented
Jan 12, 2016
|
Yes, that worked, thank you. Alternatively I think would be nice to have an implicit |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jan 12, 2016
Contributor
Looks like I got very confused by the error message, so it's probably worth improving it.
Yes, that's what the issue in the https://github.com/elm-lang/error-message-catalog/ repo I linked to is about.
So can this issue here be closed?
Yes, that's what the issue in the https://github.com/elm-lang/error-message-catalog/ repo I linked to is about. So can this issue here be closed? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
simonewebdesign
commented
Jan 12, 2016
|
Sure, thanks again for the help :) |
simonewebdesign commentedJan 12, 2016
I'm using evancz/elm-http to send an HTTP request, here's the code:
I get a compile error:
I found a workaround, which is to move the
Http.Requestdetails to its own function and pass theidto it:I'm guessing that, in the first example,
++is somehow changing the parameter type toString.Is this expected behavior?
My expectation would be that the
idparameter remains of typeIntall the time.Thanks in advance for any clarification.