Skip to content

Bob's conversational partner is a purist! #713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions exercises/bob/examples/success-standard/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: bob

dependencies:
- base
- safe

library:
exposed-modules: Bob
Expand Down
5 changes: 3 additions & 2 deletions exercises/bob/examples/success-standard/src/Bob.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Bob (responseFor) where
import Data.Char (isSpace, isUpper, isAlpha)
import Data.Char (isSpace, isUpper, isAlpha, isPunctuation)
import Safe (lastMay)

data Prompt = Silence | YellQuestion | Yell | Question | Other

Expand All @@ -10,7 +11,7 @@ classify s | all isSpace s = Silence
| question = Question
| otherwise = Other
where yell = any isAlpha s && all isUpper (filter isAlpha s)
question = '?' == last (filter (not . isSpace) s)
question = Just '?' == lastMay (filter isPunctuation s)

response :: Prompt -> String
response Silence = "Fine. Be that way!"
Expand Down
2 changes: 1 addition & 1 deletion exercises/bob/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: bob
version: 1.3.0.6
version: 1.4.0.7

dependencies:
- base
Expand Down
2 changes: 1 addition & 1 deletion exercises/bob/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ cases = [ Case { description = "stating something"
, expected = "Fine. Be that way!"
}
, Case { description = "multiple line question"
, input = "\nDoes this cryogenic chamber make me look fat?\nno"
, input = "\nDoes this cryogenic chamber make me look fat?\nNo."
, expected = "Whatever."
}
, Case { description = "starting with whitespace"
Expand Down