>>> from Redy.Collections import Flow, Traversal
    >>> x = [1, '1', 1.0]
    >>> Flow(x)[Traversal.group_by(type)]

def group_by(fn: Callable[[T], TR]):
    """
    >>> from Redy.Collections import Flow, Traversal
    >>> x = [1, '1', 1.0]
    >>> Flow(x)[Traversal.group_by(type)]
    """

    def inner(seq: ActualIterable[T]) -> Dict[TR, List[T]]:
        ret = defaultdict(list)
        for each in seq:
            ret[fn(each)].append(each)

        return ret

    return inner