In this paper, we present a new framework for the definition of various data structures (including trees and arrays) together with a generic language of filters enabling a rule-based programming style for functions. This framework is implemented in an experimental language called MGS. The underlying notions funding our framework have a topological nature and enable to extend the case-based definition of functions found in modern functional languages beyond algebraic data structures. Categories and Subject Descriptors D.3.3 [Programming Languages]: Language Con