
Hi, I must be doing something wrong when I run a program it comes up on the screen as OK module loaded Main *Main> But it will not do what I program to do. What do I enter after *main> I tried putting in the arguments but ot just returns the arguments. For example: signum x | x < 0 = -1 | x == 0 = 0 | x > 0 = 1 Enter 5 it returns 5 What have I missed? Regards John

Hello, if you enter ":h" at the prompt it gives all of the available
ghci commands. I think this is the one you're looking for
:main [<arguments> ...] run the main function with the given arguments
-Keith
On Sat, Oct 3, 2009 at 3:07 PM, John Moore
Hi, I must be doing something wrong when I run a program it comes up on the screen as OK module loaded Main *Main> But it will not do what I program to do. What do I enter after *main> I tried putting in the arguments but ot just returns the arguments.
For example:
signum x | x < 0 = -1 | x == 0 = 0 | x > 0 = 1
Enter 5 it returns 5
What have I missed?
Regards
John
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- keithsheppard.name

On Sat, Oct 03, 2009 at 08:07:50PM +0100, John Moore wrote:
Hi, I must be doing something wrong when I run a program it comes up on the screen as OK module loaded Main *Main> But it will not do what I program to do. What do I enter after *main> I tried putting in the arguments but ot just returns the arguments. For example:
signum x | x < 0 = -1 | x == 0 = 0 | x > 0 = 1
If you have the above in a file and load it into ghci, it just means that now the function 'signum' is available for use. You type expressions at the ghci prompt, so if you type 5 by itself, that is just the expression 5, which of course has the value... 5. =) If you want to evaluate signum with an input you must type, for example, signum 5 However, I should warn you that the Haskell Prelude already defines a function called 'signum', so if you load the above and type 'signum 5' it will give you an error about signum being ambiguous (it does not know which one you want, the one from the Prelude or the one you defined in the file you loaded). There are various ways around this, but the easiest for now is probably just to use a different name for your function. -Brent
participants (3)
-
Brent Yorgey
-
John Moore
-
Keith Sheppard