[Haskell-beginners] consing an element to a list inside a file

kane96 at gmx.de kane96 at gmx.de
Wed Feb 10 16:06:23 EST 2010

It's just a part of a more complex exercise
I have to read an input of the user. After that he can decide if he wants to add another input. If not, all inputs the user did should be printed on the screen. So I want to add each input to a list and print the list at the end.

-------- Original-Nachricht --------
> Datum: Wed, 10 Feb 2010 16:00:35 -0500
> Von: Brent Yorgey <byorgey at seas.upenn.edu>
> An: beginners at haskell.org
> Betreff: Re: [Haskell-beginners] consing an element to a list inside a file

> On Wed, Feb 10, 2010 at 09:52:48PM +0100, kane96 at gmx.de wrote:
> > Hi,
> > I want to add an element to a list inside a haskell file:
> > mylist = [1,2,3,4]
> > 0:mylist
> > in Prelude it works fine, but when I do it in a file I get the error: 
> > parse error (possibly incorrect indentation)
> > Failed, modules loaded: none.
> > in a line after this two that doesn't exist
> A Haskell file is simply a list of declarations, i.e. definitions of
> data types, classes, and functions.  You cannot just have an
> expression by itself in a Haskell file.  You can write expressions at
> a ghci prompt (which I assume is what you meant) because that is what
> ghci is for: evaluating expressions.
> Why do you want 0:mylist by itself in a Haskell file?  What is its
> purpose?  Note that it will not modify the value of mylist (indeed,
> you *cannot* modify the value of mylist once it has been defined).
> -Brent
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners

GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

More information about the Beginners mailing list