<div dir="auto">so what is the use of a Monad anyway if you are not lazy</div><div dir="auto">     is my question</div><div dir="auto"><br></div><div dir="auto">well it is supposed to isolate state changes ?</div><div dir="auto">     or simulate state or what is it</div><div dir="auto"><br></div><div dir="auto">you’ve got the state Monad </div><div dir="auto">     so every time you are going to mutate state you stop short ?</div><div dir="auto">     you do not mutate the state no</div><div dir="auto">     you make a new state like consing a new cons cell onto a list</div><div dir="auto">     which is not state</div><div dir="auto">          or something </div><div dir="auto">     and you return that new cons cell</div><div dir="auto">so every time you would have mutated the state you do not mutate </div><div dir="auto">     the state no you do the state Monad shuffle instead</div><div dir="auto"><br></div><div dir="auto">but often in the GUI you want the dependents to get the latest value</div><div dir="auto">     of a variable and you don’t care about the old value or</div><div dir="auto">     well it’s confusing </div><div dir="auto"><br></div><div dir="auto">so i am drawn to this whole Monad idea</div><div dir="auto">     maybe somehow it simplifies or something </div><div dir="auto">     i feel like maybe it does but when i look i can’t really see it</div><div dir="auto">     i can’t really see why     if you are not lazy</div><div dir="auto">     i want to see it but i keep coming up short</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 3, 2022 at 23:17 Kjell Godo <<a href="mailto:squeaklist@gmail.com">squeaklist@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">probably </div><div dir="auto">Association class>>inClass:c return:anObject</div><div dir="auto">     ^( ( anObject isKindOf:c )</div><div dir="auto">            ifTrue:[ self key:c value:anObject ]</div><div dir="auto">            itFalse:[ self error:’wrong type’ ] )</div><div dir="auto">would be the best place to do the type check</div><div dir="auto">so now Associations are Monads or Association subClass:#Monad or whatever</div><div dir="auto">so then</div><div dir="auto"><div dir="auto"><div dir="auto">Association>>=<< a1InputValua </div><div dir="auto">     ^( self class inClass:( self key )return:( a1InputValua value:( self value ) ) )</div></div></div><div dir="auto"><div dir="auto"><br></div><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Wed, Aug 3, 2022 at 22:53 Kjell Godo <<a href="mailto:squeaklist@gmail.com" target="_blank">squeaklist@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="auto">correct me if i am wrong but</div><div dir="auto"><br></div><div dir="auto">Association class>>return: anObject ^( self new value: anObject )</div><div dir="auto">Association>>=<< aOneInputValua </div><div dir="auto">     ^( self class return:( aOneInputValua value:( self value ) ) )</div><div dir="auto"><br></div><div dir="auto">where</div><div dir="auto">     ( aOneInputValua respondsTo:#value: )=true</div><div dir="auto"><br></div><div dir="auto">or</div><div dir="auto"><div dir="auto">Association class>>inClass:c return: anObject ^( self key:c value: anObject )</div><div dir="auto">Association>>=<< a2InputValua </div><div dir="auto">     ^( self class inClass:( self key )return:( </div><div dir="auto">             aOneInputValua value:( self key )value:( self value ) ) )</div><div dir="auto">             “where aOneInputValua uses its first input which is aClass to do some </div><div dir="auto">               kind of runtime type checking or like </div><div dir="auto">or maybe more like”</div><div dir="auto"><div dir="auto">Association class>>inClass:c return: anObject ^( self key:c value: anObject )</div><div dir="auto">Association>>=<< a1InputValua </div><div dir="auto">     ^( self class inClass:( self key )return:( </div><div dir="auto">          a1InputValua value:( </div><div dir="auto">               ( ( self value )isKindOf:( self key ) )</div><div dir="auto">                    ifTrue:[ self value ]ifFlase:[ self Error:’wrong type’ ] ) ) )</div><div dir="auto"><br></div><div dir="auto">you see the thing about Haskell is that it is completely lazy so there is no evaluation ordering that can be counted on so monads are a way to impose an execution order via function composition like</div><div dir="auto">( h value:( g value:( f value: x ) ) ) forces f to be done first and h last and g second</div><div dir="auto"><br></div><div dir="auto">but Smalltalk is not lazy , so there is a runtime ordering , so maybe Smalltalk can get an equivalent functionality out of just composing one input valua which is just composing one input functions , unless you want to insist on the >>isKindOf: type checking</div></div></div></div><div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 3, 2022 at 15:18 Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Tony,</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 1, 2022 at 1:48 AM Tony Garnock-Jones <<a href="mailto:tonyg@leastfixedpoint.com" target="_blank">tonyg@leastfixedpoint.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">On the Squeak Slack, @asarch asked "Are there monads in Squeak?"<br>
<br>
My answer was:<br>
<br>
Tricky question. Monads are a kind of design pattern reflecting a formal <br>
mathematical structure. Languages with static type systems are able to <br>
enforce some (but usually not all) of the mathematical monad laws; in <br>
Smalltalk, the type system is not strong enough to enforce any monad <br>
laws. So, monads do appear in Smalltalk in two ways: implicitly, in that <br>
theoretically every expression is "in the IO monad"; and explicitly, in <br>
examples such as the API on class Promise. Squeak's Promise class <br>
implements monadic operations and honours the monad laws.<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">I'd love to read a definition of the monad laws in plain English.  I think I understand promises perfectly well.  I've never understood what a monad is.  I'm unable to think algebraically very effectively but can think visually (for example I didn't understand the fourier transform algebraically (the double integral formulation), but understand it perfectly well as an infinite set of infinite integrals of the products of a sine wave with an arbitrary waveform (itself composed of sine waves)).  So if you can explain monads without recourse to algebra (but as much recourse to Smalltalk as you like) then you have my full attention.</div><div class="gmail_default" style="font-size:small"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">So TL;DR is "yes, but..." :-)<br>
<br>
Cheers,<br>
   Tony<br>
</blockquote></div><div><br></div><div dir="ltr"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div>
<br>
</blockquote></div></div>
</div>
</blockquote></div></div>
</blockquote></div></div>