Prelude is commandline utility for Haskell. Prelude supports one line functions. Such as,
let addThree a b c = a+b+c
If it crosses more than a line. Such as
let addThree a b c = a+b+c
If it crosses more than a line. Such as
addThree :: Int -> Int -> Int -> Int addThree x y z = x + y + zAs soon as you hit enter after the first line, you will see error as
:11:1: Not in scope: `addThree'
Solution 1
Create a haskell file such as "addThree.hs" and place the function in it. Now load the file using ":l addThree.hs" at prelude.Solution 2
You can also use multiline function in prelude. Now semicolon must be used after each line, shouldn't press ENTER key. Most importantly 'let' keyword must be prefixed. Here is the modified version of the above example.let addThree :: Int -> Int -> Int -> Int; addThree x y z = x + y + z
No comments:
Post a Comment