Skip to content

Latest commit

 

History

History
142 lines (134 loc) · 1.91 KB

ch12.adoc

File metadata and controls

142 lines (134 loc) · 1.91 KB

12 Signaling adversity

12.5 Chapter Exercises

Determine the kinds

  1. id :: a → a kind of a is *

  2. r :: a → f a kind of a is *, kind of f a is * -> *

String processing

  1. Replace "the" with "a".

    link:ch12_12.5_0.hs[role=include]
  2. recursive count

    link:ch12_12.5_1.hs[role=include]
  3. number of vowels in a word - changed the siganture to Int instead of Integer

    link:ch12_12.5_2.hs[role=include]

Validate the word

link:ch12_12.5_3.hs[role=include]

It’s only Natural

link:ch12_12.5_4.hs[role=include]

Small library for Maybe

  1. boolean check

    link:ch12_12.5_5.hs[role=include]
  2. Maybe catamorphism

    link:ch12_12.5_6.hs[role=include]
  3. fallback

    link:ch12_12.5_7.hs[role=include]
  4. Converting between List and Maybe

    link:ch12_12.5_8.hs[role=include]
  5. drop the Nothing values from our list

    link:ch12_12.5_9.hs[role=include]
  6. flipMaybe

    link:ch12_12.5_10.hs[role=include]

Small library for Either

  1. use foldr

    link:ch12_12.5_11.hs[role=include]
  2. use foldr well, same as last one (don’t see the point much, just use a instead of b)

    link:ch12_12.5_12.hs[role=include]
  3. partitionEithers

    link:ch12_12.5_13.hs[role=include]
  4. eitherMaybe

    link:ch12_12.5_14.hs[role=include]
  5. either'

    link:ch12_12.5_15.hs[role=include]
  6. use either'

    Warning
    I don’t see the point :(
    link:ch12_12.5_16.hs[role=include]

Write your own iterate and unfoldr

  1. myIterate using recursion

    link:ch12_12.5_17.hs[role=include]
  2. myUnfoldr

    link:ch12_12.5_18.hs[role=include]
  3. myIterate into betterIterate using myUnfoldr

    link:ch12_12.5_19.hs[role=include]

Finally something other than a list!

link:ch12_12.5_20.hs[role=include]