concept time in category f#

This is an excerpt from Manning's book Get Programming with F#: A guide for .NET developers.
Let’s first start at the very beginning and discuss at a relatively high level some of the key points of what F# really is (and isn’t!), and then discuss the key question that you probably have on the tip of your tongue – why should you spend time learning a new language with a new way of doing things, when you could be productively bashing out code right now in C# or VB?
In this case, you can think of 'a as the same as T in C# (a generic type argument). You can specify the generic argument placeholder (and use it as a type annotation) if you want to (for example, let createList<'a>(first:'a, second), but you should generally just let the compiler infer the arguments; it’s powerful and will save you a lot of time.
It’s well worth spending the time to understand type inference in F#, because it’s a crucial part of the flavor of the language. Type inference fits with the “more with less” philosophy, as well as another side of F# discussed at the start of this lesson, which is trusting the compiler.
You need a different mindset to create functions and arguments without type annotations and let the compiler fill in the gaps, and as you saw, at times it’s important that you understand what the compiler is doing under the hood. But as you’ll see over the coming lessons, type inference is incredibly useful in writing succinct, easily refactorable code without needing to resort to a third-party tool to “rewrite” your code for you.

This is an excerpt from Manning's book F# Deep Dives.
The four most common problems are summarized in figure 1. Analytical applications typically implement more complex tasks than the rest of the system; they only deliver value if the implementation is correct, is delivered in time, and satisfies nonfunctional requirements such as efficiency. Table 1 revisits the problems and explores their business implications.
Table 1. Business problems and their implications
Problems
Implications
Correctness As computers become more efficient, financial and actuarial models grow increasingly complicated. The amount of available data grows equally quickly, so algorithms that process this data become more advanced. Maintaining the correctness of such systems raises many problems. It becomes difficult to add new features without breaking existing code, and systems may break as data sources and formats evolve. In settings where models are developed by researchers and are later reimplemented by developers for production code, it’s hard to keep the two in sync. An incorrect system that produces incorrect values can easily lead to wrong decisions being made. If a user interface displays a picture incorrectly, your user will likely be annoyed, but they won’t lose money. But money can easily be lost if something goes wrong in an analytical component of a financial system. An infamous example of a correctness problem was the Mars Climate Orbiter probe launched by NASA in 1998. The probe failed during launch because one part of the system was using metric units (force measured in Newtons) and another was using imperial units (measured in pound force). Even when incorrect systems don’t have such massive consequences, they may lead to buggy services and the loss of reputation for the company, or to buggy products and a loss of customers. Time to market Another important consideration for analytical and data-rich components is the time to market—how much time is needed before an initial idea can be turned into production-quality code. For example, a financial company might have a research department that develops models in statistical or numerical environments like R and MATLAB. When a model is designed and tested, it’s passed to developers who translate the models to C++ for deployment to production. Such translation can easily take six months. Consider another example from the social gaming domain. A quick release cycle is important to make sure that your players keep getting new features, or even new games, every few weeks. In the financial sector, the inability to turn a new mathematical model into a system that can be used in production might mean the business loses an opportunity that exists only in a short timeframe. In the social gaming world, a company will quickly lose players if the games aren’t rapidly updated or new features aren’t added. The time to market is also important in the startup world, which is symbolized by the phrase “fail fast.” You want to be able to develop initial prototypes quickly, so that you can immediately verify the viability of some idea. If the prototype does work, you should also be able to quickly turn it into a complete project. Efficiency and scalability Two related concerns are efficiency and scalability. Efficiency is mainly important for computationally heavy software such as financial models. For example, models that were originally developed by researchers in R or Python need to be translated to more efficient C++ code or optimized Python. If the researchers were able to write their models more efficiently, then the translation step wouldn’t be needed. Scalability matters even for software that doesn’t perform heavy computations. A server-side application (such as a social game backend) or UI (a game frontend) needs to handle multiple concurrent requests or user interactions. Efficiency and scalability have varying importance in different contexts. A common case for efficiency in financial systems is that models need to be recalculated overnight, so there’s a hard limit. Failure here means up-to-date information isn’t available. Similarly, when serving a web page with ads, the ad service needs to choose an appropriate ad based on the user’s information almost instantly. As for scalability, server-side code that doesn’t scale will consume excessive resources and make maintenance costly. On the client side, nonscalable applications can hang and lead to a poor user experience. Complexity Analytical and data-centric components are usually the parts of an application that implement advanced logic. They provide value by implementing mathematical models, data analyses, or processing of concurrent events. In a poorly designed system, complexity can easily grow beyond a tractable level, most commonly because different features that should be independent interact in unexpected ways. As a result of increasing complexity, your company might not be able to implement a desired financial model, AI behavior, or data analytical component, because it’s too complex. As a result, you won’t be able to provide the data that users and customers need (or not at the required quality), or an entire project or product may fail. In other words, without the right tools, you’ll often have to settle for a suboptimal solution.

This is an excerpt from Manning's book Real-World Functional Programming with Examples in F# and C#.
The F# Interactive tool allows you to verify and test your code immediately while writing it. This tool is extremely useful at the beginning of the development process, because it encourages you to try various approaches and choose the best one. Also, when solving some problem where you’re not 100 percent sure of the best algorithm, you can immediately try the code. When writing F# code, you’ll never spend a lot of time debugging the program. Once you first compile and run your program, you’ve already tested a substantial part of it interactively.
Our main example in this chapter will be a library for creating animations. We’ll use a bottom-up approach when describing the library. This means that for most of the chapter we’ll be talking about very simple things. We’ll look at a couple of primitives for representing values that change with the time and a simple representation of drawings. The beauty of a composable library is that each piece is easy to build, understand, and test. The power is demonstrated when we start putting these building blocks together. In this case we’ll not only combine primitives from the same domain, but we’ll bring two domains together: a drawing that varies over time is practically the definition of an animation. This is a bit like using LINQ to XML, which is an XML API designed to work well with LINQ to Objects. When libraries can be combined in a natural way, it can lead to readable and flexible code.
Using lifting in F# is quite easy thanks to its advanced type inference. We created the translate primitive earlier, so in this listing we add the circle function and a custom operator -- ❶ for composing animations. Both have two arguments, so we can use the Behavior.lift2 function to take a function that works with drawings and turn it into a variant that works with animations. As you can see from the inferred type signature ❷, the resulting function (or an operator) takes two behaviors as arguments and returns a behavior (more specifically, the type Behavior<Drawing>, which represents an animation). The circle function now takes both the brush and the size as behaviors, so we can create circles that change color and size over time.
We’ve already applied the concepts of addition and multiplication to locations, but the other dimension our animations work with is time. What can we do with that? Well, we might want to speed up an animation, or delay it for a period of time. If we had two rotating circles, we may want to rotate one twice as fast as the other. We could create a new primitive behavior, but there’s a more elegant way. We can create a function that takes a behavior as an argument and returns a new behavior that runs faster or that’s delayed by a specified number of seconds. You can see the F# version in listing 15.20.
Listing 15.20. Speeding up and delaying behaviors (F#)
let wait shift (BehaviorFunc bfunc) = sample(fun t -> bfunc { t with Time = t.Time + shift }) let faster q (BehaviorFunc bfunc) = sample(fun t -> bfunc { t with Time = t.Time * q })Functions in listing 15.20 work with any kind of behavior, not just animations. Each takes a floating-point number as the first argument and an original behavior as the second. To create a new behavior, we have to use the low-level sample primitive. We create a new behavior that calls the function extracted from the original behavior and gives it a different time as the argument. In the first case, the time is shifted by the specified number of seconds, and in the second case it’s multiplied by the provided coefficient. To explain what this means, let’s look at the second function and say we’re running a behavior twice as fast. When the actual time is 3 seconds, the returned behavior will invoke the original one with a time of 6 seconds, which means that the animation will do the movements it would usually perform in 6 seconds in just 3 seconds.
We could write an entirely general function for manipulating with the time. The more general version would specify the time adjustment as a behavior—a function that returns the adjusted time given the original time. The simple functions we’ve created will be easier to use and understand.