You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 5, 2022. It is now read-only.
moduleCh13whereimportControl.MonadimportSystem.IO (hSetBuffering, stdout, BufferMode(..))
importSystem.Exit (exitSuccess)
importData.Char (isLetter, toLower)
-- Madam I’m Adam,palindrome::IO()
palindrome =do
hSetBuffering stdout NoBuffering
forever $do
line <-getLineif isPalindrome line
thendoputStrLn"It's a palindrome!"
exitSuccess
elseputStrLn"Nope!"isPalindrome::String->Bool
isPalindrome s = sm ==reverse sm
where
sm = toLower <$>filter isLetter s
Load the module in the repl with :l
Type palindrome and
Type anything. Whatever you typed will not be written to the REPL history. If the Interrupts current computation button is pressed then the strings typed will appear in the history.
Expected behavior (repl run from terminal):
*Ch13> palindrome
qwe
Nope!
nqwejbqwe
Nope!
Madam I'm Adam
It's a palindrome!
*** Exception: ExitSuccess
Extra note, when interrupting, in the Repl tab it is printed:
Interrupted.
Variable not in scope: quehquehiquehiwe
So it appears that the Repl was treating the palindrome program input as input to the Repl itself and there was no variable named quehquehiquehiwe