Skip to content

PortFusion REPL

cetinsert edited this page Sep 6, 2014 · 1 revision

Changes introduced in version 1.1 made Main.hs completely self-contained.

PortFusion can now be loaded and tested from within GHCi.

cd PortFusion
ghci src/Main.hs

The PortFusion REPL is an incredibly convenient way to start using the internals of PortFusion without much knowledge about Haskell or having to worry about which modules and functions to import from which Haskell library. The examples below are guaranteed to just work !

Note: On Windows you need the following as the first command in a new session.

withSocketsDo $ return ()

Examples for 1.2.1

This list will be extended in the future.

Dump Headers Sent by a WebSocket Client

GHCi

s <- ( @<) $! read "3000"             -- listen on port 3000
c <- (<@ ) s                          -- accept a client
forever $! recv c chunk >>= B.putStr  -- dump client messages

Browser

Visit: http:https://jsfiddle.net/yfDpq/5/

Output

GET / HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: [::1]:3000
Origin: http:https://fiddle.jshell.net
Sec-WebSocket-Key: JMt7VzItsvWI/dvDKyJR6w==
Sec-WebSocket-Version: 13
Sec-WebSocket-Extensions: x-webkit-deflate-frame

Note

Internal APIs are subject to change between every release.
This page always lists up-to-date examples for the latest version.

Contact

corsis

[email protected]