Giter Club home page Giter Club logo

focus's Introduction

Focus

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.

Background

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.

focus's People

Contributors

evancz avatar kwrooijen avatar process-bot avatar rehno-lindeque avatar sgraf812 avatar warry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

focus's Issues

Update to 0.18

Hi @evancz !
I'm trying to install this package in a project I'm working on, but the elm-package installer complains about it not being compatible with version 0.18. I've seen there's already a PR to solve this #9, are you planning to merge it eventually?
Thanks in advance!

usage example

 x : Focus { record | x:a } a

Well this probably should make sense to someone. How do we actually define x? What's x =?

[Question] Many repetitive Focus

I'm using this library for a few days and it works great.
The thing is I'm creating many repetitive focuses of the form

propFocus : Focus { r | prop : a } a
propFocus =
    Focus.create .prop (\update big -> { big | prop = update big.prop })

I'm thinking I might be doing something wrong, so I came here to ask for a little help.
Is there a canonical way of creating this types of focus?

Not building with elm 0.16

Hey, I am just trying out elm, and wanted to try out this package. Unfortunately, it seems that it is not entirely up to date. The package on package.elm-lang.org does not reflect the latest changes in the "elm-version" field in elm-package.json file. The latest commit says that 0.16 is supported, but it gives me an error message which made me think it's parser-related:

-- SYNTAX PROBLEM ---------------------------------------------- ./src/Focus.elm

I ran into something unexpected when parsing your code!

120│ (=>) largerFocus smallerFocus =
     ^
I am looking for one of the following things:

    end of input
    whitespace

Detected errors in 1 module. 

Link in README

The "type-directed macros" link in the README.md requires permission to view. I don't know if this is intentional, but otherwise it'd be nice if it was freely viewable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.