# Pastebin PGucY4I0 type Partial a = HKD a Last data User = User { name :: Text, age :: Int, adult :: Bool } deriving (Generic) test :: [(String, Bool)] test = labelsWhere' (isJust . getLast) $ (mempty :: Partial User) & field @"name" .~ pure "name here" labelsWhere' :: forall structure f. ( Label structure, ApplicativeB (HKD structure), TraversableB (HKD structure), AllB Show (HKD structure) ) => (forall a. f a -> Bool) -> HKD structure f -> [(String, Bool)] labelsWhere' p = getConst . btraverse go . bprod label where go :: Product (Const String) f a -> (Const [(String, Bool)]) (Maybe a) go (Pair (Const key) value) = Const [(key, p value) | p value]