HUGS(1)

πŸ“¦
version 98.200609.21 Β· 4 versions
, in debian bookworm, ubuntu jammy, ubuntu noble, ubuntu questing

πŸ’– HUGS πŸ’– β€” the Hugs 98 functional programming system

okay bestie, so this is the section 1 man page for the whole hugs family β€” <cyan>hugs</cyan>, <cyan>runhugs</cyan>, and <cyan>ffihugs</cyan>. It's giving interpreter, it's giving compiler-adjacent, it's giving 1999 but make it iconic. Let's go 🫢


🌸 NAME 🌸

hugs, runhugs, ffihugs β€” Hugs 98, the functional programming system. That's the trio, bestie. Three commands, one vibe. πŸ’…


✨ SYNOPSIS ✨

the whole thing, exactly as it lives:

hugs [ options ] [ modules ]
runhugs [ options ] module [ args ]
ffihugs [ options ] module [ compiler_argument ] ...

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so Hugs is an interpreter for Haskell, which is a standard non-strict functional programming language β€” yes bestie, lazy evaluation is the whole personality, we love her. Hugs implements almost all of the Haskell 98 standard, with one little exception: mutually recursive modules are not a thing here. Not it. πŸ™ˆ

and the name? Hugs is a mnemonic for the Haskell User's Gofer System. cute, right? a backronym with main character energy. πŸ‘‘

You start the interpreter with the hugs command. Once it's done chewing on your options, it loads the standard module Prelude plus whatever other modules you listed on the command line. Simple as that. πŸ’–

Every Haskell module lives in its own separate file. When Hugs loads a module name, here's the little trick it does: it replaces every . in the name with a /, and then goes hunting through every directory on its search path (that's the -P option, more on her under OPTIONS) for the files name.hs and name.lhs. (And yeah, you can change which suffixes it recognizes with the -S option β€” also described under OPTIONS, keep scrolling bestie.) It also just tries name as a literal filename, because why not. And files ending in ".lhs" get treated as literate scripts. ✨


πŸŽ€ OPTIONS πŸŽ€

Some of these are toggled with + or - to flip them on or off respectively. Turn it on, turn it off, we're flexible. πŸ’…

🧚 Language conformance

  • +98 β€” accept only Haskell 98 (this one cannot be changed within Hugs; default: on). Turning it off unlocks several special Hugs extensions, which are described in the Hugs 98 User Manual. πŸ‘€
  • +o β€” allow overlapping instances (a Hugs extension; default: off)
  • +O β€” allow unsafe overlapping instances (a Hugs extension; default: off) β€” note the capital O, bestie, and note the word unsafe. πŸ’€
  • +H β€” allow here documents (a Hugs extension; default: off)

πŸ“¦ Module loading

  • +l β€” treat files whose names end in neither .hs nor .lhs as literate scripts (default: off)
  • +. β€” print dots to show progress while loading modules (default: off)
  • +q β€” print nothing to show progress while loading modules (default: on)
  • +w β€” always show which files are loaded (default: off)

πŸ”₯ Expression evaluation

  • +s β€” print number of reductions/cells after each evaluation (default: off)
  • +t β€” print the type after each evaluation (default: off)
  • +T β€” apply the Haskell defaulting rules before printing types (default: off)
  • +g β€” print number of cells recovered after each garbage collection (default: off)
  • +Q β€” qualify names when printing (default: off)
  • +k β€” show kind errors in full (default: off)
  • +u β€” use "show" to display results (default: on)
  • +I β€” display results of IO programs (default: off)

πŸ“ Parameters

