| module Main where
|
|
|
| import Wuss
|
|
|
| import Control.Concurrent (forkIO)
|
| import Control.Monad (forever, unless, void)
|
| import Data.Text (Text, pack)
|
| import Network.WebSockets (ClientApp, receiveData, sendClose, sendTextData)
|
|
|
| main :: IO ()
|
| main = runSecureClient "echo.websocket.org" 443 "/" ws
|
|
|
| -- ws :: ClientApp ()
|
| ws connection = do
|
| putStrLn "Connected!"
|
|
|
| void . forkIO . forever $ do
|
| message <- receiveData connection
|
| print (message :: Text)
|
|
|
| let loop = do
|
| line <- getLine
|
| unless (null line) $ do
|
| sendTextData connection (pack line)
|
| loop
|
| loop
|
|
|
| sendClose connection (pack "Bye!")
|
|
|
| ---
|
|
|
| app/Main.hs:14:17: error:
|
| Unexpected do block in function application:
|
| do putStrLn "Connected!"
|
| void . forkIO . forever
|
| $ do message <- receiveData connection
|
| print (message :: Text)
|
| let loop = ...
|
| You could write it with parentheses
|
| Or perhaps you meant to enable BlockArguments?
|
| |
|
| 14 | ws connection = do
|
| | ^^...
|
|
|
| app/Main.hs:22:10: error:
|
| parse error on input ‘<-’
|
| Perhaps this statement should be within a 'do' block?
|
| |
|
| 22 | line <- getLine
|
| | ^^
|