Skip to content

Latest commit

 

History

History
162 lines (158 loc) · 2.66 KB

ch15.adoc

File metadata and controls

162 lines (158 loc) · 2.66 KB

15 Monoid, Semigroup

15.10 Reusing algebras by asking for algebras

Exercise

link:ch15_15.10_0.hs[role=include]

15.11 Madness

I guess the madlibbinBetter' is "better", but nothing to blow my mind as of now.

link:ch15_15.11_0.hs[role=include]

15.12 Better living through QuickCheck

Intermission: Exercise

link:ch15_15.12_0.hs[role=include]

15.14 Chapter exercises

Semigroup exercises

  1. data Trivial = Trivial deriving (Eq, Show)

    link:ch15_15.14_0.hs[role=include]
  2. newtype Identity a = Identity a

    link:ch15_15.14_1.hs[role=include]
  3. data Two a b = Two a b

    link:ch15_15.14_2.hs[role=include]
  4. data Three a b c = Three a b c

    link:ch15_15.14_3.hs[role=include]
  5. data Four a b c d = Four a b c d

    link:ch15_15.14_4.hs[role=include]
  6. newtype BoolConj = BoolConj Bool

    link:ch15_15.14_5.hs[role=include]
  7. newtype BoolDisj = BoolDisj Bool

    link:ch15_15.14_6.hs[role=include]
  8. data Or a b = Fst a | Snd b

    link:ch15_15.14_7.hs[role=include]
  9. newtype Combine a b = Combine { unCombine :: (a → b) }

    Warning
    could not break the CoArbitrary
    link:ch15_15.14_8.hs[role=include]
  10. newtype Comp a = Comp { unComp :: (a → a) }

    Warning
    probably correct, do not undestand
    link:ch15_15.14_9.hs[role=include]
  11. data Validation a b = Failure a | Success b deriving (Eq, Show)

    link:ch15_15.14_10.hs[role=include]
  12. newtype AccumulateRight a b = AccumulateRight (Validation a b) deriving (Eq, Show)

    link:ch15_15.14_11.hs[role=include]
  13. newtype AccumulateBoth a b = AccumulateBoth (Validation a b) deriving (Eq, Show)

    link:ch15_15.14_12.hs[role=include]

Monoid exercises

  1. data Trivial = Trivial deriving (Eq, Show)

    link:ch15_15.14_13.hs[role=include]
  2. newtype Identity a = Identity a deriving (Eq, Show)

    link:ch15_15.14_14.hs[role=include]
  3. data Two a b = Two a b

    link:ch15_15.14_15.hs[role=include]
  4. newtype BoolConj = BoolConj Bool

    link:ch15_15.14_16.hs[role=include]
  5. newtype BoolDisj = BoolDisj Bool

    link:ch15_15.14_17.hs[role=include]
  6. newtype Combine a b = Combine { unCombine :: (a → b) }

    Warning
    could not break the CoArbitrary
    link:ch15_15.14_18.hs[role=include]
  7. newtype Comp a = Comp { unComp :: (a → a) }

    Warning
    how come unComp f 0 does not break?
    link:ch15_15.14_19.hs[role=include]
  8. newtype Mem s a…​.

    Warning
    awkward, what is this for? and again, no CoArbitrary
    link:ch15_15.14_20.hs[role=include]