# Path: patmat/mimic.py
# def Mimic(*args, **kwargs):
#     """Lazy programmer's stuff.
# 
#     Automatically determines the correct mimic instances from definition.
#     """
#     if kwargs:
#         if args:
#             raise ValueError('Attribute matching should not take a sequence.')
#         for k, v in kwargs.items():
#             kwargs[k] = Mimic(v)
#         return Attr(**kwargs)
#     if len(args) > 1:
#         return Seq(args)
#     value = args[0]
#     if isinstance(value, type):
#         return Type(value)
#     if isinstance(value, list):
#         return List(Mimic(v) for v in value)
#     if isinstance(value, tuple):
#         return Tuple(Mimic(v) for v in value)
#     if isinstance(value, dict):
#         return Dict({Mimic(k): Mimic(v) for k, v in value.items()})
#     if callable(value):
#         return Pred(value)
#     return value


    from itertools import zip_longest
    from itertools import izip_longest as zip_longest
from patmat.mimic import Mimic
try:
except ImportError:



class Match(object):
    def __init__(self, *match_rules):
        self.rules = match_rules

    def with_value(self, *args):
        def _match(value):
            for matcher, func in self.rules:
                match_dict = matcher.match(value)
                if not match_dict:
                    continue
                func = func or True
                yield func(**match_dict) if callable(func) else func
        value_list = []
        for value in args:
            value_list += _match(value)
        if len(value_list) == 1:
            return value_list[0]
        return value_list


class Switch(object):
    def __init__(self, *args):
        self.values = args

    def with_case(self, mimic, func=None):

# Path: patmat/mimic.py
# def Mimic(*args, **kwargs):
#     """Lazy programmer's stuff.
# 
#     Automatically determines the correct mimic instances from definition.
#     """
#     if kwargs:
#         if args:
#             raise ValueError('Attribute matching should not take a sequence.')
#         for k, v in kwargs.items():
#             kwargs[k] = Mimic(v)
#         return Attr(**kwargs)
#     if len(args) > 1:
#         return Seq(args)
#     value = args[0]
#     if isinstance(value, type):
#         return Type(value)
#     if isinstance(value, list):
#         return List(Mimic(v) for v in value)
#     if isinstance(value, tuple):
#         return Tuple(Mimic(v) for v in value)
#     if isinstance(value, dict):
#         return Dict({Mimic(k): Mimic(v) for k, v in value.items()})
#     if callable(value):
#         return Pred(value)
#     return value


# Path: patmat/match.py
    from itertools import zip_longest
    from itertools import izip_longest as zip_longest
from patmat.mimic import Mimic

try:
except ImportError:



class Match(object):
    def __init__(self, *match_rules):
        self.rules = match_rules

    def with_value(self, *args):
        def _match(value):
            for matcher, func in self.rules:
                match_dict = matcher.match(value)
                if not match_dict:
                    continue
                func = func or True
                yield func(**match_dict) if callable(func) else func
        value_list = []
        for value in args:
            value_list += _match(value)
        if len(value_list) == 1:
            return value_list[0]
        return value_list


class Switch(object):
    def __init__(self, *args):
        self.values = args

    def with_case(self, mimic, func=None):

        func = func or True