Jump to content

User:Duplode/Foldable and Traversable plan

From Wikibooks, open books for an open world

Foldable

[edit | edit source]
  • foldr revisited (deconstructing foldr, the monoidal heart of a fold, folding as querying/summarising, understanding vs. implementation)
  • The Foldable class (the relation with lists, tons of generalised methods, pick-your-monoid folding. Exercise about mapM_)
    • Folding in a list-like way. (Can we say there is a list-likeness to the monoidal structure? Opt.: lists as the free monoid?)
    • From "can I get this by going down the list in such-and-such-a-way" to "can I express what I want as a monoidal query?" (cf. the specialised folds in Data.Foldable)
    • concat routes to Foldable via msum and asum (does this have to do with the alternative-monoid connection?)
  • (Possibly talk about Set - foldable but not a functor.)
  • (Is there a way to talk about monoid homomorphisms here?)

Traversable

[edit | edit source]

(This is less well organised)

  • "Special functors" (Identity, Const, Compose)
  • "But traverse looks like a map. What does it have to do with traversal?"
  • (Is this right?: Traversal involves a monoidal summary on an applicative context. (And that's what sequenceA does?)(Can the Monoidal presentation help with that?))
  • Recovering Foldable and Functor
  • (folding destroys structure, traverse preserves it, and adds an extra layer on top. (But you can destroy it anyway if you ask nicely.)
  • Traversable laws (how to discuss them?)
  • (How to explain sequenceA?)
  • Examples, examples, examples.
  • (Make sense of mapAccum* somehow? It does look like State in a very disguised form.)
  • Interpreting stuff in terms of monoids and functors.
  • GHC deriving extensions.