Haskell Language Free (Reader x) ~~ Reader (Stream x)


Example

Given

data Reader x a = Reader (x -> a)

we have

data Free (Reader x) a
     = Pure a
     | Free (x -> Free (Reader x) a)

which is isomorphic to

data Demand x a
     = Satisfied a
     | Hungry (x -> Demand x a)

or equivalently Stream x -> a with

data Stream x = Stream x (Stream x)