Skip to content

Make WebSocket support conditional#643

Open
andy0130tw wants to merge 1 commit into
haskell:masterfrom
andy0130tw:make-websocket-support-conditional
Open

Make WebSocket support conditional#643
andy0130tw wants to merge 1 commit into
haskell:masterfrom
andy0130tw:make-websocket-support-conditional

Conversation

@andy0130tw

@andy0130tw andy0130tw commented Jul 16, 2026

Copy link
Copy Markdown

Fixes #642.

Makes WebSocket support configurable via a websocket flag (defaults to True). Setting this to False strips out the dependency of package websockets, along with all WebSocket-related implementation, making it compatible with platforms that don't support WebSockets (e.g., the WebAssembly backend).

It introduces CPP macros to the project, which makes the code a little bit tangled. Feel free to edit it further.

@fendor
fendor requested review from MangoIV and fendor July 17, 2026 07:52

@fendor fendor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@fendor

fendor commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

cc @MangoIV

@andy0130tw

Copy link
Copy Markdown
Author

The failing formatting check is due to fourmolu not knowing how to parse CPP directives? I find this on ormolu's README:

CPP support is experimental. CPP is virtually impossible to handle correctly, so we process them as a sort of unchangeable snippets. This works only in simple cases when CPP conditionals surround top-level declarations. See the CPP section in the design notes for a discussion of the dangers.

I can try to accommodate it by moving the directive around.

@fendor

fendor commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

@andy0130tw It is fine, the formatter check is not blocking.

@michaelpj

Copy link
Copy Markdown
Collaborator

I would be tempted to try and avoid the CPP entirely. AFAICT the websocket support is entirely additional code. So what we can do is to a) put it in its own module, b) in the cabal file, expose that module only if the flag is set. I think that does everything you want without any CPP?

@andy0130tw

Copy link
Copy Markdown
Author

@michaelpj That requires a structural change, but I would be fine with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request] Make networking support optional

3 participants