Re: [GHC] #4943: Another odd missed SpecConstr opportunity
#4943: Another odd missed SpecConstr opportunity -+-- Reporter: batterseapower|Owner: Type: bug | Status: new Priority: normal|Milestone: Component: Compiler | Version: 7.1 Keywords:| Testcase: Blockedby:| Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: Runtime performance bug -+-- Comment(by simonpj): Are you sure? Here's what I get with HEAD (`-O2 -ddump-simpl`). Looks good, except for the awkward felicity of passing unused arguments around the loop (#4941): {{{ Rec { $s$wa_r1Hy :: forall s_aIE. GHC.Types.Int - GHC.Types.Int - GHC.Types.Int - GHC.Prim.MutableByteArray# s_aIE - GHC.Prim.Int# - GHC.Prim.Int# - GHC.Prim.Int# - GHC.Prim.State# s_aIE - (# GHC.Prim.State# s_aIE, () #) [GblId, Arity=8, Caf=NoCafRefs, Str=DmdType ] $s$wa_r1Hy = \ (@ s_aIE) (sc_s1Gq :: GHC.Types.Int) (sc1_s1Gr :: GHC.Types.Int) (sc2_s1Gs :: GHC.Types.Int) (sc3_s1Gt :: GHC.Prim.MutableByteArray# s_aIE) (sc4_s1Gu :: GHC.Prim.Int#) (sc5_s1Gv :: GHC.Prim.Int#) (sc6_s1Gw :: GHC.Prim.Int#) (sc7_s1Gx :: GHC.Prim.State# s_aIE) - case GHC.Prim.# sc5_s1Gv sc6_s1Gw of _ { GHC.Types.False - case GHC.Prim.readIntArray# @ s_aIE sc3_s1Gt sc5_s1Gv sc7_s1Gx of _ { (# s2#_aRI, e#_aRJ #) - case GHC.Prim.writeIntArray# @ s_aIE sc3_s1Gt sc5_s1Gv (GHC.Prim.+# e#_aRJ sc4_s1Gu) s2#_aRI of s2#1_aS8 { __DEFAULT - $s$wa_r1Hy @ s_aIE sc_s1Gq sc1_s1Gr sc2_s1Gs sc3_s1Gt sc4_s1Gu (GHC.Prim.+# sc5_s1Gv 1) sc6_s1Gw s2#1_aS8 } }; GHC.Types.True - (# sc7_s1Gx, GHC.Unit.() #) } end Rec } }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4943#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #4852: cabal doesn't tell ./configure which gcc to use
#4852: cabal doesn't tell ./configure which gcc to use --+- Reporter: kazu-yamamoto |Owner: igloo Type: bug| Status: new Priority: highest|Milestone: 7.0.2 Component: libraries (other) | Version: 7.1 Keywords: | Testcase: Blockedby: | Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: Other --+- Comment(by kazu-yamamoto): I tested this with today's the ghc-7.0 branch compiled with GHC 6.12.3/32bit on Snow Leapard. hsc2hs does not work well yet. Afeter modifiying {{{ SC2HS_EXTRA=--cflag=-march=i686 --cflag=-m32 --cflag=-isysroot --cflag=/Devel oper/SDKs/MacOSX10.5.sdk --cflag=-mmacosx-version-min=10.5 --cflag=-fno- stack-pr otector }}} to {{{ HSC2HS_EXTRA=--cflag=-isysroot --cflag=/Developer/SDKs/MacOSX10.6.sdk --cflag=- mmacosx-version-min=10.5 --cflag=-fno-stack-protector }}} everything became fine. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4852#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #4944: -fvia-C/asm mangler broken on registerised powerpc-linux build (was: -fvia-C/asm mangler broken on regiserised powerpc-linux build)
#4944: -fvia-C/asm mangler broken on registerised powerpc-linux build +--- Reporter: kgardas | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.0.1|Keywords: Testcase: | Blockedby: Os: Linux|Blocking: Architecture: powerpc | Failure: None/Unknown +--- -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4944#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #4943: Another odd missed SpecConstr opportunity
#4943: Another odd missed SpecConstr opportunity -+-- Reporter: batterseapower|Owner: Type: bug | Status: new Priority: normal|Milestone: Component: Compiler | Version: 7.1 Keywords:| Testcase: Blockedby:| Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: Runtime performance bug -+-- Comment(by batterseapower): I *do* get that result if I disable case liberation. The issue is that it totally fails to happen if I turn case liberation off. I don't have a build of HEAD on this laptop, but the attached code compiles as follows with 6.12: {{{ Rec { $wa_r1y9 :: forall s_aGn. Data.Array.Base.STUArray s_aGn GHC.Types.Int GHC.Types.Int - GHC.Types.Int - GHC.Prim.Int# - GHC.Prim.Int# - GHC.Prim.State# s_aGn - (# GHC.Prim.State# s_aGn, () #) [GblId, Arity=5, Caf=NoCafRefs, Str=DmdType L] $wa_r1y9 = \ (@ s_aGn) (w_s1wz :: Data.Array.Base.STUArray s_aGn GHC.Types.Int GHC.Types.Int) (w1_s1wA :: GHC.Types.Int) (ww_s1wD :: GHC.Prim.Int#) (ww1_s1wH :: GHC.Prim.Int#) (w2_s1wJ :: GHC.Prim.State# s_aGn) - case GHC.Prim.# ww_s1wD ww1_s1wH of _ { GHC.Bool.False - case w_s1wz of wild1_aPx { Data.Array.Base.STUArray ds2_aPz ds3_aPA ds4_aPB marr#_aPC - case GHC.Prim.readIntArray# @ s_aGn marr#_aPC ww_s1wD w2_s1wJ of _ { (# s2#_aPK, e#_aPL #) - case w1_s1wA of wild11_aQm { GHC.Types.I# y_aQo - case GHC.Prim.writeIntArray# @ s_aGn marr#_aPC ww_s1wD (GHC.Prim.+# e#_aPL y_aQo) s2#_aPK of s2#1_aQc { __DEFAULT - $wa_r1y9 @ s_aGn wild1_aPx wild11_aQm (GHC.Prim.+# ww_s1wD 1) ww1_s1wH s2#1_aQc } } } }; GHC.Bool.True - (# w2_s1wJ, GHC.Unit.() #) } end Rec } }}} This is bad. The command line was: {{{ ghc -O2 -fno-liberate-case -ddump-simpl -c -fforce-recomp STUArray- Rewrite2.hs }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4943#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #4943: Another odd missed SpecConstr opportunity
#4943: Another odd missed SpecConstr opportunity -+-- Reporter: batterseapower|Owner: Type: bug | Status: new Priority: normal|Milestone: Component: Compiler | Version: 7.1 Keywords:| Testcase: Blockedby:| Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: Runtime performance bug -+-- Comment(by batterseapower): Sorry, read disable case liberation as enable case liberation above. (I don't have enough permissions to edit tickets, even my own contributions :-) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4943#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #3843: Merge plugins into HEAD
#3843: Merge plugins into HEAD -+-- Reporter: dreixel |Owner: simonpj Type: task | Status: new Priority: normal|Milestone: 7.0.2 Component: Compiler | Version: 6.13 Keywords:| Testcase: Blockedby:| Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: None/Unknown -+-- Changes (by shelarcy): * cc: shelarcy@… (added) Comment: I'd like to use some plugins when plugins is merged to ghc HEAD branch. So, I write an opinion about plugin users' point of view. I want to use strict-ghc-plugins. Off course I know that ghc's profiler supports to find space leak problem. But I want adding strict-ghc-plugins in my toolbox to solve space leak problem. https://github.com/thoughtpolice/strict-ghc-plugin I want to use supercompiler plugin. I think Neil Mitchell will provide plugin version of supero after plugins is merged. (From this mail, Neil is interested in plugin. http://www.haskell.org/pipermail/glasgow-haskell- users/2011-January/019901.html So, I think he will provide plugin version of supero.) I also think that somebody else can provide alternative supercompilation system as a plugin. I'd like to trying to use these system for optimizing my program. http://hackage.haskell.org/package/supero And if someone write plugin version of Static contract checking, then I want to use that. I think merging Static contract checking is difficult. Because compiler becomes slow when merging Static contract checking. But if plugins would be merged, we could make plugin version more easily. http://research.microsoft.com/en- us/um/people/simonpj/papers/verify/index.htm -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/3843#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #3843: Merge plugins into HEAD
#3843: Merge plugins into HEAD -+-- Reporter: dreixel |Owner: simonpj Type: task | Status: new Priority: normal|Milestone: 7.0.2 Component: Compiler | Version: 6.13 Keywords:| Testcase: Blockedby:| Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: None/Unknown -+-- Comment(by shelarcy): One problem is that there is no patch for Cabal. I think we need Cabal support for plugins. cse-ghc-plugins and strict-ghc-plugins require to link GHC API. This means that code bloat occurs when building package that depends on plugin. If we want to avoid code bloat, we must split plugin into annotation package and plugin package. This is not good. Does anyone has an idea that solves this problem? This is just Cabal's problem. So, I don't know we should discuss here, or we should discuss on Hackage project's Ticket after plugin is merged in GHC HEAD. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/3843#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #4852: cabal doesn't tell ./configure which gcc to use
#4852: cabal doesn't tell ./configure which gcc to use --+- Reporter: kazu-yamamoto |Owner: igloo Type: bug| Status: new Priority: highest|Milestone: 7.0.2 Component: libraries (other) | Version: 7.1 Keywords: | Testcase: Blockedby: | Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: Other --+- Comment(by igloo): Hmm, this should be fixed now. Can you please tell me exactly what commands you are running, and what the output is, so that I can try to reproduce your problem? Also, what does {{{ ghc --info ghc +RTS --info }}} say for the ghc-7.0 branch compiler? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4852#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #4860: Text.Regex crasher
#4860: Text.Regex crasher -+-- Reporter: batkins | Owner: Type: bug | Status: new Priority: high| Milestone: 7.0.2 Component: libraries/base |Version: 7.0.1 Resolution: | Keywords: regex crash Testcase: | Blockedby: Difficulty: | Os: MacOS X Blocking: | Architecture: x86 Failure: Runtime crash | -+-- Comment(by igloo): I wasn't able to reproduce this, but there's a good chance it's fixed by the #4852 changes. Can you test the 7.0 branch and see if you can still reproduce the problem please? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4860#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #4943: Another odd missed SpecConstr opportunity
#4943: Another odd missed SpecConstr opportunity -+-- Reporter: batterseapower|Owner: Type: bug | Status: merge Priority: normal|Milestone: Component: Compiler | Version: 7.1 Keywords:| Testcase: Blockedby:| Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: Runtime performance bug -+-- Changes (by simonpj): * status: new = merge Comment: Aha. Thank you. You're dead right. How embarrassing. {{{ Thu Feb 3 17:27:56 GMT 2011 simo...@microsoft.com * Fix typo in SpecConstr that made it not work at all There was a terrible typo in this patch; I wrote env instead of env1. Mon Jan 31 11:35:29 GMT 2011 simo...@microsoft.com * Improve Simplifier and SpecConstr behaviour Anyway, this fix is essential to make it work properly. Thanks to Max for spotting the problem (again). M ./compiler/specialise/SpecConstr.lhs -1 +1 }}} Please merge. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4943#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #4385: Type-level natural numbers
#4385: Type-level natural numbers +--- Reporter: diatchki |Owner: diatchki Type: feature request | Status: new Priority: normal |Milestone: 7.2.1 Component: Compiler (Type checker) | Version: Keywords: | Testcase: Blockedby: | Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: None/Unknown +--- Comment(by diatchki): Hello, For the moment, there is no support for ad-hoc proofs. The problem you describe might occur when GHC encounters a type signature but it cannot show that the context of the type signature is sufficient to justify the function's implementation. As you say, this may be because GHC does not know enough math. In this case, one would have to either change (or remove) the type signature, or change the implementation (and, if the inference seems obvious, then send an e-mail to the GHC list so that we can teach GHC some more math :-). {{{unsafeCoerce}}} works as usual but I've never had to use it because, usually, there is something different one can do. For example, the array indexes that you mentioned use type-nats as a phantom type only, so the library could provide arbitrary coercion functions, including something based on manual evidence construction, but I have not really thought about that. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4385#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #4385: Type-level natural numbers
#4385: Type-level natural numbers +--- Reporter: diatchki |Owner: diatchki Type: feature request | Status: new Priority: normal |Milestone: 7.2.1 Component: Compiler (Type checker) | Version: Keywords: | Testcase: Blockedby: | Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: None/Unknown +--- Comment(by pumpkin): The main application I'm thinking about is REPA right now, which uses a fairly complex type to describe the shape of multidimensional arrays. The type is, however, not fully representative of the actual shape of the array, because we don't have easy type-level naturals. There's also some confusing overlap between the type-level shape (which mostly encodes the number of dimensions of the array) and the value-level shape (which actually contains the dimensions). Using your typenats and some fancy GADT trickery, the index computations could be made exact and proved correct at compile time, to avoid any kind of index checking at runtime, but the computation is non-trivial, and basically involves proving that if you have a list of dimensions and a list of indices, then the usual multidimensional flattening computation preserves the length requirement for the flat underlying array. I was modeling REPA in Agda a while back and came up with this: {{{ data Shape : ℕ → Set where Z : Shape 1 _∷_ : ∀ {n} → (ss : Shape n) → (s : ℕ) → Shape (suc s * n) data Index : ∀ {n} → Shape n → Set where Z : Index Z _∷_ : ∀ {m} {sh : Shape m} {n} → (is : Index sh) → (i : Fin (suc n)) → Index (sh ∷ n) flatten : ∀ {n} {sh : Shape n} → Index sh → Fin n flatten = {- lots more stuff to prove that the flattening computation preseves the Fin -} }}} Although this is dependently typed in Agda, it could be modeled in Haskell too using GADTs that refine the type index to a typenat multiplication. When I get the time to compile your repo, I'll try translating this to Haskell with typenats and see if it can spot the fairly complicated behavior that I need to prove manually in Agda. I'll be very happy if it can! Anyway, it's an exciting development in GHC! Now you just have to fight off all the proof-freaks like me that it attracts :P -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4385#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
[GHC] #4945: Another SpecConstr infelicity
#4945: Another SpecConstr infelicity -+-- Reporter: batterseapower| Owner: Type: bug | Status: new Priority: normal| Component: Compiler Version: 7.0.1 |Keywords: Testcase:| Blockedby: Os: Unknown/Multiple |Blocking: Architecture: Unknown/Multiple | Failure: Runtime performance bug -+-- I'm beginning to sound like a broken record, but SpecConstr still doesn't seem to be right! The last problem has been fixed, but I've found a new one. Please observe the output of compiling the attached code with: {{{ ./ghc -fforce-recomp -c -dverbose-core2core -O2 -fno-liberate-case STUArray-Rewrite2.hs }}} In the output of SpecConstr we have a local letrec: {{{ (letrec { $wa_s1G7 [Occ=LoopBreaker] :: forall s_aJm. Data.Array.Base.STUArray s_aJm GHC.Types.Int GHC.Types.Int - GHC.Prim.Int# - GHC.Prim.State# s_aJm - (# GHC.Prim.State# s_aJm, () #) [LclId, Arity=3, Str=DmdType LLL] $wa_s1G7 = \ (@ s_aJm) (w_s1FS :: Data.Array.Base.STUArray s_aJm GHC.Types.Int GHC.Types.Int) (ww_s1FV :: GHC.Prim.Int#) (w_s1FX :: GHC.Prim.State# s_aJm) - case GHC.Prim.# ww_s1FV ww_s1FN of wild_Xj [Dmd=Just A] { GHC.Types.False - case w_s1FS of wild_aTj [Dmd=Just L] { Data.Array.Base.STUArray ds1_aTl [Dmd=Just U] ds2_aTm [Dmd=Just U] n_aTn [Dmd=Just U(L)] ds3_aTo [Dmd=Just A] - case n_aTn of wild_aTs [Dmd=Just A] { GHC.Types.I# x_aTu [Dmd=Just L] - case $wa_s1G0 @ s_aJm w_s1FS (GHC.Types.I# ww_s1FV) 0 (GHC.Prim.-# x_aTu 1) w_s1FX of wild_XUw [Dmd=Just A] { (# new_s_XUB [Dmd=Just L], r_XUD [Dmd=Just A] #) - $wa_s1G7 @ s_aJm w_s1FS (GHC.Prim.+# ww_s1FV 1) new_s_XUB } } }; GHC.Types.True - (# w_s1FX, GHC.Unit.() #) }; } in $wa_s1G7) }}} This is a local recursive loop with an invariant first argument (w_s1FS) that is recrutinised every time! This seems deeply uncool. This is with HEAD (7.1.20110203, incorporating the patch Fix typo in SpecConstr that made it not work at all) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4945 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #4945: Another SpecConstr infelicity
#4945: Another SpecConstr infelicity -+-- Reporter: batterseapower| Owner: Type: bug | Status: new Priority: normal| Component: Compiler Version: 7.0.1 |Keywords: Testcase:| Blockedby: Os: Unknown/Multiple |Blocking: Architecture: Unknown/Multiple | Failure: Runtime performance bug -+-- Comment(by batterseapower): I see what is going on here. Since this is a local letrec, you don't generate any specialisations from the RHS call patterns unless at least one call pattern is boring. However, since the body doesn't apply *any* arguments at all to the function, SpecConstr doesn't detect any calls! How amusing :-) A quick and easy hack that would probably solve it would be to replace SpecConstr:1486 with: {{{ any isNothing mb_pats || null mb_pats }}} I can't test this right now. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4945#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #4945: Another SpecConstr infelicity
#4945: Another SpecConstr infelicity -+-- Reporter: batterseapower| Owner: Type: bug | Status: new Priority: normal| Component: Compiler Version: 7.0.1 |Keywords: Testcase:| Blockedby: Os: Unknown/Multiple |Blocking: Architecture: Unknown/Multiple | Failure: Runtime performance bug -+-- Comment(by batterseapower): OK, I did actually manage to try my fix, and I'm still not getting specialisation of that function. That observation might be part of the problem, but it's not the whole story. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4945#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #4804: ghc-stage2: Monadic.o: bus error / segmentation fault / internal error
#4804: ghc-stage2: Monadic.o: bus error / segmentation fault / internal error -+-- Reporter: altaic|Owner: Type: bug | Status: infoneeded Priority: high |Milestone: 7.2.1 Component: Compiler | Version: 7.1 Keywords:| Testcase: Blockedby:| Difficulty: Os: MacOS X | Blocking: Architecture: Unknown/Multiple | Failure: Building GHC failed -+-- Comment(by altaic): This still happens when building for i386 (bootstrapping from either my binary as shown earlier or the official i386 ghc-7.0.1 binary), however I was able to successfully build for x86_64 (bootstrapping from Gregory Wright's ghc x86_64 7.0.1 binary). I suspect the i386 build fails due to some kind of alignment issue during garbage collection... However I've poked around using gdb a fair amount without pinpointing the trouble. I consider x86_64 support more important these days than i386, so it's not a big deal to me. Just glad I can once again build HEAD. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4804#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #4938: Core2 CPU not detected correctly
#4938: Core2 CPU not detected correctly -+-- Reporter: altaic| Owner: Type: bug | Status: new Priority: normal| Component: Compiler Version: 7.1 |Keywords: Testcase:| Blockedby: Os: Unknown/Multiple |Blocking: Architecture: Unknown/Multiple | Failure: Building GHC failed -+-- Comment(by altaic): I've successfully built HEAD for x86_64, bootstrapping from Gregory Wright's x86_64 7.0.1 binary. So, it seems cross-compiling is broken. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4938#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #4852: cabal doesn't tell ./configure which gcc to use
#4852: cabal doesn't tell ./configure which gcc to use --+- Reporter: kazu-yamamoto |Owner: igloo Type: bug| Status: new Priority: highest|Milestone: 7.0.2 Component: libraries (other) | Version: 7.1 Keywords: | Testcase: Blockedby: | Difficulty: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: Other --+- Comment(by kazu-yamamoto): GHC 7.0: {{{ % ghc --info [(Project name,The Glorious Glasgow Haskell Compilation System) ,(Project version,7.0.1.20110201) ,(Booter version,6.12.3) ,(Stage,2) ,(Build platform,i386-apple-darwin) ,(Host platform,i386-apple-darwin) ,(Target platform,i386-apple-darwin) ,(Have interpreter,YES) ,(Object splitting,NO) ,(Have native code generator,YES) ,(Have llvm code generator,YES) ,(Support SMP,YES) ,(Unregisterised,NO) ,(Tables next to code,YES) ,(RTS ways,l debug thr thr_debug thr_l thr_p dyn debug_dyn thr_dyn thr_debug_dyn) ,(Leading underscore,YES) ,(Debug on,False) ,(LibDir,/ghc7.0.2/lib/ghc-7.0.1.20110201) ,(Global Package DB,/ghc7.0.2/lib/ghc-7.0.1.20110201/package.conf.d) ,(C compiler flags,[\-march=i686\,\-m32\,\-isysroot\,\/Developer/SDKs/MacOSX10.5.sdk \,\-mmacosx-version-min=10.5\,\-fno-stack-protector\]) ,(Gcc Linker flags,[\-march=i686\,\-m32\,\-isysroot\,\/Developer/SDKs/MacOSX10.5.sdk \,\-mmacosx-version-min=10.5\]) ,(Ld Linker flags,[\-arch\,\i386\,\-macosx_version_min\,\10.5\]) ] }}} {{{ % ghc +RTS --info [(GHC RTS, YES) ,(GHC version, 7.0.1.20110201) ,(RTS way, rts_thr) ,(Build platform, i386-apple-darwin) ,(Build architecture, i386) ,(Build OS, darwin) ,(Build vendor, apple) ,(Host platform, i386-apple-darwin) ,(Host architecture, i386) ,(Host OS, darwin) ,(Host vendor, apple) ,(Target platform, i386-apple-darwin) ,(Target architecture, i386) ,(Target OS, darwin) ,(Target vendor, apple) ,(Word size, 32) ,(Compiler unregisterised, NO) ,(Tables next to code, YES) ] }}} Booter: {{{ % ghc --info [(Project name,The Glorious Glasgow Haskell Compilation System) ,(Project version,6.12.3) ,(Booter version,6.12.2) ,(Stage,2) ,(Have interpreter,YES) ,(Object splitting,YES) ,(Have native code generator,YES) ,(Support SMP,YES) ,(Unregisterised,NO) ,(Tables next to code,YES) ,(Win32 DLLs,) ,(RTS ways,l debug thr thr_debug thr_l thr_p ) ,(Leading underscore,YES) ,(Debug on,False) ,(LibDir,/Library/Frameworks/GHC.framework/Versions/612/usr/lib/ghc-6.12.3) ] }}} {{{ % ghc +RTS --info [(GHC RTS, YES) ,(GHC version, 6.12.3) ,(RTS way, rts_thr) ,(Host platform, i386-apple-darwin) ,(Host architecture, i386) ,(Host OS, darwin) ,(Host vendor, apple) ,(Build platform, i386-apple-darwin) ,(Build architecture, i386) ,(Build OS, darwin) ,(Build vendor, apple) ,(Target platform, i386-apple-darwin) ,(Target architecture, i386) ,(Target OS, darwin) ,(Target vendor, apple) ,(Word size, 32) ,(Compiler unregisterised, NO) ,(Tables next to code, YES) ] }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/4852#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: GHCi+Cairo, Windows
Hi Alexey, On 01.02.2011, at 16:47, Alexey Shumitsky wrote: Hi, I have problem with ghci+cairo on windows. When I try to load, for example like this ghci -package cairo it fails with the following error: Loading package random-1.0.0.2 ... linking ... done. Loading package haskell98 ... linking ... done. Loading package syb-0.1.0.2 ... linking ... done. Loading package base-3.0.3.2 ... linking ... done. Loading package mtl-1.1.0.2 ... linking ... done. : C:\Users\alexeys\AppData\Roaming\cabal \cairo-0.12.0\ghc-6.12.3\HScairo-0.12.0.o: unknown symbol `_cairo_surface_destroy' Loading package cairo-0.12.0 ... linking ... : unable to load package `cairo-0.12.0' Even simplest programs don't work in interactive mode, like for example 'Text.hs' that comes with cairo package. However compiled with 'ghc --make' everything works as expected, so its not a missing dll problem - everything is in place. I used 'filemon' on ghci and in the log I can see that 'libcairo-2.dll' was found and loaded successfully (and this library has '_cairo_surface_destroy' symbol defined). So I don't understand - what more does it want and what can be done to combat it? Sorry about the slow feedback. I know that on Windows our Gtk2HsSetup.hs magic file does some name mangling that is necessary because the binary Gtk installer has some oddly named libraries. It might be that we didn't get this mangling right for cairo or that it has changed. I had hoped that somebody with a windows machine might reply to your problems. But maybe you could give us the version of the binary installer. If its new, then they might have changed the naming... Cheers, Axel ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: GHCi+Cairo, Windows
On Thu, Feb 3, 2011 at 9:15 AM, Axel Simon axel.si...@in.tum.de wrote: Hi Alexey, Sorry about the slow feedback. I know that on Windows our Gtk2HsSetup.hs magic file does some name mangling that is necessary because the binary Gtk installer has some oddly named libraries. It might be that we didn't get this mangling right for cairo or that it has changed. I had hoped that somebody with a windows machine might reply to your problems. But maybe you could give us the version of the binary installer. If its new, then they might have changed the naming... I took GTK binaries from official site, here: http://www.gtk.org/download-windows.html In particular, cairo libraries are these: http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo_1.10.2-1_win32.zip and http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo-dev_1.10.2-1_win32.zip. Also, I'm using HaskellPlatform-2010.2.0.0. ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: 4221 on new codegen
Correct. The Cmm optimiser is supposed to make correctness preserving transformations. The idea of the fuel is that you can binary chop your way to a situation where Fuel = 0-143Program works Fuel = 144 Program crashes Then look at the single transformation that introduces the crash. Well that's the intent anyway! Simon | -Original Message- | From: ezyang [mailto:ezy...@mit.edu] | Sent: 02 February 2011 23:12 | To: Simon Marlow; Simon Peyton-Jones | Cc: glasgow-haskell-users | Subject: Re: 4221 on new codegen | | Simon Peyton Jones, I have a question about optimization fuel and GHC panics. | When I vary the fuel using -dopt-fuel, I get the following varying behavior: | | ... | -dopt-fuel=144 = normal segfault (late in the program) | -dopt-fuel=143 = segfaults ~immediately | -dopt-fuel=142 = normal segfault | -dopt-fuel=141 = fails an assert in file compiler/cmm/CmmBuildInfoTables.hs, | line 128 | -dopt-fuel=140 = ditto | -dopt-fuel=139 = resulting executable prints 'start' and then doesn't do | anything | ... | | My impression was that these optimizations should not affect program | behavior, | in which case the first thing I should figure out is why -dopt-fuel results | in | the programming terminating after it prints 'start'. However, I'm not sure if | this is a red herring. Am I on the right track? | | Cheers, | Edward | | Quoting Simon Marlow marlo...@gmail.com: | | On 02/02/2011 00:29, Edward Z. Yang wrote: | More Hoopling later, I see this segment in the rewrite function: | | middle m@(CmmUnsafeForeignCall _ fs _) live = return $ | case map spill (filter (flip elemRegSet (on_stack live)) fs) ++ |map reload (uniqSetToList (kill fs (in_regs live))) of | [] - Nothing | reloads - Just $ mkMiddles (m : reloads) | | So, if I understand this code correctly, it unilaterally reloads | /anything/ in the registers according to the analysis at that point. | | Well, I could see that resulting in the behavior below. | | It's not so clear to me what the correct rewrite is; according to | Marlow's comment on IRC, we ought not to be spilling/reloading foreign | calls yet, so maybe the whole bit should get excised? Otherwise, it seems | to me that transfer function needs to accomodate unsafe foreign | functions. | | Right, there's no need to spill/reload anything around an *unsafe* | foreign call in the Cmm code generator. The NCG's register allocator | will do any necessary spilling/reloading around foreign calls. | | Cheers, | Simon | | | | Cheers, | Edward | | Excerpts from Simon Marlow's message of Tue Feb 01 03:44:41 -0500 2011: | On 01/02/2011 00:01, Edward Z. Yang wrote: | Current theory: | | c1jj: | _s1ep::I32 = I32[(slot_s1ep::I32 + 4)]; // CmmAssign | _s1fP::I32 = I32[(slot_s1fP::I32 + 4)]; // CmmAssign | // outOfLine should follow: | _s1eq::F64 = F64[_s1fP::I32 + 3]; // CmmAssign | I32[(youngc1jh + 4)] = c1jh; // CmmStore | foreign call ccall arg hints: [PtrHint,] result hints: | [] call_fn_blob(...) returns to c1jh args: ([_s1ep::I32, | |_s1eq::F64]) ress: | ([_s1ev::F64]) with update frame 4; // CmmForeignCall | c1jh: | _s1ev::F64 = F64[(slot_s1ev::F64 + 8)]; // CmmAssign | // emitReturn: Sequel: Assign | _s1ev::F64 = _s1ev::F64; // CmmAssign | F64[(slot_s1ev::F64 + 8)] = _s1ev::F64; // CmmStore | goto u1Ak; // CmmBranch | | Note the line immediately after c1jh, where we reload the ostensibly | spilled _s1ev back into a register. Except that it was never spilled | there in the first place, and we just clobbered the real value. Oops. | | Is this interpretation correct? | | It sounds plausible, but I really have no idea. The code generator does | not have to generate spill/reloads around foreign calls, the register | allocator will do that. | | Cheers, | Simon | | | | ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: 4221 on new codegen
I wonder if the fuel is also being used by essential transformations, like the CPS pass? Cheers, Simon On 03/02/2011 09:01, Simon Peyton-Jones wrote: Correct. The Cmm optimiser is supposed to make correctness preserving transformations. The idea of the fuel is that you can binary chop your way to a situation where Fuel = 0-143Program works Fuel = 144 Program crashes Then look at the single transformation that introduces the crash. Well that's the intent anyway! Simon | -Original Message- | From: ezyang [mailto:ezy...@mit.edu] | Sent: 02 February 2011 23:12 | To: Simon Marlow; Simon Peyton-Jones | Cc: glasgow-haskell-users | Subject: Re: 4221 on new codegen | | Simon Peyton Jones, I have a question about optimization fuel and GHC panics. | When I vary the fuel using -dopt-fuel, I get the following varying behavior: | | ... | -dopt-fuel=144 = normal segfault (late in the program) | -dopt-fuel=143 = segfaults ~immediately | -dopt-fuel=142 = normal segfault | -dopt-fuel=141 = fails an assert in file compiler/cmm/CmmBuildInfoTables.hs, | line 128 | -dopt-fuel=140 = ditto | -dopt-fuel=139 = resulting executable prints 'start' and then doesn't do | anything | ... | | My impression was that these optimizations should not affect program | behavior, | in which case the first thing I should figure out is why -dopt-fuel results | in | the programming terminating after it prints 'start'. However, I'm not sure if | this is a red herring. Am I on the right track? | | Cheers, | Edward | | Quoting Simon Marlowmarlo...@gmail.com: | | On 02/02/2011 00:29, Edward Z. Yang wrote: | More Hoopling later, I see this segment in the rewrite function: | | middle m@(CmmUnsafeForeignCall _ fs _) live = return $ | case map spill (filter (flip elemRegSet (on_stack live)) fs) ++ |map reload (uniqSetToList (kill fs (in_regs live))) of | [] - Nothing | reloads - Just $ mkMiddles (m : reloads) | | So, if I understand this code correctly, it unilaterally reloads | /anything/ in the registers according to the analysis at that point. | | Well, I could see that resulting in the behavior below. | | It's not so clear to me what the correct rewrite is; according to | Marlow's comment on IRC, we ought not to be spilling/reloading foreign | calls yet, so maybe the whole bit should get excised? Otherwise, it seems | to me that transfer function needs to accomodate unsafe foreign | functions. | | Right, there's no need to spill/reload anything around an *unsafe* | foreign call in the Cmm code generator. The NCG's register allocator | will do any necessary spilling/reloading around foreign calls. | | Cheers, | Simon | | | | Cheers, | Edward | | Excerpts from Simon Marlow's message of Tue Feb 01 03:44:41 -0500 2011: | On 01/02/2011 00:01, Edward Z. Yang wrote: | Current theory: | | c1jj: | _s1ep::I32 = I32[(slot_s1ep::I32+ 4)]; // CmmAssign | _s1fP::I32 = I32[(slot_s1fP::I32+ 4)]; // CmmAssign | // outOfLine should follow: | _s1eq::F64 = F64[_s1fP::I32 + 3]; // CmmAssign | I32[(youngc1jh+ 4)] = c1jh; // CmmStore | foreign call ccall arg hints: [PtrHint,] result hints: | [] call_fn_blob(...) returns to c1jh args: ([_s1ep::I32, | |_s1eq::F64]) ress: | ([_s1ev::F64]) with update frame 4; // CmmForeignCall | c1jh: | _s1ev::F64 = F64[(slot_s1ev::F64+ 8)]; // CmmAssign | // emitReturn: Sequel: Assign | _s1ev::F64 = _s1ev::F64; // CmmAssign | F64[(slot_s1ev::F64+ 8)] = _s1ev::F64; // CmmStore | goto u1Ak; // CmmBranch | | Note the line immediately after c1jh, where we reload the ostensibly | spilled _s1ev back into a register. Except that it was never spilled | there in the first place, and we just clobbered the real value. Oops. | | Is this interpretation correct? | | It sounds plausible, but I really have no idea. The code generator does | not have to generate spill/reloads around foreign calls, the register | allocator will do that. | | Cheers, | Simon | | | | ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
How to #include into .lhs files?
Does anyone have a working example of #include'ing Haskell code into a bird-tracks-style .lhs file with GHC? Every way I try leads to parsing errors. Is there documentation about how it's supposed to work? Help much appreciated. - Conal ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: 4221 on new codegen
Excerpts from Simon Marlow's message of Thu Feb 03 04:05:04 -0500 2011: I wonder if the fuel is also being used by essential transformations, like the CPS pass? That seems likely. Shall I try to figure out what the essential transformations are and give them infinite fuel? Edward ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: How to #include into .lhs files?
On Thursday 03 February 2011 10:33:23, Conal Elliott wrote: Does anyone have a working example of #include'ing Haskell code into a bird-tracks-style .lhs file with GHC? Every way I try leads to parsing errors. Is there documentation about how it's supposed to work? Help much appreciated. - Conal Stupid example: -- Main: {-# LANGUAGE CPP #-} module Main (main) where #include MachDeps.h main :: IO () main = do #if WORD_SIZE_IN_BITS == 32 putStrLn 32 bits #include Stuff32 # else putStrLn 64 bits #include Stuff64 #endif -- Stuff32: putStrLn Included from Stuff32 -- Stuff64: putStrLn Included from Stuff64 It's a bit tricky. Since the C preprocessor is run after the unlit, the included code should not have bird-tracks, also you have to get the indentation right. There's probably a way to run cpp before unlit, which would allow you to have bird-tracks in the #include'd code. Much easier with LaTeX-style literate code. Cheers, Daniel ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: 4221 on new codegen
On 03/02/2011 10:07, ezyang wrote: Excerpts from Simon Marlow's message of Thu Feb 03 04:05:04 -0500 2011: I wonder if the fuel is also being used by essential transformations, like the CPS pass? That seems likely. Shall I try to figure out what the essential transformations are and give them infinite fuel? Sounds reasonable, yes. Cheers, Simon ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: 4221 on new codegen
Assuming that runFuelIO is the only mechanism by which fueled execution is performed, the only file using fuel is CmmCPS.hs. This file performs: 1. Proc point analysis 2. Proc point transformation 3. Spills and reloads 4. Late reloads 5. Dead assignment elimination 6. Stub dead slots (optional) 7. Stack slot analysis 8. Manifest the SP 9. Proc point analysis 10. Splitting proc points 11. CAF analysis 12. Safe call lowering Out of these, it only seems like (5) and (11) are optional. Any that I missed? It's not very promising (and I think I will go for another angle of attack soon); I guess fuel will be more useful when we start implementing optimizations on top of the new codegen. Amusingly enough the simple control flow optimisation is not subject to fuel constraints: tis all pure code. :-) Cheers, Edward P.S. I guess if I get stuck, I'll go and remove the dead code we talked about. That shouldn't be too hard, right? ;-) ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: How to #include into .lhs files?
Thanks, Daniel. I'm still stumped. When I say #include B.hs in a .hs file, all works fine, but when in a .lhs file I get error: B.hs: No such file or directory. The file B.hs is in the same directory as the including file, which is the current directory for ghci. Same situation with ghc. If I change B.hs to ./B.hs, I get the same behavior. Only if I use a fully qualified path name for B.hs does it get found from the .lhs file. I'm using GHC 6.12.3 on Mac OS 10.6.6. Any ideas? (Anyone, not just Daniel.) Thanks, - Conal On Thu, Feb 3, 2011 at 2:51 AM, Daniel Fischer daniel.is.fisc...@googlemail.com wrote: On Thursday 03 February 2011 10:33:23, Conal Elliott wrote: Does anyone have a working example of #include'ing Haskell code into a bird-tracks-style .lhs file with GHC? Every way I try leads to parsing errors. Is there documentation about how it's supposed to work? Help much appreciated. - Conal Stupid example: -- Main: {-# LANGUAGE CPP #-} module Main (main) where #include MachDeps.h main :: IO () main = do #if WORD_SIZE_IN_BITS == 32 putStrLn 32 bits #include Stuff32 # else putStrLn 64 bits #include Stuff64 #endif -- Stuff32: putStrLn Included from Stuff32 -- Stuff64: putStrLn Included from Stuff64 It's a bit tricky. Since the C preprocessor is run after the unlit, the included code should not have bird-tracks, also you have to get the indentation right. There's probably a way to run cpp before unlit, which would allow you to have bird-tracks in the #include'd code. Much easier with LaTeX-style literate code. Cheers, Daniel ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell] a quick question
uptable::[[Char]]-[([Char],Int,Int,Int,Int)]-[([Char],Int,Int,Int,Int)] uptable (xf:xs) main_array = map (\(x,y,z,r,t)- do if x==xf then tupup x y z r t second xs ) main_array Why do you have a `do' in that snippet? ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] a quick question
Can I suggest you take this discussion to either the haskell-beginners list, or haskell-cafe?This list (haskell@haskell.org) is intended primarily for announcements.Regards, MalcolmOn 03 Feb, 2011,at 09:33 AM, Matthias Görgens matthias.goerg...@googlemail.com wrote: uptable::[[Char]]-[([Char],Int,Int,Int,Int)]-[([Char],Int,Int,Int,Int)] uptable (xf:xs) main_array = map (\(x,y,z,r,t)- do if x==xf then tupup x y z r t second xs ) main_array Why do you have a `do' in that snippet? ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Haskell Functions Help
I need help with two functionsfirst this is the curent code :http://pastebin.com/UPATJ0r -Function 1)removeTautologies :: Formula-Formula If in a clause, a literal and its negation are found, it means that the clause will be true, regardless of the value finally assigned to that propositional variable. Consider the following example: (A v B v -A) ^ (B v C v A) The first clause contains the literals A and -A. This means that the clause will always be true, in which case it can be simplify the whole set to simply (B v C v A) . I was tinking of using something like removeTautologies (f:fs)=filter rTf:removeTautologies fs where rT-is supposed to take the firs Literal from the clasue and search for a similar one,if one si found we compare the values if not the we go to the second literal. -Function 2)pureLiteralDeletion :: Formula-Formula This is a little bit complicate but from What I get this function is suppose to implement a simplification step that assumes as true any atom in a formula that appears exclusively in a positive or negative form (not both). Consider the formula: (P v Q v R) ^ (P v Q v -R) ^ (-Q v R) Note that in this formula P is present but -P is not. Using Pure Literal Deletion it can be assumed that the value of P will be True thus simplifying the formula to (-Q v R). If the literal were false then the literal would simply be deleted from the clauses it appears in. In that case any satisfying model for the resulting formula would also be a satisfying model for the formula when we assume that the literal is true. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[arch-haskell] AUR Comment for raincat
from http://aur.archlinux.org/packages.php?ID=33509 Cape wrote: mmm i can't solve all the make dependecies:haskell-extensible-exceptions, haskell-mtl and haskel-time are not present neither in aur nor in official repos. --- If you no longer wish to receive notifications about this package, please go the the above package page and click the UnNotify button. ___ arch-haskell mailing list arch-hask...@haskell.org http://www.haskell.org/mailman/listinfo/arch-haskell
Re: [Haskell] a quick question
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 2/2/11 22:01 , Ramy Abdel-Azim wrote: No need to apologize. Not dumb of you. The mandatory else is unusual. I don't personally know of any other language that requires an else for every if. Haskell's if is an expression, best compared to the ?-: ternary operator in C and Perl or Python's if-else operator instead of to a control structure. - -- brandon s. allbery [linux,solaris,freebsd,perl]allber...@gmail.com system administrator [openafs,heimdal,too many hats]kf8nh -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk1LRsQACgkQIn7hlCsL25XSPACfRTlbLfBO6bKmg9EH4RPGSdMx SvoAnjakFqCArV9GRczvi2b1HZ6BZTjO =9Vvo -END PGP SIGNATURE- ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell-cafe] Problems with iteratees
On 2/2/11 11:25 PM, Maciej Wos wrote: I think the problem is that the iteratee you give to I.convStream always returns Just [something] while you should return Nothing on EOF. That makes sense for the hanging problem (which I only noticed during debugging). Though I still get the the same error message when running the whole program... On Thu, Feb 3, 2011 at 10:06 AM, wren ng thorntonw...@freegeek.org wrote: When I put this all together, the process is killed with: control message: Just (Err endOfInput) Data.Iteratee.Base.run is the origin of the control message: part of the error, but I don't know where (Err endOfInput) is coming from since Data.Iteratee.Base only uses (Err EOF) or (Err Divergent Iteratee). I believe runGetEnumeratee is where the problem is, though it could also be the use site or something in one of the libraries. Any help would be appreciated. -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problems with iteratees
I agree with Maciej Wos' diagnosis and solution. I'd like to point out that the Tiff library has to do a similar processing: use an iteratee to read bytes from the outer stream and to produce elements for the inner stream (e.g., signed 32-bit integers). In your version of the Iteratee library, please look at Data/Iteratee/Codecs/Tiff.hs and search for the following fragment: -- Read the array of long integers -- of 1 element: the offset field contains the value read_value typ e' 1 | typ == TT_long || typ == TT_slong = ... -- of n elements read_value typ e' count | typ == TT_long || typ == TT_slong = do offset - endianRead4 e' return . Just . TEN_INT $ \iter_int - return $ do Iter.seek (fromIntegral offset) let iter = convStream (liftM (either (const Nothing) (Just . (:[]) . conv_long typ)) (checkErr (endianRead4 e'))) iter_int Iter.joinI $ Iter.joinI $ Iter.takeR (4*count) iter Of relevance is the line that contains convStream. Please notice (const Nothing) that Maciej was talking about. The newer version has a somewhat more convenient sequence_stream function, which creates a nested stream using the supplied iteratee to read from the outer stream and produce an element for the inner stream. The function is particularly useful if you read the inner stream all the way, until it is exhausted. Here is how the above read_value clause looks now -- of n elements read_value typ count | typ == TT_long || typ == TT_slong = do offset - endian_read4 let converter = endian_read4 = return . conv_long typ return . Just . TEN_INT $ \iter_int - do seek_stream (fromIntegral offset) runI = takeR (4*count) (sequence_stream converter iter_int) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Another Question
Navin Rustagi navin_ku...@yahoo.com writes: It gives the error ERROR - Control stack overflow. I assume it is because of the lazy evaluation. Yes, you're just building a tower of additions, and when evaluating this, you blow up the stack. You need to make sure to evaluate the tuple element each time, so instead of case ys of 'A' - (elf, els+1,elr,ell,elx) write: case ys of 'A' - els `seq` (elf, els+1,elr,ell,elx) (Strictly speaking this will only evaluate the previous value, but your tower of additions will now have maximum one floor) -k -- If I haven't seen further, it is by standing in the footprints of giants ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Status update on {code, trac, projects, planet, community}.haskell.org
* Duncan Coutts duncan.cou...@googlemail.com [2011-02-02 01:33:22+] These are all hosted on the community server. The community server was hacked on the 26th January and we took it offline. The server was running an old version of debian that was no longer supported with security updates. (Ironically, two days previously the infrastructure team had been discussing the fact that nobody seemed to have any time available to do the planned migration to a new host). The hacker replaced sshd which we noticed because the ssh host signature changed and it started prompting for passwords (we use key-based rather than password based logins). Might be related: http://sourceforge.net/blog/sourceforge-attack-full-report/ -- Roman I. Cheplyaka :: http://ro-che.info/ Don't worry what people think, they don't do it very often. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Another Question
Hi Navin, next time, could you please choose more informative subject for your emails to the mailing list? It is read by many people, and choosing a good subject will save them a lot of time. In this case, something like Stack overflow or How to make a function strict would do. Thanks. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't worry what people think, they don't do it very often. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell procedure
One :Thank you Carsten Schultz,Daniel Fischer,Mihai and all the other for your help. Two:After my last post I wrote some function that should help me in the future,but I need some help with the followint as I'm tired and have to fit in a schedule.I know it is long so I'll try and explain it as short and consice as I can. The DPLL procedure has two main stages: a simplification stage and a search stage. In the simplification stage, functions are applied to the formula to assign truth values to certain propositional variables. The simplifications are made because if there is a satisfying assignment for the simplified formula then it is also a satisfying assignment for the original formula. This reduces the need for search which can take a long time. The search stage is performed when no more simplifications can be made. In this stage a literal is chosen and is assigned true or false leading to two new branches in the search space. I wrote some function wich should be helpfull,but I have to fit in a schedule and I'm getting tired I need some additional help if possible. module Algorithm where import System.Random import Data.Maybe import Data.List type Atom = String type Literal = (Bool,Atom) type Clause = [Literal] type Formula = [Clause] type Model = [(Atom, Bool)] type Node = (Formula, ([Atom], Model)) -- This function takess a Clause and return the set of Atoms of that Clause. atomsClause :: Clause - [Atom] -- This function takes a Formula returns the set of Atoms of a Formula atoms :: Formula - [Atom] -- This function returns True if the given Literal can be found within -- the Clause. isLiteral :: Literal - Clause - Bool -- this function takes a Model and an Atom and flip the truthvalue of -- the atom in the model flipSymbol :: Model - Atom - Model -- is this ok? Additional functions that I wrote: remove :: (Eq a) )a -[a] -[a] -This function removes an item from a list. neg :: Literal-Literal -This function flips a literal (ie. from P to :P and from :P to P). falseClause :: Model - Clause - Bool -This function takes a Model and a Clause and returns True if the clause is unsatisfied by the model or False otherwise. falseClauses :: Formula - Model - [Clause] -This function takes a Formula and a Model and returns the list of clauses of the formula that are not satisfied. assignModel :: Model - Formula - Formula -This function applies the assign function for all the assignments of a given model. checkFormula :: Formula - Maybe Bool This function checks whether a formula can be decided to be satisfiable or unsatisfiable based on the effects of the assign function. satisfies :: Model - Formula -. Bool This function checks whether a model satisfies a formula. This is done with the combination of the assignModel and checkFormula functions. --Where do I need help: removeTautologies :: Formula-Formula This function should output a simplified formula if tautologies can be found in one or more clauses in the input Notes: If in a clause, a literal and its negation are found, it means that the clause will be true, regardless of the value finally assigned to that propositional variable. Consider the following example: (A v B v -A) ^ (B v C v A) The first clause contains the literals A and -A. This means that the clause will always be true, in which case it can be simplify the whole set to simply (B v C v A) (the second clause alone) pureLiteralDeletion :: Formula-Formula This function is suppose to implement a simplification step that assumes as true any atom in a formula that appears exclusively in a positive or negative form (not both). Consider the formula: (P v Q v R) ^ (P v Q v -R) ^ (-Q v R) Note that in this formula P is present but -P is not. Using Pure Literal Deletion it can be assumed that the value of P will be True thus simplifying the formula to (-Q v R). If the literal were false then the literal would simply be deleted from the clauses it appears in. In that case any satisfying model for the resulting formula would also be a satisfying model for the formula when we assume that the literal is true. Hence this simplification is sound in that if there is a solution to the simplified formula then there is a solution to the original formula. propagateUnits :: Formula-Formula If a clause in a propositional formula contains only one literal, then that literal must be true (so that the particular clause can be satisfied). When this happens,we can remove the unit clauses (the ones that contain only one literal), all the clauses where the literal appears and also, from the remaining clauses, we can delete the negation of the literal (because if P is true, -P will be false).For example, in the formula (P v Q v R) ^ (-P v Q v -R) ^ (P) we have one unit clause (the third clause(P) ). Because this
[Haskell-cafe] How to #include into .lhs files?
Does anyone have a working example of #include'ing Haskell code into a bird-tracks-style .lhs file with GHC? Every way I try leads to parsing errors. Is there documentation about how it's supposed to work? Help much appreciated. - Conal ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] problem with instance method
Hi, I am studying type classes using examples from the literature [1]. The attached code is a formalization of basic object oriented ideas. The particular approach seems to be built on the concepts of: thing, object, and identifier. I have no intension to implement anything or significantly change the code below. Rather, I am trying to understand the code as it stands. I include a number of test runs which seem OK, but I cannot get the *obj* function to work. obj :: t - i - o t i obj t i = Obj t i Any hints would be appreciated. Thanks, Pat [1] ftp://ftp.geoinfo.tuwien.ac.at/frank/frank97executableAxiomaticSpecification.pdf -- A property of a thing data Color = Blue | Green | Red | White deriving Show -- A thing class Cars c where car :: Color - c getColor :: c - Color putColor :: Color - c - c paint :: Color - c - c paint color car = putColor color car data Car = Car Color deriving Show instance Cars Car where car c = Car c putColor color (Car c) = Car color getColor (Car c) = c -- Identifiers for objects class (Integral i) = IDs i where startId :: i newId :: i - i newId i = succ i sameId, notSameId :: i - i - Bool sameId i j = i == j notSameId i j = not (sameId i j) instance IDs Integer where startId = 1 -- Objects consist of Things, with Identifiers class (IDs i, Show i) = Objects o t i where obj :: t - i - o t i getId :: o t i - i getThing :: o t i - t doThing :: (t - t) - o t i - o t i doThing f o = obj (f (getThing o)) (getId o) same :: o t i - o t i - Bool same i j = sameId (getId i) (getId j) isId :: i - o t i - Bool isId i o = sameId i (getId o) -- A general type of Obj data Object t i = Obj t i deriving Show -- A particular Car Obj, which an instance of Objects class (in Haskell terms, not OO terms) instance Objects Object Car Integer where obj t i = Obj t i getId (Obj t i) = i getThing (Obj t i) = t -- Create some actual Objects x = (Obj (Car Blue) (startId::Integer)) y = (Obj (Car Green) (newId startId::Integer)) -- Some tests on car thing, seem OK -- getColor (Car Blue) -- putColor Green (Car Blue) -- getColor (putColor Green (Car Blue)) -- Some tests on objects, seem OK -- same x y -- Obj (Car Blue) (newId startId::Integer) -- Obj (Car Blue) (startId::Integer) -- getThing (Obj (Car Blue) (startId::Integer)) -- getId (Obj (Car Blue) (startId::Integer)) -- isId 2 (Obj (Car Blue) (startId::Integer)) 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] problem with instance method
On 3 February 2011 21:09, Patrick Browne patrick.bro...@dit.ie wrote: Hi, I am studying type classes using examples from the literature [1]. The attached code is a formalization of basic object oriented ideas. The particular approach seems to be built on the concepts of: thing, object, and identifier. I have no intension to implement anything or significantly change the code below. Rather, I am trying to understand the code as it stands. I include a number of test runs which seem OK, but I cannot get the *obj* function to work. obj :: t - i - o t i obj t i = Obj t i The type signature says Given any `t' and any `i', this will return any `o t i' (for some unspecified type `o'). However, your actual implementation uses a specific data-type, namely Object for `o'. Change the type signature to be obj :: t - i - Object t i. -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Inheritance and Wrappers
On 3 February 2011 02:35, Brandon Moore brandon_m_mo...@yahoo.com wrote: Here's one thing to consider: Can you write a function f :: (Data a) = a - String f x = termTag x It would seem the Data a = Term a instance justifies this function, and it will always use the default instance. Now, what happens if f is applied to a value of some type T which is an instance of Data, but has a custom Term instance? Great point, thanks! I guess somehow you shouldn't be allowed to write that function f. I need to think about this one. -- Ozgur ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] problem with instance method
No, obj is a method of the Objects class. you've already declared it in the instance of Objects Object your code works just fine here. adding: mycar = Car Blue o:: Object Car Integer o = obj mycar 4 ghci says... *Objects :t obj obj :: (Objects o t i) = t - i - o t i *Objects o Obj (Car Blue) 4 But I hope you read my last email in the other thread you started... Tom On Thu, Feb 3, 2011 at 10:15 AM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 3 February 2011 21:09, Patrick Browne patrick.bro...@dit.ie wrote: Hi, I am studying type classes using examples from the literature [1]. The attached code is a formalization of basic object oriented ideas. The particular approach seems to be built on the concepts of: thing, object, and identifier. I have no intension to implement anything or significantly change the code below. Rather, I am trying to understand the code as it stands. I include a number of test runs which seem OK, but I cannot get the *obj* function to work. obj :: t - i - o t i obj t i = Obj t i The type signature says Given any `t' and any `i', this will return any `o t i' (for some unspecified type `o'). However, your actual implementation uses a specific data-type, namely Object for `o'. Change the type signature to be obj :: t - i - Object t i. -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to #include into .lhs files?
On Thursday 03 February 2011 10:33:23, Conal Elliott wrote: Does anyone have a working example of #include'ing Haskell code into a bird-tracks-style .lhs file with GHC? Every way I try leads to parsing errors. Is there documentation about how it's supposed to work? Help much appreciated. - Conal Stupid example: -- Main: {-# LANGUAGE CPP #-} module Main (main) where #include MachDeps.h main :: IO () main = do #if WORD_SIZE_IN_BITS == 32 putStrLn 32 bits #include Stuff32 # else putStrLn 64 bits #include Stuff64 #endif -- Stuff32: putStrLn Included from Stuff32 -- Stuff64: putStrLn Included from Stuff64 It's a bit tricky. Since the C preprocessor is run after the unlit, the included code should not have bird-tracks, also you have to get the indentation right. There's probably a way to run cpp before unlit, which would allow you to have bird-tracks in the #include'd code. Much easier with LaTeX-style literate code. Cheers, Daniel ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Review request for platform independent interactive graphics with VNC
Hi, I've been working on a Haskell based platform independent graphics rendering using VNC. I'd like it very much if you could take a look at it and give me feedback. Using it is straight forward - git clone g...@github.com:ckkashyap/Chitra.git cd Chitra make ./Main 100 100 5900 Main starts off a vncserver listening on port 5900. A standard vncviewer can be used to connect to 'localhost' and you can see a 100 x 100 screen. Clicking on the screen will set the pixel on the click location. What I eventually want to do is somehow integrate this piece with GHCI in such a manner that one can use GHCI to draw things on the VNC buffer. Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC
One thing to notice: $ cabal install network-server is needed. Best regards, Krzysztof Skrzętnicki On Thu, Feb 3, 2011 at 12:15, C K Kashyap ckkash...@gmail.com wrote: Hi, I've been working on a Haskell based platform independent graphics rendering using VNC. I'd like it very much if you could take a look at it and give me feedback. Using it is straight forward - git clone g...@github.com:ckkashyap/Chitra.git cd Chitra make ./Main 100 100 5900 Main starts off a vncserver listening on port 5900. A standard vncviewer can be used to connect to 'localhost' and you can see a 100 x 100 screen. Clicking on the screen will set the pixel on the click location. What I eventually want to do is somehow integrate this piece with GHCI in such a manner that one can use GHCI to draw things on the VNC buffer. Regards, Kashyap ___ 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] Status update on {code, trac, projects, planet, community}.haskell.org
On Thu, 2011-02-03 at 10:37 +0200, Roman Cheplyaka wrote: * Duncan Coutts duncan.cou...@googlemail.com [2011-02-02 01:33:22+] These are all hosted on the community server. The community server was hacked on the 26th January and we took it offline. The server was running an old version of debian that was no longer supported with security updates. (Ironically, two days previously the infrastructure team had been discussing the fact that nobody seemed to have any time available to do the planned migration to a new host). The hacker replaced sshd which we noticed because the ssh host signature changed and it started prompting for passwords (we use key-based rather than password based logins). Might be related: http://sourceforge.net/blog/sourceforge-attack-full-report/ Yes, it's quite possible. One difference to note is that we use ssh key based logins, not passwords. We suspect this saved us from the worst case scenarios. Nevertheless, while we don't have to reset passwords, we are concerned about the potential that the attacker replaced or added to users ~/.ssh/authorized_keys lists, which is why we have not yet re-enabled user accounts. We will try and provide as full a picture as we can when we're satisfied we've got as much info and confidence as we're likely to get. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problems with iteratees
From: wren ng thornton w...@freegeek.org On 2/2/11 11:25 PM, Maciej Wos wrote: I think the problem is that the iteratee you give to I.convStream always returns Just [something] while you should return Nothing on EOF. That makes sense for the hanging problem (which I only noticed during debugging). Though I still get the the same error message when running the whole program... I don't have too much to add to Maciej and Oleg's reply, except that I'd recommend looking at the Wave codec over the Tiff reader in those versions of iteratee. I don't think that's the only problem, though, because then you'd be getting a Divergent iteratee error. The endOfInput error is suspicious, and I think you'll need to track it down to solve this problem. It doesn't appear to be from either iteratee or protocol-buffers. Could it be coming from your IO library? I wonder if the enumerator is trying to force a read after EOF has been reached for some reason? As an experiment, you could try using a custom convStream function like this: convStream2 :: Monad m = IterateeG s el m (Maybe (s' el')) - EnumeratorN s el s' el' m aconvStream2 fi iter = fi = check where check (Just xs) = lift (runIter iter (Chunk xs)) = docase check (Nothing) = return iter docase (Done a _)= return . return $ a docase (Cont k Nothing) = convStream2 fi k docase (Cont k (Just endOfInput)) = convStream2 (return Nothing) k docase (Cont _ (Just e)) = return $ throwErr e This may help determine if it's a problem with IO or with the message parsing. John On Thu, Feb 3, 2011 at 10:06 AM, wren ng thorntonw...@freegeek.org wrote: When I put this all together, the process is killed with: control message: Just (Err endOfInput) Data.Iteratee.Base.run is the origin of the control message: part of the error, but I don't know where (Err endOfInput) is coming from since Data.Iteratee.Base only uses (Err EOF) or (Err Divergent Iteratee). I believe runGetEnumeratee is where the problem is, though it could also be the use site or something in one of the libraries. Any help would be appreciated. -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Yesod and concurrency
Michael Snoyman mich...@snoyman.com wrote: On Mon, Jan 31, 2011 at 1:09 PM, Ertugrul Soeylemez e...@ertes.de wrote: how well do WAI, Yesod and the 'persistent' package play with concurrency? For example, I'd like to write a program, which concurrently provides two related sites as well as a few background workers, which do something with the database. My idea would look something like this: main :: IO () main = withMyAppPool $ \pool - do forkIO $ worker1 ... -- background worker forkIO $ worker2 ... -- background worker forkIO $ worker3 ... -- background worker forkIO $ toWaiApp ... -- site 1 forkIO $ toWaiApp ... -- site 2 Will I run into problems with this? There should not be any issues, just make sure you compile with -threaded. The persistent database connection pool should work just fine for this. If you find any issues, please let me know, but I have not had trouble in the past. I've run into the first problem with this. Without having to use subsites, what's an easy method to use wai-handler-devel with such a setup? Greets, Ertugrul -- nightmare = unsafePerformIO (getWrongWife = sex) http://ertes.de/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] PhD Studentships in Functional Programming, Nottingham
Apologies for multiple copies. Best, /Henrik -- Henrik Nilsson School of Computer Science The University of Nottingham n...@cs.nott.ac.uk +--+ PhD Studentships in Functional Programming School of Computer Science University of Nottingham, UK The Functional Programming Lab (FP Lab) in the School of Computer Science at the University of Nottingham is seeking to appoint up to two new PhD students, starting on 1st October 2011. The topics for the studentships are open, but will be within the general area of functional programming. The studentships are for 3.5 years, include a maintenance grant of 13,590 UK pounds per year and UK/EU tuition fees, and are open to UK and EU applicants. Particularly strong candidates from outside the EU may also be considered, subject to additional funds being available. Applicants will require a first-class Honours degree (or equivalent) in Computer Science, Mathematics, and/or Physics, experience in functional programming, and an aptitude for mathematical subjects. A higher degree (e.g. Masters) would be desirable. Additionally, experience in one or more of the following will be particularly welcome: formal semantics, type theory, program verification, theorem provers, domain-specific languages, languages for physical modelling, programming language implementation and tools. Successful applicants will work under the supervision of Dr Graham Hutton or Dr Henrik Nilsson in the FP Lab in Nottingham, a leading centre for research on functional programming. The group currently comprises 5 academic staff, 1 research fellow, and 10 PhD students. In order to apply, please submit the following to Dr Graham Hutton (g...@cs.nott.ac.uk) or Dr Henrik Nilsson (n...@cs.nott.ac.uk) by 1st March 2011: an up-to-date copy of your CV (including the results of all your University examinations to date) along with a brief covering letter that describes your experience in functional programming, your reasons for wishing to pursue a PhD in this area, and any ideas you have regarding possible research directions. Note: applicants to the FP Lab should follow the procedure above, rather than applying directly to the School or University, e.g. in response to a general advert for PhD studentships. Closing date for applications: 1st March 2011. +--+ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Yesod and concurrency
On Thu, Feb 3, 2011 at 3:14 PM, Ertugrul Soeylemez e...@ertes.de wrote: Michael Snoyman mich...@snoyman.com wrote: On Mon, Jan 31, 2011 at 1:09 PM, Ertugrul Soeylemez e...@ertes.de wrote: how well do WAI, Yesod and the 'persistent' package play with concurrency? For example, I'd like to write a program, which concurrently provides two related sites as well as a few background workers, which do something with the database. My idea would look something like this: main :: IO () main = withMyAppPool $ \pool - do forkIO $ worker1 ... -- background worker forkIO $ worker2 ... -- background worker forkIO $ worker3 ... -- background worker forkIO $ toWaiApp ... -- site 1 forkIO $ toWaiApp ... -- site 2 Will I run into problems with this? There should not be any issues, just make sure you compile with -threaded. The persistent database connection pool should work just fine for this. If you find any issues, please let me know, but I have not had trouble in the past. I've run into the first problem with this. Without having to use subsites, what's an easy method to use wai-handler-devel with such a setup? I believe the new architecture in use for wai-handler-devel 0.2 (which will work with Yesod 0.7) should work properly with multi-threaded apps. But yes, there's no easy way to do this with the current wai-handler-devel. Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC
Hi Kashyap, What a fun project! I was able to build and run on Windows (GHC 6.12.3 and TightVNC 1.4.4) with a few minor changes: Remove from Chitra\Canvas.hs import Network.Server import Network.Socket I think these are artifacts from a previous version and are not used. For whatever reason getAddrInfo with the parameters given in RFB\Server.hs returns some IPv6 address on my system. Changing the second parameter from Nothing to (Just 127.0.0.1) made things work for me. Attached is the Cabal file I used to build (it wasn't clear what license things are under so those fields are commented out). Ryan Yates On Thu, Feb 3, 2011 at 6:15 AM, C K Kashyap ckkash...@gmail.com wrote: Hi, I've been working on a Haskell based platform independent graphics rendering using VNC. I'd like it very much if you could take a look at it and give me feedback. Using it is straight forward - git clone g...@github.com:ckkashyap/Chitra.git cd Chitra make ./Main 100 100 5900 Main starts off a vncserver listening on port 5900. A standard vncviewer can be used to connect to 'localhost' and you can see a 100 x 100 screen. Clicking on the screen will set the pixel on the click location. What I eventually want to do is somehow integrate this piece with GHCI in such a manner that one can use GHCI to draw things on the VNC buffer. Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe Chitra.cabal Description: Binary data ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC
Am 03.02.2011 12:15, schrieb C K Kashyap: Hi, I've been working on a Haskell based platform independent graphics rendering using VNC. I'd like it very much if you could take a look at it and give me feedback. Using it is straight forward - git clone g...@github.com:ckkashyap/Chitra.git This step failed for me with: maeder@leibniz:/local/maeder git clone g...@github.com:ckkashyap/Chitra.git Initialized empty Git repository in /local/maeder/Chitra/.git/ Permission denied (publickey). fatal: The remote end hung up unexpectedly maeder@leibniz:/local/maeder git --version git version 1.7.1 What permission is needed? Christian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] OSX i386/x86 and x86_64 - time to switch supported platforms?
I originally posted this on haskell-GHC-users, but was curious how the wider community felt. The last 32-bit, Intel Mac was the Mac Mini, discontinued in August 2007. The bulk of them were discontinued in 2006, along with PowerPC Macs. Does it make sense to relegate OSX x86_64 to community status while the 32-bit version is considered a supported platform? Given that I'm far from experienced enough to be able to contribute meaningfully to GHC, I'm not complaining about anyone's efforts, just that those efforts might be a bit misallocated. I'd venture a guess that far more people are interested in running 64-bit GHC on OSX than in running GHC on what is now fairly antiquated hardware. mc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC
maeder@leibniz:/local/maeder git clone g...@github.com: ckkashyap/Chitra.git Initialized empty Git repository in /local/maeder/Chitra/.git/ Permission denied (publickey). fatal: The remote end hung up unexpectedly maeder@leibniz:/local/maeder git --version git version 1.7.1 What permission is needed? Christian Oops, you can use git://github.com/ckkashyap/Chitra.git - sorry about that. You can also visit https://github.com/ckkashyap/Chitra Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC
I think you want: git clone git://github.com/ckkashyap/Chitra.git On Thu, Feb 3, 2011 at 10:50 AM, Christian Maeder christian.mae...@dfki.dewrote: Am 03.02.2011 12:15, schrieb C K Kashyap: Hi, I've been working on a Haskell based platform independent graphics rendering using VNC. I'd like it very much if you could take a look at it and give me feedback. Using it is straight forward - git clone g...@github.com:ckkashyap/Chitra.git This step failed for me with: maeder@leibniz:/local/maeder git clone g...@github.com: ckkashyap/Chitra.git Initialized empty Git repository in /local/maeder/Chitra/.git/ Permission denied (publickey). fatal: The remote end hung up unexpectedly maeder@leibniz:/local/maeder git --version git version 1.7.1 What permission is needed? Christian ___ 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] Review request for platform independent interactive graphics with VNC
Attached is the Cabal file I used to build (it wasn't clear what license things are under so those fields are commented out). Thanks a ton Rayan ... I am glad you liked it. I've checked in the cabal file - I am not familiar with it though ... how exactly can I use it to build the project? Also, do you have an idea how it can be incorporated into GHCI - As in, the program should do a forkIO and in one thread, handle network and on the other prompt an interactive ghci shell that'll let one modify the screen buffer in an expressive way in haskell! Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC
Am 03.02.2011 17:20, schrieb C K Kashyap: Oops, you can use git://github.com/ckkashyap/Chitra.git http://github.com/ckkashyap/Chitra.git - sorry about that. You can also visit https://github.com/ckkashyap/Chitra Thanks, I cannot get it to run with my vncviewer (TightVNC Viewer version 1.3.9) How should I call vncviewer and your Main binary? Cheers Christian P.S. after getArgs in Main.hs use case args of [x, y, p] - ... _ - putStrLn usage: Main xres yres port instead of !! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: Database Supported Haskell (DSH)
I am pleased to announce that Database Supported Haskell (DSH) has been released on Hackage [1]. DSH is a Haskell library for database-supported program execution. Using this library a relational database management system (RDBMS) can be used as a coprocessor for the Haskell programming language, especially for those program fragments that carry out data-intensive and data-parallel computation. Database executable program fragments can be written using the list comprehension notation (with modest syntax changes due to quasiquoting) and list processing combinators from the Haskell list prelude. Note that rather than embedding a relational language into Haskell, we turn idiomatic Haskell programs into SQL queries. DSH faithfully represents list order and nesting, and compiles the list processing combinators into relational queries. The implementation avoids unnecessary data transfer and context switching between the database coprocessor and the Haskell runtime by ensuring that the number of generated relational queries is only determined by the program fragment's type and not by the database size. DSH can be used to allow existing Haskell programs to operate on large scale data (e.g., larger than the available heap) or query existing database resident data with Haskell. Note that this package is flagged experimental and therefore not suited for production use. This is a proof of concept implementation only. To learn more about DSH, our paper entitled as Haskell boards the Ferry: Database-supported program execution for Haskell is a recommended reading [2]. The package includes a couple of examples that demonstrate how to use DSH. [1] http://hackage.haskell.org/package/DSH [2] http://www-db.informatik.uni-tuebingen.de/files/publications/ferryhaskell.pdf ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC
Thanks, I cannot get it to run with my vncviewer (TightVNC Viewer version 1.3.9) How should I call vncviewer and your Main binary? ./Main 200 200 5900 after this, the program should start listening to port 5900 You can check if things are fine by telneting to localhost:5900, you should see this - ck@ck-desktop:~/lab/Chitra$ telnet localhost 5900 Trying ::1... Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. RFB 003.003 After this, you can use vncviewer to connect to localhost (5900 is the default port for vnc) P.S. after getArgs in Main.hs use case args of [x, y, p] - ... _ - putStrLn usage: Main xres yres port instead of !! Thanks Christian ... I've incorporated this. Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC
Am 03.02.2011 18:05, schrieb C K Kashyap: ck@ck-desktop:~/lab/Chitra$ telnet localhost 5900 Trying ::1... Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. RFB 003.003 After this, you can use vncviewer to connect to localhost (5900 is the default port for vnc) Right, a window seems to pop up very shortly before it fails for me as shown below: Cheers Christian maeder@leibniz:~ vncviewer localhost Connected to RFB server, using protocol version 3.3 No authentication needed Desktop name Haskell Framebuffer VNC server default format: 32 bits per pixel. Most significant byte first in each pixel. True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0 Warning: Cannot convert string -*-helvetica-bold-r-*-*-16-*-*-*-*-*-*-* to type FontStruct Using default colormap which is TrueColor. Pixel format: 32 bits per pixel. Least significant byte first in each pixel. True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0 ShmCleanup called Using shared memory PutImage Same machine: preferring raw encoding Unknown message type 120 from VNC server ShmCleanup called ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Review request for platform independent interactive graphics with VNC
Maybe these messages are also important? Client Said :: RFB 003.003 Sharing enabled SET PIXEL FORMAT called bpp = 32 depth = 24 big endian = 0 trueColor = 1 RED MAX = 255 GREEN MAX = 255 blueMax = 255 red shift = 16 green shift = 8 blue shift = 0 SetEncodings Command 14 0 FrameBufferUpdateRequest x=0, y=0 width =1, height=1 FrameBufferUpdateRequest x=1, y=0 width =99, height=1 FrameBufferUpdateRequest x=0, y=1 width =100, height=99 Main: socket: 7: hPutBuf: resource vanished (Connection reset by peer) Am 03.02.2011 18:43, schrieb Christian Maeder: Am 03.02.2011 18:05, schrieb C K Kashyap: ck@ck-desktop:~/lab/Chitra$ telnet localhost 5900 Trying ::1... Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. RFB 003.003 After this, you can use vncviewer to connect to localhost (5900 is the default port for vnc) Right, a window seems to pop up very shortly before it fails for me as shown below: Cheers Christian maeder@leibniz:~ vncviewer localhost Connected to RFB server, using protocol version 3.3 No authentication needed Desktop name Haskell Framebuffer VNC server default format: 32 bits per pixel. Most significant byte first in each pixel. True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0 Warning: Cannot convert string -*-helvetica-bold-r-*-*-16-*-*-*-*-*-*-* to type FontStruct Using default colormap which is TrueColor. Pixel format: 32 bits per pixel. Least significant byte first in each pixel. True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0 ShmCleanup called Using shared memory PutImage Same machine: preferring raw encoding Unknown message type 120 from VNC server ShmCleanup called ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell Functions
I need help with two functionsfirst this is the curent code :http://pastebin.com/UPATJ0r -Function 1)removeTautologies :: Formula-Formula If in a clause, a literal and its negation are found, it means that the clause will be true, regardless of the value finally assigned to that propositional variable. Consider the following example: (A v B v -A) ^ (B v C v A) The first clause contains the literals A and -A. This means that the clause will always be true, in which case it can be simplify the whole set to simply (B v C v A) . I was tinking of using something like removeTautologies (f:fs)=filter rTf:removeTautologies fs where rT-is supposed to take the firs Literal from the clasue and search for a similar one,if one si found we compare the values if not the we go to the second literal. -Function 2)pureLiteralDeletion :: Formula-Formula This is a little bit complicate but from What I get this function is suppose to implement a simplification step that assumes as true any atom in a formula that appears exclusively in a positive or negative form (not both). Consider the formula: (P v Q v R) ^ (P v Q v -R) ^ (-Q v R) Note that in this formula P is present but -P is not. Using Pure Literal Deletion it can be assumed that the value of P will be True thus simplifying the formula to (-Q v R). If the literal were false then the literal would simply be deleted from the clauses it appears in. In that case any satisfying model for the resulting formula would also be a satisfying model for the formula when we assume that the literal is true. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] hsmagick on OSX 10.6
Just out of curiosity, has anyone gotten this to work? I'm getting bus errors whenever I call readImage. If anyone out there has gotten it working and would tell me which versions they're using of the relevant bits, that would be very much appreciated. Also, I'll post all my debug info if there's someone who's gotten this to work. thanks, mc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Functions
On 3 February 2011 18:33, Manolache Andrei-Ionut andressocrate...@yahoo.com wrote: first this is the curent code :http://pastebin.com/UPATJ0r There is no code on that page. (It has expired, probably?) -- Ozgur Akgun ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Reader monad wrapping State monad
Given the first program, it seems that the unchanging first element of the tuple could be handled by a Reader monad, leading to the second program, where b becomes the state, but how do I get the constant a from the Reader monad? Michael == import Control.Monad.State type GeneratorState = State (Double,Double) sqrtST :: GeneratorState Double sqrtST = do (a,b0) - get let b1 = (b0**2.0+a)/(2.0*b0) (if (abs (a-b1**2.0)) 0.01 then return b1 else do put (a,b1) sqrtST) mySqrt a = let b = a/2.0 in fst ( runState sqrtST (a,b) ) {- *Main mySqrt 2.0 1.4142135623746899 -} == import Control.Monad.Reader import Control.Monad.State type GeneratorState = State Double sqrtST :: GeneratorState Double sqrtST = do b0 - get let a = ? b1 = (b0**2.0+a)/(2.0*b0) (if (abs (a-b1**2.0)) 0.01 then return b1 else do put b1 sqrtST) mySqrt a = let b = a/2.0 in runReaderT (runState sqrtST b) a ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Reader monad wrapping State monad
Is the idea here merely an exercise in using the state monad? This can be easily performed using pure code. Bob On 3 Feb 2011, at 19:18, michael rice wrote: Given the first program, it seems that the unchanging first element of the tuple could be handled by a Reader monad, leading to the second program, where b becomes the state, but how do I get the constant a from the Reader monad? Michael == import Control.Monad.State type GeneratorState = State (Double,Double) sqrtST :: GeneratorState Double sqrtST = do (a,b0) - get let b1 = (b0**2.0+a)/(2.0*b0) (if (abs (a-b1**2.0)) 0.01 then return b1 else do put (a,b1) sqrtST) mySqrt a = let b = a/2.0 in fst ( runState sqrtST (a,b) ) {- *Main mySqrt 2.0 1.4142135623746899 -} == import Control.Monad.Reader import Control.Monad.State type GeneratorState = State Double sqrtST :: GeneratorState Double sqrtST = do b0 - get let a = ? b1 = (b0**2.0+a)/(2.0*b0) (if (abs (a-b1**2.0)) 0.01 then return b1 else do put b1 sqrtST) mySqrt a = let b = a/2.0 in runReaderT (runState sqrtST b) a ___ 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] Reader monad wrapping State monad
On Thursday 03 February 2011 20:18:43, michael rice wrote: Given the first program, it seems that the unchanging first element of the tuple could be handled by a Reader monad, leading to the second program, where b becomes the state, but how do I get the constant a from the Reader monad? You need a monad-transformer to use both, Reader and State. You can use either ReaderT Double (State Double) or StateT Double (Reader Double) (they're isomorphic). Then you can query the modifiable state with get (from the MonadState class) and the immutable with ask (from the MonadReader class) type Heron = StateT Double (Reader Double) sqrtH :: Heron Double sqrtH = do a - ask b - get let c = 0.5*(b + a/b) if (good enough) then return c else put c sqrtH mySqrt a = runReader (evalStateT sqrtH (a*0.5)) a ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Reader monad wrapping State monad
On 3 February 2011 19:18, michael rice nowg...@yahoo.com wrote: but how do I get the constant a from the Reader monad? http://hackage.haskell.org/packages/archive/transformers/latest/doc/html/Control-Monad-Trans-Reader.html#v:ask You also need to change the type to use ReaderT. -- Ozgur Akgun ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Functions
(CCing haskell-cafe again) Is this an homework question? On 3 February 2011 20:30, Manolache Andrei-Ionut andressocrate...@yahoo.com wrote: http://pastebin.com/GxQBh3hx http://pastebin.com/GxQBh3hx --- On *Thu, 2/3/11, Ozgur Akgun ozgurak...@gmail.com* wrote: From: Ozgur Akgun ozgurak...@gmail.com Subject: Re: [Haskell-cafe] Haskell Functions To: Manolache Andrei-Ionut andressocrate...@yahoo.com Cc: haskell-cafe@haskell.org Date: Thursday, February 3, 2011, 10:59 AM On 3 February 2011 18:33, Manolache Andrei-Ionut andressocrate...@yahoo.comhttp://mc/compose?to=andressocrate...@yahoo.com wrote: first this is the curent code :http://pastebin.com/UPATJ0r There is no code on that page. (It has expired, probably?) -- Ozgur Akgun -- Ozgur Akgun ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Reader monad wrapping State monad
Hi Daniel, Ok, but what I was looking for was ReaderT on top, State on the bottom. This is very confusing material, with no apparent conceptual commonality (ad hoc comes to mind) among the many examples I've looked at. Sometimes lift is used, other times a lift helper function, and in this case no use of lift at all. Michael --- On Thu, 2/3/11, Daniel Fischer daniel.is.fisc...@googlemail.com wrote: From: Daniel Fischer daniel.is.fisc...@googlemail.com Subject: Re: [Haskell-cafe] Reader monad wrapping State monad To: haskell-cafe@haskell.org Cc: michael rice nowg...@yahoo.com Date: Thursday, February 3, 2011, 2:54 PM On Thursday 03 February 2011 20:18:43, michael rice wrote: Given the first program, it seems that the unchanging first element of the tuple could be handled by a Reader monad, leading to the second program, where b becomes the state, but how do I get the constant a from the Reader monad? You need a monad-transformer to use both, Reader and State. You can use either ReaderT Double (State Double) or StateT Double (Reader Double) (they're isomorphic). Then you can query the modifiable state with get (from the MonadState class) and the immutable with ask (from the MonadReader class) type Heron = StateT Double (Reader Double) sqrtH :: Heron Double sqrtH = do a - ask b - get let c = 0.5*(b + a/b) if (good enough) then return c else put c sqrtH mySqrt a = runReader (evalStateT sqrtH (a*0.5)) a ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ($) not as transparent as it seems
Dear cafe, does anyone have an explanation for this?: error (error foo) *** Exception: foo error $ error foo *** Exception: *** Exception: foo -- Steffen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Functions
A project...this are my last questions,I'm not proeficient in haskell...this explains why Im stuck... http://pastebin.com/GxQBh3hx -- View this message in context: http://haskell.1045720.n5.nabble.com/Haskell-Functions-tp3369769p3369938.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Byte Histogram
There now follows a small grab-bag of miscelaneous but related thoughts. (Which probably means that this post will spawn a 2000 message thread discussing one tiny side-issue, rather than the main thrust of the message...) First of all, benchmarking. We have The Great Language Shootout, which tests how fast solutions implemented in various programming languages can be, given unbounded amounts of time, energy, expertise, and compiler modifications. Which is interesting, from a certain point of view. In another sense, it's less interesting. For example, a C program can be as fast as any Haskell program, since compiling Haskell entails transforming it *into* C. (Unless you're seriously going to suggest that GHC's native code generator is any match for the might of a half-decent C compiler...) That got me thinking about a more interesting question: Not *how fast* can it go, but *how easily* can it go fast? People have written fast C programs and fast Haskell programs, but how easy is it to write a typical program and have it go fast, without spending years optimising it? With that in mind, I set of with a plan to do some small-scale benchmarking. Pick a problem, solve it in both Haskell and C++, in the simplest, most obvious way, and then apply the simplest, most obvious optimisations. Measure performance and compare. There are benchmarks that just output some data. (Find all the prime numbers less than 1000...) I dislike these for a couple of reasons, not least because you can precompute the correct answer and just write a program which outputs that. (!) So I decided that all my benchmark programs should take a variable-sized data file as input, and save the results as output. There's an old maxim of running benchmarks multiple times, to ensure that whatever time you got wasn't just a fluke. But then, maybe the first run pulls the input file into the file cache, and subsequent runs go faster. If your input data was randomly generated, perhaps you chose a particularly optimal or pessimal data set by accident. So I decided that each test run should use a different input file of approximately the same characteristics (size, random distribution, etc.) So I ended up picking benchmarks like sort the lines of this file into ascending order, count the number of unique words in this file, produce a histogram of byte values, compute some statistics of this list of numbers, etc. The tasks are all extremely simple, so that there is some hope of it being possible to also implement them in C++. One benchmark turned out to be particularly interesting: I call it byte histogram. The task is simple: - Open a binary input file. - Read a stream of bytes from it. - Count how many times each of the 256 possible byte values appears. The test inputs are binary files of various sizes, some with a uniform distribution, some with variously skewed distributions (so that some bytes have a vastly higher count than others). Assuming we have some suitable import statements, it's quite easy to do this: bytes - BS.readFile Input.bin let out = BS.foldl' (\ map byte - MAP.insertWith (+) byte 1 map) MAP.empty bytes writeFile Output.csv (unlines $ map (\(k,v) - show k ++ , ++ show v) $ MAP.toAscList out) (There is some slight trickiness if you want bytes with zero frequency to still be listed.) All of this *works* perfectly - i.e., it produces the correct answers. It's also astronomically slow, and it's very easy to make it eat many gigabytes of RAM while it runs. (If the program starts actually swapping, then you will truly know what slow is!) OK, so what happens if we replace Data.Map with Data.IntMap? Well, it goes slightly faster, and consumes slightly less RAM. Inputs which didn't quite complete before will run to completion now. But performance is still abysmal. Enough with this tree sillyness. What happens if you use an array? Given that the entire program (apart from the last 0.02% of it) spends its time notionally mutating the data, a mutable array would be the logical choise. Dial up an IOArray Word8 Int and the structure of the program changes slightly, but it's still only a handful of lines of code. And the performance? Still glacial. In particular, suppose we have inc :: IOArray Word8 Int - Word8 - IO () inc array byte = do count - readArray array byte let count' = count + 1 writeArray array byte count' in the main loop. The program is giving us the right answer, but using absurd amounts of time and space to get it. Now watch this: inc :: IOArray Word8 Int - Word8 - IO () inc array byte = do count - readArray array byte let count' = count + 1 count' `seq` writeArray array byte count' And now, suddenly, memory usage becomes constant, regardless of input size, and run-time is slashed. The program goes from taking 50 seconds to process a certain file to taking only 0.02 seconds. And from taking 400 MB of RAM
Re: [Haskell-cafe] Reader monad wrapping State monad
On Thursday 03 February 2011 21:40:13, michael rice wrote: Hi Daniel, Ok, but what I was looking for was ReaderT on top, State on the bottom. No problem, just change the definition of the Heron type synonym and swap the applcations of runReader[T] and evalState[T] in mySqrt, the monadic sqrtH can remain unchanged :) This is very confusing material, with no apparent conceptual commonality (ad hoc comes to mind) among the many examples I've looked at. Sometimes lift is used, other times a lift helper function, and in this case no use of lift at all. That's because only methods of the MonadState and the MonadReader class are used and instances of MonadState are propagated/lifted through ReaderT, instance of MonadReader are propagated/lifted through StateT. ( instance MonadReader r m = MonadReader r (StateT s m) where ask = lift ask local = ... instance MonadState s m = MonadState (ReaderT r m) where get = lift get put = ... ) If you use a function on the inner monad which is not propagated to the entire transformer stack via class instances, you have to use lift (if you have a MonadTrans instance) or something similar. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Another Question
On 3/02/2011, at 8:18 PM, Navin Rustagi wrote: hi , I am stuck in the following problem. I am maintaining a list of tuples of the form ([Char],Int,Int, Int,Int) . The purpose of maintaining the tuples is that the program reads from a file line by line , Matches the contents with the first element of the tuple and updates the tuple respectively. The precise function I am using is as follows tupup::Bool-[Char]-Int-Int-Int-Int-Char-([Char],Int,Int,Int,Int) tupup val elf els elr ell elx ys= if val then case ys of 'A' - (elf, els+1,elr,ell,elx) 'G' - (elf,els, elr +1,ell,elx) 'C' - (elf,els,elr, ell +1,elx) 'T' - (elf,els,elr,ell, elx +1) else (elf,els,elr,ell,elx) uptable::[[Char]]-[([Char],Int,Int,Int,Int)]-[([Char],Int,Int,Int,Int)] uptable (xf:xs) main_array = map (\(x,y,z,r,t)- tupup (x==xf) x y z r t (secvalue xs) ) main_array It gives the error ERROR - Control stack overflow. I assume it is because of the lazy evaluation . The lazy evaluation of the ech+1 expressions, to be specific. By the way, could I make a plea for narrower lines in your source code? Ninety-nine columns is much wider than I find comfortable. A little white space helps readability too. I want to offer you a completely Haskell 98 solution. Step 1. Let's look at the types. Trust me, this WILL pay off. Twice. The type (String,Int,Int,Int,Int) occurs several times here. In fact this appears to represent a maplet String :- (Int,Int,Int,Int). We'll refactor that and make a data type for the counts. data Codon_Counts = Codon_Counts Int Int Int Int type Codon_Map = [(String, Codon_Counts)] Step 2. Two things are intermingled here: a control structure for applying a function to the second part of maplets whose first part equals a given key, and what to do to those second parts. Let's factor out the control structure. map_matching_maplets :: Eq k = k - (a - a) - [(k, a)] - [(k, a)] map_matching_maplets k f = map (\maplet@(key,val) - if key == k then (key,f val) else maplet) Step 3. Write an 'update_codon_map' function. update_codon_map :: [String] - Codon_Map - Codon_Map update_codon_map (what:how) = map_matching_maplets what $ case secvalue how of 'A' - \(Codon_Counts a g c t) - Codon_Counts (a+1) g c t 'G' - \(Codon_Counts a g c t) - Codon_Counts a (g+1) c t 'C' - \(Codon_Counts a g c t) - Codon_Counts a g (c+1) t 'T' - \(Codon_Counts a g c t) - Codon_Counts a g c (t+1) Step 4. Add strictness annotations. In Haskell 98, the only place you can put strictness annotations is in types. That's one of the reasons I introduced the Codon_Counts type. Change just one line so the declaration reads data Codon_Counts = Codon_Counts !Int !Int !Int !Int Step 5. I suspect that there is still a big performance problem. I *think* that this list of tuples is *really* a map from some key to a set of codon counts, so that a call to update_codon_map is expected to change just one maplet. If that's so, then having a Codon_Map type has a big payoff, because you can do import qualified Data.Map as Map type Codon_Map = Map.Map String Codon_Counts update_codon_map (what:how) map = Map.update f what where f (Codon_Counts a g c t) = Just $ case secvalue how of 'A' - Codon_Counts (a+1) g c t 'G' - Codon_Counts a (g+1) c t 'C' - Codon_Counts a g (c+1) t 'T' - Codon_Counts a g c (t+1) If there are n items in the map, the list based code is O(n), while this is O(log n). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Functions
On Thursday 03 February 2011 21:37:45, Ozgur Akgun wrote: (CCing haskell-cafe again) Is this an homework question? I think so: http://stackoverflow.com/questions/4877486/haskell-procedure www.inf.ed.ac.uk/teaching/courses/inf2d/.../Inf2d-09-Assignment1.pdf ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ($) not as transparent as it seems
On Thu, Feb 3, 2011 at 2:44 PM, Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de wrote: Dear cafe, does anyone have an explanation for this?: error (error foo) *** Exception: foo error $ error foo *** Exception: *** Exception: foo I don't know if this is relevant, but I thought that the GHC compiler believes that all exceptions are equivalent and indistinguishable - that is, in the presence of multiple exceptional code-paths it will make optimizations that would not otherwise otherwise be sound. That might not be the issue here, but it is interesting. http://research.microsoft.com/en-us/um/people/simonpj/papers/imprecise-exn.htm Antoine -- Steffen ___ 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] ($) not as transparent as it seems
This is indeed very strange. On my latest GHC 7 (built a couple of days ago) it does the right thing when compiled, but in GHCi it behaves as you describe. I have no idea, frankly. On Thu, Feb 3, 2011 at 8:44 PM, Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de wrote: Dear cafe, does anyone have an explanation for this?: error (error foo) *** Exception: foo error $ error foo *** Exception: *** Exception: foo -- Steffen ___ 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] Byte Histogram
To illustrate your prediction about the side-issues: On Thursday 03 February 2011 22:10:51, Andrew Coppin wrote: Consider for a moment the original implementation with Data.Map. Adding a seq or two here will do no good at all; seq reduces to WHNF. What we are wanting is NF, and I can see no way at all of doing that. Check out Data.Map.insertWith' ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Reader monad wrapping State monad
And swap the arguments. Thanks for going the extra mile. Michael --- On Thu, 2/3/11, Daniel Fischer daniel.is.fisc...@googlemail.com wrote: From: Daniel Fischer daniel.is.fisc...@googlemail.com Subject: Re: [Haskell-cafe] Reader monad wrapping State monad To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Thursday, February 3, 2011, 4:15 PM On Thursday 03 February 2011 21:40:13, michael rice wrote: Hi Daniel, Ok, but what I was looking for was ReaderT on top, State on the bottom. No problem, just change the definition of the Heron type synonym and swap the applcations of runReader[T] and evalState[T] in mySqrt, the monadic sqrtH can remain unchanged :) This is very confusing material, with no apparent conceptual commonality (ad hoc comes to mind) among the many examples I've looked at. Sometimes lift is used, other times a lift helper function, and in this case no use of lift at all. That's because only methods of the MonadState and the MonadReader class are used and instances of MonadState are propagated/lifted through ReaderT, instance of MonadReader are propagated/lifted through StateT. ( instance MonadReader r m = MonadReader r (StateT s m) where ask = lift ask local = ... instance MonadState s m = MonadState (ReaderT r m) where get = lift get put = ... ) If you use a function on the inner monad which is not propagated to the entire transformer stack via class instances, you have to use lift (if you have a MonadTrans instance) or something similar. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ($) not as transparent as it seems
On Thu, Feb 3, 2011 at 12:44 PM, Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de wrote: Dear cafe, does anyone have an explanation for this?: error (error foo) *** Exception: foo error $ error foo *** Exception: *** Exception: foo Have you read the intermediate Core (using -ddump-simpl) for each variation? Cheers, Tim -- Tim Chevalier * http://cs.pdx.edu/~tjc/ * Often in error, never in doubt an intelligent person fights for lost causes,realizing that others are merely effects -- E.E. Cummings ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hsmagick on OSX 10.6
On Thu, Feb 3, 2011 at 10:43 AM, Max Cantor mxcan...@gmail.com wrote: Just out of curiosity, has anyone gotten this to work? I'm getting bus errors whenever I call readImage. If anyone out there has gotten it working and would tell me which versions they're using of the relevant bits, that would be very much appreciated. Also, I'll post all my debug info if there's someone who's gotten this to work. Hi Max -- I know that several people have used hsmagick successfully, but I don't have Mac OS 10.6 (I use 10.5.8), so I can't try to reproduce your problem. Vincent Gerard is taking over maintainership of the library, so you may want to cc him on any emails. In general it's not too safe to assume that any particular library maintainer reads haskell-cafe regularly :-) Cheers, Tim (hsmagick maintainer) -- Tim Chevalier * http://cs.pdx.edu/~tjc/ * Often in error, never in doubt an intelligent person fights for lost causes,realizing that others are merely effects -- E.E. Cummings ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ($) not as transparent as it seems
catamorphism: On Thu, Feb 3, 2011 at 12:44 PM, Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de wrote: Dear cafe, does anyone have an explanation for this?: error (error foo) *** Exception: foo error $ error foo *** Exception: *** Exception: foo Have you read the intermediate Core (using -ddump-simpl) for each variation? A. GHC.Base.bindIO @ GHC.Prim.Any @ [()] ((GHC.Err.error @ [GHC.Types.Char] (GHC.Base.unpackCString# foo)) `cast` (CoUnsafe [GHC.Types.Char] (GHC.Types.IO GHC.Prim.Any) :: [GHC.Types.Char] ~ GHC.Types.IO GHC.Prim.Any)) ((\ (it_ade :: GHC.Prim.Any) (eta_B1 :: GHC.Prim.State# GHC.Prim.RealWorld) - ((GHC.Base.returnIO @ [()] (GHC.Types.: @ () (it_ade `cast` (CoUnsafe GHC.Prim.Any () :: GHC.Prim.Any ~ ())) (GHC.Types.[] @ ( `cast` (GHC.Types.NTCo:IO [()] :: GHC.Types.IO [()] ~ (GHC.Prim.State# GHC.Prim.RealWorld - (# GHC.Prim.State# GHC.Prim.RealWorld, [()] # eta_B1) `cast` (GHC.Prim.Any - sym (GHC.Types.NTCo:IO [()]) :: (GHC.Prim.Any - GHC.Prim.State# GHC.Prim.RealWorld - (# GHC.Prim.State# GHC.Prim.RealWorld, [()] #)) ~ (GHC.Prim.Any - GHC.Types.IO [()]))) B. GHC.Base.bindIO @ GHC.Prim.Any @ [()] (GHC.Base.$ @ [GHC.Types.Char] @ (GHC.Types.IO GHC.Prim.Any) (GHC.Err.error @ (GHC.Types.IO GHC.Prim.Any)) (GHC.Err.error @ [GHC.Types.Char] (GHC.Base.unpackCString# foo))) ((\ (it_aib :: GHC.Prim.Any) (eta_B1 :: GHC.Prim.State# GHC.Prim.RealWorld) - ((GHC.Base.returnIO @ [()] (GHC.Types.: @ () (it_aib `cast` (CoUnsafe GHC.Prim.Any () :: GHC.Prim.Any ~ ())) (GHC.Types.[] @ ( `cast` (GHC.Types.NTCo:IO [()] :: GHC.Types.IO [()] ~ (GHC.Prim.State# GHC.Prim.RealWorld - (# GHC.Prim.State# GHC.Prim.RealWorld, [()] # eta_B1) `cast` (GHC.Prim.Any - sym (GHC.Types.NTCo:IO [()]) :: (GHC.Prim.Any - GHC.Prim.State# GHC.Prim.RealWorld - (# GHC.Prim.State# GHC.Prim.RealWorld, [()] #)) ~ (GHC.Prim.Any - GHC.Types.IO [()]))) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ($) not as transparent as it seems
This is probably a result of strictness analysis. error is technically strict, so it is reasonable to optimize to: let e = error foo in e `seq` error e On Thu, Feb 3, 2011 at 1:44 PM, Steffen Schuldenzucker sschuldenzuc...@uni-bonn.de wrote: Dear cafe, does anyone have an explanation for this?: error (error foo) *** Exception: foo error $ error foo *** Exception: *** Exception: foo -- Steffen ___ 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] Byte Histogram
On 03/02/2011 09:37 PM, Daniel Fischer wrote: To illustrate your prediction about the side-issues: On Thursday 03 February 2011 22:10:51, Andrew Coppin wrote: Consider for a moment the original implementation with Data.Map. Adding a seq or two here will do no good at all; seq reduces to WHNF. What we are wanting is NF, and I can see no way at all of doing that. Check out Data.Map.insertWith' *facepalm* Wouldn't that still mean that the spine of the map is still lazy though? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ($) not as transparent as it seems
On Thu, Feb 3, 2011 at 2:03 PM, Luke Palmer lrpal...@gmail.com wrote: This is probably a result of strictness analysis. error is technically strict, so it is reasonable to optimize to: let e = error foo in e `seq` error e Yes, and you can see this in the Core code that Don posted: in version (A), GHC optimized away the outer call to error. But in version (B), the demand analyzer only knows that ($) is strict in its first argument -- it's not strict in its second. So it's not obviously safe to do the same optimization: the demand analyzer doesn't look through higher-order function arguments IIRC. (You can confirm this for yourself if you also want to read the demand analyzer output.) If ($) were getting inlined, the code would look the same coming into demand analysis in both cases, so you wouldn't see a difference. So I'm guessing you're compiling with -O0. Cheers, Tim -- Tim Chevalier * http://cs.pdx.edu/~tjc/ * Often in error, never in doubt an intelligent person fights for lost causes,realizing that others are merely effects -- E.E. Cummings ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Byte Histogram
Hi, Thanks for bringing up these issues. It's something we could be better at addressing as a community. First, we need to stop pretending that you can use Haskell effectively without first learning to reason about program evaluation order. Learning how is not terrible difficult, but there's very little material on how to do it [1]. Some of us have learnt it the hard way by experimentation or by talking to people who do understand lazy evaluation [2] (the Simons, Don, and Bryan to name a few). At the very least we need to teach people how to tell which arguments a pure function is strict in by looking at its definition. Second, many of our core data structures are lazy, but most uses are strict. That keeping a simple map of counters is tricky should tell us that something is wrong (you need to use insertWith'). It wouldn't be if Data.Map was strict in the values. Many strictness related problems people have are due to common data types like Maybe, tuples, and arrays being lazy. This is rarely what you want. 1. I tried to start creating some. For example, by giving a high performance Haskell talk at CUFP. Unfortunately the talk wasn't taped. 2. Haskell is non-strict, which doesn't necessarily imply lazy evaluation. However, lazy evaluation is what we actually deal with. Johan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Byte Histogram
On Thu, Feb 3, 2011 at 11:10 PM, Andrew Coppin andrewcop...@btinternet.com wrote: Wouldn't that still mean that the spine of the map is still lazy though? No, Data.Map and Data.Set are both spine strict (which should be documented!). Data.Map is key strict in addition. Both are value lazy. Johan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Byte Histogram
Hi, For what it's worth I saw the problems in your counting examples right away, without reading the explanatory text below. Hopefully that means that it's possibly to learn how to spot such things without resorting to e.g. running the program or reading Core *gasp*. Johan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ($) not as transparent as it seems
On Thursday 03 February 2011 23:03:36, Luke Palmer wrote: This is probably a result of strictness analysis. error is technically strict, so it is reasonable to optimize to: let e = error foo in e `seq` error e I think so too. Unoptimised, module Errors where foo = error (error foo) bar = error $ error bar produces the core Errors.bar :: forall a_aaN. a_aaN [GblId] Errors.bar = \ (@ a_aaN) - GHC.Base.$ @ [GHC.Types.Char] @ a_aaN (GHC.Err.error @ a_aaN) (GHC.Err.error @ [GHC.Types.Char] (GHC.Base.unpackCString# bar)) a_rb8 :: [GHC.Types.Char] [GblId, Str=DmdType b] a_rb8 = GHC.Err.error @ [GHC.Types.Char] (GHC.Base.unpackCString# foo) Errors.foo :: forall a_aaP. a_aaP [GblId] Errors.foo = (\ (@ a_aaP) - a_rb8) `cast` (forall a_aaP. CoUnsafe [GHC.Types.Char] a_aaP :: (forall a_aaP. [GHC.Types.Char]) ~ (forall a_aaP. a_aaP)) == The first argument to ($) is evaluated before the second [because the function may be lazy), resulting in the start of the error message ***Exception: , then that error-call must evaluate its argument, error bar, which results in ***Exception: bar (and terminates the thread) and two ***Exception: being printed. If I interpret the core correctly, error is so well known to the compiler that it strips off the outer `error' in foo even without optimisations (which surprises me a bit). With optimisations, ($) is inlined and `error $ error bar' is transformed to error (error bar), from then on both have identical structure and arrive at (mutatis mutandis) the same core (which is nearly the same as foo got without optimisations). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Byte Histogram
On Thursday 03 February 2011 23:19:31, Johan Tibell wrote: Hi, For what it's worth I saw the problems in your counting examples right away, without reading the explanatory text below. Yes, they were pretty obvious with enough experience. For beginners I expect it to be a rather insidious trap. Hopefully that means that it's possibly to learn how to spot such things without resorting to e.g. running the program or reading Core *gasp*. Within limits. Detrimental laziness or strictness can be arbitrarily well hidden. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Byte Histogram
On 4/02/2011, at 10:10 AM, Andrew Coppin wrote: The important obsevation is this: One tiny, almost insignificant change can transform a program from taking 50 seconds and 400 MB of RAM into one that takes 0.02 seconds and 0.1 MB of RAM. And, at least in this case, the simpler version is the slow one. To say that Haskell is slow is both a little bit vague, and not really backed up by facts. In about 5 minutes flat, I managed to write a Haskell program that's very simple, and yet faster than a comparably simple C++ program (and C++ is supposed to be fast). So it's not that Haskell is slow. It's that Haskell is *tricky*. Tiny, tiny little changes that look innocuous can have vast effects on performance. And this is a nice little example of that effect. This seems to me to be the heart of the message, so maybe this reply is on-topic. Back in the days when systems other than Wintel and maybe sort of intel Linux were supported by Clean, I used to really love one of the features of the Clean compiler. One simple command line switch and the compiler would list the names of all your top level functions together with their types, and the types included strictness. (Also uniqueness, not relevant to Haskell.) The GHC documentation says the information is in the interface files, but they are binary now, and I can't find it there. That got me thinking... What would happen if, instead of Integer, we had two types, evaluated Integer and possibly unevaluated Integer? What if the strictness or otherwise of a data structure were exposed at the type level? Oh, you mean like !Int and Int in Clean? I used to find bang *types* rather easier to deal with than I now do bang *patterns*. Currently, if you want a strict list, you have to implement one yourself. But is that strict in the spine, or the elements, or what? Spine strict: ![t]. Spine and element strict: ![!t]. I have no idea what the syntax for that would look like, Clean? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ($) not as transparent as it seems
On Thursday 03 February 2011 5:12:54 PM Tim Chevalier wrote: On Thu, Feb 3, 2011 at 2:03 PM, Luke Palmer lrpal...@gmail.com wrote: This is probably a result of strictness analysis. error is technically strict, so it is reasonable to optimize to: let e = error foo in e `seq` error e Yes, and you can see this in the Core code that Don posted: in version (A), GHC optimized away the outer call to error. But in version (B), the demand analyzer only knows that ($) is strict in its first argument -- it's not strict in its second. So it's not obviously safe to do the same optimization: the demand analyzer doesn't look through higher-order function arguments IIRC. (You can confirm this for yourself if you also want to read the demand analyzer output.) If ($) were getting inlined, the code would look the same coming into demand analysis in both cases, so you wouldn't see a difference. So I'm guessing you're compiling with -O0. Whatever is going on, it has to be active during ghci, because all these differences can be seen during interpretation (in 7.0.1, at least). Prelude error (error foo) *** Exception: foo Prelude error $ error foo *** Exception: *** Exception: foo Prelude let g :: (a - b) - a - b ; g f x = f x in g error (error foo) *** Exception: foo Prelude let g :: (a - b) - a - b ; g f x = f x Prelude g error (error foo) *** Exception: *** Exception: foo Prelude let foo = error foo in error foo *** Exception: foo Prelude let foo = error foo Prelude error foo *** Exception: *** Exception: foo Actually compiling seems to remove the difference in 7.0.1, at least, because the output is always: Foo: foo regardless of ($) or not ('fix error' hangs without output as well, which isn't what I thought would happen). Anyhow, that rules out most general-purpose optimizations (including strictness analysis, I thought). - Dan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ($) not as transparent as it seems
In general, errors are always interchangeable with another. An exception in haskell is a value, rather than an event. Haskell prescribes no evaluation order other than if the result is defined it must be equivalant to the one generated by a normal-order reduction strategy. Since error is not a valid value, any behavior including just locking up is a completely acceptable (if not very friendly) thing for a compiler to do. In practice, we like writing compilers that help us find our errors and using compilers that don't obfuscate them so compilers tend to behave more or less like youd expect when presented with error, but not at the expense of optimization or other necessary transformations. GHC has stronger guarentees in order to support its imprecise exceptions extension in that the exceptional value returned is guarenteed to be (non-deterministically) selected from the set of all possible errors for every possible evaluation order of the expression. So It won't just conjure up something new out of thin air, but neither can you expect any particular exception when your code can produce more than one. John On Thu, Feb 3, 2011 at 2:42 PM, Dan Doel dan.d...@gmail.com wrote: On Thursday 03 February 2011 5:12:54 PM Tim Chevalier wrote: On Thu, Feb 3, 2011 at 2:03 PM, Luke Palmer lrpal...@gmail.com wrote: This is probably a result of strictness analysis. error is technically strict, so it is reasonable to optimize to: let e = error foo in e `seq` error e Yes, and you can see this in the Core code that Don posted: in version (A), GHC optimized away the outer call to error. But in version (B), the demand analyzer only knows that ($) is strict in its first argument -- it's not strict in its second. So it's not obviously safe to do the same optimization: the demand analyzer doesn't look through higher-order function arguments IIRC. (You can confirm this for yourself if you also want to read the demand analyzer output.) If ($) were getting inlined, the code would look the same coming into demand analysis in both cases, so you wouldn't see a difference. So I'm guessing you're compiling with -O0. Whatever is going on, it has to be active during ghci, because all these differences can be seen during interpretation (in 7.0.1, at least). Prelude error (error foo) *** Exception: foo Prelude error $ error foo *** Exception: *** Exception: foo Prelude let g :: (a - b) - a - b ; g f x = f x in g error (error foo) *** Exception: foo Prelude let g :: (a - b) - a - b ; g f x = f x Prelude g error (error foo) *** Exception: *** Exception: foo Prelude let foo = error foo in error foo *** Exception: foo Prelude let foo = error foo Prelude error foo *** Exception: *** Exception: foo Actually compiling seems to remove the difference in 7.0.1, at least, because the output is always: Foo: foo regardless of ($) or not ('fix error' hangs without output as well, which isn't what I thought would happen). Anyhow, that rules out most general-purpose optimizations (including strictness analysis, I thought). - Dan ___ 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] ($) not as transparent as it seems
Thanks to all of you for making GHC's behaviour yet a bit clearer to me. On 02/03/2011 11:25 PM, Daniel Fischer wrote: On Thursday 03 February 2011 23:03:36, Luke Palmer wrote: This is probably a result of strictness analysis. error is technically strict, so it is reasonable to optimize to: let e = error foo in e `seq` error e I think so too. Unoptimised, module Errors where foo = error (error foo) bar = error $ error bar produces the core Errors.bar :: forall a_aaN. a_aaN [GblId] Errors.bar = \ (@ a_aaN) - GHC.Base.$ @ [GHC.Types.Char] @ a_aaN (GHC.Err.error @ a_aaN) (GHC.Err.error @ [GHC.Types.Char] (GHC.Base.unpackCString# bar)) a_rb8 :: [GHC.Types.Char] [GblId, Str=DmdType b] a_rb8 = GHC.Err.error @ [GHC.Types.Char] (GHC.Base.unpackCString# foo) Errors.foo :: forall a_aaP. a_aaP [GblId] Errors.foo = (\ (@ a_aaP) - a_rb8) `cast` (forall a_aaP. CoUnsafe [GHC.Types.Char] a_aaP :: (forall a_aaP. [GHC.Types.Char]) ~ (forall a_aaP. a_aaP)) == The first argument to ($) is evaluated before the second [because the function may be lazy), resulting in the start of the error message ***Exception: , then that error-call must evaluate its argument, error bar, which results in ***Exception: bar (and terminates the thread) and two ***Exception: being printed. If I interpret the core correctly, error is so well known to the compiler that it strips off the outer `error' in foo even without optimisations (which surprises me a bit). With optimisations, ($) is inlined and `error $ error bar' is transformed to error (error bar), from then on both have identical structure and arrive at (mutatis mutandis) the same core (which is nearly the same as foo got without optimisations). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Byte Histogram
Daniel Fischer wrote: On Thursday 03 February 2011 23:19:31, Johan Tibell wrote: Hi, For what it's worth I saw the problems in your counting examples right away, without reading the explanatory text below. Yes, they were pretty obvious with enough experience. For beginners I expect it to be a rather insidious trap. Hopefully that means that it's possibly to learn how to spot such things without resorting to e.g. running the program or reading Core *gasp*. Within limits. Detrimental laziness or strictness can be arbitrarily well hidden. I am a relative newcomer to Haskell, but I think I have a reasonable understanding of the executaion model. Enough to fix performance issues in simple code like the example given. However, one of the Haskell projects I work on is Ben Lippmeier's DDC compiler. Thats about 5 lines of Haskell code and finding performance issues there is really difficult. 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
Re: [Haskell-cafe] Problems with iteratees
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 2/2/11 20:06 , wren ng thornton wrote: When I put this all together, the process is killed with: control message: Just (Err endOfInput) POSIX FIFOs and GHC's nonblocking file descriptors implementation don't play well together; you should launch the writer end first and let it block waiting for the reader, or you should switch to opening the FIFO r/w and add a control message for end-of-stream (the usual way to work with FIFOs). - -- brandon s. allbery [linux,solaris,freebsd,perl]allber...@gmail.com system administrator [openafs,heimdal,too many hats]kf8nh -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk1LRWYACgkQIn7hlCsL25UhiwCePaEpZM0wlKRabmOT0SV7UKbP Bc8AnRs+QTl59Cn9JRWUfNE1MBGv0X1S =Fvqe -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell AES
I'd like to use AES in a haskell program that I'm writing. I've come across three libraries in hackage that do AES: the library named AES, the Crypto library, and the SimpleAES library. The library named AES says in its documentation for the crypt function that it is not thread-safe. What exactly does this mean in haskell? Does it mean that if you have separate AESCtx instances in different forkIO threads, that things will break? Or does it just mean that using the same AESCtx in multiple forkIO threads is a bad idea? I'm asking about that one comment because it looks like SimpleAES is probably a wrapper around AES, and the Crypto library also says it uses a library named AES, although one by an author not listed in the hackage AES library entry. Can anybody shed some light on the state of AES encryption in haskell? What is the preferred library, especially for us in a program that has many forkIO'd threads? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe