Skip to content
This repository was archived by the owner on Nov 26, 2020. It is now read-only.

Commit 087bd42

Browse files
committed
Update build
1 parent 80622be commit 087bd42

File tree

8 files changed

+129
-111
lines changed

8 files changed

+129
-111
lines changed

Diff for: .gitignore

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/.*
22
!/.gitignore
33
!/.travis.yml
4-
/output/
5-
/node_modules/
64
/bower_components/
7-
/tmp/
5+
/node_modules/
6+
/output/

Diff for: .travis.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: node_js
2+
sudo: false
3+
node_js:
4+
- 0.10
5+
env:
6+
- PATH=$HOME/purescript:$PATH
7+
install:
8+
- 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')
9+
- wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
10+
- tar -xvf $HOME/purescript.tar.gz -C $HOME/
11+
- chmod a+x $HOME/purescript
12+
- npm install
13+
script:
14+
- npm run build

Diff for: LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 PureScript
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Diff for: README.md

+8-75
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,16 @@
1-
# Module Documentation
1+
# purescript-proxy
22

3-
## Module Type.Proxy
3+
[![Latest release](http://img.shields.io/bower/v/purescript-proxy.svg)](https://github.com/purescript/purescript-proxy/releases)
4+
[![Build Status](https://travis-ci.org/purescript/purescript-proxy.svg?branch=master)](https://travis-ci.org/purescript/purescript-proxy)
45

6+
Value proxy for type inputs.
57

6-
The `Proxy` type and values are for situations where type information is
7-
required for an input to determine the type of an output, but where it is
8-
not possible or convenient to provide a _value_ for the input.
8+
## Installation
99

10-
A hypothetical example: if you have a class that is used to handle the
11-
result of an AJAX request, you may want to use this information to set the
12-
expected content type of the request, so you might have a class something
13-
like this:
14-
15-
``` purescript
16-
class AjaxResponse a where
17-
responseType :: a -> ResponseType
18-
fromResponse :: Foreign -> a
19-
```
20-
21-
The problem here is `responseType` requires a value of type `a`, but we
22-
won't have a value of that type until the request has been completed. The
23-
solution is to use a `Proxy` type instead:
24-
25-
``` purescript
26-
class AjaxResponse a where
27-
responseType :: Proxy a -> ResponseType
28-
fromResponse :: Foreign -> a
29-
```
30-
31-
We can now call `responseType (Proxy :: Proxy SomeContentType)` to produce
32-
a `ResponseType` for `SomeContentType` without having to construct some
33-
empty version of `SomeContentType` first. In situations like this where
34-
the `Proxy` type can be statically determined, it is recommended to pull
35-
out the definition to the top level and make a declaration like:
36-
37-
``` purescript
38-
_SomeContentType :: Proxy SomeContentType
39-
_SomeContentType = Proxy
4010
```
41-
42-
That way the proxy value can be used as `responseType _SomeContentType`
43-
for improved readability. However, this is not always possible, sometimes
44-
the type required will be determined by a type variable. As PureScript has
45-
scoped type variables, we can do things like this:
46-
47-
``` purescript
48-
makeRequest :: URL -> ResponseType -> Aff _ Foreign
49-
makeRequest = ...
50-
51-
fetchData :: forall a. (AjaxResponse a) => URL -> Aff _ a
52-
fetchData url = fromResponse <$> makeRequest url (responseType (Proxy :: Proxy a))
11+
bower install purescript-proxy
5312
```
5413

55-
#### `Proxy`
56-
57-
``` purescript
58-
data Proxy a
59-
= Proxy
60-
```
61-
62-
Value proxy for kind `*` types.
63-
64-
#### `Proxy2`
65-
66-
``` purescript
67-
data Proxy2 (a :: * -> *)
68-
= Proxy2
69-
```
70-
71-
Value proxy for kind `* -> *` types.
72-
73-
#### `Proxy3`
74-
75-
``` purescript
76-
data Proxy3 (a :: * -> * -> *)
77-
= Proxy3
78-
```
79-
80-
Value proxy for kind `* -> * -> *` types.
81-
82-
14+
## Module documentation
8315

16+
- [Type.Proxy](docs/Type/Proxy.md)

Diff for: bower.json

-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
"node_modules",
1313
"output",
1414
"test",
15-
"tmp",
1615
"bower.json",
17-
"gulpfile.js",
1816
"package.json"
1917
]
2018
}

Diff for: docs/Type/Proxy.md

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
## Module Type.Proxy
2+
3+
The `Proxy` type and values are for situations where type information is
4+
required for an input to determine the type of an output, but where it is
5+
not possible or convenient to provide a _value_ for the input.
6+
7+
A hypothetical example: if you have a class that is used to handle the
8+
result of an AJAX request, you may want to use this information to set the
9+
expected content type of the request, so you might have a class something
10+
like this:
11+
12+
``` purescript
13+
class AjaxResponse a where
14+
responseType :: a -> ResponseType
15+
fromResponse :: Foreign -> a
16+
```
17+
18+
The problem here is `responseType` requires a value of type `a`, but we
19+
won't have a value of that type until the request has been completed. The
20+
solution is to use a `Proxy` type instead:
21+
22+
``` purescript
23+
class AjaxResponse a where
24+
responseType :: Proxy a -> ResponseType
25+
fromResponse :: Foreign -> a
26+
```
27+
28+
We can now call `responseType (Proxy :: Proxy SomeContentType)` to produce
29+
a `ResponseType` for `SomeContentType` without having to construct some
30+
empty version of `SomeContentType` first. In situations like this where
31+
the `Proxy` type can be statically determined, it is recommended to pull
32+
out the definition to the top level and make a declaration like:
33+
34+
``` purescript
35+
_SomeContentType :: Proxy SomeContentType
36+
_SomeContentType = Proxy
37+
```
38+
39+
That way the proxy value can be used as `responseType _SomeContentType`
40+
for improved readability. However, this is not always possible, sometimes
41+
the type required will be determined by a type variable. As PureScript has
42+
scoped type variables, we can do things like this:
43+
44+
``` purescript
45+
makeRequest :: URL -> ResponseType -> Aff _ Foreign
46+
makeRequest = ...
47+
48+
fetchData :: forall a. (AjaxResponse a) => URL -> Aff _ a
49+
fetchData url = fromResponse <$> makeRequest url (responseType (Proxy :: Proxy a))
50+
```
51+
52+
#### `Proxy`
53+
54+
``` purescript
55+
data Proxy a
56+
= Proxy
57+
```
58+
59+
Value proxy for kind `*` types.
60+
61+
#### `Proxy2`
62+
63+
``` purescript
64+
data Proxy2 (a :: * -> *)
65+
= Proxy2
66+
```
67+
68+
Value proxy for kind `* -> *` types.
69+
70+
#### `Proxy3`
71+
72+
``` purescript
73+
data Proxy3 (a :: * -> * -> *)
74+
= Proxy3
75+
```
76+
77+
Value proxy for kind `* -> * -> *` types.
78+
79+

Diff for: gulpfile.js

-27
This file was deleted.

Diff for: package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{
22
"private": true,
3+
"scripts": {
4+
"postinstall": "pulp dep install",
5+
"build": "pulp build && rimraf docs && pulp docs"
6+
},
37
"devDependencies": {
4-
"gulp": "^3.8.11",
5-
"gulp-jsvalidate": "^1.0.1",
6-
"gulp-plumber": "^1.0.0",
7-
"gulp-purescript": "^0.3.1"
8+
"pulp": "^4.0.2",
9+
"rimraf": "^2.4.1"
810
}
911
}

0 commit comments

Comments
 (0)