function algebraicType()

in src/js/object-mona-parser/algebraic-type/algebraic-type-parser.js [26:53]


function algebraicType() {
  return mona.trim(
    mona.sequence(function(s) {
      const comments = s(mona.collect(parseCommon.comment()));

      const rawAnnotations = s(parseCommon.annotations());
      const parsedAnnotations = rawAnnotations || {};

      const typeNameSection = s(parseCommon.parseTypeNameSectionWithIncludes());
      const valueTypes = s(mona.between(mona.string('{'),
      mona.string('}'),
      mona.collect(algebraicSubtype())));

      const includes = typeNameSection.includes || [];
      const excludes = typeNameSection.excludes || [];

      const foundType = {
        annotations: parsedAnnotations,
        comments: comments.concat(typeNameSection.comments),
        excludes: excludes,
        includes: includes,
        typeName: typeNameSection.typeName,
        subtypes: valueTypes,
      };
      return mona.value(foundType);
    })
  );
}