Hugs

Hugs (Sistemul Gofer al utilizatorului Haskell), de asemenea, Hugs 98, este un interpret bytecode pentru limbaj de programare funcțională Haskell. Hugs este succesorul lui Gofer și a fost inițial derivat din Gofer versiunea 2.30b[3]. Hugs și Gofer au fost inițial dezvoltate de Mark P. Jones, acum profesor la Portland State University.

Hugs 98
DezvoltatorMark P. Jones, others
Ultima versiuneSeptember 2006 (  (2006-09-21))
Stare de dezvoltareInactive[1]
Scris înC[2] 
Sistem de operareCross-platform
TipCompiler
LicențăBSD
Prezență online
Hugs 98 homepage

Hugs vine cu o bibliotecă simplă de grafică. Ca o implementare completă Haskell, care este portabilă și ușor de instalat, Hugs este uneori recomandat pentru noii utilizatori Haskell.

Hugs se abate de la specificația Haskell 98[4] în câteva moduri minore[5]. De exemplu, Hugs nu acceptă module reciproc recursive. Există o listă de diferențe[6].

Interfața Hugs (un Haskell REPL) acceptă expresii pentru evaluare, dar nu definiții de module, tip sau funcții. Îmbrățișările pot încărca modulele Haskell la pornire[7].

Exemple

Înregistrări extinse

Un exemplu de "înregistrări tipărite cu extensibilitate", o caracteristică non-standard unică pentru Hugs[8].

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'

Rularea cu compatibilitatea H98 oprită pentru a activa extensiile de limbă:[9]

runhugs -98 test.hs

Note

  1. „Hugs 98”. www.haskell.org.
  2. The hugs Open Source Project on Open Hub: Languages Page (în engleză), Open Hub, accesat în
  3. „Frequently Asked Questions about Hugs”. Accesat în .
  4. Simon Peyton Jones (editor) (decembrie 2002). „Haskell 98 Language and Libraries: The Revised Report”. Accesat în .
  5. „Haskell 98 non-compliance”. The Hugs 98 User's Guide. Accesat în .
  6. „List of differences with H98 standard”.
  7. „Loading and editing Haskell module files”. The Hugs 98 User's Guide. Accesat în .
  8. „Hugs-specific language extensions”. www.haskell.org.
  9. „Changing the behaviour of Hugs”. www.haskell.org.

Legături externe

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.