Closed upsiflu closed 1 year ago
Concerning KeysSet
, Get
, Dict
...:
Layout:
Get.concatValues : List key -> Get key (List a) -> List a
Get.get : key -> (key -> value) -> value
Get.toListBy : Get key (a -> b) -> List key -> Get key a -> List b
Get.fromList : List ( key, a ) -> Get key a
Ui:
Get.singleton : key -> a -> Get key a
Get.addList : key -> List a -> Get key (List a) -> Get key (List a)
Get.map : (a -> b) -> Get key a -> Get key b
Get.mapKey : (key2 -> Maybe key1) -> Get key1 a -> Get key2 a
Get.mapByKey : (key -> a -> b) -> Get key a -> Get key b
Get.values : List key -> Get key a -> List a
Get.concatCustom : (List a -> a) -> List (Get key a) -> Get key a
Get.mutation : { current : Get key a, previous : Maybe (Get key a) } -> Get key (Mutation a)
Get.update : key -> (a -> a) -> Get key a -> Get key a
Get.append : Get key (List a) -> Get key (List a) -> Get key (List a)
Get.empty : Get key a
https://github.com/erlandsona/assoc-set/
KeysSet
Dict
with key type that doesn't require comparability but equality4c3faa8e233cca01ee997a65e46192e9e19cf74b
wrapper
toUi
andLayout
-> b4fdd8bWrap...
withWrap wrapper
item.get : AssocSet region (Ui aspect wrapper html)
item.mask
to :(statePredicate, AssocSet (OrInline (OrHeader aspect)) wrapper)
Create typemutationResolution wrapper
Motivation
I had a nasty 'comparing functions' bug, and now I feel it would be solid to refactor restrictive to store no functions in the data structure. There are currently 4 types that store functions:
Get
, which is a simplekey -> Maybe value
Wrap : List html -> List html
Mask : Get k v -> Get k v
Item.mask : ( OrHeader aspect, Url ) -> Mask (OrHeader aspect) (Ui aspect html)
Discussion
https://elm.dmy.fr/packages/lue-bird/elm-keysset/latest/ has a complete discussions of
Dict
implementations. MyGet
isIn comparison,
KeysSet
offers[2023-04-09] KeysSet seems very complex and extensive, although this makes it adaptable. In our use case, we only want the following functionality:
Item.get
: Store an immutable sparse population ofregion -> ui
Item.mask
: Manipulate this population according to the state, i.e.(OrHeader region, Url)
Layout.regions
: a sorted list of regions for view. May be omitted ifLayout.view
takes over this functionality?This could be implemented with sparse arrays or hashtables. Here are the constraints:
mask
It seems like KeysSet and friends can easily implement these constraints, but at the cost of importing lots of steep learning. If we go a simpler route, we may have to give up on some constraints at compile-time. Let's try!
Implementation
Get
->KeysSet
Wrap
can be reverted to accept awrapper
, whereLayout
provides `wrapper -> (List html -> List html)Mask key Ui
is used for two operations:key
key
, discarding its valueMask key (List html)
is used for marking up resultant changes:forget
an html fragment, for example by surrounding it with deletion flag nodes or nesting it into a fading nodesubstitute { current, previous }
, for example by comparing the elements, or simply replacingprevious
with currentmutation
handling to enable smooth transitions and should be combined to a single thing.Item.mask : ( OrHeader aspect, Url ) -> Mask (OrHeader aspect) (Ui aspect html)
can easily be replaced withKeysSet ( OrHeader aspect, Url ) ( Mask ... )
, which would beneficially encode theidentity
case asNothing
. Though the selector inside the key is perhaps a bit tricky to serialize... perhaps we do need a fourth type parameterurlPredicate
which is resolved to some Url->Bool function atLayout
.