@Test public void shouldDestructureTupleAndTagValues() { String tuple2 = "scotch.data.tuple.(,)"; Value pattern = matcher("scotch.test.second", t(1), arg("#0", t(2)), pattern("scotch.test.(second#0)", asList(struct(arg("#0", t(3)), tuple2, t(4), asList( field("_0", t(5), ignore(t(6))), field("_1", t(7), capture(access(arg("#0", t(8)), "_1", t(9)), "b", t(10))) ))), id("b", t(11)) ) ); SymbolGenerator generator = new DefaultSymbolGenerator() {{ startTypesAt(12); }}; assertThat(pattern.reducePatterns(new DefaultPatternReducer(generator)), is(fn("scotch.test.second", arg("#0", t(2)), conditional( isConstructor(arg("#0", t(3), tuple2), tuple2), scope("scotch.test.(second#0)", let(t(13), "b", access(arg("#0", t(8), tuple2), "_1", t(9)), id("b", t(11)))), raise("Incomplete match", t(12)), t(14) )))); }
private PatternState pattern() { return patterns.peek(); }
DefaultPatternReducer implements PatternReducer { private PatternState pattern() { return patterns.peek(); } }
DefaultPatternReducer implements PatternReducer { private PatternState pattern() { return patterns.peek(); } DefaultPatternReducer(SymbolGenerator generator); }
DefaultPatternReducer implements PatternReducer { private PatternState pattern() { return patterns.peek(); } DefaultPatternReducer(SymbolGenerator generator); @Override void addAssignment(CaptureMatch capture); @Override void addCondition(Value argument, Value value); @Override void addCondition(IsConstructor constructor); @Override void addTaggedArgument(Value taggedArgument); @Override void beginPattern(PatternMatcher matcher); @Override void beginPatternCase(PatternCase patternCase); @Override void endPattern(); @Override void endPatternCase(); @Override Value getTaggedArgument(Value argument); @Override void markFunction(FunctionValue function); @Override Value reducePattern(); }
DefaultPatternReducer implements PatternReducer { private PatternState pattern() { return patterns.peek(); } DefaultPatternReducer(SymbolGenerator generator); @Override void addAssignment(CaptureMatch capture); @Override void addCondition(Value argument, Value value); @Override void addCondition(IsConstructor constructor); @Override void addTaggedArgument(Value taggedArgument); @Override void beginPattern(PatternMatcher matcher); @Override void beginPatternCase(PatternCase patternCase); @Override void endPattern(); @Override void endPatternCase(); @Override Value getTaggedArgument(Value argument); @Override void markFunction(FunctionValue function); @Override Value reducePattern();  }