TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Why monads have not taken the Common Lisp world by storm (2008)

67 pointsby momo-reinaover 11 years ago

8 comments

marijnover 11 years ago
I [author] must say I&#x27;m slightly embarrassed to see this turn up here now. This is not a terribly deep or interesting post. Read <a href="http://marijnhaverbeke.nl/blog/tern.html" rel="nofollow">http:&#x2F;&#x2F;marijnhaverbeke.nl&#x2F;blog&#x2F;tern.html</a> or <a href="http://marijnhaverbeke.nl/blog/acorn.html" rel="nofollow">http:&#x2F;&#x2F;marijnhaverbeke.nl&#x2F;blog&#x2F;acorn.html</a> or <a href="http://marijnhaverbeke.nl/blog/browser-input-reading.html" rel="nofollow">http:&#x2F;&#x2F;marijnhaverbeke.nl&#x2F;blog&#x2F;browser-input-reading.html</a> instead.
评论 #6398863 未加载
评论 #6399076 未加载
评论 #6398688 未加载
Peakerover 11 years ago
&gt; It appears that in the presence of mutable state, a lot of the advantages of monads become moot.<p>In the simpler cases where use of monads can be replaced by simple mutable state -- you still lose out on the explicit types of the mutating vs. pure code.<p>For example, STM is possible because mutating effects are typed, and so can be ruled out of STM transactions.<p>And in the more complex monads (e.g: transformer stacks), mutable state is just not good enough. You can compose transformers to build things that mutable state simply cannot express, and you&#x27;d have to CPS transform your code and avoid mutable state to express those things.<p>For example, these two monads:<p><pre><code> ListT (ParsecT m) ParsecT (ListT m) </code></pre> Have no corresponding &quot;mutable state&quot; representations.
评论 #6399298 未加载
asgard1024over 11 years ago
Incidentally, I am just reading through All About Monads (<a href="http://www.haskell.org/haskellwiki/All_About_Monads" rel="nofollow">http:&#x2F;&#x2F;www.haskell.org&#x2F;haskellwiki&#x2F;All_About_Monads</a>) and his point 3 (&quot;Allow polymorphism on return types&quot;) is what confused me in this example:<p><pre><code> getAny :: (Random a) =&gt; State StdGen a getAny = do g &lt;- get (x,g&#x27;) &lt;- return $ random g put g&#x27; return x </code></pre> I was like.. how on Earth Haskell knows which function &quot;get&quot; should it call? I think this is a point which should be more stressed in the tutorials (I read Learn yourself a Haskell and glanced at couple of others..)
评论 #6399414 未加载
quartertoover 11 years ago
<p><pre><code> * Try to quickly write the whole thing as a single recursive descent parser. Note the exploding amount of ugliness. Give up. * Separate out the tokenizer (novel idea, huh?) to keep parser complexity down. Parser is still a mess. Ugh! * Play around with some CL parser frameworks. This helps a bit, but none of the systems I tried produce errors with enough information. * Remember the breeze it was to write a parser with the Haskell Parsec library. Mess around with monads for a while, learn a few things, but not how to write elegant parsers in Common Lisp. </code></pre> I&#x27;ve been going through these exact steps but in JavaScript. Writing languages is fun! And makes me want to kill things!
评论 #6399448 未加载
评论 #6399833 未加载
评论 #6399455 未加载
tonethemanover 11 years ago
I came here to make a joke about the real reason why was that no one understands them... but apparently everyone here does. Off to google monads for idiots...
评论 #6399142 未加载
评论 #6403763 未加载
dustingetzover 11 years ago
Nah, I think its just because they result in really nested types which is hard to keep track of without a really good type system. Using a single monad by itself like error or continuation is straightforward in Clojure; there are smart &amp; vocal people who do this. But the super awesome OMFG of monads is that they can be combined (e.g. parser = error + state), and this more or less requires abstracting in the type system to keep track of all the lambdas.
emiljbsover 11 years ago
&gt;That&#x27;s a little too blatantly useless to be interesting though. But note how ugly CL&#x27;s multiple namespaces make liftmaybe and its uses.<p>Oh yeah, incredibly ugly \s<p>OP, you may be interested in checking out LiL, the Lisp interface Library.<p><a href="https://github.com/fare/lisp-interface-library" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;fare&#x2F;lisp-interface-library</a>
ggchappellover 11 years ago
There is a point made here about how Haskell&#x27;s namespace handling makes monads easy, while CL&#x27;s makes them ugly. I don&#x27;t know enough about CL&#x27;s namespaces to understand this. Can someone explain?
评论 #6400099 未加载