{"id":17537530,"url":"https://github.com/zenhack/haskell-unix-simple","last_synced_at":"2025-04-23T21:08:28.305Z","repository":{"id":56881702,"uuid":"327815277","full_name":"zenhack/haskell-unix-simple","owner":"zenhack","description":null,"archived":false,"fork":false,"pushed_at":"2023-02-05T07:56:23.000Z","size":33,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-23T21:08:22.716Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zenhack.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-08T06:14:40.000Z","updated_at":"2022-04-13T03:25:50.000Z","dependencies_parsed_at":"2023-02-18T22:30:22.313Z","dependency_job_id":null,"html_url":"https://github.com/zenhack/haskell-unix-simple","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenhack%2Fhaskell-unix-simple","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenhack%2Fhaskell-unix-simple/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenhack%2Fhaskell-unix-simple/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenhack%2Fhaskell-unix-simple/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zenhack","download_url":"https://codeload.github.com/zenhack/haskell-unix-simple/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250514786,"owners_count":21443209,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-20T20:42:07.864Z","updated_at":"2025-04-23T21:08:28.280Z","avatar_url":"https://github.com/zenhack.png","language":"Haskell","readme":"A straightforward wrapping of unix APIs for Haskell.\n\nI wrote this package because state of posix API support in Haskell is\nsomewhat unsatisfactory in a few ways:\n\n* There are many syscalls not covered by the `unix` package\n* The `unix` package needlessly renames syscalls, making them harder to\n  find for people familiar with the posix API. For example, `lstat` has\n  been renamed to `getSymbolicLinkStatus`\n* There are a large number of packages that fill in various holes, but\n  you have to scrape them together.\n\nThe goal of this package then, is to provide a one-stop-shop for unix\nAPI bindings, with a straightforward mapping to the underlying C API.\nAt the time of writing there are many syscalls missing, but in theory\nmost things belong here. Patches welcome; see the section below re:\nhow to add a syscall.\n\n# General Conventions\n\n* Function names are the same as the underlying system calls, so there\n  is no guesswork.\n* Wrappers automatically retry on `EINTR` where appropriate (this is\n  safe for most system calls, but not all, e.g. `close` on Linux).\n* The basic versions of the syscalls return `IO (Either Errno a)`,\n  rather than raising an exception.\n  * Each system call also has a variant suffixed with `Exn` that throws\n    exceptions.\n  * We define a type alias `type EIO a = IO (Either Errno a)` for\n    convenience.\n* For flags, we add newtype wrappers, and they can be combined with\n  their `SemiGroup` instances, e.g.\n  * `open \"hello.txt\" (o_CREAT \u003c\u003e o_RDWR) 0o600`\n* Flags are named the same as the C constant, but with the first\n  character lower-cased.\n* For functions that take a buffer, we instead accept a `ByteString`\n  when the buffer is read, or return one when it is written, e.g.\n  * `read :: Fd -\u003e Int -\u003e EIO BS.ByteString`\n  * `write :: Fd -\u003e BS.ByteString -\u003e EIO CSsize`\n* We also provide variants suffixed with `Buf`, that take a pointer and\n  size:\n  * `readBuf :: Fd -\u003e Ptr Word8 -\u003e CSize -\u003e EIO CSsize`\n* For functions that take an array of `struct iovec` as an input,\n  we provide several variants, e.g. for `writev` we provide:\n  * `writev :: Fd -\u003e [BS.ByteString] -\u003e EIO CSize`\n  * `writevBuf :: Fd -\u003e Ptr CIOVec -\u003e CInt -\u003e EIO CSsize`\n  * `writevVec :: Fd -\u003e SMV.IOVector CIOVec -\u003e EIO CSize`\n  (How to support readv is still an open design question).\n* We provide a `CString` type for functions which accept strings as\n  arguments. This type is an instance of `IsString`, so you can use\n  string literals if you enable `OverloadedStrings`, or use the\n  `fromString` function to convert. The conversion uses utf-8 encoding.\n* For some calls we also add obvious convenience helpers, e.g.\n  `readFull` and `writeFull`, which wrap `read` and `write` and handle\n  short reads and writes for the caller.\n\n# Contributing\n\n## Adding a syscall\n\nTo add a new system call:\n\n* Add the appropriate declaration to `Unix.C`, following conventions\n  established by the examples in that file.\n* Add a wrapper following the general conventions in `Unix`.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenhack%2Fhaskell-unix-simple","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzenhack%2Fhaskell-unix-simple","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenhack%2Fhaskell-unix-simple/lists"}