libtmux for Haskell
Haskell-based tmux client
Typed tmux values for Haskell. Parse tmux entity IDs, validate dimensions and indices, and check stable tmux releases with pure Haskell functions
{-# LANGUAGE OverloadedStrings #-}
-- | Construct tmux domain values without starting a process-- or contacting a server.module Main (main) where
import LibTmux.Id (parseWindowId, renderWindowId)import LibTmux.Value (dimensionValue, mkDimension)import LibTmux.Version (parseVersion, renderVersion, requireSupported)
main :: IO ()main = do version <- either (fail . show) pure $ parseVersion "tmux 3.3a\n" >>= requireSupported window <- either (fail . show) pure (parseWindowId "@17") width <- either (fail . show) pure (mkDimension 120) print (renderVersion version, renderWindowId window, dimensionValue width)Run this example
Linux x86_64, GHC 9.14.1, Cabal 3.18.2.0, Git, a C11 compiler, and network access to GitHub and Hackage for source dependencies. No running tmux server is required.
Save the program above as Main.hs in a new directory, along with the files below.
This program validates supplied values and prints the result. It does not start tmux or create resources requiring cleanup.
libtmux-typed-values.cabal
cabal-version: 3.18name: libtmux-typed-valuesversion: 0.0.0build-type: Simplelicense: MIT
executable typed-values main-is: Main.hs default-language: GHC2024 ghc-options: -Wall -Werror build-depends: base >=4.22 && <4.23, libtmux-haskell ^>=0.1.0.0cabal.project
packages: .index-state: 2026-11-06T00:00:00Z
source-repository-package type: git location: https://github.com/libtmux/libtmux-haskell tag: 581f0ee45016ffb2283366bb1edc1658df26c5edSetup and run
cabal updatecabal run --verbose=0 typed-valuesExpected output
("3.3a","@17",120)Install libtmux-haskell
cabal.project
Save as cabal.project and add libtmux-haskell ^>=0.1.0.0 to your component's build-depends. Requires Linux x86_64, GHC 9.14.1 and Cabal 3.18.2.0. The core package is available from source; it is not published on Hackage.