lets-lens/src/Lets/Profunctor.hs

22 lines
462 B
Haskell
Raw Normal View History

2015-05-21 03:44:22 +02:00
module Lets.Profunctor (
2015-04-22 05:14:38 +02:00
Profunctor(dimap)
) where
import Lets.Data
-- | A profunctor is a binary functor, with the first argument in contravariant
-- (negative) position and the second argument in covariant (positive) position.
class Profunctor p where
dimap ::
(b -> a)
-> (c -> d)
-> p a c
-> p b d
instance Profunctor (->) where
dimap f g = \h -> g . h . f
instance Profunctor Tagged where
dimap _ g (Tagged x) =
Tagged (g x)