#!/usr/bin/env bash
# scripts/compile-check-core
#
# Verify Layer 1 + Layer 2 compile cleanly in isolation — WITHOUT loading
# any controller, view, or Main.hs. Use this to establish and confirm the
# clean base before working on Layer 3 (controllers/views).
#
# Usage (inside devenv shell):
#   scripts/compile-check-core         # interactive
#   scripts/compile-check-core --bg    # write to log only
#
# Once this reports "Ok, N modules loaded" with no errors, the core is clean.
set -euo pipefail
LOGFILE="${IHUB_COMPILE_LOG:-/tmp/ihub-core-errors.txt}"
: > "$LOGFILE"
echo "[compile-check-core] Writing to $LOGFILE"
exec ghcid \
  --no-title \
  --outputfile "$LOGFILE" \
  --command "ghci -ghci-script .ghci-core"
