[clean-list] Really Newbie Question about loops/input
Jay Kint
jean-luc-picard@ussenterprise.com
Tue, 2 Oct 2001 02:37:15 -0600
What I'm trying to do is create a simple definition I can build on to print
a prompt, accept a line of text, and then act on it.
Here is the source code so far:
getCommand :: !*File -> String
getCommand console = fst (freadline (fwritec '>' console))
commandLoop :: !*File (*File->String) -> *File
commandLoop console get
= commandLoop (fwrites ((get console) +++ " ")
console) get
Start :: *World -> *File
Start world
# (console,world) = stdio world
= commandLoop console getCommand
Trying to compile this I get:
"Type Error [116,commandLoop]:"get" * attribute required but not offered at
the indicated position: ^ File
This refers to the line "commandLoop console get". There are several
questions I have. First of all, get is supposed to be a higher order
function, getCommand, that prints a prompt and reads a line of text. (It
works if I put it in the Start function such as Start = getCommand console).
The intent is for getCommand to read in a line, and then to do it over and
over again. Later, I'll add a handler function to replace the fwrites in
the expression that will act on the commands.
First of all, what does the error message mean? What does the "* attribute
required" but not offered mean when in fact I have a function that takes the
exact parameter types its looking for (or so I think).
Second of all, what does the "^ File" at the end of the error message mean?
Is there an operator "^"? I haven't seen it mentioned to date.
Jay the Stumped