根据这篇关于 haskell中的指称语义的文章所有类型都有底,如果一个函数f:A-> B是严格的,如果它将A类型的底部映射到B类型的底部,则称其为 non-strict 。
(这让人联想到态射保持基点的尖端类别)。
为什么Haskell没有 - 严格的函数,而标准的ML没有?
解决方案每个带递归的至少一个非严格函数,通常以条件形式( if-then-else )。否则,所有的递归都会表示底部(非终止)。尽管非严格功能是必不可少的,但是,大多数这些语言不允许你自己定义!有些语言通过提供宏来弥补这一限制 - 这是一种类似于函数的机制,可以转换语法而不是值。
According to this article on denotational semantics in haskell All types have bottom, and a function f:A->B is strict if it maps the bottom of type A to the bottom of type B, it is called non-strict other-wise.
(This is reminiscent of a pointed category where morphisms preserve the basepoint).
Why does Haskell have non-strict functions, whereas Standard ML doesn't?
解决方案Every programming language with recursion has at least one non-strict function, often in the form of a conditional (if-then-else). Otherwise all recursions would denote bottom (non-termination). Essential as non-strict functions are, however, most of these languages do not let you define your own! Some languages make up for this limitation by offering macros--a somewhat function-like mechanism that transforms syntax instead of values.
更多推荐
为什么Haskell有非严格的函数(语义)?
发布评论