{-# LANGUAGE ExistentialQuantification #-} import Control.Category import Control.Arrow -- data Kl' s i o = Kl' (i -> s -> (s, o)) data Kl i o = forall s. Kl (i -> s -> (s, o)) -- OK instance Category Kl where id = Kl $ \ i () -> ((), i) (.) (Kl u2) (Kl u1) = (Kl u12) where u12 a (s1, s2) = ((s1',s2'), c) where (s1', b) = u1 a s1 (s2', c) = u2 b s2 -- OK instance Arrow Kl where arr f = Kl $ \i () -> ((), f i) first (Kl u) = (Kl u') where u' (i, x) s = (s', (o, x)) where (s', o) = u i s -- Can't make this work. The problem seems to be the same as before: -- there's no way to require that the hidden types of both -- constructors are the same. instance ArrowApply Kl where app = Kl $ \((Kl f), a) -> f a