I have a function which i must use and it is named :
hPutStrLn
That function has a type :
hPutStrLn::Handle -> String -> IO ()
And i what i wanted to do, it was using a shell command line grep
and get the output and transmit to the String variable of hPutStrLn
.
For example:
tryA (arrIO (\s -> hPutDocument (\h-> hPutStrLn h (readProcess "grep" ["-n",s,"camera2.owl"] ""))))
But the problem is, that my readProcess has type of IO String, which must be a String if i wanna use the function hPutStrLn
!
And i don't know how i can solve this...
So i have a few questions which is :
-Could i extract the String from IO String ?
- If i can't, is there any other way to do that ?
hPutDocument function
hPutDocument :: (Handle -> IO ()) -> IO ()
hPutDocument action
| isStdout
= do
hSetBinaryMode stdout (not textMode)
action stdout
hSetBinaryMode stdout False
| otherwise
= do
handle <- ( if textMode
then openFile
else openBinaryFile
) dst WriteMode
action handle
hClose handle
isStdout = null dst || dst == "-"
outFile = if isStdout
then "stdout"
else show dst