Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"parserOptions": {
"ecmaVersion": 5
},
"extends": "eslint:recommended",
"env": {
"commonjs": true
},
"rules": {
"strict": [2, "global"],
"block-scoped-var": 2,
"consistent-return": 2,
"eqeqeq": [2, "smart"],
"guard-for-in": 2,
"no-caller": 2,
"no-extend-native": 2,
"no-loop-func": 2,
"no-new": 2,
"no-param-reassign": 2,
"no-return-assign": 2,
"no-unused-expressions": 2,
"no-use-before-define": 2,
"radix": [2, "always"],
"indent": [2, 2],
"quotes": [2, "double"],
"semi": [2, "always"]
}
}
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: purescript-contrib/setup-purescript@main
with:
purescript: "0.14.0-rc3"

- uses: actions/setup-node@v1
with:
node-version: "12"

- name: Install dependencies
run: |
npm install -g bower
npm install
bower install --production

- name: Build source
run: npm run-script build

- name: Run tests
run: |
bower install
npm run-script test --if-present
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/.*
!/.gitignore
!/.jscsrc
!/.jshintrc
!/.travis.yml
!/.eslintrc.json
!/.github/
/bower_components/
/node_modules/
/output/
Expand Down
17 changes: 0 additions & 17 deletions .jscsrc

This file was deleted.

20 changes: 0 additions & 20 deletions .jshintrc

This file was deleted.

24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
# purescript-partial

[![Latest release](http://img.shields.io/bower/v/purescript-partial.svg)](https://github.com/purescript/purescript-partial/releases)
[![Build Status](https://travis-ci.org/purescript/purescript-partial.svg?branch=master)](https://travis-ci.org/purescript/purescript-partial)
[![Latest release](http://img.shields.io/github/release/purescript/purescript-partial.svg)](https://github.com/purescript/purescript-partial/releases)
[![Build status](https://github.com/purescript/purescript-partial/workflows/CI/badge.svg?branch=master)](https://github.com/purescript/purescript-partial/actions?query=workflow%3ACI+branch%3Amaster)
[![Pursuit](https://pursuit.purescript.org/packages/purescript-partial/badge)](https://pursuit.purescript.org/packages/purescript-partial)

Utilities for working with partial functions.

## Installation

```
bower install purescript-partial
spago install partial
```

## Why have a Partial type class?

Every now and then, you will want to use *partial functions;* that is,
Every now and then, you will want to use _partial functions;_ that is,
functions which don't handle every possible case of their inputs. For example,
there is a function `fromJust :: ∀ a. Partial ⇒ Maybe a → a` in `Data.Maybe`,
which gives you the value inside a `Just` value, or throws an error if given
`Nothing`.

It's important that types tell the truth wherever possible, because this is a
large part of what allows us to understand PureScript code easily and refactor
it fearlessly. However, in certain contexts, you know that e.g. an `Either`
it fearlessly. However, in certain contexts, you know that e.g. an `Either`
value is always going to be `Right`, but you can't prove that to the type
checker, and so you want an escape hatch so that you can write a function that
doesn't have to deal with the `Left` case. This is often the case when
Expand Down Expand Up @@ -69,7 +70,7 @@ at src/Main.purs line 8, column 1 - line 8, column 56
Prim.Partial
```

*Aside: Yes, this is not a fantastic error. It's going to get better soon.*
_Aside: Yes, this is not a fantastic error. It's going to get better soon._

The solution is usually to add an application of `unsafePartial` somewhere,
like this:
Expand Down Expand Up @@ -172,7 +173,7 @@ Both implementations will behave in the same way.
In this case, we know our `dot` implementation is fine, and so users of it
should not have to worry about its partiality, so it makes sense to avoid
propagating the constraint. Now, we will see another case where a `Partial`
constraint *should* be propagated.
constraint _should_ be propagated.

Let us suppose we want a `foldr1` function, which works in a very similar way
to `foldr` on Lists, except that it doesn't require an initial value to be
Expand Down Expand Up @@ -221,4 +222,4 @@ the type system do hold.

## API Documentation

* API documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-partial).
- API documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-partial).
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
"private": true,
"scripts": {
"clean": "rimraf output && rimraf .pulp-cache",
"build": "jshint src && jscs src && pulp build -- --censor-lib --strict",
"build": "eslint src && pulp build -- --censor-lib --strict",
"test": "pulp test"
},
"devDependencies": {
"jscs": "^3.0.7",
"jshint": "^2.9.5",
"eslint": "^7.15.0",
"pulp": "^15.0.0",
"purescript-psa": "^0.6.0",
"rimraf": "^2.6.2"
"purescript-psa": "^0.8.0",
"rimraf": "^3.0.2"
}
}