juan_gandhi: (VP)
Take 1.
State[A,S] is just A×S, with a point s0:1→S.

- unit is provided by the point, A→A×S
- map is just a functoriality of cartesian product
- flatten is given by p1:S×S→S.

Take 2. OTOH, a pointed object S with a projection, p1:S×S→S, gives us a monoid.

What's the point then, why not take an arbitrary monoid M, and define State[A,M] using the monoidal properties of M?

Take 3.
It is (A×S)S, with the following operations:
- unit is given by currying id:A×S→A×S
- map is obvious
- flatten is given by some obvious and canonical (((A×S)S)×S)S → (A×S)S

So, the last one.
juan_gandhi: (VP)
so, can you write in Scala a web server using state monad, without any variable? :)
Kind of inverts your perception of what controls what, but who cares. It's just an FSM.

Is not it a nice exercise? :)

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

September 2025

S M T W T F S
 1 23456
78910111213
14151617181920
21222324252627
282930    

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 5th, 2025 01:28 am
Powered by Dreamwidth Studios