Other options β€” and for these, the - could be swapped for a +, the choice makes no difference at all β€” are:

  • -hnum β€” set heap size (this one cannot be changed within Hugs; default: 250K)
  • -pstr β€” set prompt string to str (default: `%s> '). Any %s in the prompt gets replaced by the current module name. ✨
  • -rstr β€” set the repeat last expression string to str (default: $$)
  • -Pstr β€” set the search path for source files to str, which should be a colon-separated list of directories. A null entry in this list gets replaced by the previous search path; a null str means the default path. Any occurrence of {Hugs} in this string expands to the Hugs library directory, namely /usr/lib/hugs. Similarly, {Home} expands to your home directory (the value of the HOME environment variable). And an entry of the form directory/* means all the immediate subdirectories of directory. The default value is:
.:{Home}/lib/hugs/packages/*:/usr/local/lib/hugs/packages/*:{Hugs}/packages/*:{Hugs}/libraries
  • -Sstr β€” set the colon-separated list of source file suffixes to str (default: .hs:.lhs). A null entry in this list gets replaced by the previous suffix list; a null str means the default list.
  • -Estr β€” use the editor setting given by str (default: the value of the EDITOR environment variable). Any occurrences of %d and %s in the editor option get replaced by the start line number and the name of the file to be edited, respectively. A common setting is "vi +%d %s". 🫢
  • -cnum β€” set the constraint cutoff limit in the type checker to num (default: 40).
  • -Fcmd β€” set the preprocessor filter for source files to cmd (unset by default). Instead of reading a source file directly, Hugs will read the standard output of cmd run with the source file name as argument.
  • -Xstr β€” the string str is interpreted as an option string. This is useful, for example, for passing multiple arguments to runhugs in a #! script. iykyk πŸ’…

πŸ‘‘ COMMANDS πŸ‘‘

Once the interpreter is loaded up, these commands are your besties:

  • :load [modules] β€” clear all modules except the prelude, and load the specified modules.
  • :also modules β€” read additional modules.
  • :reload β€” repeat last load command.
  • :edit file β€” edit file.
  • :edit β€” edit last file.
  • :module module β€” set module for evaluating expressions.
  • expr β€” evaluate expression.
  • :type expr β€” print type of expression.
  • :? β€” display this list of commands.
  • :set options β€” set command line options.
  • :set β€” help on command line options.
  • :names [patterns] β€” list names currently in scope matching any of the shell-style patterns.
  • :info names β€” describe named objects.
  • :browse modules β€” browse names exported by modules.
  • :find name β€” edit file containing definition of name.
  • :!command β€” shell escape.
  • :cd dir β€” change directory.
  • :gc β€” force garbage collection.
  • :version β€” print Hugs version.
  • :quit β€” exit Hugs interpreter.

Any command may be abbreviated to :c where c is the first character in the full name. Short and sweet, we love efficiency. And on most systems, you can also exit from Hugs by typing the end-of-file character (^D). πŸ¦‹

Note that the interrupt key (^C on most systems) can be used at any time whilst using Hugs to abandon the process of reading in a file of function definitions or the evaluation of an expression. When the interrupt is detected, Hugs prints the string "{Interrupted!}" and prints the prompt so that further commands can be entered.

🧚 STANDALONE PROGRAMS 🧚

The runhugs command is an interpreter for an executable Hugs script, and that script must contain a Haskell Main module. For example, the executable file hello might contain the lines:

#!/usr/bin/runhugs +l

> module Main where
> main = putStr "Hello, World\n"

When this file is executed, runhugs will invoke the main function. Any arguments given on the command line will be available through getArgs. πŸŽ€

Note that #! passes only one orgument to the script. The -X option may be used to get around this.

πŸ’œ C INTERFACE πŸ’œ

On architectures that support dynamic linking, Hugs implements the part of the Haskell 98 Foreign Function Interface (FFI) that allows Haskell functions to call C routines. (On the x86, PowerPC and Sparc architectures, all foreign imports are supported; on others, only static imports are provided.) Modules containing such foreign declarations must be compiled using the ffihugs command before use with hugs. Additional arguments for the C compiler may be supplied via compiler_arguments.

For example, suppose you have some C functions in test.c and some FFI declarations for those functions in Test.hs, and the code in test.c needs to be compiled with -lm. Then you would compile the module with the command:

ffihugs Test.hs test.c -lm

which generates an object file Test.so. Then when hugs loads Test.hs, it will also load Test.so. slay. πŸ’…

In the standard FFI, each foreign import declaration should name a C header file containing the prototype of the function. Because this is often cumbersome, ffihugs provides the following additional option:

  • -istr β€” specify an include for the generated C file. The include string should be something that can follow "#include" in a C program, as in:
ffihugs '-i<math.h>' '-i"mydefs.h"' Test.hs test.c -lm

🌈 ENVIRONMENT 🌈

  • HUGSFLAGS β€” additional options for hugs, processed before any given on the command line.
  • HUGSDIR β€” the Hugs library directory (default: /usr/lib/hugs).
  • EDITOR β€” the default editor, if -E is not given.
  • SHELL β€” used to specify the shell that is invoked by the :! command.

⭐ FILES ⭐

  • /usr/bin/hugs β€” executable binary.
  • /usr/lib/hugs β€” directory containing support files.

πŸ¦‹ WEB REFERENCES πŸ¦‹


πŸŽ€ SEE ALSO πŸŽ€

  • Mark P. Jones et al. Hugs 98 User Manual, June 1999.
  • Hugs 98 User's Guide (distributed with Hugs).
  • Paul Hudak & Joseph H. Fasel. A gentle introduction to Haskell. ACM SIGPLAN Notices, 27(5), May 1992.
  • S. Peyton Jones (editor). Haskell 98 Language and Libraries: The Revised Report. December 2002.
  • Manuel Chakravarty et al. Haskell 98 Foreign Function Interface 1.0, Addendum to the Haskell Report, September 2003.

πŸ’– AUTHOR πŸ’–

  • Hugs 98: Mark Jones and others, June 1999.
  • Manual page: Jonathan Bowen, modified by Gary Leavens, and then (with apologies to the original authors) by Mark Jones. Updated for Hugs 98 by Antti-Juhani Kaijanaho and Ross Paterson. Updated for the March 2005 ffihugs changes by Joseph P. Skudlarek.

and that's the whole page bestie 🫢 this one's dated December 2005 and it lives in section 1 of the manual β€” go forth and interpret some Haskell, you absolute icon. πŸ’…βœ¨

πŸ“¦ where this page comes from