Exemplo n.º 1
0
 public static Process1 <TI, TO> Await1 <TI, TO>(
     Func <TI, Process1 <TI, TO> > recv,
     Process1 <TI, TO> fallback = null)
 {
     return(new Await1 <TI, TO>(
                () => default(TI),
                either => either.Match(
                    left: ex => ex is End
                 ? fallback.ToMaybe().GetOrElse(() => Halt1 <TI, TO>())
                 : new Halt1 <TI, TO>(ex),
                    right: i => Try(() => recv(i)))));
 }
Exemplo n.º 2
0
 public Eval1(Action effect, Process1 <TI, TO> next = null)
 {
     Effect = effect;
     Next   = next ?? Process.Halt1 <TI, TO>();
 }
Exemplo n.º 3
0
 public Emit1(TO head, Process1 <TI, TO> tail)
 {
     Head = head;
     Tail = tail ?? new Halt1 <TI, TO>(End.Only);
 }
Exemplo n.º 4
0
 public static Process1 <IEither <T1, T2>, T3> EmitT <T1, T2, T3>(T3 h, Process1 <IEither <T1, T2>, T3> t = null)
 {
     return(new Emit1 <IEither <T1, T2>, T3>(h, t));
 }
Exemplo n.º 5
0
 public static Process1 <TI, TO> Concat <TI, TO>(this Process1 <TI, TO> p1, Func <Process1 <TI, TO> > p2)
 {
     return(p1.OnHalt(ex => ex is End ? (Process1 <TI, TO>) new Cont1 <TI, TO>(() => Try(p2)) : new Halt1 <TI, TO>(ex)));
 }
Exemplo n.º 6
0
 public static Process1 <TI, TO> Repeat <TI, TO>(this Process1 <TI, TO> p1)
 {
     return(p1.Concat(p1.Repeat));
 }
Exemplo n.º 7
0
 public static Process1 <TI, TO> Emit1 <TI, TO>(TO h, Process1 <TI, TO> t = null)
 {
     return(new Emit1 <TI, TO>(h, t ?? new Halt1 <TI, TO>(End.Only)));
 }