Efficient and Correct Stencil Computation via Pattern Matching and Static Typing