Ok, so I thought of having some fun with arrows. I tried to directly translate the sexy Haskell quicksort to an implementation that uses arrows instead. But it does not work correctly.
import Control.Arrow
qs :: Ord a => [a] -> [a]
qs = isEmpty >>> right (head &&& tail
>>> first ((qs.) . filter . (<)
&&& (\x -> (x:) . qs . filter (>=x)))
>>> first (uncurry (&&&))
>>> uncurry id
>>> uncurry (++))
>>> extract
where
isEmpty [] = Left []
isEmpty x = Right x
extract (Left x) = x
extract (Right x) = x
Can someone spot the problem?