@Matthew,

this is my take on the puzzles so far:

**Puzzle1 solution:** are the *functor laws* expressed in Category class terms:

catMap id = id

catMap (f . g) = catMap f . catMap g

**Puzzle2 solution:** is _lifting_ `return`and `>=>` from `Monad`to the `Kleisli` newtype:

instance Monad m => Category (Kleisli m) where

id = Kleisli return

(Kleisli f) . (Kleisli g) = Kleisli $ f <=< g

**Puzzle3 solution:** 1 and 2 are related because I need the `RighK` values to be in the same monad context as the kleisli arrows

newtype RightK m b = RightK { unRightK :: m b }

instance Monad m => CatFunctor (Kleisli m) (RightK m) (->) where

catMap (Kleisli f) (RightK a) = RightK $ a >>= f

What I'm stuck with is the last part of the puzzle. I think I have the correct code but I cannot to make GHC to accept it. The code I have is:

instance Monad m => CatAdjunction (->) (Kleisli m) LeftK (RightK m) where

catLeftAdjunct f = RightK . f . LeftK

catRightAdjunct f = unRightK . f . unLeftK

And the error I get has to do with functional dependencies:

• Illegal instance declaration for

‘CatAdjunction (->) (Kleisli m) LeftK (RightK m)’

The liberal coverage condition fails in class ‘CatAdjunction’

for functional dependency: ‘f -> g’

Reason: lhs type ‘LeftK’ does not determine rhs type ‘RightK m’

Un-determined variable: m

• In the instance declaration for

‘CatAdjunction (->) (Kleisli m) LeftK (RightK m)’

Any suggestions?

Of course the problem can be that all my code is completely wrong :-D

this is my take on the puzzles so far:

**Puzzle1 solution:** are the *functor laws* expressed in Category class terms:

catMap id = id

catMap (f . g) = catMap f . catMap g

**Puzzle2 solution:** is _lifting_ `return`and `>=>` from `Monad`to the `Kleisli` newtype:

instance Monad m => Category (Kleisli m) where

id = Kleisli return

(Kleisli f) . (Kleisli g) = Kleisli $ f <=< g

**Puzzle3 solution:** 1 and 2 are related because I need the `RighK` values to be in the same monad context as the kleisli arrows

newtype RightK m b = RightK { unRightK :: m b }

instance Monad m => CatFunctor (Kleisli m) (RightK m) (->) where

catMap (Kleisli f) (RightK a) = RightK $ a >>= f

What I'm stuck with is the last part of the puzzle. I think I have the correct code but I cannot to make GHC to accept it. The code I have is:

instance Monad m => CatAdjunction (->) (Kleisli m) LeftK (RightK m) where

catLeftAdjunct f = RightK . f . LeftK

catRightAdjunct f = unRightK . f . unLeftK

And the error I get has to do with functional dependencies:

• Illegal instance declaration for

‘CatAdjunction (->) (Kleisli m) LeftK (RightK m)’

The liberal coverage condition fails in class ‘CatAdjunction’

for functional dependency: ‘f -> g’

Reason: lhs type ‘LeftK’ does not determine rhs type ‘RightK m’

Un-determined variable: m

• In the instance declaration for

‘CatAdjunction (->) (Kleisli m) LeftK (RightK m)’

Any suggestions?

Of course the problem can be that all my code is completely wrong :-D