<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>