[Haskell wikibook] Re: Splitting of "More on Datatypes"

Heinrich Apfelmus apfelmus at quantentunnel.de
Mon May 10 09:51:07 EDT 2010

Daniel Mlot wrote:
> One of the ideas I had while reading the book but didn't have the guts
> to pull off without asking for feedback was splitting the More on
> Datatypes module in Intermediate Haskell. As of now, it has a first part
> which describes an assortment of important datatype techniques
> (enumerations, records and a more formal presentation of parametrized
> types - using Maybe as example) and then moves on to a long discussion
> of binary trees and how to define maps and folds for arbitrary data
> structures. The coupling of these two parts is very loose (the only
> concept of the first part needed for the data structure discussions is
> parametrization) and probably does not justify them being glued together
> to make such a long (27k) module. Another related issue is that one
> important omission from the Beginner's Track is an explanation of
> newtype, and I guess More on Datatypes would be the right place to put
> it. That would make the module even longer, however, and would be
> another reason to make the split.
> The only thing I am not sure of is a good name for the second "half" of
> More on Datatypes in case of a split. The obvious choice would be "Trees
> and ???" (I have no idea of a good concise term to replace the ???),
> although maybe something more generic like "Introduction to Data
> Structures" could work.

I concur. In my opinion, the second part about generalized folds and
maps does not even belong to the beginner's track; it should be moved to
a chapter "Generic Programming" in the "Fun With Types" section. (Some
prefer the name "Datatype algebra" for that currently missing chapter,
but the standard name is "Generic Programming". By the way, it's
prerequisite to the second part of the "Zippers" chapter.)

> P.S.: By the way, Apfelmus has moved Type Declarations to just before
> Pattern Matching. Probably the right thing to do (it just didn't fit
> very well in Haskell Basics), but it will also require some reworking of
> Type Declarations (when I made that module more verbose I envisioned it
> as a preparation for a more general Pattern Matching discussion several
> modules ahead, but with the rearranging the redundancies are probably
> too obvious). I will give it a try soon.

Yep, I moved it because it seems silly to discuss data types but then
defer the discussion of how to use them (= pattern matching) until much

My vision for the 'Haskell Basics' section is to present a minimal
subset of the Haskell syntax and language that still enables people to
write pretty much any program they want. This way, readers don't have to
wade through all the syntactic variety before getting to the core concepts.

In particular, I propose the following subset:

* guards, but no  if .. then .. else
* where  clauses for local definitions, but no  let
* Lists, list comprehensions and many Prelude functions involving lists;
but no pattern matching. (Not sure about omitting pattern matching on
lists yet, but the idea is to encourage "whole-meal" programming with
* Standard primitive types
    Int, Double, Char, String, (,), ->
  and polymorphism.
* Type synonyms to encourage abstraction; but no user-defined data
types, tuples will have to serve.
* Type classes need to be mentioned because of error messages due to the
overloading of numeric literals. Also, readers need the  show  function.
* Very simple IO, do syntax:
    reading and writing files, interacting on the terminal

Heinrich Apfelmus


More information about the Wikibook mailing list