function": - return always the same output for the same input not pure: - console.log() <> output, ... - using a variable declared outside the function ! It's not always possible " Think "purely" as possible 22 โ @MontpellierJug
a function that returns a string function youAreSo(adjective) { return function(name) { return `${name}, you are so ${adjective}` } } // "shortcuts" let youAreSoAmazing = youAreSo("โจ"); let youAreSoLovely = youAreSo(""#$"); 27 โ @MontpellierJug
Kebab let ingredients = aliments .filter(sansFrite) // โฉ new list .filter(sansOignon) // โฉ new list .map(decouper) // โฉ new list (transformer en un autre []) console.log("ingrรฉdients:", ingredients) 35 โ @MontpellierJug
= aliments.filter(sansFrite).filter(sansOignon).map(decouper) let kebab = ingredients.reduce((resultatIntermediaire, ingredient) => { return resultatIntermediaire + ingredient + " " }, "" avec: ") console.log(kebab) // " avec: morceaux // de # morceaux de $ morceaux de % morceaux de & morceaux de ! // who is the '( who put ! in my ) โ 41 โ @MontpellierJug
static of(x) {return new Monad(x);} /* So, I'm a monad because I have a flatMap method */ ! flatMap (fn) { return fn(this.value); } } 65 โ @MontpellierJug
ECONNREFUSED 127.0.0.1:9090 at ClientRequest.<anonymous> (/Users/k33g/Dropbox/k33g/fp/node_modules/node-fetch/index.js:133:11) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:188:7) 103 โ @MontpellierJug
// OK, there is something more "stylish" val userOption = JSON.parseFull(fromURL("http://localhost:9090/users/"+id.toString).mkString) // JSON.parseFull returns an Option ! userOption match { " case None => Left("# Bad Json") case Some(user) => { user.asInstanceOf[Map[String, Any]].get("id") match { " case None => Left("# User unknown") " case Some(value) => Right(user) }}} } catch { " case e: Exception => Left("# " + e.toString) } } 108 โ @MontpellierJug
= { Try( JSON.parseFull(fromURL("http://localhost:9090/users/"+id.toString).mkString) ) match { ! case Failure(fail) => Left("" " + fail.toString) ! case Success(userOption) => { userOption match { ! case None => Left("" Bad Json") case Some(user) => { user.asInstanceOf[Map[String, Any]].get("id") match { ! case None => Left("" User unknown") ! case Some(value) => Right(user) }}}}} } 110 โ @MontpellierJug
not quite a monad as it doesnโt quite follow the monad rules, even though it has the monad methods. It that can hold either a success value or a failure value (i.e. an error message or some other failure object) and has methods for accumulating errors. -- Monet - la doc 113 โ @MontpellierJug
will apply a function over the validation from within the supplied validation. If any of the validations are fails then the function will collect the errors. -- Monet - la doc 118 โ @MontpellierJug
{ return user.id !== undefined ? monet.Validation.success(user.id) : monet.Validation.fail(["! User unknown"]); // " have you seen the []? } 120 โ @MontpellierJug
= { value } # it's good Yuck = { value } # it's bad } let banana = SomeThing.Yum("!") let hotPepper = SomeThing.Yuck(""") # you can do that: println(banana: isYum()) # true println(hotPepper: isYuck()) # true 134 โ @MontpellierJug
Java PIERRE-YVES SAUMONT HTTPS://WWW.MANNING.COM/BOOKS/FUNCTIONAL-PROGRAMMING-IN-JAVA Functional Programming in JavaScript LUIS ATENCIO HTTPS://WWW.MANNING.COM/BOOKS/FUNCTIONAL-PROGRAMMING-IN-JAVASCRIPT Functional Programming in Scala PAUL CHIUSANO AND RรNAR BJARNASON 150 โ @MontpellierJug
VAKIL HTTPS://WWW.YOUTUBE.COM/WATCH?V=E-5OBM1G_FY Gรฉrer les erreurs avec l'aide du systรจme de types de Scala ! DAVID SFERRUZZA HTTPS://WWW.YOUTUBE.COM/WATCH?V=TWJQKRZ23VS TDD, comme dans Type-Directed Development CLรMENT DELAFARGUE 152 โ @MontpellierJug