Skip to content

Chapter 3: Infix function application example using record accessors does not seem to work #282

@shaunplee

Description

@shaunplee

Chapter 3 includes the following as an example of how ($) can make things easier to read by reducing the number of parentheses:

For example, the following nested function application, which finds the street in the address of an employee's boss:

street (address (boss employee))

becomes (arguably) easier to read when expressed using $:

street $ address $ boss employee

However, these street, address, and boss accessor functions are not defined. I think this would be valid Haskell when using record syntax, but, based on my quick experiments in PSCi 0.13.8, it seems like PureScript doesn't automatically create these accessor functions.

I'm new to PureScript, so I could be missing something here.

Suggestion is to rewrite this a bit, maybe by introducing record accessor functions using _. per issue #281, and then rewriting the above as:

For example, the following nested function application, which finds the street in the address of an employee's boss:

_.street (_.address (_.boss employee))

becomes (arguably) easier to read when expressed using $:

_.street $ _.address $ _.boss employee

I can take a crack at this, unless I'm misunderstanding how PureScript works.

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