HORIZON HASKELLDocslts/ghc-9.14.x7a6c33e2026-10-12Search packagesCtrl K
Theme: |

GHC 9.14.1 · lts/ghc-9.14.x · 7a6c33e · 2026-10-12

Modulegithash-0.1.7.0Haskell2010

GitHash

Some handy Template Haskell splices for including the current git hash and branch in the code of your project. Useful for including in panic messages, --version output, or diagnostic info for more informative bug reports.

{-# LANGUAGE TemplateHaskell #-}
import GitHash

panic :: String -> a
panic msg = error panicMsg
  where panicMsg =
          concat [ "[panic ", giBranch gi, "@", giHash gi
                 , " (", giCommitDate gi, ")"
                 , " (", show (giCommitCount gi), " commits in HEAD)"
                 , dirty, "] ", msg ]
        dirty | giDirty gi = " (uncommitted files present)"
              | otherwise   = ""
        gi = $$tGitInfoCwd

main = panic "oh no!"
% stack runghc Example.hs
Example.hs: [panic master@2ae047ba5e4a6f0f3e705a43615363ac006099c1 (Mon Jan 11 11:50:59 2016 -0800) (14 commits in HEAD) (uncommitted files present)] oh no!

WARNING: None of this will work in a git repository without any commits.

Contents
  1. Types
  2. Getters
  3. Creators
  4. Template Haskell
Synopsis
  • Packagegithash-0.1.7.0
  • Exports17
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceGitHash.hs

Types

datadata GitInfo

Various pieces of information about a Git repository.

Instances2Show, Lift
Instances3Eq, Show, Exception

Getters

Creators

Template Haskell