Re: [Haskell-cafe] source line annotations
On 19 January 2011 23:59, Evan Laforge wrote: > Another thing is that performance in logging is pretty critical. When > I profile, logging functions wind up in the expensive list if I'm not > careful. I don't know bad an unsafePerformIO plus a catch for every > log msg is going to be, but it's not going to be as fast as doing the > work at compile time. It is possible that GHC's optimiser will let-float the "getSourceLoc assert" application to the top level, which would ensure that you only take the hit the first time. However, I'm not sure about this - do an experiment! Since logging is in IO anyway, perhaps GHC could provide a new magic primitive, (location :: IO String), which was replaced by the compiler with an expression like (return "MyLocation:42:1"). Your consumer could then look like myLogFunction location "extra-info" (myLogFunction is in IO and would deal with >>=ing in the location). This would be much less of a potential performance drag than going through exceptions. Shouldn't be too hard to patch GHC to do this, either. Cheers, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Wondering about networking programming in Haskell.
On Thu, Jan 20, 2011 at 4:19 AM, Magicloud Magiclouds wrote: > Hi, > Originally, my idea for networking programming is like: read some > bytes, judge if this is enough for a packet (defined in certain > protocol), if not, read more until the packet is complete, then parse > it into a message. I'd say this is the easiest way to get started with network programming in Haskell as well. For many applications there's a better alternative, based on a concept called iteratees. It takes a bit longer to grasp but deals with a number of problems you often have to deal with in network programming (e.g. chunk boundaries). Check out the enumerator package: http://hackage.haskell.org/package/enumerator > Now we have lazy in Haskell. Can I do it as: > buffer <- hGetContents handle > (message1, leftData1) <- parse1 buffer You can. There are a few pitfalls however: * If you close the handler before consuming 'buffer' all the data in the Handle will not have been read into 'buffer'. * You must make sure you consume all of 'buffer' to make sure that the Handle gets closed. * You must under no circumstances read only parts of 'buffer' and hold on to the result for an extended point of time as this will cause the underlying OS resources to be held up longer than desired (i.e. a space leak). Johan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] source line annotations
On Thu, Jan 20, 2011 at 12:47 AM, Max Bolingbroke wrote: > On 19 January 2011 23:59, Evan Laforge wrote: >> Another thing is that performance in logging is pretty critical. When >> I profile, logging functions wind up in the expensive list if I'm not >> careful. I don't know bad an unsafePerformIO plus a catch for every >> log msg is going to be, but it's not going to be as fast as doing the >> work at compile time. > > It is possible that GHC's optimiser will let-float the "getSourceLoc > assert" application to the top level, which would ensure that you only > take the hit the first time. However, I'm not sure about this - do an > experiment! I don't read core very well, but with a simple example it appears it does, and I wind up with the unsafePerformIO stuff in a top level CAF of type String. However, when I switch to a more realistic example with an intermediary function, as in: warn assert msg = tell (getSourceLoc assert ++ msg) it looks like each call to 'warn' calls getSourceLoc as a function, so it should take the performance hit each time. So it might be possible to get this to work by embedding all logging logic into the second argument of 'catch' and being careful to check the core. > Since logging is in IO anyway, perhaps GHC could provide a new magic > primitive, (location :: IO String), which was replaced by the compiler > with an expression like (return "MyLocation:42:1"). Your consumer > could then look like Not necessarily! None of my logging or exceptions are in IO, so it wouldn't work for me. I still like the pragma... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell time line?
On Thu, 20 Jan 2011 03:49:49 +0100, michael rice wrote: The Haskell language is some twenty years old. Is there a time line for what features were in the language's initial release and what has been added along the way? Michael For recent changes, see the page: http://www.haskell.org/haskellwiki/Haskell_2010 Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html -- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] source line annotations
On 20 January 2011 10:48, Evan Laforge wrote: > I still like the pragma... Maybe Template Haskell can help: module Location where import Language.Haskell.TH import Data.Functor ((<$>)) loc :: Q Exp loc = LitE . StringL . show . loc_start <$> location {-# LANGUAGE TemplateHaskell #-} module Main where import Location main = do putStrLn $loc putStrLn $loc putStrLn $loc *Main> main (7,12) (8,12) (9,12) Regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] GHC timings
I have small program UULib which i use for checking some timing information. When I compile with ghc 7 and profiling information I get the timings which are more or less what I expect. If I however recompile without profiling tome consumed goes up by a factor of 20! 1) Am I misinterpreting the results? 2) If not, does this look familiar to anyone? 3) If so, whether should I look first to see what is going on here? Doaitse dyn-81-64:ProgramTests doaitse$ ghc --make UULib [1 of 2] Compiling ParseInputs ( ParseInputs.hs, ParseInputs.o ) [2 of 2] Compiling Main ( UULib.hs, UULib.o ) Linking UULib ... dyn-81-64:ProgramTests doaitse$ time ./UULib 138000 real0m9.101s user0m9.048s sys 0m0.038s dyn-81-64:ProgramTests doaitse$ ghc --make -prof -auto-all -rtsopts UULib [1 of 2] Compiling ParseInputs ( ParseInputs.hs, ParseInputs.o ) [2 of 2] Compiling Main ( UULib.hs, UULib.o ) Linking UULib ... dyn-81-64:ProgramTests doaitse$ time ./UULib 138000 real0m0.418s user0m0.376s sys 0m0.038s dyn-81-64:ProgramTests doaitse$ time ./UULib +RTS -h -p 138000 real0m0.457s user0m0.397s sys 0m0.034s ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] GHC timings
I have small program UULib which i use for checking some timing information. When I compile with ghc 7 and profiling information I get the timings which are more or less what I expect. If I however recompile without profiling tome consumed goes up by a factor of 20! 1) Am I misinterpreting the results? 2) If not, does this look familiar to anyone? 3) If so, whether should I look first to see what is going on here? Doaitse dyn-81-64:ProgramTests doaitse$ ghc --make UULib [1 of 2] Compiling ParseInputs ( ParseInputs.hs, ParseInputs.o ) [2 of 2] Compiling Main ( UULib.hs, UULib.o ) Linking UULib ... dyn-81-64:ProgramTests doaitse$ time ./UULib 138000 real0m9.101s user0m9.048s sys 0m0.038s dyn-81-64:ProgramTests doaitse$ ghc --make -prof -auto-all -rtsopts UULib [1 of 2] Compiling ParseInputs ( ParseInputs.hs, ParseInputs.o ) [2 of 2] Compiling Main ( UULib.hs, UULib.o ) Linking UULib ... dyn-81-64:ProgramTests doaitse$ time ./UULib 138000 real0m0.418s user0m0.376s sys 0m0.038s dyn-81-64:ProgramTests doaitse$ time ./UULib +RTS -h -p 138000 real0m0.457s user0m0.397s sys 0m0.034s ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] source line annotations
On 20 January 2011 14:33, Bas van Dijk wrote: > On 20 January 2011 10:48, Evan Laforge wrote: >> I still like the pragma... > > Maybe Template Haskell can help: > > > module Location where > > import Language.Haskell.TH > import Data.Functor ((<$>)) > > loc :: Q Exp > loc = LitE . StringL . show . loc_start <$> location > > > {-# LANGUAGE TemplateHaskell #-} > > module Main where > > import Location > main = do > putStrLn $loc > putStrLn $loc > putStrLn $loc > > > *Main> main > (7,12) > (8,12) > (9,12) > > Regards, > > Bas > You should also take a look at the control-monad-exception package which provides, among other things, support for exception call traces (with source locations). Take a look at the description to see an example: http://hackage.haskell.org/package/control-monad-exception Regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell time line?
Thanks. I've been reading the Hudak paper. Interesting stuff. Maybe a better question would be which of these features, from http://en.wikipedia.org/wiki/Haskell_%28programming_language%29#Features *weren't* present at first launch? Haskell features lazy evaluation, pattern matching, list comprehensions, typeclasses, and type polymorphism. It is a purely functional language, which means that in general, functions in Haskell do not have side effects. There is a distinct type for representing side effects, orthogonal to the type of functions. A pure function may return a side effect which is subsequently executed, modeling the impure functions of other languages. Haskell has a strong, static type system based on Hindley–Milner type inference. Haskell's principal innovation in this area is to add type classes, which were originally conceived as a principled way to add overloading to the language,[15] but have since found many more uses.[16] The type which represents side effects is an example of a monad. Monads are a general framework which can model different kinds of computation, including error handling, nondeterminism, parsing, and software transactional memory. Monads are defined as ordinary datatypes, but Haskell provides some syntactic sugar for their use. Michael --- On Thu, 1/20/11, Henk-Jan van Tuyl wrote: From: Henk-Jan van Tuyl Subject: Re: [Haskell-cafe] Haskell time line? To: haskell-cafe@haskell.org, "michael rice" Date: Thursday, January 20, 2011, 5:03 AM On Thu, 20 Jan 2011 03:49:49 +0100, michael rice wrote: > The Haskell language is some twenty years old. Is there a time line for what > features were in the language's initial release and what has been added along > the way? > > Michael > For recent changes, see the page: http://www.haskell.org/haskellwiki/Haskell_2010 Regards, Henk-Jan van Tuyl --http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html -- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC timings
On Thursday 20 January 2011 15:18:51, S. Doaitse Swierstra wrote: > I have small program UULib which i use for checking some timing > information. > > When I compile with ghc 7 and profiling information I get the timings > which are more or less what I expect. If I however recompile without > profiling tome consumed goes up by a factor of 20! Perhaps profiling prevents the application of an optimisation which is in fact a pessimisation for your programme. Does looking at the generated Core reveal something? (if you make the code available, others could look too) What are the times when you compile with -O[2]? > > 1) Am I misinterpreting the results? > 2) If not, does this look familiar to anyone? > 3) If so, whether should I look first to see what is going on here? Look at the Core, ask on glasgow-haskell-users/open a ticket so that you have a better chance of getting the attention of an expert (the GHC team don't regularly follow the cafe). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Where is the CABAL file for haskell-platform 2010.2.0.0?
I'm not sure I'm reading the release plan for 2011.x.0.0[1] correctly (the switching between 2011.1.0.0 and 2011.2.0.0 is *very* confusing) but it looks like a stable release is scheduled for Feb 1,2011. I was expecting that the link on the front page[2] would lead to the 2010.2.0.0 release until a new stable version was released. This doesn't seem to be the case however: % curl -s http://code.haskell.org/haskell-platform/haskell-platform.cabal | head name:haskell-platform version: 2011.1.0.0 homepage:http://haskell.org/platform license: BSD3 license-file:LICENSE author: librar...@haskell.org maintainer: haskell-platf...@projects.haskell.org category:System synopsis:The Haskell Platform description: Where can I find the cabal file for 2010.2.0.0 until 2011.1.0.0 is formally released (or will it be 2011.2.0.0 as the release plan says)? Will the CABAL file for 2010.2.0.0 not be available *at all* after 2011.x.0.0 is released? /M [1]: http://trac.haskell.org/haskell-platform/wiki/ReleaseTimetable [2]: http://code.haskell.org/haskell-platform/haskell-platform.cabal -- Magnus Therning OpenPGP: 0xAB4DFBA4 email: mag...@therning.org jabber: mag...@therning.org twitter: magthe http://therning.org/magnus ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building lambdabot
On Thu, Jan 20, 2011 at 3:24 AM, Max Bolingbroke wrote: > On 20 January 2011 01:51, Gwern Branwen wrote: >> It had a lot of issues which meant it wouldn't build anywhere, where >> at least the Hackage version worked at some point. I spent this >> evening working on fixing issues (rewriting the show package to use >> QuickCheck 2 rather than QuickCheck 1 was not fun!) and have uploaded >> a lambdabot and show that compile for me on GHC 6.12.1 > > The show package almost compiles on GHC 7, but: > > * You need to loosen the base upper bound to < 4.4 > * If using base >= 4, you need to depend on the syb package as well > (current version 0.3) Would this break GHC 6.12 builds? Since I do not have GHC 7 installed and, given the breakage I experienced when I installed it the other day and tried to cabal-install my usual tools, will not have it installed any time soon, I am leery of any GHC 7-related changes. data-memocombinators is only the tip of the iceberg; I believe much of lambdabot would need modifications. (Apparently Control.OldException has gone away, which alone guarantees many changes.) So there wouldn't be much point to changing show. -- gwern http://www.gwern.net ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building lambdabot
On 20 January 2011 17:30, Gwern Branwen wrote: >> * You need to loosen the base upper bound to < 4.4 >> * If using base >= 4, you need to depend on the syb package as well >> (current version 0.3) > > Would this break GHC 6.12 builds? Thats why I suggested the flag stanza. Cabal has a weird kind of flag semantics where it will try every possible combination of flags until it finds one that builds. The solution I suggested uses this behaviour to either depend on base >= 4 && < 4.4 WITH syb, OR base < 4 WITHOUT syb. Because of the default flag setting of True, the first possibility will be tried first, but it if fails Cabal will just fall back on base < 4. In short, it should work perfectly for either GHC 7 or 6.12 clients (modulo syntax issues - I haven't actually tried the syntax I sent you). > data-memocombinators is only the tip of the iceberg; I believe much of > lambdabot would need modifications. (Apparently Control.OldException > has gone away, which alone guarantees many changes.) So there wouldn't > be much point to changing show. Actually, I: * Fixed the show upper bound * Fixed data-memocombinators and data-inttrie upper bounds (and sent a pull request to get Luke to take these changes upstream) * Got Wouter to change the upper bound on IOSpec (will be in the 0.2.2 release, out soon) And after all that lambdabot seemed to compile OK (though I got a link-time error about iconv because I'm on a Mac). So if you fix show GHC 7 users will be able to cabal install lambdabot! Cheers, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A question about monad based on http://en.wikipedia.org/wiki/Monad_(category_theory)
On Mon, Jan 17, 2011 at 9:46 PM, C K Kashyap wrote: > > I am not able to fully understand how those diagrams translate to haskell - > I can guess that T^2 -> T referes to things like concat operation but not > able to relate it to bind. > > I found it useful to work out the correspondence between monoids and monads; lots of introductory texts on CT give the example of the category Mon so I won't bore you with an account here. Thinking about monoids and monads helped me move past element-centric thinking toward the arrow-centric way of thinking in CT. In particular it's helpful to work out how the mu operator of a monad (which composes arrows) is a kind of abstraction of monoid operators (which combine elements). What you end up with is the monad as a device you can use to make non-monoidal things behave like monoids - closure, associativity, identity. For bind, google around for Kleisli Category and Kleisli star. I think of the latter as a kind of hybrid of a function and a functor, although I'm not entirely sure that's correct. -Gregg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Where is the CABAL file for haskell-platform 2010.2.0.0?
On 11-01-20 10:38 AM, Magnus Therning wrote: Where can I find the cabal file for 2010.2.0.0 until 2011.1.0.0 is formally released (or will it be 2011.2.0.0 as the release plan says)? Will the CABAL file for 2010.2.0.0 not be available *at all* after 2011.x.0.0 is released? Start from the real front page http://haskell.org/platform Click on the "Linux" link. Scroll down for either heading "Build from source" or "Build from cabal". There are links to tarballs. They are still 2010.2.0.0. Inside the tarballs is haskell-platform.cabal somewhere. P.S. I am not sure why you are so fixated on the haskell-platform.cabal file itself. It is not like it is of any use outside the context of the full source code. P.P.S. I do not even know, by merely exploring links transitively beginning from the real front page, how to reach an url for haskell-platform.cabal alone. I infer that such an url is for internal use only. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell time line?
On 20 Jan 2011, at 14:40, michael rice wrote: Maybe a better question would be which of these features, *weren't* present at first launch? The only obvious feature that was missing in 1990 was monads (at least built-in support for them). Do-notation for instance was first introduced by Mark Jones in Gofer (which later became Hugs), in version 2.30, in June 1994. Many of the specific monads (e.g. Software Transactional Memory) necessarily came later as well, for obvious reasons. Regards, Malcolm ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Where is the CABAL file for haskell-platform 2010.2.0.0?
On 20/01/11 18:08, Albert Y. C. Lai wrote: > On 11-01-20 10:38 AM, Magnus Therning wrote: >> Where can I find the cabal file for 2010.2.0.0 until 2011.1.0.0 is formally >> released (or will it be 2011.2.0.0 as the release plan says)? Will the >> CABAL file for 2010.2.0.0 not be available *at all* after 2011.x.0.0 is >> released? > > Start from the real front page http://haskell.org/platform Which redirects to http://hackage.haskell.org/platform/ > Click on the "Linux" link. > > Scroll down for either heading "Build from source" or "Build from cabal". > > There are links to tarballs. They are still 2010.2.0.0. > > Inside the tarballs is haskell-platform.cabal somewhere. Thanks, but that's hardly an obvious route to find it. See the full route I followed further down. > P.S. I am not sure why you are so fixated on the haskell-platform.cabal file > itself. It is not like it is of any use outside the context of the full > source code. It's most definitely of use to me outside of the context of the full source code, which is why I'm looking for it :-) > P.P.S. I do not even know, by merely exploring links transitively beginning > from the real front page, how to reach an url for haskell-platform.cabal > alone. I infer that such an url is for internal use only. Go to http://hackage.haskell.org/platform/ click on the link after the text "Current stable release:". You then end up on the page at http://hackage.haskell.org/platform/changelog.html, now click on the first link on that page, the one that's labelled "this Cabal file". /M -- Magnus Therning OpenPGP: 0xAB4DFBA4 email: mag...@therning.org jabber: mag...@therning.org twitter: magthe http://therning.org/magnus signature.asc Description: OpenPGP digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] class-instance
On Wed, Jan 19, 2011 at 11:56 PM, Patrick Browne wrote: > I am trying to see what how this requirement can be represented using > just the normal instance-implements-class relation for a comparison with > a specification language approach. > > If there is no simple way to do this using type classes then I am > obviously mis-using the technique. Going back to your original message: -- My intension is that the PERSON class should *specify* -- that a person has a constant id called p1 -- and that a person has a name that can be found from the id. You can do this with type level numerals. data Z data S a type Zero = Z type One = S Zero type Two = S One -- etc class PersonId a where name :: a -> String instance PersonId Z where name _ = "John" instance PersonId (S Z) where name _ = "Julie" main = putStrLn (name (undefined :: One)) -- prints "Julie" -- ryan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] class-instance
Ryan, This is exactly what I was looking for. Thanks, Pat On 20/01/2011 18:56, Ryan Ingram wrote: > On Wed, Jan 19, 2011 at 11:56 PM, Patrick Browne > wrote: >> I am trying to see what how this requirement can be represented using >> just the normal instance-implements-class relation for a comparison with >> a specification language approach. >> >> If there is no simple way to do this using type classes then I am >> obviously mis-using the technique. > > Going back to your original message: > > -- My intension is that the PERSON class should *specify* > -- that a person has a constant id called p1 > -- and that a person has a name that can be found from the id. > > You can do this with type level numerals. > > data Z > data S a > > type Zero = Z > type One = S Zero > type Two = S One > -- etc > > class PersonId a where > name :: a -> String > > instance PersonId Z where > name _ = "John" > instance PersonId (S Z) where > name _ = "Julie" > > main = putStrLn (name (undefined :: One)) -- prints "Julie" > > -- ryan This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] class-instance
> On 20/01/2011 18:56, Ryan Ingram wrote: >> On Wed, Jan 19, 2011 at 11:56 PM, Patrick Browne >> wrote: >>> I am trying to see what how this requirement can be represented using >>> just the normal instance-implements-class relation for a comparison with >>> a specification language approach. >>> >>> If there is no simple way to do this using type classes then I am >>> obviously mis-using the technique. >> Going back to your original message: >> >> -- My intension is that the PERSON class should *specify* >> -- that a person has a constant id called p1 >> -- and that a person has a name that can be found from the id. >> >> You can do this with type level numerals. >> >> data Z >> data S a >> >> type Zero = Z >> type One = S Zero >> type Two = S One >> -- etc >> >> class PersonId a where >> name :: a -> String >> >> instance PersonId Z where >> name _ = "John" >> instance PersonId (S Z) where >> name _ = "Julie" >> >> main = putStrLn (name (undefined :: One)) -- prints "Julie" Do the ids need to be numbers? You could also define data John data Julie instance PersonId John where name _ = "John" instance PersonId Julie where name _ = "Julie" ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building lambdabot
On Thu, Jan 20, 2011 at 12:45 PM, Max Bolingbroke wrote: > On 20 January 2011 17:30, Gwern Branwen wrote: >>> * You need to loosen the base upper bound to < 4.4 >>> * If using base >= 4, you need to depend on the syb package as well >>> (current version 0.3) >> >> Would this break GHC 6.12 builds? > > Thats why I suggested the flag stanza. Cabal has a weird kind of flag > semantics where it will try every possible combination of flags until > it finds one that builds. The solution I suggested uses this behaviour > to either depend on base >= 4 && < 4.4 WITH syb, OR base < 4 WITHOUT > syb. Because of the default flag setting of True, the first > possibility will be tried first, but it if fails Cabal will just fall > back on base < 4. > > In short, it should work perfectly for either GHC 7 or 6.12 clients > (modulo syntax issues - I haven't actually tried the syntax I sent > you). No, there's another issue. I've recorded this version; hunk ./show/show.cabal 25 +Flag base4 + Description: Build with base-4 + Default: False + hunk ./show/show.cabal 32 - build-depends: base<4, random, QuickCheck>=2.4, smallcheck>=0.4 + build-depends: random, QuickCheck>=2.4, smallcheck>=0.4 + if flag(base4) +build-depends: base>=4 && <4.4, syb >= 0.3 && < 0.4 + else +build-depends: base<4 Notice the flag defaults to False, not True. When I tried it with True, I got: $ cabal install Resolving dependencies... cabal: dependencies conflict: base-3.0.3.2 requires syb ==0.1.0.2 however syb-0.1.0.2 was excluded because syb-0.3 was selected instead syb-0.1.0.2 was excluded because show-0.4.1 requires syb ==0.3.* -- gwern http://www.gwern.net ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Are constructors strict?
I am having hard time understanding the following paragraph in "Purely functional Lazy non-deterministic programing" paper http://www.cs.rutgers.edu/~ccshan/rational/lazy-nondet.pdf The problem with the naive monadic encoding of non-determinism is that the arguments to a constructor must be deterministic. If these arguments are themselves results of non-deterministic computations, these computations must be performed completely before we can apply the constructor to build a non-deterministic result. Why does the argument to constructors must be deterministic?WHy is it that thunks are not used in this case? Thanks -- Daryoush Weblog: http://onfp.blogspot.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A question about monad laws
C K Kashyap schrieb: > Hi, > I am trying to get a better understanding of the "monad laws" - right > now, it seems too obvious > and pointless. I had similar feelings about identity function when I > first saw it but understood its use > when I saw it in action. > Could someone please help me get a better understanding of the necessity > of monads complying with these laws? > I think, examples of somethings stop working if the monad does not obey > these laws will help me understand it better. http://www.haskell.org/haskellwiki/Monad_laws ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Are constructors strict?
Hello Daryoush, That is a good question, and depends on distinguishing between laziness and nondeterminism. Suppose I have a normal, lazily evaluated list: [1,2...] There are thunks used in this case, but the end result is fully deterministic: the next will always be 3, and then 4, and so on. So thunks don't give us nondeterminism; we need some other mechanism (whether it's another list encoding the choices, or a more sophisticated backtracking monad.) Edward ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building lambdabot
On 20 January 2011 20:50, Gwern Branwen wrote: > Notice the flag defaults to False, not True. When I tried it with True, I got: > > $ cabal install > Resolving dependencies... > cabal: dependencies conflict: base-3.0.3.2 requires syb ==0.1.0.2 however > syb-0.1.0.2 was excluded because syb-0.3 was selected instead > syb-0.1.0.2 was excluded because show-0.4.1 requires syb ==0.3.* Suprising. It certainly seems to contradict my understanding of how Cabal works (which is derived from http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#conditional-resolution) Anyway, I'm glad that you have recorded a patch which at least gives GHC 7 a chance of working. If I knew where the repo was I would try it out (it doesn't seem to be linked anywhere from http://hackage.haskell.org/packages/archive/show/0.4.1/show.cabal). Cheers, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building lambdabot
On Thu, Jan 20, 2011 at 5:33 PM, Max Bolingbroke wrote: > On 20 January 2011 20:50, Gwern Branwen wrote: >> Notice the flag defaults to False, not True. When I tried it with True, I >> got: >> >> $ cabal install >> Resolving dependencies... >> cabal: dependencies conflict: base-3.0.3.2 requires syb ==0.1.0.2 however >> syb-0.1.0.2 was excluded because syb-0.3 was selected instead >> syb-0.1.0.2 was excluded because show-0.4.1 requires syb ==0.3.* > > Suprising. It certainly seems to contradict my understanding of how > Cabal works (which is derived from > http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#conditional-resolution) > > Anyway, I'm glad that you have recorded a patch which at least gives > GHC 7 a chance of working. If I knew where the repo was I would try it > out (it doesn't seem to be linked anywhere from > http://hackage.haskell.org/packages/archive/show/0.4.1/show.cabal). It's just a folder in the lambdabot repo, as is lambdabot-utils and unlambda and brainfuck. -- gwern http://www.gwern.net ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building lambdabot
On 20 January 2011 22:39, Gwern Branwen wrote: > It's just a folder in the lambdabot repo, as is lambdabot-utils and > unlambda and brainfuck. I'm happy to report that show-0.4.1.1 does in fact build in my GHC 7 environment unmodified, so the Cabal hackery is working. You might consider pushing this tweaked version to Hackage. Cheers, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Browser Game Engine
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 1/17/11 12:16 , Jeremy Shaw wrote: > The must be at least a million flash games, so clearly it can be used for > that. If you create a flash game, nobody gets excited. But if you create an > html5 based game, then people still get excited about that. So, I assume it > must be hard :) I think not so much hard as new. The latest Exciting! New! Web! Tech! (*yawn*... sorry, my cynicism is showing) - -- brandon s. allbery [linux,solaris,freebsd,perl] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEUEARECAAYFAk04zbcACgkQIn7hlCsL25Wh2ACXYKfES4AUgiLjzy9wp5NHPOga mgCeJDnbzxX4QQzeW5jY0dlxoWszAhQ= =fhJw -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hledget: mtv vs transformers
You mean mtl 2.*, right ? Yes that is a problem. I'm nervous about requiring mtl 2 because when I bumped hledger 0.13's process dependency to 0.14 for similar reasons it made all kinds of trouble for folks who just want to install the hledger core in standard/older haskell environments. On Jan 20, 2011, at 5:11 PM, Dmitry Astapov wrote: Since hledger-chart depends on Chart, which in turn depends on transformers 0.2.*, it will make a sense to bump all mtl dependencies in hledger to 2.2 When one does "make install" with older GHC (like 6.12.1, for example), and mtl 1.x is available, it would be happily used for hledger-lib and hledger, but compilation of hledger-chart will pull in transformers 0.2 (but not the newer mtl) and will fail due to conflicting instances. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] windows network programming
I tried this as an example and got the following error when running. net.exe: connect: failed (Connection refused (WSAECONNREFUSED)) Firewall is off, running as administrator Windows is Windows 7 Enterprise. Advice on what to do next is appreciated On Tue, Nov 2, 2010 at 1:24 PM, Nils Schweinsberg wrote: > Am 02.11.2010 19:57, schrieb Michael Litchard: > > got any urls with examples? >> > > Sure, see this short server-client-ping-pong application. > > By the way, I noticed that you don't need withSocketsDo on windows 7, but I > guess it's there for a reason for older windows versions. :) > > > >import Control.Concurrent >import Network >import System.IO > >main :: IO () >main = withSocketsDo $ do >forkIO waitAndPong >ping > >-- The basic server >waitAndPong :: IO () >waitAndPong = do >socket <- listenOn (PortNumber 1234) >(handle,_,_) <- accept socket >hSetBuffering handle LineBuffering >incoming <- hGetLine handle >putStrLn ("> " ++ incoming) >hPutStrLn handle "pong" > >-- The basic client >ping :: IO () >ping = do >handle <- connectTo "localhost" (PortNumber 1234) >hSetBuffering handle LineBuffering >hPutStrLn handle "ping" >incoming <- hGetLine handle >putStrLn ("< " ++ incoming) > > ___ > 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] windows network programming
freenode figured this out. Pasting here for future reference. import Control.Concurrent import Network import System.IO main :: IO () main = withSocketsDo $ do m <- newEmptyMVar forkIO (waitAndPong m) ping m -- The basic server waitAndPong :: MVar () -> IO () waitAndPong m = do socket <- listenOn (PortNumber 8000) putMVar m () (handle,_,_) <- accept socket hSetBuffering handle LineBuffering incoming <- hGetLine handle putStrLn ("> " ++ incoming) hPutStrLn handle "pong" -- The basic client ping :: MVar () -> IO () ping m = do _ <- takeMVar m handle <- connectTo "localhost" (PortNumber 8000) hSetBuffering handle LineBuffering hPutStrLn handle "ping" incoming <- hGetLine handle putStrLn ("< " ++ incoming) On Thu, Jan 20, 2011 at 6:17 PM, Michael Litchard wrote: > I tried this as an example and got the following error when running. > > net.exe: connect: failed (Connection refused (WSAECONNREFUSED)) > > Firewall is off, running as administrator > > Windows is Windows 7 Enterprise. > > Advice on what to do next is appreciated > > > On Tue, Nov 2, 2010 at 1:24 PM, Nils Schweinsberg wrote: > >> Am 02.11.2010 19:57, schrieb Michael Litchard: >> >> got any urls with examples? >>> >> >> Sure, see this short server-client-ping-pong application. >> >> By the way, I noticed that you don't need withSocketsDo on windows 7, but >> I guess it's there for a reason for older windows versions. :) >> >> >> >>import Control.Concurrent >>import Network >>import System.IO >> >>main :: IO () >>main = withSocketsDo $ do >>forkIO waitAndPong >>ping >> >>-- The basic server >>waitAndPong :: IO () >>waitAndPong = do >>socket <- listenOn (PortNumber 1234) >>(handle,_,_) <- accept socket >>hSetBuffering handle LineBuffering >>incoming <- hGetLine handle >>putStrLn ("> " ++ incoming) >>hPutStrLn handle "pong" >> >>-- The basic client >>ping :: IO () >>ping = do >>handle <- connectTo "localhost" (PortNumber 1234) >>hSetBuffering handle LineBuffering >>hPutStrLn handle "ping" >>incoming <- hGetLine handle >>putStrLn ("< " ++ incoming) >> >> ___ >> 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] parsec2 vs. parsec3... again
>> I think my short term solution is going to be remove -auto-all from >> attoparsec's cabal---I'm not profiling attoparsec and so I don't want >> my entire profile output to be internal attoparsec functions. But >> presumably the flag was added there for a reason, so maybe there are >> people who really want that. > > Yes - me :-) Yes, certainly it makes sense for someone profiling the library itself, or if I thought your library was too slow and wanted to send a profile in a bug report. But I don't think it makes so much sense for plain users, especially when it's applied only to some libraries. However, this seems to be a fairly common practice... at least parsec3 and text both do this, which is why I initially thought parsec3 was so much slower than parsec2, and attoparsec-text was doubly slow. > I might, though, see if there's a way I could enable that flag only for > myself (in a way that I wouldn't routinely forget). This sounds like a good idea to me. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hledget: mtv vs transformers
Couldn't you depend on either version of mtl? On Fri, Jan 21, 2011 at 3:37 AM, Simon Michael wrote: > You mean mtl 2.*, right ? > > Yes that is a problem. I'm nervous about requiring mtl 2 because when I > bumped hledger 0.13's process dependency to 0.14 for similar reasons it made > all kinds of trouble for folks who just want to install the hledger core in > standard/older haskell environments. > > On Jan 20, 2011, at 5:11 PM, Dmitry Astapov wrote: >> >> Since hledger-chart depends on Chart, which in turn depends on >> transformers 0.2.*, it will make a sense to bump all mtl dependencies in >> hledger to 2.2 >> >> When one does "make install" with older GHC (like 6.12.1, for example), >> and mtl 1.x is available, it would be happily used for hledger-lib and >> hledger, but compilation of hledger-chart will pull in transformers 0.2 (but >> not the newer mtl) and will fail due to conflicting instances. > > > ___ > 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