haskell / win32

Haskell support for the Win32 API
http://hackage.haskell.org/package/Win32
Other
98 stars 62 forks source link

Change type synonym used in `loadLibrary{Ex}`'s return type from `HINSTANCE` to `HMODULE` #211

Closed RyanGlScott closed 2 years ago

RyanGlScott commented 2 years ago

This is a fairly minor thing, but it's something that tripped me up recently. I was looking at the Haddocks for System.Win32.DLL, which defines the following functions:

disableThreadLibraryCalls :: HMODULE -> IO ()
freeLibrary               :: HMODULE -> IO ()
getModuleFileName         :: HMODULE -> IO String
getModuleHandle           :: Maybe String -> IO HMODULE
getProcAddress            :: HMODULE -> String -> IO Addr
loadLibrary               :: String -> IO HINSTANCE
loadLibraryEx             :: String -> HANDLE -> LoadLibraryFlags -> IO HINSTANCE

Most of these functions work over HMODULE with two exceptions: loadLibrary and loadLibraryEx. This confused me at first, as I didn't realize that HINSTANCE and HMODULE are both type synonyms for the same thing (Ptr ()). I even looked the official Win32 documentation for LoadLibrary and LoadLibraryEx, both of which use HMODULE rather than HINSTANCE.

Could the Haddocks in the Haskell Win32 library also use HMODULE instead of HINSTANCE? This would make all of the type synonym uses in System.Win32.DLL consistent, and it would match how the presentation in the official Win32 documentation as well.