OnWorks favicon

cpphs - Online in the Cloud

Run cpphs in OnWorks free hosting provider over Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator

This is the command cpphs that can be run in the OnWorks free hosting provider using one of our multiple free online workstations such as Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator



cpphs - liberalised cpp-a-like preprocessor for Haskell




cpphs is a liberalised re-implementation of cpp (1), the C pre-processor, in and for

Why re-implement cpp? Rightly or wrongly, the C pre-processor is widely used in Haskell
source code. It enables conditional compilation for different compilers, different
versions of the same compiler, and different OS platforms. It is also occasionally used
for its macro language, which can enable certain forms of platform-specific detail-
filling, such as the tedious boilerplate generation of instance definitions and FFI
declarations. However, there are two problems with cpp, aside from the obvious aesthetic

For some Haskell systems, notably Hugs on Windows, a true cpp is not available by

Even for the other Haskell systems, the common cpp provided by the gcc 3.x series
is changing subtly in ways that are incompatible with Haskell's syntax. There have
always been problems with, for instance, string gaps, and prime characters in
identifiers. These problems are only going to get worse.

So, it seemed right to attempt to provide an alternative to cpp, both more compatible with
Haskell, and itself written in Haskell so that it can be distributed with compilers.

cpphs is pretty-much feature-complete, and compatible with the -traditional style of cpp.
It has two modes:

conditional compilation only (--nomacro),

and full macro-expansion (default).

In --nomacro mode, cpphs performs only conditional compilation actions, i.e. #include's,
#if's, and #ifdef's are processed according to text-replacement definitions (both command-
line and internal), but no parameterised macro expansion is performed. In full
compatibility mode (the default), textual replacements and macro expansions are also
processed in the remaining body of non-cpp text.

Working Features:

#ifdef simple conditional compilation

#if the full boolean language of defined(), &&, ||, ==, etc.

#elif chained conditionals

in-line definitions (text replacements and macros)

#undef in-line revocation of definitions

file inclusion

#line line number directives

\n line continuations within all # directives

/**/ token catenation within a macro definition

## ANSI-style token catenation

# ANSI-style token stringisation

special text replacement for DIY error messages

special text replacement for DIY error messages

special text replacement

special text replacement

