GHC error! =) 
Author Message
 GHC error! =)

Okay. I've finally got the interpreter for my own little post-script like
language working pretty well.

But interpreting a language in an interpreted interpreter can get pretty
damn slow. =)

So I'm trying to compile it with GHC but I get a weird errors complaining
that "fromInt" and "isDigit" (two functions found in the Prelude?) are out
of scope; "Variable out of scope" it says.

I found this very weird since it works like a charm in Hugs98.
I have never experienced anything like this before. I compile using "ghc
--make Interpreter.hs"

The version of GHC I'm using is 5.04.2

Here's some of the instances where I've used the functions:

        isNumber = and $ map isDigit $ filter (/='.') str

        n_add ((D a):(I b):xs) dic = (D (a + fromInt b) : xs,dic)

So what could be the cause of this behaviour from GHC?

Aprechiate any help.

--

 ----------------------------------------
|  Sebastian Sylvan                      |
|  ICQ: 44640862                         |
|  Tel: 073-6818655 / 031-812 817        |
|                                        |
|  <=================================>   |
|  |Det finns 10 sorters m?nniskor.  |   |
|  |De som f?rst?r det bin?ra tal-   |   |
|  |systemet och de som inte g?r det.|   |
|  <=================================>   |
 ----------------------------------------



Sat, 13 Aug 2005 06:37:56 GMT  
 GHC error! =)

Quote:

> So I'm trying to compile it with GHC but I get a weird errors complaining
> that "fromInt" and "isDigit" (two functions found in the Prelude?) are out
> of scope; "Variable out of scope" it says.

There is no fromInt function in Haskell98 Prelude. Use fromInteger or
fromIntegral instead.

You will find isDigit function in Char module, just 'import Char (isDigit)'.

Best regards,
Tom

--
.signature: Too many levels of symbolic links



Sat, 13 Aug 2005 07:11:48 GMT  
 GHC error! =)

Quote:

> > So I'm trying to compile it with GHC but I get a weird errors complaining
> > that "fromInt" and "isDigit" (two functions found in the Prelude?) are out
> > of scope; "Variable out of scope" it says.

> There is no fromInt function in Haskell98 Prelude. Use fromInteger or
> fromIntegral instead.

> You will find isDigit function in Char module, just 'import Char (isDigit)'.

That was fast! Thank you! It's about 50 times faster now =)

--

 ----------------------------------------
|  Sebastian Sylvan                      |
|  ICQ: 44640862                         |
|  Tel: 073-6818655 / 031-812 817        |
|                                        |
|  <=================================>   |
|  |Det finns 10 sorters m?nniskor.  |   |
|  |De som f?rst?r det bin?ra tal-   |   |
|  |systemet och de som inte g?r det.|   |
|  <=================================>   |
 ----------------------------------------



Sat, 13 Aug 2005 07:40:32 GMT  
 GHC error! =)

Quote:
>I found this very weird since it works like a charm in Hugs98.

Are you using Hugs in hugs mode (the default) or in Haskell98 mode?

Quote:
>I have never experienced anything like this before. I compile using "ghc
>--make Interpreter.hs"

I've rarely not had this happen. I've seen it when moving from jdk1.3 to
1.4, gcc x.x to x.y, c compilers.  As they say, the implementation doesn't
define the language (since circa 1967, except for proprietary
languages...).

Quote:

>    isNumber = and $ map isDigit $ filter (/='.') str

to get isDigit, you need to import Char

Quote:

>    n_add ((D a):(I b):xs) dic = (D (a + fromInt b) : xs,dic)

I believe Hugs defaults to Int, where Haskell98 defaults to Integer;
try fromInteger

John Atwood



Sat, 13 Aug 2005 08:05:41 GMT  
 GHC error! =)

Quote:

> As they say, the implementation doesn't define the language (since
> circa 1967, except for proprietary languages...).

Like that well-known proprietary language Perl?

--
Aaron Denney
-><-



Sat, 13 Aug 2005 08:23:40 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. ghc errors

2. Haskell / GHC: using field names

3. GHC & POSIX package

4. GHC 5.02 and Word8

5. ghc type class extension

6. ANNOUNCE: GHC version 5.04.3 released

7. Haskell (GHC) - Help managing memory

8. Calling Haskell function from C (FFI) causes seg-fault (GHC,linux)

9. Haskell optimizations in GHC

10. ghc installation

11. GHC confusion, and a few haskell questions.

12. String to Int in GHC?

 

 
Powered by phpBB® Forum Software