upsiflu / less-ui

Write your views across several screen regions, and hide all Ui state in the Url.
https://package.elm-lang.org/packages/upsiflu/less-ui/latest
BSD 3-Clause "New" or "Revised" License
6 stars 1 forks source link

Defunc everything! #16

Closed upsiflu closed 1 year ago

upsiflu commented 1 year ago
  1. [x] Re-add type parameter wrapper to Ui and Layout -> b4fdd8b
  2. [x] Replace Wrap... with Wrap wrapper
  3. [x] Refactor item.get : AssocSet region (Ui aspect wrapper html)
  4. [x] Refactor item.mask to : (statePredicate, AssocSet (OrInline (OrHeader aspect)) wrapper)
  5. [x] Create type mutationResolution 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:

Discussion

https://elm.dmy.fr/packages/lue-bird/elm-keysset/latest/ has a complete discussions of Dict implementations. My Get is

just the function key -> Maybe value instead of a data structure examples jjant/elm-dict AllDict 👎 >= n runtime 👎 doesn't simplify it's structure. Every remove, insert, union, difference, adds to the function logic 👍 pretty easy to understand and build on with powerful features like assigning a specific value x whenever a condition is met

In comparison, KeysSet offers

  • 🔑 element -> key function as part of a given Key
  • defunc
  • customizable sorting (may be useful for the layouting)
  • typed emptiness (instead of Maybe, identity, [])

[2023-04-09] KeysSet seems very complex and extensive, although this makes it adaptable. In our use case, we only want the following functionality:

This could be implemented with sparse arrays or hashtables. Here are the constraints:

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

upsiflu commented 1 year ago

Concerning KeysSet, Get, Dict...:

What we currently use

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

upsiflu commented 1 year ago

https://github.com/erlandsona/assoc-set/

upsiflu commented 1 year ago

4c3faa8e233cca01ee997a65e46192e9e19cf74b