Add couple of potentially useful functions #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi @rtfeldman - I've been using this package in a couple of projects recently, where I've found it useful (so thanks 🙂). While using it I've found a couple of situations have reappeared, at least for my use cases:
I want to get a
SelectList
from aList
, without selecting a particular element, either because I don't care which this is or because I can immediately pipe this intoSelectList.select
; since not everyList
can be turned into aSelectList
this operation can fail so should produce aSelectList
wrapped in aMaybe
(or equivalent).I want to decode a JSON array of some type straight into a
SelectList
of that type; similarly I either don't care which element is initially selected or can useSelectList.select
to handle this.This PR contains a couple of commits with functions to perform each of these operations. Both of these are reasonably trivial with the current API, but since I found I was repeating them across projects I thought I'd suggest them here.
If you don't think these fit here or are worth adding, then no problem. If you do, or think just one of them is, let me know and I can adjust appropriately and add docs and tests. Either way, thanks in advance.