Skip to content

Chapter 6: Underscore notation for property accessors used without previously being introduced #281

@shaunplee

Description

@shaunplee

The Functional Dependencies section of Chapter 6 uses underscore notation for an accessor to the tail property of a Stream:

genericTail xs = map _.tail (uncons xs)

Grepping the text of the book, this appears to be the only place where this syntax is ever used (there's a match in Chapter 1 with the JavaScript example of _.chain(_.range(1000)), but that's not the same thing).

While the syntax is infrequently used in the book, readers may encounter it in other code, and it might be helpful to introduce this syntax when discussing Records in Chapter 3, specifically in after the section on how fields of Records can be accessed using a dot.

An additional suggestion would be to modify findEntryByStreet exercise (or add a follow up exercise) to suggest that the predicate supplied to filter could be expressed as the composition of an accessor function using the underscore notation and a test for equality, like:

(==) street <<< _.address.street

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions