---
name: "hat-trans"
section: "1"
platform: "linux"
package: "hat"
version: "2.05+rerolled-7+b1"
release: "Debian 5.0 (Lenny)"
platforms: ["linux"]
url: "https://new.carta.tech/hat-trans"
---

# hat-trans(1)

transform a Haskell module for tracing with the Hat system

## NAME

hat-trans - transform a Haskell module for tracing with the Hat system

## SYNOPSIS

**hat-trans** \[-cpp \[cppopts\]\] \[-Idir\]\* \[-package p\]\* \[transopts\] *Mod.\[l\]hs ...*

## DESCRIPTION

*hat-trans* is a batch tool for transforming a Haskell program into one which calculates its own trace.  It transforms each source module *Mod* supplied as arguments.  The modules may be ordinary source (.hs) or literate source (.lhs).  The output is a transformed module, whose name is the original module name prefixed with "Hat.", and it is written to a file of similar name in the local subdirectory *Hat/* (except that .lhs becomes .hs, because the literate part is stripped). If the subdirectory does not exist, it is created.  The original source filename may include a directory path, in which case the transformed module is placed in an identical directory tree underneath the directory *Hat/.* This facilitates the easy transformation of modules within the hierarchical module namespace.

The resulting transformed modules can be compiled and linked in the normal way with your favorite Haskell compiler, with the addition of the option *-package hat* to its command-line.

Alternatively, rather than invoking *hat-trans* and a compiler by hand on your source files, but it is often more convenient to allow *[hmake(1)](/hmake/1.md)* to invoke the tools automatically, especially because it also determines dependencies between modules and attempts to perform the minimum re-compilation necessary.  Simple give the extra option "-hat" to hmake.

## GENERAL OPTIONS

- **-Idir**

  Use the directory *dir* as an additional root when searching for imported modules.

- **-package p**

  The given source module(s) use standard modules from within the package *p* (this automatically adds the installed package root directory to the import search path).

- **-cpp**

  Invoke the C preprocessor on the source code before it is transformed. This is useful for conditional transformation. One cpp symbol is predefined, \_\_HAT\_\_, whose value is the version number of the Hat toolset, expressed as a three digit integer, e.g. version 2.02 gives \_\_HAT\_\_=202.  If the -cpp option is given, the preprocessor is invoked on all the files given as arguments.  An alternative which only invokes cpp on the files that really need it, is to place a Haskell comment containing the string "-cpp" as the first line of a source file.

- **-Dsym=val**

  Define the cpp symbol *sym* to have the value *val*

- **-Dsym**

  Define the cpp symbol *sym*

- **-Usym**

  Undefine the cpp symbol *sym*

## TRANSFORMATION OPTIONS

The following options are available to change the usual transformation behaviour.

- **-unlit**

  Unliterate the source code.  (Automatic if the file is .lhs)

- **-nounlit**

  Do not unliterate the source code.  (Automatic if the file is .hs)

- **-underscore**

  Treat underscores strictly as lowercase (default).

- **-nounderscore**

  Treat underscores as invisible, e.g. \_f is varid, \_F is conid.

- **-prelude**

  Treat prelude definitions specially.

- **-noprelude**

  Do not treat definitions specially (default).

- **-trusted**

  Make this a "trusted" module.

- **-notrusted**

  Make this an "untrusted" module (default).

- **-showwidth=w**

  Set output width (in characters) to *w* (default=80).

- **-showindent=i**

  Set layout nesting indentation (in characters) to *i* (default=2).

- **-showqualified**

  Use fully qualified names in the output.  This is off by default, because the output may refer to modules which are not explicitly imported.

## EXAMINATION OPTIONS

The following options are available to examine the internal progress of the transformation.

- **-lex**

  Show input after lexical analysis.

- **-parse**

  Show syntax tree after parsing.

- **-tracefns**

  Show syntax tree after tracing translation.

## FILES

- **/usr/bin/hat-trans**

  ## SEE ALSO

[hmake(1)](/hmake/1.md), [hat-detect(1)](/hat-detect/1.md), [hat-observe(1)](/hat-observe/1.md), [hat-trail(1)](/hat-trail/1.md), [hat-stack(1)](/hat-stack/1.md)
