|
|
|
|
|
by marcosdumay
2109 days ago
|
|
Defining a test like: # Checks if the user has the correct authorization
log(non_authorized_user)
def some_action:
assert_failure(user_has_authroization)
isn't much different from checking that on the types: data AuthorizedUser authorizationSchema = AuthrorizedUser User
someAction :: AuthroizedUser ActionAuthorization -> IO ()
someAction = undefined
|
|
However, the compiler's type-checking is automatic, so you don't have to write a ton of unit tests to get its benefit, and the error messages are usually much better.
I've yet to see a dynamically typed codebase that has sufficient unit tests to replace a decent compile-time type-system.
One other point that matters is time: running 20k unit and integration tests to verify the types are all correct for your 6kloc will take much longer than compiling 6kloc, and the compiler does a much better job of updating incrementally based on code changes than any unit testing framework I've used.