IO in the middle

2011-11-17 Thread Serge D. Mechveliani
People,

is it possible to arrange a connected output and input (with something 
like a socket) in a middle of the Haskell function?
Consider the example of sorting an integer list:
 
 sortInt :: [Int] - [Int] 
 sortInt js = 
 let callString = sortForeign(  ++ (show js) ++ ) 
 ?  = outputToSocket callStr socket?-- strict order?
 resStr = inputFromSocket socket?  :: String-- 
 (res, _) = reads str' :: ([Int], String) 
 in  res

It forms the call string for a foreign function, passes it to a Socket,
the foreign system parses  callString,  evaluates it, and returns the 
string  resStr  for the result (inputFromSocket needs to happen later than 
outputToSocket). Then,  reads  converts it back to [Int].

Forgetting of the pure-functionality philosophy, which items in the Haskell
library or in the GHC library may help? Is the C interface needed?
  
What if there is a  file  instead of socket?
(for this Foreign is able to apply  readFile, to parse and evaluate the 
call).  

I had an experience with  readFile  in Haskell, but this was only the 
top function. Here the situation looks more complex.

Thank you in advance for your explanation.

--
Sergei.
mech...@botik.ru

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: IO in the middle

2011-11-17 Thread Donn Cave
I think you're talking about RPC, Remote Procedure Call.  A search
for that term turns up http://www.haskell.org/haskellwiki/HaXR

For things like this, it would make sense to subscribe to haskell-cafe,
and post questions there - it's a much more active list that's devoted
to ideas about Haskell in general, as opposed to specific quirks of the
GHC implementation.

Donn

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users