Created
February 10, 2019 12:57
-
-
Save iurii-kyrylenko/c0e413f036f2334168d6715e61236efa to your computer and use it in GitHub Desktop.
Monad Transformers 1
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
import Control.Monad | |
import Control.Monad.Trans | |
import Control.Monad.Trans.Maybe | |
isValid :: String -> Bool | |
isValid [] = False | |
isValid (x:_) = x == 'a' | |
getPsw :: MaybeT IO String | |
getPsw = do s <- lift $ getLine | |
guard (isValid s) | |
return s | |
test = runMaybeT getPsw |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment