Z-IO: Simple and high performance IO toolkit for Haskell

[ bsd3, data, library ] [ Propose Tags ]
This version is deprecated.

Simple and high performance IO toolkit for Haskell, including file system, network, ipc and more!


[Skip to Readme]

Flags

Manual Flags

NameDescriptionDefault
no-pkg-config

Don't use pkg-config to check for library dependences

Disabled
Automatic Flags
NameDescriptionDefault
integer-simple

Use the simple integer library instead of integer-gmp

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.1.0, 0.1.1.1, 0.1.1.2, 0.1.2.0, 0.1.3.0, 0.1.4.0, 0.1.5.0, 0.1.5.1, 0.1.5.2, 0.1.6.0, 0.1.6.1, 0.1.7.0, 0.1.8.0, 0.1.8.1, 0.1.9.0, 0.2.0.0, 0.3.0.0, 0.4.0.0, 0.5.0.0, 0.6.0.0, 0.6.1.0, 0.6.2.0, 0.6.3.0, 0.6.4.0, 0.7.0.0, 0.7.1.0, 0.8.0.0, 0.8.1.0, 0.8.1.1, 1.0.0.0, 1.0.1.0, 1.0.2.0, 2.0.0.0 (info)
Change log ChangeLog.md
Dependencies base (>=4.12 && <5.0), exceptions (>=0.10 && <0.11), ghc-prim (>=0.6.1 && <0.6.2), integer-gmp (>=0.2 && <1.1), integer-simple (>=0.1 && <0.5), primitive (>=0.7.1 && <0.7.2), stm (>=2.5 && <2.6), time (>=1.8 && <2.0), Z-Data (>=0.1.3.1 && <0.1.4) [details]
License BSD-3-Clause
Copyright (c) Dong Han, 2017-2020 (c) Tao He, 2017-2019
Author Dong Han, Tao He
Maintainer winterland1989@gmail.com
Category Data
Home page https://github.com/haskell-Z/Z-IO
Bug tracker https://github.com/haskell-Z/Z-IO/issues
Source repo head: git clone git://github.com/haskell-Z/Z-IO.git
Uploaded by winterland at 2020-09-24T20:04:32Z
Distributions
Reverse Dependencies 4 direct, 0 indirect [details]
Downloads 9814 total (3 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for Z-IO-0.1.1.0

[back to package description]

Z-IO

Linux Build Status

This package provides basic IO operations:

  • IO resource management, resource pool
  • File system
  • Network: DNS, TCP, UDP and IPC
  • Buffered input and output
  • High performance logger
  • High performance timer

Dependencies

On *nix system, libuv >= 1.32 are required to build this library, e.g.

# on ubuntu
sudo apt-get install libuv1 libuv1-dev
# on mac
brew install libuv

Example usage

> :set -XOverloadedStrings  
> import Z.IO.Network
> import Z.IO.Resource
> import Z.IO.Buffered
> 
> -- call getAddrInfo to perform DNS
> head <$> getAddrInfo Nothing "www.bing.com" "http"
AddrInfo {addrFlags = [AI_ADDRCONFIG,AI_V4MAPPED], addrFamily = SocketFamily 2, addrSocketType = SocketType 1, addrProtocol = ProtocolNumber 6, addrAddress = 204.79.197.200:80, addrCanonName = }
>
> import qualified Z.Data.Text as T
> -- send a simple HTTP request
> :{
| let addr = SocketAddrInet 80 (tupleToInetAddr (13,107,21,200))
| -- addr = ipv4 "13.107.21.200" 80
| in withResource (initTCPClient defaultTCPClientConfig{ tcpRemoteAddr = addr}) $ \ tcp -> do
|     i <- newBufferedInput defaultChunkSize tcp 
|     o <- newBufferedOutput defaultChunkSize tcp
|     writeBuffer o "GET http://www.bing.com HTTP/1.1\r\nHost: www.bing.com\r\n\r\n"
|     flushBuffer o
|     readBuffer i >>= pure . T.validate
| :}
"HTTP/1.1 200 OK\r\nDate: Sat, 19 Sep 2020 06:11:08 GMT\r\nContent-Length: 0\r\n\r\n"
>
> -- Start a TCP echo server, use @nc -v localhost 8080@ to test
> :{
| startTCPServer defaultTCPServerConfig{
| tcpListenAddr = SocketAddrInet 8080 inetLoopback,
| tcpServerWorker = \ tcp -> do
|     i <- newBufferedInput defaultChunkSize tcp 
|     o <- newBufferedOutput defaultChunkSize tcp
|     forever $ readBuffer i >>= writeBuffer o >> flushBuffer o
| }
| :}

Dev guide

  • GHC(>=8.10.2)
  • cabal-install(>=3.4)
# get code
git clone --recursive git@github.com:haskell-Z/z-io.git 
cd z-io
# build
cabal build
# test
cabal run Z-IO-Test
# install 
cabal install
# generate document
cabal haddock