@GrosSacASac Would Object.assign help?
It uses the getters and setters:
The Object.assign() method only copies enumerable and own properties from a source object to a target object. It uses [[Get]] on the source and [[Put]] on the target, so it will invoke getters and setters.
let scopeName,
variableName,
DVrScopeName,
commentsDataScopeName;
for (scopeName of Object.keys(commentsData)){
if (!D.vr[scopeName]) {
D.vr[scopeName] = {};
}
DVrScopeName = D.vr[scopeName];
commentsDataScopeName = commentsData[scopeName]
Object.assign(DVrScopeName, commentsDataScopeName);
/* same as
for (variableName of Object.keys(commentsData[scopeName])){
D.vr[scopeName][variableName] = commentsData[scopeName][variableName];
} */
}
Anyone happen to have a way to get from:
[
[1, 2],
[1, 2, 3],
[1]
]
to:
[
[1, 1, 1],
[2, 2],
[3]
]
R.transpose([[1,2], [1,2,3], [1]])
[ [ 1, 1, 1 ], [ 2, 2 ], [ 3 ] ]
async/await
should replace co
eventually
hindley milner type system and typeclasses
yes plz! :fire: :fire: :fire:
let objectUpdater = R.compose(R.map(serializeNullValue), updateEntityType)
//Does R.map map over the values of the object returned by updateEntityType?
//kReduce :: Chain m => (b, a -> m b) -> m b -> [a] -> m b
const kReduce = f => m => xs => xs.reduce((m, x) => m.chain(acc => f(acc, x)), m);
let arrayOfAttributeNames = [null, null, null, null];
let verifyIfAllNil = (acc, next) => {
return ((acc === true) && (next === null)) ? true : false;
}
R.reduce(verifyIfNil, true, arrayOfAttributeNames);
R.all(R.isNil) ( [null, null, null, null] )
true
const a = () => {}
const b = () => {}
const c = () => R.pipe(a, b)
I'd like to test c
but without calling the real a
and b
main
as it was the only "public" function
I tried this and it didn't work T_T
let a = [0, 1, 2, 3, 4, 5, 6, 7]
let b = [7, 6, 5, 4, 3, 2, 1, 0]
let transducer = R.compose(R.zipWith((x, y) => { return x * y; }, b), R.map(R.add(2)))
R.transduce(transducer, R.flip(R.append), [], a)
Getting....xf.@@transducer/step is not a function
zip
and family can act like transducers. Usually the documentation would state that explicitly.
dbConnection
but a function that will return the result of a database operation - the real code will carry out actual db interaction - the test code will just pass in a function that returns the result
main
would take getPatient
, assertPatient
and getLastDemandesEditables
as arguments. Then from your test you could just call main
with stubbed versions of those dependencies.
Don't do monads in JS, do monads in C++!!!!
http://bartoszmilewski.com/2011/07/11/monads-in-c/
This guy is honestly one of my favorite bloggers XD
I love that guy :)
Bringing functional programming concepts to a language people think only supports OOP. Seriously, thank God for std::function and closure types.
But I'm a little afraid of monads in JS without a type system
My too, @jgoux, which is why I use a (run-time) type system. ;)
Either String String
and will want to convert the Right to an integer.
R.chain(S.parseInt(10), e)
, forgetting that I'm in Either context rather than Maybe context.
Either#chain
will complain, though.
R.chain(S.parseInt(10), S.Right('42'))
R.chain(S.parseInt(10), S.Right('42'))
TypeError: ‘Either#chain’ is expected to return a value of type (Either a c); returned Just(42)
S.pipe([a(), F.chain(b), F.chain(c)])
chain
from fluture)
generate
, easily the nicest build script I've written to date.
def
?
pipe([at(2),
maybeToEither('Missing command-line argument'),
map(lift2(pair, I, I)),
map(over(lensIndex(0), version)),
map(over(lensIndex(1), readme)),
chain(ifElse(all(isRight),
pipe([rights, Right]),
pipe([lefts, join('\n'), Left]))),
map(over(lensIndex(0), wrap(' <small>v', '</small>'))),
map(apply(replace(/(?=<[/]h1>)/))),
map(toDocument),
chain(writeFile('index.html')),
either(failure, success)],
process.argv);
def
indicates the type-class constraints.
Point
and I don't put it in the $.env ?
const X = curry(function(f, g, x, y) { return f(g(x,y)); });
const isFirstOrNone = X(gte(0), lastIndexOf);
const GFirstOrNone = isFirstOrNone('G');
GFirstOrNone('G456546');//-> true
GFirstOrNone('5G456546');//-> false
compose(gte(0), lastIndexOf)
wouldn't quite work)?
does someone have an idea how I can make this... more functional? also my structure doesn't match 100% what I want (included).
I was wondering if I could use R.lensIndex
with R.lensPath
but R.lensPath(path)
creates objects instead of an arry.
R.set
const isFirstOrNone = R.pipe(R.head, R.equals('G'));
isFirstOrNone('G456546');//-> true
isFirstOrNone('5G456546');//-> false
R.partialRight
I don't understand the $.env initialization. You register all the types you will check ?
I agree that this is somewhat confusing, @jgoux. The reason it's necessary to define an environment (a list of types) is to support type variables. In order to determine whether [x, y, z]
is a valid value of type $.Array(a)
, we need to know all the possible values of a
– in other words, all the types we'd like to consider.
For a type such as $.Array($.Number)
we don't need knowledge of the environment.