Skip to content

Instantly share code, notes, and snippets.

@saiema
Created December 10, 2019 19:50
Show Gist options
  • Save saiema/913ead10a14011d5828bc6166010e61c to your computer and use it in GitHub Desktop.
Save saiema/913ead10a14011d5828bc6166010e61c to your computer and use it in GitHub Desktop.
private Type appendTypes(Type atype, Type btype) {
if (atype.is_bool || atype.is_int())
return Type.EMPTY;
if (btype.is_bool || btype.is_int())
return Type.EMPTY;
List<ProductType> rtypes = new LinkedList<>();
AtomicInteger arities = new AtomicInteger(0);
Iterator<ProductType> atypesIt = atype.iterator();
Iterator<ProductType> btypesIt = btype.iterator();
atypesIt.forEachRemaining(at -> {
rtypes.add(at);
arities.addAndGet(at.arity());
});
btypesIt.forEachRemaining(bt -> {
rtypes.add(bt);
arities.addAndGet(bt.arity());
});
List<PrimSig> primSigs = new LinkedList<>();
rtypes.forEach(prodType -> {
for (PrimSig s : prodType.getAll())
primSigs.add(s);
});
List<ProductType> rProductTypes = Arrays.asList(new ProductType(primSigs.toArray(new PrimSig[primSigs.size()])));
ConstList<ProductType> rtypesConstList = ConstList.make(rProductTypes);
return new Type(false, rtypesConstList, arities.get());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment