Skip to content

Instantly share code, notes, and snippets.

@bradclawsie
Created May 9, 2011 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradclawsie/962123 to your computer and use it in GitHub Desktop.
Save bradclawsie/962123 to your computer and use it in GitHub Desktop.
haskell pw prompt
module Main where
import System.IO
import Data.Char
import System.Console.ANSI
-- ord val of 10 is return key
getPW = getPW' "" where
getPW' s = getChar >>= \x ->
if ((ord x) == 10) then return s
else cursorBackward 1 >> putStr "*" >> getPW' (s ++ [x])
main =
hSetBuffering stdin NoBuffering >>
hSetBuffering stdout NoBuffering >>
putStrLn "pass:" >>
getPW >>= \pw -> putStr pw >> clearScreen >> return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment