If you expose the record selector, then this program crashes at runtime with a divide by zero error:
import NonZero
safeDivide i (NonZero j) = i `div` j
main = case nonZero 1 of
Nothing -> putStrLn "One is zero?"
Just one -> do
let zero = one{ unNonZero = 0 }
print $ safeDivide 1 zero
If you expose the record selector, then this program crashes at runtime with a divide by zero error: