New paste Repaste Download
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
   |          ^^
Filename: None. Size: 1kb. View raw, , hex, or download this file.

This paste expires on 2024-06-22 05:22:37.722760. Pasted through web.