Haskell Patternmatching #349

Open
opened 2024-10-25 10:02:07 +00:00 by RubenKraft · 1 comment
Collaborator
sealed interface List<T> permits LinkedElem, Elem {}

public record LinkedElem<T>(T a, List<T> l) implements List<T> {}
public record Elem<T>(T a) implements List<T> {}

public class PaternMatchingHaskellStyle {
   public append(LinkedElem(a, Elem(e)), l2) {
   	  return new LinkedElem<>(a, new LinkedElem<>(e, l2));
   }

   public append(LinkedElem(a, r), l2) {
   	  return new LinkedElem<>(a, append(r, l2));
   }
}

interface List<T> {

}class LinkedElem<T> {

  T a;
  List<T> l;
  T a()({
    return ((this)::TPH AA.a)::T;
  })::TPH AB

  List<T> l()({
    return ((this)::TPH AC.l)::List<T>;
  })::TPH AD

  LinkedElem(T a, List<T> l)({
    super(()) Signature: [TPH AG];
    ((this)::TPH AA.a)::T = (a)::T;
    ((this)::TPH AC.l)::List<T> = (l)::List<T>;
  })::TPH AH

}class Elem<T> {

  T a;
  T a()({
    return ((this)::TPH AK.a)::T;
  })::TPH AL

  Elem(T a)({
    super(()) Signature: [TPH AO];
    ((this)::TPH AK.a)::T = (a)::T;
  })::TPH AP

}class PaternMatchingHaskellStyle {

PaternMatchingHaskellStyle()({
  })::TPH CA
  TPH AS append(LinkedElem<TPH AW>(TPH AT a, Elem<TPH AV>(TPH AU e)), TPH AX l2)({
    return new LinkedElem((a)::TPH AT, new LinkedElem((e)::TPH AU, (l2)::TPH AX));
  })::TPH BG

  TPH BH append(LinkedElem<TPH BK>(TPH BI a, TPH BJ r), TPH BL l2)({
    return new LinkedElem((a)::TPH BI, ((this)::TPH BN.append Signature: [TPH BO, TPH BP, TPH BQ]((r)::TPH BJ, (l2)::TPH BL))::TPH BR);
  })::TPH BW

  PaternMatchingHaskellStyle()({
    super(()) Signature: [TPH BY];
  })::TPH BZ

}
```java sealed interface List<T> permits LinkedElem, Elem {} public record LinkedElem<T>(T a, List<T> l) implements List<T> {} public record Elem<T>(T a) implements List<T> {} public class PaternMatchingHaskellStyle { public append(LinkedElem(a, Elem(e)), l2) { return new LinkedElem<>(a, new LinkedElem<>(e, l2)); } public append(LinkedElem(a, r), l2) { return new LinkedElem<>(a, append(r, l2)); } } ``` ```java interface List<T> { }class LinkedElem<T> { T a; List<T> l; T a()({ return ((this)::TPH AA.a)::T; })::TPH AB List<T> l()({ return ((this)::TPH AC.l)::List<T>; })::TPH AD LinkedElem(T a, List<T> l)({ super(()) Signature: [TPH AG]; ((this)::TPH AA.a)::T = (a)::T; ((this)::TPH AC.l)::List<T> = (l)::List<T>; })::TPH AH }class Elem<T> { T a; T a()({ return ((this)::TPH AK.a)::T; })::TPH AL Elem(T a)({ super(()) Signature: [TPH AO]; ((this)::TPH AK.a)::T = (a)::T; })::TPH AP }class PaternMatchingHaskellStyle { PaternMatchingHaskellStyle()({ })::TPH CA TPH AS append(LinkedElem<TPH AW>(TPH AT a, Elem<TPH AV>(TPH AU e)), TPH AX l2)({ return new LinkedElem((a)::TPH AT, new LinkedElem((e)::TPH AU, (l2)::TPH AX)); })::TPH BG TPH BH append(LinkedElem<TPH BK>(TPH BI a, TPH BJ r), TPH BL l2)({ return new LinkedElem((a)::TPH BI, ((this)::TPH BN.append Signature: [TPH BO, TPH BP, TPH BQ]((r)::TPH BJ, (l2)::TPH BL))::TPH BR); })::TPH BW PaternMatchingHaskellStyle()({ super(()) Signature: [TPH BY]; })::TPH BZ } ```
Owner

In 170955b333 funktionieren jetzt flache Patterns, geschachtelte (wie hier verwendet) müssen noch implementiert werden.

In 170955b333 funktionieren jetzt flache Patterns, geschachtelte (wie hier verwendet) müssen noch implementiert werden.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: JavaTX/JavaCompilerCore#349
No description provided.