Password Program Questions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Password Program Questions

Casey Newsome
I am very new to Haskell and I am attempting to make a simple password program as my first program. I have ran into a problem and I am not very sure on how to fix it. I do not know how to make a second section for the passwords. My guessing attempts have failed so I am asking for help.






Here is my code

main = do 
      putStrLn "Hello, Who are you?"
      name <- getLine --User Input
      putStrLn ("Hey " ++ name ++ ", What's the password?")
      pass <- getLine
      if pass == "12345"
          then putStrLn ("Welcome")
          pw
          else do
              putStrLn "That is wrong!"
              main
pw = do
    putStrLn "What Password do you need?"






Thanks in advance, Casey :D


_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Password Program Questions

David McBride
Remember that haskell is whitespace delimited.  You probably intended
putStrLn "Welcome" to line up with pw, in its own do.

if pass == "12345"
  then do
    putStrLn "welcome"
    pw
  else do
    putStrLn "wrong"
    main


On Thu, Aug 3, 2017 at 6:59 PM, Casey Newsome <[hidden email]> wrote:

> I am very new to Haskell and I am attempting to make a simple password
> program as my first program. I have ran into a problem and I am not very
> sure on how to fix it. I do not know how to make a second section for the
> passwords. My guessing attempts have failed so I am asking for help.
>
>
>
>
>
>
> Here is my code
>
> main = do
>       putStrLn "Hello, Who are you?"
>       name <- getLine --User Input
>       putStrLn ("Hey " ++ name ++ ", What's the password?")
>       pass <- getLine
>       if pass == "12345"
>           then putStrLn ("Welcome")
>           pw
>           else do
>               putStrLn "That is wrong!"
>               main
> pw = do
>     putStrLn "What Password do you need?"
>
>
>
>
>
>
> Thanks in advance, Casey :D
>
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Loading...