Reputation: 173
I can execute simply operations, like
Hugs> 2+2
for instance. Or any operation, for that matter.
But when it comes to actually trying to define a function, e.g:
occurs :: Eq a => a -> [a] -> Bool
occurs x l = x `elem` l
Then I get the message:
ERROR - Syntax error in input (unexpected `=')
I also get unexpected `::'
in other cases. I'm using WinHugs.
Upvotes: 2
Views: 1316
Reputation: 105905
You need to save the function in a file (*.hs) and load it via :load <filename>
, since the prompt accepts only expressions.
8.5. How do I enter function definitions?
The Hugs prompt only accepts expressions for evaluation. You can create a file containing a Haskell module, and load that (see Section 2.2 for details).
If you want to experiment with function definitions in a REPL environment, I recommend you to use GHCi instead.
Upvotes: 6
Reputation: 54068
When typing in a function in interactive mode, you need to use let
, and you also have to separate lines with a semicolon:
let occurs :: Eq a => a -> [a] -> Bool; occurs x l = x `elem` l
Upvotes: 6