graninas / software-design-in-haskell

Software Design in Haskell. A structured set of materials. How to build real-world applications in Haskell.
1.06k stars 66 forks source link

Suggestion: A Table with Simplified Definitions of Some of Haskell's Most Important Concepts #6

Open psygo opened 3 years ago

psygo commented 3 years ago

So far I've noticed the pattern that many online tutorials — and even books — are so convoluted that they manage to, with their explanations, overcomplicate the concepts. And, as a beginner, I think that the path of being able to use the API with only the minimum amount of details necessary is usually much easier to cope with — or at least that's what I think happens with many beginners, not all. So I think that a summarized table of concept-and-short-definition would be a great resource — there should, of course, be a disclaimer somewhere that this table cannot ultimately replace working through the derivations of the concepts.

A table of tools and definitions really helps beginners become productive at the beginning, until they eventually know everything by heart, from regular use.

If this table exists somewhere on the internet, please point it out to me and I'll close this issue, it's just that I haven't found it yet...

I don't have the necessary competence to create or complete such a table, but here's an example:

Concept/Type/Tool Motivation \ Problem it solves
Category identity and composition
Semigroup associative binary operation (<>), sometimes seen as concatenation
Monoid extends the Semigroup with an identity function/element
Functor mapping over a computational context
Applicative injecting values into a context and applying a function in a context to another value in a context
Monad sequencing of computations within a context so that the next one depends on the previous
Monad Transformers a scalable way of dealing with nested monads/contexts
Foldable a way of summarizing/collapsing a structure
Traversable go through a structure and apply a function to each element
Reader essentially a singleton for an environment; saves a lot of passing around of variables
Writer analogous to the Reader, but for writing to an environment
RWST the combination of Reader, Writer and State; very handy for cleanly and safely dealing with state
Arrow generalization of a monad for (...?)
Lenses a more scalable way of accessing deeply nested data types or structures
Bottom () a computation which never completes successfully; includes a failure and infinite loops
hspec the standard library for performing TDD in Haskell
QuickCheck the standard library for performing property checking
Cabal Common Architecture for Building Applications and Libraries; a package and build system
Stack built on top of cabal and many other tools, most importantly, it provides curated, compatible builds of packages
GHC Glasgow Haskell Compiler; the standard compiler for Haskell
GHCi the interactive shell to GHC

It would be nice if someone converted that table into a UML-like diagram and also a Venn diagram for alternative visualizations. The Typeclassopedia features a very nice diagram in that vein, maybe we could double-down on that.

psygo commented 3 years ago

This table, and different visualizations for it might become a small but interesting TUI — with brick, for example. I think I'm gonna give it a shot at some point — says the rookie who doesn't know what the hell he is doing.

graninas commented 3 years ago

@psygo Composing a vocabulary would be nice! I believe there are some of such things already, but I don't quite remember are they good enough or not.

I personally won't be doing this because I'm a bit busy on books writing.

Again, if there will be a good list of terms with helpful explanations, I'll be happy to reference it from the post.

psygo commented 3 years ago

I personally won't be doing this because I'm a bit busy on books writing.

Please include something like this on one of your books. I would buy a book for a map of Haskell alone.


I think I'm gonna fork this repo at some point and work on these suggestions on my own pace (this, #4, and #5). Once I feel like they are good enough, then I might either publish the content on a post on my website or give you a heads up here.

graninas commented 3 years ago

Please include something like this on one of your books.

@psygo I did!