lue-bird / elm-review-missing-record-field-lens

elm-review: helper generation
https://package.elm-lang.org/packages/lue-bird/elm-review-missing-record-field-lens/latest/
MIT License
2 stars 1 forks source link

RE: VariantLens #9

Closed erlandsona closed 2 years ago

erlandsona commented 2 years ago

2 thoughts

  1. rename: VariantLens.GenerateUsed -> NoMissingVariantPrism a. One because in Optics terms "Lenses" don't operate over Sum types / ADT's only "Product Types" aka records. Prisms operate over Sums/ADTS/Variants... b. To match better with NoMissingRecordFieldLens 🤷‍♂️

  2. Generate Prisms inline below the definition of the Variant to not force the defining module to expose its constructors. EG: I'd like to "expose" some lenses for operating over say pieces of an otherwise opaque record... something like...

module OpaqueThing exposing (Stuff, current)

type Stuff = Stuff Internal
-- generated opaque Prism constructor for composing helpers for accessing pieces of internal state.
onStuff : Lens Stuff Internal reach wrap
onStuff  = -- ...

type alias Internal = 
    { current_ : String
    , toggle : Bool  -- Notice callers have no access to this toggle property.
    } 

current : Lens Stuff String reach wrap
current = onStuff << Lens.current_
lue-bird commented 2 years ago
erlandsona commented 2 years ago

internal prism reference is a good idea are you motivated to implement this yourself? Otherwise, you might have to wait some time, sorry

It's what I had in the original PR see here for how I had implemented it before. https://github.com/lue-bird/elm-review-missing-record-field-lens/pull/2/files#diff-51ee51156bc0e70de37a9487fc4867daf98cb8a198b9d400d5cb974889677868

lue-bird commented 2 years ago

done, published