-
Hi there, I have the following function that creates an offer. In case the call succeeds it returns the Aff<Guid> CreateOffer(Guid mandantId, string offerJson)
{
return Aff(async () =>
{
var content = new StringContent(immobilieJson, Encoding.UTF8, "application/json");
var response = await _httpClient.PostAsync($"api/offers/{mandantId}", content);
if (response.StatusCode == HttpStatusCode.OK)
{
return await response.Content.ReadFromJsonAsync<Guid>();
}
var errorContent = await response.Content.ReadAsStringAsync();
var error = Error.New((int)response.StatusCode, errorContent);
return FailAff<Guid>(error);
});
} Unfortunately, this code does not compile, and it has to do with the last return statement and/or the Error CS0411 : The type arguments for method Prelude.Aff<RT, A>(Func<RT, ValueTask>) cannot be inferred from the usage. As far as I understand it, I have to lift up a pure value into the effect space which I thought that Can anyone help me, please? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
Prelude.Aff
can't return non-exceptional errors, you should usePrelude.AffMaybe
for that. It expectsFin<A>
as return value, butPrelude.FailAff
returnsAff<A>
, so you have to usePrelude.FinFail
instead