Hello All I am following the tutorial at https://www.elm-tutorial.org/en/09-conclusion/01-improvements.html and trying to implement the improvement to delete things from my app.
For reference my complete code so far is at https://github.com/bencoveney/bencoveney.github.io - specifically src/Projects/Commands.elm This is the specific part I am finding difficult to make compile: deleteTask : ProjectId -> Task.Task Http.Error ProjectId deleteTask id = let body = Http.empty config = { verb = "DELETE" , headers = [ ( "Content-Type", "application/json" ) ] , url = projectUrl id , body = body } in Http.send Http.defaultSettings config |> Task.succeed id delete : ProjectId -> Cmd Msg delete id = deleteTask id |> Task.perform DeleteFail DeleteSuccess I am having problems making my DELETE request. My assumption is that in my deleteTask function I need to use the return of Http.send somehow so that the method behaves asynchronously properly - because the Http.send is the source of the async-ness. I have tried copying code from my examples earlier in the file but the problem is that I don't care about what the Http.send message gives back in return (I don't think my API even returns anything useful for the DELETE request anyway). I know what id i want to bundle up with the DeleteSuccess message because it was the input into the delete function but I can't work out how to use it. I have tried a few different things to make this work, each with different error messages. The current error message I am getting says: The right argument of (|>) is causing a type mismatch. 116| Http.send Http.defaultSettings config 117|> |> Task.succeed id (|>) is expecting the right argument to be a: Task.Task Http.RawError Http.Response -> a But the right argument is: Platform.Task a ProjectId Hint: I always figure out the type of the left argument first and if it is acceptable on its own, I assume it is "correct" in subsequent checks. So the problem may actually be in how the left and right arguments interact. So I guess my question is how would I go about making my delete function work, and more generally how do I figure this stuff out on my own in future? The error messages describe the problem perfectly (obviously my types are wrong) but I have no idea how to get from there to finding a working solution. What is a Task.Task and why isn't it the same as a Platform.Task? Apologies for the newbie question and thanks for any help anyone can give. Ben -- 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.
