Algebraic types and pattern matching