Functional Dependencies
In Haskell, type classes have been refined to allow the programmer to declare functional dependencies between type parameters—a concept inspired from relational database theory. That is, the programmer can assert that a given assignment of some subset of the type parameters uniquely determines the remaining type parameters. For example, general monads m
which carry a state parameter of type s
satisfy the type class constraint MonadState s m
. In this constraint, there is a functional dependency m -> s
. This means that for a given monad, the state type accessible from this interface is uniquely determined. This aids the compiler in type inference, as well as aiding the programmer in type-directed programming.
Simon Peyton-Jones has objected to the introduction of functional dependencies in Haskell on grounds of complexity.
Read more about this topic: Type Class
Famous quotes containing the word functional:
“Indigenous to Minnesota, and almost completely ignored by its people, are the stark, unornamented, functional clusters of concreteMinnesotas grain elevators. These may be said to express unconsciously all the principles of modernism, being built for use only, with little regard for the tenets of esthetic design.”
—Federal Writers Project Of The Wor, U.S. public relief program (1935-1943)