Skip to content

Latest commit

 

History

History
91 lines (78 loc) · 2.04 KB

ch13.adoc

File metadata and controls

91 lines (78 loc) · 2.04 KB

13 Building projects in Haskell

Differences between cabal and stack

  1. stack new proj instead of mkdir proj; cd proj; cabal init

  2. stack creates Lib automatically

  3. cabal sandbox init no need

  4. stack build

  5. stack exec proj-exe

  6. stack ghci or stack repl - they appear to be identical

13.3 Working with a basic project

13.7 More on importing modules

Intermission: Check your understanding

  1. forever and when

  2. all the import without qualified keyword

  3. everything exported in Database.Blacktip.Types

  4. details

    1. just look for what is after the as keyword in the imports

    2. Filesystem

    3. Control.Monad

13.9 do syntax and IO

  1. error as expected

    link:ch13_13.9_0.hs[role=include]
  2. consumes two characters and prints True or False

    link:ch13_13.9_1.hs[role=include]
  3. consumes two characters and prints True if true, or nothing.

    link:ch13_13.9_2.hs[role=include]

13.15 Chapter exercises

Hangman game logic

To count only incorrect guesses, I have modified gameOver condition to if (length guessed - length (filter isJust discovered)) > 7 then

Modifying code

  1. Caesar and Vigenere cyphers taking input from user

    link:ch13_13.15_1.hs[role=include]
    link:ch13_13.15_0.hs[role=include]
  2. using exitSuccess in palindrome

    link:ch13_13.15_2.hs[role=include]
  3. palindrome on sentences

    Warning
    not sure I get the assignment other than using toLower
    link:ch13_13.15_3.hs[role=include]
  4. gimmePerson

    link:ch13_13.15_4.hs[role=include]