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