A category-theoretical approach to hypergraphs