Skip to content

Instantly share code, notes, and snippets.

@shamansir
Created October 8, 2018 10:53
Show Gist options
  • Save shamansir/b676f0c973fe45905d35d2efe11058c2 to your computer and use it in GitHub Desktop.
Save shamansir/b676f0c973fe45905d35d2efe11058c2 to your computer and use it in GitHub Desktop.
module ExceptT2 where
import Control.Monad.Trans.Maybe
import Data.Char (isNumber, isPunctuation)
import Control.Monad (guard)
import Control.Monad.Trans.Except
import Control.Monad.IO.Class (liftIO)
import Data.Foldable (msum)
import Data.Char (isNumber, isPunctuation)
askPassword0 :: MaybeT IO ()
askPassword0 = do
liftIO $ putStrLn "Enter your new password:"
value <- msum $ repeat getValidPassword0
liftIO $ putStrLn "Storing in database..."
getValidPassword0 :: MaybeT IO String
getValidPassword0 = do
s <- liftIO getLine
guard (isValid0 s)
return s
isValid0 :: String -> Bool
isValid0 s = length s >= 8
&& any isNumber s
&& any isPunctuation s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment