#7415: Add more error code support to GHC.Windows (patch) ----------------------------+----------------------------------------------- Reporter: joeyadams | Owner: Type: feature request | Status: new Priority: normal | Component: libraries/base Version: 7.6.1 | Keywords: Os: Windows | Architecture: Unknown/Multiple Failure: None/Unknown | Blockedby: Blocking: 7353 | Related: ----------------------------+----------------------------------------------- This patch adds some infrastructure for the [http://hackage.haskell.org/trac/ghc/ticket/7353 Windows I/O manager] currently in progress. It organizes `GHC.Windows` a little, and adds some things:
* A `LPWSTR` type alias. I'm not a Windows expert, but I think we should avoid [http://msdn.microsoft.com/en- us/library/windows/desktop/aa383751%28v=vs.85%29.aspx#lptstr LPTSTR] in our FFI declarations. It depends on whether or not the `UNICODE` macro is defined—a notion that makes little sense in a Haskell program. Using `LPWSTR` makes our intention clearer. I left `LPTSTR` in for compatibility. Should we DEPRECATE it? * `c_maperrno_func`. The existing `c_maperrno` calls `GetLastError`, converts the result, then sets `errno`. `c_maperrno_func` exposes the conversion as a pure function. This helps eliminate a caveat in [http://www.haskell.org/ghc/docs/latest/html/libraries/Win32/System- Win32-Types.html#v:failWith failWith], which expects `GetLastError` to return the error passed to `failWith`. This is not the case, for example, when throwing the error in another thread. * `failWith`, `failIf`, ... error guards from [http://www.haskell.org/ghc/docs/latest/html/libraries/Win32/System- Win32-Types.html System.Win32.Types]. * `ErrCode`, `getLastError`, `getErrorMessage`, `errCodeToIOError`: Lets you work with the system error code more directly. * `iNVALID_HANDLE_VALUE` Behavior change: `throwGetLastError` now attaches the system error message, making it (almost) equivalent to [http://www.haskell.org/ghc/docs/latest/html/libraries/Win32/System- Win32-Types.html#v:errorWin errorWin] from `System.Win32.Types`. Moreover, it no longer has the side effect of setting `errno`, thanks to `c_maperrno_func`. -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7415> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs