{"id":13688061,"url":"https://github.com/composewell/streamly-examples","last_synced_at":"2025-04-30T06:28:08.287Z","repository":{"id":42721201,"uuid":"221582841","full_name":"composewell/streamly-examples","owner":"composewell","description":"Examples for Streamly","archived":false,"fork":false,"pushed_at":"2025-03-25T19:56:39.000Z","size":226,"stargazers_count":29,"open_issues_count":13,"forks_count":4,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-30T13:34:11.798Z","etag":null,"topics":["streamly"],"latest_commit_sha":null,"homepage":"https://streamly.composewell.com","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/composewell.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-14T01:12:29.000Z","updated_at":"2025-02-17T16:35:10.000Z","dependencies_parsed_at":"2023-11-26T00:21:23.009Z","dependency_job_id":"6395f1db-ac15-4e23-baef-540501874330","html_url":"https://github.com/composewell/streamly-examples","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/composewell%2Fstreamly-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/composewell%2Fstreamly-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/composewell%2Fstreamly-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/composewell%2Fstreamly-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/composewell","download_url":"https://codeload.github.com/composewell/streamly-examples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251653444,"owners_count":21622126,"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":["streamly"],"created_at":"2024-08-02T15:01:05.853Z","updated_at":"2025-04-30T06:28:08.281Z","avatar_url":"https://github.com/composewell.png","language":"Nix","funding_links":[],"categories":["Nix"],"sub_categories":[],"readme":"# Streamly Examples\n\nPractical examples to demonstrate the features and performance of\nStreamly.  Includes examples about file IO, text processing, networking,\nconcurrent programming, reactive programming and more.\n\nThese examples also serve as a beginner's guide to express practical\nprograms using the dataflow programming (streaming) model.  Please visit\nthe [Streamly homepage](https://streamly.composewell.com) for more\ndetails and comprehensive documentation.\n\n## Running The Examples\n\nWhen running the unstable version (downloaded from the git repository)\nyou must use `--project-file cabal.project.user` option otherwise the\nbuild might fail. For example:\n\n```\n$ cabal run --project-file cabal.project.user AcidRain\n```\n\nExecutable names are the same as the filenames.  To run an example:\n\n```\n$ cabal run AcidRain\n```\n\nTo run SDL2 based examples, make sure that you have the OS package for\nthe sdl2 library installed on your system and the headers are visible to\ncabal:\n\n```\n$ cabal run --flag sdl2 CirclingSquare\n```\n\nTo run interop examples, use the `interop` build flag:\n\n```\n$ cabal run --flag interop Interop.Pipes\n```\n\n## List of examples\n\n### General\n\n* [Intro](https://github.com/composewell/streamly-examples/blob/master/examples/Intro.hs): Simple, introductory examples - loops, text\n  processing, networking, concurrency.\n* [MergeSort](https://github.com/composewell/streamly-examples/blob/master/examples/MergeSort.hs): Sort a stream concurrently using merge\n  sort.\n* [Rate](https://github.com/composewell/streamly-examples/blob/master/examples/Rate.hs): Run an action at a given rate.\n\n### FileSystem\n\n* [CoreUtils](https://github.com/composewell/streamly-examples/blob/master/examples/CoreUtils.hs): Implement simplified coreutils\n  like `cat`, `cp`, `tee`, `grep` using `Streamly.FileSystem.File` API.\n* [CoreUtilsHandle](https://github.com/composewell/streamly-examples/blob/master/examples/CoreUtilsHandle.hs): Implement simplified\n  coreutils using `Streamly.FileSystem.Handle` API.\n* [Split](https://github.com/composewell/streamly-examples/blob/master/examples/Split.hs): Implement file splitting utility `split`.\n* [FileSystemEvent](https://github.com/composewell/streamly-examples/blob/master/examples/FileSystemEvent.hs): File watching/fsnotify API\n  example.\n* [ListDir](https://github.com/composewell/streamly-examples/blob/master/examples/ListDir.hs): List a directory tree recursively and\n  concurrently, faster than rust fd.\n\n### Text Processing\n\n* [CamelCase](https://github.com/composewell/streamly-examples/blob/master/examples/CamelCase.hs): Convert a file to camel case.\n* [WordCount](https://github.com/composewell/streamly-examples/blob/master/examples/WordCount.hs): Simple word counting (`wc`) program.\n* [WordCount.c](https://github.com/composewell/streamly-examples/blob/master/examples/WordCount.c): C equivalent for perf comparison.\n* [WordCountModular](https://github.com/composewell/streamly-examples/blob/master/examples/WordCountModular.hs): Modular version.\n* [WordCountParallel](https://github.com/composewell/streamly-examples/blob/master/examples/WordCountParallel.hs): Concurrent version.\n* [WordCountParallelUTF8](https://github.com/composewell/streamly-examples/blob/master/examples/WordCountParallelUTF8.hs): Concurrent\n  version with full UTF8 handling.\n* [WordFrequency](https://github.com/composewell/streamly-examples/blob/master/examples/WordFrequency.hs): Count word frequency in\n  a file and print top 25 words.\n* [CSVParser](https://github.com/composewell/streamly-examples/blob/master/examples/CSVParser.hs): Process a CSV file\n* [DateTimeParser](https://github.com/composewell/streamly-examples/blob/master/examples/DateTimeParser.hs): Parse a Date/Time string.\n* [LogParser](https://github.com/composewell/streamly-examples/blob/master/examples/LogParser.hs): Parse a quoted string with escaping.\n\n### Networking\n\n* [EchoServer](https://github.com/composewell/streamly-examples/blob/master/examples/EchoServer.hs): A concurrent TCP server that\n  echoes everything that it receives.\n* [MergeServer](https://github.com/composewell/streamly-examples/blob/master/examples/MergeServer.hs): Merges lines received from\n  several client connections and writes them to a file.\n* [FileSender](https://github.com/composewell/streamly-examples/blob/master/examples/FileSender.hs): Send many files concurrently to\n  a server over multiple connections. Can be used to test `MergeServer`.\n* [CmdServer](https://github.com/composewell/streamly-examples/blob/master/examples/CmdServer.hs): Receive a stream of commands from many\n  clients and respond to them using command handlers.\n* [CmdClient](https://github.com/composewell/streamly-examples/blob/master/examples/CmdClient.hs): Run multiple concurrent clients sending\n  streams of commands to a server and receiving responses. Can be used to test\n  `CmdServer`.\n* [WordServer](https://github.com/composewell/streamly-examples/blob/master/examples/WordServer.hs): A word look up (dictionary)\n  server, instead of performing a real DB query the server just adds a\n  time delay to simulate the IO.\n\n### FRP/Games/Animation\n\n* [AcidRain](https://github.com/composewell/streamly-examples/blob/master/examples/AcidRain.hs): A console game with deteriorating health\n  that can be modified by typing \"harm\" and \"potion\" commands.\n* [CirclingSquare](https://github.com/composewell/streamly-examples/blob/master/examples/CirclingSquare.hs): Use SDL2 to display a\n  square that moves in a circle, and follows the mouse pointer.\n\n### Interoperation\n\n* [Interop.Streaming](https://github.com/composewell/streamly-examples/blob/master/examples/Interop/Streaming.hs): Converting streamly\n  stream type to and from `streaming` stream type.\n* [Interop.Pipes](https://github.com/composewell/streamly-examples/blob/master/examples/Interop/Pipes.hs): Converting streamly\n  stream type to and from `pipes` stream type.\n* [Interop.Conduit](https://github.com/composewell/streamly-examples/blob/master/examples/Interop/Conduit.hs): Converting streamly\n  stream type to and from `conduit` stream type.\n* [Interop.Vector](https://github.com/composewell/streamly-examples/blob/master/examples/Interop/Vector.hs): Converting streamly\n  stream type to and from `vector` stream type.\n\n## Comparing Haskell Performance with C and Rust\n\n### Word Count\n\n`examples/WordCount.c` is the C equivalent of `examples/WordCount.hs`:\n\n```\n$ make\n$ examples/WordCount input.txt\n```\n\n### Directory Traversal\n\n`examples/ListDirBasic.c` is the C equivalent of `examples/ListDirBasic.hs`:\n\n```\n$ make\n$ examples/ListDirBasic\n```\n\n`examples/ListDirBasic.rs` is the Rust equivalent of\n`examples/ListDirBasic.hs` using `std::fs` :\n\n```\n$ cargo build --example ListDirBasic --release\n$ target/release/examples/ListDirBasic\n```\n\n`example/WalkDirBasic.rs` is the Rust equivalent of\n``example/ListDirBasic.hs` using the `walkdir` crate:\n\n```\n$ cargo build --example WalkDirBasic --release\n$ target/release/examples/WalkDirBasic\n```\n\n## Licensing\n\nAvailable under [Apache-2.0 license](https://github.com/composewell/streamly-examples/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomposewell%2Fstreamly-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomposewell%2Fstreamly-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomposewell%2Fstreamly-examples/lists"}