Hi all, I am trying to understand the algebraic laws and operators behind a functional expression. So, for example, I can understand that the standard length function is a catamorphism, (| [_0, succ . \pi_2] |) where _0 is a constant function, . is the function composition, \pi_2 is a projection, and [] is a coproduct. Obviously, the type is 1 + A x A* -> Int ([A] -> Int in haskell). But, what about the actions? Behind these we have monads like algebraic structures. So, in the next expression f >>= g where we suppose that there is a T monad (endofunctor) involved, we can assume that f : a -> T b, g : b -> T c and g* : T b -> T c. therefore f >>= g \equiv g* . f in the Kleisli Star context. Is this right? If it is so, can I combine g*.f with a fork for example? gustavo
Gustavo Villavicencio wrote:
Hi all,
I am trying to understand the algebraic laws and operators behind a functional expression...
f >>= g \equiv g* . f
in the Kleisli Star context. Is this right?
Yep.
If it is so, can I combine g*.f with a fork for example?
What do you mean by a "fork"? Regards, Frank
Frank Atanassow wrote:
Gustavo Villavicencio wrote:
Hi all,
I am trying to understand the algebraic laws and operators behind a functional expression...
f >>= g \equiv g* . f
in the Kleisli Star context. Is this right?
Yep.
Oops, or rather, not quite. m >>= g means g* m The Kleisli composition (-)* . (-) is sometimes written as (@@): (@@) :: (Monad m) => (b -> m c) -> (a -> m b) -> (a -> m c) (f @@ g) x = let m = f x in m >>= g Regards, Frank
The Kleisli composition (-)* . (-) is sometimes written as (@@):
(@@) :: (Monad m) => (b -> m c) -> (a -> m b) -> (a -> m c) (f @@ g) x = let m = f x in m >>= g
Man, I can't get anything right today. I meant: (g @@ f) x = let m = f x in m >>= g Apologies for the flooding. Regards, Frank
participants (2)
-
Frank Atanassow -
Gustavo Villavicencio