Skip to content

Commit 431ac5b

Browse files
authored
Simplify (#10)
Simplification of representation
1 parent 015d400 commit 431ac5b

11 files changed

+444
-299
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.psci
33
.psci_modules
44
.pulp-cache/
5+
.psc-ide-port
56
npm-debug.log
67
node_modules/
78
bower_components/

Diff for: LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2016 Eric Thul
1+
Copyright (c) 2016-2017 Eric Thul
22

33
Permission is hereby granted, free of charge, to any person obtaining a
44
copy of this software and associated documentation files (the

Diff for: bower.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@
1616
"!src/**/*"
1717
],
1818
"dependencies": {
19-
"purescript-profunctor-lenses": "^3.2.0",
20-
"purescript-react": "^3.0.0"
19+
"purescript-react": "^3.0.0",
20+
"purescript-record": "athanclark/purescript-record#850360dbfa1bf765a19b3ec207a706622fa47ac7",
21+
"purescript-monoid": "^3.1.0",
22+
"purescript-strings": "^3.3.1",
23+
"purescript-nullable": "^3.0.0"
24+
},
25+
"resolutions": {
26+
"purescript-record": "850360dbfa1bf765a19b3ec207a706622fa47ac7"
2127
}
2228
}

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"pscid": "PATH=$PURESCRIPT_0_11_PATH:$PATH pscid"
99
},
1010
"devDependencies": {
11-
"pscid": "^1.12.1"
11+
"pscid": "^2.0.2"
1212
}
1313
}

Diff for: src/React/Redux.js

+8-128
Original file line numberDiff line numberDiff line change
@@ -4,138 +4,18 @@ var Redux = require('redux');
44

55
var ReactRedux = require('react-redux');
66

7-
function startsWithActionType(actionForeign) {
8-
var index = actionForeign.type.indexOf('@@PURESCRIPT_REACT_REDUX');
9-
10-
return index === 0;
11-
}
12-
13-
function makeActionForeign(action) {
14-
var constructorName = action.constructor && action.constructor.name ? action.constructor.name : 'UnknownConstructorName';
15-
16-
var actionForeign = {
17-
type: '@@PURESCRIPT_REACT_REDUX/' + constructorName,
18-
action: action
19-
};
20-
21-
return actionForeign;
22-
}
23-
24-
exports.createStore_ = function createStore_(reducer, state, enhancer){
25-
return function(){
26-
function reducerForeign(stateReducerForeign, actionForeign){
27-
var result = startsWithActionType(actionForeign) ? reducer(actionForeign.action)(stateReducerForeign) : stateReducerForeign;
28-
29-
return result;
30-
}
31-
32-
function enhancerForeign(createStoreForeign){
33-
return function(reducerEnhancerForeign, stateEnhancerForeign){
34-
function createStore(reducerCreateStore){
35-
return function(stateCreateStore){
36-
return function(){
37-
var result = createStoreForeign(reducerCreateStore, stateCreateStore);
38-
39-
return result;
40-
};
41-
};
42-
}
43-
44-
return enhancer(createStore)(reducerEnhancerForeign)(stateEnhancerForeign)();
45-
};
46-
}
47-
48-
return Redux.createStore(reducerForeign, state, enhancerForeign);
49-
};
7+
exports.reduxCreateStore = function reduxCreateStore(reducer, state, enhancer){
8+
return Redux.createStore(reducer, state, enhancer);
509
};
5110

52-
exports.connect_ = function connect_(Tuple, mapStateToProps, reactClass){
53-
function mapStateToPropsForeign(state, props) {
54-
var statePropsTuple = Tuple(state)(props);
55-
56-
var result = mapStateToProps(statePropsTuple);
57-
58-
return result;
59-
}
60-
61-
return ReactRedux.connect(mapStateToPropsForeign)(reactClass);
11+
exports.reduxApplyMiddleware = function reduxApplyMiddleware(middleware){
12+
return Redux.applyMiddleware.apply(Redux, middleware);
6213
};
6314

64-
exports.dispatch_ = function dispatch_(thisForeign, action){
65-
return function(){
66-
var actionForeign = makeActionForeign(action);
67-
68-
var actionForeignResult = thisForeign.props.dispatch(actionForeign);
69-
70-
return actionForeignResult.action;
71-
};
15+
exports.reduxConnect = function reduxConnect(mapStateToProps, mapDispatchToProps, mergeProps, options){
16+
return ReactRedux.connect(mapStateToProps, mapDispatchToProps, mergeProps, options);
7217
};
7318

74-
exports.applyMiddleware = function applyMiddleware(middlewares){
75-
var middlewaresForeign = middlewares.map(function(middleware){
76-
return function(middlewareAPIForeign){
77-
function getState(){
78-
return middlewareAPIForeign.getState();
79-
}
80-
81-
function dispatch(action){
82-
return function(){
83-
var actionForeignResult = makeActionForeign(action);
84-
85-
var result = middlewareAPIForeign.dispatch(actionForeignResult);
86-
87-
return result;
88-
};
89-
}
90-
91-
var cont = middleware({ getState: getState, dispatch: dispatch })
92-
93-
return function(nextForeign){
94-
return function(actionForeign){
95-
96-
function next(action){
97-
return function(){
98-
var actionForeignResult = makeActionForeign(action);
99-
100-
var result = nextForeign(actionForeignResult);
101-
102-
return result;
103-
};
104-
}
105-
106-
var action = actionForeign.action;
107-
108-
var result = cont(next)(action)();
109-
110-
return result;
111-
};
112-
};
113-
}
114-
});
115-
116-
var middlewareEnhancerForeign = Redux.applyMiddleware.apply(Redux, middlewaresForeign);
117-
118-
var result = exports.fromEnhancerForeign(middlewareEnhancerForeign);
119-
120-
return result;
121-
};
122-
123-
exports.fromEnhancerForeign = function fromEnhancerForeign(enhancerForeign){
124-
return function(createStore){
125-
return function(reducerForeign){
126-
return function(stateForeign){
127-
return function(){
128-
function createStoreForeign(reducer, state){
129-
var result = createStore(reducer)(state)();
130-
131-
return result;
132-
};
133-
134-
return enhancerForeign(createStoreForeign)(reducerForeign, stateForeign);
135-
};
136-
};
137-
};
138-
};
139-
}
19+
exports.reduxConnect_ = exports.reduxConnect;
14020

141-
exports.providerClass = ReactRedux.Provider;
21+
exports.reduxProviderClass = ReactRedux.Provider;

0 commit comments

Comments
 (0)