Skip to content

foldVL doesn't work with all van Laarhoven folds #535

@tomjaguarpaw

Description

@tomjaguarpaw

The type is

foldVL
  :: (forall f. Applicative f => (a -> f u) -> s -> f v)
  -> Fold s a

but it should be

foldVL'
  :: (forall f. (Applicative f, Contravariant f) => (a -> f a) -> s -> f s)
  -> Fold s a

I guess, like #533, the reason is to support old GHC's (or rather old bases) that don't include Contravariant. Perhaps #532 is the better choice. If optics is going to stick with 8.4 support, could the documentation be updated to explain that foldVL doesn't work with all van Laarhoven folds, and why this choice was made?

By the way, this seems to be the implementation:

foldVL' f =
  foldVL @_ @() @_ @() (\k s -> getAp (getConst (f (Const . Ap . k) s)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions