Here is my experience of 5h with reasonml. It is only my developer experience, and I focused on the things that can be improved.
- didn't hit any bugs
- type inference is really pleasurable
- merlin worked great in vscode
- awesome discord community
SELECT | |
tc.constraint_name, tc.table_name, tc.constraint_name, kcu.column_name, | |
ccu.table_name AS foreign_table_name, | |
ccu.column_name AS foreign_column_name | |
FROM | |
information_schema.table_constraints AS tc | |
JOIN information_schema.key_column_usage AS kcu | |
ON tc.constraint_name = kcu.constraint_name | |
JOIN information_schema.constraint_column_usage AS ccu | |
ON ccu.constraint_name = tc.constraint_name |
var fs = require('fs'); | |
var queue = require('queue'); | |
var wget = require('wget-improved'); | |
var downloadUrl = function(url) { | |
return function(cb) { | |
try { | |
// you can also change the mapping url to file here by changing the function | |
var download = wget.download(url, () => ('./downloads/' + url.substring(url.lastIndexOf('/') + 1) ) , {}); | |
download.on('end', function() { |
/** | |
* FAST PACKING / UNPACKING JSON | |
* | |
* If all objects in a collection follows a similar schema, | |
* then there is gain in changing the representation from a dictionary to a simple array. | |
* | |
* It is known results used in database, protocols, in v8 itself with shadow maps and IRL. | |
* | |
* In this example, we expect our final exchange to be equivalent to this literal representation: | |
* [ |
Here is my experience of 5h with reasonml. It is only my developer experience, and I focused on the things that can be improved.
const store = createStore( | |
reducer, | |
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() | |
); |
const ADD = 'my-app/users/ADD'; | |
export default function reducer(state = {}, action = {}) { | |
switch (action.type) { | |
ADD: return {...state, [action.payload.id]: action.payload} | |
default: return state; | |
} | |
} | |
// Action Creators |
import reducer, { * as actionCreators } from './users' | |
describe('actions', () => { | |
it('adds a user', () => { | |
const user = {id:1, name:'Bat'} | |
const action = actionCreators.addUser(user) | |
expect(action).toEqual({type:'my-app/users/ADD', payload:user }) | |
expect(reducer(undefined, action)).toMatchSnapshot('adds a user') | |
}) |
// 1 - instead of | |
const action = {type: 'my-app/users/ADD', {id: 1, name:'Bat'}} | |
/* we can */ | |
// 2 - we define an action creator in the users file | |
export const addUser = payload => ({type: 'my-app/users/ADD', payload}) | |
// we can get the action in another file when we need it | |
import {addUser} from '../redux/users' | |
const action = addUser({id: 1, name:'Bat'}) |
// 1 - instead of | |
const mapDispatchToProps = dispatch => { | |
return { | |
addUser: payload => dispatch({type:'my-app/users/ADD',payload}) | |
} | |
} | |
const connect(null, mapDispatchToProps)(MyComponent) | |
// 2 - with action creators | |
import {addUser} from './redux/users' |
// 1 - instead of | |
const state = { | |
users: [ | |
{ id: 1, name: "Bat", groups: [{ name: "admin" }, { name: "regular" }] }, | |
{ id: 2, name: "Vince", groups: { name: "admin" } }, | |
{ id: 1, name: "Romain", groups: { name: "normal" } } | |
] | |
}; | |
// 2- Normalize and index by primary key |