Skip to content

Commit 313f6a5

Browse files
committed
Initial commit, extracted from transformers
0 parents  commit 313f6a5

File tree

7 files changed

+179
-0
lines changed

7 files changed

+179
-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+
/bower_components/
4+
/node_modules/
5+
/output/
6+
/tmp/

Gruntfile.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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: ["output"],
13+
14+
pscMake: ["<%=libFiles%>"],
15+
dotPsci: ["<%=libFiles%>"],
16+
docgen: {
17+
readme: {
18+
src: "src/**/*.purs",
19+
dest: "README.md"
20+
}
21+
}
22+
23+
});
24+
25+
grunt.loadNpmTasks("grunt-contrib-clean");
26+
grunt.loadNpmTasks("grunt-purescript");
27+
28+
grunt.registerTask("make", ["pscMake", "dotPsci", "docgen"]);
29+
grunt.registerTask("default", ["make"]);
30+
};

LICENSE

Lines changed: 20 additions & 0 deletions
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.

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Module Documentation
2+
3+
## Module Data.Identity
4+
5+
### Types
6+
7+
newtype Identity a where
8+
Identity :: a -> Identity a
9+
10+
11+
### Type Class Instances
12+
13+
instance applicativeIdentity :: Applicative Identity
14+
15+
instance applyIdentity :: Apply Identity
16+
17+
instance bindIdentity :: Bind Identity
18+
19+
instance comonadIdentity :: Comonad Identity
20+
21+
instance eqIdentity :: (Eq a) => Eq (Identity a)
22+
23+
instance extendIdentity :: Extend Identity
24+
25+
instance foldableIdentity :: Foldable Identity
26+
27+
instance functorIdentity :: Functor Identity
28+
29+
instance monadIdentity :: Monad Identity
30+
31+
instance ordIdentity :: (Ord a) => Ord (Identity a)
32+
33+
instance showConst :: (Show a) => Show (Identity a)
34+
35+
instance traversableIdentity :: Traversable Identity
36+
37+
38+
### Values
39+
40+
runIdentity :: forall a. Identity a -> a

bower.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "purescript-identity",
3+
"homepage": "https://github.com/purescript/purescript-identity",
4+
"description": "Identity value/functor",
5+
"keywords": [
6+
"purescript"
7+
],
8+
"authors": [
9+
"Gary Burgess <[email protected]>",
10+
"Hardy Jones <[email protected]>"
11+
],
12+
"license": "MIT",
13+
"ignore": [
14+
"**/.*",
15+
"bower_components",
16+
"node_modules",
17+
"output",
18+
"bower.json",
19+
"Gruntfile.js",
20+
"package.json"
21+
],
22+
"dependencies": {
23+
"purescript-foldable-traversable": "~0.1.4"
24+
}
25+
}

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"private": true,
3+
"devDependencies": {
4+
"grunt": "~0.4.5",
5+
"grunt-purescript": "~0.5.2",
6+
"grunt-contrib-clean": "~0.5.0"
7+
}
8+
}

src/Data/Identity.purs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module Data.Identity where
2+
3+
import Control.Comonad (Comonad, extract)
4+
import Control.Extend (Extend, (<<=))
5+
import Data.Foldable (Foldable, foldr, foldl, foldMap)
6+
import Data.Traversable (Traversable, traverse, sequence)
7+
8+
newtype Identity a = Identity a
9+
10+
runIdentity :: forall a. Identity a -> a
11+
runIdentity (Identity x) = x
12+
13+
instance eqIdentity :: (Eq a) => Eq (Identity a) where
14+
(==) (Identity x) (Identity y) = x == y
15+
(/=) x y = not (x == y)
16+
17+
instance ordIdentity :: (Ord a) => Ord (Identity a) where
18+
compare (Identity x) (Identity y) = compare x y
19+
20+
instance showConst :: (Show a) => Show (Identity a) where
21+
show (Identity x) = "Identity (" ++ show x ++ ")"
22+
23+
instance functorIdentity :: Functor Identity where
24+
(<$>) f (Identity x) = Identity (f x)
25+
26+
instance applyIdentity :: Apply Identity where
27+
(<*>) (Identity f) (Identity x) = Identity (f x)
28+
29+
instance applicativeIdentity :: Applicative Identity where
30+
pure = Identity
31+
32+
instance bindIdentity :: Bind Identity where
33+
(>>=) m f = f (runIdentity m)
34+
35+
instance monadIdentity :: Monad Identity
36+
37+
instance extendIdentity :: Extend Identity where
38+
(<<=) f m = Identity (f m)
39+
40+
instance comonadIdentity :: Comonad Identity where
41+
extract (Identity x) = x
42+
43+
instance foldableIdentity :: Foldable Identity where
44+
foldr f z (Identity x) = f x z
45+
foldl f z (Identity x) = f z x
46+
foldMap f (Identity x) = f x
47+
48+
instance traversableIdentity :: Traversable Identity where
49+
traverse f (Identity x) = Identity <$> f x
50+
sequence (Identity x) = Identity <$> x

0 commit comments

Comments
 (0)