case userIdResult of
Ok (AdminId id) ->
Just id
_ ->
Nothing
I've found this to be important in a lot of my uses of elm-codegen both to make it easier to reach in and grab values in more complex generated code, as well as for generating more presentable code (for example in the scaffolding helpers in elm-pages v3). Using nested pattern matches results in code that isn't idiomatic so this feature is really valuable for these scaffolding helpers in elm-pages.
PR Status
I addressed all of the API design feedback you gave me on our call. Very happy to get more feedback if you have any with these changes.
Besides that, the one thing that remains is the indexes. I played around with it but couldn't get those wired in properly and could use some help on that.
Package Docs: https://elm-doc-preview.netlify.app/Elm-Pattern?repo=dillonkearns%2Felm-codegen&version=patterns
This PR introduces a
Pattern
API that lets you use more general pattern matching beyond the helpers likeElm.Case.result
, etc.Motiviation
For example, with the existing API if you want to pattern match a Custom Type variant within a Result, you currently need to unwrap it twice using:
With the
Elm.Pattern
module, we can directly pattern match on this:Which results in:
I've found this to be important in a lot of my uses of
elm-codegen
both to make it easier to reach in and grab values in more complex generated code, as well as for generating more presentable code (for example in the scaffolding helpers in elm-pages v3). Using nested pattern matches results in code that isn't idiomatic so this feature is really valuable for these scaffolding helpers in elm-pages.PR Status
I addressed all of the API design feedback you gave me on our call. Very happy to get more feedback if you have any with these changes.
Besides that, the one thing that remains is the indexes. I played around with it but couldn't get those wired in properly and could use some help on that.
Thanks again for the awesome project!