Re: [Haskell-cafe] GPipe example and screenshot
Tobias Bexelius wrote: I've put a simple GPipe example (including a screenshot) on the haskellwiki now, showing off an animated spinning box. Nice to see Data.Vec.LinAlg.Transform3D! That will be a big help. I'm having fun with GPipe. Thanks for the library! - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] GPipe example and screenshot
I've put a simple GPipe example (including a screenshot) on the haskellwiki now, showing off an animated spinning box. You'll find the page here: http://www.haskell.org/haskellwiki/GPipe Later on, I will add more examples, and also some kind of GPipe-tutorial. Hang in there... Cheers Tobias Bexelius _ Windows Live: Gör det enklare för dina vänner att se vad du håller på med på Facebook. http://www.microsoft.com/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:sv-se:SI_SB_2:092009___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] New seed. New random number. Right? Wrong.
On Thu, Oct 8, 2009 at 1:15 PM, michael rice wrote: > > Where am I going wrong? > Your seeds are all extremely close together. The System.Random PRNG takes a 32-bit seed, but your seeds haven't even got a 17-bit range, so you're supplying approximately 19 parts per million of the possible range of entropy. Evidently this PRNG doesn't fare well with such a small amount of entropy. Try providing a broader range of seeds, and you'll see better results, e.g. 877554827 3377950428 3850407650 688135636 1134078904 973676998 3178940608 840705211 185598244 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Hugs Trex for GHC / JHC / UHC / ... ?
I briefly read about Hugs record system Trex, and at first sight this was really nice! I know this question was asked a long time ago already, but are there any plans to add this extension to GHC? What about the other compilers, like JHC, UHC, etc? Is it possible to emulate Trex (lots of other record systems exist), *and* get the same easy to understand errors? What were the problems with Trex (if any)? Thanks, Peter Verswyvelen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Any example of concurrent haskell application?
rss2irc is a small app using two communicating threads, and that much works well. The error handling may be quite ideal. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] New seed. New random number. Right? Wrong.
interesting. the sequences you get are random, but unless you enter a new number that is really far from the previous one, the probability of getting the same first random number seems high. import System.Random import Control.Monad(when) main = do numberString <- getLine when (not $ null numberString) $ do let seed = read numberString let randNumbers = take 10 . randomRs (1::Int,6) $ mkStdGen seed in putStrLn $ "Numbers are " ++ show randNumbers main 1 Numbers are [6,5,2,6,5,2,3,2,5,5] 1000 Numbers are [6,4,3,2,6,5,2,3,3,5] 100 Numbers are [6,4,3,6,5,5,3,4,6,4] 10 Numbers are [4,1,3,4,6,1,2,4,1,6] 1 Numbers are [1,2,3,3,5,5,4,6,6,4] 1000 Numbers are [1,4,2,6,6,2,4,2,6,5] On Thu, Oct 8, 2009 at 10:15 PM, michael rice wrote: > I'm entering a new number to make a different seed for my generator each > time through the loop, but my resulting numbers are anything but random. > > Where am I going wrong? > > Michael > > = > > import System.Random > import Control.Monad(when) > > main = do > numberString <- getLine > when (not $ null numberString) $ do > let seed = read numberString > let (randNumber, newGen) = randomR (1,6) (mkStdGen seed) :: (Int, > StdGen) > in putStrLn $ "Number is " ++ show randNumber > main > > = > > [mich...@localhost ~]$ runhaskell zz.hs > 12317 > Number is 6 > 12371 > Number is 6 > 37829 > Number is 6 > 8713 > Number is 6 > 71392 > Number is 5 > 29492 > Number is 6 > 41089 > Number is 6 > 28483 > Number is 6 > 78687 > Number is 5 > 40703 > Number is 6 > 86910 > Number is 5 > 15608 > Number is 6 > 56155 > Number is 5 > 31575 > Number is 6 > 72231 > Number is 5 > 51815 > Number is 6 > 20189 > Number is 6 > 71533 > Number is 5 > 17755 > Number is 6 > 91161 > Number is 5 > > [mich...@localhost ~]$ > > > > ___ > 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] difference "cabal configure" and "runghc Setup.lhs configure"
2009/10/8 Andrew U. Frank : > i have a strange error, which does not occur when i run > runghc Setup.lhs configure > but when i use cabal configure and then build, it occurs. > > the error is > Type constructor Control.Exception.Exception used as a class > in the instance declaration. > (i have imported qualified Control.Exception) > > two questions: > 1. Exception is a class (in Control.Exception) - why the error? > 2. why is there a difference between runghc and cabal (using the same cabal > file). > > i attach the cabal file and the two configuratin files produced. > > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > C.E.Exception used to be a type instead of a class, so you need to have `base == 4.*` instead of `base -any`. Alternatively, use the extensible-extensions package instead. The difference in results you found is because cabal-install uses base-3 if you don't specify otherwise. The reason for this is that a lot of packages use `base -any` when they shouldn't: base-4 brought enough incompatible changes (like making Exception a class) that they don't work with it. (This is also, I assume, why GHC has two built-in versions of base in the first place.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] New seed. New random number. Right? Wrong.
I'm entering a new number to make a different seed for my generator each time through the loop, but my resulting numbers are anything but random. Where am I going wrong? Michael = import System.Random import Control.Monad(when) main = do numberString <- getLine when (not $ null numberString) $ do let seed = read numberString let (randNumber, newGen) = randomR (1,6) (mkStdGen seed) :: (Int, StdGen) in putStrLn $ "Number is " ++ show randNumber main = [mich...@localhost ~]$ runhaskell zz.hs 12317 Number is 6 12371 Number is 6 37829 Number is 6 8713 Number is 6 71392 Number is 5 29492 Number is 6 41089 Number is 6 28483 Number is 6 78687 Number is 5 40703 Number is 6 86910 Number is 5 15608 Number is 6 56155 Number is 5 31575 Number is 6 72231 Number is 5 51815 Number is 6 20189 Number is 6 71533 Number is 5 17755 Number is 6 91161 Number is 5 [mich...@localhost ~]$ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Generalizing IO
On Thu, Oct 8, 2009 at 1:42 PM, Andrew Coppin wrote: > Heinrich Apfelmus wrote: >> >> Alternatively, you can use algebraic data types instead of type classes >> to generalize one program to different implementations. For monads, this >> can be achieved with >> >> http://hackage.haskell.org/package/MonadPrompt >> >> In particular, the idea is to turn every effect like >> >> getLine >> >> into a constructor >> >> GetLine >> >> and have different implementations pattern match on that. >> > > Ooo, that's interesting... > > I did wonder for a moment whether this would allow you to analyse what the > monadic action does without actually "doing" it, but on reflection this is > fundamentally impossible. The action that happens next can (and often does) > depend on the result of a previous effect. > > I guess if you wanted to run your action through an optimiser before > actually running it, you'd need to use arrows (and all the terrifying syntax > that entails)... Or Applicatives, or some other action algebra which is appropriate for the kind of actions you are trying to encode. Don't fool yourself into thinking that Monads and Arrows are all there are; those are just two formalisms for which we have discovered a lot of uses. But if what you're trying to encode doesn't match those, then don't use them. If you want to encode actions that can be optimized before usage, expose just enough so you can find the information you need to optimize it. Luke ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Generalizing IO
Heinrich Apfelmus wrote: Alternatively, you can use algebraic data types instead of type classes to generalize one program to different implementations. For monads, this can be achieved with http://hackage.haskell.org/package/MonadPrompt In particular, the idea is to turn every effect like getLine into a constructor GetLine and have different implementations pattern match on that. Ooo, that's interesting... I did wonder for a moment whether this would allow you to analyse what the monadic action does without actually "doing" it, but on reflection this is fundamentally impossible. The action that happens next can (and often does) depend on the result of a previous effect. I guess if you wanted to run your action through an optimiser before actually running it, you'd need to use arrows (and all the terrifying syntax that entails)... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Libraries for Commercial Users
Yes. C is the language of operating systems and browsers and low-level system utilities -- not, by and large, the backbone of today's web applications. Projects written in C/C++ tend to be ignored in favor of those written in Java (Hypertable versus HBase, for example). There are exceptions, but there are fewer of them over time. Java's spot in the middle tier has overflowed into the bottom tier, as performance and community size have increased. Moreover, C libraries are seldom cross-platform (leading to wasteful fiddling and endless frustration), and they are painful to interface with due to the requirement for detailed type annotations, which are easy to get wrong. JVM is cross-platform, and contains sufficient typing information to permit one to write something like, "import foreign jvm java.list.Collection", and have typed access to the whole class and all of its methods. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net|877-376-2724 x 101 On Oct 8, 2009, at 1:00 PM, Gregory Crosswhite wrote: Out of curiosity, why do you think that porting Haskell to the JVM would make such a large difference? Haskell can already interface with C libraries; are there really so many commercially vital libraries that are JVM-only? Cheers, Greg On Oct 8, 2009, at 11:08 AM, John A. De Goes wrote: Some of these are not ready for production use; e.g.: RESTng: "RESTng is still experimental and incomplete". It has no documentation and doesn't even compile. Sadly typical. It's a bit of a chicken and egg thing. I'd switch to Haskell in a commercial setting if there were more good libraries, yet the act of switching would lead to the production of more good libraries. The latter, though, is cost-prohibitive, given all the components that would need to be developed. A few years from now, or post Haskell-on-JVM, I might be singing a different tune. I do greatly admire the work you and your company have done for Haskell. What has the Industrial Haskell group done so far? I haven't seen any announcements. The work I'd be most interested in helping co- sponsor is Haskell on JVM (biggest bang for the buck). Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net|877-376-2724 x 101 On Oct 8, 2009, at 11:24 AM, Don Stewart wrote: john: * Haskell interfaces to Twitter, Facebook, MySpace, Google, etc. This one is fine: twitter hs-twitter library: Haskell binding to the Twitter API del.icio.us delicious library: Accessing the del.icio.us APIs from Haskell (v2) friendfeed ffeed library and programs: Haskell binding to the FriendFeed API LiveJournal feed2lj program: Cross-post any RSS/Atom feed to LiveJournal flickr flickr library and programs: Haskell binding to the Flickr API amazon hS3 library and program: Interface to Amazon's Simple Storage Service (S3) mediawiki mediawiki library and programs: Interfacing with the MediaWiki API google pubsub pubsub library and programs: A library for Google/SixApart pubsub hub interaction Speaking of REST, RESTng library: A framework for writing RESTful applications. And auth: WindowsLive windowslive library and program: Implements Windows Live Web Authentication and Delegated Authentication OpenID openid library: An implementation of the OpenID-2.0 spec. OAuth hoauth library and program: A Haskell implementation of OAuth 1.0a protocol. We've obviously not all there yet, but we have a way to get there -- write and improve code on Hackage. Galois is doing its part (we've released dozens of web packages), but the other commercial users need to help out too. Join the Industrial Haskell Group and fund open source work. Or, if you can, release some of the non-IP-encumbered things you work on! -- Don ___ 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] Re: Libraries for Commercial Users
Out of curiosity, why do you think that porting Haskell to the JVM would make such a large difference? Haskell can already interface with C libraries; are there really so many commercially vital libraries that are JVM-only? Cheers, Greg On Oct 8, 2009, at 11:08 AM, John A. De Goes wrote: Some of these are not ready for production use; e.g.: RESTng: "RESTng is still experimental and incomplete". It has no documentation and doesn't even compile. Sadly typical. It's a bit of a chicken and egg thing. I'd switch to Haskell in a commercial setting if there were more good libraries, yet the act of switching would lead to the production of more good libraries. The latter, though, is cost-prohibitive, given all the components that would need to be developed. A few years from now, or post Haskell-on- JVM, I might be singing a different tune. I do greatly admire the work you and your company have done for Haskell. What has the Industrial Haskell group done so far? I haven't seen any announcements. The work I'd be most interested in helping co- sponsor is Haskell on JVM (biggest bang for the buck). Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net|877-376-2724 x 101 On Oct 8, 2009, at 11:24 AM, Don Stewart wrote: john: * Haskell interfaces to Twitter, Facebook, MySpace, Google, etc. This one is fine: twitter hs-twitter library: Haskell binding to the Twitter API del.icio.us delicious library: Accessing the del.icio.us APIs from Haskell (v2) friendfeed ffeed library and programs: Haskell binding to the FriendFeed API LiveJournal feed2lj program: Cross-post any RSS/Atom feed to LiveJournal flickr flickr library and programs: Haskell binding to the Flickr API amazon hS3 library and program: Interface to Amazon's Simple Storage Service (S3) mediawiki mediawiki library and programs: Interfacing with the MediaWiki API google pubsub pubsub library and programs: A library for Google/SixApart pubsub hub interaction Speaking of REST, RESTng library: A framework for writing RESTful applications. And auth: WindowsLive windowslive library and program: Implements Windows Live Web Authentication and Delegated Authentication OpenID openid library: An implementation of the OpenID-2.0 spec. OAuth hoauth library and program: A Haskell implementation of OAuth 1.0a protocol. We've obviously not all there yet, but we have a way to get there -- write and improve code on Hackage. Galois is doing its part (we've released dozens of web packages), but the other commercial users need to help out too. Join the Industrial Haskell Group and fund open source work. Or, if you can, release some of the non-IP-encumbered things you work on! -- Don ___ 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] Any example of concurrent haskell application?
dmehrtash: > I am trying to learn more about concurrent applications in Haskell by studying > an existing a real application source code. I would very much appreciate if > you can recommend an application that you feel has done a good job in > implementing a real time application in Haskell. > hmp3 uses a read thread to reduce user input latency. Lambdabot is an IRC gateway that forks a thread for every message. hyena is a heavily concurrent web server. All on Hackage. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Any example of concurrent haskell application?
I am trying to learn more about concurrent applications in Haskell by studying an existing a real application source code. I would very much appreciate if you can recommend an application that you feel has done a good job in implementing a real time application in Haskell. Daryoush ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Libraries for Commercial Users
The IHG (http://industry.haskell.org/) has funded about 6 months worth of development so far. You can see the status report here: http://industry.haskell.org/status Dynamic libraries, GMP-less GHC, and efficient Cabal, all appearing in the GHC 6.12. The IHG is designed as a mechanism whereby commerical users can ensure the toolchain they depend on is around for the long haul, or kick towards key features that would enable them to use Haskell in new ways. I think it is the best mechanism we have for commerical users to work on shared infrastructure -- stuff that benefits us all. john: > > Some of these are not ready for production use; e.g.: RESTng: "RESTng is > still experimental and incomplete". It has no documentation and doesn't > even compile. Sadly typical. > > It's a bit of a chicken and egg thing. I'd switch to Haskell in a > commercial setting if there were more good libraries, yet the act of > switching would lead to the production of more good libraries. The > latter, though, is cost-prohibitive, given all the components that would > need to be developed. A few years from now, or post Haskell-on-JVM, I > might be singing a different tune. > > I do greatly admire the work you and your company have done for Haskell. > > What has the Industrial Haskell group done so far? I haven't seen any > announcements. The work I'd be most interested in helping co-sponsor is > Haskell on JVM (biggest bang for the buck). > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Libraries for Commercial Users
Some of these are not ready for production use; e.g.: RESTng: "RESTng is still experimental and incomplete". It has no documentation and doesn't even compile. Sadly typical. It's a bit of a chicken and egg thing. I'd switch to Haskell in a commercial setting if there were more good libraries, yet the act of switching would lead to the production of more good libraries. The latter, though, is cost-prohibitive, given all the components that would need to be developed. A few years from now, or post Haskell-on- JVM, I might be singing a different tune. I do greatly admire the work you and your company have done for Haskell. What has the Industrial Haskell group done so far? I haven't seen any announcements. The work I'd be most interested in helping co-sponsor is Haskell on JVM (biggest bang for the buck). Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net|877-376-2724 x 101 On Oct 8, 2009, at 11:24 AM, Don Stewart wrote: john: * Haskell interfaces to Twitter, Facebook, MySpace, Google, etc. This one is fine: twitter hs-twitter library: Haskell binding to the Twitter API del.icio.us delicious library: Accessing the del.icio.us APIs from Haskell (v2) friendfeed ffeed library and programs: Haskell binding to the FriendFeed API LiveJournal feed2lj program: Cross-post any RSS/Atom feed to LiveJournal flickr flickr library and programs: Haskell binding to the Flickr API amazon hS3 library and program: Interface to Amazon's Simple Storage Service (S3) mediawiki mediawiki library and programs: Interfacing with the MediaWiki API google pubsub pubsub library and programs: A library for Google/SixApart pubsub hub interaction Speaking of REST, RESTng library: A framework for writing RESTful applications. And auth: WindowsLive windowslive library and program: Implements Windows Live Web Authentication and Delegated Authentication OpenID openid library: An implementation of the OpenID-2.0 spec. OAuth hoauth library and program: A Haskell implementation of OAuth 1.0a protocol. We've obviously not all there yet, but we have a way to get there -- write and improve code on Hackage. Galois is doing its part (we've released dozens of web packages), but the other commercial users need to help out too. Join the Industrial Haskell Group and fund open source work. Or, if you can, release some of the non-IP-encumbered things you work on! -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Libraries for Commercial Users
john: > * Haskell interfaces to Twitter, Facebook, MySpace, Google, etc. This one is fine: twitter hs-twitter library: Haskell binding to the Twitter API del.icio.us delicious library: Accessing the del.icio.us APIs from Haskell (v2) friendfeed ffeed library and programs: Haskell binding to the FriendFeed API LiveJournal feed2lj program: Cross-post any RSS/Atom feed to LiveJournal flickr flickr library and programs: Haskell binding to the Flickr API amazon hS3 library and program: Interface to Amazon's Simple Storage Service (S3) mediawiki mediawiki library and programs: Interfacing with the MediaWiki API google pubsub pubsub library and programs: A library for Google/SixApart pubsub hub interaction Speaking of REST, RESTng library: A framework for writing RESTful applications. And auth: WindowsLive windowslive library and program: Implements Windows Live Web Authentication and Delegated Authentication OpenID openid library: An implementation of the OpenID-2.0 spec. OAuth hoauth library and program: A Haskell implementation of OAuth 1.0a protocol. We've obviously not all there yet, but we have a way to get there -- write and improve code on Hackage. Galois is doing its part (we've released dozens of web packages), but the other commercial users need to help out too. Join the Industrial Haskell Group and fund open source work. Or, if you can, release some of the non-IP-encumbered things you work on! -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Let it be
On Thu, Oct 8, 2009 at 2:07 PM, Ross Mellgren wrote: > there is at least one ticket in Haskell' to fix it for if/then/else ...and there isn't one for let/in because you can use just let (without in) inside a do-block. Of course the meanings are different as in the first case the let-bound variables scope only the 'in ...' part, while without in it scopes the rest of the do block: do {ini; let ... in ...; rest} => ini >> (let ... in ...) >> rest do {ini; let ...; ...; rest} => ini >> (let ... in (... >> rest)) HTH, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Let it be
I don't know of any offhand that specifically call it out -- it's a natural consequence of the layout rule which is described in the Haskell Report. However, there is at least one ticket in Haskell' to fix it for if/then/else: http://hackage.haskell.org/trac/haskell-prime/ticket/23 -Ross On Oct 8, 2009, at 1:03 PM, michael rice wrote: Thanks all, So, in a do expression let x = 1 y = 2 etc. in z = 1 + 2 if then etc. else etc. Is this deviation documented somewhere? Michael --- On Thu, 10/8/09, Brandon S. Allbery KF8NH wrote: From: Brandon S. Allbery KF8NH Subject: Re: [Haskell-cafe] Let it be To: "michael rice" Cc: "Brandon S. Allbery KF8NH" , haskell-cafe@haskell.org Date: Thursday, October 8, 2009, 11:53 AM On Oct 8, 2009, at 11:43 , michael rice wrote: This doesn't: import System.Random main = do gen <- getStdGen let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) in putStrLn $ "Number is " ++ show randNumber [mich...@localhost ~]$ runhaskell zz.hs zz.hs:4:2: The last statement in a 'do' construct must be an expression The problem here is that the "do" construct parses things a bit differently; if you're at the same indentation level, it inserts a (>>) on the assumption that the next line is an independent expression, so you need to indent the "in" a bit more to avoid it. Note however that this usage is common enough that "do" provides a shorthand: you can simply omit the "in", and "let" will be parsed as if it were a statement: > main = do > gen <- getStdGen > let (randNumber, newGen) = randomR (1,6) gen :: (Int,StdGen) > putStrLn $ "Number is " ++ show randNumber -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH ___ 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] Let it be
Thanks all, So, in a do expression let x = 1 y = 2 etc. in z = 1 + 2 if then etc. else etc. Is this deviation documented somewhere? Michael --- On Thu, 10/8/09, Brandon S. Allbery KF8NH wrote: From: Brandon S. Allbery KF8NH Subject: Re: [Haskell-cafe] Let it be To: "michael rice" Cc: "Brandon S. Allbery KF8NH" , haskell-cafe@haskell.org Date: Thursday, October 8, 2009, 11:53 AM On Oct 8, 2009, at 11:43 , michael rice wrote:This doesn't: import System.Random main = do gen <- getStdGen let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) in putStrLn $ "Number is " ++ show randNumber [mich...@localhost ~]$ runhaskell zz.hs zz.hs:4:2: The last statement in a 'do' construct must be an expression The problem here is that the "do" construct parses things a bit differently; if you're at the same indentation level, it inserts a (>>) on the assumption that the next line is an independent expression, so you need to indent the "in" a bit more to avoid it. Note however that this usage is common enough that "do" provides a shorthand: you can simply omit the "in", and "let" will be parsed as if it were a statement: > main = do> gen <- getStdGen> let (randNumber, newGen) = randomR (1,6) gen > :: (Int,StdGen)> putStrLn $ "Number is " ++ show randNumber -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.comsystem administrator [openafs,heimdal,too many hats] allb...@ece.cmu.eduelectrical and computer engineering, carnegie mellon university KF8NH ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Test.QuickCheck: generate
On 08/10/09 04:57, David Menendez wrote: On Wed, Oct 7, 2009 at 8:29 PM, Michael Mossey wrote: In Test.QuickCheck, the type of 'generate' is generate :: Int -> StdGen -> Gen a -> a I can't find docs that explain what the Int does. Some docs are here: Judging by the source code, the integer is the upper bound for the size parameter. If you are generating a list, for example, it gives the maximum size of the list Thats right. Its the "size" parameter, and what it does depends on the instance of Arbitrary. Arbitrary numbers will be within +/- size. Arbitrary lists will be of maximum length size. On the other hand arbitrary booleans will just be True or False. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re[2]: [Haskell-cafe] type inference question
Indeed, the types foo :: forall a . (Num a) => a -> (Int, Float) and foo :: (forall a . (Num a) => a) -> (Int, Float) are quite different. The first one say, I (foo) can handle any kind of numeric 'a' you (the caller) can pick. You (the caller) get to choose exactly what type you give me. The second one says, I (foo) require you (the caller) to give me an numeric 'a' that I can use any way I want. You (the caller) don't get to choose what type you give me, you have to give me a polymorphic one. -- Lennart On Thu, Oct 8, 2009 at 5:35 PM, Bulat Ziganshin wrote: > Hello Cristiano, > > Thursday, October 8, 2009, 7:14:20 PM, you wrote: > >> Could you explain why, under NoMonomorphismRestriction, this typechecks: > >> let a = 1 in (a + (1 :: Int),a + (1 :: Float)) > >> while this not: > >> foo :: Num a => a -> (Int,Float) >> foo k = (k + (1 :: Int), k + (1.0 :: Float)) > > i think it's because type is different: > > foo :: (forall a. (Num a) => a) -> (Int,Float) > > in first equation it probably inferred correctly > > > > -- > Best regards, > Bulat mailto:bulat.zigans...@gmail.com > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Let it be
On Oct 8, 2009, at 11:53 , Brandon S. Allbery KF8NH wrote: The problem here is that the "do" construct parses things a bit differently; if you're at the same indentation level, it inserts a (>>) on the assumption that the next line is an independent expression, so you need to indent the "in" a bit more to avoid it. I should probably clarify that what is actually inserted is a semicolon as noted by Ross Mellgren, and the next level of translation then replaces it with the (>>) operator. Note however that this usage is common enough that "do" provides a shorthand: you can simply omit the "in", and "let" will be parsed as if it were a statement: > main = do > gen <- getStdGen > let (randNumber, newGen) = randomR (1,6) gen :: (Int,StdGen) > putStrLn $ "Number is " ++ show randNumber I should also mention that there are still constructs where this indentation quirk can bite you, notably: > if foo > then bar > else baz works outside of a "do" construct, but inside one you need extra spaces: > do > if foo > then bar > else baz otherwise, you again get semicolons inserted before the "then" and "else" and subsequently replaced with (>>). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH 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] Libraries for Commercial Users
Exactly, it's things like this that are so frustrating and which reduce efficiency. In a mature library, you don't need to handle details like this for yourself. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net|877-376-2724 x 101 On Oct 7, 2009, at 6:44 PM, Erik de Castro Lopo wrote: Curt Sampson wrote: On 2009-10-02 09:03 -0600 (Fri), John A. De Goes wrote: [Haskell] is missing many key libraries that would be of great commercial value. Just out of curiousity, can you give me some examples of what you feel these are? A version of Network.HTTP that accepts HTTPS URLs and does the right thing instead of attempting to do a HTTP connection instead. Erik -- -- Erik de Castro Lopo http://www.mega-nerd.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] Let it be
On Oct 8, 2009, at 11:43 , michael rice wrote: This doesn't: import System.Random main = do gen <- getStdGen let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) in putStrLn $ "Number is " ++ show randNumber [mich...@localhost ~]$ runhaskell zz.hs zz.hs:4:2: The last statement in a 'do' construct must be an expression The problem here is that the "do" construct parses things a bit differently; if you're at the same indentation level, it inserts a (>>) on the assumption that the next line is an independent expression, so you need to indent the "in" a bit more to avoid it. Note however that this usage is common enough that "do" provides a shorthand: you can simply omit the "in", and "let" will be parsed as if it were a statement: > main = do > gen <- getStdGen > let (randNumber, newGen) = randomR (1,6) gen :: (Int,StdGen) > putStrLn $ "Number is " ++ show randNumber -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH 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] Let it be
You're running into this problem because you're in a do-block. In a do- block, all the continuing lines of a single statement in the do-block must be indented w/r/t to the first line. The cylinder example doesn't have this issue because it's not in a do-block. The layout rule (I'm summarizing and I haven't read the spec, so someone jump on me if I'm stating the wrong thing) basically says that within some implied { }, ;'s will be inserted for any line that is at the same indentation level as the previous line, e.g. import System.Random main = do gen <- getStdGen let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) in putStrLn $ "Number is " ++ show randNumber has the following implied symbols import System.Random main = do { gen <- getStdGen ; let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) ; in putStrLn $ "Number is " ++ show randNumber } which is now obviously wrong, as the let and in are in two separate statements. Conversely, import System.Random main = do gen <- getStdGen let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) in putStrLn $ "Number is " ++ show randNumber implied: import System.Random main = do { gen <- getStdGen ; let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) in putStrLn $ "Number is " ++ show randNumber } Hope that clarifies things. -Ross On Oct 8, 2009, at 11:43 AM, michael rice wrote: From Learn You a Haskell ("Let it be" section): 1. cylinder :: (RealFloat a) => a -> a -> a 2. cylinder r h = 3. let sideArea = 2 * pi * r * h 4. topArea = pi * r ^2 5. in sideArea + 2 * topArea === What's the proper indentation for LET so these problems (below) don't arise? I thought LET and IN should be aligned in the same column. Also, isn't a LET expression an "expression." Michael == This works: import System.Random main = do gen <- getStdGen let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) in putStrLn $ "Number is " ++ show randNumber == This works: import System.Random main = do gen <- getStdGen let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) putStrLn $ "Number is " ++ show randNumber == This doesn't: import System.Random main = do gen <- getStdGen let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) in putStrLn $ "Number is " ++ show randNumber [mich...@localhost ~]$ runhaskell zz.hs zz.hs:4:2: The last statement in a 'do' construct must be an expression ___ 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] Market Place for Haskell development teams?
I don't dismiss Haskell in business. I only maintain it's a niche market. There are some domains where the infrastructure in more established languages is minimal, and in such cases, I think Haskell can be more efficient than those languages. I should note, too, the the agile development momement over the past ten years has had and still does have exactly the same sort of attacks on it, and yet has successfully moved into the mainstream and is well-accepted by many parts of it. What has moved into mainstream is unfortunately connected chiefly to agile by virtue of the word itself. Agile means more than getting software out the door quickly, a fact many businesses have yet to learn. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net|877-376-2724 x 101 On Oct 7, 2009, at 5:49 PM, Curt Sampson wrote: On 2009-10-02 09:04 -0600 (Fri), John A. De Goes wrote: I'm not saying Haskell is unstable. I'm saying that the attitude expressed in the following quote is at odds with the needs of business: "And as far as something like dealing with a changing language and libraries, the mainstream already has well-established and popular techniques for doing just: agile development." I don't know how much commercial experience you have, but I've been a founder of two companies, CTO or CEO of several businesses, a "chief architect" in a couple more, and consider myself as much a businessman and manager as a developer. The attitude you express is certainly common in many businesses, but it's not the only way to run a successful business. I won't go further here, since this kind of argument generally leads into a, "no, what you do isn't possible" kind of flamewar, but I did want to point this out here, so that others can know that, the attitude John De Goes expresses, while comon, is not the only way busineses look at the world. I should note, too, the the agile development momement over the past ten years has had and still does have exactly the same sort of attacks on it, and yet has successfully moved into the mainstream and is well-accepted by many parts of it. cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[2]: [Haskell-cafe] type inference question
Hello Cristiano, Thursday, October 8, 2009, 7:14:20 PM, you wrote: > Could you explain why, under NoMonomorphismRestriction, this typechecks: > let a = 1 in (a + (1 :: Int),a + (1 :: Float)) > while this not: > foo :: Num a => a -> (Int,Float) > foo k = (k + (1 :: Int), k + (1.0 :: Float)) i think it's because type is different: foo :: (forall a. (Num a) => a) -> (Int,Float) in first equation it probably inferred correctly -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Libraries for Commercial Users
Here's a list of libraries that are quite significant to commercial software development in 2009, but which either do not exist in Haskell, or if they exist, are hard to find, undocumented, unstable, or perhaps uncompilable: * A drop-in comet server, with JavaScript bindings (or compatible with existing JavaScript bindings). * A library for producing RESTful APIs, which does much of the work in mapping URLs into operations on a database. * Speaking of database, a robust, well-documented, cross-platform interface to popular databases, with a commercial-friendly license. * A scalable, fault-tolerant, distributed data store in the mold of BigTable, which provides map reduce. Or at least Haskell bindings for one, and a Haskellized wrapper around the binder. * A Haskell client for AMQP or other message broker, ideally reactive but anything's better than nothing. And while I'm at it, how about a 100% Haskell message broker that takes advantage of Haskell's functional nature to deliver something of Erlang quality. * A scalable, fault-tolerant, distributed graph database that can be used for building and maintaining social networks. * A networking library that supports peer-to-peer communication, authentication, encryption, and other features via plug-ins, with seamless multicasting when possible. * Infrastructure for building Haskell cloud computing clusters that are scalable and fault-tolerant. * Search and other data mining libraries, with robust indexing features, and the capacity to scale indefinitely. * Haskell interfaces to Twitter, Facebook, MySpace, Google, etc. * etc. In any one of these categories, Java has multiple implementations, sometimes 20 or more (yes, it's absurd at times, but it's also comforting because it means choosing Java is not risky). Many are meticulously documented with extensive Javadoc and tutorials. And this just scratches the surface. Most apps today are web apps, meaning they have client and server portions. Some modern languages natively support cross-compilation (Haxe, Fan), and others such as Java can be cross-compiled with the aid of third-party packages (gwt, java2script), but not Haskell. Reusing code, and using a single language across different platforms opens up many new possibilities and greatly improves productivity and efficiency. Let me ask you this question. How long would it take you to write a scalable first-pass Twitter clone? A good Java developer could do it in a week, maybe a day, and deploy it on AppEngine, where it will scale indefinitely with no effort. That's power. The syntax of a language, no matter how beautiful or high-level, cannot compete with the billions of dollars worth of resources freely available for inferior languages like Java. Haskell on the JVM with seamless Java interop (no need for method-by- method foreign import of information that's freely available via reflection) would go a long way towards leveling the playing field. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net|877-376-2724 x 101 On Oct 7, 2009, at 5:41 PM, Curt Sampson wrote: On 2009-10-02 09:03 -0600 (Fri), John A. De Goes wrote: [Haskell] is missing many key libraries that would be of great commercial value. Just out of curiousity, can you give me some examples of what you feel these are? cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Let it be
>From Learn You a Haskell ("Let it be" section): 1. cylinder :: (RealFloat a) => a -> a -> a 2. cylinder r h = 3. let sideArea = 2 * pi * r * h 4. topArea = pi * r ^2 5. in sideArea + 2 * topArea === What's the proper indentation for LET so these problems (below) don't arise? I thought LET and IN should be aligned in the same column. Also, isn't a LET expression an "expression." Michael == This works: import System.Random main = do gen <- getStdGen let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) in putStrLn $ "Number is " ++ show randNumber == This works: import System.Random main = do gen <- getStdGen let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) putStrLn $ "Number is " ++ show randNumber == This doesn't: import System.Random main = do gen <- getStdGen let (randNumber, newGen) = randomR (1,6) gen :: (Int, StdGen) in putStrLn $ "Number is " ++ show randNumber [mich...@localhost ~]$ runhaskell zz.hs zz.hs:4:2: The last statement in a 'do' construct must be an expression ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] more improvable randomness
I wrote some code to model the keystroke-to-keystroke delay in a person typing, with pseudorandomness. There are two kinds of delays.. one is a very small delay as the person reaches for a new key (call this 'reach' delays), the other is a larger delay that represents a pause to think or to take a break (call this 'break' delays). My thought is that I could create an infinite series of reach delays and an infinite series of break delays and zipWith (+). The inifinite series of break delays would look like: - The overall pattern is a large number of zeros, in the range (N,M) followed by a single positive number, chosen from a distribution D... and then repeat. Here's some code. I used the Gen monad to gain access to the 'frequency' function, which is useful, but I had trouble figuring out how to put the whole algorithm into Gen. I also looked at Rand. The problem is that if I want to create the list by 'sequence'ing a list of monads, they need to have state that remembers how many zeros are left to go. breakSeries :: Int -> Int -> StdGen -> [Float] breakSeries lowerB upperB gen = let (n,gen1) = randomR (lowerB,upperB) gen (gen2,gen3) = split gen1 delay = generate 1 gen2 breakM in replicate n 0 ++ [delay] ++ breakSeries lowerB upperB gen3 breakM :: Gen Float breakM = frequency [ (10, choose( 1::Float , 2)) , (10, choose( 4::Float , 6)) ] test = (print . take 100 . breakSeries 2 4 ) =<< newStdGen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] How to add use custom preprocessor in cabal
Hi folks, I am trying to integrate my own preprocessor into a cabal build process. But there are several points that I get stuck with. Could someone help me, please? A simplification of my problem: I have files "Abc.foo" and each of them should be transformed into "Abc.hs" by calling function "transform". The resulting "Abc.hs" files should then be exposed as Haskell library modules. 1. Question: How do I tell cabal that the file Abc.foo belongs to the package? After reading the User's Guide I had the impression that I should write something like Library Eposed-Modules: Abc.foo But this leads to a parse error. Adding a Data-Files: Abc.foo to the heading, on the other hand, does not seem to do anything. 2. Question: How to add the preprocessor? I have tried main = defaultMainWithHooks simpleUserHooks{hookedPreProcessors=[("foo",transformation)]} transformation :: BuildInfo -> LocalBuildInfo -> PreProcessor But under which circumstances will this function be called? Up to now I have not succeeded in making cabal call this function. Thanks for your time! Bernd ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] type inference question
2009/10/8 Cristiano Paris : > On Thu, Oct 8, 2009 at 12:48 PM, Lennart Augustsson > wrote: >> The reason a gets a single type is the monomorphism restriction (read >> the report). >> Using NoMonomorphismRestriction your example with a works fine. > > Could you explain why, under NoMonomorphismRestriction, this typechecks: > > let a = 1 in (a + (1 :: Int),a + (1 :: Float)) > > while this not: > > foo :: Num a => a -> (Int,Float) > foo k = (k + (1 :: Int), k + (1.0 :: Float)) I think it is the same thing that my (\f -> f f True) question, i.e. the polymorphism of k is fixed inside foo (you don't want that). So I guess using the rank-2 types and the corresponding type annotation to keep k polymorph should work. In other words, foo is polymorph on k but k is not polymorph when given to foo in a specific application. Thu ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [solved] Re: [Haskell-cafe] Calling Haskell from C, Linking with gcc?
On Thu, Oct 08, 2009 at 10:34:07AM +0200, Wouter Swierstra wrote: > > On 7 Oct 2009, at 23:39, John Velman wrote: > >> For anyone following this: The XCode ld script is complex, and has mac >> specific defaults early in the search path specification, and I probably >> don't want to change these. A library in a default path is the wrong >> libgmp.[dylib | a]. > > Is there any chance you'll write up exactly what you needed to do on a > blog/TMR article/Haskell wiki page? I've tried doing something similar, ran > into linking problems, and gave up my fight with XCode. I think this would > be a really useful resource for both Obj-C programmers looking into Haskell > and Haskell programmers who want to have a fancy Cocoa GUI. Thanks! > > Wouter Yes, it is my intention to do just that. Unfortunately, I don't always follow through! But with a specific request, I'll try to get it done in the next few days. I'll post the url here. Best, John Velman ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] type inference question
On Thu, Oct 8, 2009 at 12:48 PM, Lennart Augustsson wrote: > The reason a gets a single type is the monomorphism restriction (read > the report). > Using NoMonomorphismRestriction your example with a works fine. Could you explain why, under NoMonomorphismRestriction, this typechecks: let a = 1 in (a + (1 :: Int),a + (1 :: Float)) while this not: foo :: Num a => a -> (Int,Float) foo k = (k + (1 :: Int), k + (1.0 :: Float)) Thanks! Cristiano ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] On DSLs - one last time
To me, the "D" and "S" come in when I'm deciding what to support. The "domain" represents the set of primitive operations I want to support. The "specific" says that I don't support anything other than those operations. Consider a language for laying out boolean logic circuits: we want to implement only AND, OR, and XOR, and NOT. The domain is boolean logic. We can't reason directly about trees or rainbows with this language, so it's specific. Our set of primitive operations would probably consist of: 1) Create input 2) Perform one of AND, OR, or XOR on two inputs (or proceeding inputs from previous operations) 3) Apply a NOT to an operation. With this basic set of operations, one can build up a graph of gates which can then be executed directly, converted to some other intermediate form, or plotted in graphical form. This is actually the focus domain of a small EDSL I'm working on for demonstrative purposes. The following is a link to the github repository and a direct link to one of the examples. http://github.com/sw17ch/gator http://github.com/sw17ch/gator/blob/master/examples/4bitAdder.hs The example linked is a 4 bit adder (8 inputs, 4 outputs) that will dump GraphViz 'dot' code. This simple EDSL currently only allows you to construct graphviz, but the intermediate Logic type could be transformed to just about anything having to do with boolean logic or executed in place. I hope some of this made sense. /jve 2009/10/8 Günther Schmidt > Hi all, > > I'd like to summarize my impressions on the DSL issue, gathered from the > responses to my posts. > > It is absolutely amazing, various people have shown here that it is > possible to design languages within haskell that are almost or just as > powerful and safe as haskell itself. It is probably even possible to create > an EDSL within an EDSL within haskell. > > Amazing! > > > Uhm... > > ... but in that case I really wonder why I should not use Haskell directly > then. > > Because out of the EDSL I can clearly see the "E" and I can see the "L" but > having slight problems figuring out where the "D" and the "S" come in. > > In short, yes it's great that you can create a language within Haskell so > powerful that it's gone full circle and is general purpose again, but what > good is that? > > The efforts I've seen here where efforts to create a rich and powerful > syntax, but aren't we supposed to focus on expressing semantics specific to > a problem in a DSL rather? > > I'm not trying to put the efforts and achievements of the people who have > done such amazing work down, but what exactly is it that I missed? > > Günther > > ___ > 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] Happstack + network package issue on the Mac
Sean Leather writes: > We have run into an issue that it seems other people have already > found but has apparently not been resolved, yet. It manifests as with > the error "HTTP request failed with: Unsupported socket". The problem > is described in two places with different workarounds. > > http://code.google.com/p/happstack/issues/detail?id=88 > http://groups.google.com/group/HAppS/msg/0c9a0d0fd7c6aff0 > > One workaround is to rewrite part of the network package, and the > other is to downgrade the package. It could be the case that the > rewrite came from the older version, though I'm not sure. > > I'm curious if it is possible to fix this, either in Happstack or the > network package, once and for all. The workarounds are rather painful > when so many things depend on the network package. The following patch to happstack works for me: Mon May 4 10:35:54 EDT 2009 Gregory Collins * Local fix: make networking work Ignore-this: f46cdf40b26ac1ca72e50b05c772c259 diff -rN -u old-happstack/happstack-server/src/Happstack/Server/HTTP/Socket.hs new-happstack/happstack-server/src/Happstack/Server/HTTP/Socket.hs --- old-happstack/happstack-server/src/Happstack/Server/HTTP/Socket.hs 2009-10-08 10:34:22.0 -0400 +++ new-happstack/happstack-server/src/Happstack/Server/HTTP/Socket.hs 2009-10-08 10:34:22.0 -0400 @@ -24,29 +24,11 @@ (sock', addr) <- S.accept sock h <- S.socketToHandle sock' ReadWriteMode (N.PortNumber p) <- N.socketPort sock' - - let peer = $(if supportsIPv6 - then - return $ CaseE (VarE (mkName "addr")) -[Match - (ConP (mkName "S.SockAddrInet") - [WildP,VarP (mkName "ha")]) - (NormalB (AppE (VarE (mkName "showHostAddress")) - (VarE (mkName "ha" [] -,Match (ConP (mkName "S.SockAddrInet6") [WildP,WildP,VarP (mkName "ha"),WildP]) - (NormalB (AppE (VarE (mkName "showHostAddress6")) (VarE (mkName "ha" [] -,Match WildP (NormalB (AppE (VarE (mkName "error")) (LitE (StringL "Unsupported socket" []] - -- the above mess is the equivalent of this: - {-[| case addr of - (S.SockAddrInet _ ha) -> showHostAddress ha - (S.SockAddrInet6 _ _ ha _) -> showHostAddress6 ha - _ -> error "Unsupported socket" - |]-} - else - [| case addr of - (S.SockAddrInet _ ha) -> showHostAddress ha - _ -> error "Unsupported socket" - |]) - + + let peer = case addr of + (S.SockAddrInet _ ha) -> showHostAddress ha + (S.SockAddrInet6 _ _ ha _) -> showHostAddress6 ha + _ -> error "Unsupported socket" + return (h, peer, p) diff -rN -u old-happstack/happstack-server/src/Happstack/Server/HTTP/SocketTH.hs new-happstack/happstack-server/src/Happstack/Server/HTTP/SocketTH.hs --- old-happstack/happstack-server/src/Happstack/Server/HTTP/SocketTH.hs 2009-10-08 10:34:22.0 -0400 +++ new-happstack/happstack-server/src/Happstack/Server/HTTP/SocketTH.hs 2009-10-08 10:34:22.0 -0400 @@ -8,9 +8,4 @@ -- find out at compile time if the SockAddr6 / HostAddress6 constructors are available supportsIPv6 :: Bool -supportsIPv6 = $(let c = "Network.Socket.SockAddrInet6"; d = ''SockAddr in - do TyConI (DataD _ _ _ cs _) <- reify d -if isJust (find (\(NormalC n _) -> show n == c) cs) - then [| True |] - else [| False |] ) - +supportsIPv6 = True G. -- Gregory Collins ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] On DSLs - one last time
Hi all, I'd like to summarize my impressions on the DSL issue, gathered from the responses to my posts. It is absolutely amazing, various people have shown here that it is possible to design languages within haskell that are almost or just as powerful and safe as haskell itself. It is probably even possible to create an EDSL within an EDSL within haskell. Amazing! Uhm... ... but in that case I really wonder why I should not use Haskell directly then. Because out of the EDSL I can clearly see the "E" and I can see the "L" but having slight problems figuring out where the "D" and the "S" come in. In short, yes it's great that you can create a language within Haskell so powerful that it's gone full circle and is general purpose again, but what good is that? The efforts I've seen here where efforts to create a rich and powerful syntax, but aren't we supposed to focus on expressing semantics specific to a problem in a DSL rather? I'm not trying to put the efforts and achievements of the people who have done such amazing work down, but what exactly is it that I missed? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Libraries for Commercial Users
On 8 Oct 2009, at 00:41, Curt Sampson wrote: On 2009-10-02 09:03 -0600 (Fri), John A. De Goes wrote: [Haskell] is missing many key libraries that would be of great commercial value. Just out of curiousity, can you give me some examples of what you feel these are? Relational database libraries that work and have proper documentation i.e. those homework killers - examples, not just API docs or half finished wikis. Just google up how to connect to a database in any well-used (commercially) language and there will be a ton of fully fleshed out docs with examples I can cut n paste from.* No thinking, no time wasted, just get it done and get on with the real stuff. Haskell doesn't have that, and Happs isn't going to replace all those databases out there. (yet) *If you don't like the idea of cut n paste coding don't complain to me, it's given me a career and I'm grateful for that. Iain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What *is* a DSL?
> "George" == George Pollard writes: George> I'd also like to note that the canonical pronunciation of George> DSL ends in "-izzle". Whose canon? Interestingly, I have always assumed the canonical pronunciation of DSSSL was diesel, as JADE stands for JAmes's DSSSL Engine. I don't see why removing extra S-es should shorten the vowel. -- Colin Adams Preston Lancashire ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] type inference question
Thanks all! Thu 2009/10/8 Lennart Augustsson : > The reason a gets a single type is the monomorphism restriction (read > the report). > Using NoMonomorphismRestriction your example with a works fine. > > On Thu, Oct 8, 2009 at 12:29 PM, Cristiano Paris wrote: >> On Thu, Oct 8, 2009 at 11:04 AM, minh thu wrote: >>> Hi, >>> >>> I'd like to know what are the typing rules used in Haskell (98 is ok). >>> >>> Specifically, I'd like to know what makes >>> >>> let i = \x -> x in (i True, i 1) >>> >>> legal, and not >>> >>> let a = 1 in (a + (1 :: Int), a + (1.0 :: Float)) >>> >>> Is it correct that polymorphic functions can be used polymorphically >>> (in multiple places) while non-functions receive a monomorphic type ? >> >> First, "1" IS a constant function so it's in no way special and is a >> value like any other. >> >> That said, the type of 1 is (Num t) => t, hence polymorphic. But, when >> used in the first element of the tuple, a is assigned a more concrete >> type (Int) which mismatches with the second element of the tuple, >> which is a Float. >> >> If you swap the tuple, you'll find that the error reported by ghci is >> the very same as before, except that the two types are swapped. >> >> Is it possible to rewrite the expression so as to work? The answer is >> yes, using existential quantification (and Rank2 polymorphism). >> >> Here you are: >> {-# LANGUAGE ExistentialQuantification, Rank2Types #-} >> foo :: (forall a. (Num a) => a) -> (Int,Float) >> foo = \x -> (x + (1 :: Int), x + (1 :: Float)) >> >> Hence: >> >> foo 1 --> (2,2.0) >> >> Bye, >> >> Cristiano >> ___ >> 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] What *is* a DSL?
I'd also like to note that the canonical pronunciation of DSL ends in "-izzle". ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] type inference question
The reason a gets a single type is the monomorphism restriction (read the report). Using NoMonomorphismRestriction your example with a works fine. On Thu, Oct 8, 2009 at 12:29 PM, Cristiano Paris wrote: > On Thu, Oct 8, 2009 at 11:04 AM, minh thu wrote: >> Hi, >> >> I'd like to know what are the typing rules used in Haskell (98 is ok). >> >> Specifically, I'd like to know what makes >> >> let i = \x -> x in (i True, i 1) >> >> legal, and not >> >> let a = 1 in (a + (1 :: Int), a + (1.0 :: Float)) >> >> Is it correct that polymorphic functions can be used polymorphically >> (in multiple places) while non-functions receive a monomorphic type ? > > First, "1" IS a constant function so it's in no way special and is a > value like any other. > > That said, the type of 1 is (Num t) => t, hence polymorphic. But, when > used in the first element of the tuple, a is assigned a more concrete > type (Int) which mismatches with the second element of the tuple, > which is a Float. > > If you swap the tuple, you'll find that the error reported by ghci is > the very same as before, except that the two types are swapped. > > Is it possible to rewrite the expression so as to work? The answer is > yes, using existential quantification (and Rank2 polymorphism). > > Here you are: > {-# LANGUAGE ExistentialQuantification, Rank2Types #-} > foo :: (forall a. (Num a) => a) -> (Int,Float) > foo = \x -> (x + (1 :: Int), x + (1 :: Float)) > > Hence: > > foo 1 --> (2,2.0) > > Bye, > > Cristiano > ___ > 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] type inference question
2009/10/8 Cristiano Paris : > On Thu, Oct 8, 2009 at 11:04 AM, minh thu wrote: >> Hi, >> >> I'd like to know what are the typing rules used in Haskell (98 is ok). >> >> Specifically, I'd like to know what makes >> >> let i = \x -> x in (i True, i 1) >> >> legal, and not >> >> let a = 1 in (a + (1 :: Int), a + (1.0 :: Float)) >> >> Is it correct that polymorphic functions can be used polymorphically >> (in multiple places) while non-functions receive a monomorphic type ? > > First, "1" IS a constant function so it's in no way special and is a > value like any other. I thought all functions in lambda calculus, technically, take exactly one argument? -- Deniz Dogan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] type inference question
On Thu, Oct 8, 2009 at 11:04 AM, minh thu wrote: > Hi, > > I'd like to know what are the typing rules used in Haskell (98 is ok). > > Specifically, I'd like to know what makes > > let i = \x -> x in (i True, i 1) > > legal, and not > > let a = 1 in (a + (1 :: Int), a + (1.0 :: Float)) > > Is it correct that polymorphic functions can be used polymorphically > (in multiple places) while non-functions receive a monomorphic type ? First, "1" IS a constant function so it's in no way special and is a value like any other. That said, the type of 1 is (Num t) => t, hence polymorphic. But, when used in the first element of the tuple, a is assigned a more concrete type (Int) which mismatches with the second element of the tuple, which is a Float. If you swap the tuple, you'll find that the error reported by ghci is the very same as before, except that the two types are swapped. Is it possible to rewrite the expression so as to work? The answer is yes, using existential quantification (and Rank2 polymorphism). Here you are: {-# LANGUAGE ExistentialQuantification, Rank2Types #-} foo :: (forall a. (Num a) => a) -> (Int,Float) foo = \x -> (x + (1 :: Int), x + (1 :: Float)) Hence: foo 1 --> (2,2.0) Bye, Cristiano ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] type inference question
2009/10/8 Jochem Berndsen : > minh thu wrote: >> Also, I'd like to know why >> >> id id True >> >> is permitted but not >> >> (\f -> f f True) id > > If you want to do this, answer the question "what is the type of (\f -> > f f True)"? > You can do this, by the way, using rank-2 types: >> {-# LANGUAGE Rank2Types, PatternSignatures #-} >> thisIsAlwaysTrue = (\ (f :: forall a. a -> a) -> f f True) id > > Cheers, Jochem So I learned we should be explicit about f being used polymorphically; that's what rank-2 types are for. (correct ?) Thanks, Thu ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] #include path
On Thu, 2009-10-08 at 00:37 -0400, Sean McLaughlin wrote: > Hi, > > > I'm trying to compile some code using Cabal. One of the files has a > CPP directive > > > #include "undefined.h" > > > The file undefined.h is in the same directory as the file with the > directive. That works fine for me. I've got: foo.cabal Foo/Bar.hs Foo/undefined.h Bar.hs has the #include "undefined.h" directive. This works because cpp looks first in the directory containing the file it is processing at the time, ie the directory containing Foo/Bar.hs. > If I use the full path name, cabal can compile it. However, if I use > the relative path, it complains about not being able to find the file. Do you mean cpp (invoked by cabal/ghc) cannot find the undefined.h file when compiling? If this is the case we'll need more details. When you say full path name do you mean the full absolute path name all the way from /, or do you mean relative to the root of the project (ie the dir with the .cabal file)? > I tried adding it to extra-source-files, but that didn't help. Or do you mean it does not get included into the sdist tarball, and thus is missing when you build from the tarball? That would be a use case for extra-source-files. > I see that Hackage packages like Agda use this trick, so I know it's > possible. How can I get these paths worked out correctly? > There isn't much comment in the Cabal docs. I'm not clear about which stage is failing. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Cabal, sdist and flags
On Thu, 2009-10-08 at 09:31 +0100, Magnus Therning wrote: > A while ago I moved a project away from using a mix of Cabal and make > to build (Cabal to build the library and make to build the tests) to > using only Cabal. I added a flag and then made a construct like this: [..] > Interestingly that does work for things like 'configure' and 'build', > but it doesn't work for 'sdist': > I found this surprising, so I'm tempted to call it a bug. A quick > search didn't tell me whether this is well-known already, hence the > email. Would you consider it a bug? Has it been raised already? Yes, I'd consider it a bug. I don't think it has been reported. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] random question
Excerpts from Bryan O'Sullivan's message of Wed Oct 07 23:25:10 +0200 2009: > On Wed, Oct 7, 2009 at 1:59 PM, Michael Mossey wrote: > > > My thread about randomness got hijacked so I need to restate my remaining > > question here. Is it acceptable to write pure routines that use but do not > > return generators, and then call several of them from an IO monad with a > > generator obtained by several calls to newStdGen? > > > > shuffle :: RandomGen g => g -> [a] -> [a] > > shuffle = ... > > > > foo :: [a] -> [a] -> IO () > > foo xs ys = do > > g1 <- newStdGen > > print $ shuffle g1 xs > > g2 <- newStdGen > > print $ shuffle g2 ys > > > > Does this kind of thing exhibit good pseudorandomness? > > > > If you believe in the safety of the split operation (which I don't), then | Can you elaborate on that? -+ Best regards, -- Nicolas Pouillard http://nicolaspouillard.fr ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Happstack + network package issue on the Mac
We have run into an issue that it seems other people have already found but has apparently not been resolved, yet. It manifests as with the error "HTTP request failed with: Unsupported socket". The problem is described in two places with different workarounds. http://code.google.com/p/happstack/issues/detail?id=88 http://groups.google.com/group/HAppS/msg/0c9a0d0fd7c6aff0 One workaround is to rewrite part of the network package, and the other is to downgrade the package. It could be the case that the rewrite came from the older version, though I'm not sure. I'm curious if it is possible to fix this, either in Happstack or the network package, once and for all. The workarounds are rather painful when so many things depend on the network package. Thanks, Sean ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] type inference question
minh thu wrote: > Also, I'd like to know why > > id id True > > is permitted but not > > (\f -> f f True) id If you want to do this, answer the question "what is the type of (\f -> f f True)"? You can do this, by the way, using rank-2 types: > {-# LANGUAGE Rank2Types, PatternSignatures #-} > thisIsAlwaysTrue = (\ (f :: forall a. a -> a) -> f f True) id Cheers, Jochem -- Jochem Berndsen | joc...@functor.nl | joc...@牛在田里.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] type inference question
minh thu wrote: Also, I'd like to know why id id True is permitted but not (\f -> f f True) id Because this requires rank-2 types: Prelude> :set -XScopedTypeVariables Prelude> :set -XRank2Types Prelude> (\(f :: forall a. a -> a) -> f f True) id True HTH, Martijn. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] type inference question
Hi, I'd like to know what are the typing rules used in Haskell (98 is ok). Specifically, I'd like to know what makes let i = \x -> x in (i True, i 1) legal, and not let a = 1 in (a + (1 :: Int), a + (1.0 :: Float)) Is it correct that polymorphic functions can be used polymorphically (in multiple places) while non-functions receive a monomorphic type ? Also, I'd like to know why id id True is permitted but not (\f -> f f True) id Is it possible to change the later expression so it type checks ? Are there any type inference algorithms that would accept it ? I'm asking this because I have implemented a simple type inference algorithm following PLAI and I can infer the type for id id True (because I use fresh type variable names for id whenever I apply it before unification) and have an occur check fail for the later expression, just like in haskell. Thanks, Thu ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Cabal, sdist and flags
> > To make this work I had to move the 'main-is' outside of the if-else: > > executable tests > main-is: Test.hs > hs-source-dirs: test-src src > if flag(BuildTests) > build-depends: test-framework, test-framework-hunit, HUnit, > test-framework-quickcheck2, QuickCheck >= 2.1.0.0 > else > buildable: False > > I found this surprising, so I'm tempted to call it a bug. A quick > search didn't tell me whether this is well-known already, hence the > email. Would you consider it a bug? Has it been raised already? > I do something similar with EMGM, but I never tried to put the main-is inside the if. I just did this for the test executable. if flag(test) build-depends: QuickCheck >= 2.1 && < 2.2, HUnit >= 1.2 && < 1.3 else buildable: False Sean ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [solved] Re: [Haskell-cafe] Calling Haskell from C, Linking with gcc?
On 7 Oct 2009, at 23:39, John Velman wrote: For anyone following this: The XCode ld script is complex, and has mac specific defaults early in the search path specification, and I probably don't want to change these. A library in a default path is the wrong libgmp.[dylib | a]. Is there any chance you'll write up exactly what you needed to do on a blog/TMR article/Haskell wiki page? I've tried doing something similar, ran into linking problems, and gave up my fight with XCode. I think this would be a really useful resource for both Obj-C programmers looking into Haskell and Haskell programmers who want to have a fancy Cocoa GUI. Thanks! Wouter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Cabal, sdist and flags
A while ago I moved a project away from using a mix of Cabal and make to build (Cabal to build the library and make to build the tests) to using only Cabal. I added a flag and then made a construct like this: flag BuildTests Description: Build unit and quickcheck tests. Default: False ... executable tests if flag(BuildTests) main-is: Test.hs build-depends: test-framework, test-framework-hunit, HUnit, test-framework-quickcheck2, QuickCheck >= 2.1.0.0 hs-source-dirs: test-src src else main-is: Test.hs buildable: False Interestingly that does work for things like 'configure' and 'build', but it doesn't work for 'sdist': % ./Setup.hs sdist Distribution quality errors: Building source dist for dataenc-0.13.0.1... Setup.hs: Test.hsTest.hs doesn't exist To make this work I had to move the 'main-is' outside of the if-else: executable tests main-is: Test.hs hs-source-dirs: test-src src if flag(BuildTests) build-depends: test-framework, test-framework-hunit, HUnit, test-framework-quickcheck2, QuickCheck >= 2.1.0.0 else buildable: False I found this surprising, so I'm tempted to call it a bug. A quick search didn't tell me whether this is well-known already, hence the email. Would you consider it a bug? Has it been raised already? /M -- Magnus Therning(OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] What *is* a DSL?
Perhaps it would be appropriate to point out the IFIP conference on exactly that topic, DSL. The conference took place in July, here is the permanent record: http://dsl09.blogspot.com/ with pointers to the slides and the discussions. The panel discussion has debated that very question, what exactly is DSL. http://dsl09.blogspot.com/2009/07/panel.html As you can see, the agreement could not be reached on what is Domain. There will be another DSL conference, in Australia. Perhaps all the Haskell-Cafe debaters may want to participate. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] CBN, CBV, Lazy in the same final tagless framework
Actually it is possible to implement all three evaluation orders within the same final tagless framework, using the same interpretation of types and reusing most of the code save the semantics of lam. That is where the three orders differ, by their own definition. In call-by-name, we have lam f = S . return $ (unS . f . S) In call-by-value, we have lam f = S . return $ (\x -> x >>= unS . f . S . return) In call-by-need, we have lam f = S . return $ (\x -> share x >>= unS . f . S) In CBV, the function first evaluates its argument, whether the value will be needed or not. In call-by-need, we arrange for the sharing of the result should the computation be evaluated. Here is an illustrative test t2 :: HOAS exp => exp IntT t2 = (lam $ \z -> lam $ \x -> let_ (x `add` x) $ \y -> y `add` y) `app` (int 100 `sub` int 10) `app` (int 5 `add` int 5) t2SN = runName t2 >>= print {- *CB> t2SN Adding Adding Adding Adding Adding Adding Adding 40 -} In CBN, the result of subtraction was not needed, and so it was not performed OTH, (int 5 `add` int 5) was computed four times. t2SV = runValue t2 >>= print {- *CB> t2SV Subtracting Adding Adding Adding 40 -} In CBV, although the result of subtraction was not needed, it was still performed. OTH, (int 5 `add` int 5) was computed only once. t2SL = runLazy t2 >>= print {- *CB> t2SL Adding Adding Adding 40 -} Now, Lazy is better than both CBN and CBV: subtraction was not needed, and it was not performed. All other expressions were needed, and evaluated once. The complete code is at http://okmij.org/ftp/tagless-final/CB.hs ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe