tricu

An interpreted language for exploring Tree Calculus
Log | Files | Refs | README | LICENSE

consumer_pattern_slots.tri (829B)


      1 -- Shared compiler-side slot ordering; reference matching remains independent.
      2 !import "prelude" !Local
      3 !import "consumers.structural" S
      4 !import "consumers.pattern-slots" Slots
      5 !import "consumers.lowerings.specialize" Indexed
      6 
      7 nested = S.patAs 1 (S.patFork (S.patCapture 2) (S.patStem (S.patCapture 3)))
      8 state = S.patFork (S.patCapture 4) (S.patAs 5 S.patLeaf)
      9 checks = foldl and? true [
     10   (equal? (Slots.patternSlots nested [9]) [3 2 1 9])
     11   (equal? (Slots.patternSlots state (Slots.patternSlots nested t)) [5 4 3 2 1])
     12   (equal? (Slots.patternSlots (S.patLiteral nested) [9]) [9])
     13   (equal? (Slots.patternSlots S.patAny [9]) [9])
     14   (equal? (Slots.patternSlots S.patLeaf [9]) [9])
     15   (equal? (Indexed.patternSlots nested [9]) (Slots.patternSlots nested [9]))]
     16 main = matchBool "pattern-slots-ok" "pattern-slots-DIFF" checks
     17 main