zbo14 / bencode-hs

small bencoding library in haskell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bencode-hs

Small bencoding library in haskell.

example:

module Main where

import Bencode (decode,encode)
import Data.Map (empty)
import Value (consInt,consString,insertList,insertString,wrap)

main :: IO ()
main = do 
    let l = consInt 123 $ consString "abc" []
        d = insertString "string" "v a p o r vv a v e" $ insertList "list" l empty
        s = encode $ wrap d
    putStrLn s
    -- d4:listli123e3:abce6:string18:v a p o r vv a v ee
    putStrLn . show $ decode s
    -- Just (D (fromList [("list",L [I 123,S "abc"]),("string",S "v a p o r vv a v e")]),49,"")

About

small bencoding library in haskell

License:MIT License


Languages

Language:Haskell 100.0%