ghci4luatex: A GHCi session in LaTeX

[ bsd3, latex, library, program ] [ Propose Tags ] [ Report a vulnerability ]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.0
Change log CHANGELOG.md
Dependencies aeson (>=2.2 && <2.3), base (>=4.18 && <5), bytestring (>=0.12 && <0.13), cmdargs (>=0.10 && <0.11), containers (>=0.6 && <0.7), ghci4luatex, network-simple (>=0.4 && <0.5), process (>=1.6.25 && <1.7), stm (>=2.5 && <2.6), text (>=2.1 && <2.2) [details]
License BSD-3-Clause
Copyright Copyright (C) 2025 Alice Rixte
Author Alice Rixte
Maintainer alice.rixte@u-bordeaux.fr
Category Latex, Program
Home page https://github.com/AliceRixte/ghci4luatex#readme
Bug tracker https://github.com/AliceRixte/ghci4luatex/issues
Source repo head: git clone https://github.com/AliceRixte/ghci4luatex
Uploaded by AliceRixte at 2025-07-04T17:22:06Z
Distributions
Executables ghci4luatex
Downloads 3 total (3 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for ghci4luatex-0.0

[back to package description]

ghci4luatex : a GHCi session in LuaTeX

Haskell Hackage BSD3 License

Run a GHCi session within a latex document :

  • The ghci environment evaluates Haskell code without printing anything :
\begin{ghci}
x :: Int
x = 4

y :: Int
y = 5
\end{ghci}
  • The hask command evaluates any GHCi command and prints in Haskell what GHCi printed :
The sum of $x$ and $y$ when $x = \hask{x}$ and $y = \hask{y}$ is $\hask{x + y}$.
  • You can use HaTeX :

\begin{ghci}
:set -XOverloadedStrings
\end{ghci}

\begin{ghci}
import Text.LaTeX

printTex = putStrLn . prettyLateX
\end{ghci}

\hask{printTex (section "A section using HaTeX")}
  • Use any package you need by adding it to package.yaml (if the package is on Stackage) or to stack.yaml if it is your own package or only on Hackage.

Quick start

  1. Install haskell and cabal or stack

  2. Install ghci4luatexby running either

cabal install ghci4luatex

or

stack install ghci4luatex
  1. Copy ghci.sty and dkjson.lua in the folder containing a main.tex file with the following content :
\documentclass{article}

\usepackage{ghci}

\begin{document}

\begin{ghci}
x :: Int
x = 5

y :: Int
y = 6
\end{ghci}

The sum of $x$ and $y$ when $x = \hask{x}$ and $y = \hask{y}$ is $\hask{x + y}$.

\end{document}
  1. Within that folder, run the ghci4luatex server :
ghci4luatex
  1. Open another shell and compile with luatex :
latexmk -shell-escape -lualatex main.tex

Workflow with lhs2tex in Visual Studio Code with LaTeX workshop

In this repository, you will find an example that contains a Makefile.

You can take inspiration from this to use make in a LateX Workshop receipe :

  1. Install the LaTeX Workshop extension.
  2. In settings.json , add the following
"latex-workshop.latex.recipes": [
        {
            "name": "ghci4luatex",
            "tools": [
                "mklatex"
            ]
        }
    ],
"latex-workshop.latex.outDir": "./build/",
"latex-workshop.latex.tools": [
        {
            "name": "mklatex",
            "command": "make",
            "args": [
                "latex",
                "main=%DOCFILE%"
            ],
            "env": {}
        }
    ],