9 Feb 12:02
Relation between monads and computations
Dmitriy Matrosov <sgf.dma <at> gmail.com>
2012-02-09 11:02:59 GMT
2012-02-09 11:02:59 GMT
Hi, everyone!
Not so long ago i started to learn haskell, and now i have a question
about relation between monads and computations. In fact, i think, that
i understand it and write some explanation for myself, but i'm not
sure whether my explanation is correct or not, and will be very
thankful if someone check it :) Here it is (i don't know category
theory and my math knowledge is poor, so if i accidently use some
terms from them incorrectly - it was just my understanding).
Monads and computations.
Generally computation consists of initial value, computation itself and the
result. So it can be illustrated as:
type a (M b) b
data I ------> C <--------- E
f ConstrM
I :: a
f :: a -> M b
data M a = ContrM a | ...
E :: b
Let's see what happens: i take initial value I of type a and map it to some
computation C (of type (M b)) using function f. Then, exist such value E of
type b, that C = (ConstrM E). This value E will be the result of computation.
Now consider two functions: unitM, which maps value into trivial computation
(trivial computation is a computation, which result is equal to initial
(Continue reading)
RSS Feed