codata

How to encode corecursion/codata in a strictly evaluated setting?

限于喜欢 提交于 2020-11-29 03:07:06
问题 Corecursion means calling oneself on data at each iteration that is greater than or equal to what one had before. Corecursion works on codata, which are recursively defined values. Unfortunately, value recursion is not possible in strictly evaluated languages. We can work with explicit thunks though: const Defer = thunk => ({get runDefer() {return thunk()}}) const app = f => x => f(x); const fibs = app(x_ => y_ => { const go = x => y => Defer(() => [x, go(y) (x + y)]); return go(x_) (y_)

How to encode corecursion/codata in a strictly evaluated setting?

无人久伴 提交于 2020-11-29 03:07:05
问题 Corecursion means calling oneself on data at each iteration that is greater than or equal to what one had before. Corecursion works on codata, which are recursively defined values. Unfortunately, value recursion is not possible in strictly evaluated languages. We can work with explicit thunks though: const Defer = thunk => ({get runDefer() {return thunk()}}) const app = f => x => f(x); const fibs = app(x_ => y_ => { const go = x => y => Defer(() => [x, go(y) (x + y)]); return go(x_) (y_)

Pithy summary for codata (Where a comonad is a 'type for input impurity')

自作多情 提交于 2019-12-24 05:31:36
问题 In terms of pithy summaries - this description of Comonads seems to win - describing them as a 'type for input impurity'. What is an equivalent pithy (one-sentence) description for codata? 回答1: "Codata are types inhabited by values that may be infinite" This contrasts with "data" which is inhabited only by finite values. For example, if we take the "data" definition of lists, it is inhabited by lists of finite length (as in ML), but if we take the "codata" definition it is inhabited also by

What is the difference between codata and data?

ぃ、小莉子 提交于 2019-12-03 12:15:55
问题 There is some explanation here. Intuitively I understand how finite data structures differ from infinite data structures like streams. Nevertheless, it's interesting to see other explanations of differences, characteristics, types of codata. I stumbled upon codata term when reading about streams. 回答1: This answer isn't terribly precise, but I'm going to post it anyway. The real distinction... ... is between data and computations . Data The fundamental property of data is that it has a

What is the difference between codata and data?

自古美人都是妖i 提交于 2019-12-03 02:41:58
There is some explanation here . Intuitively I understand how finite data structures differ from infinite data structures like streams. Nevertheless, it's interesting to see other explanations of differences, characteristics, types of codata. I stumbled upon codata term when reading about streams . This answer isn't terribly precise, but I'm going to post it anyway. The real distinction... ... is between data and computations . Data The fundamental property of data is that it has a structure . Data can be passed as input and returned as output by computations. The structure of data can be used