Created
October 8, 2018 10:53
-
-
Save shamansir/b676f0c973fe45905d35d2efe11058c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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