[Haskell-cafe] Writing functions in Haskell.

Cale Gibbard cgibbard at gmail.com
Thu Apr 28 21:22:15 EDT 2005


Hi,

I'm sorry to hear that you've been having a hard time finding good
references. From the example you gave, it looks like you're using "Yet
Another Haskell Tutorial" from http://www.isi.edu/~hdaume/htut/ which
is actually my favourite tutorial.

When using hugs or ghci, you should note that what these do is to
evaluate Haskell expressions and print (or execute) the results. To
actually write programs, (define data types and functions and such)
you'll need to fire up a text editor and enter your definitions into a
.hs file, which you can then load with your interpreter by passing the
filename on the commandline, or by using ":load filename.hs" at the
hugs or ghci prompt. I think this handles your first problem.

The second problem arises from hugs not doing the same thing as ghci
with respect to looking up qualified variable names (that is, those
with the module name specified, in this case, the standard module
Char). You can tell hugs to also load the Char module on top of
whatever code you have loaded by using the command ":also Char", after
which the prompt should look like
Char>
and you can try
toUpper 'a'
(without the Char, hugs doesn't seem to like qualified names, perhaps
someone else can explain this)

There are a number of resources which you might be interested in for
learning Haskell. You've already found the mailing lists, there is
also an IRC channel: #haskell on irc.freenode.net, where there are
plenty of people to help at any time. There's also a wiki at:
http://www.haskell.org/hawiki/FrontPage
The page http://www.haskell.org/hawiki/HaskellNewbie in particular
might be useful, as it answers lots of common questions from new
users. If you have additional questions, feel free to ask them there
and someone will probably respond fairly quickly.

I'm not sure how you found the tutorial, but if it wasn't from the
Learning Haskell page on haskell.org, I'll point you at that, since it
links to a bunch of other potentially useful resources:
http://www.haskell.org/learning.html

hope this helps,
 - Cale

On 4/28/05, Daniel Carrera <dcarrera at digitaldistribution.com> wrote:
> Hello,
> 
> I'm trying to get started with Haskell. I must say that as good as the
> language must be, the documentation was been a source of frustration.
> Only one document actually showed me how to get started (ie. run hugs or
> ghci), and I was asked to give out my email address before getting it.
> 
> Sigh...
> 
> Well, in any event, I did get that document in the end and I've been
> reading through it. I've compiled Hugs on my Solaris workstation. There
> were no errors at compilation. Yet, I think there's something seriously
> wrong with my installation. I can't seem to be able to defin functions:
> 
> my/prompt $ hugs
> ....
> Hugs.Base> fibs 1 = 1
> ERROR - Syntax error in input (unexpected `=')
> 
> And some functions seem to be missing.
> 
> Hugs.Base> Char.toUpper 'a'
> ERROR - Undefined qualified variable "Char.toUpper"
> 
> I was hoping that someone could confirm or deny that my Hugs
> installation is broken.
> 
> Thank you for your time.
> 
> Cheers,
> Daniel.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list