Any Websocket client example for browser?

I am a purescript beginner who has managed to get quite a few example projects to build but I am very surprised at how difficult it is to put together a simple working websocket client .

purescript-websocket-simple appears to be the websocket package most likely to work.
Based on this issue people have used it as recently as a couple of months ago.

But I couldn’t figure out how to even install it.
spago install websockets-simple does not find it
I then tried to copy the example/src/Main.purs program and src/WebSocket.{js,purs} from the github repo into my new spago init project’s src/ folder.

Then spago build fails because the code uses Effect.Var . I can only find Eff.Var but no Effect.Var anywhere.



I had no trouble making websocket clients in Elm and Haskell even though I am beginner in those languages too. I really want to pick Purescript+Halogen over Elm for my front end projects that I am rewriting (from typescript/react). Hoping this something silly that I have overlooked.


Looks like that’s not in the package set (see this issue).

This should work though:

spago install websocket-moderate

Indeed it installs! That is great. Thank you Miles!

Looks like the source doesn’t come with an example. I couldn’t find anything using this package with a GitHub search either .

But that is OK. It is a learning moment. For once, I will have to write my own code to call some API instead of making small changes to other people’s working code.


Today, I noticed that the purescript-halogen repo (latest 5.1 release) includes an example ‘driver-websockets’ that uses the web-socket package. This builds and works fine.


I stumbled into via Jordan’s Purescript reference. It uses web-socket as well.

The state of Purescript websocket client libraries seems to be: