fabulous-dev / Fabulous

Declarative UI framework for cross-platform mobile & desktop apps, using MVU and F# functional programming
https://fabulous.dev
Apache License 2.0
1.16k stars 122 forks source link

Refactor EnumerationMode #1091

Open kerams opened 2 days ago

kerams commented 2 days ago

struct adds extra overhead. because case elements are not stored in the tupled form but as separate fields in the struct.

kerams commented 2 days ago

We could go further with

[<Struct; IsByRefLike; RequireQualifiedAccess; NoComparison; NoEquality>]
type EnumerationMode<'a> =
    | AllAdded of prev: 'a[] 
    | AllRemoved of prev: 'a[] 
    | Empty
    | ActualDiff of prev: 'a[] * next: 'a[]

This would get rid of the bool in the DU struct at the cost of slightly confusing case field names. (Although struct field merging might require F# 9 and SDK 9)