[Haskell-cafe] Existential question

oleg at okmij.org oleg at okmij.org
Thu Aug 25 09:18:17 CEST 2011

> Ehm... what? How can you do such a replacement without losing, for
> example, functions like this:
> f (KI s h) i = snd $ h i $ fst $ h i s

Well, if we eliminate the existential from

   data Kl i o = forall s. Kl s (i ->  s ->  (s, o))

following strictly the procedure we obtain

	data S i o = S (i -> (S i o, o))

It is the data type of infinite streams, with an extra input. Your
function is obtaining the second element of the stream (assuming the
constant input i).  Infinite streams form a monad, as described in
great detail here:


More information about the Haskell-Cafe mailing list