[Haskell-beginners] How to get IO String from Network.Socket.ByteString.recv method

Dinesh Amerasekara ddinesh31 at yahoo.com
Sun May 20 07:52:33 UTC 2018


Hi,
I am unable to compile the below code.
import Network.Socket hiding(recv) import Network.Socket.ByteString as S (recv) import qualified Data.ByteString.Lazy.Char8 as Char8  
getMessage :: Socket -> IO String getMessage sock =  Char8.unpack <$> S.recv sock 8888

It gives the below error.
Couldn't match type ‘Data.ByteString.Internal.ByteString’                     with ‘ByteString’NB: ‘ByteString’ is defined in ‘Data.ByteString.Lazy.Internal’    ‘Data.ByteString.Internal.ByteString’        is defined in ‘Data.ByteString.Internal’    Expected type: IO ByteString    Actual type: IO Data.ByteString.Internal.ByteString
In the second argument of ‘(<$>)’, namely ‘recv sock 8888’In the expression: unpack <$> recv sock 8888In an equation for ‘getMsg’:      getMsg sock = unpack <$> recv sock 8888
Can somebody tell me how I can return the IO String using Network.Socket.ByteString.recv?
Best Regards,Dinesh.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20180520/aa7291ee/attachment.html>


More information about the Beginners mailing list