[go: nahoru, domu]

Skip to content

pescuma/elm-lens

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elm-lens Build Status

Unconventional lens for eml.

> import Lens exposing (Lens)
> import Lens.Operators exposing (..)
> import Lens.Extensions.Dict as Dict
> import Lens.Extensions.Maybe as Maybe
> import Lens.Extensions.Record as Record
>
> import Dict exposing (Dict)
>
>
> val = Just <| Dict.fromList [("k", { name = "Name" })]
Just (Dict.fromList [("k",{ name = "Name" })])
    : Maybe.Maybe (Dict.Dict String { name : String })
>
> lens = Maybe.justLens ^?>> Dict.valueLens "k" ^?>> Record.nameLens
Lens { target = FixedFields, get = <function>, getIfPossible = <function>, setIfPossible = <function>, removeIfPossible = <function> }
    : Lens.Lens
        Lens.ValueMaybeExists
        (Maybe.Maybe (Dict.Dict String { whole | name : part }))
        part
>
> Lens.getMaybe lens val
Just "Name" : Maybe.Maybe String
>
> Lens.set lens "New name" val
Just (Dict.fromList [("k",{ name = "New name" })])
    : Maybe.Maybe (Dict.Dict String { name : String })

About

Unconventional lens for eml

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages