pattern matcher takes an implicit env