Skip to main content
Install Relativities before running the synthetic examples. A carrier files one countrywide manual and, for each state, exception pages that change some of its rates and rules. Keep the countrywide manual in one rater. Write a state file for each state: it names that rater as its base and states only the changes.
The example rates pet accident and illness for the synthetic carrier Example Mutual, in Texas and in California. Save the files below in a folder pet-states.

Keep the countrywide manual in one rater

Save the countrywide rater as pet-states/base.rsl, with its four tables:
pet-states/base.rsl
pet-states/tables/BaseRate.csv
pet-states/tables/BreedFactor.csv
pet-states/tables/SexFactor.csv
pet-states/tables/AgeFactor.csv
The monthly premium is a chain of factors, plus a claims fee, times an inception factor:
Check the countrywide rater:

Name the base in a state file

Texas files the countrywide manual as it stands. Its memorandum reprints the claims fee, so the Texas rater cites the fee on that page. Save pet-states/tx.rsl:
pet-states/tx.rsl
  • rsl: "0.4.2" is the RSL version that reads state files. The base keeps its own version.
  • The spec block of the state file is the spec of the Texas rater.
  • extends "base.rsl" names the base: a file in the folder of the state file.
  • Sources declares the Texas filing. A plain section declares names of the state’s own.
  • replace Constants gives the claims fee the base’s value and the Texas citation.
Check the state file:
The check compiles the base, applies the state file to it, and checks the result as one rater.

Replace what the state’s pages change

The California pages file four tables and the claims fee, and add a breed group. Save pet-states/ca.rsl and the California tables:
pet-states/ca.rsl
pet-states/tables/ca/BaseRate.csv
pet-states/tables/ca/BreedFactor.csv
pet-states/tables/ca/SexFactor.csv
pet-states/tables/ca/AgeFactor.csv
Each replace names a declaration of the base and states the state’s version of it.

Replace a type and the tables it keys

California adds the breed group giant. A replaced enumeration holds every member of the base’s enumeration:
Each member of the base keeps its id, so every read of the base reads the same member. The new member giant takes the next id. BreedFactor is keyed by BreedGroup, so California files it again with a row for giant. A table that California declares in its own Tables section is keyed by California’s BreedGroup already, so it stands as written. A replaced table keeps the base’s keys in the same order, and each column of the base under its name and type:
The CSV file of a replaced table holds a row for each key of the base’s rows.

Change one row of a table

California changes the factor of male pets, and keeps the factor of female pets. A table’s rows are the rows of one file. A state that changes one row declares the whole table in replace Tables and names its own CSV:
The California file tables/ca/SexFactor.csv holds both rows: male at 1.02, and female at the countrywide 1.00. Each key compares by its declared type. A number key, such as the age band 2, compares by value, so 2 and 2.0 are one key. California files its own anniversary factors and keeps the countrywide inception factors. Its file tables/ca/AgeFactor.csv holds both columns.

Replace a constant

The new value has the type of the base’s value.

Add to a record and its chain

amend Records adds inputs, calculations and rules to a record of the base. California asks whether the pet carries a microchip, and charges a fee for a senior pet:
Each added field has a name of its own. Each value of the base keeps its definition. The senior charge joins the monthly premium before the inception factor. amend chain adds a named step to the arithmetic of a calculation:
  • The chain of Pet.monthly starts from base_rate. Its steps read breed_factor, sex_factor, age_factor, claims_fee and inception_factor, in that order.
  • A step is named by the value it reads. before inception_factor puts the new step between the claims fee and the inception factor.
  • The base’s round holds the whole chain, so it rounds the new total.
  • The new step is the calculation Pet.senior. California’s monthly premium is round((base_rate × breed_factor × sex_factor × age_factor + claims_fee + senior_charge) × inception_factor, 2, half_up).

Drop a base rule

The countrywide manual enrolls a pet up to age 14. California enrolls a pet up to age 13, under the same code:
drop check removes each base rule with the code. A rule of the state’s own amend Records keeps the code, so California refuses age 14 with its own message.

Check and rate each state

rslc show prints the merged program of a state file, with the file that supplies each declaration:
The first line names the stack of files, lowest first, and the second line the identity of the merged program. rslc diff prints the difference between two states. Texas adds its own source and cites the claims fee at the countrywide value:
Build a rater from each file, and rate a male dog of a medium breed, aged 4:
Texas rates as the countrywide manual: $61.74 a month. California asks the added input microchipped, and its own tables give $70.15. A California dog aged 12 pays the senior charge before the inception factor:
The premium is round((44.20 × 1.21 × 1.02 × 2.00 + 3.60 + 2.50) × 1.25, 2, half_up) = 144.00. California refuses a pet aged 14 with its own message. The countrywide rater accepts 14 and refuses 15:
Keep each state file in the folder of its base. Rater.build compiles a state file as the bundle’s rater.rsl, so name the base base.rsl, or any name other than rater.rsl.

Export a state

rslc export packages the rater that a state file gives:
The bundle holds the base’s source, the state file, the tables the California rater reads, and the countrywide tables that check California’s:
California replaces all four countrywide tables, so the rater reads each table from one California file. The bundle keeps each countrywide file, so a California file is checked for a row for each countrywide key wherever the bundle opens. The bundle’s manifest lists each such base file in source_files with the kind enum_csv: it is data that a check reads, and the rater rates only on the California files. rslc check, rslc export and the catalog all read the same California rater.