In +98 mode, Hugs supports Haskell 98 and some standardized extensions (described by addenda to the Haskell 98 report).
Hugs deviates from Haskell 98 in a few minor ways, listed here corresponding to the relevant sections of the Report.
The Haskell report specifies that programs may be written using Unicode. Hugs only accepts the ISO8859-1 (Latin-1) subset at the moment.
Hugs is confused by such things as "0xy", "0oy", "9e+y" and "9.0e+y", because it doesn't look far enough ahead.
Hugs doesn't use the fixity of operators until after parsing, and so fails to accept legal (but weird) Haskell 98 expressions like
let x = True in x == x == True |
In Hugs, the expression must be an fexp (or case or do). Legal expressions like (a+b+)) and (a*b+)) are rejected.
Hugs's treatment of polymorphic recursion is less restrictive than Haskell 98 when the functions involved are mutually recursive. Consider the following example:
data BalancedTree a = Zero a | Succ (BalancedTree (a,a)) zig :: BalancedTree a -> a zig (Zero a) = a zig (Succ t) = fst (zag t) zag (Zero a) = a zag (Succ t) = snd (zig t) |
In Hugs, the binding of zig depends on that of zag, but not vice versa. (The binding of zag is considered to depend only on the explicit signature of zig.) It is possible to infer a polymorphic type for zag, and from that for zig. This type matches the declared signature, so Hugs accepts this example.
Contrary to the the Report (4.3.1), Hugs allows the types of the member functions of a class C a to impose further constraints on a, as in
class Foo a where op :: Num a => a -> a -> a |
For example, Hugs rejects the following example from the Haskell 98 Report, 4.5.5:
module M where import List len1 = genericLength "Hello" len2 = (2*len1) :: Rational |
In Haskell 98, type inference is then performed on len2, resolving the type variable a to Rational, and the module is legal.
In Hugs, the defaulting rule is applied to len1, instantiating the type variable a to Integer. Then type inference on len2 fails.
In Haskell 98, if the module header is omitted, it defaults to "module Main(main) where". In Hugs it defaults to "module Main where", because many people test small modules without module headers.
In Haskell 98, a missing export list means all names defined in the current module. In Hugs, it is treated as "(module M)", where M is the current module. This is almost the same, differing only when an imported module is aliased as M.
Hugs allows the T(..) syntax for type synonyms in export and import lists. It also allows the form T() for type synonyms in import lists.
Note that although the Haskell 98 specification of the Prelude and library modules is recursive, Hugs achieves the same effect by putting most of these definitions in a module Hugs.Prelude that these modules import.
The Hugs prelude exports (:) as if it were an identifier, even though this is not permitted in user-defined modules. This means that Hugs incorrectly rejects the following:
module Foo where import Prelude() cs = 'a':cs |
The type Char is limited to the ISO8859-1 subset of Unicode.
In Haskell 98, a floating point literal like 1.234e-5 stands for "fromRational (1234 % 100000000)". In particular, if the literal is of Rational type, the fraction is exact. In Hugs such literals are stored as double precision floating point numbers. If the literal is of Rational type, it usually denotes the same number, but some precision may be lost.
Haskell 98 specifies that show for floating point numbers is the function Numeric.showFloat, but Hugs uses an internal function with slightly different semantics.
In Haskell 98, all tuple types are instances of Eq, Ord, Bounded, Read, and Show if all their component types are. Hugs defines these instances only for tuple types of size 5 or less (3 or less in the small Hugs configuration).