A library for getting and setting values in deeply nested data structures.


License: BSD-3-Clause

Language: Elm


A Focus is a way to work with particular parts of a large chunk of data. On the most basic level, it lets you get and set fields of a deeply nested record in a more composable way.

Problems with this Idea

It is possible that the concept of a Focus is harmful to code quality in that it can help you to be lax with abstraction boundaries. By making it easy to look deep inside of data structures, it encourages you to stop thinking about how to make these substructures modular, perhaps leading to an architecture that is not as nice and has extra conceptual complexity.

The deeper problem may be that lenses are best when they are bidirectional, whereas a Focus is only in one direction. The issue is then that making proper lenses is not necessarily possible without changing the language itself.

Point is, I have yet to see any code that follows The Elm Architecture that gets better by adding this library.


This API is inspired by the concept of Bidirectional Lenses as described by Nate Foster and seen in a modified form in Haskell as “lenses” and in ClojureScript as “cursors”. My personal opinions and understanding come primarily from this talk by Simon Peyton Jones and Nate Foster's PhD dissertation on bidirectional lenses. I chose the name “Focus” because it is sort of like a lens that only lets you see in one direction.

Project Statistics

Sourcerank 11
Repository Size 17.6 KB
Stars 56
Forks 13
Watchers 4
Open issues 2
Dependencies 1
Contributors 6
Tags 6
Last updated
Last pushed

Top Contributors See all

Evan Czaplicki Maxime Dantec Michel Rijnders Kevin W. van Rooijen Rehno Lindeque Sebastian Graf

Packages Referencing this Repo

an experimental library for working with records
Latest release 2.0.2 - Updated - 56 stars

Recent Tags See all

2.0.2 March 02, 2017
2.0.1 May 20, 2016
2.0.0 November 22, 2015
1.0.1 April 29, 2015
1.0.0 November 27, 2014
0.1 October 03, 2014

Something wrong with this page? Make a suggestion

Last synced: 2017-03-02 23:28:45 UTC

Login to resync this repository