HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

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.

  • 2 types
  • 15 values
  • Packagegithash-0.1.7.0
  • Exports17
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceGitHash.hs

Types

2 declarations
datadata GitInfo
#

Various pieces of information about a Git repository.

Instances2Show, Lift
datadata GitHashException
#
Instances3Eq, Show, Exception

Getters

valuegiTag :: GitInfo -> String
#

The output of git describe --always --tags for the most recent commit.

valuegiFiles :: GitInfo -> [FilePath]
#

The files used to determine whether recompilation is necessary in splices.

Creators

2 declarations

Template Haskell

4 declarations