Quoth siki <ga...@karamaan.com>,

> The actual problem is quite similar to the one that I provided or to the one
> in the description of the proposed extension that you linked. 
>
> Someone on another forum suggested record functions but I'm not sure I
> understood correctly how that would work around this problem. Any suggestion
> is greatly appreciated!

Maybe it was function records.  That's kind of the poor man's OOP in
Haskell - no typeclasses needed.

data FileRec = FileRec {
          fileRecRead :: Int -> IO String
        , fileRecWrite :: String -> IO ()
        }
socketFileRec socket = {
          fileRecWrite = \ s -> send socket s 0
        , fileRecRead = \ i -> recv socket i 0
        }
pipeFileRec p0 p1 = {
          fileRecWrite = writeFd p1
        , fileRecRead = readFd p0
        }
echoBlock file count = (fileRecRead file) count >>= fileRecWrite file

Maybe you could use that, maybe you couldn't.  That's why Martin suggested
that you reveal the actual problem.  Not the solution you had in mind,
but the thing you're trying to solve.

        Donn

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to