RE: [Haskell-cafe] Pointfree rank-2 typed function
| Are there workarounds for uses of impredicative types, or do we lose the | ability to express certain programs as a result? There's usually a workaround. I include the msg I sent below. Simon -Original Message- From: Simon Peyton-Jones Sent: 30 October 2009 09:52 To: GHC users Cc: Dimitrios Vytiniotis Subject: GHC 6.12.1 and impredicative polymorphism Friends One more update about GHC 6.12, concerning impredicative polymorphism. GHC has had an experimental implementation of impredicative polymorphism for a year or two now (flag -XImpredicativePolymorphism). But a) The implementation is ridiculously complicated, and the complexity is pervasive (in the type checker) rather than localized. I'm very unhappy about this, especially as we add more stuff to the type checker for type families. b) The specification (type system) is well-defined [1], but is also pretty complicated, and it's just too hard to predict which programs will typecheck and which will not. So it's time for a re-think. I propose to deprecate it in 6.12, and remove it altogether in 6.14. We may by then have something else to put in its place. (There is no lack of candidates [2,3,4]!) Fortunately, I don't think a lot of people use the feature in anger. Please yell if you *are* using impredicative polymorphism for something serious. But if you are, we need to think of a workaround. The current situation seems unsustainable. Simon [1] http://research.microsoft.com/en-us/um/people/simonpj/papers/boxy/ [2] http://research.microsoft.com/en-us/um/people/crusso/qml/ [3] http://research.microsoft.com/en-us/um/people/daan/pubs.html [4] http://gallium.inria.fr/~remy/mlf/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HOpenGL and freeglut rendering problems
On Wed, Nov 25, 2009 at 3:45 AM, Eitan Goldshtrom thesource...@gmail.com wrote: Hello. I'm new to this mailing list, so I apologize if this question is inappropriate for this list, but I've been looking for a solution to this problem for weeks and I've had no luck. I am trying to write a program with HOpenGL and freeglut, but I can't seem to get it to render. I'm running Ubuntu 9.10 on a DELL 1555 with an ATI Radeon HD 4500. Right now my program just creates a window with a black background. However, when I try to run the program I get the following error: Unable to create direct context rendering for window 'IGL' This may hurt performance. I've read that this is because of the fglrx driver. The driver uses indirect rendering for OpenGL, but freeglut requires direct rendering? Is there a way to force freeglut to function with indirect rendering? -Eitan If I'm not mistaken, lack of Direct Rendering: yes in the output of `glxinfo` means you do not have hardware acceleration because fglrx is not installed correctly. Suggest you seek help from your distro's support forum. Jeff ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] haskell-mode.el mailing list (+ dpatch)
On Wed, Nov 25, 2009 at 12:06 AM, Valery V. Vorotyntsev valery...@gmail.com wrote: Is there anybody except me feeling the need for mailing list and issue tracker for emacs' haskell-mode? +1 Since there already is a haskellmode-emacs project on the http://community.haskell.org server we can start a mailing list and issue tracker easily: http://code.haskell.org/haskellmode-emacs/ regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] haskell-mode.el mailing list (+ dpatch)
On Wed, Nov 25, 2009 at 9:21 AM, Bas van Dijk v.dijk@gmail.com wrote: On Wed, Nov 25, 2009 at 12:06 AM, Valery V. Vorotyntsev valery...@gmail.com wrote: Is there anybody except me feeling the need for mailing list and issue tracker for emacs' haskell-mode? +1 Since there already is a haskellmode-emacs project on the http://community.haskell.org server we can start a mailing list and issue tracker easily: Well, I know when I'm beat.. http://trac.haskell.org/haskellmode-emacs/ http://projects.haskell.org/cgi-bin/mailman/listinfo/haskellmode-emacs -- Svein Ove Aas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] haskell-mode.el mailing list (+ dpatch)
On Wed, Nov 25, 2009 at 9:37 AM, Svein Ove Aas svein@aas.no wrote: On Wed, Nov 25, 2009 at 9:21 AM, Bas van Dijk v.dijk@gmail.com wrote: On Wed, Nov 25, 2009 at 12:06 AM, Valery V. Vorotyntsev valery...@gmail.com wrote: Is there anybody except me feeling the need for mailing list and issue tracker for emacs' haskell-mode? +1 Since there already is a haskellmode-emacs project on the http://community.haskell.org server we can start a mailing list and issue tracker easily: Well, I know when I'm beat.. http://trac.haskell.org/haskellmode-emacs/ http://projects.haskell.org/cgi-bin/mailman/listinfo/haskellmode-emacs Joined. Thank you, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] haskell-mode.el mailing list (+ dpatch)
On Wed, Nov 25, 2009 at 10:37 AM, Svein Ove Aas svein@aas.no wrote: http://trac.haskell.org/haskellmode-emacs/ http://projects.haskell.org/cgi-bin/mailman/listinfo/haskellmode-emacs Hurray! Thanks, Svein. -- vvv ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] haskell-mode.el mailing list (+ dpatch)
On Wed, Nov 25, 2009 at 9:37 AM, Svein Ove Aas svein@aas.no wrote: Well, I know when I'm beat.. http://trac.haskell.org/haskellmode-emacs/ http://projects.haskell.org/cgi-bin/mailman/listinfo/haskellmode-emacs Nice! I joined the list and submitted my first ticket. Keep up the good work. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] surrogate code points in a Char
2009/11/25 Mark Lentczner ma...@glyphic.com: The current version of Unicode is 5.1. This text is now in D90, though otherwise the same. My references below are to the 5.1 documents (freely available on line at: http://www.unicode.org/versions/Unicode5.1.0/ ) It's been 5.2 for over a month now, I think. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Pointfree rank-2 typed function
Simon Peyton-Jones wrote: | Are there workarounds for uses of impredicative types, or do we lose the | ability to express certain programs as a result? There's usually a workaround. I include the msg I sent below. I tried to use impredicative polymorphism once to create polymorphic values inside a monad, similar to the following (silly) example foo :: IO (∀a. a - a) foo = do ref - newIORef id-- ref :: IO (∀a. a - a) readIORef ref (Fortunately, it turned out that this was not what I needed anyway.) Generally, it seems to me that all polymorphically typed EDSLs require impredicative polymorphism. After all, they are usually embedded with some kind of functor F (= Expr, IO, Parser, ...) and polymorphically typed means that you want types like F (∀a. a :~ a) and so on. Of course, we don't have (m)any examples of polymorphically typed DSLs yet, but it would be handy to have support for impredicativity in GHC if someone stumbles upon a useful one. Regards, apfelmus -- http://apfelmus.nfshost.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: haskell-mode.el mailing list (+ dpatch)
Svein Ove Aas svein@aas.no writes: Well, I know when I'm beat.. http://trac.haskell.org/haskellmode-emacs/ http://projects.haskell.org/cgi-bin/mailman/listinfo/haskellmode-emacs Excellent! Thanks. Any objection to my adding the list to gmane.org? Cheers, jao -- A: Because it fouls the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Possible FGL bug
It looks like a bug to me. Can you show an exact list of nodes and edges that is causing mkGraph to fail? Or is that what you have displayed, and I can't parse it properly? Thanks, Neil. Ivan Lazar Miljenovic wrote: When developing my QuickCheck-2 test-suite for graphviz, I wrote the following Arbitrary instance for FGL graphs (which needs FlexibleInstances): , | instance (Graph g, Arbitrary n, Arbitrary e, Show n, Show e) = Arbitrary (g n e) where | arbitrary = do ns - liftM nub arbitrary | let nGen = elements ns | lns - mapM makeLNode ns | trace (Nodes: ++ show lns) (return ()) | les - listOf $ makeLEdge nGen | trace (Edges: ++ show les) (return ()) | return $ mkGraph lns les | where | makeLNode n = liftM ((,) n) arbitrary | makeLEdge nGen = liftM3 (,,) nGen nGen arbitrary | | shrink gr = map (flip delNode gr) (nodes gr) ` However, when I try to run this, I occasionally get irrefutable pattern match failures as follows: , | *Data.GraphViz.Testing.Instances.FGL Data.Graph.Inductive.Tree sample (arbitrary :: Gen (Gr Int Char)) | | | 0:0-[] | | 0:-2-[] | 1:0-[('\a',0)] | 2:0-[] | | -4:-3-[('U',-3),('#',1)] | -3:3-[] | 1:-1-[('}',-3)] | | -8:8-[] | -3:2-[] | -1:-5-[('\US',-3),('',0)] | 0:5-[('F',-1),('p',4)] | 4:-1-[] | | -2:8-[('\177',-2),('(',-2),('d',-2),('4',-2),('D',-2),('\US',-2),('d',-2),('u',-2)] | | -16:11-[] | -2:-2-[] | 0:11-[('@',1)] | 1:13-[('u',11)] | 9:-11-[('\231',11)] | 11:12-[('\226',1)] | 16:15-[] | | -10:2-[] | -4:8-[] | 1:30-[] | 26:26-[('',1),('K',-4)] | 31:-21-[] | | -35:51-[('@',-29)] | -29:21-[('\132',-11)] | -11:-31-[('j',61)] | -4:40-[('a',-29)] | 0:6-[('z',-35),('9',28),('\170',-11),('\SUB',28)] | 23:8-[('P',-29),('(',61),('\\',28)] | 28:60-[] | 61:44-[('q',61)] | *** Exception: Data/Graph/Inductive/Graph.hs:250:26-59: Irrefutable pattern failed for pattern (Data.Maybe.Just (pr, _, la, su), g') ` The actual error comes from the definition of insEdge: , | -- | Insert a 'LEdge' into the 'Graph'. | insEdge :: DynGraph gr = LEdge b - gr a b - gr a b | insEdge (v,w,l) g = (pr,v,la,(l,w):su) g' | where (Just (pr,_,la,su),g') = match v g ` with the Graph instance for Tree-based graphs using this for its mkGraph method: , | mkGraph vs es = (insEdges' . insNodes vs) empty | where | insEdges' g = foldl' (flip insEdge) g es ` So, is this really a bug in FGL, or am I using mkGraph wrong? On another note, why doesn't the PatriciaTree graph type have a Show instance? :( ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Possible FGL bug
(Sorry for sending this to you twice Neil, I forgot to CC -cafe). Neil Brown nc...@kent.ac.uk writes: It looks like a bug to me. Can you show an exact list of nodes and edges that is causing mkGraph to fail? Or is that what you have displayed, and I can't parse it properly? That's what I was trying to do with the trace statements, but they didn't seem to print anything... (hmmm, maybe if I put the trace statements in the call to mkGraph itself). Thanks, Neil. Ivan Lazar Miljenovic wrote: When developing my QuickCheck-2 test-suite for graphviz, I wrote the following Arbitrary instance for FGL graphs (which needs FlexibleInstances): , | instance (Graph g, Arbitrary n, Arbitrary e, Show n, Show e) = Arbitrary (g n e) where | arbitrary = do ns - liftM nub arbitrary | let nGen = elements ns | lns - mapM makeLNode ns | trace (Nodes: ++ show lns) (return ()) | les - listOf $ makeLEdge nGen | trace (Edges: ++ show les) (return ()) | return $ mkGraph lns les | where | makeLNode n = liftM ((,) n) arbitrary | makeLEdge nGen = liftM3 (,,) nGen nGen arbitrary | | shrink gr = map (flip delNode gr) (nodes gr) ` However, when I try to run this, I occasionally get irrefutable pattern match failures as follows: , | *Data.GraphViz.Testing.Instances.FGL Data.Graph.Inductive.Tree sample (arbitrary :: Gen (Gr Int Char)) | | | 0:0-[] | | 0:-2-[] | 1:0-[('\a',0)] | 2:0-[] | | -4:-3-[('U',-3),('#',1)] | -3:3-[] | 1:-1-[('}',-3)] | | -8:8-[] | -3:2-[] | -1:-5-[('\US',-3),('',0)] | 0:5-[('F',-1),('p',4)] | 4:-1-[] | | -2:8-[('\177',-2),('(',-2),('d',-2),('4',-2),('D',-2),('\US',-2),('d',-2),('u',-2)] | | -16:11-[] | -2:-2-[] | 0:11-[('@',1)] | 1:13-[('u',11)] | 9:-11-[('\231',11)] | 11:12-[('\226',1)] | 16:15-[] | | -10:2-[] | -4:8-[] | 1:30-[] | 26:26-[('',1),('K',-4)] | 31:-21-[] | | -35:51-[('@',-29)] | -29:21-[('\132',-11)] | -11:-31-[('j',61)] | -4:40-[('a',-29)] | 0:6-[('z',-35),('9',28),('\170',-11),('\SUB',28)] | 23:8-[('P',-29),('(',61),('\\',28)] | 28:60-[] | 61:44-[('q',61)] | *** Exception: Data/Graph/Inductive/Graph.hs:250:26-59: Irrefutable pattern failed for pattern (Data.Maybe.Just (pr, _, la, su), g') ` The actual error comes from the definition of insEdge: , | -- | Insert a 'LEdge' into the 'Graph'. | insEdge :: DynGraph gr = LEdge b - gr a b - gr a b | insEdge (v,w,l) g = (pr,v,la,(l,w):su) g' | where (Just (pr,_,la,su),g') = match v g ` with the Graph instance for Tree-based graphs using this for its mkGraph method: , | mkGraph vs es = (insEdges' . insNodes vs) empty | where | insEdges' g = foldl' (flip insEdge) g es ` So, is this really a bug in FGL, or am I using mkGraph wrong? On another note, why doesn't the PatriciaTree graph type have a Show instance? :( -- 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] Re: haskell-mode.el mailing list (+ dpatch)
On Wed, 25 Nov 2009 09:37:21 +0100, Svein Ove Aas svein@aas.no wrote: On Wed, Nov 25, 2009 at 9:21 AM, Bas van Dijk v.dijk@gmail.com wrote: On Wed, Nov 25, 2009 at 12:06 AM, Valery V. Vorotyntsev valery...@gmail.com wrote: Is there anybody except me feeling the need for mailing list and issue tracker for emacs' haskell-mode? +1 Since there already is a haskellmode-emacs project on the http://community.haskell.org server we can start a mailing list and issue tracker easily: Well, I know when I'm beat.. http://trac.haskell.org/haskellmode-emacs/ http://projects.haskell.org/cgi-bin/mailman/listinfo/haskellmode-emacs Excellent topic for a mailing list! I edit most of my Haskell programs in haskell-mode in Emacs. Joined! -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 Furuike ya, kawazu tobikomu mizu no oto. -- Matsuo Basho^ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: feldspar-language
(In response to Tom Hawkins' posting of an IIR filter in Atom) We're still experimenting with how to best describe streaming computations with feedback in Feldspar. But for completeness, here one possible implementation of an IIR filter: iir :: forall m n o a . (NaturalT m, NaturalT n, NaturalT o, Num a , Primitive a) = VectorP m a - VectorP n a - VectorP o a - VectorP o a iir as bs = feedback f where f :: VectorP o a - VectorP o a - Data a f inPrev outPrev = dotProd as (resize inPrev) - dotProd bs (resize outPrev) (Please don't mind the type clutter -- we hope to get rid of most of it in the future.) The local function `f` computes a single output, and the `feedback` combinator applies `f` across the input stream. You can find the resulting C code attached. As you can see, the generated C has lots of room for optimization, but the time complexity is right (one top-level loop with two inner loops in sequence). We plan to tackle the more small-scale optimizations in the future. The dot product is defined in standard Haskell style: dotProd :: (Num a, Primitive a) = VectorP n a - VectorP n a - Data a dotProd as bs = fold (+) 0 (zipWith (*) as bs) Interestingly, `feedback` is also defined within Feldspar: feedback :: forall n a . (NaturalT n, Storable a) = (VectorP n a - VectorP n a - Data a) - VectorP n a - VectorP n a feedback f inp = unfreezeVector (length inp) outArr' where outArr :: Data (n : a) outArr = array [] outArr' = for 0 (length inp - 1) outArr $ \i arr - let prevInps = reverse $ take (i+1) inp prevOutps = reverse $ take i $ unfreezeVector i arr a = f prevInps prevOutps in setIx arr i a This definition uses low-level data structures and loops, and this is not something that ordinary Feldspar users should write. It is our hope that a few combinators like this one can be defined once and for all, and then reused for a wide range of DSP applications. It turns out that FIR filters are much nicer :) fir :: (NaturalT m, Num a , Primitive a) = VectorP m a - VectorP n a - VectorP n a fir coeffs = map (dotProd coeffs . resize . reverse) . inits C code attached. / Emil #include feldspar.h void fir( signed int var0_0_0, signed int var0_0_1[10], signed int var0_1_0, signed int var0_1_1[100], signed int *out_0, signed int out_1[100] ) { signed int var23[100]; { int var1; for( var1 = 0; var1 var0_1_0; var1 += 1) { signed int var7; int var8; signed int var9; int var10; signed int var11; signed int var12; signed int var17; signed int var22_0; var7 = (var1 + 1); var8 = (var0_1_0 = var7); if(var8) { var9 = var0_1_0; } else { var9 = var7; } var10 = (var0_0_0 = var9); if(var10) { var11 = var0_0_0; } else { var11 = var9; } var12 = (var11 - 1); var17 = (var9 - 1); var22_0 = 0; var23[var1] = 0; { int var13; var13 = (var22_0 = var12); while(var13) { var23[var1] = (var23[var1] + (var0_0_1[var22_0] * var0_1_1[(var17 - var22_0)])); var22_0 = (var22_0 + 1); var13 = (var22_0 = var12); } } } } *out_0 = var0_1_0; copy_arrayOf_signed_int((var23[0]), 100, (out_1[0])); } #include feldspar.h void iir( signed int var0_0_0, signed int var0_0_1[10], signed int var0_1_0, signed int var0_1_1[10], signed int var0_2_0, signed int var0_2_1[100], signed int *out_0, signed int out_1[100] ) { signed int var3; signed int var51_0; signed int var51_1[100]; signed int var53[100]; var3 = (var0_2_0 - 1); var51_0 = 0; copy_arrayOf_signed_int(({}[0]), 100, (var51_1[0])); { int var4; var4 = (var51_0 = var3); while(var4) { signed int var12; int var13; signed int var14; int var15; signed int var16; signed int var17; signed int var22; signed int var27_0; signed int var27_1; int var33; signed int var34; int var35; signed int var36; signed int var37; signed int var42; signed int var47_0; signed int var47_1; signed int var49[100]; var12 = (var51_0 + 1); var13 = (var0_2_0 = var12); if(var13) { var14 = var0_2_0; } else { var14 = var12;
Re: [Haskell-cafe] haskell-mode.el mailing list (+ dpatch)
On Wed, Nov 25, 2009 at 2:37 AM, Svein Ove Aas svein@aas.no wrote: Well, I know when I'm beat.. http://trac.haskell.org/haskellmode-emacs/ http://projects.haskell.org/cgi-bin/mailman/listinfo/haskellmode-emacs Thank you, Svein! I'm glad to see there's a good number of people using haskellmode. Paulo ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Possible FGL bug
On Wed, Nov 25, 2009 at 6:28 AM, Neil Brown nc...@kent.ac.uk wrote: It looks like a bug to me. Can you show an exact list of nodes and edges that is causing mkGraph to fail? Or is that what you have displayed, and I can't parse it properly? From what I can tell, insEdge inserts an edge between two nodes which are already in the graph. The code is calling insEdge on arbitrarily-labeled nodes, which may not exist in the graph. Instead of picking arbitrary node labels, try selecting arbitrary elements from the list of node labels. -- Dave Menendez d...@zednenem.com http://www.eyrie.org/~zednenem/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Possible FGL bug
David Menendez wrote: From what I can tell, insEdge inserts an edge between two nodes which are already in the graph. The code is calling insEdge on arbitrarily-labeled nodes, which may not exist in the graph. That's what I thought initially, but in fact what it is doing is exactly what you suggest: Instead of picking arbitrary node labels, try selecting arbitrary elements from the list of node labels. That nGen = elements ns line assigns into nGen a random generator that will pick from ns, the list of nodes. Thanks, Neil. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: haskell-mode.el mailing list (+ dpatch)
On Wed, 25 Nov 2009 11:37:11 +0100 Jose == Jose A. Ortega Ruiz j...@gnu.org wrote: Jose Excellent! Thanks. Any objection to my adding the list to Jose gmane.org? +1 for adding it to gmane. Sincerely, Gour -- Gour | Hlapicina, Croatia | GPG key: F96FF5F6 signature.asc Description: PGP signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Scrap your boilerplate traversals
Hi all, Is there a non-recursive traversal defined in Data.Generics' modules? I mean, the everywhere traversal first applies a function "f" to the subterms, and then applies "f" to the result. I am wondering if do exists a traversal that applies f only to the subterms. Thanks in advance, Rodrigo. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Scrap your boilerplate traversals
Hi, You want gmapT (or gmapM for the monadic version). If you look at the source to the everywhere function, you'll see that everywhere is defined in terms of gmapT: everywhere f = f . gmapT (everywhere f) Thanks, Neil. rodrigo.bonifacio wrote: Hi all, Is there a non-recursive traversal defined in Data.Generics' modules? I mean, the everywhere traversal first applies a function f to the subterms, and then applies f to the result. I am wondering if do exists a traversal that applies f only to the subterms. Thanks in advance, Rodrigo. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: haskell-mode.el mailing list (+ dpatch)
On Wed, Nov 25, 2009 at 11:37 AM, Jose A. Ortega Ruiz j...@gnu.org wrote: Svein Ove Aas svein@aas.no writes: Well, I know when I'm beat.. http://trac.haskell.org/haskellmode-emacs/ http://projects.haskell.org/cgi-bin/mailman/listinfo/haskellmode-emacs Excellent! Thanks. Any objection to my adding the list to gmane.org? I certainly don't mind. I've noticed that the list administrative interface has a news-gateway option. Is there anything I should do there? -- Svein Ove Aas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Possible FGL bug
On Wed, Nov 25, 2009 at 11:02 AM, Neil Brown nc...@kent.ac.uk wrote: David Menendez wrote: From what I can tell, insEdge inserts an edge between two nodes which are already in the graph. The code is calling insEdge on arbitrarily-labeled nodes, which may not exist in the graph. That's what I thought initially, but in fact what it is doing is exactly what you suggest: Instead of picking arbitrary node labels, try selecting arbitrary elements from the list of node labels. That nGen = elements ns line assigns into nGen a random generator that will pick from ns, the list of nodes. You're right. I've tried this in ghci, and I'm not able to reproduce the error. I did get an exception from QuickCheck when it tried to call elements on an empty list, though. This code works fine for me: a :: Gen ([LNode Char], [LEdge Char], Gr Char Char) a = do NonEmpty ns' - arbitrary let ns = nub ns' let nGen = elements ns lns - mapM (\n - liftM ((,) n) arbitrary) ns les - listOf $ liftM3 (,,) nGen nGen arbitrary return (lns, les, mkGraph lns les) I suspect that there's no value to generating an arbitrary list of node IDs, as opposed to something like: ns - liftM (\(Positive n) - [0..n]) arbitrary -- Dave Menendez d...@zednenem.com http://www.eyrie.org/~zednenem/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: atom-0.1.2
Atom is a DSL for designing hard realtime embedded software with Haskell. This release adds guarded division operations, 'phase', a new scheduling constraint, and a new rule scheduling algorithm. Many thanks to Lee Pike for his contributions! (Lee, sorry it took so long to get this out.) http://hackage.haskell.org/package/atom/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] I miss OO
I'm fairly new to Haskell, and starting to write some big projects. Previously I used OO exclusively, mostly Python. I really miss the namespace capabilities... a class can have a lot of generic method names which may be identical for several different classes because there is no ambiguity. In my musical application, many objects (or in Haskell, data) have a time associated with them. In Python I would have an accessor function called time in every class. So if I have objects/data note1, cursor1, and staff1, Python: note1.time() cursor1.time() staff1.time() Haskell needs something like note_time note1 cursor_time cursor1 staff_time staff1 which is a lot more visually disorganized. What's worse, I have a moderate case of RSI (repetitive strain injury) so I type slowly and depend on abbreviations a lot. I use the souped-up abbreviation capabilities of Emacs. Let's say I have a field/member-variable called orientedPcSet that is used across many classes. In Python, I can create an abbreviation for that and it is useful many times. In Haskell, I might need someType_orientedPcSet someOtherType_orientedPcSet thirdType_orientedPcSet which prevents me from using abbreviations effectively (especially the dynamic-completion feature). (It would help to make the underscore not part of word syntax, but that's not ideal.) So I'm thinking of moving to a scheme in Haskell using modules, most types being defined in their own modules, and doing qualified imports. Generic names like 'time' can be defined in each module w/o clashing. Then I have Note.time note1 Cursor.time cursor1 Staff.time staff1 This is very useful because I can define abbreviations for the type name and for oft-used accessor function names and these abbrevs are more organized, easier to remember, and easier to combine. I would be interested in comments... is this a good way to do things? Am I trying too hard to impose OO on Haskell and is there a better way? Thanks, Mike ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] I miss OO
On Wed, Nov 25, 2009 at 2:51 PM, Michael Mossey m...@alumni.caltech.edu wrote: I'm fairly new to Haskell, and starting to write some big projects. Previously I used OO exclusively, mostly Python. I really miss the namespace capabilities... a class can have a lot of generic method names which may be identical for several different classes because there is no ambiguity. In my musical application, many objects (or in Haskell, data) have a time associated with them. In Python I would have an accessor function called time in every class. So if I have objects/data note1, cursor1, and staff1, Python: note1.time() cursor1.time() staff1.time() Haskell needs something like note_time note1 cursor_time cursor1 staff_time staff1 which is a lot more visually disorganized. What's worse, I have a moderate case of RSI (repetitive strain injury) so I type slowly and depend on abbreviations a lot. I use the souped-up abbreviation capabilities of Emacs. Let's say I have a field/member-variable called orientedPcSet that is used across many classes. In Python, I can create an abbreviation for that and it is useful many times. In Haskell, I might need someType_orientedPcSet someOtherType_orientedPcSet thirdType_orientedPcSet which prevents me from using abbreviations effectively (especially the dynamic-completion feature). (It would help to make the underscore not part of word syntax, but that's not ideal.) So I'm thinking of moving to a scheme in Haskell using modules, most types being defined in their own modules, and doing qualified imports. Generic names like 'time' can be defined in each module w/o clashing. Then I have Note.time note1 Cursor.time cursor1 Staff.time staff1 This is very useful because I can define abbreviations for the type name and for oft-used accessor function names and these abbrevs are more organized, easier to remember, and easier to combine. I would be interested in comments... is this a good way to do things? Am I trying too hard to impose OO on Haskell and is there a better way? That is the way to do what you want and not a bad practice in general. There's nothing particularly OO about namespacing, for example, ML's modules and functors are quite a bit more flexible in this regard than typical OO languages. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] I miss OO
Michael Mossey wrote: I'm fairly new to Haskell, and starting to write some big projects. Previously I used OO exclusively, mostly Python. I really miss the namespace capabilities... a class can have a lot of generic method names which may be identical for several different classes because there is no ambiguity. In my musical application, many objects (or in Haskell, data) have a time associated with them. In Python I would have an accessor function called time in every class. This is what Type Classes in Haskell are for. See: http://www.haskell.org/tutorial/classes.html Erik -- -- Erik de Castro Lopo http://www.mega-nerd.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: mecha-0.0.4
Mecha is a little constructive solid modeling language intended for 3D CAD. This release adds animation capabilities, which use POVRay and FFmpeg behind the scenes. At work we've used Mecha to illustrated the kinematics of a new hydraulic pump design -- I wish I could post the animation, it's pretty cool to watch. http://hackage.haskell.org/package/mecha/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] I miss OO
2009/11/25 Michael Mossey m...@alumni.caltech.edu: I'm fairly new to Haskell, and starting to write some big projects. Previously I used OO exclusively, mostly Python. I really miss the namespace capabilities... a class can have a lot of generic method names which may be identical for several different classes because there is no ambiguity. In my musical application, many objects (or in Haskell, data) have a time associated with them. In Python I would have an accessor function called time in every class. So if I have objects/data note1, cursor1, and staff1, Python: note1.time() cursor1.time() staff1.time() Haskell needs something like note_time note1 cursor_time cursor1 staff_time staff1 which is a lot more visually disorganized. It looks like you use record syntax. This is not bad per se, but you can use Haskell classes to get an OO feeling. Like that: class Time a where time :: a - Time instance Time Note where time = note_time instance Time Cursor where time = cursor_time What's worse, I have a moderate case of RSI (repetitive strain injury) so I type slowly and depend on abbreviations a lot. I use the souped-up abbreviation capabilities of Emacs. Let's say I have a field/member-variable called orientedPcSet that is used across many classes. In Python, I can create an abbreviation for that and it is useful many times. In Haskell, I might need someType_orientedPcSet someOtherType_orientedPcSet thirdType_orientedPcSet Same here, I think. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] I miss OO
On Wed, Nov 25, 2009 at 2:08 PM, Erik de Castro Lopo mle...@mega-nerd.com wrote: Michael Mossey wrote: I'm fairly new to Haskell, and starting to write some big projects. Previously I used OO exclusively, mostly Python. I really miss the namespace capabilities... a class can have a lot of generic method names which may be identical for several different classes because there is no ambiguity. In my musical application, many objects (or in Haskell, data) have a time associated with them. In Python I would have an accessor function called time in every class. This is what Type Classes in Haskell are for. See: http://www.haskell.org/tutorial/classes.html I feel like this should be qualified. Type classes are not for name punning ; you wouldn't use a type class for the method bark on types Tree and Dog. But if you have a well-defined *structure* that many types follow, then a type class is how you capture that. It sounds like you do have this structure in your example. Further, with typeclasses, you can write methods that are generic over any type with that structure. So: class Temporal a where time :: a - Time temporalOrder :: Temporal a = [a] - [a] temporalOrder = sortBy (comparing time) The ability to do this indicates why using them for punning is a bad idea. Luke ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: implementing recursive let
Derek Elkins wrote: The following code works fine for me, so it seems you are missing some details that may help. [...snip code...] Thank you! Indeed I did simplify the code when writing the message -- because I thought that those other bits could not possibly be at fault... ;-) *trying out many changes to my own code and yours* Ok, I finally found it. What actually made the difference was the case for variables: Your version is eval (Var x) = gets (fromJust . M.lookup x) which is suitably lazy, whereas mine was (more or less) eval e@(Var name) = do env - ask case M.lookup name env of Nothing - do -- undefined variable reference warning (reference to undefined variable ++ show name) let val = Data modify (M.insert name val) return val Just val - return val Note that whatever I do in the 'Nothing' case is irrelevant, your code with the Var case replaced by eval e@(Var name) = do env - ask case M.lookup name env of Just val - return val loops as well. My problem is that I still don't understand why this is so! I know of course that pattern matching is strict, but I thought this should be ok here, since I evaluate the declarations _before_ the body, so when evaluation of the body demands the variable, it will be defined. What am I missing? Cheers Ben ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: haskell-mode.el mailing list (+ dpatch)
Svein Ove Aas svein@aas.no writes: I certainly don't mind. I've noticed that the list administrative interface has a news-gateway option. Is there anything I should do there? I've submitted the request. I don't think the news-gateway option is needed in this case, but i'll ask when i hear back from gmane. Thanks! jao -- I don't necessarily agree with everything I say. -Marshall McLuhan (1911-1980) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: ANNOUNCE: feldspar-language
Emil Axelsson wrote: Henning Thielemann skrev: On Fri, 6 Nov 2009, Emil Axelsson wrote: Henning Thielemann skrev: I'm trying to get realtime signal processing with Haskell for long. I make progress, but slowly. Has Ericsson ever thought about using Haskell itself for signal processing? (But I think they already have Erlang?) No, using Haskell directly is not an option (at least with current compiler technology). Their performance requirements are very high, and the signal processors have quite limited memory, so putting a Haskell RTS on them wouldn't work. Yes, Erlang is used in some applications, but that's more for control programs, not for numerical computations. I hope you will succeed in making real-time signal processing in Haskell work! I'm currently testing JHC to that end. It produces relatively small C programs without a precompiled run-time system. Cool! I'd be very interested to see how that works out. Me too! Cheers Ben ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: I miss OO
Python: note1.time() cursor1.time() staff1.time() (...) So I'm thinking of moving to a scheme in Haskell using modules, most types being defined in their own modules, and doing qualified imports. Generic names like 'time' can be defined in each module w/o clashing. (...) I would be interested in comments... is this a good way to do things? Am I trying too hard to impose OO on Haskell and is there a better way? I had this same experience. After you learn how to think in Haskell, the problem will just disapear. Maybe it would help you more if, instead of just this small detail, you write the general idea of what you want your application to do. Then we could sugest you a Haskell-like design where you would not need note1.time, cursor.time etc. In time you'll probably want to study this: http://hackage.haskell.org/package/haskore Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] I miss OO
Luke Palmer lrpal...@gmail.com wrote I feel like this should be qualified. Type classes are not for name punning ; you wouldn't use a type class for the method bark on types Tree and Dog. But if you have a well-defined *structure* that many types follow, then a type class is how you capture that. It sounds like you do have this structure in your example. Is there any way that type classes can manage name spaces to disambiguate functions like bark on types Tree and Dog? If constants are considered as unary functions, can we use constants in type classes and/or instances? How are local class specific constants, such as tank in Army/tank in Fish, bank in River/bank in Finance, handled? Pat ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] I miss OO
You can define the methods with the same names in different modules, then when you are importing them into the same module for use, use a qualified import. import qualified Dog import qualified Tree This will allow you to use exactly the syntax you described. Dog.bark Tree.bark Plus if you only have to import one of these, it is an opportunity to be implicit which about the module being used. On Thu, Nov 26, 2009 at 6:34 AM, pbrowne patrick.bro...@comp.dit.ie wrote: Luke Palmer lrpal...@gmail.com wrote I feel like this should be qualified. Type classes are not for name punning ; you wouldn't use a type class for the method bark on types Tree and Dog. But if you have a well-defined *structure* that many types follow, then a type class is how you capture that. It sounds like you do have this structure in your example. Is there any way that type classes can manage name spaces to disambiguate functions like bark on types Tree and Dog? If constants are considered as unary functions, can we use constants in type classes and/or instances? How are local class specific constants, such as tank in Army/tank in Fish, bank in River/bank in Finance, handled? Pat ___ 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] I miss OO
2009/11/25 Michael Mossey m...@alumni.caltech.edu: I'm fairly new to Haskell, and starting to write some big projects. Previously I used OO exclusively, mostly Python. I really miss the namespace capabilities... a class can have a lot of generic method names which may be identical for several different classes because there is no ambiguity. In my musical application, many objects (or in Haskell, data) have a time associated with them. In Python I would have an accessor function called time in every class. This is really an opportunity to consider an important difference between the OO and typed, functional approach to things. In OO, we create classes that have time as a property or method; in the typed, functional approach we say there are a family of types that all allow a certain function to be called on them, `time :: t - Time`. This is what type classes are all about; they allow us to say here is a function and some types it works with. After all, you don't just want a `time` property -- you also want it to give you a `Time`. When one is accustomed to treating properties as part of an object, it's natural to go the record syntax route; but this doesn't capture the notion that all these records conform to a certain type equation. In this way, Haskell is more demanding of you; but it also offers you a way to make the semantics of your data explicit. -- Jason Dusek ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re. I miss OO
My experience with objects comes from Common List, Clean, Hasekell and Nice. In all these languages, the function behavior is determined by many objects. I think that this is more powerful and clear than the Java way. In Nice one can see the superiority of type-driven behavior over the Java dot notation, since the dot notation is a particular case of the type driven behavior. To make a long story short, one can apply the dot notation to the first argument, or put it together with the other arguments. For instance, consider the followin init() function (entirely in dot notation): c l a s s DrawLines ext ends Applet { Button ext = new Button ( ”Exi t ” ) ; Button dbutton= new Button ( ”Exec” ) ; TextFi e ld t f= new TextFi e ld ( 1 5 ) ; i n t xx= 5 ; i n i t ( ) { this.setBackground ( Color . l ightGray ) ; t h i s . add ( dbutton ) ; t h i s . add ( t f ) ; t h i s . add ( ext ) ; t h i s . setLayout ( n u l l ) ; ext . r e shape (50 , 30 , 50 , 2 0 ) ; dbutton . r e shape ( 50 , 80 , 80 , 3 0 ) ; t f . r e shape (140 , 80 , 200 , 3 0 ) ; } ... etc. } However, in Nice the method is selected not only by the dotted object, but by all arguments. This becomes clear by placing the dotted object inside the argument list: c l a s s DrawLines ext ends Applet { Button ext = new Button ( ”Exi t ” ) ; Button dbutton= new Button ( ”Exec” ) ; TextFi e ld t f= new TextFi e ld ( 1 5 ) ; i n t xx= 5 ; i n i t ( ) { setBackground (this, Color . l ightGray ) ; add (this, dbutton ) ; t h i s . add ( t f ) ; add (this, ext ) ; setLayout (this, n u l l ) ; reshape (ext, 50 , 30 , 50 , 2 0 ) ; reshape (dbutton, 50 , 80 , 80 , 3 0 ) ; reshape (tf, 140 , 80 , 200 , 3 0 ) ; } ... etc. } In order to see how useful and practical is the generalization of dot selection, let us suppose that one needs to write Lisp-like lists in Nice. I am using Nice because it has both the simpler, more restricted dot notation as Java and Python, and the argument selection, more general and powerful, as Haskell and Lisp. Here is the Nice definition of polymorphic lists: import java . i o . * ; class LstT { T head ; ?LstT t a i l ; } ?Lstint cons ( i n t x , ?Lstint xs ) { ?Lstint newList= new Lst ( head : x , tail : xs ) ; return ( newList ) ; } ?LstString cons ( String x , ?LstString xs ) { ?LstString newList= newLst ( head : x , tail : xs ) ; return ( newList ) ; } String car (? LstString xs ) { if ( xs==null ) return ( ) ; else return ( xs.head ) ; } int car (? Lstint xs ) { if ( xs==null ) return ( 0 ) ; else return ( xs.head ) ; } boolean isEmpty (? LstString xs )= xs==null ; ?LstString cdr (? LstString xs ) { if ( xs== null ) return ( xs ) ; else return ( xs.tail ) ; } ?LstString cdr (? LstString xs ) { if ( xs== null ) return ( xs ) ; else return ( xs.tail ) ; } ?Lstint cdr (? Lstint xs ) { if ( xs== null ) return ( xs ) ; else return ( xs.tail ) ; } void main ( String [ ] args ) { InputStreamReader converter = new InputStreamReader ( System.in ) ; Buf feredReader in = new BufferedReader ( converter ) ; ?String s= Type a sentence and press Enter ; println ( s ) ; s= in.readLine ( ) ; ?LstString words=null ; StringTokenizerst = new StringTokenizer ( s ) ; while ( st.hasMoreTokens ( ) ) { words= cons ( st.nextToken ( ), words ) ; } var xs= words ; while ( ! isEmpty ( xs ) ) { println ( car ( xs ) ) ; xs= cdr ( xs ) ; } } If you want to see how the above program can be generalized into a full fledged Lisp like stucture, take a look at my page on Nice: www.discenda.org. In any case, since Haskell has the more general method selection, there is no need to have the more restricted dot selector. Nice has both method selectors, but I seldom use the dot selector. --- On Wed, 11/25/09, Michael Mossey m...@alumni.caltech.edu wrote: From: Michael Mossey m...@alumni.caltech.edu Subject: [Haskell-cafe] I miss OO To: haskell-cafe@haskell.org Received: Wednesday, November 25, 2009, 1:51 PM I'm fairly new to Haskell, and starting to write some big projects. Previously I used OO exclusively, mostly Python. I really miss the namespace capabilities... a class can have a lot of generic method names which may be identical for several different classes because there is no ambiguity. In my musical application, many objects (or in Haskell, data) have a time associated with them. In Python I would have an accessor function called time in every class. So if I have objects/data note1, cursor1, and staff1, Python: note1.time() cursor1.time() staff1.time() Haskell needs something like note_time note1 cursor_time cursor1 staff_time staff1 which is a lot more visually disorganized. What's worse, I have a moderate case of RSI (repetitive strain injury) so I type slowly and depend on abbreviations a lot. I use the souped-up
[Haskell-cafe] Re: haskell-mode.el mailing list (+ dpatch)
On Wed, 25 Nov 2009 21:15:59 +0100, Svein Ove Aas svein@aas.no wrote: On Wed, Nov 25, 2009 at 11:37 AM, Jose A. Ortega Ruiz j...@gnu.org wrote: Svein Ove Aas svein@aas.no writes: Well, I know when I'm beat.. http://trac.haskell.org/haskellmode-emacs/ http://projects.haskell.org/cgi-bin/mailman/listinfo/haskellmode-emacs Excellent! Thanks. Any objection to my adding the list to gmane.org? I certainly don't mind. I've noticed that the list administrative interface has a news-gateway option. Is there anything I should do there? You don't need to worry about that one. When I set up the gateway to Gmane.org for the Haskell-Beginners mailing list, there had been no need to bother with that option. -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 Furuike ya, kawazu tobikomu mizu no oto. -- Matsuo Basho^ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] I miss OO
Hello, Coming also from an OO background, I had this same feeling as yours when I started learning haskell. It might help to think that type classes are like interfaces: They allow expressing a family of behaviors as a bunch of related functions. The fact that it allows using same name to act on/with different things is an interesting side-effect. -- Arnaud Bailly -- OQube software engineering http://www.oqube.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] I miss OO
Hi, Are you sure you need to store the time *inside* your objects instead of using, say, pairs (Time, YourObject) (and lists of them instead of lists of your objects)? It would seem strange to me that a note HAS-A time even in an OO design: more likely, a note is associated with a time, and this is modeled by pairing them. 2009/11/25 Michael Mossey m...@alumni.caltech.edu: I'm fairly new to Haskell, and starting to write some big projects. Previously I used OO exclusively, mostly Python. I really miss the namespace capabilities... a class can have a lot of generic method names which may be identical for several different classes because there is no ambiguity. In my musical application, many objects (or in Haskell, data) have a time associated with them. In Python I would have an accessor function called time in every class. So if I have objects/data note1, cursor1, and staff1, Python: note1.time() cursor1.time() staff1.time() Haskell needs something like note_time note1 cursor_time cursor1 staff_time staff1 which is a lot more visually disorganized. What's worse, I have a moderate case of RSI (repetitive strain injury) so I type slowly and depend on abbreviations a lot. I use the souped-up abbreviation capabilities of Emacs. Let's say I have a field/member-variable called orientedPcSet that is used across many classes. In Python, I can create an abbreviation for that and it is useful many times. In Haskell, I might need someType_orientedPcSet someOtherType_orientedPcSet thirdType_orientedPcSet which prevents me from using abbreviations effectively (especially the dynamic-completion feature). (It would help to make the underscore not part of word syntax, but that's not ideal.) So I'm thinking of moving to a scheme in Haskell using modules, most types being defined in their own modules, and doing qualified imports. Generic names like 'time' can be defined in each module w/o clashing. Then I have Note.time note1 Cursor.time cursor1 Staff.time staff1 This is very useful because I can define abbreviations for the type name and for oft-used accessor function names and these abbrevs are more organized, easier to remember, and easier to combine. I would be interested in comments... is this a good way to do things? Am I trying too hard to impose OO on Haskell and is there a better way? Thanks, Mike ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Eugene Kirpichov Web IR developer, market.yandex.ru ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] I miss OO
On Thu, Nov 26, 2009 at 12:03 AM, Eugene Kirpichov ekirpic...@gmail.com wrote: Hi, Are you sure you need to store the time *inside* your objects instead of using, say, pairs (Time, YourObject) (and lists of them instead of lists of your objects)? It would seem strange to me that a note HAS-A time even in an OO design: more likely, a note is associated with a time, and this is modeled by pairing them. +1 This hadn't occurred to me, but in retrospect is quite obvious. In FRP notation, these are Futures, eg. Future Note. Luke 2009/11/25 Michael Mossey m...@alumni.caltech.edu: I'm fairly new to Haskell, and starting to write some big projects. Previously I used OO exclusively, mostly Python. I really miss the namespace capabilities... a class can have a lot of generic method names which may be identical for several different classes because there is no ambiguity. In my musical application, many objects (or in Haskell, data) have a time associated with them. In Python I would have an accessor function called time in every class. So if I have objects/data note1, cursor1, and staff1, Python: note1.time() cursor1.time() staff1.time() Haskell needs something like note_time note1 cursor_time cursor1 staff_time staff1 which is a lot more visually disorganized. What's worse, I have a moderate case of RSI (repetitive strain injury) so I type slowly and depend on abbreviations a lot. I use the souped-up abbreviation capabilities of Emacs. Let's say I have a field/member-variable called orientedPcSet that is used across many classes. In Python, I can create an abbreviation for that and it is useful many times. In Haskell, I might need someType_orientedPcSet someOtherType_orientedPcSet thirdType_orientedPcSet which prevents me from using abbreviations effectively (especially the dynamic-completion feature). (It would help to make the underscore not part of word syntax, but that's not ideal.) So I'm thinking of moving to a scheme in Haskell using modules, most types being defined in their own modules, and doing qualified imports. Generic names like 'time' can be defined in each module w/o clashing. Then I have Note.time note1 Cursor.time cursor1 Staff.time staff1 This is very useful because I can define abbreviations for the type name and for oft-used accessor function names and these abbrevs are more organized, easier to remember, and easier to combine. I would be interested in comments... is this a good way to do things? Am I trying too hard to impose OO on Haskell and is there a better way? Thanks, Mike ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Eugene Kirpichov Web IR developer, market.yandex.ru ___ 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] I miss OO
First of all, thanks for the ideas, everyone. I think I'm starting to get the usefulness of type classes. With regard to your question, Eugene, you are probably right. In fact my rough draft of this code from four months ago used a Map with time as the key (of type Rational). I was trying to come up with a quick example and didn't think straight. You may observe, however, that the concept note has a lot of uses and contexts. Sometimes it means simply a pitch, like middle C. Sometimes it means a black dot on a piece of staff paper, in which case it has a duration (as a number of beats). The context of that black dot gives it a dynamic level, an associated instrument (timbre), and of course, a time. In this larger context, I'm not sure if there is a deep difference between storing time inside the object or outside it, except for the practical matter of wanting to index notes by time (in which case it is useful to use time outside the object as the key). You tell me: do you think it makes a deep difference? Thanks, Mike Eugene Kirpichov wrote: Hi, Are you sure you need to store the time *inside* your objects instead of using, say, pairs (Time, YourObject) (and lists of them instead of lists of your objects)? It would seem strange to me that a note HAS-A time even in an OO design: more likely, a note is associated with a time, and this is modeled by pairing them. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] I miss OO
2009/11/26 Michael Mossey m...@alumni.caltech.edu: First of all, thanks for the ideas, everyone. I think I'm starting to get the usefulness of type classes. With regard to your question, Eugene, you are probably right. In fact my rough draft of this code from four months ago used a Map with time as the key (of type Rational). I was trying to come up with a quick example and didn't think straight. You may observe, however, that the concept note has a lot of uses and contexts. Sometimes it means simply a pitch, like middle C. Sometimes it means a black dot on a piece of staff paper, in which case it has a duration (as a number of beats). The context of that black dot gives it a dynamic level, an associated instrument (timbre), and of course, a time. In this larger context, I'm not sure if there is a deep difference between storing time inside the object or outside it, except for the practical matter of wanting to index notes by time (in which case it is useful to use time outside the object as the key). You tell me: do you think it makes a deep difference? I argue that in the situation you provided, the pitch, duration, timbre and instrument are essential attributes of the dot, whereas time is the position of the dot on paper and should be separated from its essence. I think two concepts should be separated if one makes sense and is useful without the other. A note out of its time context is certainly useful, for example, it may probably be converted to a MIDI command or to a graphical glyph (which is further to be positioned by a layout engine). Thanks, Mike Eugene Kirpichov wrote: Hi, Are you sure you need to store the time *inside* your objects instead of using, say, pairs (Time, YourObject) (and lists of them instead of lists of your objects)? It would seem strange to me that a note HAS-A time even in an OO design: more likely, a note is associated with a time, and this is modeled by pairing them. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Eugene Kirpichov Web IR developer, market.yandex.ru ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] FastCGI under Windows
Just to add more detail: I am running Apache 2.2.9. The message I mentioned appeared in the Apache error log file when running the sample Haskell FastCGI scripts under localhost with mod_fastcgi. I understand that there are some problems with mod_fastcgi and Apache 2.2.9, so I downloaded the Apache 2.2.9 version of mod_fcgid from here: http://www.apachelounge.com/download/ and tried that instead. I no longer get the error message I mentioned before, but instead get: [Thu Nov 26 08:44:30 2009] [warn] mod_fcgid: read timeout from pipe [Thu Nov 26 08:44:30 2009] [error] [client 127.0.0.1] Premature end of script headers: test2.fcgi Any suggestions? Kevin --- On Wed, 11/25/09, Kevin Jardine kevinjard...@yahoo.com wrote: From: Kevin Jardine kevinjard...@yahoo.com Subject: [Haskell-cafe] FastCGI under Windows To: haskell-cafe@haskell.org Date: Wednesday, November 25, 2009, 10:44 PM I'm attempting to get FastCGI working with Haskell under Windows XP. However, all the sample code I've tried always fails with: user error (FCGX_Accept_r failed with error code: -) unknown listenType (0) Has anyone seen this before? Any ideas on what I could try to get this to work? Kevin ___ 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