#fun hook didn't work as expected for getmntent(3)
- Dominant language
- Haskell
- Stars
- 211
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Description
### Description
`getmntent` function signature from `man`,
```C
struct mntent *getmntent(FILE *stream);
```
`#fun` hook syntax used when this issue was observed,
```chs
{#fun unsafe getmntent as ^ {`MntHandle'} -> `MntEntPtr' peek*#}
```
Generated definiton for `getmntent`
```hs
getmntent :: (MntHandle) -> IO ((MntEntPtr))
getmntent a1 =
let {a1' = id a1} in
getmntent'_ a1' >>= \res ->
peek res >>= \res' ->
return (res')
foreign import ccall unsafe "Sample.chs.h getmntent"
getmntent'_ :: ((MntHandle) -> (IO (C2HSImp.Ptr ())))
```
Full example to recreate this issue can be found [here](https://gist.github.com/krisis/e80b8cf6aeae4f3b08a448607afd5022/65ee329b4949c97a583413ed5a83c70f3ebb0d05)
### Steps to reproduce
- Command used to generate Haskell binding module
```
c2hs --cppopts='-I/usr/include/' -l Sample.chs
```
- Compile the generated Haskell binding module
```
ghc Sample.hs
```
### Software versions used
- `GHC` - `ghc-nopie-8.2.2 ` (I use `stack` for development)
- `c2hs` - ` C->Haskell Compiler, version 0.28.3 Switcheroo, 25 November 2017`
- `Platform` - `Linux komboothi 4.13.0-32-generic #35-Ubuntu SMP`
To get things to work, I copied the generated definition for `getmntent` into the `.chs` file and modifed the return type to `IO (Ptr MntEnt)`. This works as expected. From the documentation, I expected `#fun` hook to give this type automatically. Let me know if I am missing something or if I should provide further information to recreate this issue.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.