Skip to content

Instantly share code, notes, and snippets.

@mpickering
Created November 14, 2025 13:45
Show Gist options
  • Select an option

  • Save mpickering/c02262282bf561e0ecdee382c82fcf1c to your computer and use it in GitHub Desktop.

Select an option

Save mpickering/c02262282bf561e0ecdee382c82fcf1c to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -euo pipefail
# Directory where all the sockets will live
SOCKET_DIR="$HOME/.ghc-eventlog-sockets"
mkdir -p "$SOCKET_DIR"
# Find the directory from which the command is being run (e.g. your project root)
CWD="$(pwd)"
# Remove /home/matt prefix if present
if [[ "$CWD" == /home/matt* ]]; then
CWD="${CWD#/home/matt}"
# Remove leading slash if present
CWD="${CWD#/}"
fi
# Make a filesystem-safe socket name derived from the current directory
SOCKET_NAME="$(echo "$CWD" | tr '/ ' '__')"
SOCKET_PATH="$SOCKET_DIR/hls-$SOCKET_NAME.sock"
# Path to the real HLS binary
HLS_BIN="/home/matt/hls-9.6/dist-newstyle/build/x86_64-linux/ghc-9.12.2/haskell-language-server-2.11.0.0/x/haskell-language-server/build/haskell-language-server/haskell-language-server"
# If the first argument is --numeric-version, bypass all socket + RTS logic
if [[ "${1:-}" == "--numeric-version" ]]; then
exec "$HLS_BIN" "$@"
fi
# Export the socket path to the environment variable
export GHC_EVENTLOG_SOCKET="$SOCKET_PATH"
# Launch HLS with all arguments passed through
exec "$HLS_BIN" "$@" +RTS -l -hT --eventlog-flush-interval=60 -i60 -RTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment