Peter Simons wrote:

>Note my original definition:
>
>  type Buffer = (Ptr Word8, Int)
>
>  data StreamProc ctx a
>    = SP
>      { start  :: IO ctx
>      , feed   :: ctx -> Buffer -> IO ctx
>      , commit :: ctx -> IO a
>      }
>
>So you would use it like this:
>
>  foo :: StreamProc ctx a -> IO a
>  foo sp = do
>    ctx <- start sp
>    (ptr,n) <- "read buffer"
>    ctx' <- feed sp ctx (ptr,n)
>    ...
>    commit sp ctx'

Sorry, my mistake. I was thinking of StreamProc as a type class.
What I meant was this:

 bar :: StreamProc ctx a -> IO (a,a)
 bar sp = do
   ctx <- start sp
   (ptr1,n1) <- ...
   (ptr2,n2) <- ...
   ctx1 <- feed sp ctx (ptr1,n1)
   ctx2 <- feed sp ctx (ptr2,n2)
   val1 <- commit sp ctx1
   val2 <- commit sp ctx2
   return (val1,val2)

My point is just that bar typechecks and therefore must do something
at runtime; what does it do? This is a genuine question -- I'm hoping
the answer will help me understand what you're trying to do here.

-- Ben

_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to