Skip to content

Instantly share code, notes, and snippets.

@iurii-kyrylenko
Created February 10, 2019 12:57
Show Gist options
  • Save iurii-kyrylenko/c0e413f036f2334168d6715e61236efa to your computer and use it in GitHub Desktop.
Save iurii-kyrylenko/c0e413f036f2334168d6715e61236efa to your computer and use it in GitHub Desktop.
Monad Transformers 1
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