public static AccumulWriter <A> Restore <A> (this AccumulWriter <A> src) { src.Paper.Pop(); src.Value.Pop(); return(src); }
internal AccumulWriter(A value, string txt, AccumulWriter <A> past) { if (value == null) { throw new ArgumentException(nameof(value)); } Value = past.Value; Value.Push(value); Paper = past.Paper; Writer = past.Writer; Paper.Push(Paper.First() + Writer(txt)); }
public static A GetLastValue <A> (this AccumulWriter <A> self) => self.Value.First();
public static string GetLastPaper <A> (this AccumulWriter <A> self) => self.Paper.First();
// Func => new M<A> ( val , txt , self ) public static AccumulWriter <A> Add <A> (this AccumulWriter <A> self, Func <A, A> f, string txt) => new AccumulWriter <A>(f(self.Value.First()), txt, self);
public static A Lift <A> (this AccumulWriter <A> self, Func <A, A> f) => f(self.Value.First());
public static int Count <A> (this AccumulWriter <A> src) => src.Value.Count;