tag:blogger.com,1999:blog-21500237.post7484465779104535299..comments2023-04-29T04:08:32.247-04:00Comments on Praise, Curse, and Recurse: The Polar Game in Haskell, Day 5: Array v. ListPaul R. Pottshttp://www.blogger.com/profile/04401509483200614806noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-21500237.post-44351925632013623432013-07-12T04:54:53.246-04:002013-07-12T04:54:53.246-04:00Wow, I'm so happy I found your blog. I was try...Wow, I'm so happy I found your blog. I was trying to model a game in haskell recently (I thought it would be a good training), and I stumble on a lot of things you did, like Arrays. <br /><br />I'll be sure to keep an eye on your articles now :)Cakehttps://www.blogger.com/profile/15667632757435972948noreply@blogger.comtag:blogger.com,1999:blog-21500237.post-81734744833315067702013-07-03T16:26:01.874-04:002013-07-03T16:26:01.874-04:00I am taking a sanity break from glowing screens ov...I am taking a sanity break from glowing screens over the Fourth of July Weekend -- I'll get back to looking at this next week.Paul R. Pottshttps://www.blogger.com/profile/04401509483200614806noreply@blogger.comtag:blogger.com,1999:blog-21500237.post-15646709806668756562013-07-03T15:09:11.700-04:002013-07-03T15:09:11.700-04:00Jeff, I'd love to see it! The feedback and com...Jeff, I'd love to see it! The feedback and comments are what makes this really valuable for me to blog about, rather than just writing it and keeping the code to myself. Maybe it will be the moment when I achieve monad enlightenment! If you like, send me an e-mail and I'll make it a real entry. Or actually if you have a Blogger account, I could enable you as a contributor on Blogger, at least I think I could.Paul R. Pottshttps://www.blogger.com/profile/04401509483200614806noreply@blogger.comtag:blogger.com,1999:blog-21500237.post-74814779743190047522013-07-03T14:39:04.509-04:002013-07-03T14:39:04.509-04:00I know this is your learning exercise, not mine......I know this is your learning exercise, not mine... but I ended up implementing scorekeeping with the Writer monad.<br /><br />Are you interested in seeing it, or do you not want the fun spoiled?<br />Jeff Licquiahttps://www.blogger.com/profile/02635921619274584156noreply@blogger.comtag:blogger.com,1999:blog-21500237.post-25224368643365105272013-07-03T13:25:23.956-04:002013-07-03T13:25:23.956-04:00Michael, I am vaguely aware of lenses as something...Michael, I am vaguely aware of lenses as something I would like to master... and I've still got to get a better handle on monads. I feel like I understand them when explained but attempting to use one in my own code outside of IO has been a complete failure. I will take a look at that video.Paul R. Pottshttps://www.blogger.com/profile/04401509483200614806noreply@blogger.comtag:blogger.com,1999:blog-21500237.post-15361481365782808002013-07-03T13:23:40.374-04:002013-07-03T13:23:40.374-04:00Thanks, Jeff. Sorry to hear about the insomnia! Bu...Thanks, Jeff. Sorry to hear about the insomnia! But I'm happy for the help.<br /><br />Yes, when I got rid of Edge it broke a lot of things including my collide and slide methods, and that was not immediately apparent. I had to rewrite that extensively. I'm keeping the github version up to date: https://github.com/paulrpotts/arctic-slide-haskell<br /><br />but I'm not going to go back and revise all the blog posts as I go -- that way lies madness : )Paul R. Pottshttps://www.blogger.com/profile/04401509483200614806noreply@blogger.comtag:blogger.com,1999:blog-21500237.post-54650104164371231542013-07-03T06:50:01.353-04:002013-07-03T06:50:01.353-04:00I think (as something of a Haskell newbie myself, ...I think (as something of a Haskell newbie myself, so take this with a grain of salt) what you want to be looking at is lenses to simplify your board manipulation code.<br /><br />http://www.youtube.com/watch?v=cefnmjtAolY is a presentation from Edward Kmett about them.Michael Alan Dormanhttps://www.blogger.com/profile/16555925667421988971noreply@blogger.comtag:blogger.com,1999:blog-21500237.post-37763889511065192052013-07-03T06:44:24.867-04:002013-07-03T06:44:24.867-04:00Took care of a little insomnia by fixing your list...Took care of a little insomnia by fixing your list implementation. There are two problems.<br /><br />First: the bad patterns error comes from two places where apply_view_to_row wasn't renamed to account for the "_list_" implementation. A quick search-n-replace fixed that right up.<br /><br />After that, the list version "steals" tiles; each eastward move at the beginning chops a tile off the end, and eventually the moves collide with the shortened list and things blow up. I remembered you used to have Edge tiles, but decided to get rid of them, so I guessed that the "init update" calls in apply_view_list_to_row were for chopping off the Edge tile that's no longer there, so I just took out the "init" call. Either my hunch was right, or I'm just lucky. :-)<br /><br />After those two fixes, the list and array implementations seem to produce identical output. I know you're more a fan of the array version, but I want to see the all-important performance evaluation later, which won't happen with broken lists.<br /><br />I really like the new view functions. I still tend to be leery of the "case dir of..." thing happening over and over, but am getting tired again (yay! die, insomnia!), so not seeing the problem clearly.<br /><br />Also, the pretty printer stuff is screaming for something like a fold or map, but I'm not seeing how that improves things at the moment. Maybe some sleep will bring clarity.Jeff Licquiahttps://www.blogger.com/profile/02635921619274584156noreply@blogger.com