LINUX.ORG.RU

История изменений

Исправление quasimoto, (текущая версия) :

http://blog.sigfpe.com/2014/05/cofree-meets-free.html

I often think of coalgebraic things as machines. They have some internal state and you can press buttons to change that internal state.

state

O_o

Just as monads are a kind of generalised algebraic structure, comonads are a generalised kind of machine.

if you think of comonads as machines, monads give a language that can be used to compute something based on the output of the machine.

Монадические вещи (языки, структуры) конструируются монадическим интерфейсом и сворачиваются в значения катаморфизмами (свёртками), комонадические вещи (потоки, машины) генерируются анаморфизмами (развёртками), а их части обозреваются комонадическим интерфейсом. Если Free для ADT-функтора даст «язык», то, надо полагать, Cofree дуализация этого ADT-функтора даст соответствующую «машину», и наоборот.

Но

http://comonad.com/reader/2011/monads-from-comonads/

Is there is a similar construction that lets you build a comonad out of a monad?

Sadly, it seems the answer in Haskell is no.

for any more interesting such type that actually lets us get at its contents, we would be able to derive a circuitous path to unsafePerformIO!

Итого примеры — Identity (http://comonad.com/reader/2008/the-cofree-comonad-and-the-expression-problem/), дуализация — он же

Free Identity (Int -> Int) -> Cofree Identity Int -> Int
~~~~~~~~~~~~~~~~~~~~~~~~~~    ~~~~~~~~~~~~~~~~~~~
Nat                           Stream

выполнение числа («программы») на потоке («машине») возвращает такой-то элемент потока.

UpDown a = a + a, дуализация — Two a = a * a

Free Two (x -> r) -> Cofree UpDown x -> r
~~~~~~~~~~~~~~~~~    ~~~~~~~~~~~~~~~
FreeMagma            CoFreeComagma

Ещё с comonad стороны:

http://blog.sigfpe.com/2006/12/evaluating-cellular-automata-is.html

http://github.com/ekmett/machines/blob/master/src/Data/Machine/Moore.hs

Исходная версия quasimoto, :

http://blog.sigfpe.com/2014/05/cofree-meets-free.html

I often think of coalgebraic things as machines. They have some internal state and you can press buttons to change that internal state.

state

O_o

Just as monads are a kind of generalised algebraic structure, comonads are a generalised kind of machine.

if you think of comonads as machines, monads give a language that can be used to compute something based on the output of the machine.

Монадические вещи (языки, структуры) конструируются монадическим интерфейсом и сворачиваются в значения катаморфизмами (свёртками), комонадические вещи (потоки, машины) генерируются анаморфизмами (развёртками), а их части обозреваются комонадическим интерфейсом. Если Free для ADT-функтора даст «язык», то, надо полагать, Cofree дуализации этого ADT-функтора даст соответствующую «машину», и наоборот.

Но

http://comonad.com/reader/2011/monads-from-comonads/

Is there is a similar construction that lets you build a comonad out of a monad?

Sadly, it seems the answer in Haskell is no.

for any more interesting such type that actually lets us get at its contents, we would be able to derive a circuitous path to unsafePerformIO!

Итого примеры — Identity (http://comonad.com/reader/2008/the-cofree-comonad-and-the-expression-problem/), дуализация — он же

Free Identity (Int -> Int) -> Cofree Identity Int -> Int
~~~~~~~~~~~~~~~~~~~~~~~~~~    ~~~~~~~~~~~~~~~~~~~
Nat                           Stream

выполнение числа на потоке возвращает такой-то элемент потока.

UpDown a = a + a, дуализация — Two a = a * a

Free Two (x -> r) -> Cofree UpDown x -> r
~~~~~~~~~~~~~~~~~    ~~~~~~~~~~~~~~~
FreeMagma            CoFreeComagma

Ещё с comonad стороны:

http://blog.sigfpe.com/2006/12/evaluating-cellular-automata-is.html

http://github.com/ekmett/machines/blob/master/src/Data/Machine/Moore.hs