WinHugs extremely basic newbie question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

WinHugs extremely basic newbie question

Risto Rangel Kuoppa
Hello everyone,

I am having troubles to start using WinHugs.  I downloaded it, installed,
and run it.  Yet I am unable to run something else than just evaluating
expressions.  For example, I am trying to define my first data type with:

Hugs> data Tipo = Cruz | Circulo deriving Eq

But all I get is:
ERROR - Syntax error in expression (unexpected keyword "data")
Hugs>

I think that I must load some module or library but when I make:


Hugs> :load "C:\\Program
Files\\WinHugs\\packages\\hugsbase\\Hugs\\Prelude.hs"

I get:
ERROR file:.\Prelude.hs - Module "Hugs.Prelude" already loaded
Hugs.Prelude>

And I cannot find any Data.hs (Does it actually exist?) anywhere.  Could
someone help me with this please? I have already spent several hours
trying to figure it out.  All I want is to start testing the tutorials and
learn Haskell but I am missing something to run them with WinHugs.

Thanks in advance,

Risto



_______________________________________________
Hugs-Users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/hugs-users
Reply | Threaded
Open this post in threaded view
|

Re: WinHugs extremely basic newbie question

Thorkil Naur
Hello Risto,

I don't have a Windows system myself, and therefore no winhugs, but your
problems seem unrelated to winhugs as such, so I will try to indicate how you
might proceed, using my Linux Hugs for illustration.

On Thursday 06 September 2007 14:13, Risto Rangel Kuoppa wrote:
> Hello everyone,
>
> I am having troubles to start using WinHugs.  I downloaded it, installed,
> and run it.  Yet I am unable to run something else than just evaluating
> expressions.  For example, I am trying to define my first data type with:
>
> Hugs> data Tipo = Cruz | Circulo deriving Eq

Quoting from the "The Hugs 98 User's Guide": "The Hugs prompt accepts
expressions, but not Haskell definitions." (See
http://cvs.haskell.org/Hugs/pages/users_guide/module-commands.html) So if you
wish to work with definitions, you have to put them in a file and either list
the file on the hugs command line (this is not winhugs) or load the file from
the hugs promt. Here is what it would look like on a Linux system:

> tn@linux:~/tn/tmp/hugs> cat Risto1.hs
> data Tipo = Cruz | Circulo deriving Eq

("cat" is the Linux "type" command.)

> tn@linux:~/tn/tmp/hugs> hugs
> __   __ __  __  ____   ___      _________________________________________
> ||   || ||  || ||  || ||__      Hugs 98: Based on the Haskell 98 standard
> ||___|| ||__|| ||__||  __||     Copyright (c) 1994-2003
> ||---||         ___||           World Wide Web: http://haskell.org/hugs
> ||   ||                         Report bugs to: [hidden email]
> ||   || Version: November 2003  _________________________________________
>
> Haskell 98 mode: Restart with command line option -98 to enable extensions
>
> Type :? for help
> Prelude> :load Risto1
> Main> Cruz
> ERROR - Cannot find "show" function for:
> *** Expression : Cruz
> *** Of type    : Tipo
>
> Main> :type Cruz
> Cruz :: Tipo
> Main>

From this, you can see that hugs has indeed "got" the data definition. (To
enable values of type Tipo to be printed, you should derive Show in addition
to Eq.)

>
> But all I get is:
> ERROR - Syntax error in expression (unexpected keyword "data")
> Hugs>
>
> I think that I must load some module or library but when I make:
>
>
> Hugs> :load "C:\\Program
> Files\\WinHugs\\packages\\hugsbase\\Hugs\\Prelude.hs"
>
> I get:
> ERROR file:.\Prelude.hs - Module "Hugs.Prelude" already loaded
> Hugs.Prelude>

Here, you are trying to load the standard prelude, but that is loaded already
by default, so the error message tells you exactly that. As indicated, you
should probably create your own file, containing your definitions, and then
load that.

>
> And I cannot find any Data.hs (Does it actually exist?) anywhere.

I am not sure what you are getting at here. Please give some additional
information.

I hope that you will be able to get past some of the initial hurdles. If not,
or if you have additional questions, please feel free to ask again.

Best regards
Thorkil

> Could
> someone help me with this please? I have already spent several hours
> trying to figure it out.  All I want is to start testing the tutorials and
> learn Haskell but I am missing something to run them with WinHugs.
>
> Thanks in advance,
>
> Risto
>
>
>
> _______________________________________________
> Hugs-Users mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/hugs-users
>
_______________________________________________
Hugs-Users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/hugs-users