tag:blogger.com,1999:blog-5336273.post2650246717230365328..comments2023-08-23T21:56:42.999+09:00Comments on A++ [Eric Torreborre's Blog]: Doing my homeworkUnknownnoreply@blogger.comBlogger7125tag:blogger.com,1999:blog-5336273.post-32952101478261638362011-06-26T09:39:30.377+09:002011-06-26T09:39:30.377+09:00Yes, Scalaz is still evolving. And ListApply is ba...Yes, Scalaz is still evolving. And ListApply is back as <a href="https://github.com/scalaz/scalaz/blob/scalaz7/core/src/main/scala/scalaz/Applic.scala" rel="nofollow">ListApplic</a> in Scalaz 7!Erichttps://www.blogger.com/profile/16484514586929815703noreply@blogger.comtag:blogger.com,1999:blog-5336273.post-74228316011927880612011-06-26T07:36:41.877+09:002011-06-26T07:36:41.877+09:00yes, I had not realised how old this post was. :-)...yes, I had not realised how old this post was. :-) I came to it while reading your recent post "The Essence of the Iterator Pattern", somehow...<br /><br />It looks like there have been a lot of changes since 2009. It is quite interesting to see those. I noticed for example that there is no ListApply either anymore.bblfishhttps://www.blogger.com/profile/04401485465826521210noreply@blogger.comtag:blogger.com,1999:blog-5336273.post-48624875553138244072011-06-26T07:28:07.967+09:002011-06-26T07:28:07.967+09:00I think that this all has been refactored into the...I think that this all has been refactored into the <a href="https://github.com/scalaz/scalaz/blob/master/core/src/main/scala/scalaz/Monoid.scala" rel="nofollow">Monoid</a> class, where Empty is Zero and Plus is Semigroup. So I guess that Monad would become MonadMonoid (but I can't find anything like that either).<br /><br />The "old" names come from the Haskell way of doing things: http://en.wikibooks.org/wiki/Haskell/MonadPlus, but the refactoring is better since it reuses the Monoid typeclass.Erichttps://www.blogger.com/profile/16484514586929815703noreply@blogger.comtag:blogger.com,1999:blog-5336273.post-34064931432173336672011-06-26T05:01:16.873+09:002011-06-26T05:01:16.873+09:00Can't find MonadPlus or MonadEmptyPlus when se...Can't find MonadPlus or MonadEmptyPlus when searching scalaz. Was that something you made up, or did I not find right? From the text at the top it sounds like it was something in the scalaz library...bblfishhttps://www.blogger.com/profile/04401485465826521210noreply@blogger.comtag:blogger.com,1999:blog-5336273.post-1462736634936719202009-01-07T09:20:00.000+09:002009-01-07T09:20:00.000+09:00@how.gaucheYou're right! This changes the type of ...@how.gauche<BR/><BR/>You're right! This changes the type of the return value of the mapFilter function but I should definitely add more laziness to my tool belt.<BR/><BR/>@Kris<BR/><BR/>Thanks Kris, I corrected that mistake.Erichttps://www.blogger.com/profile/16484514586929815703noreply@blogger.comtag:blogger.com,1999:blog-5336273.post-58529808947430506872009-01-07T01:08:00.000+09:002009-01-07T01:08:00.000+09:00Am I missing something here? The type signature of...Am I missing something here? The type signature of f in the following example doesn't seem to be correct:<BR/><I><BR/>When I bind a function to an Option, like Some(4), it is as if I'm doing:<BR/><BR/>val f = x => x + 2<BR/>bind(f, Some(4))<BR/></I><BR/>Shouldn't it be this?<BR/><I><BR/>val f = x => Some(x + 2)<BR/></I>Kris Nuttycombehttps://www.blogger.com/profile/06347383351250086727noreply@blogger.comtag:blogger.com,1999:blog-5336273.post-71162232437286094992009-01-07T01:01:00.000+09:002009-01-07T01:01:00.000+09:00Of course I wanted this function to be as efficien...<I>Of course I wanted this function to be as efficient as possible so it had to do the job in one pass. Otherwise, I could just use a combination of "map" and "filter" to do the trick:<BR/><BR/>def mapFilter[T, U](l: List[T], f: T =>Option[U]): List[U] = {<BR/> l.map(f(_)).filter(_.isDefined).map(_.get)<BR/>}<BR/><BR/>3 passes on the list, we can definitely do better than this!</I><BR/><BR/>Change "l" to "l.toStream" above and you should have a one-pass mapFilter. Voila!Unknownhttps://www.blogger.com/profile/12757268515031054537noreply@blogger.com