2006-09-17

FP notes

type inference
the action that the compiler performs when it guesses the type of each expression of a program.


closure
a function which, when executed, accesses the values (environment) which were accessible at the time it was defined in addition to the parameters, as opposed to the values which are accessible at the point where the function is being called.


High Order Function
Functions that have an argument that is, itself, a function are called higher-order functions. Functions that deliver a value that is, itself, a function are also called higher-order functions. The composition operator is a higher-order function that does both.


arrow (->) is right-associative
To make the arrow notation (->) for function types compatible with curried forms of function invocations, the arrow associates to the right. That is, a -> b -> c is interpreted as a -> (b -> c) automatically, even if the parentheses are missing. In reporting types, the Haskell system omits redundant parentheses.


where

A where-clause appears as an indented subsection of a higher-level definition. The indentation is Haskell’s way of marking subsections — it is a bracketing method known as the offsides rule. A where-clause may contain any number of private definitions. The end of a where-clause occurs when the level of indentation moves back to the left of the level established by the keyword where that begins the where clause.


foldr
foldr op init list
=> x1 op (x2 op (x3 ... op (xn op init))

foldl
foldl op init list
=> (x1 op init) op x2) op x3) ... op xn)

没有评论: