What you will learn in Functional Programming in Scala, Second Edition
Chapter by chapter
Concepts explained in this book
- flatmapflatMap is a monadic combinator that applies a computation-producing function and combines its result with the surrounding monadic context.
- type-lifting functionunit is a book-defined operation that constructs a state-threading computation containing a supplied value without changing the state.
- monadA monad is an abstraction that represents effectful or context-dependent values and provides operations, including flatMap, for sequencing computations while preserving that context.
- map2map2 is a state-action combinator that combines two actions with a binary function while threading state from the first action into the second.
- parsingParsing is the process of analyzing an input sequence according to a grammar or other syntactic rules to recognize its structure and produce a result.
- ParPar is a book-defined abstraction representing a computation that can be executed in parallel and whose result is obtained through a Future.
- traverseA traversable functor is an abstraction that systematically applies an effectful function to the elements of a data structure and combines the resulting effects.
- streamingStream processing is the incremental computation of results from sequences of data as elements become available.
- side effectA side effect is an observable state change or interaction caused by evaluating an expression beyond producing its returned value.
- attributeA property is a Boolean-valued statement about program behavior that should hold for a range of inputs or configurations.
- propProp is a book-defined representation of a testable property as a computation over test configuration and random state that produces a result.
- PullPull is a book-defined data type representing a computation that emits zero or more values of one type and then terminates with a result value of another type.
- genericsA polymorphic method is a method declared with type parameters that can operate over values of multiple types.
- stateState is a parameterized state-transition abstraction that represents computations producing a value while transforming an underlying state.
- forkfork is a book-defined parallel-computation operation that evaluates a computation asynchronously in a separate logical thread while preserving its result.
- forallProp.forAll is a ScalaCheck API function that constructs a property by applying a predicate to values generated by a Gen.
- referential transparencyReferential transparency is the property that an expression can be replaced by its value without changing a program's meaning within a specified context.
- property-based testingProperty-based testing checks general behavioral properties against automatically generated input values rather than relying only on hand-written examples.
- joinjoin is a monadic combinator that flattens a nested monadic value into a single monadic layer.
- parse errorA parse error is a failure report identifying that input does not conform to the expectations of a parser, including its location and cause.
- foldableA foldable data type is a data type whose elements can be traversed and reduced to a result by a folding operation.
- applicative functorAn applicative functor is an abstraction that applies effectful functions to effectful arguments while combining their contexts.
- foldRightfoldRight is a polymorphic list-folding function that processes elements from the right using an initial result and a combining function.
- stack safetyStack safety is the property of an implementation being able to process inputs without exhausting the call stack as input size grows.
- ConsCons is the book-defined List data constructor for a nonempty list containing a first element and a remaining list.
- NilNil is the book-defined List data constructor representing an empty list.
- pattern matchingPattern matching is a language feature that selects a case by comparing a target expression with structural patterns and evaluates the corresponding result.
- listOfNlistOfN is a parser combinator that parses a specified number of occurrences of another parser and returns their results as a list.
- combinatorA combinator is a compositional operation that builds a larger computation from smaller functions or computational structures.
- parser combinatorA parser combinator is a compositional operation that constructs or transforms parsers while preserving their parsing behavior.
- lazy evaluationLazy evaluation defers evaluating an expression until its value is required.
- parallelismParallelism is the execution of multiple parts of a computation at the same time, typically on multiple processor cores or CPUs.
- type constructorA type constructor is a type-level function that takes one or more types as parameters and produces a new parameterized type.
- treeA recursive data structure whose values are formed from nodes such as leaves and branches, with this section focusing on structural shape during combination.
- IOIO is a monadic abstraction that represents effectful computations as values whose execution can be controlled separately from their description.
- algebraic lawA law is a general equation or behavioral property that operations or their implementations are expected to satisfy.
- foldLeftfoldLeft is a polymorphic list-folding function that processes elements from the left using an initial accumulator and a combining function.
- optionOption is a Scala standard-library type representing either the presence of a value with Some or its absence with None.
- genGen is a book-defined generator abstraction that represents computations for producing randomly generated values of a specified type.
- sequencesequence combines nested effectful values by exchanging the order of their outer and inner type constructors when the inner context is applicative.
- manymany is a parser combinator that parses zero or more repetitions of an input parser and returns the parsed values as a list.
- FreeFree is a data type that represents a program constructed from an instruction set together with recursive sequencing and result substitution.
- sliceA parser combinator that returns the portion of input consumed by another parser instead of its parsed value.
- pure functionA pure function is a function whose result depends only on its arguments and whose evaluation has no observable side effects.
- compositionKleisli composition is an operation that composes functions producing monadic results into a larger monadic computation.
- productA product is a construction that combines two algebraic or effectful structures componentwise into a structure over pairs.
- functorA functor is an abstraction that provides a map operation for transforming values inside a computational structure while preserving that structure.
- associativityThe algebraic law stating that regrouping repeated applications of a binary operation does not change the result.
- scopeA book-defined structure representing an open or closed region of stream interpretation with an associated finalizer and nested scopes.
- string parserA string parser is a parser combinator that recognizes a specified complete string and returns it as its result.
- many1many1 is a parser combinator that applies a parser at least once and then repeats it for additional successful matches.
- foldMapfoldMap transforms the elements of a data structure and combines the results using the operations of a monoid, discarding the original structure.
- sized generationA sized generator is a test-value generator whose generated values or search space vary according to a maximum size parameter.
- lazyUnitlazyUnit is a book-defined Par operation that accepts a by-name value and constructs a parallel computation for evaluating it asynchronously.
- stepstep is a Free interpreter operation that reassociates and simplifies a computation into a normalized Return, Suspend, or right-associated FlatMap form.
- function generationA function generator produces functions whose outputs are determined by generated values and information derived from their inputs.
- data constructorA data constructor is a named constructor that creates a value of an algebraic data type and may contain zero or more arguments.
- callbackA callback is a function supplied to an asynchronous operation so that the operation can report completion or a result later.
- by-name parameterA by-name parameter is a Scala parameter whose argument expression is evaluated when the parameter is accessed rather than when the function is invoked.
- identity lawA left identity law states that combining the identity with an operation on its left leaves the operation unchanged.
- functional, stateless philosophyFunctional design is the practice of structuring software around pure functions, immutable data, composition, and explicit effects.
- parallel map2Parallel map2 is a book-defined higher-order function that combines the results of two parallel computations with a binary function.
- WCWC is an algebraic data type representing a partial word-count result with complete-word counts and unfinished words at its boundaries.
- word countThe number of whitespace-delimited words represented by a character sequence or word-count summary.
- PipeA Pipe is a stream-processing abstraction that transforms input values into output values, potentially while evaluating effects.
- algebraic structureAn algebra is an abstract system consisting of operations on elements together with laws that specify how those operations behave.
- randRand is a type alias for a state-transition function that accepts an RNG and returns a value together with a new RNG.
- replicateMreplicateM is a monadic combinator that repeats an effectful computation a specified number of times and collects the results in a monadic list.
- unfoldunfold is a book-defined function that generates a LazyList from an initial state and a function producing the next state and output value.
- higher-order functionA higher-order function is a function that takes one or more functions as arguments or returns a function as its result.
- unconsUncons is a Pull data constructor that stores a source pull whose next result is obtained when the constructor is evaluated.
- early terminationEarly termination is stopping an operation as soon as its result is determined without processing the remaining input.
- choicechoice is a parallel-computation combinator that selects one of two computations according to the Boolean result of an initial computation.
- choiceNchoiceN is a parallel-computation combinator that selects a computation from a list using the integer result of an initial computation.
- chooserchooser is a parallel-computation combinator that runs an initial computation and uses its result to generate or select a second computation.
- applicative applyApplicative apply is an operation that applies an effectful function to an effectful argument while combining their contexts.
- filteringAn Option filter retains a present value only when it satisfies a Boolean-valued predicate, otherwise producing None.
- given instanceThe given keyword declares a Scala value or definition that can be selected as a contextual instance.
- algebraic designAlgebraic design is a software-design approach that specifies an algebra, including its operations and laws, before choosing concrete data representations.
- lazy listA lazy list is an immutable sequence whose elements and continuation are evaluated on demand, allowing finite or infinite sequences.
- parfoldmapA parallel fold-map operation that maps and reduces sequence elements as parallel computations.
- runFreerunFree is a book-defined operation that interprets a Free program by translating its instructions into a target monad.
- SuspendSuspend is an IO computation constructor that contains a deferred function to be executed when the computation is interpreted.
- getget is a State constructor that returns the current state as its result without changing the state.
- lambdaA function expression without a declared name, typically written using parameter and body syntax.
- LazyListLazyList is a Scala standard-library sequence type whose elements are computed lazily and that can represent finite or infinite sequences.
- mapAccummapAccum is a traversal operation that threads an accumulator through a structure while transforming its elements and preserving its shape.
- modifymodify is an atomic Ref operation that computes an updated state and returns an additional value from the previous state.
- monad lawThe monad associativity law states that sequential binding has the same meaning regardless of how nested bindings are parenthesized.
- deadlockA deadlock is a state in which concurrent computations wait indefinitely for one another to release resources or provide progress.
- thread poolA thread pool is a managed set of reusable worker threads that execute submitted tasks, optionally with a fixed maximum size.
- tail recursionTail recursion is recursion in which the recursive call is the final computation of the calling function, allowing constant-stack evaluation when supported by the language.
- labelA parser operation that replaces a parse-error stack with a contextual message when the enclosed parser fails.
- choiceMapchoiceMap is a parallel-computation combinator that selects a computation from a map using the result of an initial computation.
- RNGRNG is a Scala trait interface representing a random number generator whose operation returns a generated integer together with a successor generator state.
- pure functional data structureA purely functional data structure is an immutable data structure whose operations produce new values without mutating existing ones.
- ReturnReturn is an IO data constructor representing a computation that has completed with a value and requires no further steps.
- resultResult is a parser-result type that represents a parse outcome, including a successful value and the number of input characters consumed.
- context parameterA context parameter is a parameter whose argument can be supplied automatically by contextual or given-instance search.
- generatorA generator is a parameterized representation of a computation that produces test-case values, potentially for any element type.
- logical threadA logical thread is an independent line of computation used to describe concurrent execution without necessarily denoting a physical operating-system thread.
- algebraic data typeAn algebraic data type is a data type defined as a sum of one or more data constructors, where each constructor is a product of its arguments.
- lazy valA lazy val is an immutable Scala binding whose right-hand side is evaluated on first reference and whose result is cached for later references.
- RefRef is a purely functional mutable-reference abstraction whose access and mutation are performed within an effect type.
- EitherThe Either monad is the monadic structure formed by sequencing computations that may produce a left or right result.
- futureFuture is a Java concurrency interface representing the result of an asynchronous computation and supporting result retrieval and cancellation.
- non-blocking I/ONon-blocking asynchronous I/O performs external input and output without waiting synchronously for each operation to complete.
- type systemA type system is the set of language rules and mechanisms that classify program expressions and constrain their valid composition.
- unsafeRununsafeRun is a book-defined operation that executes an IO computation and returns its result while permitting its external effects.
- trampoliningTrampolining is a technique that represents chained function calls as iterative steps so computation can proceed without growing the call stack.
- pure coreThe side-effect-free central portion of a program whose computations are expressed with pure functions.
- resource safetyResource safety is the property that acquired resources are released appropriately and are not accessed after release, including when errors occur.
- translatetranslate is a book-defined operation that converts a Free program between instruction or execution representations using a natural transformation.
- MonoidA Monoid is an algebraic structure with an associative binary operation and an identity element.
- finalizerA finalizer is a cleanup action associated with an acquired resource and run when its scope is closed.
- enumAn enumeration is a type declaration that defines a finite set of named data constructors.
- charchar is a parser combinator that recognizes a specified single character and returns that character.
- linked listA singly linked list is a sequence represented by nodes in which each nonempty node contains an element and a reference to the remaining list.
- error reportingError reporting is the presentation of diagnostic information about a failed computation, including the failure location and cause.
- parMapparMap is a book-defined operation that applies a function to all elements of a list in parallel and returns a Par computation of the results.
- unionunion is a generator combinator that combines two generators of the same type and selects between them with equal likelihood.
- weightedweighted is a generator combinator that selects among generators with probabilities proportional to supplied weights.
- actorAn actor is a computational component that communicates through asynchronous messages and processes them according to its internal state.
- JSONJSON is a text-based data interchange format for representing structured values such as objects, arrays, strings, numbers, booleans, and null.
- listA list is an ordered collection whose elements are linked sequentially and whose structure is preserved by list-processing operations.
- resourceresource is a Stream constructor that acquires a value and guarantees evaluation of its corresponding release action.
- covarianceCovariance is a type-system property in which subtyping of a type argument induces the same direction of subtyping for the parameterized type.
- thunkA thunk is a zero-argument function representing an unevaluated expression that can be invoked to obtain its result.
- parser choiceParser choice is a combinator that succeeds when either of two alternative parsers succeeds.
- substitution modelThe substitution model is a method of evaluating expressions by replacing a function call with the result of substituting its arguments into the function body.
- STRefSTRef is a book-defined mutable-reference wrapper whose operations produce ST actions for reading or writing a cell.
- extensionAn extension method is a method defined outside a type's original declaration that can be invoked with object-oriented syntax on values of that type.
- locationA representation of a position in input containing the input text, an offset, and line and column information.
- asynchronous programmingAn asynchronous computation is a computation whose execution can proceed independently of the caller without requiring the caller to wait synchronously for completion.
- ConsoleConsole is an algebraic data type representing primitive console-interaction operations supported by a free program.
- smart constructorA smart constructor is a constructor-like function that creates a value while returning an abstraction's base type rather than a concrete data-constructor type.
- varianceVariance is a type-system property describing how subtyping between parameterized types relates to subtyping between their type arguments.
- ST monadThe ST monad is a functional programming abstraction that encapsulates local mutable state while preventing references created in one state thread from being used in another.
- nonempty listA nonempty list is a list data structure constrained to contain at least one element.
- companion objectA companion object is a Scala singleton object declared with the same name as a class or other data type and granted access to its private and protected members.
- language primitiveA primitive is a foundational operation supplied directly in an abstraction's interface rather than derived from other operations.
- race conditionA race condition is a concurrency defect in which a result depends on the timing or interleaving of operations from multiple threads.
- ScalaScala is a statically typed programming language that combines object-oriented and functional programming features and runs on the Java Virtual Machine.
- identity elementIdentity is the property that an operation has an element whose combination with another element leaves that element unchanged.
- JSON arrayA JSON array is an ordered JSON value containing a comma-separated sequence of JSON values enclosed in square brackets.
- JSON objectA JSON object is a JSON value containing comma-separated quoted-string keys paired with values and enclosed in curly braces.
- effect typeAn effect type is a type-level representation of computations that may perform specified effects while producing values.
- EvalEval is a Pull data constructor that wraps an effectful computation producing a result without output elements.
- tagless final interpreterA capability trait is an interface-based encoding of an effect algebra whose operations expose only the capabilities required by a program.
- foldA fold is an operation that combines a sequence of outputs into one accumulated value using an associative operation and an initial value.
- ST actionAn ST action is a value representing a computation in the ST monad that may access or mutate state when run with its state-thread token.
- state transitionA state action is a function that consumes an RNG state and returns a generated value together with a successor RNG state.
- currycurry is a book-defined higher-order function that transforms a two-argument function into a function returning a one-argument function.
- eager evaluationStrict code evaluates an argument or expression before the surrounding computation proceeds, rather than delaying evaluation until its value is needed.
- modularityA modular program is composed of components whose meanings and reuse can be understood independently and combined through explicit composition rules.
- imperative i/oImperative I/O is an input/output style that combines control flow, algorithmic logic, and resource management through explicit stateful operations.
- exceptionAn exception is an abnormal runtime condition represented by a control-flow mechanism that can interrupt normal computation and be handled separately.
- pseudo-random number generatorPseudo-random number generation is the deterministic production of values that approximate randomness from an initial seed.
- ziplistZipList is a wrapper type whose applicative combines corresponding elements of sequences rather than forming their Cartesian product.
- type hintsA type annotation is syntax that explicitly specifies the type associated with a program expression or parameter.
- contractAn application programming interface is a set of operations and abstractions through which software components are programmed or composed.
- local reasoningLocal reasoning is analyzing a component from its definition and inputs without tracking unrelated execution history or state changes.
- bindBind is a computation combinator that runs a computation and feeds its result to a function producing the next computation.
- error codeAn error code is a returned value that indicates an exceptional or failed condition instead of transferring control by throwing an exception.
- arrayAn array is an indexed, fixed-size sequence of elements stored in contiguous or logically contiguous positions.
- partial functionA partial function is a function defined for only some values in its input domain.
- structural sharingStructural sharing is the reuse of unchanged substructures between immutable data structures instead of copying them.
- test case minimizationTest case minimization reduces a failing generated input until it finds a smaller input that still causes the property to fail.
- exhaustive checkingExhaustive checking is a verification technique that evaluates a property over every value in a finite domain or every value within a bounded generated domain.
- forAllParforAllPar is a property-construction function that generates parallel computations and evaluates their properties across executor variations.
- ProvedProved is a Result case indicating that a property was established conclusively rather than merely tested without finding a counterexample.
- verifyverify is a property-construction function that proves a supplied Boolean expression by evaluating it once.
- lazy-list consLazy-list Cons is the nonempty lazy-list data constructor whose head and tail are represented by thunks.
- for-comprehensionA for-comprehension is Scala syntax for expressing a sequence of bindings and a result that the compiler translates into map and flatMap calls.
- liftlift is a book-defined function transformation that adapts an ordinary function to operate within the context of an Option value.
- property conjunctionThe property conjunction operator combines two Prop values so that the combined property represents their conjunction.
- corecursive functionCorecursion is a data-producing form of recursion whose continuation is justified by the ability to generate each next result productively.
- lazy I/OLazy I/O represents input or output operations as deferred computations whose effects occur only when the representation is evaluated.
- resource leakA resource leak is failure to release an acquired resource, such as an open file handle, after it is no longer needed.
- ValidatedValidated is an error-handling data type that represents successful or failed computations and can accumulate errors across combined failures.
- recursionRecursion is a technique in which a computation solves a problem by calling itself on smaller or simpler inputs.
- monadic recursionMonadic recursion is recursion that sequences recursive computations through a monad rather than through direct function calls.
- block expressionA Scala sequence of statements and expressions whose value is the value of its last expression.
- immutable variableA named binding whose association with its value cannot be reassigned after initialization.
- valA Scala declaration form that binds a name immutably to a value.
- curryingCurrying is the transformation of a function taking multiple arguments into a sequence of functions each taking one argument.
- partial applicationPartial application is the creation of a function by supplying some arguments to a function while leaving the remaining arguments to be supplied later.
- partial1partial1 is a book-defined function that partially applies a function by fixing one of its arguments and returning a function for the remaining argument.
- type signatureA type signature is a declaration of the types of a function's parameters and result, including any type parameters.
- TailRecTailRec is a book-defined data type that represents recursive control flow as an explicitly interpreted sequence of suspended computations.
- continuationA continuation is a representation of the computation that should proceed after an asynchronous result becomes available.
- error channelAn error channel is a computation component that carries errors separately from ordinary result values.
- MonadThrowMonadThrow is a type class extending Monad with operations for raising errors and handling them later.
- raiseErrorraiseError is an effect operation that constructs a computation representing a specified error.
- stream eliminatorA stream eliminator is an operation that runs an incremental stream and converts its effects and outputs into a final result.
- TaskTask is a book-defined effect type that represents an asynchronous or effectful computation whose result may be a successful value or an error.
- resource finalizationResource finalization is the execution of cleanup actions that release an acquired resource after computation completes or fails.
- derived combinatorA derived combinator is a compositional operation defined in terms of other operations rather than as a primitive.
- parsing libraryA parsing library is a software library that provides abstractions and operations for recognizing and processing structured input.
- free monadA free monad is a monad generated from an underlying set of operations, representing computations as composable syntax whose interpretation is supplied separately.
- FilesFiles is an algebraic data type representing primitive file-system operations supported by a free program.
- subtypingSubtyping is a type-system relationship in which values of one type may be used where values of another, more general type are expected.
- console I/OConsole I/O is interaction with a textual console through line-oriented input and output.
- eta expansionEta expansion is the conversion of a method into a function value with equivalent behavior.
- imperative programmingImperative programming is a programming paradigm that expresses computation as an ordered sequence of statements that may modify program state.
- tail-call optimizationTail call elimination is a compiler optimization that implements eligible recursive calls without allocating a new call-stack frame for each call.
- bottomBottom is the semantic outcome of an expression that does not return a definite value because it diverges or throws an error.
- property checkA property check is an operation that executes a Prop and returns an outcome describing whether its tests succeeded or failed.
- STST is a book-defined monadic abstraction for in-place mutable state whose underlying state-manipulating function cannot be directly invoked outside its scope.
- statefulnessA stateful API is a program interface whose behavior or results depend on state maintained across interactions.
- state tokenA state token is a value serving as type-level authorization to run computations that access or mutate a particular local state thread.
- partial type applicationPartial type application fixes one or more arguments of a parameterized type constructor while leaving the remaining arguments abstract.
- state monadA state monad represents a stateful computation as a function from an input state to a result paired with an output state.
- type lambdaA type lambda is an anonymous type-level function that maps type arguments to a constructed type.
- attempt combinatorA parser operation that reverses a parser's commitment on failure so that an alternative branch can be tried.
- coroutineA coroutine is a computation that can suspend execution and later resume while cooperatively transferring control to another computation.
- read-execute-print loopA read-eval-print loop is an interactive environment that repeatedly reads an expression, evaluates it, prints the result, and prompts for another expression.
- opaque typeAn opaque type is a Scala type whose representation is equivalent to an underlying type within its defining scope but abstract outside that scope.
- first-class objectA first-class value is a value that can be represented, returned, stored, passed to functions, and otherwise manipulated like other values.
- thin effect layerA small outer program layer responsible for performing or handling effects excluded from the pure core.
- compositionalityCompositionality is the property that components can be combined generically to form larger computations without depending on their internal implementations.
- error accumulationError accumulation is the combination of multiple computation errors into a single error result instead of stopping at the first error.
- parser combinator libraryA parser combinator library is a software library whose compositional operations create parsers from elementary and other parsers.
- property-based testing libraryA property-based testing library is a software library that specifies behavioral properties, generates constrained test cases, and evaluates the resulting tests.
- developer productivityProductivity is the property that each finite portion of a potentially infinite result can be computed in finite time.
- type classA typeclass is an abstraction that provides operations for types satisfying a specified interface or set of laws.
- sgenSGen is a book-defined type representing a size-aware generator of arbitrary test values.
- underscore notationUnderscore notation is Scala syntax that represents anonymous-function parameters with underscores whose occurrences are introduced in left-to-right order.
- tailtail is a list operation that returns all elements except the first, failing when applied to Nil.
- sealed traitA sealed trait hierarchy is a Scala type hierarchy whose permitted subtypes are restricted to declarations known to the compiler.
- effect algebraAn effect algebra is a collection of primitive operations representing a related class of computational effects.
- free algebraA free algebra is an algebraic representation of effect operations whose programs are interpreted separately into an executable effect.
- principle of least powerThe principle of least power is the design principle of exposing only the minimal functionality required by a program.
- target monadA target monad is the monadic computation type into which an effect program is directly constructed or interpreted for execution.
- OutputOutput is a Pull constructor representing one output value followed by a continuation pull.
- setset is a State constructor that replaces the current state with a supplied state and returns Unit.
- finite-state machineA state machine is a computational model whose behavior is determined by a current state and input-driven transitions.
- control flowControl flow is the ordering and transfer of execution among operations in a program.
- flatmap constructorThe FlatMap constructor represents continuation of an IO computation by applying a function to the result of a preceding computation.
- trampolineA trampoline is a control mechanism that repeatedly executes returned computation steps through a single driver loop rather than nested calls.
- or combinatorThe or combinator runs a second parser when the first parser fails without consuming committed input, and otherwise returns the first parser's result.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
