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.
62 questions
17
votes
5 answers

Differences Between Hugs, Yhc and GHCi

There are differences between Hugs, Yhc and GHCi? If there are differences, What are they?
Nathan Campos
  • 26,567
  • 57
  • 185
  • 289
15
votes
2 answers

How to implement Dijkstra Algorithm in Haskell

For my studies I have to write the following function which gets the shortest route between two countries. I already have already written a function isRoute which checks if there is a connection between two countries, and a function yieldRoute which…
Jakob Abfalter
  • 4,270
  • 14
  • 48
  • 81
9
votes
2 answers

Can someone explain to me the following Haskell expression

f :: Integer -> Integer -> [Integer] f i n = n : f (i+2) (n+i) can someone explain to me what it does. i know it returns [0,1,4,9,16..] but i dont understand how and what n : f means
code511788465541441
  • 20,207
  • 61
  • 174
  • 298
9
votes
2 answers

Are arithmetic patterns legal Haskell?

Patterns like this: front :: [a] -> a front (x:_) = x front _ = error "Empty list" seem to be common in Haskell, but I distinctively remember learning the following when I started learning Haskell: dec :: (Integral a) => a -> a dec (x+1) = x dec _…
bitmask
  • 25,740
  • 12
  • 80
  • 142
8
votes
2 answers

Writing Haskell interpreter in C++ (using ghc or hugs as library)

I'm writing a C++ application that needs to interpret and evaluate haskell code. This code isn't known at compile time but given by the user. Is there a way to use a haskell compiler/interpreter (like GHCi or hugs) as a library? I found FFI but…
Heinzi
  • 4,834
  • 3
  • 31
  • 57
7
votes
2 answers

A Haskell interpreter /w type definitions

Is there a Haskell interpreter that accepts type definitions or preferably all kinds of statements? I've already tried ghci and hugs and none of these does that. Is there some particular reason that this is hard/impossible?
julx
  • 7,913
  • 5
  • 40
  • 82
7
votes
1 answer

Why aren't the inferred types of these Haskell functions all the same?

I define five functions that seem to me like they should be equivalent (and, therefore, have the same type). But the inferred types are different. I put the following five lines in type-inference.hs: f1 a b = a + b f2 a = \b -> a + b f3 = \a -> \b…
davidthomas
  • 123
  • 4
6
votes
1 answer

Hugs !! Partial Application Bug

Hugs seems to have a problem with several non-enbraced !! in a partial application. While this works fine in GHCi: ([[0]]!!0!!)0 Hugs reports a syntax error for the ). Is this a bug in Hugs? Adding an extra brace for the second list index operator…
fabb
  • 11,262
  • 13
  • 57
  • 109
6
votes
2 answers

"ERROR - C stack overflow" in Haskell using Hugs

I'm working on parsing a CSV file into a CSV type which is a list of Record which is a list of Field, which are just Strings. After inserting a new row and then trying to access the csv I get the c stack overflow error. I'v read this error may come…
6
votes
2 answers

What is the type of (1 2) in Haskell?

I was playing around with hugs today and got stuck at a very simple question: λ 1 1 :: (Num a, Num (a -> t)) => t What would that type be? I am having trouble to read this. And if it has a type, why? I would guess that the expression 1 1 is…
Jens
  • 8,115
  • 1
  • 21
  • 37
6
votes
3 answers

Why Int type 2^31 does not go outside the range in GHCi?

I'm reading Programming in Haskell book and testing provided examples in GHCi interpreter. It turns out, that there is a difference in Int type behavior in GHCi and Hugs interpreter. According to Chapter 3 of "Programming in Haskel", 2^31 :: Int…
Szymon Stepniak
  • 32,284
  • 9
  • 78
  • 108
6
votes
2 answers

Haskell to find the distance between the two closest points

Given a list of points in a two dimensional space, you want to perform a function in Haskell to find the distance between the two closest points. example: Input: project [(1,5), (3,4), (2,8), (-1,2), (-8.6), (7.0), (1.5), (5.5), (4.8),…
franvergara66
  • 9,675
  • 17
  • 51
  • 98
5
votes
2 answers

Hugs type signature contains extra type constraints?

Came across this while playing with Haskell and I'm stumped: Hugs> :type (\x -> x^2) \x -> x ^ 2 :: (Integral a, Num b) => b -> b What is a doing in there? How am I supposed to read that? If I type the same thing into GHCi, it gives me the output I…
Ian Henry
  • 21,297
  • 4
  • 47
  • 60
5
votes
6 answers

How to test my haskell functions

I just started with Haskell and tried to do write some tests first. Basically, I want to define some function and than call this function to check the behavior. add :: Integer -> Integer -> Integer add a b = a+b -- Test my function add 2 3 If I…
mort
  • 10,940
  • 14
  • 45
  • 92
5
votes
2 answers

How to use two let's on the same line?

I'm using Hugs interpreter and I want to execute the following code (by Haskell 2010 language report): let x = 1 z = x+y in z+1 Is it possible only creating a .hs file and loading? Can I do it by command line directly?
eightShirt
  • 1,387
  • 2
  • 13
  • 25
1
2 3 4 5