All Projects → ZHaskell → Stdio

ZHaskell / Stdio

Licence: bsd-3-clause
Haskell Standard Input and Output

Programming Languages

haskell
3896 projects

Labels

Projects that are alternatives of or similar to Stdio

Luvit
Lua + libUV + jIT = pure awesomesauce
Stars: ✭ 3,443 (+3308.91%)
Mutual labels:  libuv
Zigbridge
Zigbee gateway implementation
Stars: ✭ 21 (-79.21%)
Mutual labels:  libuv
Deep Into Code
Node.js / Libuv / V8 引擎源代码学习笔记
Stars: ✭ 66 (-34.65%)
Mutual labels:  libuv
Luv
Bare libuv bindings for lua
Stars: ✭ 466 (+361.39%)
Mutual labels:  libuv
Txiki.js
The tiny JavaScript runtime built with QuickJS, libuv and ❤️
Stars: ✭ 733 (+625.74%)
Mutual labels:  libuv
Uvloop
Ultra fast asyncio event loop.
Stars: ✭ 8,246 (+8064.36%)
Mutual labels:  libuv
Libwebsockets
canonical libwebsockets.org networking library
Stars: ✭ 3,314 (+3181.19%)
Mutual labels:  libuv
Hypepool
🚀 ⚡️ ✨ next-gen mining pool server software
Stars: ✭ 89 (-11.88%)
Mutual labels:  libuv
Libuv Mbedtls
port mbedtls on libuv
Stars: ✭ 17 (-83.17%)
Mutual labels:  libuv
Uwt
libuv bindings for OCaml
Stars: ✭ 51 (-49.5%)
Mutual labels:  libuv
Uv Cpp
libuv wrapper in C++11 /libuv C++11网络库
Stars: ✭ 480 (+375.25%)
Mutual labels:  libuv
Gameproject3
游戏服务器框架,网络层分别用SocketAPI、Boost Asio、Libuv三种方式实现, 框架内使用共享内存,无锁队列,对象池,内存池来提高服务器性能。还包含一个不断完善的Unity 3D客户端,客户端含大量完整资源,坐骑,宠物,伙伴,装备, 这些均己实现上阵和穿戴, 并可进入副本战斗,多人玩法也己实现, 持续开发中。
Stars: ✭ 655 (+548.51%)
Mutual labels:  libuv
Node.pas
Asynchronous Event-driven server programming for EMB Delphi, powered by libuv.
Stars: ✭ 45 (-55.45%)
Mutual labels:  libuv
Deep Into Node
深入理解Node.js:核心思想与源码分析
Stars: ✭ 4,005 (+3865.35%)
Mutual labels:  libuv
Uvw
Header-only, event based, tiny and easy to use libuv wrapper in modern C++ - now available as also shared/static library!
Stars: ✭ 1,222 (+1109.9%)
Mutual labels:  libuv
S task
awaitable coroutine library for C
Stars: ✭ 317 (+213.86%)
Mutual labels:  libuv
Ijjs
a lightweight js runtime for IOT(一个面向物联网的JS运行时)
Stars: ✭ 38 (-62.38%)
Mutual labels:  libuv
Gruvi
Async IO for Python, Simplified
Stars: ✭ 96 (-4.95%)
Mutual labels:  libuv
Igropyr
a async http server base on libuv for Chez Scheme
Stars: ✭ 85 (-15.84%)
Mutual labels:  libuv
Pyuv
Python interface for libuv
Stars: ✭ 1,046 (+935.64%)
Mutual labels:  libuv

Haskell stdio: haskell standard input and output

This project is moved to project Z and split into several packages.

Linux Build Status Windows Build Status

Welcome! Haskell stdio is a complete I/O toolkit powered by libuv, it features a multi-core io multiplexer and various improvements on packed data types. This project is still in infancy. Please join in!

    __  _____   _____ __ __ ________    __       _______________  ________ 
   / / / /   | / ___// //_// ____/ /   / /      / ___/_  __/ __ \/  _/ __ \
  / /_/ / /| | \__ \/ ,<  / __/ / /   / /       \__ \ / / / / / // // / / /
 / __  / ___ |___/ / /| |/ /___/ /___/ /___    ___/ // / / /_/ // // /_/ / 
/_/ /_/_/  |_/____/_/ |_/_____/_____/_____/   /____//_/ /_____/___/\____/

Install

On windows we have bundled libuv source, so no extra steps to be taken.

On *nix platforms, you should install libuv library first, you can use your distribution's package manager if available, for example:

# on debian/ubuntu, make sure to use 1.x
apt-get install libuv1-dev  libuv1

# on MacOS, we recommend brew
brew install libuv

...

Currently the minimum version requirement for libuv is v1.14. If your package manager's libuv doesn't meet this requirement, you can also build libuv from source following the guide here, e.g.

git clone https://github.com/libuv/libuv.git 
cd libuv 
git checkout tags/v1.24.0   # depend on your own need, any version >= 1.14 will work.
sh autogen.sh 
./configure 
make 
sudo make install 

After manually building and installing, you may need to modify your LIBRARY_PATH/CPATH if necessary. Now installing stdio is as easy as any other haskell packages.

cabal install stdio

Now you can fire GHCi and play around, or read the project overview, haddock.

Examples

  • hello world
import Std.IO.StdStream
import qualified Std.Data.Text as T

main = do
    -- read stdin and write to stdout, but with our new IO manager!
    input <- readLineStd
    printStd (T.validate input)
  • tcp echo server
import Std.IO.TCP
import Std.IO.Buffered
import Control.Monad

main = do
    startServer defaultServerConfig
        { serverAddr = SockAddrInet 8888 inetAny
        , serverWorker = echo
        }
  where
    echo uvs = forever $ do
        i <- newBufferedInput uvs 4096
        o <- newBufferedOutput uvs 4096
        readBuffer i >>= writeBuffer o
        flushBuffer o

Now try nc -v 127.0.0.1 8888.

  • logging
import Std.IO.Logger
import qualified Std.Data.Builder as B
import Control.Concurrent

main = withStdLogger $ do
    debug $ "hello world! PI ~=" >> B.double pi     -- debug level won't be immediately flushed
    forkIO $ do
        fatal "fatal message will trigger a log flush"
  • file system operatations
import           Std.IO.FileSystem
import           Std.IO.Resource
import           Std.IO.StdStream

main = do
    -- create a temp directory
    tempdir <- mkdtemp "temp"   
    let filename = "temp" <> "/test"
        flags = O_RDWR .|. O_CREAT      -- create if not exist
        mode = DEFAULT_MODE

    -- file is a 'Resource', use 'withResource' to automatically manage it
    withResource (initUVFile filename flags mode) $ \ f -> do
        o <- newBufferedOutput file 4096
        writeBuffer o "hello world!"
        flushBuffer o

    stat filename >>= printStd
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].