Indeed, the question is not wherever it's a monad or not, just to what extent is the monad useful.


Dne po 11. 7. 2016 22:08 uživatel Olaf Klinke <olf@aatal-apotheke.de> napsal:
As someone else on this list whose name I don't recall put it, there is no
choice on whether to make Stream a monad or not. It simply _is_ a monad.
Anyone with some CS education hearing 'diagonal of inifinite list of
infinite lists' should immediately think of Georg Cantor.

import Data.Stream
import Data.Ratio

type Real = Stream Rational
-- approximate a real number by an ascending stream
-- of lower bounds.

supremum :: Stream Real -> Real
supremum  = join
-- If a stream of reals is index-wise ascending,
-- the monad instance for Stream computes its supremum.
-- Use this e.g. to compute any mathematical quantity
-- defined as a supremum.

-- Olaf