ekmett / profunctors

Haskell 98 Profunctors
http://hackage.haskell.org/package/profunctors
Other
70 stars 43 forks source link

Converse of `Closed` #102

Closed Zemyla closed 2 years ago

Zemyla commented 2 years ago

There is no Profunctor subclass where the elements wind up in inverted positions. There probably should be.

class Profunctor p => ContraClosed p where
  contraclosed :: p a b -> p (b -> x) (a -> x)

-- This shows that ContraClosed should be a superclass of Mapping
contraclosedMapping :: Mapping p => p a b -> p (b -> x) (a -> x)
contraclosedMapping = roam (flip (.))

The question is if there are any ContraClosed instances that aren't also Mapping.

UltimateDude101 commented 2 years ago

The classes are equivalent.

roamContraclosed :: ContraClosed p => ((a -> b) -> s -> t) -> p a b -> p s t
roamContraclosed f = dimap (flip f) ($ id) . contraclosed . contraclosed