This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Some helpful setters (a.k.a. Lenses/foci) using and extending please-focus
version 1.0.0
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.0
Committed At 2017-08-08 19:10:26 UTC
elm-lang/html 2.0.0 <= v < 3.0.0 2.0.0
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1
SwiftsNamesake/please-focus 1.1.2 <= v < 2.0.0 1.1.2

Modules

README

Focus More

Adds a couple of helpful "Setters" (or "Lenses" or "Foci" or whatever).

This library is ment as a small extension of the SwiftNamesake/please-focus package. Usually imported together like this:

import Focus exposing (Setter, (&), (.=), (=>), ($=))
import FocusMore as Focus exposing (FieldSetter)

Also here's my free trick for handling Union-type Models:

import Focus
import FocusMore as Focus

type alias InActionModel = ...

type alias NotInActionModel = ...

type Model
    = UserInAction InActionModel
    | NotInAction NotInActionModel

-- Define the "Setters" which only set,
-- when the model is in the respective case
userInAction : Focus.FieldSetter Model InActionModel
userInAction f model =
    case model of
        UserInAction inAction ->
            UserInAction (f inAction)

        _ ->
            model

notInAction : Focus.FieldSetter Model NotInActionModel
notInAction f model =
    case model of
        NotInAction notInAction ->
            NotInAction (f notInAction)

        _ ->
            model

Now you can use these Setters in your update function:

update : ...
update msg model =
    case msg of
        UserActionMsg actionMsg ->
            model & userInAction $= updateInAction actionMsg

        ... ->
            ...