create a loader for a dataclass type

def create_dataclass_loader(cls, registry, field_getters):
    """create a loader for a dataclass type"""
    fields = cls.__dataclass_fields__
    item_loaders = map(registry, map(attrgetter('type'), fields.values()))
    getters = map(field_getters.__getitem__, fields)
    loaders = list(starmap(compose, zip(item_loaders, getters)))

    def dloader(obj):
        return cls(*(g(obj) for g in loaders))

    return dloader