I think it would be handy to let CellLoop.Loop return the Cell<T> itself instead of Unit.Default. Like that one can directly assign the return value to a readonly output cell property. Now it requires two statements, and that feels imperative to me.
A simple C# example I'm working on:
public sealed class SimpleTextCircuit : ISimpleTextOutputs
{
public Cell<string> Text { get; }
public Cell<bool> IsTextEmpty { get; }
public Cell<bool> CanReverseText { get; }
private SimpleTextCircuit(ISimpleTextInputs inputs)
{
var text = new CellLoop<string>();
var userText = inputs.SetText;
var clearText = inputs.ClearText.Map(_ => "");
var reverseText = inputs.ReverseText.Snapshot(text, (_, t) => SimpleTextRules.Reversed(t));
IsTextEmpty = text.Map(SimpleTextRules.IsTextEmpty);
CanReverseText = text.Map(SimpleTextRules.CanReverse);
// Very handy to Loop and assign in one go.
Text = text.Loop(userText.OrElse(clearText).OrElse(reverseText).Hold("")); ;
}
public static ISimpleTextOutputs Create(ISimpleTextInputs inputs)
{
return new SimpleTextCircuit(inputs);
}
}
I think it would be handy to let
CellLoop.Loop
return theCell<T>
itself instead ofUnit.Default
. Like that one can directly assign the return value to a readonly output cell property. Now it requires two statements, and that feels imperative to me.A simple C# example I'm working on:
Also for
StreamLoop
this would be handy.I don't think it would break any code?
Thanks, Peter