jeff p | 10 Oct 09:27 2012
Picon

CPS Streams

{-

I've always thought that the essence of iteratees is just CPS (I have
no desire to argue the merits of this statement, and I preemptively
concede to anyone who disagrees with this), so I decided to experiment
with a direct CPS version of streams. The resulting code turned out
nicer than I'd expected, so I'm writing about it in case anyone else
finds it interesting or instructive (it seems to me that Haskellers
tend to shy away from CPS). I'm pretty sure this technique is not new,
but a cursory search didn't turn up quite the same thing. I'd be
interested in any pointers to this somewhere else, as well any general
feedback about this.

-}

{-# LANGUAGE ScopedTypeVariables, TupleSections #-}

import Control.Applicative hiding (empty)
import Control.Arrow
import Control.Exception
import Control.Monad (unless)
import Data.Attoparsec.Text
import Data.Text
import Data.Text.IO
import Prelude hiding (catch, getLine, lines, length, null, putStrLn,
readFile, splitAt)
import qualified Prelude as P
import System.IO (IOMode(..), hClose, hIsClosed, withFile)
import System.IO.Error hiding (catch)

(Continue reading)

Johannes Waldmann | 10 Oct 11:34 2012
Picon

Re: CPS Streams

jeff p <mutjida <at> gmail.com> writes:

> I've always thought that the essence of iteratees is just CPS 

for sure, at some level of abstraction this ought to be true,
since CPS simulates call-by-value in a call-by-name language,

cf. Gordon Plotkin: Call-by-Name, Call-by Value and the Lambda Calculus
TCS , Vol. 1, pp. 125-159, http://homepages.inf.ed.ac.uk/gdp/publications/

and the purpose of  iteratee is to  "provide strict [...] I/O" 
http://hackage.haskell.org/package/iteratee-0.8.9.4

J.W.
jeff p | 10 Oct 16:22 2012
Picon

Re: CPS Streams

Here is an haste of the original message since it seems like the
formatting was lost.

http://hpaste.org/76082

sorry about that,
  Jeff

Gmane