Skip to content

Commit 6830dde

Browse files
committed
Merge pull request #2 from purescript/0.8-updates
Updates for PureScript 0.8
2 parents f41e713 + 2de0414 commit 6830dde

File tree

10 files changed

+73
-110
lines changed

10 files changed

+73
-110
lines changed

.jscsrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"preset": "grunt",
3+
"disallowSpacesInFunctionExpression": null,
4+
"requireSpacesInFunctionExpression": {
5+
"beforeOpeningRoundBrace": true,
6+
"beforeOpeningCurlyBrace": true
7+
},
38
"disallowSpacesInAnonymousFunctionExpression": null,
49
"requireSpacesInAnonymousFunctionExpression": {
510
"beforeOpeningRoundBrace": true,

.jshintrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"freeze": true,
66
"funcscope": true,
77
"futurehostile": true,
8-
"globalstrict": true,
8+
"strict": "global",
99
"latedef": true,
1010
"maxparams": 1,
1111
"noarg": true,
@@ -15,5 +15,6 @@
1515
"singleGroups": true,
1616
"undef": true,
1717
"unused": true,
18-
"eqnull": true
18+
"eqnull": true,
19+
"predef": ["exports"]
1920
}

.travis.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
language: node_js
2-
sudo: false
3-
node_js:
4-
- 0.10
2+
sudo: required
3+
dist: trusty
4+
node_js: 5
55
env:
66
- PATH=$HOME/purescript:$PATH
77
install:
88
- TAG=$(wget -q -O - https://github.com/purescript/purescript/releases/latest --server-response --max-redirect 0 2>&1 | sed -n -e 's/.*Location:.*tag\///p')
99
- wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
1010
- tar -xvf $HOME/purescript.tar.gz -C $HOME/
1111
- chmod a+x $HOME/purescript
12+
- npm install -g bower
1213
- npm install
14+
- bower install
1315
script:
14-
- npm run build
16+
- npm test
17+
after_success:
18+
- >-
19+
test $TRAVIS_TAG &&
20+
psc-publish > .pursuit.json &&
21+
curl -X POST http://pursuit.purescript.org/packages \
22+
-d @.pursuit.json \
23+
-H 'Accept: application/json' \
24+
-H "Authorization: token ${GITHUB_TOKEN}"

README.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,34 @@
44
[![Build Status](https://travis-ci.org/purescript/purescript-exists.svg?branch=master)](https://travis-ci.org/purescript/purescript-exists)
55
[![Dependency Status](https://www.versioneye.com/user/projects/55848c7c363861001d000339/badge.svg?style=flat)](https://www.versioneye.com/user/projects/55848c7c363861001d000339)
66

7-
Existential types as a library.
7+
The `Exists` type, for encoding existential types.
88

99
## Installation
1010

1111
```
1212
bower install purescript-exists
1313
```
1414

15-
## Module documentation
15+
## Overview
1616

17-
- [Data.Exists](docs/Data/Exists.md)
17+
The type `Exists f` is isomorphic to the existential type `exists a. f a`.
18+
19+
For example, consider the type `exists s. Tuple s (s -> Tuple s a)` which represents infinite streams of elements of type `a`.
20+
21+
This type can be constructed by creating a type constructor `StreamF` as follows:
22+
23+
```purescript
24+
data StreamF a s = StreamF s (s -> Tuple s a)
25+
```
26+
27+
We can then define the type of streams using `Exists`:
28+
29+
```purescript
30+
type Stream a = Exists (StreamF a)
31+
```
32+
33+
The `mkExists` and `runExists` functions then enable packing and unpacking of `SteamF` into/out of `Stream`.
34+
35+
## Documentation
36+
37+
Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-exists).

bower.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "purescript-exists",
3+
"homepage": "https://github.com/purescript/purescript-exists",
34
"description": "Existential types as a library",
4-
"keywords": ["purescript"],
55
"license": "MIT",
66
"repository": {
77
"type": "git",
@@ -16,7 +16,10 @@
1616
"bower.json",
1717
"package.json"
1818
],
19+
"dependencies": {
20+
"purescript-unsafe-coerce": "^1.0.0-rc.1"
21+
},
1922
"devDependencies": {
20-
"purescript-console": "^0.1.0"
23+
"purescript-console": "^1.0.0-rc.1"
2124
}
2225
}

docs/Data/Exists.md

Lines changed: 0 additions & 68 deletions
This file was deleted.

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"private": true,
33
"scripts": {
4-
"postinstall": "pulp dep install",
5-
"build": "jshint src && jscs src && pulp test && rimraf docs && pulp docs"
4+
"clean": "rimraf output && rimraf .pulp-cache",
5+
"build": "jshint src && jscs src && pulp build",
6+
"test": "jshint src && jscs src && pulp test"
67
},
78
"devDependencies": {
8-
"jscs": "^1.13.1",
9-
"jshint": "^2.8.0",
10-
"pulp": "^4.0.2",
11-
"rimraf": "^2.4.1"
9+
"jscs": "^2.8.0",
10+
"jshint": "^2.9.1",
11+
"pulp": "^8.1.0",
12+
"rimraf": "^2.5.0"
1213
}
1314
}

src/Data/Exists.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/Data/Exists.purs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Data.Exists where
22

3-
import Prelude
3+
import Unsafe.Coerce (unsafeCoerce)
44

55
-- | This type constructor can be used to existentially quantify over a type of kind `*`.
66
-- |
@@ -16,7 +16,7 @@ import Prelude
1616
-- | This type can be constructed by creating a type constructor `StreamF` as follows:
1717
-- |
1818
-- | ```purescript
19-
-- | data StreamF a s = StreamF s (s -> Tuple s a)
19+
-- | data StreamF a s = StreamF s (s -> Tuple s a)
2020
-- | ```
2121
-- |
2222
-- | We can then define the type of streams using `Exists`:
@@ -35,19 +35,21 @@ foreign import data Exists :: (* -> *) -> *
3535
-- | nats :: Stream Number
3636
-- | nats = mkExists $ StreamF 0 (\n -> Tuple (n + 1) n)
3737
-- | ```
38-
foreign import mkExists :: forall f a. f a -> Exists f
39-
38+
mkExists :: forall f a. f a -> Exists f
39+
mkExists = unsafeCoerce
40+
4041
-- | The `runExists` function is used to eliminate a value of type `Exists f`. The rank 2 type ensures
4142
-- | that the existentially-quantified type does not escape its scope. Since the function is required
4243
-- | to work for _any_ type `a`, it will work for the existentially-quantified type.
43-
-- |
44+
-- |
4445
-- | For example, we can write a function to obtain the head of a stream by using `runExists` as follows:
45-
-- |
46+
-- |
4647
-- | ```purescript
4748
-- | head :: forall a. Stream a -> a
4849
-- | head = runExists head'
4950
-- | where
5051
-- | head' :: forall s. StreamF a s -> a
51-
-- | head' (StreamF s f) = snd (f s)
52+
-- | head' (StreamF s f) = snd (f s)
5253
-- | ```
53-
foreign import runExists :: forall f r. (forall a. f a -> r) -> Exists f -> r
54+
runExists :: forall f r. (forall a. f a -> r) -> Exists f -> r
55+
runExists = unsafeCoerce

test/Test/Main.purs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ module Test.Main where
22

33
import Prelude
44

5-
import Control.Monad.Eff.Console
6-
import Data.Exists
5+
import Control.Monad.Eff (Eff)
6+
import Control.Monad.Eff.Console (CONSOLE, logShow)
7+
8+
import Data.Exists (Exists, mkExists, runExists)
79

810
data Tuple a b = Tuple a b
911

@@ -23,4 +25,5 @@ head = runExists head'
2325
head' :: forall s. StreamF a s -> a
2426
head' (StreamF s f) = snd (f s)
2527

26-
main = print $ head nats
28+
main :: Eff (console :: CONSOLE) Unit
29+
main = logShow $ head nats

0 commit comments

Comments
 (0)