A native error originates outside an application's framework and business logic, typically in the programming-language ecosystem or an external library. If it reaches business logic unchanged, it couples that logic to native libraries and their types. section 13.1.1
Treat native errors as boundary concerns:
- A filesystem library may report a missing file through an exception or a native result type. section 13.1.2
- Propagating that failure directly into business logic exposes opaque types, increases coupling, and makes testing harder. section 13.1.2
- Layer-specific error domains contain each kind of failure behind a defined handling mechanism. section 13.1.2
Missing-file failure
A filesystem interpreter can catch a missing-file exception, carry it through an abstract filesystem language, and translate or reveal it at the appropriate boundary rather than embedding the library exception in business logic. section 13.1.2
module System.File where #1 import qualified GHC.IO.Exception as IOE #2 type NativeResult a = Either IOE.IOException a #3
The listing makes the native boundary concrete by representing a filesystem result with IOException inside NativeResult. section 13.1.2
