Implement as_boolean/1 type

Closes #798