Re: [Haskell-cafe] XCode Dependency for HP on Mac
On 7/27/11, Richard O'Keefe o...@cs.otago.ac.nz wrote: A quick web search for Mac OS X gcc binary turned up http://hpc.sourceforge.net/index.php with binary releases of GCC 4.6 for Lion and Snow Leopard. This requires Developer Tools, but that isn't XCode, and it's on the OS X DVD. Developer Tools is actually what the HP requires. I think it might be under the XCode umbrella. Still, the Macbook Air doesn't come with an install for XCode or Developer Tools. How can gcc require this stuff, though? Doesn't gcc pre-date all of this stuff by a decade and a half? Thanks for your time, Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] XCode Dependency for HP on Mac
27/07/2011 4:25 PM, Tom Murphy kirjutas: On 7/27/11, Richard O'Keefe o...@cs.otago.ac.nz wrote: A quick web search for Mac OS X gcc binary turned up http://hpc.sourceforge.net/index.php with binary releases of GCC 4.6 for Lion and Snow Leopard. This requires Developer Tools, but that isn't XCode, and it's on the OS X DVD. Developer Tools is actually what the HP requires. I think it might be under the XCode umbrella. Still, the Macbook Air doesn't come with an install for XCode or Developer Tools. How can gcc require this stuff, though? Doesn't gcc pre-date all of this stuff by a decade and a half? I believe it's to link in with all the very Mac-specific APIs and so on. Perhaps only OS X knows how to link a binary just right, or something. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Idiomatic ways to make all instances of a certain class also instances of another?
On Tue, Jul 26, 2011 at 11:14 PM, Alexander Solla alex.so...@gmail.com wrote: data OrderType = Market Size | Limit LimitPrice Expiration Size | Stop (Either Percent Price) newtype Sell = Sell OrderType newtype Buy = Buy OrderType newtype Order = Order (Either Buy Sell) size :: Order - Int size (Order (Left (Buy (Market s))) = s size (Order (Left (Buy (Limit _ _ s))) = s etc. Aah, thank you - this is really neat. So now, I can write (for instance) an Eq instance for OrderType and use deriving (Eq) on the newtypes that wrap it, and my Order can be a concrete type, but still encapsulates all the different types of order. Thank you! Tim Thank you ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] XCode Dependency for HP on Mac
Okay, you're all scaring me again. I'm supposed to be teaching a class this next school year, on Haskell programming, to middle schoolers aged 12 to 13. Some of the students will be using Macs, and I'm again very confused about the situation of the Haskell platform on MacOS. There are different installation requirements for different versions of the operating system? Is there a good complete source somewhere for information on how to get this installed, across different versions of MacOS, with a minimum of needing people to have the install disks that came with their computer? Alternatively, maybe it would it be easier to have the Mac users install VMWare's free version and I can just have them install Windows or Linux in that? Or does it also have weird dependency issues like this, too? -- Chris Smith ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] XCode Dependency for HP on Mac
On Wed, Jul 27, 2011 at 8:09 AM, Chris Smith cdsm...@gmail.com wrote: Alternatively, maybe it would it be easier to have the Mac users install VMWare's free version and I can just have them install Windows or Linux in that? Or does it also have weird dependency issues like this, too? (Perhaps wandering slightly O/T, but...) Having done some teaching in similar circumstances before (although not with Haskell), I'd highly recommend this approach. In fact, I'd probably have all the students, regardless of OS install VMWare or VirtualBox, and then distribute a VM image with the Haskell Platform and any other tools they need preinstalled. It means a bit of extra preparation, but it'll allow you to get to the interesting bit of the class more quickly and with less frustration on the part of both yourself and your students. Hope this helps. Chers, Tim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] XCode Dependency for HP on Mac
On Wed, Jul 27, 2011 at 05:55, Tom Murphy wrote: This may sound ignorant because, well, it is ignorant: I know very little about the underlying mechanics here. Installing the Haskell Platform currently requires XCode developer tools. To get XCode on my 10.6 machine, I... ... will check out the related discussion: http://thread.gmane.org/gmane.comp.lang.haskell.cafe/89745 Regards, Sean ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stack space overflow in HaskellNet
This should be mapM_ and 'ghc -Wall' spots this problem since 6.12. The compiler (7.04) doesn't tell me anything about it. Henning It seems that it is no longer part of -Wall. Indeed, that's not part of -Wall. http://www.haskell.org/ghc/docs/7.0.4/html/users_guide/options-sanity.html Am I the only one who assumed so far that Wall turned on all existing warnings ? From the doc : -Wall: Turns on all warning options that indicate potentially suspicious code. The warnings that are not enabled by -Wall are -fwarn-tabs, -fwarn-incomplete-record-updates, -fwarn-monomorphism-restriction, -fwarn-unused-do-bind, and -fwarn-implicit-prelude. -w:Turns off all warnings, including the standard ones and those that -Wall doesn't enable. If there were no backward compatibility issues, I'd prefer to just see -w and -Wall swaped. -w would mean We let the GHC team decide what subset of warnings they really want us to observe, and -Wall would mean We really want them all. -- Paul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stack space overflow in HaskellNet
On 27 July 2011 17:42, Paul R paul.r...@gmail.com wrote: This should be mapM_ and 'ghc -Wall' spots this problem since 6.12. The compiler (7.04) doesn't tell me anything about it. Henning It seems that it is no longer part of -Wall. Indeed, that's not part of -Wall. http://www.haskell.org/ghc/docs/7.0.4/html/users_guide/options-sanity.html Am I the only one who assumed so far that Wall turned on all existing warnings ? From the doc : -Wall: Turns on all warning options that indicate potentially suspicious code. The warnings that are not enabled by -Wall are -fwarn-tabs, -fwarn-incomplete-record-updates, -fwarn-monomorphism-restriction, -fwarn-unused-do-bind, and -fwarn-implicit-prelude. -w: Turns off all warnings, including the standard ones and those that -Wall doesn't enable. If there were no backward compatibility issues, I'd prefer to just see -w and -Wall swaped. -w would mean We let the GHC team decide what subset of warnings they really want us to observe, and -Wall would mean We really want them all. Ummm, going by what you quoted, -w _disables_ warnings, which isn't at all like you say you want it to be! ;-) -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stack space overflow in HaskellNet
Hem hem ... I should never try to write anything sensible before putting my thick glasses. -w does not turn ON all warnings, but turns them OFF, so my previous comment regarding swapping its definition with -Wall is just nonsense. Sorry for the noise. Still, do you think there could be room for a -Wsuspicious that would be defined as current -Wall, and for a more intuitive meaning for -Wall : turns on really all warnings ? Paul Indeed, that's not part of -Wall. Paul http://www.haskell.org/ghc/docs/7.0.4/html/users_guide/options-sanity.html Paul Am I the only one who assumed so far that Wall turned on all Paul existing warnings ? Paul From the doc : Paul -Wall: Turns on all warning options that indicate potentially Paul suspicious code. The warnings that are not enabled by -Wall Paul are -fwarn-tabs, -fwarn-incomplete-record-updates, -fwarn-monomorphism-restriction, -fwarn-unused-do-bind, Paul and -fwarn-implicit-prelude. Paul -w: Turns off all warnings, including the standard ones and those Paul that -Wall doesn't enable. Paul If there were no backward compatibility issues, I'd prefer to just Paul see -w and -Wall swaped. -w would mean We let the GHC team decide Paul what subset of warnings they really want us to observe, and -Wall Paul would mean We really want them all. -- Paul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stack space overflow in HaskellNet
On 27 July 2011 17:56, Paul R paul.r...@gmail.com wrote: Hem hem ... I should never try to write anything sensible before putting my thick glasses. -w does not turn ON all warnings, but turns them OFF, so my previous comment regarding swapping its definition with -Wall is just nonsense. Sorry for the noise. Still, do you think there could be room for a -Wsuspicious that would be defined as current -Wall, and for a more intuitive meaning for -Wall : turns on really all warnings ? Definitely. -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Fwd: C9 video in the Monadic Design Patterns for the Web series
Dear Haskellians, A new C9 video in the series! So, you folks already know most of this... except for maybe the generalization of the Conway construction! Best wishes, --greg -- Forwarded message -- From: Charles Torre ... Date: Tue, Jul 26, 2011 at 1:12 PM Subject: C9 video in the Monadic Design Patterns for the Web series To: Meredith Gregory lgreg.mered...@gmail.com Cc: Brian Beckman ... And we’re live! ** ** http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Greg-Meredith-Monadic-Design-Patterns-for-the-Web-4-of-n C ** ** *From:* Charles Torre *Sent:* Tuesday, July 26, 2011 11:51 AM *To:* 'Meredith Gregory' *Cc:* Brian Beckman *Subject:* C9 video in the Monadic Design Patterns for the Web series ** ** Here it ‘tis: ** ** Greg Meredith http://biosimilarity.blogspot.com/, a mathematician and computer scientist, has graciously agreed to do a C9 lecture series covering monadic design principles applied to web development. You've met Greg before in a Whiteboard jam session with Brian Beckmanhttp://channel9.msdn.com/shows/Going+Deep/E2E-Whiteboard-Jam-Session-with-Brian-Beckman-Greg-Meredith-Monads-and-Coordinate-Systems/ . The fundamental concept here is the monad, and Greg has a novel and conceptually simplified explanation of what a monad is and why it matters. This is a very important and required first step in the series since the whole of it is about the application of monadic composition to real world web development. In *part 4, *Greg primarily focuses on the idea that *a monad is really an API* -- it's a view onto the organization of data and control structures, not those structures themselves. In OO terms, it's an *interface*. To make this point concrete Greg explores one of the simplest possible data structures that supports at least two different, yet consistent interpretations of the same API. The structure used, Conway's partisan gameshttp://mathworld.wolfram.com/ConwayGame.html, turned out to be tailor-made for this investigation. Not only does this data structure have the requisite container-like shape, it provided opportunities to see just what's necessary in a container to implement the monadic interface. ** ** Running throughout the presentation is a more general comparison of reuse between an OO approach versus a more functional one. When the monadic API is mixed into the implementing structure we get less reuse than when the implementing structure is passed as a type parameter. Finally, doing the work put us in a unique position to see not just how to generalize Conway's construction, *monadically*, but the underlying pattern which allows the generalization to suggest itself. See *part 1 http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Greg-Meredith-Monadic-Design-Patterns-for-the-Web-Introduction-to-Monads *See *part 2http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Greg-Meredith-Monadic-Design-Patterns-for-the-Web-2-of-n ** *See* part 3http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Greg-Meredith-Monadic-Design-Patterns-for-the-Web-3-of-n * ** -- L.G. Meredith Managing Partner Biosimilarity LLC 7329 39th Ave SW Seattle, WA 98136 +1 206.650.3740 http://biosimilarity.blogspot.com -- L.G. Meredith Managing Partner Biosimilarity LLC 1219 NW 83rd St Seattle, WA 98117 +1 206.650.3740 http://biosimilarity.blogspot.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Fwd: C9 video in the Monadic Design Patterns for the Web series
On 27 July 2011 10:31, Greg Meredith lgreg.mered...@biosimilarity.com wrote: Dear Haskellians, A new C9 video in the series! So, you folks already know most of this... except for maybe the generalization of the Conway construction! Best wishes, --greg Thanks for the heads up! I love these videos. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Typeclasses, data, constructors
Hi everyone! I have data declaration like this: data MyTable = MyTableOne Int String | MyTableTwo Int String String and function that insert new row in tables: newRow :: MyTable - IO Int newRow (MyTableOne fld1 fld2 ) = . newRow (MyTableTwo fld1 fld2 fld3 ) = .. That work perfectly, I enjoy it. But now I want to get rows, and I don't know what to do :( I want func something like this: getRow :: Int - [MyTable] - what should I write here ? Possibly use this function: getRow 23 :: MyTableTwo (like haskell function Read for example: read 7 :: Int) I try to use typeclasses, class GetRow a where hasID :: Int - IO a instance GetRow MyTableOne where hasID myid = return [(MyTableOne 1 name)] instance GetRow MyTableTwo where hasID myid = return [(MyTableTwo 1 name path)] But I have error: Not in scope: type constructor or class `MyTableOne' make: *** [Foo.so] Error 1 Not in scope: type constructor or class `MyTableTwo' make: *** [Foo.so] Error 1 I ask you to suggest me right way in my efforts Cheers! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] XCode Dependency for HP on Mac
XCode 4.1 is free on the Mac App Store; but that requires OSX 10.7; they seem to have removed Xcode 4 that used to be $5 there. I can still download Xcode 4 on my developer account, but that isn't available to people who don't pay up. I think Apple is making a good case here for bundling gcc and friends with Haskell Platform. Niklas 2011/7/27 Chris Smith cdsm...@gmail.com: Okay, you're all scaring me again. I'm supposed to be teaching a class this next school year, on Haskell programming, to middle schoolers aged 12 to 13. Some of the students will be using Macs, and I'm again very confused about the situation of the Haskell platform on MacOS. There are different installation requirements for different versions of the operating system? Is there a good complete source somewhere for information on how to get this installed, across different versions of MacOS, with a minimum of needing people to have the install disks that came with their computer? Alternatively, maybe it would it be easier to have the Mac users install VMWare's free version and I can just have them install Windows or Linux in that? Or does it also have weird dependency issues like this, too? -- Chris Smith ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] XCode Dependency for HP on Mac - old XCode versions
To get XCode on my 10.6 machine, I... I had quite a hunt recently to find the most recent XCode for my not-so-recent mac... so I'll share what I found: If you are a registered developer (free reg is fine) with apple go to http://connect.apple.com/ Hit the link to developer tools, and you will find a fairly comprehensive set of XCode versions. Then you just have to work out the latest one for your OS (3.1.4 for Leopard; I assume any 3.2 is fine with SL; looks like 4.0 is missing from list as jumps to 4.1 for Lion). Not that it solves the 4G download for 3.2.x, but hopefully useful for anyone looking older versions, which can be quite difficult to find if you try to navigate from developer.apple.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Ur tutorial, and a challenge
On 19 July 2011 17:22, Adam Chlipala ad...@impredicative.com wrote: http://www.impredicative.com/ur/demo/crud1.html The example involves a library component encapsulating functionality like that of Ruby on Rails's scaffolding: automatic generation of a standard web-based admin interface to an SQL database table. The Ur/Web version uses static typing to guarantee that any applications generated by this component are free of injection attacks and other generic problems. The guarantees apply both to app communication with server-side pieces (e.g., static type-checking of SQL) and client-side pieces (e.g., static type-checking of HTML). This is not done by type-checking individual invocations of the admin-interface component. Rather, the component is checked at a static type which guarantees correct operation for _any_specialization_parameters_. So, the challenge is, can this functionality be implemented in Haskell (GHC extensions fair game, any web framework allowed)? Is TemplateHaskell fair game? Because if so these problems are not hard. Yesod employs static typing for templates. HaskellDB achieves injectionless static type checking even without TemplateHaskell, and templatepg has type safe SQL queries based on parsing the SQL itself and inspecting the types involved by asking the PostgreSQL server directly at compile time. This doesn't protect you from runtime changes to the DB schema of course. I think there's a lot of interesting work to be done based on inspecting the data base schema by querying the database server and analyzing queries at compile time. Ferry, anyone? Statically avoiding SQL and HTML injection/type problems are trivial problems that have been solved since forever ago, I don't think those are Ur's best secret weapon (dependent types goes without saying). Of Ur I particularly like that you can write Ur that will be compiled to JS. That is something that is hard to do in Haskell right now (ghcjs is a great base, but it's alpha). I don't anyone will spend time to answer the crud challenge. If so, how pretty is it? :) Anything's gonna be prettier than what you've presented there. ;-) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Ur tutorial, and a challenge
Excerpts from Christopher Done's message of Wed Jul 27 12:26:08 +0200 2011: Is TemplateHaskell fair game? Because if so these problems are not hard. Yesod employs static typing for templates. HaskellDB achieves injectionless static type checking even without TemplateHaskell, and templatepg has type safe SQL queries based on parsing the SQL itself and inspecting the types involved by asking the PostgreSQL server directly at compile time. Which doesn't work because the result of querying is not accurate enough (or has not been in the past?).. Eg see here - Only DB2 seems to return usable results. http://www.haskell.org/haskellwiki/MetaHDBC The main problem is: Does a field return a nullable value (thus Maybe?) However if that changed I want to know about it :) If you know databases inside out than you also know that its sometimes faster to run a sophisticated custom query than doing all the work in Haskell (after sending data over network). Don't think HaskellDB supports all of those features. I imagine that its easier to extend urweb in this regard. However there are a lot new SQL based Haskell libraries I don't know yet. The difference is that Haskell's type system is bad at creating temporary types unless you go the HList route? http://hackage.haskell.org/package/records Does this library address this? While Haskell's type system is known to be touring complete this doesn't mean that such code is easy to maintain. I'm no longer up to date so all I said may be partially wrong :( Marc Weber ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] XCode Dependency for HP on Mac
http://developer.apple.com/devcenter/mac/index.action Go there. Log in (free account). Download Xcode 3.2.6. If you want the full complement of blessed UNIX-y tools, you have to get Xcode. Bundling things with the HP is just going to bloat that download and confuse new users more (and my god, the dep-chasing... the number of libs that might have to be piled in on top of it could be absurd). The Dev Tools are standard fare for most everything now. They're my first install on a new system. As much as I would love to be able to just install the UNIX Development tree (really just hardlinks from the Developer folder) and skip all the Xcode Essentials tree, that's just not how it's set up. Apple has to appeal to the masses, and the masses are writing iPhone apps and C in an IDE. 3.2.6 is your best bet now, anyway, since Xcode 4 introduced one or two annoying kinks (though no breakages unless you use 4.2). Also, remind me never to post to the list right after work. I worry I come off as not a very nice person, at all. :/ On Jul 27, 2011, at 3:30 AM, Sean Leather wrote: On Wed, Jul 27, 2011 at 05:55, Tom Murphy wrote: This may sound ignorant because, well, it is ignorant: I know very little about the underlying mechanics here. Installing the Haskell Platform currently requires XCode developer tools. To get XCode on my 10.6 machine, I... ... will check out the related discussion: http://thread.gmane.org/gmane.comp.lang.haskell.cafe/89745 Regards, Sean ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe Jack Henahan jhena...@uvm.edu == Computer science is no more about computers than astronomy is about telescopes. -- Edsger Dijkstra == 398E692F.gpg Description: application/apple-msg-attachment PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Ur tutorial, and a challenge
Christopher Done wrote: On 19 July 2011 17:22, Adam Chlipalaad...@impredicative.com wrote: http://www.impredicative.com/ur/demo/crud1.html [...] This is not done by type-checking individual invocations of the admin-interface component. Rather, the component is checked at a static type which guarantees correct operation for _any_specialization_parameters_. So, the challenge is, can this functionality be implemented in Haskell (GHC extensions fair game, any web framework allowed)? Is TemplateHaskell fair game? Sure. Because if so these problems are not hard. Maybe, but I don't think you've outlined any solutions that meet my criteria. The key property is what I've highlighted in my self-quote above: the challenge is to type-check _the_code_generator_, not just the individual programs it generates. I want a static theorem that every program coming out of the code generator will play by the rules. Even rules that are trivial to check for individual programs (e.g., no code injection attacks because you follow a simple AST discipline) become quite non-trivial when you are reasoning about the behavior of a code generator. Also, this simple property gets more interesting when you also want to enforce statically, e.g., that all SQL queries are type-correct w.r.t. the database. Yesod employs static typing for templates. Does this static type system support metaprogramming strong enough to implement my challenge problem with the level of static guarantee for all specialization parameters that I ask for? HaskellDB achieves injectionless static type checking even without TemplateHaskell Right. Easy to do for individual programs, harder to do for a code generator. and templatepg has type safe SQL queries based on parsing the SQL itself and inspecting the types involved by asking the PostgreSQL server directly at compile time. Ur/Web does this, too, as a kind of belt-and-suspenders measure. This alone provides no support for static checking of metaprograms. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Ur tutorial, and a challenge
On 27 July 2011 13:58, Adam Chlipala ad...@impredicative.com wrote: Maybe, but I don't think you've outlined any solutions that meet my criteria. The key property is what I've highlighted in my self-quote above: the challenge is to type-check _the_code_generator_, not just the individual programs it generates. I want a static theorem that every program coming out of the code generator will play by the rules. No, I didn't outline any solutions for that criteria. I'm not competent to answer that. Yesod employs static typing for templates. Does this static type system support metaprogramming strong enough to implement my challenge problem with the level of static guarantee for all specialization parameters that I ask for? Again I don't really know what you're talking about so I'll drop it. Agda is still on my list of things to learn. As is Ur. But that order seems appropriate. Ciao! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Fwd: C9 video in the Monadic Design Patterns for the Web series
I'm always glad to see videos like this. I wish more people could have that much fun playing with math ;). It wouldn't really be suitable for your application but another interesting generalization is to insert the 'Either' at the top level: data ConwayT m a = Pure a | ConwayT { runLeftConwayT :: m (ConwayT m a) , runRightConwayT :: m (ConwayT m a) } Using this construction, the handedness of the structure doesn't appear until you start implementing binary operations on games, so there is a unique monad structure instead of just a unique bind/join: instance Functor m = Monad (ConwayT m) where return = Pure Pure x = f = f x ConwayT l r = f= ConwayT (fmap (= f) l) (fmap (= f) r) but there are then (at least) two versions of every monoid structure. Given that monoidal structures such as addition and multiplication are the main purpose of a calculator it's probably simpler in this case to just give up the 'unit' as you chose to do. On the other hand, if for some reason a monadic structure is the extent of one's interest then this version definitely simplifies that structure. -- James On Jul 27, 2011, at 4:31 AM, Greg Meredith wrote: Dear Haskellians, A new C9 video in the series! So, you folks already know most of this... except for maybe the generalization of the Conway construction! Best wishes, --greg -- Forwarded message -- From: Charles Torre ... Date: Tue, Jul 26, 2011 at 1:12 PM Subject: C9 video in the Monadic Design Patterns for the Web series To: Meredith Gregory lgreg.mered...@gmail.com Cc: Brian Beckman ... And we’re live! http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Greg-Meredith-Monadic-Design-Patterns-for-the-Web-4-of-n C From: Charles Torre Sent: Tuesday, July 26, 2011 11:51 AM To: 'Meredith Gregory' Cc: Brian Beckman Subject: C9 video in the Monadic Design Patterns for the Web series Here it ‘tis: Greg Meredith, a mathematician and computer scientist, has graciously agreed to do a C9 lecture series covering monadic design principles applied to web development. You've met Greg before in a Whiteboard jam session with Brian Beckman. The fundamental concept here is the monad, and Greg has a novel and conceptually simplified explanation of what a monad is and why it matters. This is a very important and required first step in the series since the whole of it is about the application of monadic composition to real world web development. In part 4, Greg primarily focuses on the idea that a monad is really an API -- it's a view onto the organization of data and control structures, not those structures themselves. In OO terms, it's an interface. To make this point concrete Greg explores one of the simplest possible data structures that supports at least two different, yet consistent interpretations of the same API. The structure used, Conway's partisan games, turned out to be tailor-made for this investigation. Not only does this data structure have the requisite container-like shape, it provided opportunities to see just what's necessary in a container to implement the monadic interface. Running throughout the presentation is a more general comparison of reuse between an OO approach versus a more functional one. When the monadic API is mixed into the implementing structure we get less reuse than when the implementing structure is passed as a type parameter. Finally, doing the work put us in a unique position to see not just how to generalize Conway's construction, monadically, but the underlying pattern which allows the generalization to suggest itself. See part 1 See part 2 See part 3 -- L.G. Meredith Managing Partner Biosimilarity LLC 7329 39th Ave SW Seattle, WA 98136 +1 206.650.3740 http://biosimilarity.blogspot.com -- L.G. Meredith Managing Partner Biosimilarity LLC 1219 NW 83rd St Seattle, WA 98117 +1 206.650.3740 http://biosimilarity.blogspot.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Fwd: C9 video in the Monadic Design Patterns for the Web series
For any who are interested, here's a quick and dirty Haskell version of the generalized Conway game monad transformer described in the video. It uses two newtypes, L and R, to select from two possible implementations of the Monad class. (all the LANGUAGE pragmas are just to support a derived Show instance to make it easier to play around with in GHCi - the type and monad itself are H98) -- James {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} module Monads.Conway where import Control.Applicative import Control.Monad data ConwayT m a = ConwayT { runLeftConwayT :: m (Either a (ConwayT m a)) , runRightConwayT :: m (Either a (ConwayT m a)) } deriving instance (Eq a, Eq (m (Either a (ConwayT m a = Eq (ConwayT m a) deriving instance (Ord a, Ord (m (Either a (ConwayT m a = Ord (ConwayT m a) deriving instance (Read a, Read (m (Either a (ConwayT m a = Read (ConwayT m a) deriving instance (Show a, Show (m (Either a (ConwayT m a = Show (ConwayT m a) instance Functor m = Functor (ConwayT m) where fmap f (ConwayT l r) = ConwayT (fmap g l) (fmap g r) where g (Left x) = Left (f x) g (Right x) = Right (fmap f x) bind liftS (ConwayT l r) f = ConwayT (liftS g l) (liftS g r) where g (Left x) = Right (f x) g (Right x) = Right (bind liftS x f) newtype L f a = L { runL :: f a } deriving (Eq, Ord, Read, Show) instance Functor m = Functor (L (ConwayT m)) where fmap f (L x) = L (fmap f x) instance MonadPlus m = Monad (L (ConwayT m)) where return x = L (ConwayT (return (Left x)) mzero) L x = f = L (bind liftM x (runL . f)) newtype R f a = R { runR :: f a } deriving (Eq, Ord, Read, Show) instance Functor m = Functor (R (ConwayT m)) where fmap f (R x) = R (fmap f x) instance MonadPlus m = Monad (R (ConwayT m)) where return x = R (ConwayT (return (Left x)) mzero) R x = f = R (bind liftM x (runR . f)) On Jul 27, 2011, at 4:31 AM, Greg Meredith wrote: Dear Haskellians, A new C9 video in the series! So, you folks already know most of this... except for maybe the generalization of the Conway construction! Best wishes, --greg -- Forwarded message -- From: Charles Torre ... Date: Tue, Jul 26, 2011 at 1:12 PM Subject: C9 video in the Monadic Design Patterns for the Web series To: Meredith Gregory lgreg.mered...@gmail.com Cc: Brian Beckman ... And we’re live! http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Greg-Meredith-Monadic-Design-Patterns-for-the-Web-4-of-n C From: Charles Torre Sent: Tuesday, July 26, 2011 11:51 AM To: 'Meredith Gregory' Cc: Brian Beckman Subject: C9 video in the Monadic Design Patterns for the Web series Here it ‘tis: Greg Meredith, a mathematician and computer scientist, has graciously agreed to do a C9 lecture series covering monadic design principles applied to web development. You've met Greg before in a Whiteboard jam session with Brian Beckman. The fundamental concept here is the monad, and Greg has a novel and conceptually simplified explanation of what a monad is and why it matters. This is a very important and required first step in the series since the whole of it is about the application of monadic composition to real world web development. In part 4, Greg primarily focuses on the idea that a monad is really an API -- it's a view onto the organization of data and control structures, not those structures themselves. In OO terms, it's an interface. To make this point concrete Greg explores one of the simplest possible data structures that supports at least two different, yet consistent interpretations of the same API. The structure used, Conway's partisan games, turned out to be tailor-made for this investigation. Not only does this data structure have the requisite container-like shape, it provided opportunities to see just what's necessary in a container to implement the monadic interface. Running throughout the presentation is a more general comparison of reuse between an OO approach versus a more functional one. When the monadic API is mixed into the implementing structure we get less reuse than when the implementing structure is passed as a type parameter. Finally, doing the work put us in a unique position to see not just how to generalize Conway's construction, monadically, but the underlying pattern which allows the generalization to suggest itself. See part 1 See part 2 See part 3 -- L.G. Meredith Managing Partner Biosimilarity LLC 7329 39th Ave SW Seattle, WA 98136 +1 206.650.3740 http://biosimilarity.blogspot.com -- L.G. Meredith Managing Partner Biosimilarity LLC 1219 NW 83rd St Seattle, WA 98117 +1 206.650.3740
Re: [Haskell-cafe] Fwd: C9 video in the Monadic Design Patterns for the Web series
Dang, I should have played with both versions before sending this. The 'R' instance has a very obvious error: return x = R (ConwayT (return (Left x)) mzero) should be changed to return x = R (ConwayT mzero (return (Left x))) Sorry! -- James On Jul 27, 2011, at 9:28 AM, James Cook wrote: For any who are interested, here's a quick and dirty Haskell version of the generalized Conway game monad transformer described in the video. It uses two newtypes, L and R, to select from two possible implementations of the Monad class. (all the LANGUAGE pragmas are just to support a derived Show instance to make it easier to play around with in GHCi - the type and monad itself are H98) -- James {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} module Monads.Conway where import Control.Applicative import Control.Monad data ConwayT m a = ConwayT { runLeftConwayT :: m (Either a (ConwayT m a)) , runRightConwayT :: m (Either a (ConwayT m a)) } deriving instance (Eq a, Eq (m (Either a (ConwayT m a = Eq (ConwayT m a) deriving instance (Ord a, Ord (m (Either a (ConwayT m a = Ord (ConwayT m a) deriving instance (Read a, Read (m (Either a (ConwayT m a = Read (ConwayT m a) deriving instance (Show a, Show (m (Either a (ConwayT m a = Show (ConwayT m a) instance Functor m = Functor (ConwayT m) where fmap f (ConwayT l r) = ConwayT (fmap g l) (fmap g r) where g (Left x) = Left (f x) g (Right x) = Right (fmap f x) bind liftS (ConwayT l r) f = ConwayT (liftS g l) (liftS g r) where g (Left x) = Right (f x) g (Right x) = Right (bind liftS x f) newtype L f a = L { runL :: f a } deriving (Eq, Ord, Read, Show) instance Functor m = Functor (L (ConwayT m)) where fmap f (L x) = L (fmap f x) instance MonadPlus m = Monad (L (ConwayT m)) where return x = L (ConwayT (return (Left x)) mzero) L x = f = L (bind liftM x (runL . f)) newtype R f a = R { runR :: f a } deriving (Eq, Ord, Read, Show) instance Functor m = Functor (R (ConwayT m)) where fmap f (R x) = R (fmap f x) instance MonadPlus m = Monad (R (ConwayT m)) where return x = R (ConwayT (return (Left x)) mzero) R x = f = R (bind liftM x (runR . f)) On Jul 27, 2011, at 4:31 AM, Greg Meredith wrote: Dear Haskellians, A new C9 video in the series! So, you folks already know most of this... except for maybe the generalization of the Conway construction! Best wishes, --greg -- Forwarded message -- From: Charles Torre ... Date: Tue, Jul 26, 2011 at 1:12 PM Subject: C9 video in the Monadic Design Patterns for the Web series To: Meredith Gregory lgreg.mered...@gmail.com Cc: Brian Beckman ... And we’re live! http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Greg-Meredith-Monadic-Design-Patterns-for-the-Web-4-of-n C From: Charles Torre Sent: Tuesday, July 26, 2011 11:51 AM To: 'Meredith Gregory' Cc: Brian Beckman Subject: C9 video in the Monadic Design Patterns for the Web series Here it ‘tis: Greg Meredith, a mathematician and computer scientist, has graciously agreed to do a C9 lecture series covering monadic design principles applied to web development. You've met Greg before in a Whiteboard jam session with Brian Beckman. The fundamental concept here is the monad, and Greg has a novel and conceptually simplified explanation of what a monad is and why it matters. This is a very important and required first step in the series since the whole of it is about the application of monadic composition to real world web development. In part 4, Greg primarily focuses on the idea that a monad is really an API -- it's a view onto the organization of data and control structures, not those structures themselves. In OO terms, it's an interface. To make this point concrete Greg explores one of the simplest possible data structures that supports at least two different, yet consistent interpretations of the same API. The structure used, Conway's partisan games, turned out to be tailor-made for this investigation. Not only does this data structure have the requisite container-like shape, it provided opportunities to see just what's necessary in a container to implement the monadic interface. Running throughout the presentation is a more general comparison of reuse between an OO approach versus a more functional one. When the monadic API is mixed into the implementing structure we get less reuse than when the implementing structure is passed as a type parameter. Finally, doing the work put us in a unique position to see not just how to generalize Conway's construction, monadically, but the underlying pattern which
Re: [Haskell-cafe] Stack space overflow in HaskellNet
On Tue, 26 Jul 2011 14:17:08 -0700 (PDT) Donn Cave d...@avvanta.com wrote: Quoth Manfred Lotz manfred.l...@arcor.de, ... I'm not quite sure I understand what you mean. Stack overflow comes from this: forM_ msgs (\x - fetch con x = print) If I change it to: mapM_ (\x - fetch con x = print) msgs there is the same stack overflow. I didn't understand that myself, but neither do I know what might be wrong. One thing to consider is that email messages can be very large. Looking at messages received in the last 10 days I see I have one that exceeds your reported stack size, and that isn't counting the extra space required for text representation of non printing characters etc. There may be messages that you simply can't print. The HaskellNet IMAP fetch is actually FETCH ... BODY[], i.e., the whole contents of the message. Normal practice for giant data files is to send them as part of a MIME multipart/mixed message, and something like the above can proceed with a reasonable chance of success if it avoids these attachments by fetching BODY[1] (or BODY[1.1], etc. depending on actual structure.) I just fetched the 10Mb message I mentioned above to check the structure, and it happened in the blink of an eye - BODY[1] is smaller than the header. I don't see any support for fetch by part, you might have to hack that up yourself. You may ideally also want to fetch BODYSTRUCTURE, but practically I might go out on a limb and predict that you won't run into messages where the first part is a multipart/mixed with a large attachment - so if the object is just a survivable first part, you could live without BODYSTRUCTURE analysis and optimistically ask for BODY[1]. Moving on to practical use of email via IMAP, you'd also want to be able to fetch and decode the attachments. At this point, it's interesting to return to the question of space requirements. Donn The problem seems to lie in the HaskellNet package. If for example I only fetch a specific message m - fetch con 2092 having a size of some 1.2m then I get the same stack overflow. If at runtime I specify +RTS -K40M -RTS it works but takes over 40 seconds to fetch the message. -- Manfred ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Typeclasses, data, constructors
On 27 July 2011 10:45, Sergiy Nazarenko nazarenko.ser...@gmail.com wrote: Hi everyone! Hi, I have data declaration like this: I try to use typeclasses, class GetRow a where hasID :: Int - IO a instance GetRow MyTableOne where hasID myid = return [(MyTableOne 1 name)] instance GetRow MyTableTwo where hasID myid = return [(MyTableTwo 1 name path)] The issue here seems to be that you are trying to define a class instance for /constructors/, not types. I don't really understand what it is you are trying to do, but perhaps you could treat MyTableOne and MyTableTwo as distinct types. Something like: \begin{code} data MyTableOne = MyTableOne Int String data MyTableTwo = MyTableTwo Int String String instance GetRow MyTableOne where ... instance GetRow MyTableTwo where ... \end{code} You might even use a class for tables, so you can define arbitrary table structures which all support a common interface (e.g., row fetching). Hope this helps. Regards, Joachim ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] XCode Dependency for HP on Mac - old XCodeversions
Quoth Clive Brettingham-Moore hask...@brettingham-moore.net, To get XCode on my 10.6 machine, I... I had quite a hunt recently to find the most recent XCode for my not-so-recent mac... so I'll share what I found: Were you able to look on your install CD? Donn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Approximate String Matching
Hi, I am looking for Haskell libraries to do approximate string matching: http://en.wikipedia.org/wiki/Approximate_string_matching I need this to reduce a set of English word variants with spelling errors to a single canonical dictionary entry. Any libraries to work with spelling will also help. Thanks, Dmitri ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stack space overflow in HaskellNet
Quoth Manfred Lotz manfred.l...@arcor.de, ... The problem seems to lie in the HaskellNet package. If for example I only fetch a specific message m - fetch con 2092 having a size of some 1.2m then I get the same stack overflow. If at runtime I specify +RTS -K40M -RTS it works but takes over 40 seconds to fetch the message. That's not so good, but I wouldn't be surprised if it's a natural parsing problem, I mean it's just a lot of data to run through a Haskell parser. IMAP does give you the means to mitigate the problem - the big data transfer in a FETCH response is preceded by a byte count - but to really take advantage of that, how far do you go? I don't have much experience with general purpose parsers, do they often support an efficient counted string read? Is it OK to return String, or do we need a more efficient type (e.g., ByteString?) Is it OK to return any kind of string value - given that a message part could be arbitrarily long (and needs to be decoded), do you go to a lot of trouble to support large message parts but not extremely large ones? For me, the answer is for the parser to bail out, reporting the counted input as a count but leaving it to the application to actually effect the data transfer and return to finish the parse. That's only moderately complicated, but it's part of a general philosophy about application driven I/O vs. protocol parsing that seems to be mine alone. I have no idea how much could be done to tighten up HaskellNet.IMAP. Someone who understands it well enough might be able to get a miraculous improvement with a strictness annotation or something. Maybe you could track that down with profiling. Donn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Question re SMTPClient
How does one pass authentication info to the SMTP server when using the package STMPClient? Thanks! Jay ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stack space overflow in HaskellNet
Hello, I guess I should stick my hand up as the supposed maintainer of HaskellNet. Unfortunately I can't say that I know the code that well. Two years ago I rescued it from bitrot cabalized it and when I couldn't get any response from the original author put myself down as the maintainer. It is a package which is starting to show its age. Michael Snoyman and I had a conversation in February agreeing that I should try to revamp it by applying some techniques such as those used in blaze html. Unfortunately, I haven't had the time. I agree with the post above that for mime mail HaskellNet shouldn't be retreiving all of the messages with their message bodies. I might see if I can get a chance to work on it a little this weekend but if someone is using the library and has some time to make some changes that person woould be very welcome (and I'd be more than happy if someone wishes to take over as the maintenance). -Rob On Wed, Jul 27, 2011 at 5:47 PM, Donn Cave d...@avvanta.com wrote: Quoth Manfred Lotz manfred.l...@arcor.de, ... The problem seems to lie in the HaskellNet package. If for example I only fetch a specific message m - fetch con 2092 having a size of some 1.2m then I get the same stack overflow. If at runtime I specify +RTS -K40M -RTS it works but takes over 40 seconds to fetch the message. That's not so good, but I wouldn't be surprised if it's a natural parsing problem, I mean it's just a lot of data to run through a Haskell parser. IMAP does give you the means to mitigate the problem - the big data transfer in a FETCH response is preceded by a byte count - but to really take advantage of that, how far do you go? I don't have much experience with general purpose parsers, do they often support an efficient counted string read? Is it OK to return String, or do we need a more efficient type (e.g., ByteString?) Is it OK to return any kind of string value - given that a message part could be arbitrarily long (and needs to be decoded), do you go to a lot of trouble to support large message parts but not extremely large ones? For me, the answer is for the parser to bail out, reporting the counted input as a count but leaving it to the application to actually effect the data transfer and return to finish the parse. That's only moderately complicated, but it's part of a general philosophy about application driven I/O vs. protocol parsing that seems to be mine alone. I have no idea how much could be done to tighten up HaskellNet.IMAP. Someone who understands it well enough might be able to get a miraculous improvement with a strictness annotation or something. Maybe you could track that down with profiling. Donn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stack space overflow in HaskellNet
On Wed, 27 Jul 2011 09:47:52 -0700 (PDT) Donn Cave d...@avvanta.com wrote: Quoth Manfred Lotz manfred.l...@arcor.de, ... The problem seems to lie in the HaskellNet package. If for example I only fetch a specific message m - fetch con 2092 having a size of some 1.2m then I get the same stack overflow. If at runtime I specify +RTS -K40M -RTS it works but takes over 40 seconds to fetch the message. That's not so good, but I wouldn't be surprised if it's a natural parsing problem, I mean it's just a lot of data to run through a Haskell parser. Yep, I agree. Perhaps the library should provide a fetchRaw function to get the whole message without much parsing. Perhaps I could tell the package author what the problem is, and he is happy to provide a solution. In the end the only thing I need is to get the full message because I want to feed bogofilter to learn that a message is ham or spam. For the time being I decided to write my own program to fetch the data because it is a good exercise for a Haskell beginner as I am. -- Manfred ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Stack space overflow in HaskellNet
Quoth Manfred Lotz manfred.l...@arcor.de, In the end the only thing I need is to get the full message because I want to feed bogofilter to learn that a message is ham or spam. For the time being I decided to write my own program to fetch the data because it is a good exercise for a Haskell beginner as I am. Sure, for a very limited case where you don't have to support any options at all, it's as easy as you want it to be. All the responses are one line only and only one to a line, so you can read line by line (and then switch to block read after a line that ends with {count}.) The way I understand it, though, you do not need the full message, you would be better off with the first part only. The following parts in a multipart/mixed message will just be reams of byte64 encoded nonsense for bogofilter's purposes, true? If you fetch BODY[1], you may once in a while get more than you need - both text and HTML versions of a multipart/alternative sub-part - but that won't happen often. Donn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Approximate String Matching
On Wed, 27 Jul 2011, dokondr wrote: Hi, I am looking for Haskell libraries to do approximate string matching: http://en.wikipedia.org/wiki/Approximate_string_matching I need this to reduce a set of English word variants with spelling errors to a single canonical dictionary entry. Any libraries to work with spelling will also help. In a quick investigation I found: http://hackage.haskell.org/package/edit-distance ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] XCode Dependency for HP on Mac
On Wed, 2011-07-27 at 08:27 +0100, Tim Cowlishaw wrote: (Perhaps wandering slightly O/T, but...) Having done some teaching in similar circumstances before (although not with Haskell), I'd highly recommend this approach. In fact, I'd probably have all the students, regardless of OS install VMWare or VirtualBox, and then distribute a VM image with the Haskell Platform and any other tools they need preinstalled. Thanks for the advice. I'd like to avoid this, because I want to leave the students with the impression that they have the tools to do their own programming for their own computers when they finish... but at least it's an option that lets Mac users have a working environment of some sort. I've never had any problems with the Windows installation of the HP, and I'm knowledgeable enough to help with Linux, so I'm not worried about those. -- Chris ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] XCode Dependency for HP on Mac
On Wed, 2011-07-27 at 07:20 -0400, Jack Henahan wrote: Bundling things with the HP is just going to bloat that download and confuse new users more (and my god, the dep-chasing... the number of libs that might have to be piled in on top of it could be absurd). I don't understand this. Are you saying it would be too hard for the Haskell Platform maintainers to build the install kits? It seems like bundling gcc would be just the thing to solve all the problems with the XCode dependency (which I'm now told include not just the install-time dependencies, but also the Haskell Platform regularly breaking with every new operating system release). -- Chris Smith ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Fwd: C9 video in the Monadic Design Patterns for the Web series
Dear James, This is so cool! It's so natural to express this as a monad transformer. It's great insight and it's just the sort of insight that Haskell and this way of thinking about computation makes possible. Bravo! Best wishes, --greg On Wed, Jul 27, 2011 at 6:33 AM, James Cook mo...@deepbondi.net wrote: Dang, I should have played with both versions before sending this. The 'R' instance has a very obvious error: return x = R (ConwayT (return (Left x)) mzero) should be changed to return x = R (ConwayT mzero (return (Left x))) Sorry! -- James On Jul 27, 2011, at 9:28 AM, James Cook wrote: For any who are interested, here's a quick and dirty Haskell version of the generalized Conway game monad transformer described in the video. It uses two newtypes, L and R, to select from two possible implementations of the Monad class. (all the LANGUAGE pragmas are just to support a derived Show instance to make it easier to play around with in GHCi - the type and monad itself are H98) -- James {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} module Monads.Conway where import Control.Applicative import Control.Monad data ConwayT m a = ConwayT { runLeftConwayT :: m (Either a (ConwayT m a)) , runRightConwayT :: m (Either a (ConwayT m a)) } deriving instance (Eq a, Eq (m (Either a (ConwayT m a = Eq (ConwayT m a) deriving instance (Ord a, Ord (m (Either a (ConwayT m a = Ord (ConwayT m a) deriving instance (Read a, Read (m (Either a (ConwayT m a = Read (ConwayT m a) deriving instance (Show a, Show (m (Either a (ConwayT m a = Show (ConwayT m a) instance Functor m = Functor (ConwayT m) where fmap f (ConwayT l r) = ConwayT (fmap g l) (fmap g r) where g (Left x) = Left (f x) g (Right x) = Right (fmap f x) bind liftS (ConwayT l r) f = ConwayT (liftS g l) (liftS g r) where g (Left x) = Right (f x) g (Right x) = Right (bind liftS x f) newtype L f a = L { runL :: f a } deriving (Eq, Ord, Read, Show) instance Functor m = Functor (L (ConwayT m)) where fmap f (L x) = L (fmap f x) instance MonadPlus m = Monad (L (ConwayT m)) where return x = L (ConwayT (return (Left x)) mzero) L x = f = L (bind liftM x (runL . f)) newtype R f a = R { runR :: f a } deriving (Eq, Ord, Read, Show) instance Functor m = Functor (R (ConwayT m)) where fmap f (R x) = R (fmap f x) instance MonadPlus m = Monad (R (ConwayT m)) where return x = R (ConwayT (return (Left x)) mzero) R x = f = R (bind liftM x (runR . f)) On Jul 27, 2011, at 4:31 AM, Greg Meredith wrote: Dear Haskellians, A new C9 video in the series! So, you folks already know most of this... except for maybe the generalization of the Conway construction! Best wishes, --greg -- Forwarded message -- From: Charles Torre ... Date: Tue, Jul 26, 2011 at 1:12 PM Subject: C9 video in the Monadic Design Patterns for the Web series To: Meredith Gregory lgreg.mered...@gmail.com Cc: Brian Beckman ... And we’re live! ** ** http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Greg-Meredith-Monadic-Design-Patterns-for-the-Web-4-of-n C ** ** *From:* Charles Torre *Sent:* Tuesday, July 26, 2011 11:51 AM *To:* 'Meredith Gregory' *Cc:* Brian Beckman *Subject:* C9 video in the Monadic Design Patterns for the Web series ** ** Here it ‘tis: ** ** Greg Meredith http://biosimilarity.blogspot.com/, a mathematician and computer scientist, has graciously agreed to do a C9 lecture series covering monadic design principles applied to web development. You've met Greg before in a Whiteboard jam session with Brian Beckmanhttp://channel9.msdn.com/shows/Going+Deep/E2E-Whiteboard-Jam-Session-with-Brian-Beckman-Greg-Meredith-Monads-and-Coordinate-Systems/ . The fundamental concept here is the monad, and Greg has a novel and conceptually simplified explanation of what a monad is and why it matters. This is a very important and required first step in the series since the whole of it is about the application of monadic composition to real world web development. In *part 4, *Greg primarily focuses on the idea that *a monad is really an API* -- it's a view onto the organization of data and control structures, not those structures themselves. In OO terms, it's an *interface*. To make this point concrete Greg explores one of the simplest possible data structures that supports at least two different, yet consistent interpretations of the same API. The structure used, Conway's partisan games http://mathworld.wolfram.com/ConwayGame.html, turned out to be tailor-made for this investigation. Not only does this data structure have the requisite container-like shape, it provided
[Haskell-cafe] Input redirection in WinGHCi
I know I can do the following from a command prompt: $ runghc WC quux.txt How do I do this in WinGHCi? I know I have to first load the file like this: Prelude :load WC But then what? This doesn't work: *Main WC quux.txt interactive:1:1: Not in scope: data constructor `WC' interactive:1:6: Not in scope: `quux' interactive:1:11: Not in scope: `txt' ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] XCode Dependency for HP on Mac
On Jul 27, 2011 3:30 AM, Sean Leather leat...@cs.uu.nl wrote: To get XCode on my 10.6 machine, I... ... will check out the related discussion: http://thread.gmane.org/gmane.comp.lang.haskell.cafe/89745 I remember this thread from last month, but several of the details have changed (availability of the $5 XCode in App Store, for example). Thanks for your time, Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Idiomatic ways to make all instances of a certain class also instances of another?
On Tue, Jul 26, 2011 at 11:58 PM, Tim Cowlishaw t...@timcowlishaw.co.ukwrote: On Tue, Jul 26, 2011 at 11:14 PM, Alexander Solla alex.so...@gmail.com wrote: data OrderType = Market Size | Limit LimitPrice Expiration Size | Stop (Either Percent Price) newtype Sell = Sell OrderType newtype Buy = Buy OrderType newtype Order = Order (Either Buy Sell) size :: Order - Int size (Order (Left (Buy (Market s))) = s size (Order (Left (Buy (Limit _ _ s))) = s etc. Aah, thank you - this is really neat. So now, I can write (for instance) an Eq instance for OrderType and use deriving (Eq) on the newtypes that wrap it, and my Order can be a concrete type, but still encapsulates all the different types of order. Thank you! No problem. This is more-or-less how type classes work internally, with fewer restrictions (but some more implicit passing around of stuff). Notice that my Order type corresponds with your Order typeclass. My OrderType type value constructors correspond to all your Order types. In other words, a typeclass is a fancy open union type. I never use type classes unless I need that openness property. The problem with this approach is that it can become verbose very quickly. It can be mitigated some by defining accessors for the newtypes, and using function composition. So instead of: newtype Sell = Sell OrderType newtype Buy = Buy OrderType newtype Order = Order (Either Buy Sell) I would personally use newtype Sell = Sell { unSell :: OrderType } newtype Buy = Buy { unBuy :: OrderType } newtype Order = Order { unOrder :: Either Buy Sell } where un should be read like unwrap. These unwrappers can help cut down on the size of pattern matches. I'll give an example shortly. I suggested using Maybe to deal with nonsense semantics/undefinedness. All orders have a size/quantity, but not all have a limit price. So we might write an accessor like: limitPrice' :: OrdeType - Maybe Price limitPrice' (Limit l _ _) = Just l limitPrice' _ = Nothing We have turned a partial function into a total function by embedding it in (Order - Maybe Price). This cuts down on bugs. Now that easy accessor for all orders: limitPrice :: Order - Maybe Price limitPrice = limitPrice' . either (unBuy) (unSell) . unOrder We might even want to stick limitPrice' in a where clause for limitPrice, depending on whether you expect reuse or not. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Ur tutorial, and a challenge
On Wed, Jul 27, 2011 at 8:30 AM, Christopher Done chrisd...@googlemail.com wrote: On 27 July 2011 13:58, Adam Chlipala ad...@impredicative.com wrote: Does this static type system support metaprogramming strong enough to implement my challenge problem with the level of static guarantee for all specialization parameters that I ask for? Again I don't really know what you're talking about so I'll drop it. Here's a question that I suspect may be relevant: Can you generate code with TH that isn't well-typed? If your first thought is something like of course, how would you type check the code before generating it?, I would ask how that differs from of course programs can crash, how can you check all inputs before reading them at run time?. Bonus question for any OCaml folks: What's the difference between using Camlp4 and using MetaOCaml? - C. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Please help me spot where space leak occur.
On Fri, Jul 22, 2011 at 1:54 AM, Olexander Kozlov ookoz...@gmail.com wrote: Jason, thank you for your help. The hint for using -s option is very valuable. It is good to see people answering questions about Haskell here on haskell-cafe. stackoverflow is another good place to ask. This is really matter. I hope I will be helpfull some day too :) As for the question I didn't mention in my psot that Fn can be of arbitrary size. You could extend my solution pretty easily to work for arbitrary size. Now I have another question which I'm concerned with. I used foldl' (strict) in my implementation instead of just foldl (lazy). Does it mean that libraries are to be in two implementations one strict and another one lazy? Because there no way to affect strictness/lazyness of function without modifying its implementation. I' going to ask this question as a separate thread. It doesn't come up that much. It comes up here with your foldl, with Chans, modifyIORef, modifySTRef, and a few things like that. But most of the time you want a lazy version until you spot a space leak. Most of the time the library creator notices and makes a strict version as needed. One of the nice things about Haskell is that you get a choice between lazy and strict, and lazy by default is nice in many ways. Space leaks like this are not usually show stoppers for experienced Haskell folks. Good luck! Jason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Input redirection in WinGHCi
On 28 July 2011 04:56, Paul Reiners paul.rein...@gmail.com wrote: I know I can do the following from a command prompt: $ runghc WC quux.txt How do I do this in WinGHCi? I know I have to first load the file like this: Prelude :load WC But then what? This doesn't work: *Main WC quux.txt interactive:1:1: Not in scope: data constructor `WC' interactive:1:6: Not in scope: `quux' interactive:1:11: Not in scope: `txt' Probably something like: *Main quux - readFile quux.txt *Main :main quux i.e. you can't do file redirection inside ghci -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] XCode Dependency for HP on Mac
On 28 July 2011 03:58, Chris Smith cdsm...@gmail.com wrote: On Wed, 2011-07-27 at 08:27 +0100, Tim Cowlishaw wrote: (Perhaps wandering slightly O/T, but...) Having done some teaching in similar circumstances before (although not with Haskell), I'd highly recommend this approach. In fact, I'd probably have all the students, regardless of OS install VMWare or VirtualBox, and then distribute a VM image with the Haskell Platform and any other tools they need preinstalled. Thanks for the advice. I'd like to avoid this, because I want to leave the students with the impression that they have the tools to do their own programming for their own computers when they finish... but at least it's an option that lets Mac users have a working environment of some sort. I've never had any problems with the Windows installation of the HP, and I'm knowledgeable enough to help with Linux, so I'm not worried about those. I've tutored a Haskell course for the past two years at ANU (it's gone on for longer though) and students generally don't have a problem getting it working. There is a week or two when we have to track down all the OSX stuff (i.e. where is XCode, etc.) though it helps that Alex Mason also tutored it and uses OSX. Then comes the fun part where students are told to set up their editing environment on the uni Linux machines to set tabs to 4 literal spaces, etc. but never seem to remember to do so for their Windows machines... ;-) -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Retaining functions in memory
Use memoization. Here's an example: cabal-install MemoTrie import Data.MemoTrie fib_fix :: (Integer - Integer) - Integer - Integer fib_fix _ n | n 0 = error invalid input fib_fix _ 0 = 1 fib_fix _ 1 = 1 fib_fix rec n = rec (n-1) + rec (n-2) -- 'tie the knot' on a recusrive function func_fix :: ((a - b) - (a - b)) - (a - b) func_fix f = let rec = f rec in rec -- memoized knot tying; 'memo' stops us from recomputing the same value more than once. memo_fix :: HasTrie a = ((a - b) - (a - b)) - (a - b) memo_fix f = let rec = memo (f rec) in rec -- try comparing the performance of these two on large arguments fib_slow, fib_fast :: Integer - Integer fib_slow = func_fix fib_fix fib_fast = memo_fix fib_fix On Tue, Jul 26, 2011 at 2:53 AM, Siddhartha Gadgil siddhartha.gad...@gmail.com wrote: I have been making programs for mathematical applications (low-dimensional topology) in Haskell, which I find a delight to code in. However, the execution is slow, and this seems to be because recursively defined functions seem to be recomputed. For example f(100) needs f(15) which needs f(7) ... The dependencies are not obvious to the compiler. I was looking for a way to retain the values of a specific function in memory. Is there some way to do this. Thanks, Siddhartha ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell Weekly News: Issue 192
Welcome to issue 192 of the HWN, a newsletter covering developments in the Haskell community. This release covers the week of July 17 to 23, 2011. [1] http://goo.gl/8hDku You can find an HTML rendition of this issue at: http://contemplatecode.blogspot.com/2011/07/haskell-weekly-news-issue-192.html Announcements Nicolas Wu announced the 4th edition of the Haskell Parallel Digest. The digest is made possible by the Parallel GHC Project. [2] http://goo.gl/lm5T1 Quotes of the Week * copumpkin: perhaps I should stop eating people I've never met * Saizan: agda is webscale in the sense that you need half of The Cloud to run the typechecker * kmc: my algorithm is O(1), but the constant factor grows quadratically as the problem size increases * cmccann: C++ is dual to Haskell in a sense: it's much too hard for the average programmer to use safely, but they do anyway with disastrous results; whereas Haskell isn't actually that difficult to use but people don't even try Top Reddit Stories * What Haskell Doesn't Have Domain: elaforge.blogspot.com, Score: 73, Comments: 58 On Reddit: [3] http://goo.gl/17UDu Original: [4] http://goo.gl/u4Ozy * Take the State of Haskell 2011 Survey Domain: blog.johantibell.com, Score: 55, Comments: 0 On Reddit: [5] http://goo.gl/Q7iip Original: [6] http://goo.gl/jq1Je * Economic Interpreter for Haskell Domain: pnyf.inf.elte.hu, Score: 40, Comments: 5 On Reddit: [7] http://goo.gl/BmBqf Original: [8] http://goo.gl/92mfS * Haskell on Heroku Domain: yesodweb.com, Score: 38, Comments: 5 On Reddit: [9] http://goo.gl/LYHZY Original: [10] http://goo.gl/Ly4n7 * Haskell Stickers! Domain: redbubble.com, Score: 33, Comments: 7 On Reddit: [11] http://goo.gl/WVXoH Original: [12] http://goo.gl/RpQ0f * Rewritten Agda introduction Domain: pnyf.inf.elte.hu, Score: 31, Comments: 34 On Reddit: [13] http://goo.gl/gz6TJ Original: [14] http://goo.gl/oTg5J * A plugin for GHC to turn Haskell into a strict language Domain: github.com, Score: 28, Comments: 18 On Reddit: [15] http://goo.gl/BK4os * What is the state of HackageDB 2.0? Domain: hackage.haskell.org, Score: 26, Comments: 8 On Reddit: [16] http://goo.gl/nrMTc Original: [17] http://goo.gl/tui2x * wxHaskell: The road to the Haskell Platform? Domain: sourceforge.net, Score: 26, Comments: 33 On Reddit: [18] http://goo.gl/vqfPC Original: [19] http://goo.gl/KNa16 * Just do It: Simple Monadic Equational Reasoning [pdf] Domain: cs.ox.ac.uk, Score: 24, Comments: 2 On Reddit: [20] http://goo.gl/GG0cs Original: [21] http://goo.gl/7MHGw * Cabal-dev 0.8 is out with improvements to: flag parsing, user cabal settings, cabal-dev ghci and more! Domain: github.com, Score: 24, Comments: 15 On Reddit: [22] http://goo.gl/YO6Q6 * Functors, applicative functors, monads – their relationship by example Domain: heh.fi, Score: 23, Comments: 0 On Reddit: [23] http://goo.gl/bkJ4Y Original: [24] http://goo.gl/bf6zo * Snap 0.5.2 released Domain: snapframework.com, Score: 23, Comments: 0 On Reddit: [25] http://goo.gl/0RCh3 Original: [26] http://goo.gl/jeFU5 Top StackOverflow Questions * Help in understanding pointfree code votes: 14, answers: 1 Read on SO: [27] http://goo.gl/Ryy5c * How can I combine Handles in Haskell? votes: 12, answers: 2 Read on SO: [28] http://goo.gl/25W4E * Current state of integrating unit tests with Haskell's Cabal? votes: 9, answers: 1 Read on SO: [29] http://goo.gl/nm8Zc * Does iteratee I/O make sense in non-functional languages? votes: 9, answers: 2 Read on SO: [30] http://goo.gl/f8YhP * Literate Haskell: References And Indexing votes: 8, answers: 1 Read on SO: [31] http://goo.gl/QYPBK * Call C Functions from Haskell at runtime votes: 7, answers: 1 Read on SO: [32] http://goo.gl/oj0R7 * Type-class instances for types with 2 parameters when the type-class has only one votes: 7, answers: 2 Read on SO: [33] http://goo.gl/JmxBr * List of options: equivalent of sequence in Scala? votes: 7, answers: 4 Read on SO: [34] http://goo.gl/MnZg8 * Is it necessary to specify every superclass in a class context of a class declaration? votes: 7, answers: 1 Read on SO: [35] http://goo.gl/OxoSN * Partial decoding of ByteStrings to Text votes: 7, answers: 1 Read on SO: [36] http://goo.gl/9JSKw * Haskell, algorithms and school votes: 7, answers: 1 Read on SO: [37] http://goo.gl/bsM5v About the Haskell Weekly News To help create new editions of this newsletter, please send stories to dstc...@gmail.com. Until next time, Daniel Santa Cruz References 1. http://haskell.org/ 2.