Skip to content

Commit 8441644

Browse files
committed
first commit
0 parents  commit 8441644

File tree

9 files changed

+158
-0
lines changed

9 files changed

+158
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.*
2+
!/.gitignore
3+
/output/
4+
/node_modules/
5+
/bower_components/
6+
/tmp/

Gruntfile.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
module.exports = function(grunt) {
2+
3+
"use strict";
4+
5+
grunt.initConfig({
6+
7+
libFiles: [
8+
"src/**/*.purs",
9+
"bower_components/purescript-*/src/**/*.purs"
10+
],
11+
12+
clean: ["tmp", "output"],
13+
14+
pscMake: {
15+
lib: {
16+
src: ["<%=libFiles%>"]
17+
},
18+
tests: {
19+
src: ["tests/Tests.purs", "<%=libFiles%>"]
20+
}
21+
},
22+
23+
dotPsci: ["<%=libFiles%>"],
24+
25+
copy: [
26+
{
27+
expand: true,
28+
cwd: "output",
29+
src: ["**"],
30+
dest: "tmp/node_modules/"
31+
}, {
32+
src: ["js/index.js"],
33+
dest: "tmp/index.js"
34+
}
35+
],
36+
37+
execute: {
38+
tests: {
39+
src: "tmp/index.js"
40+
}
41+
}
42+
});
43+
44+
grunt.loadNpmTasks("grunt-contrib-copy");
45+
grunt.loadNpmTasks("grunt-contrib-clean");
46+
grunt.loadNpmTasks("grunt-execute")
47+
grunt.loadNpmTasks("grunt-purescript");
48+
49+
grunt.registerTask("test", ["pscMake:tests", "copy", "execute:tests"]);
50+
grunt.registerTask("make", ["pscMake:lib", "dotPsci"]);
51+
grunt.registerTask("default", ["clean", "make", "test"]);
52+
};

LICENSE-MIT

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

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# purescript-exists
2+
3+
Existential types as a library
4+
5+
## Building
6+
7+
```
8+
npm install
9+
bower update
10+
grunt
11+
```

bower.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "purescript-exists",
3+
"description": "Existential types as a library",
4+
"keywords": ["purescript"],
5+
"ignore": [
6+
"**/.*",
7+
"bower_components",
8+
"node_modules",
9+
"output",
10+
"tests",
11+
"output",
12+
"js",
13+
"tmp",
14+
"bower.json",
15+
"Gruntfile.js",
16+
"package.json"
17+
],
18+
"dependencies": {
19+
},
20+
"devDependencies": {
21+
}
22+
}

js/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require("Main").main();

package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "purescript-exists",
3+
"version": "0.1.0",
4+
"description": "Existential types as a library",
5+
"main": "",
6+
"private": true,
7+
"author": "Phil Freeman",
8+
"license": "MIT",
9+
"dependencies": {
10+
"grunt": "~0.4.4",
11+
"grunt-contrib-copy": "~0.5.0",
12+
"grunt-contrib-clean": "~0.5.0",
13+
"grunt-execute": "~0.1.5",
14+
"grunt-purescript": "~0.5.0"
15+
}
16+
}

src/Data/Exists.purs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module Data.Exists where
2+
3+
foreign import data Exists :: (* -> *) -> *
4+
5+
foreign import mkExists
6+
"function mkExists(fa) {\
7+
\ return fa;\
8+
\}" :: forall f a. f a -> Exists f
9+
10+
foreign import runExists
11+
"function runExists(f) {\
12+
\ return function(fa) {\
13+
\ return f(fa);\
14+
\ };\
15+
\}" :: forall f r. (forall a. f a -> r) -> Exists f -> r

tests/Tests.purs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module Main where
2+
3+
import Debug.Trace
4+
import Data.Exists
5+
6+
data Example a = Example a (a -> String)
7+
8+
runExample :: Exists Example -> String
9+
runExample = runExists (\(Example a f) -> f a)
10+
11+
test = runExample (mkExists (Example "Done" show))
12+
13+
main = trace test

0 commit comments

Comments
 (0)