@@ -1,33 +1,40 @@
1โ# Package-Sets
1+# Package Sets
22
33[](https://travis-ci.org/purescript/package-sets)
44
5โPureScript package sets for Psc-Package, aka "Spacchetti"
5+A curated list of PureScript packages for Psc-Package and Spago
66
77
88
9โDhall-driven package sets, made for forking and modifying easily.
109
11โHistorically, this was a separate project created by Justin Woo called "Spacchetti" (as in Spagghetti + Pacchetti). This has now merged into package-sets, but is still referred to as "Spacchetti" in many resources.
10+- [What is a package-set?](#what-is-a-package-set)
11+- [Add your package](#add-your-package)
12+- [How do I use package-sets with `psc-package`?](#how-do-i-use-package-sets-with-psc-package)
13+- [How do I use package-sets with `spago`?](#how-do-i-use-package-sets-with-spago)
1214
13โ## Introduction to Psc-Package (from a Package-Sets perspective)
1415
15โ### What is Psc-Package?
16+## What is a package set?
1617
17โ[Psc-Package](https://github.com/purescript/psc-package/) is a package manager for PureScript that works essentially by running a bunch of git commands. Its distinguishing feature from most package managers is that it uses a **package set**.
18+A package set is a **collection** of packages, such that there is only **one** entry (i.e. version) for a given package in the set.
1819
19โ### What is a Package Set?
20+If you use a package manager based on package-sets, this means that when you want to install a package:
21+- it must be in the package set
22+- its dependencies and all the transitive dependencies must be in the package set
2023
21โMany users trying to rush into using Psc-Package don't slow down enough to learn what package sets are. They are a **set** of packages, such that the package set only contains **one** entry for a given package in a set. This means that
24+## Add your package
2225
23โ* Whichever package you want to install must be in the package set
24โ* The dependencies and the transitive dependencies of the package you want to install must be in the package set
26+This repository aims to be a good collection of packages you can depend on.
27+In general we welcome all packages, provided that they follow some guidelines defined in the [contributing guide](#CONTRIBUTING.md).
2528
26โPackage sets are defined in `packages.json` in the root of any package set repository, like in <https://github.com/purescript/package-sets/blob/master/packages.json>.
29+The linked document also contains instructions on how to add new packages to the set, and information on versioning and related policies.
2730
28โ### How are package sets used?
31+## How do I use `package-sets` with Psc Package?
2932
30โPackage sets are consumed by having a `psc-package.json` file in the root of your project, where the contents are like below:
33+[`psc-package`][psc-package] is a package manager for PureScript that works essentially by running a bunch of git commands. Its distinguishing feature from most package managers is that it uses a **package set**.
34+
35+`psc-package` will use as package-set the `packages.json` file in the root of any package-set repository, like in [this case][packages-json].
36+
37+In order to use a package-set, the `psc-package.json` file in the root of your project, should look something like this:
3138
3239```json
3340{
@@ -42,178 +49,49 @@ Package sets are consumed by having a `psc-package.json` file in the root of you
4249}
4350```
4451
45โSo the way this file works is that
52+The way this file works is that:
53+- `"set"` matches the tag or branch of the git repository of the package set
54+- `"source"` is the URL for the git repository of the package set
55+- `"depends"` is an array of strings, where the strings are names of packages you depend on.
56+ *Note:* as said above, these dependencies should be contained in the package-set
4657
47โ* `"set"` matches the tag or branch of the git repository of the package set
48โ* `"source"` is the URL for the git repository of the package set
49โ* `"depends"` is an array of strings, where the strings are names of packages you depend on
50โ
51โWhen you run `psc-package install`, psc-package will perform the steps so that the following directory has the package set cloned to it:
58+When you run `psc-package install`, psc-package will perform the steps so that the following directory will have the package set cloned into it:
5259
5360```
5461.psc-package/set-name/.set
5562```
5663
57โAnd the package set will be available in
64+And the package set will then be available in
5865
5966```
6067.psc-package/set-name/.set/packages.json
6168```
6269
63โWhen you install a package in your given package set, the directory structure will be used, such that if you install `aff` from your package set at version `v5.0.0`, you will have the contents of that package in the directory
70+When you install a package in your given package set, the package contents will be cloned in the following directory structure:
6471
6572```
66โ.psc-package/set-name/aff/v5.0.0
67โ```
68โ
69โOnce you understand these three sections, you'll be able to solve any problems you run into with Psc-Package.
70โ
71โ## Why/How Dhall?
72โ
73โ[Dhall](https://github.com/dhall-lang/dhall-lang) is a programming language that guarantees termination. Its most useful characteristics for uses in this project are
74โ
75โ* Static typing with correct inference: unlike the packages.json file, we have the compiler check that we correctly define packages
76โ* Functions: we can use functions to create simple functions for defining packages
77โ* Local and remote path importing: we can use this to mix and match local and remote sources as necessary to build package sets
78โ* Typed records with directed merging: we can use this to split definitions into multiple groupings and apply patching of existing packages as needed
79โ
80โLet's look at the individual parts for how this helps us make a package set.
81โ
82โ### Files
83โ
84โThe files in this package set are prepared as such:
85โ
73+.psc-package/${set-name}/${package-name}/${tag}
8674```
87โ-- Package type definition
88โsrc/Package.dhall
89โ
90โ-- function to define packages
91โsrc/mkPackage.dhall
9275
93โ-- packages to be included when building package set
94โsrc/packages.dhall
76+E.g. in case of `aff@v5.0.0`:
9577
96โ-- package "groups" where packages are defined in records
97โsrc/groups/[...].dhall
9878```
99โ
100โ#### `Package.dhall`
101โ
102โThis contains the simple type that is the definition of a package:
103โ
104โ```hs
105โ{ dependencies : List Text, repo : Text, version : Text }
106โ```
107โ
108โSo a given package has a list of dependencies, the git url for the repository, and the tag or branch that it can be pulled from.
109โ
110โ#### `mkPackage.dhall`
111โ
112โThis contains a function for creating `Package` values easily
113โ
114โ```hs
115โ ฮป(dependencies : List Text)
116โโ ฮป(repo : Text)
117โโ ฮป(version : Text)
118โโ { dependencies = dependencies, repo = repo, version = version }
119โ : ./Package.dhall
120โ```
121โ
122โWhile this function is unfortunately stringly typed, this still lets us conveniently define packages without having to clutter the file with record definitions.
123โ
124โ#### `packages.dhall`
125โ
126โThis is the main file used to generate `packages.json`, and is defined by taking package definitions from the groups and joining them with a right-sided merge.
127โ
128โ```hs
129โ ./groups/purescript.dhall
130โโซฝ ./groups/purescript-contrib.dhall
131โโซฝ ./groups/purescript-web.dhall
132โโซฝ ./groups/purescript-node.dhall
133โ-- ...
134โโซฝ ./groups/justinwoo.dhall
135โโซฝ ./groups/patches.dhall
136โ```
137โ
138โ### Definitions and overrides
139โ
140โAs `patches.dhall` is last, its definitions override any existing definitions. For example, you can put an override for an existing definition of `string-parsers` with such a definition:
141โ
142โ```hs
143โ let mkPackage = ./../mkPackage.dhall
144โ
145โin { string-parsers =
146โ mkPackage
147โ [ "arrays"
148โ , "bifunctors"
149โ , "control"
150โ , "either"
151โ , "foldable-traversable"
152โ , "lists"
153โ , "maybe"
154โ , "prelude"
155โ , "strings"
156โ , "tailrec"
157โ ]
158โ "https://github.com/justinwoo/purescript-string-parsers.git"
159โ "no-code-points"
160โ }
161โ```
162โ
163โ## How to contribute to this package set
164โ
165โ### Requirements
166โ
167โThis project requires that you have at least:
168โ
169โ* [Dhall](https://github.com/dhall-lang/dhall-haskell) installed.
170โ* [Psc-Package](https://github.com/purescript/psc-package/) installed, with the release binary in your PATH in some way.
171โ* [jq](https://github.com/stedolan/jq) installed.
172โ
173โ### How to generate the package set after editing Dhall files
174โ
175โFirst, test that you can actually run `make`:
176โ
177โ```sh
178โ> make
179โformatted dhall files
180โgenerated to packages.json
181โ```
182โ
183โThis is how you format Dhall files in the project and generate the `packages.json` that needs to be checked in. Unless you plan to consume only the `packages.dhall` file in your repository, you must check in `packages.json`.
184โ
185โTo actually use your new package set, you must create a new git tag and push it to your **fork of package-sets**. Then set your package set in your **project** repository accordingly, per EXAMPLE:
186โ
187โ```js
188โ{
189โ "name": "EXAMPLE",
190โ "set": "160618", // GIT TAG NAME
191โ "source": "https://github.com/purescript/package-sets.git", // PACKAGE SET REPO URL
192โ "depends": [
193โ "console",
194โ "prelude"
195โ ]
196โ}
79+.psc-package/set-name/aff/v5.0.0
19780```
19881
199โWhen you set this up correctly, you will see that running `psc-package install` will create the file `.psc-package/{GIT TAG NAME HERE}/.set/packages.json`.
200โ
201โ### Testing changes to package set
202โ
203โTo set up a test project, run `make setup`. Then you can test individual packages with `psc-package verify PACKAGE`.
204โ
205โ### Package set maintenance
206โ
207โIf you would like to help maintain Package-Sets, please get in touch with Justin via Twitter: <https://twitter.com/jusrin00>
208โ
209โ## Spago
82+## How do I use `package-sets` with `spago`?
21083
211โ### Intro
84+[`spago`][spago] is a package manager and build tool for PureScript. It is very similar to `psc-package`, and the main differences are:
85+- it uses Dhall for its configuration (instead of `json` as `psc-package` does)
86+- it supports package overrides and additions directly in the project configuration
87+- it supports local dependencies (think `bower link`)
21288
213โSpago is a new CLI that can replace your usage of Psc-Package, using Dhall to configure your packages and your project.
89+With `spago` the package-set address is specified in the `upstream` variable of your local `packages.dhall`, which will usually import a remote `packages.dhall`, e.g. the one from this repo.
21490
215โSee the Spago repo for more: <https://github.com/spacchetti/spago>
91+You can change the package-set version you are using by just pointing the `upstream` to a different location, and running `spago freeze` afterwards (see [its readme][spago] for more info about this)
21692
217โ### Does Spago replace Psc-Package?
21893
219โYes and no. See the Spago project for the full details on what it is and how it is the similar and different from Psc-Package: <https://github.com/spacchetti/spago>
94+[spago]: https://github.com/spacchetti/spago
95+[psc-package]: https://github.com/purescript/psc-package
96+[issues]: https://github.com/purescript/package-sets/issues
97+[packages-json]: https://github.com/purescript/package-sets/blob/master/packages.json