-- e.g. type R = Double
type Cont x = (x -> R) -> R
type Minus y x = (y, x -> R)
cocurry :: (x -> Cont (Either y z)) -> Minus x z -> Cont y
cocurry f (x, w) q = f x (\case
Left y -> q y
Right z -> w z)
councurry :: (Minus x z -> Cont y) -> (x -> Cont (Either y z))
councurry f x v = f (x, \z -> v (Right z)) (\y -> v (Left y))
References.