liveBook · Manning

Pointed getter

As explained in Functional Design and Architecture: Examples in Haskell

A pointed getter is a getter that returns both a focused value and the path identifying that value within a structure.

A pointed getter solves a practical validation problem: checking nested data is not enough when an error must identify the field that failed. It behaves like a lens getter but returns both the focused value and its path, allowing validators to build breadcrumbs for precise errors. section 14.2.4

Nested validation with paths

A pointed validator can inspect an outer string field and compose an inner validator through a nested getter. Applying it to Outer "" (Inner 0) produces separate paths such as ["stringField"] and ["innerField", "intField"], rather than undifferentiated failures. Getters may be written manually or generated with Template Haskell. section 14.2.4

How Functional Design and Architecture: Examples in Haskell covers it

How deep it goes
Defines the returned value-path pair and shows construction, but defers broader structural and effectful validation.
Examples
Uses Inner and Outer records, intField' and stringField', and errors reporting innerField.intField and stringField paths.
What it assumes
Assumes familiarity with lens getters, functional composition, validators, and basic Haskell record syntax.
What you can do after
Diagnose validation failures by retaining the path associated with every focused field.
How it connects
Connects lens getters with validators, nested composition, applicative validation, and error paths.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Design and Architecture: Examples in Haskell. The section links point to the parts of the book it draws on.