A type system classifies expressions and restricts how they may compose. In Scala, a type signature can make an implementation almost inevitable: a function returning B => C must return a function accepting B and producing C, often by applying the available function f. section 2.5
Following types to an implementation
Given def partial1[A, B, C](a: A, f: (A, B) => C): B => C, first return a function taking b: B. Its result must be C, and f is the available operation that produces C from a and b, yielding (b: B) => f(a, b). The same reasoning supports curry, uncurry, and compose. section 2.5
Using types to protect local state
The ST design uses types to prevent local mutable references from escaping. ST[S, STRef[S, Int]] is unsafe to run because its result exposes S, while ST[S, Int] is safe because it returns only an Int. A polymorphic action [s] => () => ST[s, A] can therefore be run without revealing its private state. section 14.2.3





