I'm working on the 2nd Euler's problem, but for now I'm just trying to define the Fibonacci sequence. Currently, I have my Fib function defined as
Fib 0 = 0
Fib 1 = 1
Fib x = Fib (x - 1) + Fib (x - 2)
Because I want the program to depend on my keyboard input, I used
main = do
putStrLn "Enter desired Fibonacci index: "
"index" <- getLine
putStrLn Fib x
And defined x as x = read "index"
I'm pretty sure I'm messing up both the indentation, and my syntax. Depending on how I modify the code, running "ghc /dir/file.hs gets me stuff like "Not in scope: data constructor `Fib'", or "parse error (possibly incorrect indentation)". I really, really don't know what the heck I'm doing, especially with regard to how to set up the .hs to be compiler friendly. I've read through about 7 tutorials on compiling with GHC, but they all seem to skip the part where they explain the basic requirements of compiling.
Please let me know how I can be more specific if that would help. I think the two things I'm trying to understand is how the whole "main" thing is related to compiling, and how I can get it to recognized I HAVE defined Fib as a function, even though it says its not in scope.
PS: I can't figure out the indentation here, Stack seems to want to put everything in one line, so I have to separate it all out. Sorry.