Algebraic Data Types for fun and profit

I'm online!

Algebraic Data Types for fun and profit

Algebraic

Data

Type

class DnsRecord {
    String recordType;
    String domainName;
    String cnameAlias;
    IpAddr recordIp;
    int ttl;
}
if(record.recordType.equals("CNAME")) {
    // should not be null
    record.cnameAlias;
} else if(record.recordType.equals("A")) {
    // should not be null
    record.recordIp;
} else {
    // ???
}

Implicit subset of fields