2019-06-26 15:37:55 +03:00
|
|
|
# Using `streamly` package
|
|
|
|
|
2019-08-14 04:05:12 +03:00
|
|
|
* [Latest stable release](https://hackage.haskell.org/package/streamly) is available on
|
|
|
|
Hackage.
|
|
|
|
* [Latest development version](https://github.com/composewell/streamly) is
|
|
|
|
available on github.
|
|
|
|
* See [recommeded compilation options here](docs/Build.md).
|
2019-06-26 15:37:55 +03:00
|
|
|
|
2019-08-14 04:05:12 +03:00
|
|
|
If you are using `stack` or `nix` please make sure to add the latest version
|
|
|
|
from Hackage to your tool configuration.
|
2019-06-26 15:37:55 +03:00
|
|
|
|
2019-08-14 04:05:12 +03:00
|
|
|
## Using with `cabal`
|
2019-06-26 15:37:55 +03:00
|
|
|
|
|
|
|
Make sure you have `cabal` version 2.4 or later installed and you have `ghc`
|
|
|
|
available in your PATH. Refresh your package list:
|
|
|
|
|
|
|
|
```
|
|
|
|
$ cabal v2-update
|
|
|
|
```
|
|
|
|
|
2019-08-14 04:05:12 +03:00
|
|
|
### Using hackage version in repl
|
2019-06-26 15:37:55 +03:00
|
|
|
|
|
|
|
```
|
2019-08-14 04:05:12 +03:00
|
|
|
# Run repl with the latest version from Hackage
|
2019-06-26 15:37:55 +03:00
|
|
|
$ cabal v2-repl --build-depends streamly
|
|
|
|
|
2019-08-14 04:05:12 +03:00
|
|
|
# Run repl with a specific version from Hackage
|
2019-06-26 15:37:55 +03:00
|
|
|
$ cabal v2-repl --build-depends streamly==0.6.1
|
|
|
|
```
|
|
|
|
|
2019-08-14 04:05:12 +03:00
|
|
|
### Using github version in repl
|
2019-06-26 15:37:55 +03:00
|
|
|
|
2019-08-14 04:05:12 +03:00
|
|
|
Create a directory for your playground (e.g. `test`) and create a
|
|
|
|
`cabal.project` file in it as follows:
|
2019-06-26 15:37:55 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
packages: .
|
|
|
|
source-repository-package
|
|
|
|
type: git
|
|
|
|
location: https://github.com/composewell/streamly
|
|
|
|
tag: master
|
|
|
|
```
|
|
|
|
|
2019-08-14 04:05:12 +03:00
|
|
|
Create a cabal file (e.g. `test.cabal`) as follows
|
2019-06-26 15:37:55 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
cabal-version: 2.4
|
|
|
|
name: test
|
|
|
|
version: 0
|
|
|
|
|
|
|
|
library
|
|
|
|
build-depends: base, streamly
|
|
|
|
```
|
|
|
|
|
|
|
|
Run repl:
|
|
|
|
|
|
|
|
```
|
|
|
|
$ cabal v2-repl
|
|
|
|
```
|
|
|
|
|
2019-08-14 04:05:12 +03:00
|
|
|
### Compiling with ghc
|
2019-06-26 15:37:55 +03:00
|
|
|
|
|
|
|
```
|
|
|
|
$ cat hello.hs
|
|
|
|
import qualified Streamly.Prelude as S
|
|
|
|
|
|
|
|
main = S.runStream $ S.fromListM [putStrLn "hello", putStrLn "world"]
|
|
|
|
```
|
|
|
|
|
|
|
|
```
|
|
|
|
$ cabal v2-install streamly-0.6.1
|
|
|
|
$ ghc -package streamly-0.6.1 hello.hs
|
|
|
|
```
|
|
|
|
|
2019-08-14 04:05:12 +03:00
|
|
|
### Using in a Project
|
2019-06-26 15:37:55 +03:00
|
|
|
|
|
|
|
Add `streamly` to the `build-depends` section of your library/executable in
|
|
|
|
your `<package>.cabal` file. Appropriate version from Hackage will be picked
|
|
|
|
depending on the version bounds that you specify. See the `github version in
|
|
|
|
repl` section above for a sample `<package>.cabal` file and optionally the
|
|
|
|
`cabal.project` file if you want to use the development version from github in
|
|
|
|
your project.
|