Macro expansion is recursive. Redefinition of a macro name does not generate a warning.
Macros can be defined on the command-line with -D just like textual replacements. Macro
names are permitted to be Haskell identifiers e.g. with the prime ` and backtick ´
characters, which is slightly looser than in C, but they still may not include operator

Numbering of lines in the output is preserved so that any later processor can give
meaningful error messages. When a file is #include'd, cpphs inserts #line directives for
the same reason. Numbering should be correct even in the presence of line continuations.
If you don't want #line directives in the final output, use the --noline option.

Any syntax errors in cpp directives gives a message to stderr and halts the program.
Failure to find a #include'd file produces a warning to stderr, but processing continues.

You can give any number of filenames on the command-line. The results are catenated on
standard output.

-Dsym define a textual replacement (default value is 1)

define a textual replacement with a specific value

-Ipath add a directory to the search path for #include's

-Ofile specify a file for output (default is stdout)

only process #ifdef's and #include's,
do not expand macros

remove #line droppings from the output

convert C-style comments to whitespace, even outside
cpp directives

recognise the ANSI # stringise operator, and ## for
token catenation, within macros

--text treat the input as plain text, not Haskell code

preserve newlines within macro expansions

remove literate-style comments

report version number of cpphs and stop

There are NO textual replacements defined by default. (Normal cpp usually has definitions
for machine, OS, etc. These could easily be added to the cpphs source code if you wish.)
The search path is searched in order of the -I options, except that the directory of the
calling file, then the current directory, are always searched first. Again, there is no
default search path (and again, this could easily be changed).


In general, cpphs is based on the -traditional behaviour, not ANSI C, and has the
following main differences from the standard cpp.


The # that introduces any cpp directive must be in the first column of a line (whereas
ANSI permits whitespace before the # ).

Generates the #line n "filename" syntax, not the # n "filename" variant.

C comments are only removed from within cpp directives. They are not stripped from other
text. Consider for instance that in Haskell, all of the following are valid operator
symbols: /* */ */* However, you can turn on C-comment removal with the --strip option.

Macro language

Accepts /**/ for token-pasting in a macro definition. However, /* */ (with any text
between the open/close comment) inserts whitespace.

The ANSI ## token-pasting operator is available with the --hashes flag. This is to avoid
misinterpreting any valid Haskell operator of the same name.

Replaces a macro formal parameter with the actual, even inside a string (double or single
quoted). This is -traditional behaviour, not supported in ANSI.

Recognises the # stringisation operator in a macro definition only if you use the --hashes
option. (It is an ANSI addition, only needed because quoted stringisation (above) is
prohibited by ANSI.)

Preserves whitespace within a textual replacement definition exactly (modulo newlines),
but leading and trailing space is eliminated.

Preserves whitespace within a macro definition (and trailing it) exactly (modulo
newlines), but leading space is eliminated.

Preserves whitespace within macro call arguments exactly (including newlines), but leading
and trailing space is eliminated.

With the --layout option, line continuations in a textual replacement or macro definition
are preserved as line-breaks in the macro call. (Useful for layout-sensitive code in

Use cpphs online using onworks.net services

Free Servers & Workstations

Download Windows & Linux apps

  • 1
    Fork of TeamWinRecoveryProject(TWRP)
    with many additional functions, redesign
    and more Features:Supports Treble and
    non-Treble ROMsUp-to-date Oreo kernel,
    Download OrangeFox
  • 2
    itop - ITSM  CMDB OpenSource
    itop - ITSM CMDB OpenSource
    IT Operations Portal: a complete open
    source, ITIL, web based service
    management tool including a fully
    customizable CMDB, a helpdesk system and
    a document man...
    Download itop - ITSM CMDB OpenSource
  • 3
    Clementine is a multi-platform music
    player and library organizer inspired by
    Amarok 1.4. It has a fast and
    easy-to-use interface, and allows you to
    search and ...
    Download Clementine
  • 4
    ATTENTION: Cumulative update 2.4.3 has
    been released!! The update works for any
    previous 2.x.x version. If upgrading
    from version v1.x.x, please download and
    Download XISMuS
  • 5
    Modular headtracking program that
    supports multiple face-trackers, filters
    and game-protocols. Among the trackers
    are the SM FaceAPI, AIC Inertial Head
    Tracker ...
    Download facetracknoir
  • 6
    PHP QR Code
    PHP QR Code
    PHP QR Code is open source (LGPL)
    library for generating QR Code,
    2-dimensional barcode. Based on
    libqrencode C library, provides API for
    creating QR Code barc...
    Download PHP QR Code
  • 7
    Cuckoo Sandbox
    Cuckoo Sandbox
    Cuckoo Sandbox uses components to
    monitor the behavior of malware in a
    Sandbox environment; isolated from the
    rest of the system. It offers automated
    analysis o...
    Download Cuckoo Sandbox
  • More »

Linux commands

  • 1
    rsbac-admin - Rule Set Based Access
    Control DESCRIPTION: rsbac-admin is a
    set of tool used to manage systems using
    a Rule Set Based Access Control (RSBAC)
    Run acl_gran
  • 2
    rsbac-admin - Rule Set Based Access
    Control DESCRIPTION: rsbac-admin is a
    set of tool used to manage systems using
    a Rule Set Based Access Control (RSBAC)
    Run acl_grant
  • 3
    cpupower idle-set - Utility to set cpu
    idle state specific kernel options
    SYNTAX: cpupower [ -c cpulist ]
    idle-info [options] DESCRIPTION: The
    cpupower idle-se...
    Run cpupower-idle-set
  • 4
    cpupower-info - Shows processor power
    related kernel or hardware
    configurations ...
    Run cpupower-info
  • 5
    g15daemon - provides access to extra
    keys and the LCD available on the
    logitech G15 keyboard. DESCRIPTION:
    G15Daemon allows users access to all
    extra keys by d...
    Run g15daemon
  • 6
    laditools - tools to control and
    monitor LADI (JACK and ladish) systems ...
    Run g15ladi
  • More »