Introduce funnel operator i,e '|>' to allow for generator pipelines

I’ve created the topic here. I don’t have high hopes as I would imagine we are more advanced in this area here than the general public, including studying some of the other languages - at least me (R, Ocaml, Haskell, Idris, JavaScript). But who knows.

I’ve updated the Pyodide deployment: here.

You can do many interesting things with the __pipe__() magic now, including:

from functools import partial


class PartialsPipe:
  def __init__(self, value):
    self.value = value  

  def __pipe__(self, rhs, last):
    p = rhs(self.value)
    if last:
      return p(self.value)
    else:
      return PartialsPipe(p(self.value))
    

def second(a, b):
  return b


def mypartial(func, *args, **kwargs):
  def inner(_):
    return func(_, *args[:-1], **kwargs)
  return inner


def mypartial2(func, *args, **kwargs):
  def inner(_):
    return func(*args[:-1], _, **kwargs)
  return inner


my_split = partial(str.split, maxsplit=2)
print(PartialsPipe("lorem ipsum dolor sit amet") |> my_split)

print(PartialsPipe("lorem ipsum dolor sit amet") |> partial(second(_, str.split), maxsplit=2))

print(PartialsPipe("lorem ipsum dolor sit amet") |> partial(_ := str.split, maxsplit=2))

print(PartialsPipe("lorem ipsum dolor sit amet") |> mypartial(str.split, maxsplit=2) |> mypartial2(map, str.capitalize) |> mypartial(list))

@dg-pb how does it look to you?