Skip to content

Make WebSocket support conditional - #643

Merged
fendor merged 1 commit into
haskell:masterfrom
andy0130tw:make-websocket-support-conditional
Jul 28, 2026
Merged

Make WebSocket support conditional#643
fendor merged 1 commit into
haskell:masterfrom
andy0130tw:make-websocket-support-conditional

Conversation

@andy0130tw

@andy0130tw andy0130tw commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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
Contributor 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
Contributor Author

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

@MangoIV MangoIV left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like a nice and simple change.

@MangoIV

MangoIV commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

I am not a huge opponent of CPP if used sparingly.

@MangoIV

MangoIV commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Since the websocket specific code is entirely self contained, I think it's not a detriment to the code quality at all.

@fendor

fendor commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

@MangoIV I also think CPP isn't a huge deal, but I agree that avoiding it altogether and having the WS parts separate could make sense any way. So I am lighlty in favour of the separate module.

@andy0130tw Did we exhaust you already or would you attempt moving the WS parts into a separate module?

@andy0130tw

Copy link
Copy Markdown
Contributor Author

@fendor I'm leaning towards avoiding CPP here, but I would like to passing on this task as I don't think I have enough context on the overall project architecture.

@fendor
fendor merged commit 532a79b into haskell:master Jul 28, 2026
14 of 15 checks passed
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

4 participants