Questions tagged [hugs]

Hugs 98 is a functional programming system based on Haskell 98.

Hugs is a compiler which implements most of the Haskell 98 standard but deviates from it in a few minor ways. Features include:

  • Lazy evaluation, higher order functions, and pattern matching.
  • A wide range of built-in types, from characters to bignums, and lists to functions, with comprehensive facilities for defining new datatypes and type synonyms.
  • An advanced polymorphic type system with type and constructor class overloading. All of the features of the Haskell 98 expression and pattern syntax including lambda, case, conditional and let expressions, list comprehensions, do-notation, operator sections, and wildcard, irrefutable and `as' patterns.
  • An implementation of the Haskell 98 primitives for monadic I/O, with support for simple interactive programs, access to text files, handle-based I/O, and exception handling.
  • An almost complete implementation of the Haskell module system.
  • Hugs 98 also supports a number of advanced and experimental extensions including multi-parameter classes, extensible records, rank-2 polymorphism, existentials, scoped type variables, and restricted type synonyms.
65 questions
4
votes
1 answer

Hugs `/` vs. Type Inference

In GHCi the following code works fine: f1 :: Float f1 = f2 -- f2 :: Float f2 = 1/1 But in Hugs, I get a type error - it wants to be a Double. When I uncomment the type signature of f2, it works fine. Shouldn't exactly this be taken care of the…
fabb
  • 11,660
  • 13
  • 67
  • 111
3
votes
3 answers

Why does this Show instance in Haskell (Hugs) cause a stack overflow error?

The following is a polymorphic data type in Haskell, interpreted by Hugs. I am trying to create an instance of Show for Equality. The instance declaration says that if a type "a" is in Show, then Equality a is in Show. It should print the two…
Cody
  • 135
  • 1
  • 3
  • 11
3
votes
4 answers

Functions in Haskell

I'm new to functional programming. I have a basic question. I'm using the Hugs interpreter, I would like to write a function in Haskell; I went though several tutorials, but I'm not getting it. fact :: Int -> Int fact n = if n == 0 then 1 else n *…
3
votes
1 answer

Is there a way to run a Haskell console in a recursion depth or memory limited mode?

Here is the problem: sometimes, when playing with GHCI, I end up running an infinite computation by mistake. When this happens, most times, my computer crashes and I'm not even able to interrupt it using Ctrl+C. I wonder if there is a way to run…
matiascelasco
  • 1,145
  • 2
  • 13
  • 18
3
votes
1 answer

Why does Hugs complain about `|` in my data type declaration?

I'm in the process of writing a small lisp interpreter in haskell. In the process I defined this datatype, to get a less typed number. data Number = _Int Integer | _Rational Rational | _Float Double …
keiter
  • 3,534
  • 28
  • 38
3
votes
3 answers

Hugs don't let script file use keyword "let"

I load this file as a module to Hugs, but get this error: ERROR file:.\Hugs.hs:38 - Syntax error in input (unexpected keyword "let") data MetricUnit = Meter | Liter | KiloGram deriving (Show, Eq) data…
CodeFarmer
  • 2,644
  • 1
  • 23
  • 32
3
votes
1 answer

Importing Ratio module using ghci

I am learning Haskell and trying to use exact Rational numbers. I have the the following simple Haskell code: import Ratio x :: Rational x = 5 % 2 When I load this in WinHugs, everything is fine. However, when I load it in ghci, I get the…
Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
2
votes
3 answers

Haskell recursive list comprehension causes C Stack Overflow

So I'm making a list of prime numbers to help me learn haskell using simple trial division (no fancy stuff until I get better with the language). I'm trying to use the following code: primes = 2 : [ x | x <- [3..], all (\p -> (mod x p) /= 0)…
Robert Mason
  • 3,949
  • 3
  • 31
  • 44
2
votes
3 answers

Why can I print a tuple with 5 elements but not with 6 in Haskell?

I tried printing the following tuple (1,2,3,4,5,6) which gave me the following error ERROR - Cannot find "show" function for: *** Expression : (1,2,3,4,5,6) *** Of type : (Integer,Integer,Integer,Integer,Integer,Integer) But if I try it with…
wastl
  • 2,643
  • 14
  • 27
2
votes
1 answer

Make a newtype instance of Eq

I'm learning Haskell and I've been given following assignment - I have a newtype consisting of two mixed data types, and I have to make it an instance of Eq without using deriving. Here's what I have: data Number = One | Two | Three deriving Eq data…
skulpt
  • 527
  • 2
  • 6
  • 25
2
votes
0 answers

emacs haskell-mode repl can't find hugs. how to use ghci instead?

To set up my haskell-in-emacs environment, I dutifully followed the instructions here: http://tim.dysinger.net/posts/2014-02-18-haskell-with-emacs.html When I load Main.hs, it syntax-highlights correctly. When I do Ctrl-c Ctrl-l as instructed, it…
Jake
  • 2,852
  • 7
  • 32
  • 39
2
votes
2 answers

I can't do anything on Haskell due to syntax errors

I can execute simply operations, like Hugs> 2+2 for instance. Or any operation, for that matter. But when it comes to actually trying to define a function, e.g: occurs :: Eq a => a -> [a] -> Bool occurs x l = x `elem` l Then I get the message:…
Jason Born
  • 163
  • 1
  • 14
2
votes
1 answer

Haskell: Why I can load this file in ghci but when I try to do the same in hugs I get a syntax error?

This is the file I am trying to load: import Data.List (foldl') import Text.Printf (printf) import Data.Char (ord) --data IntParsedStr = Int | ParsingError --data ParsingError = ParsingError String asInt :: String -> Either String Integer asInt ""…
matiascelasco
  • 1,145
  • 2
  • 13
  • 18
1
vote
1 answer

How do I use Bits type in Haskell?

I am using WinHugs98 and I would like to do simple XOR of Int 10 with Int 11. How do I do it? Current Attempt: Hugs> :l Data.Bits Data.Bits> (Bits 10) `xor` (Bits 11) ERROR - Undefined data constructor "Bits" How do I convert the integer 10 and 11…
Herman Schoenfeld
  • 8,464
  • 4
  • 38
  • 49
1
vote
1 answer

I want to work with a list of coordinates [Haskell]

So I need to work with a list of coordinates, I already made a type like this: type Pont = (Float, Float) And I need to return a list of Floats calculated from the points I got. What I did so far: szamol :: Pont -> Float szamol 0.0 = 0.0 szamol…
Bery Purda
  • 33
  • 3