Re:Functional Programming Jargon
by jethrolarson on Thursday July 28, 2016 @01:15AM
(#12178445)
Thanks for the feedback. I've been trying to direct the definitions to be informal and understandable but many contributions come in with a different voice. Some of the definitions are first draft attempts just to get something in place.
It's been awesome to see the sudden popularity of our humble glossary :)
Lazy: I feel like the definition of lazy needs to be demonstrated in contrast to eager evaluation.
val x = {println("evaluating x"; 5)}
lazy val lazyX = {println("evaluating lazyX"; 5)}
this would print ("evaluating x) to the console. lazyX would not be evaluated because it is not invoked. Here the eager definition of x demonstrates that it is evaluated immediately. lazyZ is only evaluated when invoked.
Monads and higher kinded types. The informal vs formal definition of some of the higher kinded types is worth noting. You're either describing the most formal definitions (identity/associativity laws) or you're describing the informal defition (has flatmap, processing things in a series as described in the wikipedia article https://en.wikipedia.org/wiki/Monad_(functional_programming) ) Monad seems to be the informal definition, otherwise associativity laws should be included maybe? Eg in Scala Try is not a formal monad as the associativity laws don't hold true. https://wiki.haskell.org/Monad_laws Also why is it "of" and "chain" here? Isn't it traditionally flatmap that indicates a type might be a monad, and then the identity laws the truly confirm it? Maybe this is js land? If so, should the doc say "this is js" as flatmap is pretty descriptive of map+flatten. It's hard to talk about - It's not at all clear to me what people mean when they talk about monads either - just throwing thoughts around.
I think you should outline how Currying and Partial Application are related maybe? Eg currying is taking a function with an arg list and making it take multiple arg lists (the act of making a function take multiple arg lists), and Partial application is the application of an argument of a curried function more or less? I think the relationship between these should be highlighted possibly to sort of draw out what part of the life of a function we're talking about if trying to illuminate the subject for someone.