[Haskell-cafe] Functional programmer's intuition for adjunctions?
miguelimo38 at yandex.ru
Tue Mar 4 13:45:59 EST 2008
Well, we have at least one very useful example of adjunction. It's
called "curry". See, if X is some arbitrary type, you can define
type F = (,X)
instance Functor F where
fmap f (a,x) = (fa,x)
type G = (->) X
instance Functor G where
fmap f h = \x -> f (h x)
Now, we have the adjunction:
phi :: ((a,X) -> b) -> (a -> (X -> b))
phi = curry
phiInv :: (a -> (X -> b)) -> ((a,X) -> b)
phiInv = uncurry
On 4 Mar 2008, at 21:30, Edsko de Vries wrote:
> On Tue, Mar 04, 2008 at 11:58:38AM -0600, Derek Elkins wrote:
>> On Tue, 2008-03-04 at 17:16 +0000, Edsko de Vries wrote:
>>> Is there an intuition that can be used to explain adjunctions to
>>> functional programmers, even if the match isn't necessary 100%
>>> (like natural transformations and polymorphic functions?).
>> Well when you pretend Hask is Set, many things can be discussed
>> F is left adjoint to U, F -| U, if Hom(FA,B) is naturally
>> isomorphic to
>> Hom(A,UB), natural in A and B. A natural transformation over Set is
>> just a polymorphic function. So we have an adjunction if we have two
>> phi :: (F a -> b) -> (a -> U b)
>> phiInv :: (a -> U b) -> (F a -> b)
>> such that phi . phiInv = id and phiInv . phi = id and F and U are
>> instances of Functor.
>> The unit and counit respectively is then just phi id and phiInv id.
> Sure, but that doesn't really explain what an adjunction *is*. For me,
> it helps to think of a natural transformation as a polymorphic
> it gives me an intuition about what a natural transformation is.
> Specializing the definition of an adjunction for Hask (or Set) helps
> understanding the *definitions*, but not the *intention*, if that
> any sense..
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe