-
Hi there, I am currently collecting experience with programming with side effects and hence with Problem #1: public Aff<IEnumerable<Unit>> Start(List<Customer> customers)
{
return customers.Map(cust =>
from _1 in LogInformation($"Processing {cust.Name}")
from result in ProcessCustomer(cust)
from _2 in SendResult(result)
select unit)
.Sequence();
}
Aff<Unit> LogInformation(string msg){}
Aff<ProcessResult> ProcessCustomer(Customer customer){}
Aff<Unit> SendResult(ProcessResult result){} Unfortunately, the compiler gives me an error telling me that for the Problem #2: The public class Processor
{
private Aff<ProcessResult> ProcessCustomer(Customer customer)
{
return
from inputFile in LoadInputFile(customer.Id)
from result in inputFile.Match( // <- Here it goes wrong
Succ: file => ProcessFile(file),
None: _ => NoFileFound(customer)
)
select result;
}
private Aff<ProcessResult> ProcessFile(string file) =>
from _1 in LogInformation($"Process {file}")
select new ProcessResult();
private Aff<ProcessResult> NoFileFound(Customer customer) =>
from _1 in LogInformation($"No file found for {customer.Name}")
select new ProcessResult();
private Aff<Option<string>> LoadInputFile(int id)
{
return default;
}
private Aff<Unit> LogInformation(string msg) =>
Aff<Unit>(() => default); // Log Info somehow...
}
public class ProcessResult
{
public string Description { get; set; } = string.Empty;
}
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
} So, if someone could help me to get this compiled I would really appreciate it. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
Sequence
overload forIEnumerable<Aff<T>>
. UseSequenceSerial
orSequenceParallel
Option.Match
isSome
notSucc