Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DMS-68] Deduplicate switch cases using or-patterns #29

Open
wants to merge 16 commits into
base: milestone-2
Choose a base branch
from

Commits on Sep 30, 2024

  1. Extract persistent RBTree from mutable wrapper into a separate module

    No changes in logic so far, just simple refactoring
    s-and-witch authored and GoPavel committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    c268695 View commit details
    Browse the repository at this point in the history
  2. [DMS-66] Extend API for persistent ordered map

    Add `MapOps` class with the following signature:
    
      public class MapOps<K>(compare : (K,K) -> O.Order) {
    
        public func put<V>(rbMap : Map<K, V>, key : K, value : V) : Map<K, V>
    
        public func fromIter<V>(i : I.Iter<(K,V)>) : Map<K, V>
    
        public func replace<V>(rbMap : Map<K, V>, key : K, value : V) : (Map<K,V>, ?V)
    
        public func mapFilter<V1, V2>(f : (K, V1) -> ?V2, rbMap : Map<K, V1>) : Map<K, V2>
    
        public func get<V>(key : K, rbMap : Map<K, V>) : ?V
    
        public func delete<V>(rbMap : Map<K, V>, key : K) : Map<K, V>
    
        public func remove< V>(rbMap : Map<K, V>, key : K) : (Map<K,V>, ?V)
    
      };
    
    The other functionality provided as standalone functions, as they
    don't require comparator:
    
      public type Direction = { #fwd; #bwd };
    
      public func iter<K, V>(rbMap : Map<K, V>, direction : Direction) : I.Iter<(K, V)>
    
      public func entries<K, V>(m : Map<K, V>) : I.Iter<(K, V)>
    
      public func keys<K, V>(m : Map<K, V>, direction : Direction) : I.Iter<K>
    
      public func vals<K, V>(m : Map<K, V>, direction : Direction) : I.Iter<V>
    
      public func map<K, V1, V2>(f : (K, V1) -> V2, rbMap : Map<K, V1>) : Map<K, V2>
    
      public func size<K, V>(t : Map<K, V>) : Nat
    
      public func foldLeft<Key, Value, Accum>(
        combine : (Key, Value, Accum) -> Accum,
        base : Accum,
        rbMap : Map<Key, Value>
      ) : Accum
    
      And foldRight with the same signature as foldLeft
    
    The following functions are new for the API:
    - MapOps.put, MapOps.delete
    - MapOps.fromIter, entries, keys, vals
    - MapOps.mapFilter, map
    - foldLeft, foldRight
    s-and-witch authored and GoPavel committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    e9d9ab6 View commit details
    Browse the repository at this point in the history
  3. [DMS-66] fix order of method arguments

    Problem: now order is not consistent within new module and with old
    modules as well.
    
    Solution: make the map argument always go first
    GoPavel committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    614fa56 View commit details
    Browse the repository at this point in the history
  4. [DMS-76] Persistent ordered map unit testing

    In addition to tests this patch removes `direction`
    argument from `keys` and `values` function to keep
    them simple and provides a new function `Map.empty`
    to create a map without knowing its internal representation.
    s-and-witch authored and GoPavel committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    ffdad00 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    89b7f6d View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    41b6516 View commit details
    Browse the repository at this point in the history

Commits on Oct 2, 2024

  1. Configuration menu
    Copy the full SHA
    09fd7d0 View commit details
    Browse the repository at this point in the history
  2. Merge pull request #8 from serokell/wip/s-and-witch/fix-doc

    Specify keys order in iterators
    s-and-witch authored Oct 2, 2024
    Configuration menu
    Copy the full SHA
    fcae5a6 View commit details
    Browse the repository at this point in the history

Commits on Oct 7, 2024

  1. Configuration menu
    Copy the full SHA
    40208d0 View commit details
    Browse the repository at this point in the history

Commits on Oct 14, 2024

  1. Configuration menu
    Copy the full SHA
    38d7bd2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a26ad5d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9e25663 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    d65c36c View commit details
    Browse the repository at this point in the history
  5. Make internal module public

    s-and-witch authored and GoPavel committed Oct 14, 2024
    Configuration menu
    Copy the full SHA
    2d87094 View commit details
    Browse the repository at this point in the history

Commits on Oct 15, 2024

  1. Move leaf branch to the end of switch expression, as the most unlikely

    This PR didn't touch folds and map as benchmark showed us
    that it performs worse.
    s-and-witch committed Oct 15, 2024
    Configuration menu
    Copy the full SHA
    86b876f View commit details
    Browse the repository at this point in the history

Commits on Oct 18, 2024

  1. Configuration menu
    Copy the full SHA
    d4eac36 View commit details
    Browse the repository at this point in the history