Hugs (interpreter)
   HOME

TheInfoList



OR:

Hugs (Haskell User's Gofer System), also Hugs 98, is a
bytecode Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (normal ...
interpreter Interpreting is translation from a spoken or signed language into another language, usually in real time to facilitate live communication. It is distinguished from the translation of a written text, which can be more deliberative and make use o ...
for the functional
programming language A programming language is a system of notation for writing computer programs. Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
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 pioneered several programming language ...
. Hugs is the successor to
Gofer A gofer, go-fer or gopher is an employee who specializes in the delivery of specific items to their superior(s). Examples of these items include a cup of coffee, a tool, a tailored suit, or a car. Outside of the business world, the term is use ...
, and was originally derived from Gofer version 2.30b. Hugs and Gofer were originally developed by Mark P. Jones, now a professor at
Portland State University Portland State University (PSU) is a public research university in Portland, Oregon, United States. It was founded in 1946 as a post-secondary educational institution for World War II veterans. It evolved into a four-year college over the next ...
. Hugs comes with a simple graphics library. As a complete Haskell implementation that is
portable Portable may refer to: General * Portable building, a manufactured structure that is built off site and moved in upon completion of site and utility work * Portable classroom, a temporary building installed on the grounds of a school to provide a ...
and simple to install, Hugs is sometimes recommended for new Haskell users. Hugs deviates from the Haskell 98 specification in several minor ways. For example, Hugs does not support mutually recursive modules. A list of differences exists. The Hugs prompt is a Haskell
read–eval–print loop A read–eval–print loop (REPL), also termed an interactive toplevel or language shell, is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user; a program written ...
(REPL). It accepts expressions for evaluation, but not module, type, or function definitions. Hugs can load Haskell modules at start-up.


Examples


Extensible records

An example of "typed records with extensibility", a non-standard feature unique to Hugs. module Main where import Hugs.Trex type Coord = Double type Point2D = Rec (x::Coord, y::Coord) type Point3D = 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 x addZCoord :: (r\z, r\x) => t -> Rec ( x::t , r) -> Rec ( x::t, z::t , r) addZCoord z ( x = x , other) = (x = x, z = z , other) point3D = addZCoord 3 point2D -- :: Point3D -- admit any record with ''showable'' fields x and y printXY :: (Show t, r\x, r\y) => Rec (x::t, y::t , r) -> IO () printXY point = putStrLn xy -- with SML style field accessors ('#' prefix) where xy = show (#x point) ++", "++ show (#y point) incrementX :: (Num t, r\x) => Rec (x::t , r) -> Rec (x::t , r) incrementX (x=v , rest) = (x=v+1 , rest) main = do let point3D' = incrementX point3D printXY point2D printXY point3D' Running with H98 compatibility turned off to activate language extensions:
runhugs -98 test.hs


References


External links

* {{Portalbar, Free and open-source software Free Haskell implementations Software using the BSD license Articles with example Haskell code