Quantified Types
They are also known as polymorhphic types.
> :type id
id :: forall a. a -> a
The key word forall
indicates that id
is univerally quantified, meaning that id
can be applied to any type.
> id 1
1
A more complicated example is flip
. flip
is also a higher-order function, which will be explained in the later chapter.
> :type flip
forall a b c. (a -> b -> c) - > b -> a -> c
当前内容版权归 hamler-lang 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 hamler-lang .