effectful-websockets-tls: The WebSocket effect of effectful-websockets, over TLS too

[ bsd3, control, library, network, web ] [ Propose Tags ] [ Report a vulnerability ]

Interpreters for the WebSocket effect of effectful-websockets that open secure WebSockets, through streamly-websockets-tls. A package apart, so that programs that only speak in clear need not build a TLS stack.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.19 && <4.22), bytestring (>=0.12 && <0.13), effectful-core (>=2.7.1 && <2.8), effectful-websockets (>=0.1 && <0.2), streamly-core (>=0.3.3 && <0.4), streamly-http (>=0.1 && <0.2), streamly-network-tls (>=0.1 && <0.2), streamly-websockets (>=0.1 && <0.2), streamly-websockets-tls (>=0.1 && <0.2), tls (>=2.5 && <2.6) [details]
Tested with ghc ==9.8.4 || ==9.10.3 || ==9.12.4
License BSD-3-Clause
Author Xavier Dectot
Maintainer Xavier Dectot <xavier@wheredoibegin.fr>
Uploaded by GdeVolpiano at 2026-11-28T14:01:19Z
Category Network, Web, Control
Home page https://github.com/GuillaumedeVolpiano/effectful-websockets-tls
Source repo head: git clone https://github.com/GuillaumedeVolpiano/effectful-websockets-tls.git
Distributions
Downloads 4 total (4 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for effectful-websockets-tls-0.1.0.0

[back to package description]

effectful-websockets-tls

Interpreters for the WebSocket effect of effectful-websockets that open secure WebSockets, through streamly-websockets-tls. A package apart, so that programs that only speak in clear need not build a TLS stack.

{-# LANGUAGE OverloadedStrings #-}

import Effectful (runEff)
import Effectful.Error.Static (runErrorNoCallStack)
import Effectful.WebSocket (Message, receiveMessage, sendText)
import Effectful.WebSocket.Client (WebSocketError, clientConfig)
import Effectful.WebSocket.Client.TLS (Certificates (SystemCertificates),
                                       runWebSocketSecure)

hello :: IO (Either WebSocketError (Maybe Message))
hello = runEff . runErrorNoCallStack . runWebSocketSecure SystemCertificates (clientConfig "example.org" 443 "/chat") $ do
  _ <- sendText "hello"
  receiveMessage

What it gives

  • runWebSocketSecure: the connection over TLS, the server checked against the certificates of the system (SystemCertificates) or of a file in PEM (CertificatesFrom).
  • runWebSocketAt: in clear or over TLS, as a scheme says.
  • urlClientConfig: the scheme and the configuration of a ws or wss URL, to give to runWebSocketAt.

They behave as runWebSocketClient does in clear: the action runs in the calling thread, the server is pinged, and a connection that the server closes, or that breaks, is not an error. A certificate that is not accepted is a ConnectFailed.

Building

To build against copies of the libraries this package is built on (effectful-websockets, streamly-websockets-tls and those under them) checked out next to this repository, pass --project-file=cabal.project.siblings.

Tested with GHC 9.8.4, 9.10.3 and 9.12.4, and effectful 2.7.1.