Hugs (interpreter)

Last updated
Hugs 98
Developer(s) Mark P. Jones, others
Final release
September 2006 / September 21, 2006;17 years ago (2006-09-21)
Operating system Cross-platform
Predecessor Gofer
Type Compiler
License BSD
Website www.haskell.org/hugs

Hugs (Haskell User's Gofer System), also Hugs 98, is a bytecode interpreter for the functional programming language Haskell. Hugs is the successor to Gofer, and was originally derived from Gofer version 2.30b. [1] Hugs and Gofer were originally developed by Mark P. Jones, now a professor at Portland State University.

Contents

Hugs comes with a simple graphics library. As a complete Haskell implementation that is portable and simple to install, Hugs is sometimes recommended for new Haskell users.

Hugs deviates from the Haskell 98 specification [2] in several minor ways. [3] For example, Hugs does not support mutually recursive modules. A list of differences exists. [4]

The Hugs prompt is a Haskell read–eval–print loop (REPL). It accepts expressions for evaluation, but not module, type, or function definitions. Hugs can load Haskell modules at start-up. [5]

Examples

Extensible records

An example of "Typed records with extensibility", a non standard feature unique to Hugs. [6]

moduleMainwhereimportHugs.TrextypeCoord=DoubletypePoint2D=Rec(x::Coord,y::Coord)typePoint3D=Rec(x::Coord,y::Coord,z::Coord)point2D=(x=1,y=1)::Point2D-- emptyRec :: Rec EmptyRow  -- predefined-- (x=1 | (y=1))   -- rec. extension-- (x=v | rec)     -- record value decomposition, pattern fields must be non empty-- (x::type | rec)   -- record type decomposition-- (rec\z) in the context means ''rec'' does not contain field ''z''-- add a field z with the same type as field xaddZCoord::(r\z,r\x)=>t->Rec(x::t|r)->Rec(x::t,z::t|r)addZCoordz(x=x|other)=(x=x,z=z|other)point3D=addZCoord3point2D-- :: Point3D-- admit any record with ''showable'' fields x and y printXY::(Showt,r\x,r\y)=>Rec(x::t,y::t|r)->IO()printXYpoint=putStrLnxy-- with SML style field accessors ('#' prefix)wherexy=show(#xpoint)++", "++show(#ypoint)incrementX::(Numt,r\x)=>Rec(x::t|r)->Rec(x::t|r)incrementX(x=v|rest)=(x=v+1|rest)main=doletpoint3D'=incrementXpoint3DprintXYpoint2DprintXYpoint3D'

Running with H98 compatibility turned off to activate language extensions: [7]

runhugs -98 test.hs 

Related Research Articles

In computer science, an abstract data type (ADT) is a mathematical model for data types, defined by its behavior (semantics) from the point of view of a user of the data, specifically in terms of possible values, possible operations on data of this type, and the behavior of these operations. This mathematical model contrasts with data structures, which are concrete representations of data, and are the point of view of an implementer, not a user. For example, a stack has push/pop operations that follow a Last-In-First-Out rule, and can be concretely implemented using either a list or an array. Another example is a set which stores values, without any particular order, and no repeated values. Values themselves are not retrieved from sets, rather one tests a value for membership to obtain a Boolean "in" or "not in".

OCaml is a general-purpose, high-level, multi-paradigm programming language which extends the Caml dialect of ML with object-oriented features. OCaml was created in 1996 by Xavier Leroy, Jérôme Vouillon, Damien Doligez, Didier Rémy, Ascánder Suárez, and others.

<span class="mw-page-title-main">Lua (programming language)</span> Lightweight programming language

Lua is a lightweight, high-level, multi-paradigm programming language designed primarily for embedded use in applications. Lua is cross-platform, since the interpreter of compiled bytecode is written in ANSI C, and Lua has a relatively simple C API to embed it into applications.

In mathematics, rings are algebraic structures that generalize fields: multiplication need not be commutative and multiplicative inverses need not exist. Informally, a ring is a set equipped with two binary operations satisfying properties analogous to those of addition and multiplication of integers. Ring elements may be numbers such as integers or complex numbers, but they may also be non-numerical objects such as polynomials, square matrices, functions, and power series.

In programming languages, a closure, also lexical closure or function closure, is a technique for implementing lexically scoped name binding in a language with first-class functions. Operationally, a closure is a record storing a function together with an environment. The environment is a mapping associating each free variable of the function with the value or reference to which the name was bound when the closure was created. Unlike a plain function, a closure allows the function to access those captured variables through the closure's copies of their values or references, even when the function is invoked outside their scope.

<span class="mw-page-title-main">Miranda (programming language)</span>

Miranda is a lazy, purely functional programming language designed by David Turner as a successor to his earlier programming languages SASL and KRC, using some concepts from ML and Hope. It was produced by Research Software Ltd. of England and was the first purely functional language to be commercially supported.

Standard ML (SML) is a general-purpose, modular, functional programming language with compile-time type checking and type inference. It is popular for writing compilers, for programming language research, and for developing theorem provers.

Generic programming is a style of computer programming in which algorithms are written in terms of data types to-be-specified-later that are then instantiated when needed for specific types provided as parameters. This approach, pioneered by the ML programming language in 1973, permits writing common functions or types that differ only in the set of types on which they operate when used, thus reducing duplicate code.

In abstract algebra, a Dedekind domain or Dedekind ring, named after Richard Dedekind, is an integral domain in which every nonzero proper ideal factors into a product of prime ideals. It can be shown that such a factorization is then necessarily unique up to the order of the factors. There are at least three other characterizations of Dedekind domains that are sometimes taken as the definition: see below.

In combinatory logic for computer science, a fixed-point combinator, is a higher-order function that returns some fixed point of its argument function, if one exists.

The Glasgow Haskell Compiler (GHC) is a native or machine code compiler for the functional programming language Haskell. It provides a cross-platform software environment for writing and testing Haskell code and supports many extensions, libraries, and optimisations that streamline the process of generating and executing code. GHC is the most commonly used Haskell compiler. It is free and open-source software released under a BSD license. The lead developers are Simon Peyton Jones and Simon Marlow.

In mathematics, the Lasker–Noether theorem states that every Noetherian ring is a Lasker ring, which means that every ideal can be decomposed as an intersection, called primary decomposition, of finitely many primary ideals. The theorem was first proven by Emanuel Lasker for the special case of polynomial rings and convergent power series rings, and was proven in its full generality by Emmy Noether.

In computer science, a type class is a type system construct that supports ad hoc polymorphism. This is achieved by adding constraints to type variables in parametrically polymorphic types. Such a constraint typically involves a type class T and a type variable a, and means that a can only be instantiated to a type whose members support the overloaded operations associated with T.

<span class="mw-page-title-main">Agda (programming language)</span> Functional programming language

Agda is a dependently typed functional programming language originally developed by Ulf Norell at Chalmers University of Technology with implementation described in his PhD thesis. The original Agda system was developed at Chalmers by Catarina Coquand in 1999. The current version, originally known as Agda 2, is a full rewrite, which should be considered a new language that shares a name and tradition.

Gofer is an implementation of the programming language Haskell intended for educational purposes and supporting a language based on version 1.2 of the Haskell report. It was replaced by Hugs.

In computer science, partial application refers to the process of fixing a number of arguments of a function, producing another function of smaller arity. Given a function , we might fix the first argument, producing a function of type . Evaluation of this function might be represented as . Note that the result of partial function application in this case is a function that takes two arguments. Partial application is sometimes incorrectly called currying, which is a related, but distinct concept.

This article describes the features in the programming language Haskell.

Haskell is a general-purpose, statically-typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research, and industrial applications, Haskell has pioneered a number of programming language features such as type classes, which enable type-safe operator overloading, and monadic input/output (IO). It is named after logician Haskell Curry. Haskell's main implementation is the Glasgow Haskell Compiler (GHC).

<span class="mw-page-title-main">Yesod (web framework)</span>

Yesod is a web framework based on the programming language Haskell for productive development of type-safe, representational state transfer (REST) model based, high performance web applications, developed by Michael Snoyman, et al. It is free and open-source software released under an MIT License.

<span class="mw-page-title-main">Elm (programming language)</span> Functional programming language

Elm is a domain-specific programming language for declaratively creating web browser-based graphical user interfaces. Elm is purely functional, and is developed with emphasis on usability, performance, and robustness. It advertises "no runtime exceptions in practice", made possible by the Elm compiler's static type checking.

References

  1. "Frequently Asked Questions about Hugs" . Retrieved 2006-08-04.
  2. Peyton Jones, Simon, ed. (December 2002). Haskell 98 Language and Libraries: The Revised Report (Report). Retrieved 2006-08-03.
  3. "Haskell 98 non-compliance". The Hugs 98 User's Guide. Retrieved 2006-08-04.
  4. "List of differences with H98 standard".
  5. "Loading and editing Haskell module files". The Hugs 98 User's Guide. Retrieved 2006-08-04.
  6. "Hugs-specific language extensions". www.haskell.org.
  7. "Changing the behaviour of Hugs". www.haskell.org.