Comments (4)
Hi, Thanks for the report.
While I agree that the type is technically incorrect, as in PHANDLE
is void**
I'm not sure it really matters in this case. We've effectively declared PHANDLE
as void*
because there's no easy way to create a GHC.IO.Handle
from this to be able to use it in Haskell functions expecting a Handle
.
In case you're passing it to other Win32 functions it should be fine as well as it's an opaque value. We don't pretend to know anything about it in the Haskell world.
Whenever #51 gets done I'll make sure to correct this. Unless you want to submit a PR for it to get it done sooner?
from win32.
Any update on this? #51 seems done, via #70
from win32.
It hasn't been done yet, it's not a correctness issue so it's not particularly high on my to-do list atm I must admit. The handle is being treated as a completely opaque value in Haskell side so we assume nothing about it.
from win32.
I posted this issue two years ago, I can recall a bit why I need to represent PHANDLE
as Ptr HANDLE
. Consider such situation: we need create pipe and then use the in/out handle created by CreatePipe
for other purpose. The signature of CreatePipe
of Win32 API is
BOOL WINAPI CreatePipe(
_Out_ PHANDLE hReadPipe,
_Out_ PHANDLE hWritePipe,
_In_opt_ LPSECURITY_ATTRIBUTES lpPipeAttributes,
_In_ DWORD nSize
);
In haskell, it should be
createPipe :: PHANDLE -> PHANDLE -> LPSECURITY_ATTRIBUTES -> DWORD -> IO Bool
This is roughly how we invoke this function:
let lpattr = ...
size = ...
(in, out) <- alloca $ \pin ->
alloca $ \pout ->
createPipe pin pout lpattr size
(,) <$> (peek pin) <*> (peek pout)
If we represent PHANDLE
also as Ptr ()
, we would need to cast pin
and pout
before or after invoke createPipe
to get the type correct. That would lead to inconvenience and concern about type safe. The code above may not be the correct manner to use CreatePipe
, but we do feel uncomfortable in certain situations.
As what is stated in the description of this issue, I think we might should obey the relation, and difference of types of Win32 API as what they are in their C/C++version, even although they are opaque.
from win32.
Related Issues (20)
- Win32-2.6.2.1, provided by GHC 8.10.6 and 8.10.7, is not on Hackage HOT 2
- `isMinTTY` no longer detects recent `mintty`s HOT 7
- Change maxLength to 16 in function getComputerName HOT 1
- If `--io-manager=native`, `withHandleToHANDLE` does not work for a 'console' `Handle` HOT 7
- `Setup.hs` seems inconsistent with the `build-type` option of the cabal file. HOT 1
- Support for `schannel.h` and `wincrypt.h` functions HOT 1
- Add constant `INVALID_SET_FILE_POINTER`
- Provide `GetTempFileNameW`
- Expose `FindData` struct HOT 5
- createFile without busy-wait HOT 6
- fails to start soon after starlink terminal power on HOT 1
- Change type synonym used in `loadLibrary{Ex}`'s return type from `HINSTANCE` to `HMODULE`
- Is it possible to use this package to control the Microsoft Excel application? HOT 2
- `System.Win32.MinTTY` doesn't detect newer versions of `mintty` (but perhaps that's OK) HOT 5
- Add setWindowPos and getConsoleWindow HOT 1
- Support filepath >= 1.5.0.0 and os-string HOT 1
- #221 Introduced unused-imports warnings which lead to failures in GHC HOT 7
- Make hackage revision for 2.13.3.0 HOT 3
- Can't retrieve registry value size HOT 2
- Please build and upload documentation to Hackage
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from win32.