pattern이 수행하는 세 작업

검사, binding, component 분해를 한 분기에 묶는다.

  1. Type test

    입력 subtype을 검사한다

    match
  2. Bind

    cast된 변수에 이름을 붙인다

    variable
  3. Deconstruct

    record component를 꺼낸다

    data
  4. Guard

    when 조건으로 값을 세분화한다

    refine

핵심: 입력 공간과 branch 결과가 명확해지는 범위에서 pattern을 사용한다.