2.5 KiB
Bob
Welcome to Bob on Exercism's Haskell Track.
If you need help running the tests or submitting your code, check out HELP.md
.
Instructions
Bob is a lackadaisical teenager. In conversation, his responses are very limited.
Bob answers 'Sure.' if you ask him a question, such as "How are you?".
He answers 'Whoa, chill out!' if you YELL AT HIM (in all capitals).
He answers 'Calm down, I know what I'm doing!' if you yell a question at him.
He says 'Fine. Be that way!' if you address him without actually saying anything.
He answers 'Whatever.' to anything else.
Bob's conversational partner is a purist when it comes to written communication and always follows normal rules regarding sentence punctuation in English.
You need to implement the responseFor
function that returns Bob's response
for a given input. You can use the provided signature if you are unsure
about the types, but don't let it restrict your creativity:
responseFor :: String -> String
To solve this exercise you may read up on:
This exercise works with textual data. For historical reasons, Haskell's
String
type is synonymous with [Char]
, a list of characters. For more
efficient handling of textual data, the Text
type can be used.
As an optional extension to this exercise, you can
-
Read about string types in Haskell.
-
Add
- text
to your list of dependencies in package.yaml. -
Import
Data.Text
in the following way:import qualified Data.Text as T import Data.Text (Text)
-
You can now write e.g.
responseFor :: Text -> Text
and refer toData.Text
combinators as e.g.T.isSuffixOf
. -
Look up the documentation for
Data.Text
, -
You can then replace all occurrences of
String
withText
in Bob.hs:responseFor :: Text -> Text
This part is entirely optional.
Source
Created by
- @etrepum
Contributed to by
- @austinlyons
- @cmccandless
- @danbst
- @eijynagai
- @hritchie
- @iHiD
- @jrib
- @Kobata
- @kytrinyx
- @petertseng
- @ppartarr
- @rbasso
- @sshine
- @tejasbubane
- @tofische
Based on
Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial. - http://pine.fm/LearnToProgram/?Chapter=06