récuperer le react transform boilerplate. => workflow hot swaping trop cool ;)
git clone https://github.com/gvergnaud/prez-react.git TutoReact
npm install
npm start
| /* --------------------------------------------------------------------------- * | |
| Utilities for managing lists, implemented using only recursion | |
| * --------------------------------------------------------------------------- */ | |
| const head = ([x]) => x | |
| const tail = ([x, ...rest]) => rest | |
| const last = xs => xs[xs.length - 1] |
| /* ----------------------------------------- * | |
| Learning Machin Learning | |
| * ----------------------------------------- */ | |
| // gradientDescent for the square error function and a Theta of Two parameter (a, b) | |
| // Theta :: [Number, Number] | |
| // sum :: (a -> Int) -> List a -> Int | |
| const sum = (transformer, list) => | |
| list.reduce((acc, item) => acc + transformer(item), 0) |
| /* ----------------------------------------- * | |
| Learning Machin Learning | |
| * ----------------------------------------- */ | |
| import { compose, map, chain, range } from 'ramda' | |
| // Result = { a :: Int, b :: Int, cost :: Number } | |
| // Data = [Int, Int] | |
| // Tupple = [Int, Int] | |
| // findBestResult :: [Result] -> Result |
| export type Option<T> = | |
| | { readonly type: 'some'; readonly value: T } | |
| | { readonly type: 'none' }; | |
| export const none: Option<never> = { type: 'none' }; | |
| export const some = <T>(value: T): Option<T> => ({ type: 'some', value }); | |
| const compose = |
| const stateIdLens = propLens('id') | |
| const stateTokenLens = propLens('token') | |
| let setCurrentUserId = (state, action) => set(idLens, action.payload.result, state) | |
| let setCurrentUserToken = (state, action) => set(tokenLens, action.payload.token, state) | |
| compose(setCurrentUserId, setCurrentUserToken) | |
| export default class Identity { | |
| constructor(v) { | |
| this.value = v | |
| } | |
| static of(v) { | |
| return new Identity(v) | |
| } |
| export default class Const { | |
| constructor(v) { | |
| this.value = v | |
| } | |
| static of(v) { | |
| return new Const(v) | |
| } |
| import { compose, curry, map } from 'ramda' | |
| import Const, { getConst } from './functors/Const' | |
| import Identity, { runIdentity } from './functors/Identity' | |
| import K from './functors/K' | |
| /* ----------------------------------------- * | |
| Lenses définition | |
| * ----------------------------------------- */ |