From apfelmus at quantentunnel.de Sun Nov 1 07:12:10 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Sun Nov 1 06:48:51 2009 Subject: [Haskell-cafe] Re: Experiments with defunctionalization, church-encoding and CPS In-Reply-To: <5e0214850910130244rf0164d4k6144e8d6f07d022e@mail.gmail.com> References: <5e0214850910130244rf0164d4k6144e8d6f07d022e@mail.gmail.com> Message-ID: Eugene Kirpichov wrote: > I took a toy problem - find the first node satisfying a predicate in a > binary tree, started with a naive Maybe-based implementation - and > experimented with 3 ways of changing the program: > - Church-encode the Maybe > - Convert the program into CPS > - Defunctionalize the Church-encoded or CPS-transformed program > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=10686 > > The link points to code, a benchmark and conclusion. > > Conclusion: > - Haskell implements Maybe well enough that it is not possible to do better > - Defunctionalization and consequent optimization yields same > performance as the one with Maybe > - Non-simplified CPS and Church-encoded representations do bad I'm not sure your example program is enough to justify the conclusions. The main advantage of the Church-encoding of Maybe type Maybe' a = forall b . b -> (a -> b) -> b is that the latter has the pattern match for failure / success built-in when used as a monad m >>= g = \nothing just -> m nothing (\x -> g x nothing just) VS m >>= g = case m of Nothing -> Nothing Just x -> g x The algebraic data type has to check that the result was indeed Just x whereas the Church-encoding can jump right to the success continuation. The problem is that your tree doesn't really make use of this advantage. For that, you need a completely left-biased tree, like for example Fork 1 (Fork 2 (Fork 3 ... Leaf) Leaf) Leaf testTree = fromList [1..100000] fromList = foldr (\x t -> Fork x t Leaf) Leaf I've implemented this and posted it below your version at http://hpaste.org/fastcgi/hpaste.fcgi/view?id=10686 I've used the criterion benchmarking package, so you can run this straight out of the box. Even then, the results are mixed. The Church-encoding shines in GHCi as it should, but loses its advantage when the code is being compiled. I guess we have to look at the core if we want to know what exactly is going on. PS: I'm not entirely sure I'm using criterion correctly, in particular concerning strictness. For instance, dropping the fromJust will reduce the run-time of the "data Maybe" benchmark by 75%. Comments? Regards, apfelmus -- http://apfelmus.nfshost.com From mxcantor at gmail.com Sun Nov 1 07:12:33 2009 From: mxcantor at gmail.com (Max Cantor) Date: Sun Nov 1 06:48:57 2009 Subject: [Haskell-cafe] ATTN: Singapore based Haskellers - Singapore FP Users Group First Meeting Message-ID: <8E7F8570-119C-4CA8-9F1C-50AA32CECEA5@gmail.com> We are organizing a Functional Programming Users Group in Singapore and our first meeting is Monday, November 2nd at 6 pm. We will meet initially in the Lobby of 8 Shenton Way. Map: http://bit.ly/1PzqlB -or- http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=8+Shenton+Way,+Singapore+068811&sll=37.0625,-95.677068&sspn=37.325633,79.101563&ie=UTF8&hq=&hnear=8+Shenton+Way,+Singapore+068811&ll=1.276047,103.847408&spn=0.01152,0.019312&z=16&iwloc=A If you have any trouble, please feel free to call me at +65-9329-6139 Max From tittoassini at gmail.com Sun Nov 1 07:45:31 2009 From: tittoassini at gmail.com (Pasqualino "Titto" Assini) Date: Sun Nov 1 07:21:49 2009 Subject: [Haskell-cafe] ANNOUNCE: dbus-core 0.5 and dbus-client 0.1 In-Reply-To: <3283f7fe0910301444o7fe94785yec5e5b55b2d30066@mail.gmail.com> References: <3283f7fe0910301444o7fe94785yec5e5b55b2d30066@mail.gmail.com> Message-ID: <2d34474e0911010445y5155d9fau57b9933e953c2f4e@mail.gmail.com> I think that we should institute an award for "best documented haskell package" and yours would be my first choice. Congratulations, titto 2009/10/30 John Millikin : > These are pure-Haskell client libraries for using the D-Bus protocol. > D-Bus is heavily used for inter-application IPC on Free and > open-source desktop platforms, such as Linux, OpenSolaris, and > FreeBSD. These libraries allow applications written in Haskell to > inter-operate with other components of recent GNOME, KDE, and XFCE > desktops. > > This is the first "real" release of these libraries; dbus-core has > been published on Hackage for some time, but mostly just to make sure > I got the Cabal bits right. I feel they are now stable / featureful > enough for public use. > > Both are available on Hackage: > > http://hackage.haskell.org/package/dbus-core > http://hackage.haskell.org/package/dbus-client > > --------- > > "dbus-core" is an implementation of the D-Bus protocol, specifically > the parts relevant to clients. Eventually, it will probably grow some > functions useful for implementing a message bus as well. It includes > type mapping / conversion, an implementation of the wire format > (marshaling / unmarshaling), data types for the currently defined > message types (METHOD_CALL, METHOD_RETURN, ERROR, and SIGNAL) and a > basic parser / generator for introspection documents. It is roughly > equivalent in purpose to libdbus. > > By itself, a protocol implementation is somewhat cumbersome to use, so > "dbus-client" is a high-level wrapper. It provides some abstractions > like remote object proxies, exported object trees, synchronous method > calls, signal reception, and name reservation. Messages are received > and processed in separate IO threads, allowing asynchronous method > call and signal handling. > > The purpose between splitting the library into two packages is > stability; "dbus-core", ideally, will change only rarely -- > performance improvements, new message / data types, etc. It provides a > base level of functionality which more specialised libraries may use. > "dbus-client" is an example of what such a library could look like, > though for now it's not very Haskell-y (IO everywhere, exceptions, > explicit locking). By separating the protocol from the client libs, > alternative client libs can safely depend on the protocol > implementation. > > --------- > > To see a sample of the library working, there's a clone of the > "dbus-monitor" utility in . Documentation is > currently a bit lacking, so for now, the best documentation is the PDF > of the source code itself, and the (rather barren) Haddock output: > > https://dl.getdropbox.com/u/1947532/dbus-core_0.5.pdf > https://dl.getdropbox.com/u/1947532/dbus-core_0.5/index.html > > https://dl.getdropbox.com/u/1947532/dbus-client_0.1.pdf > https://dl.getdropbox.com/u/1947532/dbus-client_0.1/index.html > > Once more people have used it without any major API issues, I'll write > up a manual and populate the Haddock entries. > > Please respond with any feedback, difficulties, or suggestions. I'm > particularly interested in ways to improve the public API, since I > would rather make any breaking changes *before* anything big depends > on these libraries. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Pasqualino "Titto" Assini, Ph.D. http://quicquid.org/ From tphyahoo at gmail.com Sun Nov 1 08:58:00 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sun Nov 1 08:34:17 2009 Subject: [Haskell-cafe] hackage is down. Message-ID: <910ddf450911010558q48e21c72sfcb12ed8105c8d86@mail.gmail.com> http://hackage.haskell.org From gue.schmidt at web.de Sun Nov 1 09:31:22 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Sun Nov 1 09:08:06 2009 Subject: [Haskell-cafe] Monad Comprehensions Message-ID: Hi all, once again I find myself merely scratching the surface of the power of Haskell, which is exciting and frustrating at the same time. While real world demands require me to find / develop solutions quickly (abstractions for querying data sets) I keep catching glimpses of all this power. But for someone like me it's difficult to assess from these glimpses alone which to study first. In the last few weeks I kept bugging people here on this list about DSLs, so I could create my own to express queries / relational algebra. I'd later choose then to compile this to SQL or to in-memory code. Next thing I notice that I've overlooked list comprehension all this time, which already express quite a lot of what I'd need. And then, on top of it all, monad comprehension, or rather monads period. The thing that particularly set me off was a video from Dan Piponi: http://vimeo.com/6590617 It certainly made me realize how little I have understood how much power merely monads give you. In short, I'm truly lost. If anyone else, with roughly the same starting point as me, has found their way through this jungle I'd certainly appreciate some tips. In particular I wonder if someone has been able to follow what Dan demonstrates in this video, or was it a jaw-dropping experience for everyone else just as me? G?nther From jochem at functor.nl Sun Nov 1 09:59:16 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Sun Nov 1 09:35:34 2009 Subject: [Haskell-cafe] hackage is down. In-Reply-To: <910ddf450911010558q48e21c72sfcb12ed8105c8d86@mail.gmail.com> References: <910ddf450911010558q48e21c72sfcb12ed8105c8d86@mail.gmail.com> Message-ID: <20091101145916.GA7500@functor.nl> On Sun, Nov 01, 2009 at 07:58:00AM -0600, Thomas Hartman wrote: > http://hackage.haskell.org Hackage is down currently, I am seeding the torrent by mauke from IRC on http://mauke.ath.cx/tmp/2009-10-19-hackage-archive.torrent Cheers, Jochem -- Jochem Berndsen | jochem@functor.nl | jochem@????.com From tomahawkins at gmail.com Sun Nov 1 10:55:19 2009 From: tomahawkins at gmail.com (Tom Hawkins) Date: Sun Nov 1 10:31:37 2009 Subject: [Haskell-cafe] ANN: mecha-0.0.2 Message-ID: <594c1e830911010755u6605089gbf1a1b3f79033dec@mail.gmail.com> > Neat! ?What a cool idea. > >> data Solid = Solid (Vector -> Bool) > > With a type like this, how is it possible to make solids without hard edges? Now the only way is to create a new primitive. In the future I want to have blended versions of the set operations to apply fillets or bevels at the joints. But I'm not sure how to do this yet. > Why did you choose a monadic interface? ?Is there a technical or > semantic problem with a statement like: I was originally thinking a monad would be needed to prevent re-meshing difference instances of the same solid, as well has to generate a bill-of-materials, 2D prints, etc. But you're right, I don't think it's needed. Thanks. See mecha-0.0.2: example :: IO () example = view design design :: Asm design = assemble [ color (0, 0, 0.8) $ place 1 0.06 8 $ difference sphereCube cyl3 , move (-4, 0, 0) $ color (0.8, 0, 0) $ place 1 0.08 8 $ sphereCube , move ( 0, 4, 0) $ color (0, 0.8, 0) $ place 1.5 0.08 8 $ cyl3 ] sphereCube = intersection sphere $ scaleXYZ 0.75 cube cyl = scale (0.5, 0.5, 1.2) $ cylinder cyl3 = unions [cyl, rotateX (pi / 2) cyl, rotateY (pi / 2) cyl] From sergueyz at gmail.com Sun Nov 1 11:03:06 2009 From: sergueyz at gmail.com (Serguey Zefirov) Date: Sun Nov 1 10:39:29 2009 Subject: [Haskell-cafe] ANN: mecha-0.0.2 In-Reply-To: <594c1e830911010755u6605089gbf1a1b3f79033dec@mail.gmail.com> References: <594c1e830911010755u6605089gbf1a1b3f79033dec@mail.gmail.com> Message-ID: <600376290911010803r7280cc57tc49a12fed8065ab0@mail.gmail.com> http://iat.ubalt.edu/summers/math/platsol.htm and http://hyperfun.org/wiki/doku.php?id=frep:main CSG on implicitly specified surfaces (F(r)=0) and volumes (F(r)>=0). Min(F,G) is a union, max(F,G) is an intersection. 2009/11/1 Tom Hawkins : >> Neat! ?What a cool idea. >>> data Solid = Solid (Vector -> Bool) >> With a type like this, how is it possible to make solids without hard edges? > Now the only way is to create a new primitive. ?In the future I want > to have blended versions of the set operations to apply fillets or > bevels at the joints. ?But I'm not sure how to do this yet. From nick.straw at gmail.com Sun Nov 1 11:09:14 2009 From: nick.straw at gmail.com (b1g3ar5) Date: Sun Nov 1 10:45:31 2009 Subject: [Haskell-cafe] Re: Newcomers question In-Reply-To: References: <250d869d-3677-4000-96ce-d4f9a014ef5e@b2g2000yqi.googlegroups.com> Message-ID: <113b1e77-09bb-48d5-b542-f97f5d43dc03@z41g2000yqz.googlegroups.com> OK, I understand that now but I've got a supplimentary question. If I put: instance Eq b => Eq (a -> b) where (==) = liftA2 (Prelude.==) to do the Eq part I get another error: Couldn't match expected type `Bool' against inferred type `a -> Bool' In the expression: liftA2 (==) In the definition of `==': == = liftA2 (==) In the instance declaration for `Eq (a -> b)' Now can someone please explain this? I'm hoping that when I've understood this stuff I'll have made a small step to understanding Haskell. Thanks. On 31 Oct, 23:38, Daniel Peebles wrote: > For some reason, Show and Eq are superclasses of Num (despite Num not > actually using any of their methods), meaning that the compiler forces > you to write instances of Eq and Show before it even lets you write a > Num instance. I don't think anybody likes this, but I think we're > stuck with it for the foreseeable future. > > > > On Sat, Oct 31, 2009 at 7:31 PM, b1g3ar5 wrote: > > I'm trying: > > > instance Num b => Num (a -> b) where > > fromInteger = pure . Prelude.fromInteger > > negate = fmap Prelude.negate > > (+) = liftA2 (Prelude.+) > > (*) = liftA2 (Prelude.*) > > abs = fmap Prelude.abs > > signum = fmap Prelude.signum > > > but the compiler rejects it with: > > > src\Main.hs:24:9: > > ? ?Could not deduce (Show (a -> b), Eq (a -> b)) > > ? ? ?from the context (Num b) > > ? ? ?arising from the superclasses of an instance declaration > > ? ? ? ? ? ? ? ? ? at src\Main.hs:24:9-29 > > ? ?Possible fix: > > ? ? ?add (Show (a -> b), Eq (a -> b)) to the context of > > ? ? ? ?the instance declaration > > ? ? ?or add an instance declaration for (Show (a -> b), Eq (a -> b)) > > ? ?In the instance declaration for `Num (a -> b)' > > > Could someone please explain this to me? > > > I thought that it might be that it couldn't work out the functions > > necessary for (a->b) to be in the classes Show and Eq - so I tried > > adding definitions for == ans show, but it made no difference. > > > Thanks > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-C...@haskell.org > >http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-C...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe From conor at strictlypositive.org Sun Nov 1 11:20:18 2009 From: conor at strictlypositive.org (Conor McBride) Date: Sun Nov 1 10:56:38 2009 Subject: [Haskell-cafe] Applicative but not Monad In-Reply-To: References: Message-ID: Hi On 31 Oct 2009, at 10:39, Conor McBride wrote: > Hi > > On 30 Oct 2009, at 16:14, Yusaku Hashimoto wrote: > >> Hello cafe, >> Do you know any data-type which is Applicative but not Monad? > > [can resist anything but temptation] > > I have an example, perhaps not a datatype: > tomorrow-you-will-know Elaborating, one day later, if you know something today, you can arrange to know it tomorrow if will know a function tomorrow and its argument tomorrow, you can apply them tomorrow but if you will know tomorrow that you will know something the day after, that does not tell you how to know the thing tomorrow Put otherwise, unit-delay is applicative but not monadic. I've been using this to organise exactly what happens when in those wacky miraculous-looking circular programs. It seems quite promising, so far... Cheers Conor From alexander.dunlap at gmail.com Sun Nov 1 11:49:57 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Sun Nov 1 11:26:33 2009 Subject: [Haskell-cafe] Re: Newcomers question In-Reply-To: <113b1e77-09bb-48d5-b542-f97f5d43dc03@z41g2000yqz.googlegroups.com> References: <250d869d-3677-4000-96ce-d4f9a014ef5e@b2g2000yqi.googlegroups.com> <113b1e77-09bb-48d5-b542-f97f5d43dc03@z41g2000yqz.googlegroups.com> Message-ID: <57526e770911010849o4268415r3f71f0ecf6821a0f@mail.gmail.com> The type of liftA2 :: Applicative f =>(a -> b -> c) -> f a -> f b -> f c. Thus, the type of liftA2 (==) :: (Eq b, Applicative f) => f b -> f b -> f Bool. In your case, f :: a -> b, so liftA2 (==) :: (Eq b) => (a -> b) -> (a -> b) -> (a -> Bool). (==) takes two arguments, so you're left with the type (liftA2 (==)) x y :: a -> Bool. This contradicts the class definition of Eq, which says that the type of (==) after giving it two arguments must be Bool, not a -> Bool. I hope that's clear enough. Busting out GHCi and using :t to find the types of a lot of these expressions can be really helpful. Alex On Sun, Nov 1, 2009 at 8:09 AM, b1g3ar5 wrote: > OK, I understand that now but I've got a supplimentary question. > > If I put: > > instance Eq b => Eq (a -> b) where > ? ?(==) = liftA2 (Prelude.==) > > to do the Eq part I get another error: > > ? ?Couldn't match expected type `Bool' > ? ? ? ? ? against inferred type `a -> Bool' > ? ?In the expression: liftA2 (==) > ? ?In the definition of `==': == = liftA2 (==) > ? ?In the instance declaration for `Eq (a -> b)' > > Now can someone please explain this? > > I'm hoping that when I've understood this stuff I'll have made a small > step to understanding Haskell. > > Thanks. > > > On 31 Oct, 23:38, Daniel Peebles wrote: >> For some reason, Show and Eq are superclasses of Num (despite Num not >> actually using any of their methods), meaning that the compiler forces >> you to write instances of Eq and Show before it even lets you write a >> Num instance. I don't think anybody likes this, but I think we're >> stuck with it for the foreseeable future. >> >> >> >> On Sat, Oct 31, 2009 at 7:31 PM, b1g3ar5 wrote: >> > I'm trying: >> >> > instance Num b => Num (a -> b) where >> > fromInteger = pure . Prelude.fromInteger >> > negate = fmap Prelude.negate >> > (+) = liftA2 (Prelude.+) >> > (*) = liftA2 (Prelude.*) >> > abs = fmap Prelude.abs >> > signum = fmap Prelude.signum >> >> > but the compiler rejects it with: >> >> > src\Main.hs:24:9: >> > ? ?Could not deduce (Show (a -> b), Eq (a -> b)) >> > ? ? ?from the context (Num b) >> > ? ? ?arising from the superclasses of an instance declaration >> > ? ? ? ? ? ? ? ? ? at src\Main.hs:24:9-29 >> > ? ?Possible fix: >> > ? ? ?add (Show (a -> b), Eq (a -> b)) to the context of >> > ? ? ? ?the instance declaration >> > ? ? ?or add an instance declaration for (Show (a -> b), Eq (a -> b)) >> > ? ?In the instance declaration for `Num (a -> b)' >> >> > Could someone please explain this to me? >> >> > I thought that it might be that it couldn't work out the functions >> > necessary for (a->b) to be in the classes Show and Eq - so I tried >> > adding definitions for == ans show, but it made no difference. >> >> > Thanks >> >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > Haskell-C...@haskell.org >> >http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-C...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dave at zednenem.com Sun Nov 1 12:06:05 2009 From: dave at zednenem.com (David Menendez) Date: Sun Nov 1 11:42:23 2009 Subject: [Haskell-cafe] Re: Newcomers question In-Reply-To: <113b1e77-09bb-48d5-b542-f97f5d43dc03@z41g2000yqz.googlegroups.com> References: <250d869d-3677-4000-96ce-d4f9a014ef5e@b2g2000yqi.googlegroups.com> <113b1e77-09bb-48d5-b542-f97f5d43dc03@z41g2000yqz.googlegroups.com> Message-ID: <49a77b7a0911010906k32bf5c03hd546f6b2f1dc90fd@mail.gmail.com> On Sun, Nov 1, 2009 at 11:09 AM, b1g3ar5 wrote: > OK, I understand that now but I've got a supplimentary question. > > If I put: > > instance Eq b => Eq (a -> b) where > ? ?(==) = liftA2 (Prelude.==) You don't need the "Prelude." here. > to do the Eq part I get another error: > > ? ?Couldn't match expected type `Bool' > ? ? ? ? ? against inferred type `a -> Bool' > ? ?In the expression: liftA2 (==) > ? ?In the definition of `==': == = liftA2 (==) > ? ?In the instance declaration for `Eq (a -> b)' > > Now can someone please explain this? The type of liftA2 (==) is forall f b. Applicative f => f b -> f b -> f Bool. In your case, f is (->) a, so liftA2 (==) :: (a -> b) -> (a -> b) -> (a -> Bool), which can't be unified with the type for (==). Personally, I recommend against trying to make (a -> b) an instance of Num. If you really want to do arithmetic on functions, it's easier to just do something along these lines: (.+.),(.-.),(.*.) :: (Applicative f, Num a) => f a -> f a -> f a (.+.) = liftA2 (+) (.-.) = liftA2 (-) (.*.) = liftA2 (*) -- Dave Menendez From dave at zednenem.com Sun Nov 1 12:10:09 2009 From: dave at zednenem.com (David Menendez) Date: Sun Nov 1 11:46:26 2009 Subject: [Haskell-cafe] Re: Experiments with defunctionalization, church-encoding and CPS In-Reply-To: References: <5e0214850910130244rf0164d4k6144e8d6f07d022e@mail.gmail.com> Message-ID: <49a77b7a0911010910i5b9f5be5ya47fa538fef10951@mail.gmail.com> On Sun, Nov 1, 2009 at 7:12 AM, Heinrich Apfelmus wrote: > Even then, the results are mixed. The Church-encoding shines in GHCi as > it should, but loses its advantage when the code is being compiled. I > guess we have to look at the core if we want to know what exactly is > going on. What optimization level did you compile with? -- Dave Menendez From apfelmus at quantentunnel.de Sun Nov 1 12:31:43 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Sun Nov 1 12:08:23 2009 Subject: [Haskell-cafe] Re: Experiments with defunctionalization, church-encoding and CPS In-Reply-To: <49a77b7a0911010910i5b9f5be5ya47fa538fef10951@mail.gmail.com> References: <5e0214850910130244rf0164d4k6144e8d6f07d022e@mail.gmail.com> <49a77b7a0911010910i5b9f5be5ya47fa538fef10951@mail.gmail.com> Message-ID: David Menendez wrote: > On Sun, Nov 1, 2009 at 7:12 AM, Heinrich Apfelmus > wrote: >> Even then, the results are mixed. The Church-encoding shines in GHCi as >> it should, but loses its advantage when the code is being compiled. I >> guess we have to look at the core if we want to know what exactly is >> going on. > > What optimization level did you compile with? No optimization. From the bottom of the paste http://hpaste.org/fastcgi/hpaste.fcgi/view?id=10686#a11420 Results: In ghci, the church encodings clearly win. *Main> force testTree () (1.63 secs, 13948748 bytes) *Main> test findMaybe 0 100000 (1.70 secs, 15026356 bytes) *Main> test findChurch 0 100000 (0.72 secs, 15553668 bytes) *Main> test findChurch' 0 100000 (0.71 secs, 13456600 bytes) But when compiling, the algebraic data types wins. ghc --make Test.hs data Maybe mean: 90.08407 ms, lb 86.36974 ms, ub 94.13646 ms Church encoding mean: 152.0198 ms, lb 144.0916 ms, ub 161.0063 ms Church encoding optimised mean: 114.0715 ms, lb 107.3498 ms, ub 122.6881 ms I am a bit surprised. Then again, I probably shouldn't be surprised that the cost model is not like I imagine it to be. Regards, apfelmus -- http://apfelmus.nfshost.com From derek.a.elkins at gmail.com Sun Nov 1 12:44:20 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sun Nov 1 12:20:37 2009 Subject: [Haskell-cafe] Experiments with defunctionalization, church-encoding and CPS In-Reply-To: <5e0214850910130244rf0164d4k6144e8d6f07d022e@mail.gmail.com> References: <5e0214850910130244rf0164d4k6144e8d6f07d022e@mail.gmail.com> Message-ID: <61f84eff0911010944j671b7373m5010d3da497b22c2@mail.gmail.com> On Tue, Oct 13, 2009 at 4:44 AM, Eugene Kirpichov wrote: > I took a toy problem - find the first node satisfying a predicate in a > binary tree, started with a naive Maybe-based implementation - and > experimented with 3 ways of changing the program: > ?- Church-encode the Maybe > ?- Convert the program into CPS > ?- Defunctionalize the Church-encoded or CPS-transformed program > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=10686 > > The link points to code, a benchmark and conclusion. > > Conclusion: > ?- Haskell implements Maybe well enough that it is not possible to do better > ?- Defunctionalization and consequent optimization yields same > performance as the one with Maybe > ?- Non-simplified CPS and Church-encoded representations do bad You may find this collection of related papers interesting if you have not already seen them: http://lambda-the-ultimate.org/node/2423#comment-38384 From chris at eidhof.nl Sun Nov 1 13:25:22 2009 From: chris at eidhof.nl (Chris Eidhof) Date: Sun Nov 1 13:01:40 2009 Subject: [solved] Re: [Haskell-cafe] Calling Haskell from C, Linking with gcc? In-Reply-To: <20091029235305.GA421@cox.net> References: <20091006164416.GA960@cox.net> <4c44d90b0910060948m41ebb11r781b4080881dd9c8@mail.gmail.com> <20091006185136.GB960@cox.net> <871vlgl4tm.fsf@gregorycollins.net> <20091006232031.GC960@cox.net> <8570DCFE-6DC2-4021-9F1E-BE0AB10D3480@ece.cmu.edu> <20091007173853.GA276@cox.net> <20091007213927.GD276@cox.net> <4FCAFAF2-29C5-4E87-A22F-D2C8D8D53F32@cs.nott.ac.uk> <20091029235305.GA421@cox.net> Message-ID: <435C2221-3441-4F7A-B66C-93DB4CE23471@eidhof.nl> I can confirm that, if you follow the steps on the wiki, you'll end up with a working Mac application. Excellent work John, thanks very much! -chris On 30 okt 2009, at 00:53, John Velman wrote: > It's taken 21 days with interruptions, but I finally posted a > tutorial with > details of what I did on the Haskel Wiki. Category:Tutorials, > title: Using Haskell in an Xcode Cocoa project > > Hope it's clear. Please send comments and suggestions. > > John V. > > > On Thu, Oct 08, 2009 at 10:34:07AM +0200, Wouter Swierstra wrote: >> >> On 7 Oct 2009, at 23:39, John Velman wrote: >> >>> For anyone following this: The XCode ld script is complex, and >>> has mac >>> specific defaults early in the search path specification, and I >>> probably >>> don't want to change these. A library in a default path is the >>> wrong >>> libgmp.[dylib | a]. >> >> Is there any chance you'll write up exactly what you needed to do >> on a >> blog/TMR article/Haskell wiki page? I've tried doing something >> similar, ran >> into linking problems, and gave up my fight with XCode. I think >> this would >> be a really useful resource for both Obj-C programmers looking into >> Haskell >> and Haskell programmers who want to have a fancy Cocoa GUI. Thanks! >> >> Wouter > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From dons at galois.com Sun Nov 1 14:01:40 2009 From: dons at galois.com (Don Stewart) Date: Sun Nov 1 13:37:59 2009 Subject: [Haskell-cafe] hackage is down. In-Reply-To: <910ddf450911010558q48e21c72sfcb12ed8105c8d86@mail.gmail.com> References: <910ddf450911010558q48e21c72sfcb12ed8105c8d86@mail.gmail.com> Message-ID: <20091101190140.GA3919@whirlpool.galois.com> This has been reported to the sysadmins. tphyahoo: > http://hackage.haskell.org > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From svein.ove at aas.no Sun Nov 1 14:20:56 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Sun Nov 1 13:57:12 2009 Subject: [Haskell-cafe] ANN: haskell-mode 2.6 Message-ID: <221b53ab0911011120o37e79d37gfaa0928f31e1d46c@mail.gmail.com> Fellow haskellers: Haskell-mode 2.6 has been released. * By web: http://projects.haskell.org/haskellmode-emacs/ * By darcs: http://code.haskell.org/haskellmode-emacs/ This is mainly a bugfix release; to anyone using haskell-indentation, the big news will be that it no longer under some circumstances hands you a parse error and refuses to insert a newline, or backspace. It still gives you a parse error. It just tries its best to proceed anyway. There are also some new features, courtesy of Alex Ott: More font-lock symbols, and a hayoo function. In the case of the font-lock symbols, your mileage may vary on how nice the picked ones are. Mine certainly does. As such, I'm announcing open season on font-lock symbols: Comment to your heart's desire, and I'll use whatever you decide on for the next official release. The tab-cycle implementation is thanks to ivanm, whose random comments can trigger hours and hours of work. I'll just quote from the NEWS file now: === Changes since 2.5.1 * haskell-indentation: Pressing tab in the rightmost position now moves to the leftmost, by default with a warning. * Typo fix: One haskell-indentation variable had ended up in the haskell-ntation customize group. * haskell-hoogle aliased to hoogle, haskell-hayoo aliased to hayoo * Courtesy of Alex Ott: - Additional unicode symbols for font-lock-symbols: () == /= >= <= !! && || sqrt - M-x haskell-hayoo search added, opens using browse-url - Bug-fix for inferior-haskell-type * If haskell-indentation errors out, it now fail-safes to inserting a literal newline or deleting one character, for return and backspace respectively. -- Svein Ove Aas From phi500ac at yahoo.ca Sun Nov 1 15:44:42 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Sun Nov 1 15:20:58 2009 Subject: [Haskell-cafe] hSeek in Windows Message-ID: <370673.26462.qm@web58804.mail.re1.yahoo.com> As many people guess, I am trying to port programs from Clean 1.3 to Haskell (and also to Clean 2.2, which is easier, but not much easier). Late Professor Wellesley wrote an interesting data base manager in Clean 1.3 that I would like to see in Haskell and Clean 2.2. However, when I tried to implement the BTree algorithm, GHC compiler did not accept hSeek and other IO operations. D:\Programs\GHC-PROGS\docs\textut>ghc btree.hs --make [1 of 1] Compiling Main???????????? ( btree.hs, btree.o ) Linking btree.exe ... D:\Programs\GHC-PROGS\docs\textut>btree.exe btree.exe: teste.txt: hSeek: illegal operation (seek operations on text-mod dles are not allowed on this platform) To make a long story short, the program compiles, but does not run. This is interesting, because when Clean compiles an input/output operation it certainly executes it. In any case, what I should do in order to make file operations work on Windows? I need random access to text files. __________________________________________________________________ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now http://ca.toolbar.yahoo.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091101/205f93af/attachment.html From ndmitchell at gmail.com Sun Nov 1 15:48:34 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sun Nov 1 15:24:51 2009 Subject: [Haskell-cafe] hSeek in Windows In-Reply-To: <370673.26462.qm@web58804.mail.re1.yahoo.com> References: <370673.26462.qm@web58804.mail.re1.yahoo.com> Message-ID: <404396ef0911011248h58ea87d4h6a8235b16446d612@mail.gmail.com> Hi Philippos, The secret is there in the error message: "seek operations on text-moddles are not allowed on this platform" You need to set your file in to binary mode, with hSetBinaryMode (http://haskell.org/hoogle/?hoogle=hSetBinaryMode) or openBinaryFile (http://haskell.org/hoogle/?hoogle=openBinaryFile). After doing that hSeek will work. Thanks, Neil On Sun, Nov 1, 2009 at 8:44 PM, Philippos Apolinarius wrote: > > As many people guess, I am trying to port programs from Clean 1.3 to Haskell (and also to Clean 2.2, which is easier, but not much easier). Late Professor Wellesley wrote an interesting data base manager in Clean 1.3 that I would like to see in Haskell and Clean 2.2. However, when I tried to implement the BTree algorithm, GHC compiler did not accept hSeek and other IO operations. > > D:\Programs\GHC-PROGS\docs\textut>ghc btree.hs --make > [1 of 1] Compiling Main???????????? ( btree.hs, btree.o ) > Linking btree.exe ... > > D:\Programs\GHC-PROGS\docs\textut>btree.exe > btree.exe: teste.txt: hSeek: illegal operation (seek operations on text-mod > dles are not allowed on this platform) > > To make a long story short, the program compiles, but does not run. This is interesting, because when Clean compiles an input/output operation it certainly executes it. In any case, what I should do in order to make file operations work on Windows? I need random access to text files. > > > ________________________________ > All new Yahoo! Mail - Get a sneak peak at messages with a handy reading pane. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ndmitchell at gmail.com Sun Nov 1 15:49:16 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sun Nov 1 15:25:33 2009 Subject: [Haskell-cafe] hackage is down. In-Reply-To: <20091101190140.GA3919@whirlpool.galois.com> References: <910ddf450911010558q48e21c72sfcb12ed8105c8d86@mail.gmail.com> <20091101190140.GA3919@whirlpool.galois.com> Message-ID: <404396ef0911011249t49f5050bw7212d611982f27f@mail.gmail.com> For future reference, if Hackage or community is down where should that be reported to? On Sun, Nov 1, 2009 at 7:01 PM, Don Stewart wrote: > This has been reported to the sysadmins. > > tphyahoo: >> http://hackage.haskell.org >> _______________________________________________ >> 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 > From dons at galois.com Sun Nov 1 15:54:39 2009 From: dons at galois.com (Don Stewart) Date: Sun Nov 1 15:30:58 2009 Subject: [Haskell-cafe] hackage is down. In-Reply-To: <404396ef0911011249t49f5050bw7212d611982f27f@mail.gmail.com> References: <910ddf450911010558q48e21c72sfcb12ed8105c8d86@mail.gmail.com> <20091101190140.GA3919@whirlpool.galois.com> <404396ef0911011249t49f5050bw7212d611982f27f@mail.gmail.com> Message-ID: <20091101205439.GG3919@whirlpool.galois.com> I'd say, community -> dcoutts, Igloo, ijones@galois.com hackage.haskell.org/darcs.haskell.org -> {dons,heinelein}@galois.com ndmitchell: > For future reference, if Hackage or community is down where should > that be reported to? > > On Sun, Nov 1, 2009 at 7:01 PM, Don Stewart wrote: > > This has been reported to the sysadmins. > > > > tphyahoo: > >> http://hackage.haskell.org > >> _______________________________________________ > >> 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 > > From lemming at henning-thielemann.de Sun Nov 1 16:05:45 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Nov 1 15:40:11 2009 Subject: [Haskell-cafe] ghci REPL output under Haskell Platform on Mac OS X In-Reply-To: <40D8D225-957C-4236-992A-10466DB1C626@glyphic.com> References: <40D8D225-957C-4236-992A-10466DB1C626@glyphic.com> Message-ID: <4AEDF829.209@henning-thielemann.de> Mark Lentczner schrieb: > My ghci installation has a very annoying behavior: When it takes input, > the result is displayed on the same line as the input, overwriting the > prompt and input. Viz.: > > [1015] : ghci > GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > 7relude> 3 + 4 > Prelude> > > Note the 7 that overwrites the P in Prelude. > > I have had several prior versions of ghci installed, most recently > 6.10.1, and they never had this problem. (In other words, I saw: > > Prelude> 3 + 4 > 7 > Prelude> I had a similar problem with Haskeline and an too old version of terminfo. I assume Haskeline is used by your GHC instead of readline. Now I'm using self-compiled ghci-haskeline. From schlepptop at henning-thielemann.de Sun Nov 1 16:26:17 2009 From: schlepptop at henning-thielemann.de (Henning Thielemann) Date: Sun Nov 1 16:00:38 2009 Subject: [Haskell-cafe] Applicative but not Monad In-Reply-To: References: Message-ID: <4AEDFCF9.1040701@henning-thielemann.de> Yusaku Hashimoto schrieb: > Hello cafe, > Do you know any data-type which is Applicative but not Monad? Here you also find an example: http://www.haskell.org/haskellwiki/Applicative_functor From svein.ove at aas.no Sun Nov 1 16:45:58 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Sun Nov 1 16:22:16 2009 Subject: [Haskell-cafe] Re: ANN: haskell-mode 2.6 In-Reply-To: <221b53ab0911011120o37e79d37gfaa0928f31e1d46c@mail.gmail.com> References: <221b53ab0911011120o37e79d37gfaa0928f31e1d46c@mail.gmail.com> Message-ID: <221b53ab0911011345m13dd8bc9i7c010fb790b28fda@mail.gmail.com> On Sun, Nov 1, 2009 at 8:20 PM, Svein Ove Aas wrote: > Fellow haskellers: > > Haskell-mode 2.6 has been released. > Make that 2.6.1. Naturally, I broke something, but I think I'm about out of things to break now. -- Svein Ove Aas From svein.ove at aas.no Sun Nov 1 16:48:33 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Sun Nov 1 16:24:49 2009 Subject: [Haskell-cafe] hSeek in Windows In-Reply-To: <370673.26462.qm@web58804.mail.re1.yahoo.com> References: <370673.26462.qm@web58804.mail.re1.yahoo.com> Message-ID: <221b53ab0911011348h78eb5677m78e63d342567ad0d@mail.gmail.com> On Sun, Nov 1, 2009 at 9:44 PM, Philippos Apolinarius wrote: > To make a long story short, the program compiles, but does not run. This is interesting, because when Clean compiles an input/output operation it certainly executes it. In any case, what I should do in order to make file operations work on Windows? I need random access to text files. > The reason it fails to run is because, on windows, there isn't a one-to-one mapping between characters and bytes on text files. You have to use binary mode, in which case you're likely to see doubled newlines - \r\n, or the other way around, I don't remember. Which brings up the interesting question of how this works in 6.12, which has text support for modes that are 1:N on /all/ platforms; e.g. UTF-8. If hSeek works there, then chances are it'll work in text mode on windows as well. -- Svein Ove Aas From dave at zednenem.com Sun Nov 1 17:23:54 2009 From: dave at zednenem.com (David Menendez) Date: Sun Nov 1 17:00:14 2009 Subject: [Haskell-cafe] Applicative but not Monad In-Reply-To: References: Message-ID: <49a77b7a0911011423lc2bff8dwe834384b02793603@mail.gmail.com> On Sun, Nov 1, 2009 at 11:20 AM, Conor McBride wrote: > On 31 Oct 2009, at 10:39, Conor McBride wrote: >> On 30 Oct 2009, at 16:14, Yusaku Hashimoto wrote: >> >>> Hello cafe, >>> Do you know any data-type which is Applicative but not Monad? >> >> [can resist anything but temptation] >> >> I have an example, perhaps not a datatype: >> tomorrow-you-will-know > > Elaborating, one day later, > > ?if you know something today, you can arrange to know it tomorrow > ?if will know a function tomorrow and its argument tomorrow, you > ? ?can apply them tomorrow > ?but if you will know tomorrow that you will know something the > ? ?day after, that does not tell you how to know the thing tomorrow > > Put otherwise, unit-delay is applicative but not monadic. I've been > using this to organise exactly what happens when in those wacky > miraculous-looking circular programs. It seems quite promising, > so far... Can you do that with just applicative functors, or do you need arrows? According to "Idioms are oblivious, arrows are meticulous, monads are promiscuous"[1], an arrow (~>) that's equivalent to an applicative functor has the property that "a ~> b" is isomorphic to "() ~> (a -> b)". A typical delay arrow has the form delay :: a -> (a ~> a), so if (~>) is equivalent to some applicative functor f, we can rewrite that as delay :: a -> f (a -> a), which seems too limited to have the proper behavior. [1] http://homepages.inf.ed.ac.uk/wadler/topics/links.html#arrows-and-idioms -- Dave Menendez From dave at zednenem.com Sun Nov 1 17:26:40 2009 From: dave at zednenem.com (David Menendez) Date: Sun Nov 1 17:02:56 2009 Subject: [Haskell-cafe] Re: Experiments with defunctionalization, church-encoding and CPS In-Reply-To: References: <5e0214850910130244rf0164d4k6144e8d6f07d022e@mail.gmail.com> <49a77b7a0911010910i5b9f5be5ya47fa538fef10951@mail.gmail.com> Message-ID: <49a77b7a0911011426h54625ffdn79d953fa266fd87c@mail.gmail.com> On Sun, Nov 1, 2009 at 12:31 PM, Heinrich Apfelmus wrote: > David Menendez wrote: >> On Sun, Nov 1, 2009 at 7:12 AM, Heinrich Apfelmus >> wrote: >>> Even then, the results are mixed. The Church-encoding shines in GHCi as >>> it should, but loses its advantage when the code is being compiled. I >>> guess we have to look at the core if we want to know what exactly is >>> going on. >> >> What optimization level did you compile with? > > No optimization. Do you get the same results if you compile with -O2? Or does that screw up criterion somehow? -- Dave Menendez From markl at glyphic.com Sun Nov 1 18:12:29 2009 From: markl at glyphic.com (Mark Lentczner) Date: Sun Nov 1 17:48:46 2009 Subject: [Haskell-cafe] ghci REPL output under Haskell Platform on Mac OS X In-Reply-To: <4AEDF829.209@henning-thielemann.de> References: <40D8D225-957C-4236-992A-10466DB1C626@glyphic.com> <4AEDF829.209@henning-thielemann.de> Message-ID: On Nov 1, 2009, at 1:05 PM, Henning Thielemann wrote: > I had a similar problem with Haskeline and an too old version of > terminfo. I assume Haskeline is used by your GHC instead of readline. Aha! That led me to find it: I had TERM set to 'ansi'. ghci + Haskeline works find if TERM is set to any of rxvt, vt52, vt100, vt102 or xterm. Don't know what in terminfo Haskeline is relying on, but 'ansi' doesn't have it! - Mark From dvde at gmx.net Sun Nov 1 18:24:47 2009 From: dvde at gmx.net (Daniel van den Eijkel) Date: Sun Nov 1 18:01:06 2009 Subject: [Haskell-cafe] hackage is down. In-Reply-To: <20091101145916.GA7500@functor.nl> References: <910ddf450911010558q48e21c72sfcb12ed8105c8d86@mail.gmail.com> <20091101145916.GA7500@functor.nl> Message-ID: <4AEE18BF.9080602@gmx.net> you saved my day! thanks, daniel Jochem Berndsen schrieb: > On Sun, Nov 01, 2009 at 07:58:00AM -0600, Thomas Hartman wrote: > >> http://hackage.haskell.org >> > > Hackage is down currently, I am seeding the torrent by mauke from IRC on > http://mauke.ath.cx/tmp/2009-10-19-hackage-archive.torrent > > Cheers, Jochem > From lemming at henning-thielemann.de Sun Nov 1 18:59:26 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Nov 1 18:35:43 2009 Subject: [Haskell-cafe] hackage is down. In-Reply-To: <4AEE18BF.9080602@gmx.net> References: <910ddf450911010558q48e21c72sfcb12ed8105c8d86@mail.gmail.com> <20091101145916.GA7500@functor.nl> <4AEE18BF.9080602@gmx.net> Message-ID: > Jochem Berndsen schrieb: >> On Sun, Nov 01, 2009 at 07:58:00AM -0600, Thomas Hartman wrote: >> >>> http://hackage.haskell.org >> >> Hackage is down currently, I am seeding the torrent by mauke from IRC on >> http://mauke.ath.cx/tmp/2009-10-19-hackage-archive.torrent Cool, is this the beginning of distributed Hackage? Still needs support in 'cabal-install'. From ross at soi.city.ac.uk Sun Nov 1 19:11:32 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Sun Nov 1 18:47:51 2009 Subject: [Haskell-cafe] Applicative but not Monad In-Reply-To: References: Message-ID: <20091102001132.GA2027@soi.city.ac.uk> On Sun, Nov 01, 2009 at 04:20:18PM +0000, Conor McBride wrote: > On 31 Oct 2009, at 10:39, Conor McBride wrote: > >I have an example, perhaps not a datatype: > >tomorrow-you-will-know > > Elaborating, one day later, > > if you know something today, you can arrange to know it tomorrow > if will know a function tomorrow and its argument tomorrow, you > can apply them tomorrow > but if you will know tomorrow that you will know something the > day after, that does not tell you how to know the thing tomorrow Yes, but if you will know tomorrow that you will know something tomorrow, then you will know that thing tomorrow. The applicative does coincide with a monad, just not the one you first thought of (or/max rather than plus). From svein.ove at aas.no Sun Nov 1 19:14:25 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Sun Nov 1 18:50:40 2009 Subject: [Haskell-cafe] Re: ANN: haskell-mode 2.6 In-Reply-To: <221b53ab0911011120o37e79d37gfaa0928f31e1d46c@mail.gmail.com> References: <221b53ab0911011120o37e79d37gfaa0928f31e1d46c@mail.gmail.com> Message-ID: <221b53ab0911011614g25499d3asa0dc9af5fce505a7@mail.gmail.com> On Sun, Nov 1, 2009 at 8:20 PM, Svein Ove Aas wrote: > Fellow haskellers: > > Haskell-mode 2.6 has been released. > > * By web: http://projects.haskell.org/haskellmode-emacs/ > * By darcs: http://code.haskell.org/haskellmode-emacs/ > Since there appears to be some confusion: Indentation is now /off by default/. This is because there are several indentation modules, and I don't want to force people to use a particular one. If you want indentation, read the README; it explains how to turn it on. -- Svein Ove Aas From conor at strictlypositive.org Sun Nov 1 19:17:48 2009 From: conor at strictlypositive.org (Conor McBride) Date: Sun Nov 1 18:54:07 2009 Subject: [Haskell-cafe] Applicative but not Monad In-Reply-To: <20091102001132.GA2027@soi.city.ac.uk> References: <20091102001132.GA2027@soi.city.ac.uk> Message-ID: <294434B3-5D60-4924-BAE6-B77CE68479BD@strictlypositive.org> On 2 Nov 2009, at 00:11, Ross Paterson wrote: > On Sun, Nov 01, 2009 at 04:20:18PM +0000, Conor McBride wrote: >> On 31 Oct 2009, at 10:39, Conor McBride wrote: >>> I have an example, perhaps not a datatype: >>> tomorrow-you-will-know >> >> Elaborating, one day later, >> >> if you know something today, you can arrange to know it tomorrow >> if will know a function tomorrow and its argument tomorrow, you >> can apply them tomorrow >> but if you will know tomorrow that you will know something the >> day after, that does not tell you how to know the thing tomorrow > > Yes, but if you will know tomorrow that you will know something > tomorrow, then you will know that thing tomorrow. That depends on what "tomorrow" means tomorrow. > The applicative does coincide with a monad, just not the one you first > thought of (or/max rather than plus). True, but it's not the notion I need to analyse circular programs. I'm looking for something with a fixpoint operator fix :: (Tomorrow x -> x) -> x which I can hopefully use to define things like repmin :: Tree Int -> (Int, Tomorrow (Tree Int)) so that the fixpoint operator gives me a Tomorrow Int which I can use to build the second component, but ensures that the black-hole-tastic Tomorrow (Tomorrow (Tree Int)) I also receive is too late to be a serious temptation. All the best Conor From magicloud.magiclouds at gmail.com Sun Nov 1 20:06:36 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Sun Nov 1 19:42:53 2009 Subject: [Haskell-cafe] How to fulfill the "code-reuse" destiny of OOP? In-Reply-To: <87aaz7ovlt.fsf@gregorycollins.net> References: <3bd412d40910291854w67677d4esc0d47763c6a6fd8a@mail.gmail.com> <4AEB38BE.5010100@btinternet.com> <3bd412d40910310503p3b45d004ia69f873114579f2a@mail.gmail.com> <8b70a98a0910310521s646593a3i2558aca5d4088a27@mail.gmail.com> <87aaz7ovlt.fsf@gregorycollins.net> Message-ID: <3bd412d40911011706s697948e6nd0ed88b14341a6fb@mail.gmail.com> I am not saying that the code has to be in OO style. When I say OO is general, I mean I am thinking in OO style. This reflects on modeling, program structure, even code organization. Style is how we present things. I think that is less important than how we think about things. On Sun, Nov 1, 2009 at 9:57 AM, Gregory Collins wrote: > Tom Davie writes: > >> On 10/31/09, Magicloud Magiclouds wrote: >>> After all, I never think OO as an oppsite way to all other things. The >>> idea is so general that if you say I cannot use it in Haskell at all, >>> that would make me feel weird. The only difference between languages >>> is, some are easy to be in OO style, some are not. >> >> Wow, someone drank the cool aid! > > Doing OO-style programming in Haskell is difficult and unnatural, it's > true (although technically speaking it is possible). That said, nobody's > yet to present a convincing argument to me why Java gets a free pass for > lacking closures and typeclasses. > > G. > -- > Gregory Collins > -- ??????? ??????? From me at rkit.pp.ru Sun Nov 1 20:53:11 2009 From: me at rkit.pp.ru (=?ISO-8859-1?Q?=3F=3F=3F=3F=3F=3F=3F_=3F=3F=3F=3F=3F=3F?=) Date: Sun Nov 1 20:15:58 2009 Subject: [Haskell-cafe] hackage is down. In-Reply-To: References: <910ddf450911010558q48e21c72sfcb12ed8105c8d86@mail.gmail.com> <20091101145916.GA7500@functor.nl> <4AEE18BF.9080602@gmx.net> Message-ID: <4AEE3B87.2020607@rkit.pp.ru> After some discussion in haskell@conference.jabber.ru, I've got this ideas: + Distributed hackage is DHT network. + Everything is PGP-signed. + Everyone can push package into network, everyone can rate package (malicious / SPAM / unstable / stable / etc). + User maintains list of trusted people's open keys, in order to validate authenticity and see trusted ratings. Additional features: + Load balancing. + Ability to work through HTTP, trusted LAN peers, etc. Sorry for my terrible English. > > Cool, is this the beginning of distributed Hackage? Still needs > support in 'cabal-install'. > From thomas.dubuisson at gmail.com Sun Nov 1 20:46:30 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Sun Nov 1 20:22:46 2009 Subject: [Haskell-cafe] hackage is down. In-Reply-To: <4AEE3B87.2020607@rkit.pp.ru> References: <910ddf450911010558q48e21c72sfcb12ed8105c8d86@mail.gmail.com> <20091101145916.GA7500@functor.nl> <4AEE18BF.9080602@gmx.net> <4AEE3B87.2020607@rkit.pp.ru> Message-ID: <4c44d90b0911011746pb9abeecu37cc436f593dd64e@mail.gmail.com> > + Distributed hackage is DHT network. A DHT has been discussed before on IRC, glad to hear more people voicing the thought. > + Everything is PGP-signed. Yes, that would certainly be needed and also came up in our discussion. > + Everyone can push package into network, everyone can rate package > (malicious / SPAM / unstable / stable / etc). No no no! Why not download the normal (signed) cabal list from the DHT (and optionally directly from hackage.haskell.org)? These are all the packages that would appear on the website. Why serve any other content? All nodes in the DHT may check and make sure the file (or fragment) being served is properly signed. Any desire for popularity or tagging capability should be separate. > + User maintains list of trusted people's open keys, in order to > validate authenticity and see trusted ratings. This would need further explanation, but in general I'm against requiring user interaction on this level. Thomas From me at rkit.pp.ru Sun Nov 1 21:28:53 2009 From: me at rkit.pp.ru (=?windows-1252?Q?=3F=3F=3F=3F=3F=3F=3F_=3F=3F=3F=3F=3F=3F?=) Date: Sun Nov 1 20:51:37 2009 Subject: [Haskell-cafe] hackage is down. In-Reply-To: <4c44d90b0911011746pb9abeecu37cc436f593dd64e@mail.gmail.com> References: <910ddf450911010558q48e21c72sfcb12ed8105c8d86@mail.gmail.com> <20091101145916.GA7500@functor.nl> <4AEE18BF.9080602@gmx.net> <4AEE3B87.2020607@rkit.pp.ru> <4c44d90b0911011746pb9abeecu37cc436f593dd64e@mail.gmail.com> Message-ID: <4AEE43E5.6090200@rkit.pp.ru> > No no no! Why not download the normal (signed) cabal list from the > DHT (and optionally directly from hackage.haskell.org)? These are all > the packages that would appear on the website. Why serve any other > content? All nodes in the DHT may check and make sure the file (or > fragment) being served is properly signed. > > Any desire for popularity or tagging capability should be separate. > Because single single hackage private key can be bruteforsed or stolen far easier than lots and lots keys of random people. >> + User maintains list of trusted people's open keys, in order to >> validate authenticity and see trusted ratings. >> > > This would need further explanation, but in general I'm against > requiring user interaction on this level. You choose who's moderating packages for you. Some well-known community moderators and your trusted friends. If no one rated package yet, then you download and rate, so people who trust you can make decision based on your rate. Kind of social network. From chak at cse.unsw.edu.au Sun Nov 1 21:30:02 2009 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Sun Nov 1 21:06:30 2009 Subject: [Haskell-cafe] Bulding a library for C users on OS X In-Reply-To: <7230440F-F18E-4495-9EAF-75A93550C9B3@eidhof.nl> References: <7230440F-F18E-4495-9EAF-75A93550C9B3@eidhof.nl> Message-ID: <1D2186E4-8731-4E73-B81D-A264A332C80A@cse.unsw.edu.au> Chris Eidhof: > I'm trying to call a Haskell function from C, on OS X. There's an > excellent post [1] by Tom?? Janou?ek that explains how to do this on > Linux. However, on OS X, it's different. First of all, it looks like > the -no-hs-main flag is ignored, because I get the following error: > > > ghc -O2 --make -no-hs-main -optl '-shared' -optc '- > DMODULE=Test' -o Test.so Test.hs module_init.c > > [1 of 1] Compiling Main ( Test.hs, Test.o ) > > > > Test.hs:1:0: The function `main' is not defined in module `Main''' The flag -no-hs-main is a link-time flag that allows you to link without a main function, but you are getting a compile time error. It's as if you try to export main, but don't define it. Have you had a look at http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#foreign-export-ghc ? Manuel From shelby at coolpage.com Sun Nov 1 21:39:08 2009 From: shelby at coolpage.com (Shelby Moore) Date: Sun Nov 1 21:15:29 2009 Subject: [Haskell-cafe] Base classes can be _ELIMINATED_ with interfaces Message-ID: <4232.121.97.54.144.1257129548.squirrel@webmail4.pair.com> I was correct before, except I conflated the word "extended" with "eliminated" in my mind: http://lambda-the-ultimate.org/node/1277#comment-51723 The most robust solution to Tim Sweeney's problem is to rethink what a "class" should be: http://www.haskell.org/haskellwiki/?title=Why_Haskell_matters&oldid=24286#Haskell_vs_OOP In Haskel, subtyping is done with Module. A "type class" is a polymorphic (relative to data type) interface, and the polymorphism is strictly parameterized for the client/consumer of the interface, i.e. the data type is known to the function that inputs the interface AT COMPILE TIME: http://www.haskell.org/~pairwise/intro/section2.html#part3 If all the functions/methods of package Engine input exclusively interfaces (i.e. Engine.IActor), then client package GearsOfWar can create a new subtype GearsOfWar.Actor which also implements the interface Engine.IActor (and perhaps even more interfaces). A problem with virtual (runtime pointer) inheritance is that it hides the subclass from the compiler. Polymorphic interfaces are missing from C++ and one can sort of hack an emulation with abstract classes, private delegates, and templates: http://lambda-the-ultimate.org/node/1277#comment-51806 In Haskell, parameterized polymorphic interfaces can be inherited, and this is knowable to the client function at compile time. Fundamental theorems tell us that any membership rule for a set can not be an absolute point, thus we should strive for typing and classing architecture which is the most granular (these are my summaries): * Russell's Paradox: there is no rule for a set that does not cause it to contain itself, thus all sets are infinitely recursive. * Liskov Substition Principle: it is an undecidable problem that subsets inherit. * Linsky Referencing: it is undecidable what something is when it is described or perceived. * Coase Theorem: there is no external reference point, any such barrier will fail. * Godel's Theorem: any formal theory, in which all arithmetic truths can be proved, is inconsistent. * 1856 Thermo Law: entire universe (a closed system, i.e. everything) trends to maximum disorder. From shelby at coolpage.com Sun Nov 1 22:06:42 2009 From: shelby at coolpage.com (Shelby Moore) Date: Sun Nov 1 21:42:57 2009 Subject: [Haskell-cafe] How to fulfill the "code-reuse" destiny of OOP? In-Reply-To: <3bd412d40911011706s697948e6nd0ed88b14341a6fb@mail.gmail.com> References: <3bd412d40910291854w67677d4esc0d47763c6a6fd8a@mail.gmail.com> <4AEB38BE.5010100@btinternet.com> <3bd412d40910310503p3b45d004ia69f873114579f2a@mail.gmail.com> <8b70a98a0910310521s646593a3i2558aca5d4088a27@mail.gmail.com> <87aaz7ovlt.fsf@gregorycollins.net> <3bd412d40911011706s697948e6nd0ed88b14341a6fb@mail.gmail.com> Message-ID: <4266.121.97.54.144.1257131202.squirrel@webmail4.pair.com> Magicloud wrote: > I am not saying that the code has to be in OO style. When I say OO is > general, I mean I am thinking in OO style. This reflects on modeling, > program structure, even code organization. > Style is how we present things. I think that is less important than > how we think about things. Style is irrelevant to the larger theorems of the universe which tells us that OOP must be granular in architecture (composability will force it, else code has to be re-written), thus I cross link this thread to "Base classes can be _ELIMINATED_ with interfaces": http://www.haskell.org/pipermail/haskell-cafe/2009-November/068432.html From shelby at coolpage.com Sun Nov 1 22:12:45 2009 From: shelby at coolpage.com (Shelby Moore) Date: Sun Nov 1 21:48:59 2009 Subject: [Haskell-cafe] Base classes can be _ELIMINATED_ with interfaces In-Reply-To: <4232.121.97.54.144.1257129548.squirrel@webmail4.pair.com> References: <4232.121.97.54.144.1257129548.squirrel@webmail4.pair.com> Message-ID: <4279.121.97.54.144.1257131565.squirrel@webmail4.pair.com> The "style" of OOP is irrelevant, and if one means by "style" the conflation of the interface with the data and/or use of virtual (runtime) base class inheritance and the style of that induces, then it is an architectural mistake: http://www.haskell.org/pipermail/haskell-cafe/2009-November/068433.html From shelby at coolpage.com Sun Nov 1 22:57:55 2009 From: shelby at coolpage.com (Shelby Moore) Date: Sun Nov 1 22:34:10 2009 Subject: [Haskell-cafe] hackage is down. In-Reply-To: <4AEE43E5.6090200@rkit.pp.ru> References: <910ddf450911010558q48e21c72sfcb12ed8105c8d86@mail.gmail.com> <20091101145916.GA7500@functor.nl> <4AEE18BF.9080602@gmx.net> <4AEE3B87.2020607@rkit.pp.ru> <4c44d90b0911011746pb9abeecu37cc436f593dd64e@mail.gmail.com> <4AEE43E5.6090200@rkit.pp.ru> Message-ID: <4332.121.97.54.144.1257134275.squirrel@webmail4.pair.com> Opportunity cost minimization problem: >> No no no! Why not download the normal (signed) cabal list from the >> DHT (and optionally directly from hackage.haskell.org)? These are all >> the packages that would appear on the website. Why serve any other >> content? All nodes in the DHT may check and make sure the file (or >> fragment) being served is properly signed. >> >> Any desire for popularity or tagging capability should be separate. >> > Because single single hackage private key can be bruteforsed or stolen > far easier than lots and lots keys of random people. > > > >>> + User maintains list of trusted people's open keys, in order to >>> validate authenticity and see trusted ratings. >> >> This would need further explanation, but in general I'm against >> requiring user interaction on this level. > You choose who's moderating packages for you. Some well-known community > moderators and your trusted friends. If no one rated package yet, then > you download and rate, so people who trust you can make decision based > on your rate. > Kind of social network. In short, P2P introduces non-determinism. Non-determinism is natural law and otherwise order is not permanent (e.g. ends in non-composability, errors, vulnerabilities, etc): http://www.haskell.org/pipermail/haskell-cafe/2009-November/068432.html What is needed is some way to set up upper bound to the level of non-determinism in some useful domain: http://www.haskell.org/pipermail/haskell-cafe/2009-October/068382.html (space determinism in Haskell) Which are really opportunity cost minimizations: http://forum.bittorrent.org/viewtopic.php?id=28 (my architectural comments about BitTorrent free loading) http://goldwetrust.up-with.com/technology-f8/computers-t112-15.htm#2189 (long winded, not so coherent brainstorming) From shelby at coolpage.com Sun Nov 1 23:15:14 2009 From: shelby at coolpage.com (Shelby Moore) Date: Sun Nov 1 22:51:30 2009 Subject: [Haskell-cafe] Re: Suggested algorithm to control upper bound of space "leaks" In-Reply-To: <1182.121.97.54.144.1257026037.squirrel@webmail4.pair.com> References: <1182.121.97.54.144.1257026037.squirrel@webmail4.pair.com> Message-ID: <4346.121.97.54.144.1257135314.squirrel@webmail4.pair.com> This is an opportunity cost minimization problem: http://www.haskell.org/pipermail/haskell-cafe/2009-November/068435.html One of the worst (most unoptimized and conflated) solutions is to force some determinism at the low-level language architecture specifically targetted to achieve determinism in some domain at the higher level (which actually doesn't achieve it as the aliasing error gets pushed around any way). It analogous to pulling all your teeth out so you won't get cavities, considering the power that lazy evaluation and pure referential transparency adds to algorithm expression, composability, OOP, optimization opportunities (in many domains, e.g. speed, algorithmic resonance, concurrency, etc): http://www.haskell.org/pipermail/haskell-cafe/2009-November/068432.html Thus my analysis so far is Haskell has it correct, and I am suggesting the missing optimization is to let us automatically put an upper bound on the space non-determinism (the topic of this thread), then the programmer can optimize beyond that with profiling and strategy placement of seq and type constraints[1]. [1]Hudak, Hughes, Peyton Jones, Wadler (2007). "A History of Haskell: being lazy with class" (?32 ?10.3, "Controlling evaluation order" and ?32 ?10.2, "Space profiling") From shelby at coolpage.com Sun Nov 1 23:23:26 2009 From: shelby at coolpage.com (Shelby Moore) Date: Sun Nov 1 22:59:42 2009 Subject: [Haskell-cafe] Re: Suggested algorithm to control upper bound of space "leaks" In-Reply-To: <4346.121.97.54.144.1257135314.squirrel@webmail4.pair.com> References: <1182.121.97.54.144.1257026037.squirrel@webmail4.pair.com> <4346.121.97.54.144.1257135314.squirrel@webmail4.pair.com> Message-ID: <4355.121.97.54.144.1257135806.squirrel@webmail4.pair.com> > Thus my analysis so far is Haskell has it correct, and I am suggesting the > missing optimization is to let us automatically put an upper bound on the > space non-determinism (the topic of this thread), then the programmer can > optimize beyond that with... Arghh, the mailing list web archive did not find the head thread from the previous month, so those readers here it is, so you know what I am refering to: http://www.haskell.org/pipermail/haskell-cafe/2009-October/068382.html Unfortunately anyone reading the link above will not see a link to the thread continuation in this month. Bug. From DekuDekuplex at Yahoo.com Sun Nov 1 23:42:02 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Sun Nov 1 23:18:45 2009 Subject: [Haskell-cafe] Re: Haskell Weekly News: Issue 137 - October 31, 2009 References: <4aebbf41.0703c00a.7ed8.ffffa4c8@mx.google.com> Message-ID: On Fri, 30 Oct 2009 21:38:25 -0700 (PDT), jfredett@gmail.com wrote: > > ... a new version of > haskell-mode for the lesser of two editors.... ^^^^^^ > > [...] > > haskell-mode 2.5. Svein Ove Aas [14]announced a new version of > haskell-mode for that other 'editor'... ^ ^ Hey, careful now.... No need to start another Emacs vs. the other 'editor' flamewar ... lest someone run "M-x nethack" and summon a Demogorgon against you ... er, make that "M-x haskellhack," since a Haskell version needs to be created. ;-) -- 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^ From scooter.phd at gmail.com Mon Nov 2 00:03:17 2009 From: scooter.phd at gmail.com (scooter.phd@gmail.com) Date: Sun Nov 1 23:39:26 2009 Subject: [Haskell-cafe] hackage is down. Message-ID: <901785131-1257138188-cardhu_decombobulator_blackberry.rim.net-1411634226-@bda437.bisx.prod.on.blackberry> Untenable for many "corporate" users administratively prohibited from running any P2P software. First really creative use of a DHT I've seen in 6 years, kudos. ------Original Message------ From: Shelby Moore Sender: haskell-cafe-bounces@haskell.org To: haskell-cafe@haskell.org ReplyTo: shelby@coolpage.com Subject: Re: [Haskell-cafe] hackage is down. Sent: Nov 1, 2009 19:57 Opportunity cost minimization problem: >> No no no! Why not download the normal (signed) cabal list from the >> DHT (and optionally directly from hackage.haskell.org)? These are all >> the packages that would appear on the website. Why serve any other >> content? All nodes in the DHT may check and make sure the file (or >> fragment) being served is properly signed. >> >> Any desire for popularity or tagging capability should be separate. >> > Because single single hackage private key can be bruteforsed or stolen > far easier than lots and lots keys of random people. > > > >>> + User maintains list of trusted people's open keys, in order to >>> validate authenticity and see trusted ratings. >> >> This would need further explanation, but in general I'm against >> requiring user interaction on this level. > You choose who's moderating packages for you. Some well-known community > moderators and your trusted friends. If no one rated package yet, then > you download and rate, so people who trust you can make decision based > on your rate. > Kind of social network. In short, P2P introduces non-determinism. Non-determinism is natural law and otherwise order is not permanent (e.g. ends in non-composability, errors, vulnerabilities, etc): http://www.haskell.org/pipermail/haskell-cafe/2009-November/068432.html What is needed is some way to set up upper bound to the level of non-determinism in some useful domain: http://www.haskell.org/pipermail/haskell-cafe/2009-October/068382.html (space determinism in Haskell) Which are really opportunity cost minimizations: http://forum.bittorrent.org/viewtopic.php?id=28 (my architectural comments about BitTorrent free loading) http://goldwetrust.up-with.com/technology-f8/computers-t112-15.htm#2189 (long winded, not so coherent brainstorming) _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe Sent from my Verizon Wireless BlackBerry From shelby at coolpage.com Mon Nov 2 01:06:43 2009 From: shelby at coolpage.com (Shelby Moore) Date: Mon Nov 2 00:42:58 2009 Subject: [Haskell-cafe] Base classes can be _ELIMINATED_ with interfaces In-Reply-To: <4279.121.97.54.144.1257131565.squirrel@webmail4.pair.com> References: <4232.121.97.54.144.1257129548.squirrel@webmail4.pair.com> <4279.121.97.54.144.1257131565.squirrel@webmail4.pair.com> Message-ID: <4483.121.97.54.144.1257142003.squirrel@webmail4.pair.com> Shelby Moore wrote: > ...A "type class" is a polymorphic > (relative to data type) interface, and the polymorphism is strictly > parameterized for the client/consumer of the interface, i.e. the data type > is known to the function that inputs the interface AT COMPILE TIME. >...A problem with virtual (runtime pointer) inheritance is that it hides > the subclass from the compiler. I emphasize that in Haskell, the consuming function knows the interface at compile time (or it can allow the compiler to infer it, if no type class restriction is specified). > ...if one means by "style" the > conflation of the interface with the data and/or use of virtual (runtime) > base class inheritance and the style of that induces, then it is an > architectural mistake... One explanation of how "extends" (base class) does impact composability: http://www.haskell.org/pipermail/haskell-cafe/2009-October/068337.html Instead encapsulate ("inherit") data type orthogonal to "type class" (interface) in Haskell: http://www.haskell.org/pipermail/haskell-cafe/2009-October/068328.html > The point of that whole rant is that extending data-bearing classes > isn't necessarily a good idea, so before trying to find a way to do it > with haskell, it may be better to just encapsulate another data type, > which is trivial: > > data InnerThing = A | B | C > > data OuterThing = Outer { innerThing :: InnerThing, otherField :: Int } Additionally note: Shelby Moore wrote: > In Haskel, subtyping is done with Module... data is analogous to a public class members. Use Module to make some implementation private: http://www.cs.auckland.ac.nz/references/haskell/haskell-intro-html/modules.html#sect9.2 Thus use type classes (interfaces) when consuming the public Module interfaces in functions (i.e. only consume the exported Module interfaces in the sense they implement a type class, never directly consume the Module name space). I realize some examples would make the above easier to visualize. From will_n48 at yahoo.com Mon Nov 2 02:41:15 2009 From: will_n48 at yahoo.com (Will Ness) Date: Mon Nov 2 02:18:10 2009 Subject: [Haskell-cafe] Simple FAST lazy functional primes Message-ID: First, here it is: primes = 2: 3: sieve 0 primes' 5 primes' = tail primes sieve k (p:ps) x = [x | x<-[x,x+2..p*p-2], and [(x`rem`p)/=0 | p<-take k primes']] ++ sieve (k+1) ps (p*p+2) (thanks to Leon P.Smith for his brilliant idea of directly generating the spans of odds instead of calling 'span' on the infinite odds list). This code is faster than PriorityQueue-based sieve (granted, using my own ad-hoc implementation, so YMMV) in producing the first million primes (testing was done running the ghc -O3 compiled code inside GHCi). The relative performance vs the PQ-version is: 100,000 300,000 1,000,000 primes produced 0.6 0.75 0.97 I've recently came to the Melissa O'Neill's article (I know, I know) and she makes the incredible claim there that the square-of-prime optimization doesn't count if we want to improve the old and "lazy" uprimes = 2: sieve [3,5..] where sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p > 0] Her article gave me the strong impression that she claims that the only way to fix this code is by using Priority Queue based optimization, and then goes on to present astronomical gains in speed by implementing it. Well, I find this claim incredible. First of all, the "naive" code fires up its nested filters much too early, when in fact each must be started only when the prime's square is reached (not only have its work started there - be started there itself!), so that filters are delayed: dprimes = 2: 3: sieve (tail dprimes) [5,7..] where sieve (p:ps) xs = h ++ sieve ps (filter ((/=0).(`rem`p)) (tail t)) where (h,t)=span (< p*p) xs This code right there is on par with the PQ-base code, only x3-4 slower at generating the first million primes. Second, the implicit control structure of linearly nested filters, piling up in front of the supply stream, each with its prime-number-it-filters-by hidden inside it, needs to be explicated into a data structure of primes-to-filter-by (which is in fact the prefix of the primes list we're building itself), so the filtering could be done by one function call instead of many nested calls: xprimes = 2: 3: sieve 0 primes' [5,7..] where primes' = tail xprimes sieve k (p:ps) xs = noDivs k h ++ sieve (k+1) ps (tail t) where (h,t)=span (< p*p) xs noDivs k = filter (\x-> all ((/=0).(x`rem`)) (take k primes')) >From here, using the brilliant idea of Leon P. Smith's of fusing the span and the infinite odds supply, we arrive at the final version, kprimes = 2: 3: sieve 0 primes' 5 where primes' = tail kprimes sieve k (p:ps) x = noDivs k h ++ sieve (k+1) ps (t+2) where (h,t)=([x,x+2..t-2], p*p) noDivs k = filter (\x-> all ((/=0).(x`rem`)) (take k primes')) Using the list comprehension syntax, it turns out, when compiled with ghc -O3, gives it another 5-10% speedup itself. So I take it to disprove the central premise of the article, and to show that simple lazy functional FAST primes code does in fact exist, and that the PQ optimization - which value of course no-one can dispute - is a far-end optimization. From max.rabkin at gmail.com Mon Nov 2 04:58:59 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Mon Nov 2 04:35:39 2009 Subject: [Haskell-cafe] Re: Haskell Weekly News: Issue 137 - October 31, 2009 In-Reply-To: References: <4aebbf41.0703c00a.7ed8.ffffa4c8@mx.google.com> Message-ID: On Mon, Nov 2, 2009 at 6:42 AM, Benjamin L.Russell wrote: > Hey, careful now.... No need to start another Emacs vs. the other > 'editor' flamewar ... lest someone run "M-x nethack" and summon a > Demogorgon against you ... er, make that "M-x haskellhack," since a > Haskell version needs to be created. ;-) There's MazesOfMonad on Hackage, Roguestar at http://roguestar.downstairspeople.org/, and I think there are more on Hackage too but it's still down. > -- Benjamin L. Russell --Max From chris at eidhof.nl Mon Nov 2 05:21:53 2009 From: chris at eidhof.nl (Chris Eidhof) Date: Mon Nov 2 04:58:08 2009 Subject: [Haskell-cafe] Bulding a library for C users on OS X In-Reply-To: <1D2186E4-8731-4E73-B81D-A264A332C80A@cse.unsw.edu.au> References: <7230440F-F18E-4495-9EAF-75A93550C9B3@eidhof.nl> <1D2186E4-8731-4E73-B81D-A264A332C80A@cse.unsw.edu.au> Message-ID: <35835677-0FDC-424B-8AC1-7CA826DE17CE@eidhof.nl> On 2 nov 2009, at 03:30, Manuel M T Chakravarty wrote: > Chris Eidhof: >> I'm trying to call a Haskell function from C, on OS X. There's an >> excellent post [1] by Tom?? Janou?ek that explains how to do this >> on Linux. However, on OS X, it's different. First of all, it looks >> like the -no-hs-main flag is ignored, because I get the following >> error: >> >> > ghc -O2 --make -no-hs-main -optl '-shared' -optc '- >> DMODULE=Test' -o Test.so Test.hs module_init.c >> > [1 of 1] Compiling Main ( Test.hs, Test.o ) >> > >> > Test.hs:1:0: The function `main' is not defined in module `Main''' > > The flag -no-hs-main is a link-time flag that allows you to link > without a main function, but you are getting a compile time error. > It's as if you try to export main, but don't define it. > > Have you had a look at http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#foreign-export-ghc > ? Interesting! I didn't see that section before, thanks a lot. -chris From simonpj at microsoft.com Mon Nov 2 05:30:06 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Mon Nov 2 05:06:28 2009 Subject: [Haskell-cafe] Bulding a library for C users on OS X In-Reply-To: <35835677-0FDC-424B-8AC1-7CA826DE17CE@eidhof.nl> References: <7230440F-F18E-4495-9EAF-75A93550C9B3@eidhof.nl> <1D2186E4-8731-4E73-B81D-A264A332C80A@cse.unsw.edu.au> <35835677-0FDC-424B-8AC1-7CA826DE17CE@eidhof.nl> Message-ID: <59543203684B2244980D7E4057D5FBC1061BDA9B@DB3EX14MBXC310.europe.corp.microsoft.com> There is some stuff on using the FFI under "Collaborative documentation" at http://haskell.org/haskellwiki/GHC. The FFI link takes you to http://haskell.org/haskellwiki/GHC/Using_the_FFI It's called "collaborative" because it's When you solve your problem, can I urge you to update that page (its a wiki) to embody what you have learned? Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On | Behalf Of Chris Eidhof | Sent: 02 November 2009 10:22 | To: Manuel M T Chakravarty | Cc: Haskell Cafe | Subject: Re: [Haskell-cafe] Bulding a library for C users on OS X | | On 2 nov 2009, at 03:30, Manuel M T Chakravarty wrote: | | > Chris Eidhof: | >> I'm trying to call a Haskell function from C, on OS X. There's an | >> excellent post [1] by Tom?? Janou?ek that explains how to do this | >> on Linux. However, on OS X, it's different. First of all, it looks | >> like the -no-hs-main flag is ignored, because I get the following | >> error: | >> | >> > ghc -O2 --make -no-hs-main -optl '-shared' -optc '- | >> DMODULE=Test' -o Test.so Test.hs module_init.c | >> > [1 of 1] Compiling Main ( Test.hs, Test.o ) | >> > | >> > Test.hs:1:0: The function `main' is not defined in module `Main''' | > | > The flag -no-hs-main is a link-time flag that allows you to link | > without a main function, but you are getting a compile time error. | > It's as if you try to export main, but don't define it. | > | > Have you had a look at | http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#foreign-export- | ghc | > ? | | | Interesting! I didn't see that section before, thanks a lot. | | -chris | | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe From vandijk.roel at gmail.com Mon Nov 2 06:16:45 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Mon Nov 2 05:53:01 2009 Subject: [Haskell-cafe] Re: ANN: haskell-mode 2.6 In-Reply-To: <221b53ab0911011614g25499d3asa0dc9af5fce505a7@mail.gmail.com> References: <221b53ab0911011120o37e79d37gfaa0928f31e1d46c@mail.gmail.com> <221b53ab0911011614g25499d3asa0dc9af5fce505a7@mail.gmail.com> Message-ID: Thanks for the update. I am using it now and am very happy with it! No more tabtabtabtabtab to properly indent something. I did notice a bug in the declaration scanning part. Blocks of haddock comments are parsed as code. Code like this: {-| bla bla bla -} will be parsed as a variable "bla". If you remove the pipe symbol "|" the comment is skipped. I though it would be an easy fix in the declaration scanner but my elisp-fu is too weak :-( This bug makes the nice imenu almost useless in well documented code. Otherwise I am a very happy user! Regards, Roel From bulat.ziganshin at gmail.com Mon Nov 2 06:21:00 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Nov 2 05:57:27 2009 Subject: [Haskell-cafe] Simple FAST lazy functional primes In-Reply-To: References: Message-ID: <206233628.20091102142100@gmail.com> Hello Will, Monday, November 2, 2009, 10:41:15 AM, you wrote: > (testing was done running the ghc -O3 compiled code inside GHCi). afaik, -O2 should be used -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From jochem at functor.nl Mon Nov 2 06:37:54 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Mon Nov 2 06:13:30 2009 Subject: [Haskell-cafe] hackage is down. In-Reply-To: <4AEE43E5.6090200@rkit.pp.ru> References: <910ddf450911010558q48e21c72sfcb12ed8105c8d86@mail.gmail.com> <20091101145916.GA7500@functor.nl> <4AEE18BF.9080602@gmx.net> <4AEE3B87.2020607@rkit.pp.ru> <4c44d90b0911011746pb9abeecu37cc436f593dd64e@mail.gmail.com> <4AEE43E5.6090200@rkit.pp.ru> Message-ID: <4AEEC492.1020508@functor.nl> ??????? ?????? wrote: > >> No no no! Why not download the normal (signed) cabal list from the >> DHT (and optionally directly from hackage.haskell.org)? These are all >> the packages that would appear on the website. Why serve any other >> content? All nodes in the DHT may check and make sure the file (or >> fragment) being served is properly signed. >> >> Any desire for popularity or tagging capability should be separate. >> > Because single single hackage private key can be bruteforsed or stolen > far easier than lots and lots keys of random people. You only need to compromise one well-trusted key to compromise the system. Cheers, Jochem -- Jochem Berndsen | jochem@functor.nl | jochem@????.com From dan.doel at gmail.com Mon Nov 2 07:18:39 2009 From: dan.doel at gmail.com (Dan Doel) Date: Mon Nov 2 06:55:00 2009 Subject: [Haskell-cafe] Re: ANN: haskell-mode 2.6 In-Reply-To: <221b53ab0911011345m13dd8bc9i7c010fb790b28fda@mail.gmail.com> References: <221b53ab0911011120o37e79d37gfaa0928f31e1d46c@mail.gmail.com> <221b53ab0911011345m13dd8bc9i7c010fb790b28fda@mail.gmail.com> Message-ID: <200911020718.39791.dan.doel@gmail.com> On Sunday 01 November 2009 4:45:58 pm Svein Ove Aas wrote: > On Sun, Nov 1, 2009 at 8:20 PM, Svein Ove Aas wrote: > > Fellow haskellers: > > > > Haskell-mode 2.6 has been released. > > Make that 2.6.1. Naturally, I broke something, but I think I'm about > out of things to break now. As it happens, the haskell-indentation mode (the new one) doesn't like hierarchical modules names. Something like: module Foo.Bar (\n will begin at the beginning of the line, complaining about there being an operator (the '.'). Though you may not have broken it. :) I can't recall if that happened previously or not. Cheers, -- Dan From jfredett at gmail.com Mon Nov 2 08:01:22 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Nov 2 07:37:41 2009 Subject: [Haskell-cafe] Re: Haskell Weekly News: Issue 137 - October 31, 2009 In-Reply-To: References: <4aebbf41.0703c00a.7ed8.ffffa4c8@mx.google.com> Message-ID: <6A37601A-8D49-4CFD-9045-99797040BB7E@gmail.com> It's not my fault you emacs-y people chose the wrong editor... :) /Joe On Nov 1, 2009, at 11:42 PM, Benjamin L.Russell wrote: > On Fri, 30 Oct 2009 21:38:25 -0700 (PDT), jfredett@gmail.com wrote: > >> >> ... a new version of >> haskell-mode for the lesser of two editors.... > ^^^^^^ >> >> [...] >> >> haskell-mode 2.5. Svein Ove Aas [14]announced a new version of >> haskell-mode for that other 'editor'... > ^ ^ > > Hey, careful now.... No need to start another Emacs vs. the other > 'editor' flamewar ... lest someone run "M-x nethack" and summon a > Demogorgon against you ... er, make that "M-x haskellhack," since a > Haskell version needs to be created. ;-) > > -- 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 From sjoerd at w3future.com Mon Nov 2 08:07:45 2009 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Mon Nov 2 07:44:04 2009 Subject: [Haskell-cafe] Simple FAST lazy functional primes In-Reply-To: References: Message-ID: <72A1955E-348C-4674-A3A8-F1A3F1050B3F@w3future.com> You can remove the "take k" step by passing along the list of primes smaller than p instead of k: primes = 2 : 3 : 5 : 7 : sieve [3, 2] (drop 2 primes) sieve qs@(q:_) (p:ps) = [x | x<-[q*q+2,q*q+4..p*p-2], and [(x`rem`p)/=0 | p<-qs]] ++ sieve (p:qs) ps I also removed the "x" parameter by generating it from the previous prime. But this also means you have to start at p=5 and q=3, because you want q*q+2 to be odd. Sjoerd On Nov 2, 2009, at 8:41 AM, Will Ness wrote: > > First, here it is: > > primes = 2: 3: sieve 0 primes' 5 > primes' = tail primes > sieve k (p:ps) x > = [x | x<-[x,x+2..p*p-2], and [(x`rem`p)/=0 | p<-take k > primes']] > ++ sieve (k+1) ps (p*p+2) > > (thanks to Leon P.Smith for his brilliant idea of directly generating > the spans of odds instead of calling 'span' on the infinite odds > list). > > This code is faster than PriorityQueue-based sieve (granted, using > my own > ad-hoc implementation, so YMMV) in producing the first million primes > (testing was done running the ghc -O3 compiled code inside GHCi). > The relative performance vs the PQ-version is: > > 100,000 300,000 1,000,000 primes produced > 0.6 0.75 0.97 > > I've recently came to the Melissa O'Neill's article (I know, I know) > and > she makes the incredible claim there that the square-of-prime > optimization > doesn't count if we want to improve the old and "lazy" > > uprimes = 2: sieve [3,5..] where > sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p > 0] > > Her article gave me the strong impression that she claims that the > only way > to fix this code is by using Priority Queue based optimization, and > then > goes on to present astronomical gains in speed by implementing it. > > Well, I find this claim incredible. First of all, the "naive" code > fires up > its nested filters much too early, when in fact each must be started > only > when the prime's square is reached (not only have its work started > there - > be started there itself!), so that filters are delayed: > > dprimes = 2: 3: sieve (tail dprimes) [5,7..] where > sieve (p:ps) xs > = h ++ sieve ps (filter ((/=0).(`rem`p)) (tail t)) > where (h,t)=span (< p*p) xs > > This code right there is on par with the PQ-base code, only x3-4 > slower at > generating the first million primes. > > Second, the implicit control structure of linearly nested filters, > piling up > in front of the supply stream, each with its prime-number-it-filters- > by > hidden inside it, needs to be explicated into a data structure of > primes-to-filter-by (which is in fact the prefix of the primes list > we're building itself), so the filtering could be done by one > function call > instead of many nested calls: > > xprimes = 2: 3: sieve 0 primes' [5,7..] where > primes' = tail xprimes > sieve k (p:ps) xs > = noDivs k h ++ sieve (k+1) ps (tail t) > where (h,t)=span (< p*p) xs > noDivs k = filter (\x-> all ((/=0).(x`rem`)) (take k primes')) > >> From here, using the brilliant idea of Leon P. Smith's of fusing >> the span > and the infinite odds supply, we arrive at the final version, > > kprimes = 2: 3: sieve 0 primes' 5 where > primes' = tail kprimes > sieve k (p:ps) x > = noDivs k h ++ sieve (k+1) ps (t+2) > where (h,t)=([x,x+2..t-2], p*p) > noDivs k = filter (\x-> all ((/=0).(x`rem`)) (take k primes')) > > Using the list comprehension syntax, it turns out, when compiled with > ghc -O3, gives it another 5-10% speedup itself. > > So I take it to disprove the central premise of the article, and to > show > that simple lazy functional FAST primes code does in fact exist, and > that the PQ optimization - which value of course no-one can dispute > - is > a far-end optimization. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Sjoerd Visscher sjoerd@w3future.com From vandijk.roel at gmail.com Mon Nov 2 08:41:27 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Mon Nov 2 08:17:43 2009 Subject: [Haskell-cafe] Re: ANN: haskell-mode 2.6 In-Reply-To: <221b53ab0911011345m13dd8bc9i7c010fb790b28fda@mail.gmail.com> References: <221b53ab0911011120o37e79d37gfaa0928f31e1d46c@mail.gmail.com> <221b53ab0911011345m13dd8bc9i7c010fb790b28fda@mail.gmail.com> Message-ID: I also thought of some font-lock symbols you could consider adding to haskell-font-lock.el: ;; Nice bottom symbol (cons "undefined" (decode-char 'ucs #X22A5)) ;; Small case pi symbol (cons "pi" (decode-char 'ucs #X3C0)) ;; This one is less serious (cons "unsafePerformIO" (decode-char 'ucs #X2620)) I don't know if the predicate in the list of font-lock symbols can express this condition, but it would be nice to be able to replace 'a' and 'b' in types with lowercase alpha (U003B1) and beta (U003B1) symbols. But only in the context of a type. Regards, Roel From sjoerd at w3future.com Mon Nov 2 08:56:33 2009 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Mon Nov 2 08:32:55 2009 Subject: [Haskell-cafe] Simple FAST lazy functional primes In-Reply-To: <72A1955E-348C-4674-A3A8-F1A3F1050B3F@w3future.com> References: <72A1955E-348C-4674-A3A8-F1A3F1050B3F@w3future.com> Message-ID: <4151EE32-0AC9-43DD-8FF5-BBCEEEFB9774@w3future.com> Excuse me, 2 doesn't have to be in the list of smaller primes, as we're only generating odd numbers: primes = 2 : 3 : 5 : 7 : sieve [3] (drop 2 primes) sieve qs@(q:_) (p:ps) = [x | x<-[q*q+2,q*q+4..p*p-2], and [(x`rem`p)/=0 | p<-qs]] ++ sieve (p:qs) ps Sjoerd On Nov 2, 2009, at 2:07 PM, Sjoerd Visscher wrote: > You can remove the "take k" step by passing along the list of primes > smaller than p instead of k: > > primes = 2 : 3 : 5 : 7 : sieve [3, 2] (drop 2 primes) > sieve qs@(q:_) (p:ps) > = [x | x<-[q*q+2,q*q+4..p*p-2], and [(x`rem`p)/=0 | p<-qs]] > ++ sieve (p:qs) ps > > I also removed the "x" parameter by generating it from the previous > prime. But this also means you have to start at p=5 and q=3, because > you want q*q+2 to be odd. > > Sjoerd > > On Nov 2, 2009, at 8:41 AM, Will Ness wrote: > >> >> First, here it is: >> >> primes = 2: 3: sieve 0 primes' 5 >> primes' = tail primes >> sieve k (p:ps) x >> = [x | x<-[x,x+2..p*p-2], and [(x`rem`p)/=0 | p<-take k >> primes']] >> ++ sieve (k+1) ps (p*p+2) >> >> (thanks to Leon P.Smith for his brilliant idea of directly generating >> the spans of odds instead of calling 'span' on the infinite odds >> list). >> >> This code is faster than PriorityQueue-based sieve (granted, using >> my own >> ad-hoc implementation, so YMMV) in producing the first million primes >> (testing was done running the ghc -O3 compiled code inside GHCi). >> The relative performance vs the PQ-version is: >> >> 100,000 300,000 1,000,000 primes produced >> 0.6 0.75 0.97 >> >> I've recently came to the Melissa O'Neill's article (I know, I >> know) and >> she makes the incredible claim there that the square-of-prime >> optimization >> doesn't count if we want to improve the old and "lazy" >> >> uprimes = 2: sieve [3,5..] where >> sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p > 0] >> >> Her article gave me the strong impression that she claims that the >> only way >> to fix this code is by using Priority Queue based optimization, and >> then >> goes on to present astronomical gains in speed by implementing it. >> >> Well, I find this claim incredible. First of all, the "naive" code >> fires up >> its nested filters much too early, when in fact each must be >> started only >> when the prime's square is reached (not only have its work started >> there - >> be started there itself!), so that filters are delayed: >> >> dprimes = 2: 3: sieve (tail dprimes) [5,7..] where >> sieve (p:ps) xs >> = h ++ sieve ps (filter ((/=0).(`rem`p)) (tail t)) >> where (h,t)=span (< p*p) xs >> >> This code right there is on par with the PQ-base code, only x3-4 >> slower at >> generating the first million primes. >> >> Second, the implicit control structure of linearly nested filters, >> piling up >> in front of the supply stream, each with its prime-number-it- >> filters-by >> hidden inside it, needs to be explicated into a data structure of >> primes-to-filter-by (which is in fact the prefix of the primes list >> we're building itself), so the filtering could be done by one >> function call >> instead of many nested calls: >> >> xprimes = 2: 3: sieve 0 primes' [5,7..] where >> primes' = tail xprimes >> sieve k (p:ps) xs >> = noDivs k h ++ sieve (k+1) ps (tail t) >> where (h,t)=span (< p*p) xs >> noDivs k = filter (\x-> all ((/=0).(x`rem`)) (take k primes')) >> >>> From here, using the brilliant idea of Leon P. Smith's of fusing >>> the span >> and the infinite odds supply, we arrive at the final version, >> >> kprimes = 2: 3: sieve 0 primes' 5 where >> primes' = tail kprimes >> sieve k (p:ps) x >> = noDivs k h ++ sieve (k+1) ps (t+2) >> where (h,t)=([x,x+2..t-2], p*p) >> noDivs k = filter (\x-> all ((/=0).(x`rem`)) (take k primes')) >> >> Using the list comprehension syntax, it turns out, when compiled with >> ghc -O3, gives it another 5-10% speedup itself. >> >> So I take it to disprove the central premise of the article, and to >> show >> that simple lazy functional FAST primes code does in fact exist, and >> that the PQ optimization - which value of course no-one can dispute >> - is >> a far-end optimization. >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- > Sjoerd Visscher > sjoerd@w3future.com > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Sjoerd Visscher sjoerd@w3future.com From ryani.spam at gmail.com Mon Nov 2 09:38:57 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Nov 2 09:15:11 2009 Subject: [Haskell-cafe] AND/OR Perceptron In-Reply-To: References: <69630b260910291227h3f3ff536q78ce1503ce72ca7a@mail.gmail.com> <4335a3260910291233l4cd0c74bh5c3a4485c111a650@mail.gmail.com> <69630b260910291332t294b81cdybd5688ba500a4938@mail.gmail.com> <2f9b2d30910311209l39bd51at8a9430d1c84fd0fd@mail.gmail.com> Message-ID: <2f9b2d30911020638j613fa558wf7d95467479e35ca@mail.gmail.com> I suppose I wasn't entirely clear. "where" is syntactic sugar for "let...in", pattern matching is syntactic sugar for "case", and guards are syntactic sugar for "if..then..else" and/or "case" (for pattern guards) In fact, the whole reason for the existence of "where" is so that it can attach at a higher-level scope and make use of the other syntactic sugar (like guards). Also, I find the postfix definitions in "where" to generally be more readable, but that is a matter of taste. -- ryan On Sat, Oct 31, 2009 at 11:33 AM, Chadda? Fouch? wrote: > On Sat, Oct 31, 2009 at 8:09 PM, Ryan Ingram wrote: > > > > "where" is just syntactic sugar for "let...in" > > That's not perfectly true : "where" and "let...in" don't attach to the > same syntactic construction, "where" attaches to a definition and can > works for several guard clauses whereas "let ... in expression" is an > expression in itself. > > -- > Jeda? > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091102/ebd6f9ee/attachment.html From svein.ove at aas.no Mon Nov 2 10:18:40 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Mon Nov 2 09:54:59 2009 Subject: [Haskell-cafe] Re: ANN: haskell-mode 2.6 In-Reply-To: <200911020718.39791.dan.doel@gmail.com> References: <221b53ab0911011120o37e79d37gfaa0928f31e1d46c@mail.gmail.com> <221b53ab0911011345m13dd8bc9i7c010fb790b28fda@mail.gmail.com> <200911020718.39791.dan.doel@gmail.com> Message-ID: <221b53ab0911020718m4decd3br710faf53d91d7381@mail.gmail.com> On Mon, Nov 2, 2009 at 1:18 PM, Dan Doel wrote: > On Sunday 01 November 2009 4:45:58 pm Svein Ove Aas wrote: >> On Sun, Nov 1, 2009 at 8:20 PM, Svein Ove Aas wrote: >> > Fellow haskellers: >> > >> > Haskell-mode 2.6 has been released. >> >> Make that 2.6.1. Naturally, I broke something, but I think I'm about >> out of things to break now. > > As it happens, the haskell-indentation mode (the new one) doesn't like > hierarchical modules names. Something like: > > ?module Foo.Bar (\n > > will begin at the beginning of the line, complaining about there being an > operator (the '.'). > > Though you may not have broken it. :) I can't recall if that happened > previously or not. > What seems to be going on is that haskell-indentation simply isn't prepared to deal with hierarchical module names at all, or qualified imports. The latter works because it interprets "Foo.bar" as actually using the operator (.), which it considers to be valid syntax. Operators are not valid in module statements, however. I'm going to try teaching it. Hopefully I won't break anything in the process. -- Svein Ove Aas From will_n48 at yahoo.com Mon Nov 2 10:42:08 2009 From: will_n48 at yahoo.com (Will Ness) Date: Mon Nov 2 10:18:41 2009 Subject: [Haskell-cafe] Re: Simple FAST lazy functional primes References: <72A1955E-348C-4674-A3A8-F1A3F1050B3F@w3future.com> <4151EE32-0AC9-43DD-8FF5-BBCEEEFB9774@w3future.com> Message-ID: Sjoerd Visscher w3future.com> writes: > [...] 2 doesn't have to be in the list of smaller primes, as > we're only generating odd numbers: > > primes = 2 : 3 : 5 : 7 : sieve [3] (drop 2 primes) > sieve qs@(q:_) (p:ps) > = [x | x<-[q*q+2,q*q+4..p*p-2], and [(x`rem`p)/=0 | p<-qs]] > ++ sieve (p:qs) ps > > Sjoerd Thanks! I haven't tested your code's speed yet, but have few points: i wouldn't expect eliminating a parameter to have any effect on performance in compiled code (I haven't a clue whether -O2 or -O3 should be used BTW) if it doesn't eliminate any superfluous computations. second, you prepend bigger primes in front of a list (building the prefix in reverse order); this will cause them to be tested against first. I think (1) we're supposed to test composites against smaller factors first, for the tests to stop sooner. IMO it'll slow the code down. I think (2) you can safely append them at the end instead, for a compiler should be able to just maintain a tail pointer there. But then you loose immediate access to the last found prime; so will need to return the 'x' parameter back. Then you end up with my code exactly :) (only replicating the prefix): primes = 2 : 3 : 5 : 7 : sieve [3] (drop 2 primes) 9 sieve pfx (p:ps) x = [x | x<-[x+2,x+4..p*p-2], and [(x`rem`p)/=0 | p<-pfx]] ++ sieve (pfx++[p]) ps (p*p) it'll be interesting to test my hypothesis (two of them :) ) and see if this has in fact better time than your code. thirdly, (take k) could be compiled out completely into a tail pointer too, maintained and advanced after each step. I would hope a smart compiler to do just that. Again, some more testing is in order. Although, I tested the two approaches on some previous incarnation of this code, and the (take k) vs (pfx++[p]) had exactly same run time (or was better). What I'm after mostly here, is for the code to be clear and simple, and reasonably efficient. Right now it corresponds very nicely to the description of the sieve as filtering all the odds testable by a known prefix of primes, and then going on to proceed with the next batch of them with a prefix that was grown by one more prime. And so on. But more importantly I want it to be known that there's a lot that can be done here, in a natural functional lazy kind of way, before resorting to priority queues and mutable arrays. We could always just use C too. ;) Thanks for the feedback! :) From will_n48 at yahoo.com Mon Nov 2 10:54:28 2009 From: will_n48 at yahoo.com (Will Ness) Date: Mon Nov 2 10:31:11 2009 Subject: [Haskell-cafe] Re: Simple FAST lazy functional primes References: <72A1955E-348C-4674-A3A8-F1A3F1050B3F@w3future.com> <4151EE32-0AC9-43DD-8FF5-BBCEEEFB9774@w3future.com> Message-ID: Will Ness yahoo.com> writes: > But more importantly I want it to be known that there's a lot that can be done > here, in a natural functional lazy kind of way, before resorting to priority > queues and mutable arrays. We could always just use C too. ;) I mean it as an introductory code that's nevertheless good for producing the first million primes or so - not the best sieve ever, but the best (is it?) simple clear functional introductory sieve, instead. That's another reason to using (take k primes') - it practically says it in English, "the first k odd primes". :) From jgbailey at gmail.com Mon Nov 2 11:10:02 2009 From: jgbailey at gmail.com (Justin Bailey) Date: Mon Nov 2 10:46:37 2009 Subject: [Haskell-cafe] Using HaskellDB on Tables that contain same column names In-Reply-To: <20091031103805.GB6469@terra.galaxy> References: <20091031103805.GB6469@terra.galaxy> Message-ID: I'd recommend sending HaskellDB questions to the haskelldb users mailing list. You do need to subscribe first. Now to your question: On Sat, Oct 31, 2009 at 2:38 AM, R. Emre Ba?ar wrote: > Hi all, > project (Server.name << s!Server.name # > ? ? ? ? Vendor.name << v!Vendor.name # > ? ? ? ? Model.name << m!Model.name # > ? ? ? ? Server.system_id << s!Server.system_id) > This is by design. Just like in SQL, the column names are not disambiguated. If you wrote a SQL query like: select * from Server join Model on ... join Vendor on ... you would get duplicate column names. You must use unique column names in the projection. Check out the haskelldb-th package for Template Haskell utils for easily creating column names if you don't want to declare them by hand. Justin From will_n48 at yahoo.com Mon Nov 2 11:11:53 2009 From: will_n48 at yahoo.com (Will Ness) Date: Mon Nov 2 10:48:19 2009 Subject: [Haskell-cafe] Re: Simple FAST lazy functional primes References: <72A1955E-348C-4674-A3A8-F1A3F1050B3F@w3future.com> <4151EE32-0AC9-43DD-8FF5-BBCEEEFB9774@w3future.com> Message-ID: Sjoerd Visscher w3future.com> writes: > > Excuse me, 2 doesn't have to be in the list of smaller primes, as > we're only generating odd numbers: > > primes = 2 : 3 : 5 : 7 : sieve [3] (drop 2 primes) > sieve qs@(q:_) (p:ps) > = [x | x<-[q*q+2,q*q+4..p*p-2], and [(x`rem`p)/=0 | p<-qs]] > ++ sieve (p:qs) ps > > Sjoerd > Hi, I've run it now. In producing 100,000 primes, your above code takes x3.5 more time than the one I posted. The code modified as I suggested with (qs++[p]) takes exactly the same time as mine. :) Cheers, From apfelmus at quantentunnel.de Mon Nov 2 11:15:51 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Mon Nov 2 10:52:34 2009 Subject: [Haskell-cafe] Re: Experiments with defunctionalization, church-encoding and CPS In-Reply-To: <49a77b7a0911011426h54625ffdn79d953fa266fd87c@mail.gmail.com> References: <5e0214850910130244rf0164d4k6144e8d6f07d022e@mail.gmail.com> <49a77b7a0911010910i5b9f5be5ya47fa538fef10951@mail.gmail.com> <49a77b7a0911011426h54625ffdn79d953fa266fd87c@mail.gmail.com> Message-ID: David Menendez wrote: > Heinrich Apfelmus wrote: >> David Menendez wrote: >>> Heinrich Apfelmus wrote: >>>> Even then, the results are mixed. The Church-encoding shines in GHCi as >>>> it should, but loses its advantage when the code is being compiled. I >>>> guess we have to look at the core if we want to know what exactly is >>>> going on. >> >>> What optimization level did you compile with? >> No optimization. > > Do you get the same results if you compile with -O2? Or does that > screw up criterion somehow? The results for the Church encodings are mostly the same, but now the algebraic data type is much faster. touch Test.hs; ghc --make Test.hs -o Test-O2 -O2 ./Test-O2 data Maybe mean: 23.99268 ms, lb 23.64836 ms, ub 24.43737 ms, ci 0.950 Church encoding mean: 146.0500 ms, lb 138.6242 ms, ub 154.0508 ms, ci 0.950 Church encoding optimised mean: 93.31060 ms, lb 90.34235 ms, ub 96.25145 ms, ci 0.950 Regards, apfelmus -- http://apfelmus.nfshost.com From sjoerd at w3future.com Mon Nov 2 11:24:58 2009 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Mon Nov 2 11:01:14 2009 Subject: [Haskell-cafe] Re: Simple FAST lazy functional primes In-Reply-To: References: <72A1955E-348C-4674-A3A8-F1A3F1050B3F@w3future.com> <4151EE32-0AC9-43DD-8FF5-BBCEEEFB9774@w3future.com> Message-ID: On Nov 2, 2009, at 5:11 PM, Will Ness wrote: > Sjoerd Visscher w3future.com> writes: > >> >> Excuse me, 2 doesn't have to be in the list of smaller primes, as >> we're only generating odd numbers: >> >> primes = 2 : 3 : 5 : 7 : sieve [3] (drop 2 primes) >> sieve qs@(q:_) (p:ps) >> = [x | x<-[q*q+2,q*q+4..p*p-2], and [(x`rem`p)/=0 | p<-qs]] >> ++ sieve (p:qs) ps >> >> Sjoerd >> > > Hi, > > I've run it now. In producing 100,000 primes, your above code takes > x3.5 more > time than the one I posted. Too bad. The order of the primes when filtering matters quite a lot! > The code modified as I suggested with (qs++[p]) > takes exactly the same time as mine. :) Yes, append and take are both O(n). Here's another variation which I rather like: primes = 2 : 3 : sieve (tail primes) (notDivides 3) 5 sieve (p:ps) test from = [x | x <- [from, from + 2 .. p * p - 2], test x] ++ sieve ps (\x -> test x && notDivides p x) (p * p + 2) notDivides d x = (x `rem` d) /= 0 I'm curious if GHC can compile this to the same speed as your code. -- Sjoerd Visscher sjoerd@w3future.com From svein.ove at aas.no Mon Nov 2 11:36:03 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Mon Nov 2 11:12:21 2009 Subject: [Haskell-cafe] Re: ANN: haskell-mode 2.6 In-Reply-To: <221b53ab0911020718m4decd3br710faf53d91d7381@mail.gmail.com> References: <221b53ab0911011120o37e79d37gfaa0928f31e1d46c@mail.gmail.com> <221b53ab0911011345m13dd8bc9i7c010fb790b28fda@mail.gmail.com> <200911020718.39791.dan.doel@gmail.com> <221b53ab0911020718m4decd3br710faf53d91d7381@mail.gmail.com> Message-ID: <221b53ab0911020836p3648f747x96100332b13823f0@mail.gmail.com> On Mon, Nov 2, 2009 at 4:18 PM, Svein Ove Aas wrote: > > I'm going to try teaching it. Hopefully I won't break anything in the process. > I have so taught. If you grab the latest darcs version, it should work. However, I won't be releasing this without further testing, so if you do - caveat emptor. -- Svein Ove Aas From will_n48 at yahoo.com Mon Nov 2 11:56:47 2009 From: will_n48 at yahoo.com (Will Ness) Date: Mon Nov 2 11:33:51 2009 Subject: [Haskell-cafe] Re: Simple FAST lazy functional primes References: <72A1955E-348C-4674-A3A8-F1A3F1050B3F@w3future.com> <4151EE32-0AC9-43DD-8FF5-BBCEEEFB9774@w3future.com> Message-ID: Sjoerd Visscher w3future.com> writes: > On Nov 2, 2009, at 5:11 PM, Will Ness wrote: > > > Hi, > > > > I've run it now. In producing 100,000 primes, your above code takes > > x3.5 more > > time than the one I posted. > > Too bad. The order of the primes when filtering matters quite a lot! Yep. Most of the composites will have mostly small prime factors, most of the time. :) An English paraphrase of the analysis from the paper, when she proves that whatever you do with composites, doesn't matter (in the _long_ run!) if you test primes for divisibility - because for primes we end up testing against _all_ of the primes in the prefix. This is exactly where her PQ code achieves its coup - it gets its primes for free when it checks its composites and sees the gap there. So the reason not to have these nested functions is to have all the logic represented in the open, in the data structure - here the list, still. PQ is a natural next step. Having a lot of linearly nested functions, there isn't a lot we can do with them. :) > > The code modified as I suggested with (qs++[p]) > > takes exactly the same time as mine. :) > > Yes, append and take are both O(n). I would hope 'append' to be O(1), and 'take' just translated into an upper limit of the testing loop in 'and'. > > Here's another variation which I rather like: > > primes = 2 : 3 : sieve (tail primes) (notDivides 3) 5 > sieve (p:ps) test from > = [x | x <- [from, from + 2 .. p * p - 2], test x] > ++ sieve ps (\x -> test x && notDivides p x) (p * p + 2) > notDivides d x = (x `rem` d) /= 0 > > I'm curious if GHC can compile this to the same speed as your code. It depends on whether it is as good at traversing function call frames at run time, as elements of a list. Or whether it uses the call frames at all, or is able to compile away all of it. :) From will_n48 at yahoo.com Mon Nov 2 12:03:43 2009 From: will_n48 at yahoo.com (Will Ness) Date: Mon Nov 2 11:40:52 2009 Subject: [Haskell-cafe] Re: Base classes can be _ELIMINATED_ with interfaces References: <4232.121.97.54.144.1257129548.squirrel@webmail4.pair.com> Message-ID: Shelby Moore coolpage.com> writes: > > * 1856 Thermo Law: entire universe (a closed system, i.e. everything) > trends to maximum disorder. > On the very, *very*, VERY long timescale. In the meantime, chaos creates clashes of matter, which cause local energy outbursts (i.e. galaxies), which pump their immediate surroundings, where natural selection in presence of energy influx leads to increasing complexity. To persist for a long, *long*, LONG time. From patai_gergely at fastmail.fm Mon Nov 2 12:48:47 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Mon Nov 2 12:25:01 2009 Subject: [Haskell-cafe] IORefs and weak pointers Message-ID: <1257184127.11636.1343178769@webmail.messagingengine.com> Hello all, I wanted to create a weak pointer with an IORef as the key and something else as the value, but I saw no way to do it through the API provided. After some experimentation I came up with the following abomination for a solution: myWeakRef (IORef (STRef r)) v f = IO $ \s -> case mkWeak# r v f s of (# s', w #) -> (# s', Weak w #) This works perfectly when the code is compiled both with and without optimisations, but ghci chokes on it with an internal error. So my question is if I can expect this to work at least this much in the long run, or is it a hopelessly fragile hack? Gergely -- http://www.fastmail.fm - Same, same, but different... From vanenkj at gmail.com Mon Nov 2 12:52:52 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon Nov 2 12:29:06 2009 Subject: [Haskell-cafe] IORefs and weak pointers In-Reply-To: <1257184127.11636.1343178769@webmail.messagingengine.com> References: <1257184127.11636.1343178769@webmail.messagingengine.com> Message-ID: Is the IORef or the value in the IORef your key? 2009/11/2 Patai Gergely > Hello all, > > I wanted to create a weak pointer with an IORef as the key and something > else as the value, but I saw no way to do it through the API provided. > After some experimentation I came up with the following abomination for > a solution: > > myWeakRef (IORef (STRef r)) v f = > IO $ \s -> case mkWeak# r v f s of (# s', w #) -> (# s', Weak w #) > > This works perfectly when the code is compiled both with and without > optimisations, but ghci chokes on it with an internal error. So my > question is if I can expect this to work at least this much in the long > run, or is it a hopelessly fragile hack? > > Gergely > > -- > http://www.fastmail.fm - Same, same, but different... > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091102/66522e5b/attachment.html From patai_gergely at fastmail.fm Mon Nov 2 13:10:21 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Mon Nov 2 12:46:34 2009 Subject: [Haskell-cafe] IORefs and weak pointers In-Reply-To: References: <1257184127.11636.1343178769@webmail.messagingengine.com> Message-ID: <1257185421.15446.1343184401@webmail.messagingengine.com> > Is the IORef or the value in the IORef your key? I want the IORef itself to be the key. However, that doesn't work with optimisations turned on (the pointers get wiped out at the first gc), I guess because they remove the box around the MutVar#. Extracting that MutVar# seems to solve the problem. Gergely -- http://www.fastmail.fm - mmm... Fastmail... From magnus at therning.org Mon Nov 2 13:41:58 2009 From: magnus at therning.org (Magnus Therning) Date: Mon Nov 2 13:18:12 2009 Subject: [Haskell-cafe] Hackage still down? Message-ID: It seems to have been down for at least the better part of today. Is it something worth worrying about? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From dons at galois.com Mon Nov 2 13:45:37 2009 From: dons at galois.com (Don Stewart) Date: Mon Nov 2 13:21:53 2009 Subject: [Haskell-cafe] Hackage still down? In-Reply-To: References: Message-ID: <20091102184537.GD8395@whirlpool.galois.com> magnus: > It seems to have been down for at least the better part of today. Is > it something worth worrying about? Summarising what we know: * The machine that hosts darcs.haskell.org and hackage.haskell.org, has an increasing number of uncorrectable errors on its RAID drives. * We will be purchasing a new server to replace monk. * In the meantime, we're doing what we can to get it back up (the disks are fscking at the moment). I'd expect it up shortly, and there will be an announcement about any downtime as a result of the new server migration. -- Don From gcross at phys.washington.edu Mon Nov 2 14:01:00 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Mon Nov 2 13:37:35 2009 Subject: [Haskell-cafe] Hackage still down? In-Reply-To: <20091102184537.GD8395@whirlpool.galois.com> References: <20091102184537.GD8395@whirlpool.galois.com> Message-ID: <87C3AD9E-E1C6-4364-9457-89ED67867179@phys.washington.edu> Of *course* your hard drives are getting damaged --- everyone knows that Raid only works on *real* bugs, not software bugs! Spraying it on your hard drives to improve the quality of the libraries on Hackage is just silly! - Greg On Nov 2, 2009, at 10:45 AM, Don Stewart wrote: > magnus: >> It seems to have been down for at least the better part of today. Is >> it something worth worrying about? > > Summarising what we know: > > * The machine that hosts darcs.haskell.org and > hackage.haskell.org, has an increasing number of uncorrectable > errors on its RAID drives. > > * We will be purchasing a new server to replace monk. > > * In the meantime, we're doing what we can to get it back up (the > disks are fscking at the moment). > > I'd expect it up shortly, and there will be an announcement about any > downtime as a result of the new server migration. > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jvranish at gmail.com Mon Nov 2 14:01:27 2009 From: jvranish at gmail.com (Job Vranish) Date: Mon Nov 2 13:37:43 2009 Subject: [Haskell-cafe] IORefs and weak pointers In-Reply-To: <1257184127.11636.1343178769@webmail.messagingengine.com> References: <1257184127.11636.1343178769@webmail.messagingengine.com> Message-ID: Could mkWeakPair do what you want? http://haskell.org/ghc/docs/latest/html/libraries/base/System-Mem-Weak.html#v:mkWeakPair Or are you trying to do something else? - Job 2009/11/2 Patai Gergely > Hello all, > > I wanted to create a weak pointer with an IORef as the key and something > else as the value, but I saw no way to do it through the API provided. > After some experimentation I came up with the following abomination for > a solution: > > myWeakRef (IORef (STRef r)) v f = > IO $ \s -> case mkWeak# r v f s of (# s', w #) -> (# s', Weak w #) > > This works perfectly when the code is compiled both with and without > optimisations, but ghci chokes on it with an internal error. So my > question is if I can expect this to work at least this much in the long > run, or is it a hopelessly fragile hack? > > Gergely > > -- > http://www.fastmail.fm - Same, same, but different... > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091102/3dbf50ef/attachment.html From magnus at therning.org Mon Nov 2 14:02:22 2009 From: magnus at therning.org (Magnus Therning) Date: Mon Nov 2 13:38:37 2009 Subject: [Haskell-cafe] Hackage still down? In-Reply-To: <20091102184537.GD8395@whirlpool.galois.com> References: <20091102184537.GD8395@whirlpool.galois.com> Message-ID: On Mon, Nov 2, 2009 at 7:45 PM, Don Stewart wrote: > magnus: >> It seems to have been down for at least the better part of today. ?Is >> it something worth worrying about? > > Summarising what we know: > > ? ?* The machine that hosts darcs.haskell.org and > ? ? ?hackage.haskell.org, has an increasing number of uncorrectable > ? ? ?errors on its RAID drives. > > ? ?* We will be purchasing a new server to replace monk. > > ? ?* In the meantime, we're doing what we can to get it back up (the > ? ? ?disks are fscking at the moment). > > I'd expect it up shortly, and there will be an announcement about any > downtime as a result of the new server migration. Excellent. Thanks for the update. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From westondan at imageworks.com Mon Nov 2 14:56:45 2009 From: westondan at imageworks.com (Dan Weston) Date: Mon Nov 2 14:33:05 2009 Subject: [Haskell-cafe] Applicative but not Monad In-Reply-To: <294434B3-5D60-4924-BAE6-B77CE68479BD@strictlypositive.org> References: <20091102001132.GA2027@soi.city.ac.uk> <294434B3-5D60-4924-BAE6-B77CE68479BD@strictlypositive.org> Message-ID: <4AEF397D.90307@imageworks.com> Obviously you know what your talking about and I don't, so this is a question purely out of ignorance. It seems to me that Tomorrow cannot be parametrically polymorphic, or else I could wrap it again (Tomorrow (Tomorrox x)). An unwrapping fixpoint operator needs to reflect the type to know when not to go too far. One solution is to guarantee that it can go as far as it wants with a comonad (stopping when the function argument wants to, not when the data type runs out of data): import Control.Comonad import Control.Monad.Fix tfix :: Comonad tomorrow => (tomorrow x -> x) -> x tfix = extract . (\f -> fix (extend f)) To quote Cabaret, if tomorrow belongs to me, then surely the day after belongs to me as well. Otherwise, to stop the fixpoint, it seems you need a more restricted type to encode some stopping sentinel (my own parametrically polymorphic attempts all end in infinite types, so maybe ad hoc polymorphism or a type witness is needed?) Do you have a blog post on this problem? Dan Conor McBride wrote: > On 2 Nov 2009, at 00:11, Ross Paterson wrote: > >> On Sun, Nov 01, 2009 at 04:20:18PM +0000, Conor McBride wrote: >>> On 31 Oct 2009, at 10:39, Conor McBride wrote: >>>> I have an example, perhaps not a datatype: >>>> tomorrow-you-will-know >>> Elaborating, one day later, >>> >>> if you know something today, you can arrange to know it tomorrow >>> if will know a function tomorrow and its argument tomorrow, you >>> can apply them tomorrow >>> but if you will know tomorrow that you will know something the >>> day after, that does not tell you how to know the thing tomorrow >> Yes, but if you will know tomorrow that you will know something >> tomorrow, then you will know that thing tomorrow. > > That depends on what "tomorrow" means tomorrow. > >> The applicative does coincide with a monad, just not the one you first >> thought of (or/max rather than plus). > > True, but it's not the notion I need to analyse circular programs. > I'm looking for something with a fixpoint operator > > fix :: (Tomorrow x -> x) -> x > > which I can hopefully use to define things like > > repmin :: Tree Int -> (Int, Tomorrow (Tree Int)) > > so that the fixpoint operator gives me a Tomorrow Int which I > can use to build the second component, but ensures that the > black-hole-tastic Tomorrow (Tomorrow (Tree Int)) I also receive > is too late to be a serious temptation. > > All the best > > Conor > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From patai_gergely at fastmail.fm Mon Nov 2 15:04:19 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Mon Nov 2 14:40:31 2009 Subject: [Haskell-cafe] IORefs and weak pointers In-Reply-To: References: <1257184127.11636.1343178769@webmail.messagingengine.com> Message-ID: <1257192259.939.1343203007@webmail.messagingengine.com> > Could mkWeakPair do what you want? > http://haskell.org/ghc/docs/latest/html/libraries/base/System-Mem-Weak.html#v:mkWeakPair No, it's just a convenience function that doesn't help much, because the value already refers to the IORef anyway. Here's a minimal example to illustrate the problem: import Data.IORef import Data.Maybe import System.Mem import System.Mem.Weak main = do ref <- newIORef 42 ptr <- mkWeak ref 21 Nothing performGC print . isNothing =<< deRefWeak ptr print =<< readIORef ref Depending on whether you compile with optimisations, the weak reference might be reported dead, even though the IORef is alive and kicking. Switching to mkWeakPair (or just mentioning ref in the value somehow) doesn't affect that. > Or are you trying to do something else? The goal is to create mutable objects whose update codes are tracked by the main program, but they can be thrown out when all the other references to the objects are lost. Creating weak pointers with MutVar#s seems to do the trick, but I'm not confident if it is a solution I can trust... Gergely -- http://www.fastmail.fm - A fast, anti-spam email service. From andrewcoppin at btinternet.com Mon Nov 2 15:23:45 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Nov 2 14:59:56 2009 Subject: [Haskell-cafe] Re: Haskell Weekly News: Issue 137 - October 31, 2009 In-Reply-To: References: <4aebbf41.0703c00a.7ed8.ffffa4c8@mx.google.com> Message-ID: <4AEF3FD1.7020403@btinternet.com> Benjamin L.Russell wrote: > Hey, careful now.... No need to start another Emacs vs. the other > 'editor' flamewar ... lest someone run "M-x nethack" and summon a > Demogorgon against you ... er, make that "M-x haskellhack," since a > Haskell version needs to be created. ;-) > Yes, because nobody truly believes your language is "fringe" until somebody implements an obscure text advanture game with it. ;-) From will_n48 at yahoo.com Mon Nov 2 15:59:07 2009 From: will_n48 at yahoo.com (Will Ness) Date: Mon Nov 2 15:35:51 2009 Subject: [Haskell-cafe] Re: Simple FAST lazy functional primes References: Message-ID: Will Ness yahoo.com> writes: > primes = 2: 3: sieve 0 primes' 5 > primes' = tail primes > sieve k (p:ps) x > = [x | x <- [x,x+2..p*p-2], > and [(x`rem`p)/=0 | p <- take k primes']] > ++ sieve (k+1) ps (p*p+2) > > (thanks to Leon P.Smith for his brilliant idea of directly generating > the spans of odds instead of calling 'span' on the infinite odds list). > > The relative performance vs the PQ-version is: > > 100,000 300,000 1,000,000 primes produced > 0.6 0.75 0.97 > One _crucial_ tidbit I've left out: _type_signature_. Adding (:: [Int]) speeds this code up more than TWICE! :) :) 'sieve' can also be used in e.g. primesFrom m = sieve (length h) ps m where (h,(_:ps)) = span (<= (floor.sqrt.fromIntegral) m) primes to get few big primes even faster. :) From dagit at codersbase.com Mon Nov 2 16:10:12 2009 From: dagit at codersbase.com (Jason Dagit) Date: Mon Nov 2 15:46:24 2009 Subject: [Haskell-cafe] Re: Simple FAST lazy functional primes In-Reply-To: References: Message-ID: On Mon, Nov 2, 2009 at 1:59 PM, Will Ness wrote: > Will Ness yahoo.com> writes: > > > primes = 2: 3: sieve 0 primes' 5 > > primes' = tail primes > > sieve k (p:ps) x > > = [x | x <- [x,x+2..p*p-2], > > and [(x`rem`p)/=0 | p <- take k primes']] > > ++ sieve (k+1) ps (p*p+2) > > > > (thanks to Leon P.Smith for his brilliant idea of directly generating > > the spans of odds instead of calling 'span' on the infinite odds list). > > > > The relative performance vs the PQ-version is: > > > > 100,000 300,000 1,000,000 primes produced > > 0.6 0.75 0.97 > > > > One _crucial_ tidbit I've left out: _type_signature_. > > Adding (:: [Int]) speeds this code up more than TWICE! > > :) :) > If you are okay with Int, then maybe you're also happy with Int32 or Word32. If so, why don't you use template haskell to build the list at compile time? If you do that, then getting the kth prime at run-time is O(k). Take that AKS! :) Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091102/bbf9bb7c/attachment.html From will_n48 at yahoo.com Mon Nov 2 16:40:10 2009 From: will_n48 at yahoo.com (Will Ness) Date: Mon Nov 2 16:16:53 2009 Subject: [Haskell-cafe] Re: Simple FAST lazy functional primes References: Message-ID: Jason Dagit codersbase.com> writes: > On Mon, Nov 2, 2009 at 1:59 PM, Will Ness yahoo.com> wrote: > Will Ness yahoo.com> writes: > > One _crucial_ tidbit I've left out: _type_signature_. > Adding (:: [Int]) speeds this code up more than TWICE! > :) :) > > > If you are okay with Int, then maybe you're also happy with Int32 or Word32. ?If so, why don't you use template haskell to build the list at compile time? ?If you do that, then getting the kth prime at run-time is O(k). ?Take that AKS! ?:) > O(k), I've removed it since the post actually. Wasn't thinking clearly for a moment, having seen the double speedup! I've found Matthew Brecknell's fast code in old Melissa O'Neill's article here from 2007-02-19 18:14:23 GMT. Without the type signature, it's twice slower than my code. I think it is a fairly faithful translation now of what the sieve is all about, except that it tests its candidate numbers whereas sieve counts over them (and thus is able to skip over primes without testing them). The usual functional approach has it working with each number in isolation, so tests it (to recreate counting state in effect), thus overworks much on primes. Next logical step is to start counting! :) > Jason > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From felipe.lessa at gmail.com Mon Nov 2 16:42:43 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Mon Nov 2 16:19:02 2009 Subject: [Haskell-cafe] Re: Simple FAST lazy functional primes In-Reply-To: References: Message-ID: <20091102214243.GA21611@kira.casa> On Mon, Nov 02, 2009 at 02:10:12PM -0700, Jason Dagit wrote: > If you are okay with Int, then maybe you're also happy with Int32 or Word32. > If so, why don't you use template haskell to build the list at compile > time? If you do that, then getting the kth prime at run-time is O(k). Take > that AKS! :) Silly you! If he's into TH than he may just create an -- god forbid -- array and get the kth prime in O(1). :) -- Felipe. From shelby at coolpage.com Mon Nov 2 17:11:33 2009 From: shelby at coolpage.com (Shelby Moore) Date: Mon Nov 2 16:47:48 2009 Subject: [Haskell-cafe] Re: Suggested algorithm to control upper bound of space "leaks" In-Reply-To: <4355.121.97.54.144.1257135806.squirrel@webmail4.pair.com> References: <1182.121.97.54.144.1257026037.squirrel@webmail4.pair.com> <4346.121.97.54.144.1257135314.squirrel@webmail4.pair.com> <4355.121.97.54.144.1257135806.squirrel@webmail4.pair.com> Message-ID: <4814.121.97.54.144.1257199893.squirrel@webmail4.pair.com> Simon Marlow replied: http://www.haskell.org/pipermail/cvs-ghc/2009-November/050946.html ============= Also I received privately a very much appreciated and stimulating reply about the convolution of the competition for the shared resources in the external state machine. My quick (not deeply thought out) response is that the algorithm's target is not fixed (not a hard-coded upper bound), but rather the algorithm should be a gradient search for the local minima (which will always be a moving target, but that is okay). The problem is when it gets stuck in some local minima that is far from the global minima (e.g. some cycling resonance with the external competition), so to the degree that is a common, we occasionally we need to test some random position in the solution space (simulated annealing). That is analogous to how autonomous actors optimize problems in real-world, e.g. humans in their interaction with their shared reality with other actors, they bite off some goal and go for it, then they scrap the goal if it is useless local minima. In short, we trade speed of convergence for determinism of convergence, i.e. in annealing (very slow cooling), then ice has fewer cracks. (I learned this stuff 20+ years ago from reading about one model of how neural networks can learn and converge). So yes I agree that the nondeterminism can still creep back in as aliasing error in the algorithm's sampling for a global solution. But according to the fundamental theorems of the universe ( http://www.haskell.org/pipermail/haskell-cafe/2009-November/068432.html ), nothing is every finally optimized (except that "faith exists") to a globally closed solution (even if you have closed solution mathematical model which says it is, i.e. space-time did not finalize the later inconsistency of quantum theory), i.e. there is no global solution in life only a relative one (there is always some more complex external state, i.e. the universe trends to maximum disorder). But the practical motivation is that to the degree the gradient search is reasonably more deterministic in common usage (see my "KEY POINT" in response to Simon Marlow as for why I think that is likely achievable), then the space nondeterminism should in theory scale more continuously more often. Regarding the private point about overbooking, since the CPU is much faster than the hard disk, it should be true that even if the paging load is 100% of CPU allocation, then the CPU is not overbooked. And if the paging load is so overbooked due to competiting actors, you might as well just turn off your machine :). And I agree with the private point that the gradient search algorithm should incorporate a gradient reduction in it's velocity towards the target as it approaches the target minima, i.e. that systems do not perform reliabily if resource allocation strategies are edge discontinuous. I disagree that the programmer/user needs to be burdened with this, as is the case now. I am arguing it should be automatic, unless the programmer wants to do space profile optimization work. Maybe I am very wrong. It is research after all. From shelby at coolpage.com Mon Nov 2 18:00:15 2009 From: shelby at coolpage.com (Shelby Moore) Date: Mon Nov 2 17:36:29 2009 Subject: [Haskell-cafe] Re: Suggested algorithm to control upper bound of space "leaks" In-Reply-To: <4814.121.97.54.144.1257199893.squirrel@webmail4.pair.com> References: <1182.121.97.54.144.1257026037.squirrel@webmail4.pair.com> <4346.121.97.54.144.1257135314.squirrel@webmail4.pair.com> <4355.121.97.54.144.1257135806.squirrel@webmail4.pair.com> <4814.121.97.54.144.1257199893.squirrel@webmail4.pair.com> Message-ID: <4837.121.97.54.144.1257202815.squirrel@webmail4.pair.com> > stimulating reply > about the convolution of the competition for the shared resources in the > external state machine. Apparently the concurrency problem is potentially convolved with external state in much more convoluted and intertwinded spaghetti: http://lambda-the-ultimate.org/node/2048#comment-51673 http://lambda-the-ultimate.org/node/3637#comment-51649 Multi-core is coming! Wouldn't it be better if the mainstream scripting (i.e. composability) language was also pure FP (and the composable modules were pure FP). If it costs 4X slower (lose 3/4 of) performance (and I doubt it would be any where near that bad) on keeping some of the thunks closures around so that scripting doesn't require masters degree in profiling, but we can remain in pure FP and minimize our STM usage (which also purportedly costs 4X), then if we hit 8+ cores then perfomance has improved, not to mention all the other benefits. Okay I realize that napkin calculation can't possibly encompass the details, but just make a conceptual point. From shelby at coolpage.com Mon Nov 2 18:47:54 2009 From: shelby at coolpage.com (Shelby Moore) Date: Mon Nov 2 18:24:08 2009 Subject: [Haskell-cafe] Base classes can be _ELIMINATED_ with interfaces In-Reply-To: <4483.121.97.54.144.1257142003.squirrel@webmail4.pair.com> References: <4232.121.97.54.144.1257129548.squirrel@webmail4.pair.com> <4279.121.97.54.144.1257131565.squirrel@webmail4.pair.com> <4483.121.97.54.144.1257142003.squirrel@webmail4.pair.com> Message-ID: <4867.121.97.54.144.1257205674.squirrel@webmail4.pair.com> > Shelby Moore wrote: >> ...A "type class" is a polymorphic >> (relative to data type) interface, and the polymorphism is strictly >> parameterized for the client/consumer of the interface, i.e. the data >> type >> is known to the function that inputs the interface AT COMPILE TIME. > >>...A problem with virtual (runtime pointer) inheritance is that it hides >> the subclass from the compiler. > > > I emphasize that in Haskell, the consuming function knows the interface at > compile time (or it can allow the compiler to infer it, if no type class > restriction is specified). Caveat follows. The fundamental theorems I mentioned ( http://www.haskell.org/pipermail/haskell-cafe/2009-November/068432.html ), can not be voided by any programming language that is Turing complete. Thus, it is no surprise that dynamic run-time typing is achievable in Haskell[1], basically a punt of the attempt of strict typing exponential local order (which the theorems predict _MUST_ happen in some cases, unless there is no state diagram), to run-time nondeterminism due to Liskov Substitution Principle (and Linsky Referencing). Alas (good news!), local exponential order wins in vast majority of common use cases in Haskell because it is also possible to use static compile-time typing[1], which I assert is because the static typing architecture is granular and orthogonal. [1] http://research.microsoft.com/en-us/um/people/simonpj/papers/papers.html#language http://research.microsoft.com/en-us/um/people/simonpj/papers/hmap/gmap3.pdf Ralf Laemmel and Simon Peyton Jones. "Scrap your boilerplate: a practical approach to generic programming", Proc ACM SIGPLAN Workshop on Types in Language Design and Implementation (TLDI 2003), New Orleans, pp26-37, Jan 2003 From dagit at codersbase.com Mon Nov 2 18:48:37 2009 From: dagit at codersbase.com (Jason Dagit) Date: Mon Nov 2 18:24:50 2009 Subject: [Haskell-cafe] Re: Simple FAST lazy functional primes In-Reply-To: References: Message-ID: On Mon, Nov 2, 2009 at 2:40 PM, Will Ness wrote: > Jason Dagit codersbase.com> writes: > > > On Mon, Nov 2, 2009 at 1:59 PM, Will Ness yahoo.com> > wrote: > > Will Ness yahoo.com> writes: > > > > One _crucial_ tidbit I've left out: _type_signature_. > > Adding (:: [Int]) speeds this code up more than TWICE! > > :) :) > > > > > > If you are okay with Int, then maybe you're also happy with Int32 or > Word32. > If so, why don't you use template haskell to build the list at compile > time? > If you do that, then getting the kth prime at run-time is O(k). Take that > AKS! :) > > > > > O(k), I've removed it since the post actually. Wasn't thinking clearly for > a > moment, having seen the double speedup! > By the way, do you understand where the speedup with Int is coming from? As I understand it, there are two main places. One is that the type class dictionary passing can be removed (GHC might figure this out already, I'd need to check the core to be sure). The other is that GHC is likely unboxing to it's primitive Int# type. If none of that made sense, or you'd like to know how you can double check what I'm talking about, then Real-World Haskell has a chapter with an example: http://book.realworldhaskell.org/read/profiling-and-optimization.html Good luck! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091102/75e34028/attachment.html From jwlato at gmail.com Mon Nov 2 19:17:04 2009 From: jwlato at gmail.com (John Lato) Date: Mon Nov 2 18:53:17 2009 Subject: [Haskell-cafe] advice for dispatch question Message-ID: <9979e72e0911021617g6d51b055od7d57560c5f469d9@mail.gmail.com> Hello, I've been thinking about a problem recently, and would like to know if there are any recommendations for a solution. I have two container-like type classes, defined as follows: > import Control.Monad > > type family ElemOf c :: * > type family MonadOf c :: * -> * > > class PureContainer c where > chead :: c -> ElemOf c > > class MonadicContainer c where > mhead :: c -> MonadOf c (ElemOf c) now suppose I have two functions, like this: > pureOp :: (PureContainer c, Monad m) => c -> m () > pureOp c = doSomethingWithElem $ chead c > > monadOp :: (Monad (MonadOf c), MonadicContainer c) => c -> MonadOf c () > monadOp c = mhead c >>= doSomethingWithElem > > -- assume this function does something > doSomethingWithElem :: Monad m => a -> m () > doSomethingWithElem _ = return () the goal is to take the head from either a PureContainer or a MonadicContainer and feed it to the doSomethingWithElem function, which we can assume does something monadic. What I would like to do would be write one function that behaves like this quasi-Haskell: combinedOp :: c -> m () combinedOp | PureContainer c = doSomethingWithElem $ chead c combinedOp | MonadicContainer c = mhead c >>= doSomethingWithElem I have many functions under consideration, and it would be nice to not have to duplicate all of them. So far I've thought of two possible solutions: 1. create a newtype > newtype M s (m :: * -> *) = M{ unM :: s} then I can write > type instance ElemOf (M c m) = ElemOf c > type instance MonadOf (M c m) = m > > instance (Monad m, PureContainer c) => MonadicContainer (M c m) where > mhead = return . chead . unM In this case, I would ignore the PureContainer case of combinedOp and just stick every PureContainer of interest into the newtype as necessary. 2. Use a GADT with two constructors to special-case appropriately. I think this should work, but haven't tried it yet. It seems more complicated, and less transparent, than using a newtype as above. Does anyone have any advice for this situation? I'm defining PureContainer instances anyway, so it seems silly to have to duplicate everything for the monadic case. Likewise the MonadicContainer version is highly desirable for certain types, so I don't want to forgo that either. Thanks, John From shelby at coolpage.com Mon Nov 2 19:28:34 2009 From: shelby at coolpage.com (Shelby Moore) Date: Mon Nov 2 19:04:47 2009 Subject: [Haskell-cafe] Re: Base classes can be _ELIMINATED_ with interfaces In-Reply-To: References: <4232.121.97.54.144.1257129548.squirrel@webmail4.pair.com> Message-ID: <4891.121.97.54.144.1257208114.squirrel@webmail4.pair.com> > Shelby Moore writes: >> * 1856 Thermo Law: entire universe (a closed system, i.e. everything) >> trends to maximum disorder. >> > > Will Ness wrote: > On the very, *very*, VERY long timescale. I love your ascii art :) Note I put it last in the list for reason. Not to be combative, but your statement encapsulates a common fallacy (even though you have not stated an error). Although it is true the exponential local orders are randomly[1] created while (actually necessary ingredient in[2]) breaking down of global order on the universal trend towards maximum disorder, these are occurring simultaneously with infinite cases of exponential decay[1]. Haskell may end up being a good example of success (rising up out of the OOP "failures"): http://www.haskell.org/pipermail/haskell-cafe/2009-November/068481.html The fallacy is rooted in the concept that time is an absolute reference point, but remember that Eistein ignored the complex of the Lorentz Equations. [1] Doesn't seem like random until you consider all the failures you didn't read about. [2] I have a good theory about what knowledge is, and it is precisely the exponential deviation from the Bell Curve (yet even any knowledge succumbs to the Theorems and exponentially decays eventually[3])-- just deviating is failure, but deviating is success if also suck the Bell Curve towards you at exponential rate: http://www.coolpage.com/commentary/economic/shelby/Bell%20Curve%20Economics.html (Theory of Everything is near the end, and I have since refined it at my blog, but I have not published a coherent paper yet). I am just sharing, not professing, so flame if you want, and I won't be offended. [3]Time is shared reality, that is why we can say "eventually" or long, *long*, LONG time, if the shared experience is stable, then the knowledge has a long exponential stability. But there is new knowledge competing all the time. Small things can grow faster-- oak trees don't grow to the moon. There are infinite simultaneous realities going on right now out there (due to permutations of interactions) between billions of humans. Thus we can say thus far that Bill Gates was much more knowledgeable (if our shared reality is the mainstream one) than proponents of pure FP, because he moved more shared reality exponentially. I am trying to bring a key piece of knowledge to the mix that might change that: http://www.haskell.org/pipermail/haskell-cafe/2009-November/068436.html http://www.haskell.org/pipermail/haskell-cafe/2009-November/068479.html > In the meantime, chaos creates clashes of matter, which cause local energy > outbursts (i.e. galaxies), which pump their immediate surroundings, where > natural selection in presence of energy influx leads to increasing > complexity. Agreed as I described above. > > To persist for a long, *long*, LONG time. It depends what you mean by persist. For example the a fiat world reserve currency (first ever in history of world, i.e. dollar) persisted since 1971, but probably won't exist beyond 2020 at best: http://goldwetrust.up-with.com/economics-f4/what-is-money-t44-15.htm#2177 While one widely shared perception is peaking and rotting, another one is smoldering and ready to do the 50% pond covered in the 30th day of the Lily's month maturity. And besides, there isn't just one reality at any time. Time is itself just an arbitrary perception. This is why Bible's logarithmic time scale can jive with carbon dating, ... (move it to my blog if you want to discuss further)... off topic of this list... From magicloud.magiclouds at gmail.com Mon Nov 2 20:29:56 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Mon Nov 2 20:06:09 2009 Subject: [Haskell-cafe] How to convert records into Haskell structure in Haskell way? Message-ID: <3bd412d40911021729q607513a4o2fe9808cb8c1a9a4@mail.gmail.com> Hi, Say I have something like this: [ Record { item = "A1", value = "0" } , Record { item = "B1", value = "13" } , Record { item = "A2", value = "2" } , Record { item = "B2", value = "10" } ] How to convert it into: [ XXInfo { name = "A", value1 = "0", value2 = "2" } , XXInfo { name = "B", value1 = "13", value2 = "10" } ] If XXInfo has a lot of members. And sometimes the original data might be not integrity. -- ??????? ??????? From daniel.is.fischer at web.de Mon Nov 2 20:55:45 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Nov 2 20:33:22 2009 Subject: [Haskell-cafe] How to convert records into Haskell structure in Haskell way? In-Reply-To: <3bd412d40911021729q607513a4o2fe9808cb8c1a9a4@mail.gmail.com> References: <3bd412d40911021729q607513a4o2fe9808cb8c1a9a4@mail.gmail.com> Message-ID: <200911030255.46598.daniel.is.fischer@web.de> Am Dienstag 03 November 2009 02:29:56 schrieb Magicloud Magiclouds: > Hi, > Say I have something like this: > [ Record { item = "A1", value = "0" } > , Record { item = "B1", value = "13" } > , Record { item = "A2", value = "2" } > , Record { item = "B2", value = "10" } ] > How to convert it into: > [ XXInfo { name = "A", value1 = "0", value2 = "2" } > , XXInfo { name = "B", value1 = "13", value2 = "10" } ] > If XXInfo has a lot of members. And sometimes the original data > might be not integrity. Could you be a little more specific about what you want to achieve? As a first guess, you might use something like import Data.List import Data.Ord (comparing) import Data.Function (on) sortedRecords = sortBy (comparing item) records recordGroups = groupBy ((==) `on` (head . item)) sortedRecords -- now comes the tricky part, converting the groups to XXinfo -- if all groups are guaranteed to have the appropriate number of -- elements, you can use xxInfo [Record (c:_) v1, Record _ v2] = XXinfo [c] v1 v2 -- and then xxInfos = map xxInfo recordGroups -- if the groups may have different numbers of elements, it's going to be uglier From magicloud.magiclouds at gmail.com Mon Nov 2 21:06:58 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Mon Nov 2 20:43:11 2009 Subject: [Haskell-cafe] How to convert records into Haskell structure in Haskell way? In-Reply-To: <200911030255.46598.daniel.is.fischer@web.de> References: <3bd412d40911021729q607513a4o2fe9808cb8c1a9a4@mail.gmail.com> <200911030255.46598.daniel.is.fischer@web.de> Message-ID: <3bd412d40911021806lb3682a5jc1d74fe0297a0105@mail.gmail.com> This is pretty much it, with one thing left. I got the original data from outside. Out of no reason, the data could be incomplete. For example, XXInfo has two members, this is the correct case. But the data I got may only contain only one member's information, with the other one totally lost. Kind like: [ Record { item = "A1", value = "0" } ] This is not a legal XXInfo, I have to deal with it. Plus, there are 28 members of XXInfo, so xxInfo of yours would be very ugly. On Tue, Nov 3, 2009 at 9:55 AM, Daniel Fischer wrote: > Am Dienstag 03 November 2009 02:29:56 schrieb Magicloud Magiclouds: >> Hi, >> ? Say I have something like this: >> [ Record { item = "A1", value = "0" } >> , Record { item = "B1", value = "13" } >> , Record { item = "A2", value = "2" } >> , Record { item = "B2", value = "10" } ] >> ? How to convert it into: >> [ XXInfo { name = "A", value1 = "0", value2 = "2" } >> , XXInfo { name = "B", value1 = "13", value2 = "10" } ] >> ? If XXInfo has a lot of members. And sometimes the original data >> might be not integrity. > > Could you be a little more specific about what you want to achieve? > > As a first guess, you might use something like > > import Data.List > import Data.Ord (comparing) > import Data.Function (on) > > sortedRecords = sortBy (comparing item) records > > recordGroups = groupBy ((==) `on` (head . item)) sortedRecords > > -- now comes the tricky part, converting the groups to XXinfo > -- if all groups are guaranteed to have the appropriate number of > -- elements, you can use > xxInfo [Record (c:_) v1, Record _ v2] = XXinfo [c] v1 v2 > > -- and then > > xxInfos = map xxInfo recordGroups > > -- if the groups may have different numbers of elements, it's going to be uglier > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- ??????? ??????? From qdunkan at gmail.com Mon Nov 2 21:38:33 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Mon Nov 2 21:14:46 2009 Subject: [Haskell-cafe] How to convert records into Haskell structure in Haskell way? In-Reply-To: <3bd412d40911021729q607513a4o2fe9808cb8c1a9a4@mail.gmail.com> References: <3bd412d40911021729q607513a4o2fe9808cb8c1a9a4@mail.gmail.com> Message-ID: <2518b95d0911021838g4647e889xfd2c162ef3f00ca5@mail.gmail.com> On Mon, Nov 2, 2009 at 5:29 PM, Magicloud Magiclouds wrote: > Hi, > ?Say I have something like this: > [ Record { item = "A1", value = "0" } > , Record { item = "B1", value = "13" } > , Record { item = "A2", value = "2" } > , Record { item = "B2", value = "10" } ] > ?How to convert it into: > [ XXInfo { name = "A", value1 = "0", value2 = "2" } > , XXInfo { name = "B", value1 = "13", value2 = "10" } ] > ?If XXInfo has a lot of members. And sometimes the original data > might be not integrity. This is a function from my library that I use a lot: -- | Group the unsorted list into @(key x, xs)@ where all @xs@ compare equal -- after @key@ is applied to them. List is returned in sorted order. keyed_group_with :: (Ord b) => (a -> b) -> [a] -> [(b, [a])] keyed_group_with key = map (\gs -> (key (head gs), gs)) . groupBy ((==) `on` key) . sortBy (compare `on` key) -- You can use it thus, Left for errors of course: to_xx records = map convert (keyed_group_with item records) where convert (name, [Record _ v1, Record _ v2]]) = Right (XXInfo name v1 v2) convert (name, records) = Left (name, records) From scooter.phd at gmail.com Mon Nov 2 21:47:22 2009 From: scooter.phd at gmail.com (Scott Michel) Date: Mon Nov 2 21:23:36 2009 Subject: [Haskell-cafe] How to convert records into Haskell structure in Haskell way? In-Reply-To: <2518b95d0911021838g4647e889xfd2c162ef3f00ca5@mail.gmail.com> References: <3bd412d40911021729q607513a4o2fe9808cb8c1a9a4@mail.gmail.com> <2518b95d0911021838g4647e889xfd2c162ef3f00ca5@mail.gmail.com> Message-ID: <258cd3200911021847m7e3a2817x6954f607c353f2a@mail.gmail.com> You might want to look at the code out there that processes command line options by creating record setting functions, which then are foldl'-ed to create an updated structure. See http://leiffrenzel.de/papers/commandline-options-in-haskell.html at the bottom of the page. I suspect you can easily create a conversion function (of functions) that does what you want. On Mon, Nov 2, 2009 at 6:38 PM, Evan Laforge wrote: > On Mon, Nov 2, 2009 at 5:29 PM, Magicloud Magiclouds > wrote: > > Hi, > > Say I have something like this: > > [ Record { item = "A1", value = "0" } > > , Record { item = "B1", value = "13" } > > , Record { item = "A2", value = "2" } > > , Record { item = "B2", value = "10" } ] > > How to convert it into: > > [ XXInfo { name = "A", value1 = "0", value2 = "2" } > > , XXInfo { name = "B", value1 = "13", value2 = "10" } ] > > If XXInfo has a lot of members. And sometimes the original data > > might be not integrity. > > This is a function from my library that I use a lot: > > -- | Group the unsorted list into @(key x, xs)@ where all @xs@ compare > equal > -- after @key@ is applied to them. List is returned in sorted order. > keyed_group_with :: (Ord b) => (a -> b) -> [a] -> [(b, [a])] > keyed_group_with key = map (\gs -> (key (head gs), gs)) > . groupBy ((==) `on` key) . sortBy (compare `on` key) > > -- You can use it thus, Left for errors of course: > > to_xx records = map convert (keyed_group_with item records) > where > convert (name, [Record _ v1, Record _ v2]]) = Right (XXInfo name v1 v2) > convert (name, records) = Left (name, records) > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091102/c8ad28ec/attachment.html From robgreayer at gmail.com Tue Nov 3 00:30:51 2009 From: robgreayer at gmail.com (Robert Greayer) Date: Tue Nov 3 00:07:04 2009 Subject: [Haskell-cafe] ANN: BlogLiterately-0.2 Message-ID: <4ec472cb0911022130v4fe98b48ib92fbd70cd5b1a35@mail.gmail.com> Due to overwhelming popular demand*, BlogLiterately (version 0.2) has been released on Hackage. It's a simple tool for uploading posts written in markdown and (optionally) literate Haskell to web logs. It relies heavily on Pandoc for markdown processing, but adds a few twists like syntax highlighting via hscolour. The original version was described here: http://greayer.wordpress.com/2009/10/26/blogging-literately-in-haskell/ The new version (the first version on hackage) has been updated a bit -- to take advantage of Pandoc highlighting extensions and to support blog categories, mainly. The primary documentation is just the haskell package page: http://hackage.haskell.org/package/BlogLiterately It's only been tested with a WordPress blog (mine) but ought to work with any blogging software that supports the MetaWeblog API. Send bug reports, etc. to me... Thanks! * -- 2 people asked -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091103/59797e18/attachment.html From dan.doel at gmail.com Tue Nov 3 00:39:52 2009 From: dan.doel at gmail.com (Dan Doel) Date: Tue Nov 3 00:16:11 2009 Subject: [Haskell-cafe] Applicative but not Monad In-Reply-To: <4AEF397D.90307@imageworks.com> References: <294434B3-5D60-4924-BAE6-B77CE68479BD@strictlypositive.org> <4AEF397D.90307@imageworks.com> Message-ID: <200911030039.52861.dan.doel@gmail.com> On Monday 02 November 2009 2:56:45 pm Dan Weston wrote: > It seems to me that Tomorrow cannot be parametrically polymorphic, or > else I could wrap it again (Tomorrow (Tomorrox x)). An unwrapping > fixpoint operator needs to reflect the type to know when not to go too > far. One solution is to guarantee that it can go as far as it wants with > a comonad (stopping when the function argument wants to, not when the > data type runs out of data): He isn't worried about people putting things off; he's worried about people using things sooner than they're ready. So: > import Control.Comonad > import Control.Monad.Fix > > tfix :: Comonad tomorrow => (tomorrow x -> x) -> x > tfix = extract . (\f -> fix (extend f)) This doesn't achieve his goals, because: tfix extract tries to get the 'x' from tomorrow and give it to you today, which is bad, and of course: tfix extract = extract (fix (extend extract)) = extract (fix id) = extract _|_ =? _|_ Rather, the aim is to give you a promise of something tomorrow, so that you can build a structure made of something today, followed by something tomorrow. That is, roughly, enforcing the productive construction of a circular object. Such a productive process is given the object 'in the future', and it must produce something now, followed (in time) by operations on the future whole. And the problem with monads is that Tomorrow (Tomorrow x) is something that happens in two days, but join is supposed to make it happen tomorrow instead. > To quote Cabaret, if tomorrow belongs to me, then surely the day after > belongs to me as well. > > Otherwise, to stop the fixpoint, it seems you need a more restricted > type to encode some stopping sentinel (my own parametrically polymorphic > attempts all end in infinite types, so maybe ad hoc polymorphism or a > type witness is needed?) > > Do you have a blog post on this problem? He does, in fact: http://www.e-pig.org/epilogue/?p=186 Cheers, -- Dan From gour at gour-nitai.com Tue Nov 3 03:55:21 2009 From: gour at gour-nitai.com (Gour) Date: Tue Nov 3 03:31:41 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows References: <25908187.post@talk.nabble.com> <25917670.post@talk.nabble.com> <5D2B35D8-1377-4C01-B9E7-4F15C43819BE@phys.washington.edu> <7b501d5c0910160229h21e61073wd6ba78ef8e11d463@mail.gmail.com> <8A5A333D-32FE-42F8-A4CF-2BDD7A20F4AC@phys.washington.edu> Message-ID: <20091103095521.487d3a2e@gaura-nitai.no-ip.org> On Fri, 16 Oct 2009 10:41:05 -0700 >>>>>> "Gregory" == >>>>>> wrote: Hi Greg, Gregory> While Emacs has some outline capabilities, they are not at Gregory> this time remotely as nice or as powerful as Leo, which among Gregory> other things: Do you use Leo for Haskell development? I've asked on Leo list about support for Haskell and Emacs, but no reply so far. IIRC, Emacs can be used as Leo's external editor, right? Sincerely, Gour -- Gour | Hlapicina, Croatia | GPG key: F96FF5F6 ---------------------------------------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091103/84e17930/signature.bin From gcross at phys.washington.edu Tue Nov 3 04:21:53 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Tue Nov 3 03:58:25 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows In-Reply-To: <20091103095521.487d3a2e@gaura-nitai.no-ip.org> References: <25908187.post@talk.nabble.com> <25917670.post@talk.nabble.com> <5D2B35D8-1377-4C01-B9E7-4F15C43819BE@phys.washington.edu> <7b501d5c0910160229h21e61073wd6ba78ef8e11d463@mail.gmail.com> <8A5A333D-32FE-42F8-A4CF-2BDD7A20F4AC@phys.washington.edu> <20091103095521.487d3a2e@gaura-nitai.no-ip.org> Message-ID: Gour, Yes, I use Leo for Haskell development. You will need to use the development trunk, though, since it contains a necessary patch I submitted to make Leo work correctly with Haskell sources. You can download this from Launchpad: https://launchpad.net/leo-editor It is possible to use Emacs as the external editor. I don't remember the exact procedure off the top of my head, but the idea is that you enable the emacs plugin inside Leo, set your installation of emacs to start the emacs server (so that emacsclient can connect to it), and then when you double-click on a node it sends the node to emacs via. emacsclient and when you save the buffer is sent back to Leo. One caveat with this is that Leo has a newer Qt-based GUI and an older Tk- based GUI, and I don't know if the plugin works with the Qt-based GUI yet. You can tell Leo to use the Tk GUI by specifying "--gui=Tk" on the command line --- i.e., "python launchLeo.py --gui=Tk". Hope this helps! - Greg On Nov 3, 2009, at 12:55 AM, Gour wrote: > On Fri, 16 Oct 2009 10:41:05 -0700 >>>>>>> "Gregory" == >>>>>> wrote: > > Hi Greg, > > Gregory> While Emacs has some outline capabilities, they are not at > Gregory> this time remotely as nice or as powerful as Leo, which among > Gregory> other things: > > Do you use Leo for Haskell development? > > I've asked on Leo list about support for Haskell and Emacs, but no > reply so far. > > IIRC, Emacs can be used as Leo's external editor, right? > > > Sincerely, > Gour > > -- > > Gour | Hlapicina, Croatia | GPG key: F96FF5F6 > ---------------------------------------------------------------- > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From stevech1097 at yahoo.com.au Tue Nov 3 04:45:56 2009 From: stevech1097 at yahoo.com.au (Steve) Date: Tue Nov 3 04:17:00 2009 Subject: [Haskell-cafe] Re: Simple FAST lazy functional primes In-Reply-To: <20091103000458.54A6932478D@www.haskell.org> References: <20091103000458.54A6932478D@www.haskell.org> Message-ID: <1257241556.2098.87.camel@localhost> Hi Will, I had previously tested the Melissa O'Neil prime function (using the primes 0.1.1 package) and found it to be fast (for a functional approach), but with high memory use. To fully test a prime function, I think you should: 1. Test for more than the first 10^6 primes. Generating all primes to 10^6 is quite easy for modern computers. Most prime generating functions will run in less than 1 sec and look fast. Try generating all primes to 10^7 and 10^8 then you will see how 'fast' these lazy functional methods really are. 2. Measure memory use. As you move above 10^6 and test primes up to 10^7, 10^8, and 10^9, memory use becomes very important. A prime function with excessive memory use will soon consume all of the system's memory. Here's another primes function which performs quite well. primes :: [Int] primes = 2 : filter (isPrime primes) [3,5..] where isPrime (p:ps) n | mod n p == 0 = False | p*p > n = True | otherwise = isPrime ps n isPrime [] _ = False -- never used, but avoids compiler warning Here's some results from my PC, for generating primes to 10^8. 10**6 10**7 10**8 secs MiB secs MiB secs MiB ------------------------------- 1 0.01 0 0.1 2 2 14 2 0.56 7 11.1 43 270 306 3 0.61 7 11.8 44 260 342 4 0.43 36 5.4 345 900 not finished 1 using a Haskell ST Array 2 your primes function 3 my primes function, listed above 4 Melissa O'Neil method from primes 0.1.1 package To summarise the results from the tests I've run: - if you want fast functional primes, forget it, its not possible. - if you just want fast primes, then use C, or a Haskell array. - if performance does not matter and slow primes are acceptable, then use the purely functional approach. Regards, Steve From apfelmus at quantentunnel.de Tue Nov 3 04:45:28 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Tue Nov 3 04:22:04 2009 Subject: [Haskell-cafe] Re: Lecture Notes Advanced Functional programming available In-Reply-To: <9e5767b0910181056i6609579bn2060bc14d99d6bc6@mail.gmail.com> References: <9e5767b0910181056i6609579bn2060bc14d99d6bc6@mail.gmail.com> Message-ID: Warren Henning wrote: > $83 and "3-4 weeks" for a 300 page book? Oy vey. Yeah, I'm not going to buy it. :( Regards, apfelmus -- http://apfelmus.nfshost.com From phi500ac at yahoo.ca Tue Nov 3 06:15:03 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Tue Nov 3 05:51:15 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows In-Reply-To: Message-ID: <581589.80982.qm@web58804.mail.re1.yahoo.com> I tryed it, and noticed that it is very slow, compared both with Emacs, TextPad, and Emerald. I tryed also leksah, but it is always complaining about something missing in Pango, although it works fine. Here is the error message (leksah.exe:1588): Pango-WARNING **: error opening config file '"C:\Arquivos de Programas\Leksah\etc\pango\pangorc': Invalid argument --- On Tue, 11/3/09, Gregory Crosswhite wrote: From: Gregory Crosswhite Subject: Re: [Haskell-cafe] Re: Best Editor In Windows To: "Gour" Cc: haskell-cafe@haskell.org Received: Tuesday, November 3, 2009, 2:21 AM Gour, Yes, I use Leo for Haskell development.? You will need to use the development trunk, though, since it contains a necessary patch I submitted to make Leo work correctly with Haskell sources.???You can download this from Launchpad: ??? https://launchpad.net/leo-editor It is possible to use Emacs as the external editor.? I don't remember the exact procedure off the top of my head, but the idea is that you enable the emacs plugin inside Leo, set your installation of emacs to start the emacs server (so that emacsclient can connect to it), and then when you double-click on a node it sends the node to emacs via. emacsclient and when you save the buffer is sent back to Leo.? One caveat with this is that Leo has a newer Qt-based GUI and an older Tk-based GUI, and I don't know if the plugin works with the Qt-based GUI yet.? You can tell Leo to use the Tk GUI by specifying "--gui=Tk" on the command line --- i.e., "python launchLeo.py --gui=Tk". Hope this helps! - Greg On Nov 3, 2009, at 12:55 AM, Gour wrote: > On Fri, 16 Oct 2009 10:41:05 -0700 >>>>>>> "Gregory" == >>>>>> wrote: > > Hi Greg, > > Gregory> While Emacs has some outline capabilities, they are not at > Gregory> this time remotely as nice or as powerful as Leo, which among > Gregory> other things: > > Do you use Leo for Haskell development? > > I've asked on Leo list about support for Haskell and Emacs, but no > reply so far. > > IIRC, Emacs can be used as Leo's external editor, right? > > > Sincerely, > Gour > > -- > Gour? | Hlapicina, Croatia? | GPG key: F96FF5F6 > ---------------------------------------------------------------- > _______________________________________________ > 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 __________________________________________________________________ The new Internet Explorer? 8 - Faster, safer, easier. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091103/dd8ab6b9/attachment.html From will_n48 at yahoo.com Tue Nov 3 06:36:38 2009 From: will_n48 at yahoo.com (Will Ness) Date: Tue Nov 3 06:13:13 2009 Subject: [Haskell-cafe] Re: Simple FAST lazy functional primes References: Message-ID: Jason Dagit codersbase.com> writes: > By the way, do you understand where the speedup with Int is coming from? ?As I understand it, there are two main places. ?One is that the type class dictionary passing can be removed (GHC might figure this out already, I'd need to check the core to be sure). ?The other is that GHC is likely unboxing to it's primitive Int# type. > [...] > Good luck! > Jason Thanks! Writing the super-fast sieve wasn't my objective here though. It rather was writing the fastest possible simple functional lazy code true to the sieve's definition, and understanding it better that way (that's the added bonus). As it stands now, this code seems a rather faithful description of what _is_ sieve, except that it tests each number in isolation instead of counting over a bunch of them at once (skipping over primes, getting them for free). THAT's the crucial difference, which the article seems trying to explain but never quite gets it in such simple terms. All the extra activity is kept to absolute minimum here, and _now_ the main thing can be dealt with further, if so desired - like turning to using the PQ thing, etc. Then if we were to compare them, it wouldn't be like comparing apples with orange juice. :) That's what it felt like, seeing the PQ code compared with the classic "naive" version in that article. I'm reasonably sure that PQ-augmented, this code will be even faster, not slower, even for the first million primes. This whole experience proves it that the clearest code can also be the fastest (and may be necessarily so). Seeing it described in that article as if clarity must be paid for with efficiency (and vice versa), didn't seem right to me. Cheers, > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ekirpichov at gmail.com Tue Nov 3 07:02:46 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Tue Nov 3 06:38:58 2009 Subject: [Haskell-cafe] ANN: timeplot - a program for visualizing time series from log files Message-ID: <5e0214850911030402w79d79736w6f6b019966f84111@mail.gmail.com> Hi. I've released timeplot on hackage: http://hackage.haskell.org/package/timeplot Timeplot is a program for visualizing time series from log files. The typical usage scenario: - Take a big log file of your program (100k-1m lines is OK) - Preprocess it with an awk one-liner to obtain a trace for timeplot - Plot the trace with timeplot, telling it which chart type (one of 8) to use for each "track" of the trace. For example, you can plot the frequencies of response times falling into 0..100ms, 100..500ms, 500..1000ms and >1000ms over 5-minute time intervals, or plot their 25% and 50% quantiles. - Behold the resulting graphics and discover anomalies and interesting process interdependencies in your program. Take a look at the description with lots of pretty pictures and a tutorial: http://www.haskell.org/haskellwiki/Timeplot -- Eugene Kirpichov Web IR developer, market.yandex.ru From nccb2 at kent.ac.uk Tue Nov 3 07:45:42 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Tue Nov 3 07:22:02 2009 Subject: [Haskell-cafe] Are all arrows functors? Message-ID: <4AF025F6.2020200@kent.ac.uk> Hi, I was thinking about some of my code today, and I realised that where I have an arrow in my code, A b c, the type (A b) is also a functor. The definition is (see http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Arrow.html): fmap = (^<<) -- Or, in long form: fmap f x = arr f <<< x Out of curiosity, and since this is a typical haskell-cafe question, does this definition of fmap hold for all arrows? And is there a wiki page somewhere that has a table of all of these Haskell type-classes (Functor, Monad, Category, Arrow, Applicative and so on), and says that if you are an instance of class A you must have some corresponding instance of B? (e.g. all Monads are Functors and Applicatives) I'm fairly certain my arrow isn't a Monad or Applicative, although of course it must be a Category, given the type-class dependency, but it would be nice when using one of these things to see what other instances you should automatically supply. Thanks, Neil. From ekirpichov at gmail.com Tue Nov 3 07:48:57 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Tue Nov 3 07:25:09 2009 Subject: [Haskell-cafe] Are all arrows functors? In-Reply-To: <4AF025F6.2020200@kent.ac.uk> References: <4AF025F6.2020200@kent.ac.uk> Message-ID: <5e0214850911030448s1343ca9bq439dbeacf972b5d5@mail.gmail.com> 2009/11/3 Neil Brown : > Hi, > > I was thinking about some of my code today, and I realised that where I have > an arrow in my code, A b c, the type (A b) is also a functor. ?The > definition is (see > http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Arrow.html): > > fmap = (^<<) > -- Or, in long form: > fmap f x = arr f <<< x > > Out of curiosity, and since this is a typical haskell-cafe question, does > this definition of fmap hold for all arrows? > > And is there a wiki page somewhere that has a table of all of these Haskell > type-classes (Functor, Monad, Category, Arrow, Applicative and so on), and > says that if you are an instance of class A you must have some corresponding > instance of B? (e.g. all Monads are Functors and Applicatives) ?I'm fairly > certain my arrow isn't a Monad or Applicative, although of course it must be > a Category, given the type-class dependency, but it would be nice when using > one of these things to see what other instances you should automatically > supply. > What about the Typeclassopedia (http://haskell.org/sitewiki/images/8/85/TMR-Issue13.pdf)? > Thanks, > > Neil. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From lemming at henning-thielemann.de Tue Nov 3 08:24:22 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Nov 3 07:58:40 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: control-monad-exception 0.5 with monadic call traces In-Reply-To: References: Message-ID: <4AF02F06.2030105@henning-thielemann.de> Jose Iborra schrieb: > Folks, > > I'm happy to announce a new release of control-monad-exception with > monadic call traces, > available in Hackage. Grab it now while it is still online! > > Monadic stack traces are described in detail in a blog post [1]. > > In short, what this means for your code is the ability to generate > errors like this: > > 500 Internal Server Error > The CGI server failed with the following error: > DeleteException (BmPK 2009-10-26 19:39:51.031297 UTC "Testing RPO") > in deleteBenchmarkFromPK, > NarradarBenchmarkDB(src/NarradarBenchmarkDB.hs): (186, 44) > deleteBenchmarkFromPK, > NarradarBenchmarkDB(src/NarradarBenchmarkDB.hs): (186, 25) > deleteBenchmarkFromPK, > NarradarBenchmarkDB(src/NarradarBenchmarkDB.hs): (184, 17) > deleteBenchmarkFromPK, > NarradarBenchmarkDB(src/NarradarBenchmarkDB.hs): (180, 90) > deleteTests, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): > (108, 3) > deleteTests, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): > (106, 20) > cgiMain, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): (52, 33) > cgiMain, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): (52, 30) > cgiMain, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): (50, 9) > cgiMain, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): (46, 11) Sure, this is a nice functionality. But isn't it about debugging, not exception handling? Internal Server Error means to me, the server has a bug, thus we want to know, how to reproduce it, thus the stack trace. For handling expected irregularites, what exceptions are, you would not need that, right? From nicolas.pouillard at gmail.com Tue Nov 3 08:26:45 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Tue Nov 3 08:02:56 2009 Subject: [Haskell-cafe] Are all arrows functors? In-Reply-To: <4AF025F6.2020200@kent.ac.uk> References: <4AF025F6.2020200@kent.ac.uk> Message-ID: <1257254743-sup-8857@peray> Excerpts from Neil Brown's message of Tue Nov 03 13:45:42 +0100 2009: > Hi, > > I was thinking about some of my code today, and I realised that where I > have an arrow in my code, A b c, the type (A b) is also a functor. The > definition is (see > http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Arrow.html): > > fmap = (^<<) > -- Or, in long form: > fmap f x = arr f <<< x > > Out of curiosity, and since this is a typical haskell-cafe question, > does this definition of fmap hold for all arrows? Yes, as shown by the 'WrappedArrow' newtype: http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Applicative.html#t%3AWrappedMonad -- Nicolas Pouillard http://nicolaspouillard.fr From tphyahoo at gmail.com Tue Nov 3 08:59:50 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Tue Nov 3 08:36:02 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: control-monad-exception 0.5 with monadic call traces In-Reply-To: <4AF02F06.2030105@henning-thielemann.de> References: <4AF02F06.2030105@henning-thielemann.de> Message-ID: <910ddf450911030559g42fb13d2ia75df75f1370bbf8@mail.gmail.com> When using happstack, I find it really annoying to get a Prelude.head: null list error (or similar) in my web browser window because somewhere, some library used something unsafe -- and of course, since this is haskell, no stack trace. if c-m-e can offer benefits around this, I would be very interested in adopting it. thomas. 2009/11/3 Henning Thielemann : > Jose Iborra schrieb: >> Folks, >> >> I'm happy to announce a new release of control-monad-exception with >> monadic call traces, >> available in Hackage. Grab it now while it is still online! >> >> Monadic stack traces are described in detail in a blog post [1]. >> >> In short, what this means for your code is the ability to generate >> errors like this: >> >> 500 Internal Server Error >> The CGI server failed with the following error: >> DeleteException (BmPK 2009-10-26 19:39:51.031297 UTC "Testing RPO") >> ?in deleteBenchmarkFromPK, >> NarradarBenchmarkDB(src/NarradarBenchmarkDB.hs): (186, 44) >> ? ? deleteBenchmarkFromPK, >> NarradarBenchmarkDB(src/NarradarBenchmarkDB.hs): (186, 25) >> ? ? deleteBenchmarkFromPK, >> NarradarBenchmarkDB(src/NarradarBenchmarkDB.hs): (184, 17) >> ? ? deleteBenchmarkFromPK, >> NarradarBenchmarkDB(src/NarradarBenchmarkDB.hs): (180, 90) >> ? ? deleteTests, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): >> (108, 3) >> ? ? deleteTests, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): >> (106, 20) >> ? ? cgiMain, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): (52, 33) >> ? ? cgiMain, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): (52, 30) >> ? ? cgiMain, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): (50, 9) >> ? ? cgiMain, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): (46, 11) > > Sure, this is a nice functionality. But isn't it about debugging, not > exception handling? Internal Server Error means to me, the server has a > bug, thus we want to know, how to reproduce it, thus the stack trace. > For handling expected irregularites, what exceptions are, you would not > need that, right? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From pepeiborra at gmail.com Tue Nov 3 08:59:57 2009 From: pepeiborra at gmail.com (Jose Iborra) Date: Tue Nov 3 08:36:13 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: control-monad-exception 0.5 with monadic call traces In-Reply-To: <4AF02F06.2030105@henning-thielemann.de> References: <4AF02F06.2030105@henning-thielemann.de> Message-ID: On 03/11/2009, at 14:24, Henning Thielemann wrote: > Jose Iborra schrieb: >> Folks, >> >> I'm happy to announce a new release of control-monad-exception with >> monadic call traces, >> available in Hackage. Grab it now while it is still online! >> >> Monadic stack traces are described in detail in a blog post [1]. >> >> In short, what this means for your code is the ability to generate >> errors like this: >> >> 500 Internal Server Error >> The CGI server failed with the following error: >> DeleteException (BmPK 2009-10-26 19:39:51.031297 UTC "Testing RPO") >> in deleteBenchmarkFromPK, >> NarradarBenchmarkDB(src/NarradarBenchmarkDB.hs): (186, 44) >> deleteBenchmarkFromPK, >> NarradarBenchmarkDB(src/NarradarBenchmarkDB.hs): (186, 25) >> deleteBenchmarkFromPK, >> NarradarBenchmarkDB(src/NarradarBenchmarkDB.hs): (184, 17) >> deleteBenchmarkFromPK, >> NarradarBenchmarkDB(src/NarradarBenchmarkDB.hs): (180, 90) >> deleteTests, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): >> (108, 3) >> deleteTests, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): >> (106, 20) >> cgiMain, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): (52, >> 33) >> cgiMain, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): (52, >> 30) >> cgiMain, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): (50, >> 9) >> cgiMain, NarradarBenchmarkCGI(src/NarradarBenchmarkCGI.hs): (46, >> 11) > > Sure, this is a nice functionality. But isn't it about debugging, not > exception handling? Internal Server Error means to me, the server > has a > bug, thus we want to know, how to reproduce it, thus the stack trace. > For handling expected irregularites, what exceptions are, you would > not > need that, right? > This is about error handling and reporting. Catching an exception does not tell you where the exception comes from, in the same way that a "head of empty list" error does not point at the source of the error. You need a stack trace to know that. So the output above, generated by a regular exception handler > cgiMain > `catchWithSrcLoc` > \loc e@SomeException{} -> > outputInternalServerError [ "The Narradar CGI server failed with the following error:" > , showExceptionWithTrace loc e] gives you that kind of information. What you do with the stack trace, printing it (currently it is simply a list of Strings) or something else, is your choice. Thanks, pepe From will_n48 at yahoo.com Tue Nov 3 09:34:58 2009 From: will_n48 at yahoo.com (Will Ness) Date: Tue Nov 3 09:11:39 2009 Subject: [Haskell-cafe] Re: Simple FAST lazy functional primes References: <20091103000458.54A6932478D@www.haskell.org> <1257241556.2098.87.camel@localhost> Message-ID: Hi Steve, Steve yahoo.com.au> writes: > > Hi Will, > > I had previously tested the Melissa O'Neil prime function (using the > primes 0.1.1 package) and found it to be fast (for a functional > approach), but with high memory use. > > To fully test a prime function, I think you should: > 1. Test for more than the first 10^6 primes. > Generating all primes to 10^6 is quite easy for modern computers. Most > prime generating functions will run in less than 1 sec and look fast. > Try generating all primes to 10^7 and 10^8 then you will see how 'fast' > these lazy functional methods really are. > 2. Measure memory use. > As you move above 10^6 and test primes up to 10^7, 10^8, and 10^9, > memory use becomes very important. A prime function with excessive > memory use will soon consume all of the system's memory. > > Here's another primes function which performs quite well. > > primes :: [Int] > primes = 2 : filter (isPrime primes) [3,5..] where > isPrime (p:ps) n > | mod n p == 0 = False > | p*p > n = True > | otherwise = isPrime ps n > isPrime [] _ = False -- never used, but avoids compiler warning > > Here's some results from my PC, for generating primes to 10^8. > > 10**6 10**7 10**8 > secs MiB secs MiB secs MiB > ------------------------------- > 1 0.01 0 0.1 2 2 14 > 2 0.56 7 11.1 43 270 306 > 3 0.61 7 11.8 44 260 342 > 4 0.43 36 5.4 345 900 not finished > > 1 using a Haskell ST Array > 2 your primes function > 3 my primes function, listed above > 4 Melissa O'Neil method from primes 0.1.1 package > > To summarise the results from the tests I've run: > - if you want fast functional primes, forget it, its not possible. > - if you just want fast primes, then use C, or a Haskell array. > - if performance does not matter and slow primes are acceptable, then > use the purely functional approach. > > Regards, > Steve > you just have a fast PC that's all, :) so a million is not enough for you. My old laptop is 50 times slower. :) Seriously though, your conclusions seem entirely plausible to me. My goal here was to have a Haskell code for primes, that is decent. Nothing more. The reason your code is slightly slower is of course that in effect it recalculates the needed primes prefix for each new candidate. If you could somehow thread its length through, it might have sped it up some more. I've just tried it and it was twice slower than mine. (?) I didn't use the [Int] signature in both. Maybe it's not real issues we're dealing with here, but compiler/OS/CPU issues? (or have you've forgotten to put the [Int] signature into my code too, when tested? It runs twice as fast with it). Although your code has an advantage that it is very easy to add the wheel optimization to it. BTW I don't know about the code in the package, but the one in the article makes terrible faux-pas of adding each prime into the queue as soon as it is produced; this could easily account for a memory blow-up you're seeing. What's really needed, is to plug a decent PQ implementation into my framework, which does absolute minimum of repeated calculations it seems. What I have now, is this: qprimes = 2: 3: sieve emptyQ primes' 5 where primes' = tail qprimes sieve q (p:ps) x = h ++ sieve (addQ q' (2*p) (p*p+2*p)) ps (p*p+2) where (h,q') = noComps q [x,x+2..p*p-2] ...... The main deficiency of list-based sieves, as I've now came to realize and formulate in simple enough terms for myself to understand, is that they work with each number in isolation, and thus must test primes as well as composites. Testing composites on average is cheap, because most of them will have small factors; testing primes is costly. Imperative sieves avoid that by working over spans of numbers at once, so they get their primes for free, when they "see" gaps in produced/marked composites (I repeat myself here, but am not sure if you've read this my explanation in other posts). What counts here, is the direct access to random memory - or the numbers written out on a blackboard. Melissa's PQ approach tries to emulate that. Not crossing them off, but seeing the gaps in between. One is tempted to treat Haskell as high-level executable definition, hoping for a compiler to turn it into the fastest possible low-level code. I know I can translate it into C by hand fairly well; why wouldn't the compiler? It seems Haskell compilers have much room for improvement. :) From svein.ove at aas.no Tue Nov 3 09:56:50 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Tue Nov 3 09:33:02 2009 Subject: [Haskell-cafe] Re: ANN: haskell-mode 2.6 In-Reply-To: <221b53ab0911011120o37e79d37gfaa0928f31e1d46c@mail.gmail.com> References: <221b53ab0911011120o37e79d37gfaa0928f31e1d46c@mail.gmail.com> Message-ID: <221b53ab0911030656y7159695m860ebd0919084f46@mail.gmail.com> On Sun, Nov 1, 2009 at 8:20 PM, Svein Ove Aas wrote: > Fellow haskellers: > > Haskell-mode 2.6 has been released. > 2.6.2 is now out. This is a pure bugfix release; it fixes some parse issues in haskell-decl-scan and haskell-indentation. -- Svein Ove Aas From agocorona at gmail.com Tue Nov 3 10:57:00 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Tue Nov 3 10:33:12 2009 Subject: [Haskell-cafe] socket error Message-ID: : hPutBuf: illegal operation (handle is finalized) I?m a bit lost trying to find the source of this error. I?m running an hack application (package hack). Basically it is a handler of web requests. hack can be used with different web servers: Hyena, simpleserver, HappStack.... all of them produce this error after a few interactions., Supposedly, it happens within the socket module since neither my module, nor hack, nor the hack simpleserver (package hack-handler-simpleserver) call explicitly hPutBuf I tried to reproduce the error under linux, but my ubuntu installation is too old and I?m in the process of reinstalling everything again. In the meantime, Any of you can give me any hint about the error? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091103/d7e742e0/attachment.html From agocorona at gmail.com Tue Nov 3 11:16:06 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Tue Nov 3 10:52:19 2009 Subject: [Haskell-cafe] Re: socket error In-Reply-To: References: Message-ID: I?m running windows, ghc 6.10.3 and 6.10.4 in two different machines. 2009/11/3 Alberto G. Corona > : hPutBuf: illegal operation (handle is finalized) > > I?m a bit lost trying to find the source of this error. > I?m running an hack application (package hack). Basically it is a handler > of web requests. > hack can be used with different web servers: Hyena, simpleserver, > HappStack.... > all of them produce this error after a few interactions., Supposedly, it > happens within the socket module > since neither my module, nor hack, nor the hack simpleserver (package > hack-handler-simpleserver) call explicitly hPutBuf > > I tried to reproduce the error under linux, but my ubuntu installation is > too old and I?m in the process of reinstalling everything again. > > In the meantime, Any of you can give me any hint about the error? > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091103/7a3db553/attachment-0001.html From phi500ac at yahoo.ca Tue Nov 3 15:02:06 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Tue Nov 3 14:38:15 2009 Subject: [Haskell-cafe] Gauss Elimination -> More Clean2Haskell Message-ID: <647041.32282.qm@web58805.mail.re1.yahoo.com> I am keeping with my project of translating programs from Clean to Haskell. As far as arrays go, I don't understand well how to use them in Haskell. Therefore, I will appreciate if somebody can find time to check the program below, and make suggestions to improve it. My Haskell program is about 4 times slower than the Clean version. It would be great if one could reduce the execution time by half, approaching to the speed of Clean and Scheme. Here are the constraints: 1 --- The program must be implemented using arrays.? Update must be done in place, in order to minimize use of the garbage collector. I have used Data.Array.IO, but I guess that? Data.Array.ST is better. Is it easy to rewrite the program in order to use DataArray.ST? 2 --? I liked very much the forM_ monad. I wonder if there is an accumulating monad that play the role of a program like leftSide. 3 -- Clean program almost double its speed, if one uses strictness annotations. Is it possible to use similar anotations for Haskell? Here is how I compiled the program: ghc -O2 gel.hs --make In order to run the program with 2000 equations,? type gel.exe 2000 +RTS -sstderr The program will create a linear system with 2000 equations so that all elements of the solution is equal to 1. It prints 20 elements of the solution. Here is the program: {- File: gel.hs Compilation: ghc -O2 gel.hs --make Run: time gel.exe 2000 -} import Control.Monad import Data.Array.IO import System.IO import System.Random import System (getArgs) prtSol i n1 arr | i < 1= return () prtSol i n1 arr= do ??? b <- readArray arr (i, n1) ??? putStr ((show b)++" ") ??? prtSol (i-1) n1 arr fillArray xs s (i, n) (j, m) arr |? i > n= return () fillArray xs s (i,n) (j, m) arr | i==n && j>m= do ? writeArray arr (i, j) s ? return () fillArray xs s (i, n) (j, m) arr | j > m? = do ?? writeArray arr (i, j) s ?? fillArray xs 0.0 (i+1, n) (1, m) arr fillArray (val:xs) s (i, n) (j, m) arr= do ?? writeArray arr (i, j) val ?? fillArray xs (s+val) (i, n) (j+1, m) arr sLU arr n= sIJ 2 1 2 n arr sIJ i j k n arr | i > n = return () sIJ i j k n arr | k > n = sIJ (i+1) i (i+1) n arr sIJ i j k n arr = do ? im <- pmax (j+1) j ? swap j im 1 ? a <- readArray arr (k, j) ? forM_ [j..n+1] $? \l -> do ????? ajj <- readArray arr (j, j) ????? ajl <- readArray arr (j, l) ????? akl <- readArray arr (k, l) ????? writeArray arr (k, l) (akl-a*(ajl/ajj)) ? sIJ i j (k+1) n arr where ???? pmax line imax | line > n = return imax ???? pmax line imax = do ?????? alj <- readArray arr (line, j) ?????? aij <- readArray arr (imax, j) ?????? if (abs alj)> (abs aij) ????????? then pmax (line+1) line ????????? else pmax (line+1) imax ???? swap r s q | q>n+1 = return () ???? swap r s q | r==s = return () ???? swap r s q = do ??????? arq <- readArray arr (r,q) ??????? asq <- readArray arr (s,q) ??????? writeArray arr (s,q) arq ??????? writeArray arr (r,q) asq ??????? swap r s (q+1) ???? ? leftSide acc i j n arr | j>n= return acc leftSide acc i j n arr = do ?? v <- readArray arr (j, n+1) ?? a <- readArray arr (i, j) ?? leftSide (acc-v*a) i (j+1) n arr solvit i n arr | i<1= return () solvit i n arr= do ?? a <- readArray arr (i, i) ?? acc <- readArray arr (i, n+1) ?? v <- leftSide acc i (i+1) n arr ?? writeArray arr (i, n+1) (v/a) ?? solvit (i-1) n arr rnList :: (Double, Double) -> IO [Double] rnList r=getStdGen>>=(\x->return(randomRs r x)) dims [input] = (read input, read input) dims _ = (1000, 1000) main = do ???? xs <- rnList (1.0,1000.0) ???? args <- getArgs ???? let (n, m)= dims args ???? arr <- newArray_ ((1,1),(n,m+1)) :: ??????????????? IO (IOUArray (Int, Int) Double) ???? fillArray xs 0.0 (1,n) (1,m) arr ???? sLU arr n ???? solvit n n arr ???? prtSol (min 20 n) (n+1) arr ???? print "Done" __________________________________________________________________ Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail. Click on Options in Mail and switch to New Mail today or register for free at http://mail.yahoo.ca -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091103/0494694a/attachment.html From gour at gour-nitai.com Tue Nov 3 15:26:09 2009 From: gour at gour-nitai.com (Gour) Date: Tue Nov 3 15:02:31 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows References: <581589.80982.qm@web58804.mail.re1.yahoo.com> Message-ID: <20091103212609.6e72e0ab@gaura-nitai.no-ip.org> On Tue, 3 Nov 2009 03:15:03 -0800 (PST) >>>>>> "Philippos" == wrote: Philippos> I tryed it, and noticed that it is very slow, compared both Philippos> with Emacs, TextPad, and Emerald. Is it usable (btw, what hardware?) or just slow? Philippos> I tryed also leksah, but it is always complaining about Philippos> something missing in Pango, although it works fine. I'd prefer to stay with Emacs and its haskell-mode as editor-tool, but Leo might come handy as meta-editor. Sincerely, Gour -- Gour | Hlapicina, Croatia | GPG key: F96FF5F6 ---------------------------------------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091103/0ee66be9/signature.bin From ryani.spam at gmail.com Tue Nov 3 15:30:48 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Nov 3 15:06:58 2009 Subject: [Haskell-cafe] Gauss Elimination -> More Clean2Haskell In-Reply-To: <647041.32282.qm@web58805.mail.re1.yahoo.com> References: <647041.32282.qm@web58805.mail.re1.yahoo.com> Message-ID: <2f9b2d30911031230x39c7cc7dx467fa9612c29cbd7@mail.gmail.com> On Tue, Nov 3, 2009 at 12:02 PM, Philippos Apolinarius wrote: > 1 --- The program must be implemented using arrays. > Update must be done in place, in order to minimize use of the garbage collector. > I have used Data.Array.IO, but I guess that? Data.Array.ST is better. Is it easy to > rewrite the program in order to use DataArray.ST? It should be pretty easy as long as the rest is pure; ST is a subset of I/O that deals with algorithms that have mutable variables/arrays but no observable side-effects. ST safely guarantees that no side-effects escape to somewhere they can be observed through a clever type-system trick. > 2 --? I liked very much the forM_ monad. I wonder if there is an accumulating monad that play the role of a program like leftSide. forM_ is just a function; it works for all monads. Probably just a terminology error? > 3 -- Clean program almost double its speed, if one uses strictness annotations. Is it possible to use similar anotations for Haskell? Yes. The common ways to do this are to use ! annotations in data structures, like so: ] data Foo s = Foo !Int !Int !(STArray s (Int,Int) Double) You also can use seq and/or $! to guide the evaluation order of your expressions: x <- readArray a (1,1) writeArray a (1,1) $! (x+1) -- forces x+1 to evaluate instead of writing a thunk. If you really care about speed, you probably want to look into STUArrays; these store unboxed values and should be about as fast as a C array. Now to the stylistic comments: You can use guards better to not repeat yourself so often: > prtSol i n1 arr | i < 1= return () > prtSol i n1 arr= do > ??? b <- readArray arr (i, n1) > ??? putStr ((show b)++" ") > ??? prtSol (i-1) n1 arr becomes ] prtSol i n1 arr ] | i < 1 = return () ] | otherwise = do ] b <- readArray arr (i, n1) ] putStr ((show b)++" ") ] prtSol (i-1) n1 arr Similarily: > fillArray xs s (i, n) (j, m) arr |? i > n= return () > fillArray xs s (i,n) (j, m) arr | i==n && j>m= do this branch doesn't need "do" because writeArray returns () > ? writeArray arr (i, j) s > ? return () > fillArray xs s (i, n) (j, m) arr | j > m? = do > ?? writeArray arr (i, j) s > ?? fillArray xs 0.0 (i+1, n) (1, m) arr > fillArray (val:xs) s (i, n) (j, m) arr= do > ?? writeArray arr (i, j) val > ?? fillArray xs (s+val) (i, n) (j+1, m) arr ] fillArray xs s (i, n) (j, m) arr ] | i > n= return () ] | i==n && j>m = writeArray arr (i, j) s ] | j > m = do ] writeArray arr (i, j) s ] fillArray xs 0.0 (i+1, n) (1, m) arr ] | otherwise = do ] writeArray arr (i, j) val ] fillArray xs (s+val) (i, n) (j+1, m) arr I'll let someone else show you how to build this into a fold. -- ryan From deniz.a.m.dogan at gmail.com Tue Nov 3 15:30:50 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Tue Nov 3 15:07:22 2009 Subject: [Haskell-cafe] What's the deal with Clean? Message-ID: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> Recently there has been a lot of discussion on this list about the programming language Clean and converting Clean programs to Haskell. Reading the Wikipedia article on the language, I can't really see any major difference between that and Haskell, except for the monads vs. uniqueness types. So what's the deal with Clean? Why is it preferable to Haskell? Why is it not? -- Deniz Dogan From dons at galois.com Tue Nov 3 15:41:26 2009 From: dons at galois.com (Don Stewart) Date: Tue Nov 3 15:17:39 2009 Subject: [Haskell-cafe] Gauss Elimination -> More Clean2Haskell In-Reply-To: <647041.32282.qm@web58805.mail.re1.yahoo.com> References: <647041.32282.qm@web58805.mail.re1.yahoo.com> Message-ID: <20091103204126.GA14095@whirlpool.galois.com> phi500ac: > import Control.Monad > import Data.Array.IO You're using boxed arrays here -- try Data.Array.Unboxed and IOUArray's From martijn at van.steenbergen.nl Tue Nov 3 15:42:56 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Tue Nov 3 15:19:11 2009 Subject: [Haskell-cafe] Fair diagonals Message-ID: <4AF095D0.9030105@van.steenbergen.nl> Dear caf?, I am looking for a function that does an N-dimensional diagonal traversal. I want the traversal to be fair: the sum of the indices of the produced combinations should be non-decreasing. Let me illustrate with an example. The type of a 2-dimensional traversal would look like this: > diag2 :: [a] -> [b] -> [(a, b)] The first two arguments are the two half-axes of the grid and the result is a fair diagonal traversal of all the points. For example: >> diag2 [1,2,3] [4,5,6,7] > [(1,4),(2,4),(1,5),(3,4),(1,6),(2,5),(1,7),(3,5),(2,6),(2,7),(3,6),(3,7)] Of course the function should work on infinite lists: >> diag2 [1..] [1..] > [(1,1),(2,1),(1,2),(3,1),... Or a combination of finite and infinite lists: >> diag2 [1,2] [1..] > [(1,1),(2,1),(1,2),(1,3),(2,2),(1,4),... Notice that in each case the sum of the pairs (which can seen as indices in these particular examples) are non-decreasing: >> let sums = map (uncurry (+)) >> sums $ diag2 [1,2,3] [4,5,6,7] > [5,6,6,7,7,7,8,8,8,9,9,10] >> sums $ diag2 [1..] [1..] > [2,3,3,4,4,4,5,5,5,5,6,... >> sums $ diag2 [1,2] [1..] > [2,3,3,4,4,5,5,6,6,7,7,... Similarly for 3 dimensions the type would be: > diag3 :: [a] -> [b] -> [c] -> [(a, b, c)] For N dimensions we have to sacrifice some generality and ask all axes to be of the same type and produce lists instead of tuples, but I'm perfectly happy with that: > diagN :: [[a]] -> [[a]] I have implemented diag2 and diag3 [1] but noticed that the function bodies increase in size exponentially following Pascal's triangle and have no clue how to generialize to N dimensions. Can you help me write diagN? Bonus points for the following: * An infinite number of singleton axes produces [origin] (and finishes computing), e.g. forall (infinite) xs. diagN (map (:[]) xs) == map (:[]) xs * For equal indices, the traversal biases to axes that are occur early in the input (but I don't know how to formalize this). * The implementation shows regularity and elegance. Many thanks, Martijn. [1] http://hpaste.org/fastcgi/hpaste.fcgi/view?id=11515 From gcross at phys.washington.edu Tue Nov 3 15:47:40 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Tue Nov 3 15:23:53 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows In-Reply-To: <20091103212609.6e72e0ab@gaura-nitai.no-ip.org> References: <581589.80982.qm@web58804.mail.re1.yahoo.com> <20091103212609.6e72e0ab@gaura-nitai.no-ip.org> Message-ID: <8740041C-68EA-4940-A8AA-80A4A1BD2C47@phys.washington.edu> The problem with Leo is that although there are rarely performance problems when navigating and editing the outline, the text pane can be very slow at times when using the Tk-based GUI --- even on modern hardware --- because the syntax highlighter is written in Python. (Incidentally, as much as I love Leo, I also hold it up as an example of how slow scripting languages aren't always "fast enough" as their proponents claim. :-) ) There are two solutions to this: First, you can use the Qt-based Leo GUI, which uses the native C++ colorizer built into QtScintilla, which I have never had any performance problems with. Since you (reasonably) really like haskell-mode in Emacs, though, you can alternatively use the Emacs plugin so that you end up using Leo to navigate through your code to the chunk that you want to edit, and then using Emacs to do the actual editing. This might sound like an awkward setup, but I actually find that navigating in this way requires much less mental energy than scanning through multiple flat files to pick out the code that you want to edit next, and the plugin makes this type of workflow fairly painless. Viewing Leo as a "meta-editor" is a good way to think about it. Cheers, Greg On Nov 3, 2009, at 12:26 PM, Gour wrote: > On Tue, 3 Nov 2009 03:15:03 -0800 (PST) >>>>>>> "Philippos" == wrote: > > Philippos> I tryed it, and noticed that it is very slow, compared both > Philippos> with Emacs, TextPad, and Emerald. > > Is it usable (btw, what hardware?) or just slow? > > Philippos> I tryed also leksah, but it is always complaining about > Philippos> something missing in Pango, although it works fine. > > I'd prefer to stay with Emacs and its haskell-mode as editor-tool, but > Leo might come handy as meta-editor. > > > Sincerely, > Gour > > -- > > Gour | Hlapicina, Croatia | GPG key: F96FF5F6 > ---------------------------------------------------------------- > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From lrpalmer at gmail.com Tue Nov 3 16:10:56 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Nov 3 15:47:06 2009 Subject: [Haskell-cafe] Fair diagonals In-Reply-To: <4AF095D0.9030105@van.steenbergen.nl> References: <4AF095D0.9030105@van.steenbergen.nl> Message-ID: <7ca3f0160911031310i7846ce2dx48ac50fa1b31b95b@mail.gmail.com> On Tue, Nov 3, 2009 at 1:42 PM, Martijn van Steenbergen wrote: > Dear caf?, > > I am looking for a function that does an N-dimensional diagonal traversal. I > want the traversal to be fair: the sum of the indices of the produced > combinations should be non-decreasing. Let me illustrate with an example. > > The type of a 2-dimensional traversal would look like this: >> >> diag2 :: [a] -> [b] -> [(a, b)] I believe you can get what you want using the diagonal function from Control.Monad.Omega. product xs ys = [ [ (x,y) | y <- ys ] | x <- xs ] diag2 xs ys = diagonal (product xs ys) I think if you separate taking the cartesian product and flattening it, like this, you might have an easier time wrangling all the different variants you want. Luke From andrewcoppin at btinternet.com Tue Nov 3 16:37:29 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Tue Nov 3 16:13:36 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> Message-ID: <4AF0A299.7010007@btinternet.com> Deniz Dogan wrote: > Recently there has been a lot of discussion on this list about the > programming language Clean and converting Clean programs to Haskell. > Reading the Wikipedia article on the language, I can't really see any > major difference between that and Haskell, except for the monads vs. > uniqueness types. > > So what's the deal with Clean? Why is it preferable to Haskell? Why is it not? > As far as I can tell, Clean is to Haskell as C is to Pascal. I.e., Clean is notionally very similar to Haskell, but with lots of added clutter, complexity and general ugliness - but it's probably somehow more machine-efficient as a result. (All of which makes the name "Clean" rather ironic, IMHO.) Of course, this is merely the opinion I formed after performing a cursory scan of some of the introductory documentation. I haven't actually seen any code written with it or anything, so my opinion probably doesn't mean a lot... From leimy2k at gmail.com Tue Nov 3 16:57:04 2009 From: leimy2k at gmail.com (David Leimbach) Date: Tue Nov 3 16:33:13 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <4AF0A299.7010007@btinternet.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> Message-ID: <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> On Tue, Nov 3, 2009 at 1:37 PM, Andrew Coppin wrote: > Deniz Dogan wrote: > >> Recently there has been a lot of discussion on this list about the >> programming language Clean and converting Clean programs to Haskell. >> Reading the Wikipedia article on the language, I can't really see any >> major difference between that and Haskell, except for the monads vs. >> uniqueness types. >> >> So what's the deal with Clean? Why is it preferable to Haskell? Why is it >> not? >> >> > > As far as I can tell, Clean is to Haskell as C is to Pascal. I.e., Clean is > notionally very similar to Haskell, but with lots of added clutter, > complexity and general ugliness - but it's probably somehow more > machine-efficient as a result. > > (All of which makes the name "Clean" rather ironic, IMHO.) > > Of course, this is merely the opinion I formed after performing a cursory > scan of some of the introductory documentation. I haven't actually seen any > code written with it or anything, so my opinion probably doesn't mean a > lot... > > It's preferable to Haskell in situations where Haskell isn't the best choice. The criteria for that decision is different from problem to problem. Example: I had to implement a ring buffer, and I wanted the code using it to be written in Haskell. I ended up implementing the buffer in C, and wrapping it in FFI from Haskell because implementing a destructive array in Haskell is kind of unwieldy to someone of my experience level. In Clean, it looks like the uniqueness typing allows for destructive updates in a very controlled manner. Disciplined Disciple might be interesting to look at here too, but i'm not sure I'd deploy anything with DDC just yet :-) Dave > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091103/50baf8c2/attachment.html From tracy.wadleigh at gmail.com Tue Nov 3 17:16:26 2009 From: tracy.wadleigh at gmail.com (Tracy Wadleigh) Date: Tue Nov 3 16:52:37 2009 Subject: Fwd: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> Message-ID: > I had to implement a ring buffer, and I wanted the code using it to be > written in Haskell. I ended up implementing the buffer in C, and wrapping > it in FFI from Haskell because implementing a destructive array in Haskell > is kind of unwieldy to someone of my experience level. In Clean, it looks > like the uniqueness typing allows for destructive updates in a very > controlled manner. > The ST monad provides this functionality. The never-instantiated-in-a-visible-way state parameter of the ST monad provides the "uniqueness" required for doing destructive updates in a pure way. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091103/80cce38a/attachment.html From mle+hs at mega-nerd.com Tue Nov 3 17:16:53 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Tue Nov 3 16:53:05 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> Message-ID: <20091104091653.e91aae14.mle+hs@mega-nerd.com> David Leimbach wrote: > Disciplined Disciple might be interesting to look at here too, but i'm not > sure I'd deploy anything with DDC just yet :-) Indeed. What DDC needs most at the moment is more people working on it. I've fixed a couple of bugs and I'm working on some others, but there are a large chunk of them in the bug tracker which are simply too deep for me with my current level of knowledge. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From jmillikin at gmail.com Tue Nov 3 17:22:14 2009 From: jmillikin at gmail.com (John Millikin) Date: Tue Nov 3 16:58:24 2009 Subject: [Haskell-cafe] ANNOUNCE: dbus-core 0.5 and dbus-client 0.1 In-Reply-To: References: <3283f7fe0910301444o7fe94785yec5e5b55b2d30066@mail.gmail.com> Message-ID: <3283f7fe0911031422q7530051dja1693d97ecfdb314@mail.gmail.com> The purpose behind the weird signature there is so that the computations in DBus.Bus can be passed directly to mkClient. Because of the design of dbus-client, you probably don't want to keep the connection around separately. ----- client <- mkClient getSessionBus ----- Here's a quick-and-dirty skeleton for sending notifications: ----- {-# LANGUAGE OverloadedStrings #-} import DBus.Bus import DBus.Client import DBus.Types -- Definition of notification object / interface notifications = Proxy (RemoteObject (mkBusName' "org.freedesktop.Notifications") (mkObjectPath' "/org/freedesktop/Notifications")) (mkInterfaceName' "org.freedesktop.Notifications") -- Callbacks; in real systems, these would probably be more complex onError x = putStrLn ("ERROR\n\n" ++ show x ++ "\n\n") onReturn x = putStrLn ("RETURN\n\n" ++ show x ++ "\n\n") -- A real library might accept additional parameters -- by the way: signature of Notify() is "susssasa{sv}i" notify c = call' params onError onReturn where params = [{- build parameters for your library here -}] call' = call client notifications (mkMemberName' "Notify") [] main = do client <- mkClient getSessionBus notify client {- main loop / mvar / whatever your library uses -} ----- On Tue, Nov 3, 2009 at 14:07, Max Rabkin wrote: > Hi John > > I'm trying to implement a pure Haskell library for notifications (like > libnotify). Unfortunately I don't know my way around dbus too well. > > Is there a reason for > > mkClient :: IO (Connection, BusName) -> IO Client > > instead of > > mkClient :: Connection -> IO Client > > ? > > mkClient simply discards the bus name, so in the event that one > doesn't have a bus name, one must create a fake one. Also, it executes > the IO action right away, so there is no need for it to take an IO > argument. All in all, this means I must write > > getClient = mkClient (flip (,) undefined <$> getSessionConnection) > > instead of > > getClient = mkClient =<< getSessionConnection. > > Perhaps you have a good reason for it? > > Regards, > Max > > On Fri, Oct 30, 2009 at 11:44 PM, John Millikin wrote: >> These are pure-Haskell client libraries for using the D-Bus protocol. >> D-Bus is heavily used for inter-application IPC on Free and >> open-source desktop platforms, such as Linux, OpenSolaris, and >> FreeBSD. These libraries allow applications written in Haskell to >> inter-operate with other components of recent GNOME, KDE, and XFCE >> desktops. >> >> This is the first "real" release of these libraries; dbus-core has >> been published on Hackage for some time, but mostly just to make sure >> I got the Cabal bits right. I feel they are now stable / featureful >> enough for public use. >> >> Both are available on Hackage: >> >> http://hackage.haskell.org/package/dbus-core >> http://hackage.haskell.org/package/dbus-client >> >> --------- >> >> "dbus-core" is an implementation of the D-Bus protocol, specifically >> the parts relevant to clients. Eventually, it will probably grow some >> functions useful for implementing a message bus as well. It includes >> type mapping / conversion, an implementation of the wire format >> (marshaling / unmarshaling), data types for the currently defined >> message types (METHOD_CALL, METHOD_RETURN, ERROR, and SIGNAL) and a >> basic parser / generator for introspection documents. It is roughly >> equivalent in purpose to libdbus. >> >> By itself, a protocol implementation is somewhat cumbersome to use, so >> "dbus-client" is a high-level wrapper. It provides some abstractions >> like remote object proxies, exported object trees, synchronous method >> calls, signal reception, and name reservation. Messages are received >> and processed in separate IO threads, allowing asynchronous method >> call and signal handling. >> >> The purpose between splitting the library into two packages is >> stability; "dbus-core", ideally, will change only rarely -- >> performance improvements, new message / data types, etc. It provides a >> base level of functionality which more specialised libraries may use. >> "dbus-client" is an example of what such a library could look like, >> though for now it's not very Haskell-y (IO everywhere, exceptions, >> explicit locking). By separating the protocol from the client libs, >> alternative client libs can safely depend on the protocol >> implementation. >> >> --------- >> >> To see a sample of the library working, there's a clone of the >> "dbus-monitor" utility in . Documentation is >> currently a bit lacking, so for now, the best documentation is the PDF >> of the source code itself, and the (rather barren) Haddock output: >> >> https://dl.getdropbox.com/u/1947532/dbus-core_0.5.pdf >> https://dl.getdropbox.com/u/1947532/dbus-core_0.5/index.html >> >> https://dl.getdropbox.com/u/1947532/dbus-client_0.1.pdf >> https://dl.getdropbox.com/u/1947532/dbus-client_0.1/index.html >> >> Once more people have used it without any major API issues, I'll write >> up a manual and populate the Haddock entries. >> >> Please respond with any feedback, difficulties, or suggestions. I'm >> particularly interested in ways to improve the public API, since I >> would rather make any breaking changes *before* anything big depends >> on these libraries. >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From stephen.tetley at gmail.com Tue Nov 3 17:49:54 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Tue Nov 3 17:26:04 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <4AF0A299.7010007@btinternet.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> Message-ID: <5fdc56d70911031449h3314c9b9l5d1a43ab485c540@mail.gmail.com> 2009/11/3 Andrew Coppin : > > As far as I can tell, Clean is to Haskell as C is to Pascal. I.e., Clean is > notionally very similar to Haskell, but with lots of added clutter, > complexity and general ugliness - but it's probably somehow more > machine-efficient as a result. > > (All of which makes the name "Clean" rather ironic, IMHO.) Ouch - you really could put it the other way round. Clean has very little clutter, though I suppose some people might take offence to it having simple macros (:==), but wait so does GHC via -XCPP... I think Clean had generics before Haskell had Data.Generics, otherwise Haskell generally has more innovation, more people work on Haskell, Haskell's motivation was language research... Clean has far fewer libraries, more people use Haskell... Clean used to be considered faster than Haskell, though I don't know what the situation is now: http://www.haskell.org/pipermail/haskell-cafe/2007-October/033854.html Clean is a very fine language, if I wasn't using Haskell I know what my alternative choice would be. Best wishes Stephen From qdunkan at gmail.com Tue Nov 3 18:01:03 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Tue Nov 3 17:37:13 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> Message-ID: <2518b95d0911031501k2e3d789dva747e8917ca20225@mail.gmail.com> > So what's the deal with Clean? Why is it preferable to Haskell? Why is it not? Purely from glancing through the language reference, two things that it looks like clean has that I would love to have in haskell are better records and better arrays. The records don't implement any of the fancy subtyping stuff that the various haskell proposals do, but they have the benefits of a nicer syntax and actually being implemented. Haskell arrays (by which I mean the IArray and MArray interfaces) are, to me at least, really hard to use. From little things like using closed ranges where the rest of the world uses half-open ones and opaque documentation and no consistency between IArray and MArray, to bigger things like how do you insert or delete something. My conclusion, after wrestling with ixmap for 15 minutes, was to convert to a list, concatMap across [(i, a)], convert back to an array, which has the bonus of runtime crashes if you forget an 'i'. Sorry if this turned into a rant about arrays, but it's bothered me for a while :) I think the clean guys got it right when they decided to make good array support an explicit goal. I suppose haskell has since gone a different way with the various array fusion libraries with listlike interfaces, and maybe that's better in the long term. Maybe type families can make a nice interface someday. Meanwhile it's a mess though. From Ben.Lippmeier at anu.edu.au Tue Nov 3 18:14:38 2009 From: Ben.Lippmeier at anu.edu.au (Ben Lippmeier) Date: Tue Nov 3 17:50:51 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> Message-ID: <4AF0B95E.3080102@anu.edu.au> David Leimbach wrote: > Disciplined Disciple might be interesting to look at here too, but i'm > not sure I'd deploy anything with DDC just yet :-) :) Nor would I (and I wrote most of it). I think the approach is right, but the compiler itself is still in the "research prototype" stage. Ben. From leimy2k at gmail.com Tue Nov 3 18:42:24 2009 From: leimy2k at gmail.com (David Leimbach) Date: Tue Nov 3 18:18:34 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> Message-ID: <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> On Tue, Nov 3, 2009 at 2:16 PM, Tracy Wadleigh wrote: > > I had to implement a ring buffer, and I wanted the code using it to be >> written in Haskell. I ended up implementing the buffer in C, and wrapping >> it in FFI from Haskell because implementing a destructive array in Haskell >> is kind of unwieldy to someone of my experience level. In Clean, it looks >> like the uniqueness typing allows for destructive updates in a very >> controlled manner. >> > > The ST monad provides this functionality. The > never-instantiated-in-a-visible-way state parameter of the ST monad provides > the "uniqueness" required for doing destructive updates in a pure way. > Someone suggested that to me on IRC once I'd already cranked out a C implementation with FFI bindings. It's just too easy to use the FFI in Haskell :-) If we raise the barrier of FFI, more people will use ST! Dave > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091103/19cbd9d6/attachment.html From leimy2k at gmail.com Tue Nov 3 18:45:15 2009 From: leimy2k at gmail.com (David Leimbach) Date: Tue Nov 3 18:21:24 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <4AF0B95E.3080102@anu.edu.au> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <4AF0B95E.3080102@anu.edu.au> Message-ID: <3e1162e60911031545g75f07716w7f9c84afb9707953@mail.gmail.com> On Tue, Nov 3, 2009 at 3:14 PM, Ben Lippmeier wrote: > David Leimbach wrote: > >> Disciplined Disciple might be interesting to look at here too, but i'm not >> sure I'd deploy anything with DDC just yet :-) >> > :) Nor would I (and I wrote most of it). I think the approach is right, but > the compiler itself is still in the "research prototype" stage. > > Ben. > > I have to admit, the first time I hit the wiki page for DDC I said to myself "Self, this sounds crazy complicated". Then I read part of the PDF (your thesis I believe) about Region Types on the bus ride to work and thought. "Gee I think I scared myself off too quickly". Uniqueness typing is quite interesting in Clean, but to control aliasing, like really *control* aliasing, that's just far out man. So I still have to wrap my head around "why this isn't going to get completely out of control" and see why it's all safer than just writing C code but I must say the attention I will be paying to DDC has just gone quite a bit up. Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091103/e4f3788d/attachment.html From dons at galois.com Tue Nov 3 18:57:30 2009 From: dons at galois.com (Don Stewart) Date: Tue Nov 3 18:33:42 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <5fdc56d70911031449h3314c9b9l5d1a43ab485c540@mail.gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <5fdc56d70911031449h3314c9b9l5d1a43ab485c540@mail.gmail.com> Message-ID: <20091103235730.GA14808@whirlpool.galois.com> stephen.tetley: > 2009/11/3 Andrew Coppin : > > > > > As far as I can tell, Clean is to Haskell as C is to Pascal. I.e., Clean is > > notionally very similar to Haskell, but with lots of added clutter, > > complexity and general ugliness - but it's probably somehow more > > machine-efficient as a result. > > > > (All of which makes the name "Clean" rather ironic, IMHO.) > > Clean used to be considered faster than Haskell, though I don't know > what the situation is now: > http://www.haskell.org/pipermail/haskell-cafe/2007-October/033854.html We've come a long way in 5 years. Haskell is almost always faster on the shootout now. And parallelism goes a long way to helping there: http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=ghc&lang2=clean&box=1 Though this is also true on a single core: http://shootout.alioth.debian.org/u64/benchmark.php?test=all&lang=ghc&lang2=clean&box=1 It's just a lot closer. Clean continues to have a very small memory footprint. -- Don From briand at aracnet.com Tue Nov 3 21:12:29 2009 From: briand at aracnet.com (brian) Date: Tue Nov 3 20:48:42 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> Message-ID: <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> Really, arrays in Haskell are the most @#!$! confusing thing in the world. There's a bunch of different array structures. I can't tell which one works best, and all I want to do is x[i] = value. I thought uvector was the answer, you know, fast unboxed ARRAYs. Imagine my surprise when I saw this indexU :: UA e => UArr e -> Int -> e O(n). indexU extracts an element out of an immutable unboxed array. An array implementation with an order N lookup. huh ?? That's not an array, that's a list. I was looking for an array. However, I then found in the same hackage: readMU :: MUArr e s -> Int -> ST s e O(1). readMU reads the element at the specified index of a mutable unboxed array. So O(1) for mutable, but O(n) for immutable ? See, confusing... I'm sure there's a really good, lofty type safety, something or other reason for that, that I'm sure I don't care about ;-) There's also ST. So why is there a uvector, when there's ST ?? etc, etc, etc... and then there's monads... other than that, having fun with haskell :-) Brian On Nov 3, 2009, at 3:42 PM, David Leimbach wrote: > > > On Tue, Nov 3, 2009 at 2:16 PM, Tracy Wadleigh > wrote: > > I had to implement a ring buffer, and I wanted the code using it to > be written in Haskell. I ended up implementing the buffer in C, and > wrapping it in FFI from Haskell because implementing a destructive > array in Haskell is kind of unwieldy to someone of my experience > level. In Clean, it looks like the uniqueness typing allows for > destructive updates in a very controlled manner. > > The ST monad provides this functionality. The never-instantiated-in- > a-visible-way state parameter of the ST monad provides the > "uniqueness" required for doing destructive updates in a pure way. > > Someone suggested that to me on IRC once I'd already cranked out a C > implementation with FFI bindings. It's just too easy to use the FFI > in Haskell :-) > > If we raise the barrier of FFI, more people will use ST! > > Dave > > > > _______________________________________________ > 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 From pumpkingod at gmail.com Tue Nov 3 21:23:48 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Tue Nov 3 20:59:57 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> Message-ID: In the presence of fusion (as is the case in uvector), it's hard to give meaningful time complexities for operations as they depend on what operations they are paired with. We need to think of a better way to express this behavior in the documentation though. On Tue, Nov 3, 2009 at 9:12 PM, brian wrote: > Really, arrays in Haskell are the most @#!$! confusing thing in the world. > > There's a bunch of different array structures. > > I can't tell which one works best, and all I want to do is x[i] = value. > > I thought uvector was the answer, you know, fast unboxed ARRAYs. ?Imagine my > surprise when I saw this > > ?indexU :: UA e => UArr e -> Int -> e > > ?O(n). indexU extracts an element out of an immutable unboxed array. > > An array implementation with an order N lookup. ?huh ?? ?That's not an > array, that's a list. ?I was looking for an array. > > However, I then found in the same hackage: > > ?readMU :: MUArr e s -> Int -> ST s e > > ?O(1). readMU reads the element at the specified index of a mutable unboxed > array. > > So O(1) for mutable, but O(n) for immutable ? See, confusing... ?I'm sure > there's a really good, lofty type safety, something > or other reason for that, that I'm sure I don't care about ;-) > > There's also ST. ?So why is there a uvector, when there's ST ?? > > etc, etc, etc... > > and then there's monads... > > other than that, having fun with haskell :-) > > Brian > > > On Nov 3, 2009, at 3:42 PM, David Leimbach wrote: > >> >> >> On Tue, Nov 3, 2009 at 2:16 PM, Tracy Wadleigh >> wrote: >> >> I had to implement a ring buffer, and I wanted the code using it to be >> written in Haskell. ?I ended up implementing the buffer in C, and wrapping >> it in FFI from Haskell because implementing a destructive array in Haskell >> is kind of unwieldy to someone of my experience level. ?In Clean, it looks >> like the uniqueness typing allows for destructive updates in a very >> controlled manner. >> >> The ST monad provides this functionality. The >> never-instantiated-in-a-visible-way state parameter of the ST monad provides >> the "uniqueness" required for doing destructive updates in a pure way. >> >> Someone suggested that to me on IRC once I'd already cranked out a C >> implementation with FFI bindings. ?It's just too easy to use the FFI in >> Haskell :-) >> >> If we raise the barrier of FFI, more people will use ST! >> >> Dave >> >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From rl at cse.unsw.edu.au Tue Nov 3 21:25:27 2009 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Tue Nov 3 21:01:47 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> Message-ID: On 04/11/2009, at 13:12, brian wrote: > indexU :: UA e => UArr e -> Int -> e > > O(n). indexU extracts an element out of an immutable unboxed array. This is a typo (unless Don inserted a nop loop into the original DPH code). Roman From wren at freegeek.org Tue Nov 3 21:26:35 2009 From: wren at freegeek.org (wren ng thornton) Date: Tue Nov 3 21:02:46 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <5fdc56d70911031449h3314c9b9l5d1a43ab485c540@mail.gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <5fdc56d70911031449h3314c9b9l5d1a43ab485c540@mail.gmail.com> Message-ID: <4AF0E65B.6060601@freegeek.org> Stephen Tetley wrote: > 2009/11/3 Andrew Coppin : > >> As far as I can tell, Clean is to Haskell as C is to Pascal. I.e., Clean is >> notionally very similar to Haskell, but with lots of added clutter, >> complexity and general ugliness - but it's probably somehow more >> machine-efficient as a result. >> >> (All of which makes the name "Clean" rather ironic, IMHO.) > > Ouch - you really could put it the other way round. Part of this really comes down to how one feels about the monads vs uniqueness types argument. It's a silly argument to have since the ideas are orthogonal and only really intersect at IO, but there's history there which lead to the current state of things. Sometimes in Haskell I've thought about how uniqueness typing would make something faster, but in general all the plumbing associated with it in Clean makes me feel like I'm writing systems-level code (i.e. C, asm) instead of using a high-level language. The extra plumbing really makes it feel dirtier to work with. That doesn't mean Clean is bad, but I think it does contribute to the "cluttered" feeling Haskellers get. But as I said, it's a silly argument and folks should use whichever gives them warm fuzzies. I also have a vague unnameable distaste whenever working with Python, and rather enjoy working with Perl. Nobody's perfect :) -- Live well, ~wren From rl at cse.unsw.edu.au Tue Nov 3 21:27:05 2009 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Tue Nov 3 21:03:21 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> Message-ID: On 04/11/2009, at 13:23, Daniel Peebles wrote: > In the presence of fusion (as is the case in uvector), it's hard to > give meaningful time complexities for operations as they depend on > what operations they are paired with. We need to think of a better way > to express this behavior in the documentation though. I have to disagree here. Fusion never makes the complexity of operations worse. If it does, it's a bug. Roman From porges at porg.es Tue Nov 3 21:32:21 2009 From: porges at porg.es (George Pollard) Date: Tue Nov 3 21:08:31 2009 Subject: [Haskell-cafe] Are all arrows functors? In-Reply-To: <1257254743-sup-8857@peray> References: <4AF025F6.2020200@kent.ac.uk> <1257254743-sup-8857@peray> Message-ID: <6d942a4a0911031832w1cb5e439xeb70d3b078d680e4@mail.gmail.com> See also the paper "Idioms are oblivious, arrows are meticulous, monads are promiscuous" [1]. Functors can be extended to give applicative functors (idioms) which can then be extended to arrows, and then monads. So all arrows are also (applicative) functors. [1]: http://homepages.inf.ed.ac.uk/wadler/papers/arrows-and-idioms/arrows-and-idioms.pdf From wren at freegeek.org Tue Nov 3 21:35:43 2009 From: wren at freegeek.org (wren ng thornton) Date: Tue Nov 3 21:11:54 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> Message-ID: <4AF0E87F.7000306@freegeek.org> Roman Leshchinskiy wrote: > On 04/11/2009, at 13:23, Daniel Peebles wrote: > >> In the presence of fusion (as is the case in uvector), it's hard to >> give meaningful time complexities for operations as they depend on >> what operations they are paired with. We need to think of a better way >> to express this behavior in the documentation though. > > I have to disagree here. Fusion never makes the complexity of operations > worse. If it does, it's a bug. I think the point was more that the relevant complexity bound can change in the presence of fusion. For a poor example: the first map over a list is O(n) but all subsequent ones in a chain of maps are O(1) with fusion. I'm sure there are better examples than that, but you get the idea. Some people may care to know about that latter complexity rather than just the "independent" complexity. While this comes up with fusion, it's not a new problem. The same sort of thing is gotten at by distinguishing worst-case vs average-case complexity, or amortized worst-case vs non-amortized wost-case, etc. -- Live well, ~wren From dons at galois.com Tue Nov 3 21:48:16 2009 From: dons at galois.com (Don Stewart) Date: Tue Nov 3 21:24:29 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> Message-ID: <20091104024816.GA15444@whirlpool.galois.com> briand: > Really, arrays in Haskell are the most @#!$! confusing thing in the > world. > > There's a bunch of different array structures. > > I can't tell which one works best, and all I want to do is x[i] = value. > > I thought uvector was the answer, you know, fast unboxed ARRAYs. > Imagine my surprise when I saw this > > indexU :: UA e => UArr e -> Int -> e > > O(n). indexU extracts an element out of an immutable unboxed array. Umm.... That's a typo in the docs. Thanks. -- Don From wasserman.louis at gmail.com Tue Nov 3 21:49:00 2009 From: wasserman.louis at gmail.com (Louis Wasserman) Date: Tue Nov 3 21:25:30 2009 Subject: [Haskell-cafe] Re: Fair diagonals Message-ID: +1 on Control.Monad.Omega. In point of fact, your diagN function is simply diagN = runOmega . mapM Omega You'll find it an interesting exercise to grok the source of Control.Monad.Omega, obviously, but essentially, you're replacing concatMap with a fair (diagonal) traversal order version. Louis Wasserman wasserman.louis@gmail.com http://profiles.google.com/wasserman.louis -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091103/8c3cac37/attachment.html From gcross at phys.washington.edu Tue Nov 3 22:07:26 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Tue Nov 3 21:44:29 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> Message-ID: <4613CAAA-A646-427D-A0CD-975E493B7ABC@phys.washington.edu> Actually, it's not a typo. If you look at the source, what you'll see is indexU arr n = indexS (streamU arr) n and then tracking down indexS, you'll see indexS (Stream next s0 _) n0 | n0 < 0 = error "Data.Array.Vector.Stream.indexS: negative index" | otherwise = loop_index n0 s0 where loop_index n s = case next s of Yield x s' | n == 0 -> x | otherwise -> s' `seq` loop_index (n-1) s' Skip s' -> s' `seq` loop_index n s' Done -> error "Data.Array.Vector.Stream.indexS: index too large" So in other words, indexU really does have O(n) complexity since it first converts the array into a stream and then walks down the stream in order to find the desired element. Cheers, Greg On Nov 3, 2009, at 6:25 PM, Roman Leshchinskiy wrote: > On 04/11/2009, at 13:12, brian wrote: > >> indexU :: UA e => UArr e -> Int -> e >> >> O(n). indexU extracts an element out of an immutable unboxed array. > > This is a typo (unless Don inserted a nop loop into the original DPH > code). > > Roman > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ajb at spamcop.net Tue Nov 3 22:15:44 2009 From: ajb at spamcop.net (ajb@spamcop.net) Date: Tue Nov 3 21:51:52 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <4AF0E65B.6060601@freegeek.org> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <5fdc56d70911031449h3314c9b9l5d1a43ab485c540@mail.gmail.com> <4AF0E65B.6060601@freegeek.org> Message-ID: <20091103221544.5h2jy454essccogw-nwo@webmail.spamcop.net> G'day all. Quoting wren ng thornton : > Sometimes in Haskell I've thought about how uniqueness typing would > make something faster, but in general all the plumbing associated with > it in Clean makes me feel like I'm writing systems-level code (i.e. C, > asm) instead of using a high-level language. The extra plumbing really > makes it feel dirtier to work with. That doesn't mean Clean is bad, but > I think it does contribute to the "cluttered" feeling Haskellers get. I think you're right here. Haskell has developed something of an aversion to naming things that aren't important enough to have a name, such as variables whose only reason to exist is "plumbing". We'd far rather spend effort on more higher-order functions, monads, combinators and points-freeness than name something that's unimportant. And the funny thing about this is that it usually works, because in Haskell, abstraction is cheap. I believe that this is the main reason why Haskell programmers haven't embraced arrows, despite their theoretical advantages: Every notation that has been implemented so far requires names for things that shouldn't need names. > But as I said, it's a silly argument and folks should use whichever > gives them warm fuzzies. I'd like to think that professional developers are a bit more scientific than this. Cheers, Andrew Bromage From phi500ac at yahoo.ca Tue Nov 3 22:38:48 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Tue Nov 3 22:14:59 2009 Subject: [Haskell-cafe] Arrays in Clean and Haskell In-Reply-To: <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> Message-ID: <132632.69517.qm@web58803.mail.re1.yahoo.com> Brian wrote: > Really, arrays in Haskell are the most @#!$! confusing thing in the world. Hi, Brian. I am having a great difficulty with arrays in Haskell.? In the university where I study, functional programming is taught in Clean or in Haskell, depending on the professor who is teaching the subject in a given year. One year ago, when I took functional programming, the professor used Clean in his classes. I had no difficulty in learning how arrays and input/output work in Clean.? In the case of arrays, the idea is very simple: One can update arrays, provided that s/he does not try to access the old array. Therefore, one needs to make a copy of any value of the old array that s/he will use before performing the update; the operation that makes copies also provides a new name for the array, that obliterates the old name.? In order to get a better feeling of the thing, here is the `solvit? function, in Clean and Haskell (you can consider the # as a kind of do): // Clean leftSide acc i j n arr | j >= n= (acc, arr); ?? # (v, arr)= arr![j, n]; ???? (a, arr)= arr![i, j]; ?? = leftSide (acc-v*a) i (j+1) n arr; solvit i n arr | i < 0 = arr ? # (a, arr)= arr![i, i]; ??? (acc, arr)= arr![i, n]; ??? (v, arr)= leftSide acc i (i+1) n arr; ? = solvit (i-1) n {arr&[i, n]= v/a}; -- HASKELL leftSide acc i j n arr | j>n= return acc leftSide acc i j n arr = do ?? v <- readArray arr (j, n+1) ?? a <- readArray arr (i, j) ?? leftSide (acc-v*a) i (j+1) n arr solvit i n arr | i<1= return () solvit i n arr= do ?? a <- readArray arr (i, i) ?? acc <- readArray arr (i, n+1) ?? v <- leftSide acc i (i+1) n arr ?? writeArray arr (i, n+1) $! (v/a) ?? solvit (i-1) n arr And here comes the reason for writing this article. In the previous version of the Gauss elimination algorithm, I have imported Data.Array.IO. I also wrote a version of the program that imports Data.Array.ST. The problem is that I? don't know how to read an STUArray from a file, process it, and write it back to a file. Is it possible to transform it into an IOUArray pro tempore, read it, make it into an STUArray again in order to process it, and bring it back to IOUArray in order to print it? Below,? you will find the Gauss elimination program in STUArray (by the way, it is slower than IOUArray). Could you modify the main function so it can read array `arr? from a file, and write the result to a file?? Here is the Gauss Elimination for STUArray (the main function is the first one; modify it to read the array from a file, and write it back to a file): import Control.Monad import Control.Monad.ST import Data.Array.ST import Data.Array.IO import System.IO import System.Random import System (getArgs) main = do ???? xs <- rnList (1.0,1000.0) ???? args <- getArgs ???? let (n, m)= dims args ???? xx <-? stToIO $ do ???????????????? arr <- newArray_ ((1,1),(n,m+1)) :: ?????????????????? ST s (STUArray s (Int, Int) Double) ???????????????? fillArray xs 0.0 (1,n) (1,m) arr ???????????????? sLU arr n ???????????????? solvit n n arr ???????????????? x1 <- readArray arr (1, n+1) ???????????????? x2 <- readArray arr (1, n+1) ???????????????? return [x1, x2] ???? print xx {-? -- Other option: main = do ???? xs <- rnList (1.0,1000.0) ???? args <- getArgs ???? let (n, m)= dims args ???? print $ runST $ do ???????????????? arr <- newArray_ ((1,1),(n,m+1)) :: ?????????????????? ST s (STUArray s (Int, Int) Double) ???????????????? fillArray xs 0.0 (1,n) (1,m) arr ???????????????? sLU arr n ???????????????? solvit n n arr ???????????????? x1 <- readArray arr (1, n+1) ???????????????? x2 <- readArray arr (1, n+1) ???????????????? return [x1, x2] -}?? fillArray xs s (i, n) (j, m) arr |? i > n= return () fillArray xs s (i,n) (j, m) arr | i==n && j>m= do ? writeArray arr (i, j) $! s ? return () fillArray xs s (i, n) (j, m) arr | j > m? = do ?? writeArray arr (i, j) $! s ?? fillArray xs 0.0 (i+1, n) (1, m) arr fillArray (val:xs) s (i, n) (j, m) arr= do ?? writeArray arr (i, j) $! val ?? fillArray xs (s+val) (i, n) (j+1, m) arr sLU arr n= sIJ 2 1 2 n arr sIJ i j k n arr | i > n = return () sIJ i j k n arr | k > n = sIJ (i+1) i (i+1) n arr sIJ i j k n arr = do ?{- im <- pmax (j+1) j ? swap j im 1 -} ? a <- readArray arr (k, j) ? forM_ [j..n+1] $? \l -> do ????? ajj <- readArray arr (j, j) ????? ajl <- readArray arr (j, l) ????? akl <- readArray arr (k, l) ????? writeArray arr (k, l) $! (akl-a*(ajl/ajj)) ? sIJ i j (k+1) n arr where ???? pmax line imax | line > n = return imax ???? pmax line imax = do ?????? alj <- readArray arr (line, j) ?????? aij <- readArray arr (imax, j) ?????? if (abs alj)> (abs aij) ????????? then pmax (line+1) line ????????? else pmax (line+1) imax ???? swap r s q | q>n+1 = return () ???? swap r s q | r==s = return () ???? swap r s q = do ??????? arq <- readArray arr (r,q) ??????? asq <- readArray arr (s,q) ??????? writeArray arr (s,q) $! arq ??????? writeArray arr (r,q) $! asq ??????? swap r s (q+1) ???? ? leftSide acc i j n arr | j>n= return acc leftSide acc i j n arr = do ?? v <- readArray arr (j, n+1) ?? a <- readArray arr (i, j) ?? leftSide (acc-v*a) i (j+1) n arr solvit i n arr | i<1= return () solvit i n arr= do ?? a <- readArray arr (i, i) ?? acc <- readArray arr (i, n+1) ?? v <- leftSide acc i (i+1) n arr ?? writeArray arr (i, n+1) $! (v/a) ?? solvit (i-1) n arr rnList :: (Double, Double) -> IO [Double] rnList r=getStdGen>>=(\x->return(randomRs r x)) dims [input] = (read input, read input) dims _ = (1000, 1000) --- On Tue, 11/3/09, brian wrote: From: brian Subject: Re: [Haskell-cafe] What's the deal with Clean? To: "David Leimbach" Cc: haskell-cafe@haskell.org Received: Tuesday, November 3, 2009, 7:12 PM Really, arrays in Haskell are the most @#!$! confusing thing in the world. There's a bunch of different array structures. I can't tell which one works best, and all I want to do is x[i] = value. I thought uvector was the answer, you know, fast unboxed ARRAYs.? Imagine my surprise when I saw this ? indexU :: UA e => UArr e -> Int -> e ? O(n). indexU extracts an element out of an immutable unboxed array. An array implementation with an order N lookup.? huh ??? That's not an array, that's a list.? I was looking for an array. However, I then found in the same hackage: ? readMU :: MUArr e s -> Int -> ST s e ? O(1). readMU reads the element at the specified index of a mutable unboxed array. So O(1) for mutable, but O(n) for immutable ? See, confusing...? I'm sure there's a really good, lofty type safety, something or other reason for that, that I'm sure I don't care about ;-) There's also ST.? So why is there a uvector, when there's ST ?? etc, etc, etc... and then there's monads... other than that, having fun with haskell :-) Brian On Nov 3, 2009, at 3:42 PM, David Leimbach wrote: > > > On Tue, Nov 3, 2009 at 2:16 PM, Tracy Wadleigh wrote: > > I had to implement a ring buffer, and I wanted the code using it to be written in Haskell.? I ended up implementing the buffer in C, and wrapping it in FFI from Haskell because implementing a destructive array in Haskell is kind of unwieldy to someone of my experience level.? In Clean, it looks like the uniqueness typing allows for destructive updates in a very controlled manner. > > The ST monad provides this functionality. The never-instantiated-in-a-visible-way state parameter of the ST monad provides the "uniqueness" required for doing destructive updates in a pure way. > > Someone suggested that to me on IRC once I'd already cranked out a C implementation with FFI bindings.? It's just too easy to use the FFI in Haskell :-) > > If we raise the barrier of FFI, more people will use ST! > > Dave > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe __________________________________________________________________ Get the name you've always wanted @ymail.com or @rocketmail.com! Go to http://ca.promos.yahoo.com/jacko/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091103/1eca675d/attachment.html From emax at chalmers.se Tue Nov 3 22:39:55 2009 From: emax at chalmers.se (Emil Axelsson) Date: Tue Nov 3 22:16:06 2009 Subject: [Haskell-cafe] ANNOUNCE: feldspar-language Message-ID: <4AF0F78B.2090405@chalmers.se> I'm happy to announce the first release of Feldspar, which is an embedded domain-specific language with associated code generator mainly targeting DSP algorithms. The language is developed in cooperation by Ericsson, Chalmers University and E?tv?s Lor?nd University. Feldspar stands for *F*unctional *E*mbedded *L*anguage for *DSP* and *PAR*allelism. The language front-end is available on Hackage: http://hackage.haskell.org/package/feldspar-language The back-end C code generator will be uploaded and announced shortly. For more information, see: http://feldspar.sourceforge.net/ / Emil From warren.henning at gmail.com Tue Nov 3 23:03:28 2009 From: warren.henning at gmail.com (Warren Henning) Date: Tue Nov 3 22:39:38 2009 Subject: [Haskell-cafe] ANNOUNCE: feldspar-language In-Reply-To: <4AF0F78B.2090405@chalmers.se> References: <4AF0F78B.2090405@chalmers.se> Message-ID: <9e5767b0911032003o28292050rba2f8efa20c0fda@mail.gmail.com> I see that section 4.1 of the user guide - http://feldspar.sourceforge.net/documents/language/FeldsparLanguage.html#htoc23 - includes an example involving autocorrelation. Does this mean I could use Feldspare to easily build my own Autotune program? I love T-Pain and Autotune the News! Warren On Tue, Nov 3, 2009 at 7:39 PM, Emil Axelsson wrote: > I'm happy to announce the first release of Feldspar, which is an embedded > domain-specific language with associated code generator mainly targeting DSP > algorithms. The language is developed in cooperation by Ericsson, Chalmers > University and E?tv?s Lor?nd University. > > Feldspar stands for *F*unctional *E*mbedded *L*anguage for *DSP* and > *PAR*allelism. > > The language front-end is available on Hackage: > > ?http://hackage.haskell.org/package/feldspar-language > > The back-end C code generator will be uploaded and announced shortly. For > more information, see: > > ?http://feldspar.sourceforge.net/ > > / Emil > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From rl at cse.unsw.edu.au Tue Nov 3 23:20:14 2009 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Tue Nov 3 22:56:27 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <4AF0E87F.7000306@freegeek.org> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> <4AF0E87F.7000306@freegeek.org> Message-ID: On 04/11/2009, at 13:35, wren ng thornton wrote: > Roman Leshchinskiy wrote: >> On 04/11/2009, at 13:23, Daniel Peebles wrote: >>> In the presence of fusion (as is the case in uvector), it's hard to >>> give meaningful time complexities for operations as they depend on >>> what operations they are paired with. We need to think of a better >>> way >>> to express this behavior in the documentation though. >> I have to disagree here. Fusion never makes the complexity of >> operations worse. If it does, it's a bug. > > I think the point was more that the relevant complexity bound can > change in the presence of fusion. For a poor example: the first map > over a list is O(n) but all subsequent ones in a chain of maps are > O(1) with fusion. I'm sure there are better examples than that, but > you get the idea. Some people may care to know about that latter > complexity rather than just the "independent" complexity. I think asymptotic complexity is the wrong tool for what you're trying to do. You implement your algorithm using operations with known complexities. This allows you to compute the complexity of the entire algorithm. That's all you can use operation complexities for. The compiler is then free to optimise the algorithm as it sees fit but is supposed to preserve (or improve) its complexity. It is not guaranteed or even supposed to preserve the original operations. To stay with your example, each of the two maps is linear regardless of whether fusion happens. Executing the two maps, be it one after another or interlocked, is linear simply because O(n) + O(n) = O(n), not because of fusion. Essentially, you're trying to use complexity to describe an optimisation which doesn't actually affect the complexity. Roman From rl at cse.unsw.edu.au Tue Nov 3 23:30:19 2009 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Tue Nov 3 23:06:36 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <4613CAAA-A646-427D-A0CD-975E493B7ABC@phys.washington.edu> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> <4613CAAA-A646-427D-A0CD-975E493B7ABC@phys.washington.edu> Message-ID: <0050132F-B781-4996-A891-DC451B57C0E0@cse.unsw.edu.au> On 04/11/2009, at 14:07, Gregory Crosswhite wrote: > Actually, it's not a typo. If you look at the source, what you'll > see is > > indexU arr n = indexS (streamU arr) n I suspect it gets rewritten back to the O(1) version somewhere after is has had a chance to fuse. If not, then it's a bug. In the vector package, I do this instead, though: indexU arr n = {-# RULES "indexU/unstreamU" forall s n. indexU (unstreamU s) n = indexS s n #-} Roman From jason.dusek at gmail.com Tue Nov 3 23:31:39 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Tue Nov 3 23:07:48 2009 Subject: [Haskell-cafe] Arrays in Clean and Haskell In-Reply-To: <132632.69517.qm@web58803.mail.re1.yahoo.com> References: <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> <132632.69517.qm@web58803.mail.re1.yahoo.com> Message-ID: <42784f260911032031l4111f0e6tea9be50d9bfe8522@mail.gmail.com> How do you read in the IOUArray? By parsing a character string or do you treat the file as binary numbers or ... ? -- Jason Dusek From john at repetae.net Tue Nov 3 23:34:39 2009 From: john at repetae.net (John Meacham) Date: Tue Nov 3 23:10:48 2009 Subject: [Haskell-cafe] Nice addition to Foreign: castAny In-Reply-To: References: Message-ID: <20091104043439.GA5072@sliver.repetae.net> On Tue, Oct 27, 2009 at 12:48:32AM -0200, Maur??cio CA wrote: > This could be beside castPtr, castCharToCChar etc. > > ---- > > castAny :: (Storable a, Storable b) => a -> b > castAny = unsafePerformIO . genericCast > where > genericCast :: (Storable a, Storable b) => a -> IO b > genericCast v = return undefined >>= \r -> > allocaBytes (max (sizeOf v) (sizeOf r)) $ \p -> > poke p v >> if False then return r else peek (castPtr p) > > ---- > > GHCi: > > > let a = -1000 :: Int16 > > castAny a :: Word16 --> > 64536 > > castAny a :: Ptr () > 0xb4c2fc18 > > castAny (castAny a :: Ptr ()) :: Int16 > -1000 > > > let b = pi :: CLDouble > > b > 3.141592653589793 > > castAny b :: CInt > 1413754136 > > castAny b :: Ptr () > 0x54442d18 > > castAny b :: CFloat > 3.3702806e12 > > castAny b :: Int8 > 24 > > > At minimum, this is safer than 'unsafeCoerce'. What do you think? Try it on a big endian architecture, or one that has alignment restrictions, or a different size for HsChar or so forth. Casting by 'punning' (as the C folks like to call it) does have uses, but they are generally hardware dependent and useful only in certain rare circumstances that a generic cast probably isn't likely to fill. John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From briand at aracnet.com Tue Nov 3 23:34:44 2009 From: briand at aracnet.com (brian) Date: Tue Nov 3 23:10:56 2009 Subject: [Haskell-cafe] Arrays in Clean and Haskell In-Reply-To: <132632.69517.qm@web58803.mail.re1.yahoo.com> References: <132632.69517.qm@web58803.mail.re1.yahoo.com> Message-ID: <3DCC9ECC-CFE6-48B6-845B-F5268BE7BF3B@aracnet.com> On Nov 3, 2009, at 7:38 PM, Philippos Apolinarius wrote: > Brian wrote: > > Really, arrays in Haskell are the most @#!$! confusing thing in > the world. > > Hi, Brian. > I am having a great difficulty with arrays in Haskell. In the > university where I study, functional programming is taught in Clean > or in me too :-) > And here comes the reason for writing this article. In the previous > version of the Gauss elimination algorithm, I have imported you're asking me ?? I have no idea. I can't even figure out which package to use. However if I had to guess, it seems to me that you want to read the data into a list and then find some ST function which can initialize an array using a list (maybe ?) Brian From rl at cse.unsw.edu.au Tue Nov 3 23:37:54 2009 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Tue Nov 3 23:14:05 2009 Subject: [Haskell-cafe] Arrays in Clean and Haskell In-Reply-To: <132632.69517.qm@web58803.mail.re1.yahoo.com> References: <132632.69517.qm@web58803.mail.re1.yahoo.com> Message-ID: On 04/11/2009, at 14:38, Philippos Apolinarius wrote: > And here comes the reason for writing this article. In the previous > version of the Gauss elimination algorithm, I have imported > Data.Array.IO. I also wrote a version of the program that imports > Data.Array.ST. The problem is that I don't know how to read an > STUArray from a file, process it, and write it back to a file. Why don't you use the IOUArray directly instead of converting it to STUArray and back? Roman From john at repetae.net Tue Nov 3 23:45:27 2009 From: john at repetae.net (John Meacham) Date: Tue Nov 3 23:21:36 2009 Subject: [Haskell-cafe] Hugs Trex for GHC / JHC / UHC / ... ? In-Reply-To: References: Message-ID: <20091104044527.GB5072@sliver.repetae.net> On Thu, Oct 08, 2009 at 11:13:42PM +0200, Peter Verswyvelen wrote: > I briefly read about Hugs record system Trex, and at first sight this > was really nice! > > I know this question was asked a long time ago already, but are there > any plans to add this extension to GHC? > > What about the other compilers, like JHC, UHC, etc? The most likely record system to be implemented by jhc would be a variant of Daan Leijen's Extensible records with scoped labels[1]. However, it is not something I will likely get to any time soon. (contributors welcome of course!) [1] http://www.cs.ioc.ee/tfp-icfp-gpce05/tfp-proc/21num.pdf -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From ok at cs.otago.ac.nz Wed Nov 4 00:04:28 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue Nov 3 23:40:42 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> Message-ID: On Nov 4, 2009, at 9:30 AM, Deniz Dogan wrote: > So what's the deal with Clean? Why is it preferable to Haskell? Why > is it not? (1) Speed. (2) If you are a Windows developer, the fact that Windows is the primary platform and others (even Mac OS, which is historically ironic) are second- (or in the case of Solaris) third-class citizens. (3) Did I mention speed? (4) It comes with its own IDE. I don't think it can do anything much that Haskell tools can't do, but if you don't like looking for things, it's a help. (5) Plus of course there's speed. (6) They're working on a Haskell front end, so you won't actually have to choose. (Anyone doing a Clean front end for Haskell?) (7) Haskell now has bang-patterns so you can specify (a bound on) intended strictness when you declare a function. But that's not in Haskell 98. (8) As a result of this, speed is a bit more "declarative" than adding $! in strange places. (9) There's a theorem prover for Clean, called Sparkle. Sadly, it's Windows-only, but we all know what most computers on the planet run, don't we? (It's probably Symbian, actually.) (10) And finally, of course, there's speed. Did I mention that? From dons at galois.com Wed Nov 4 00:15:11 2009 From: dons at galois.com (Don Stewart) Date: Tue Nov 3 23:51:29 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <4613CAAA-A646-427D-A0CD-975E493B7ABC@phys.washington.edu> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> <4613CAAA-A646-427D-A0CD-975E493B7ABC@phys.washington.edu> Message-ID: <20091104051511.GA15880@whirlpool.galois.com> Well, it depends on which indexU the OP means. The one linked in the docs is the O(1) UA type class version. -- Don gcross: > Actually, it's not a typo. If you look at the source, what you'll see > is > > indexU arr n = indexS (streamU arr) n > > and then tracking down indexS, you'll see > > > indexS (Stream next s0 _) n0 > | n0 < 0 = error "Data.Array.Vector.Stream.indexS: negative > index" > | otherwise = loop_index n0 s0 > where > loop_index n s = case next s of > Yield x s' | n == 0 -> x > | otherwise -> s' `seq` loop_index (n-1) s' > Skip s' -> s' `seq` loop_index n s' > Done -> error "Data.Array.Vector.Stream.indexS: > index too large" > > > So in other words, indexU really does have O(n) complexity since it > first converts the array into a stream and then walks down the stream in > order to find the desired element. > > Cheers, > Greg > > > On Nov 3, 2009, at 6:25 PM, Roman Leshchinskiy wrote: > >> On 04/11/2009, at 13:12, brian wrote: >> >>> indexU :: UA e => UArr e -> Int -> e >>> >>> O(n). indexU extracts an element out of an immutable unboxed array. >> >> This is a typo (unless Don inserted a nop loop into the original DPH >> code). >> >> Roman >> >> >> _______________________________________________ >> 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 From gcross at phys.washington.edu Wed Nov 4 00:16:48 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Tue Nov 3 23:53:18 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> Message-ID: <2AE3ABAD-0EB2-4AE6-BC5C-065C174FF2ED@phys.washington.edu> So I take it you are saying that it really *cleans* Haskell's clock when it comes to speed? ;-) - Greg On Nov 3, 2009, at 9:04 PM, Richard O'Keefe wrote: > > On Nov 4, 2009, at 9:30 AM, Deniz Dogan wrote: >> So what's the deal with Clean? Why is it preferable to Haskell? Why >> is it not? > > (1) Speed. > (2) If you are a Windows developer, the fact that Windows is the > primary > platform and others (even Mac OS, which is historically ironic) are > second- (or in the case of Solaris) third-class citizens. > (3) Did I mention speed? > (4) It comes with its own IDE. I don't think it can do anything > much that > Haskell tools can't do, but if you don't like looking for things, > it's > a help. > (5) Plus of course there's speed. > (6) They're working on a Haskell front end, so you won't actually > have to > choose. (Anyone doing a Clean front end for Haskell?) > (7) Haskell now has bang-patterns so you can specify (a bound on) > intended > strictness when you declare a function. But that's not in > Haskell 98. > (8) As a result of this, speed is a bit more "declarative" than adding > $! in strange places. > (9) There's a theorem prover for Clean, called Sparkle. > Sadly, it's Windows-only, but we all know what most computers on > the > planet run, don't we? (It's probably Symbian, actually.) > (10) And finally, of course, there's speed. Did I mention that? > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jfredett at gmail.com Wed Nov 4 00:19:13 2009 From: jfredett at gmail.com (Joe Fredette) Date: Tue Nov 3 23:55:29 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <2AE3ABAD-0EB2-4AE6-BC5C-065C174FF2ED@phys.washington.edu> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <2AE3ABAD-0EB2-4AE6-BC5C-065C174FF2ED@phys.washington.edu> Message-ID: <97B1809A-FA2C-425E-88A8-2382C5135A18@gmail.com> Given the Shootout results, the difference is a matter of a few seconds. If Clean Programmers need those few extra seconds, they're welcome to them. We're Lazy around here. :) /Joe On Nov 4, 2009, at 12:16 AM, Gregory Crosswhite wrote: > So I take it you are saying that it really *cleans* Haskell's clock > when it comes to speed? ;-) > > - Greg > > > On Nov 3, 2009, at 9:04 PM, Richard O'Keefe wrote: > >> >> On Nov 4, 2009, at 9:30 AM, Deniz Dogan wrote: >>> So what's the deal with Clean? Why is it preferable to Haskell? >>> Why is it not? >> >> (1) Speed. >> (2) If you are a Windows developer, the fact that Windows is the >> primary >> platform and others (even Mac OS, which is historically ironic) are >> second- (or in the case of Solaris) third-class citizens. >> (3) Did I mention speed? >> (4) It comes with its own IDE. I don't think it can do anything >> much that >> Haskell tools can't do, but if you don't like looking for things, >> it's >> a help. >> (5) Plus of course there's speed. >> (6) They're working on a Haskell front end, so you won't actually >> have to >> choose. (Anyone doing a Clean front end for Haskell?) >> (7) Haskell now has bang-patterns so you can specify (a bound on) >> intended >> strictness when you declare a function. But that's not in >> Haskell 98. >> (8) As a result of this, speed is a bit more "declarative" than >> adding >> $! in strange places. >> (9) There's a theorem prover for Clean, called Sparkle. >> Sadly, it's Windows-only, but we all know what most computers on >> the >> planet run, don't we? (It's probably Symbian, actually.) >> (10) And finally, of course, there's speed. Did I mention that? >> >> >> >> _______________________________________________ >> 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 From dons at galois.com Wed Nov 4 00:19:57 2009 From: dons at galois.com (Don Stewart) Date: Tue Nov 3 23:56:13 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> Message-ID: <20091104051957.GB15880@whirlpool.galois.com> ok: > > On Nov 4, 2009, at 9:30 AM, Deniz Dogan wrote: >> So what's the deal with Clean? Why is it preferable to Haskell? Why is >> it not? > > (1) Speed. I'd strongly argue that speed is not a reason to use Clean -- esp. if you have more than one core: http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=ghc&lang2=clean&box=1 Nor a reason to use OCaml, for that matter: http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=ghc&lang2=ocaml&box=1 The Haskell compiler isn't the bottleneck. Use it when performance matters. I do. Reading the OP's statements, though, it seems picking the right library is more of a problem. And widespread expertise in fast Haskell. -- Don From gcross at phys.washington.edu Wed Nov 4 00:22:26 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Tue Nov 3 23:58:58 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <20091104051511.GA15880@whirlpool.galois.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> <4613CAAA-A646-427D-A0CD-975E493B7ABC@phys.washington.edu> <20091104051511.GA15880@whirlpool.galois.com> Message-ID: <58F6A0DB-9AB5-472B-A969-CECA6B110264@phys.washington.edu> Oh, that's strange... the type class "UA" is defined twice, once in Data.Array.Vector and once in Data.Array.Vector.UArr; in the first module indexU is a separate function with the sources I exhibited, in the second module it is a method of the UA type-class which seems to have O(1) access for most of the defined instances. That's incredibly confusing... - Greg On Nov 3, 2009, at 9:15 PM, Don Stewart wrote: > Well, it depends on which indexU the OP means. The one linked in the > docs is > the O(1) UA type class version. > > -- Don > > gcross: >> Actually, it's not a typo. If you look at the source, what you'll >> see >> is >> >> indexU arr n = indexS (streamU arr) n >> >> and then tracking down indexS, you'll see >> >> >> indexS (Stream next s0 _) n0 >> | n0 < 0 = error "Data.Array.Vector.Stream.indexS: negative >> index" >> | otherwise = loop_index n0 s0 >> where >> loop_index n s = case next s of >> Yield x s' | n == 0 -> x >> | otherwise -> s' `seq` loop_index (n-1) s' >> Skip s' -> s' `seq` loop_index n s' >> Done -> error >> "Data.Array.Vector.Stream.indexS: >> index too large" >> >> >> So in other words, indexU really does have O(n) complexity since it >> first converts the array into a stream and then walks down the >> stream in >> order to find the desired element. >> >> Cheers, >> Greg >> >> >> On Nov 3, 2009, at 6:25 PM, Roman Leshchinskiy wrote: >> >>> On 04/11/2009, at 13:12, brian wrote: >>> >>>> indexU :: UA e => UArr e -> Int -> e >>>> >>>> O(n). indexU extracts an element out of an immutable unboxed array. >>> >>> This is a typo (unless Don inserted a nop loop into the original DPH >>> code). >>> >>> Roman >>> >>> >>> _______________________________________________ >>> 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 From dons at galois.com Wed Nov 4 00:25:06 2009 From: dons at galois.com (Don Stewart) Date: Wed Nov 4 00:01:19 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <58F6A0DB-9AB5-472B-A969-CECA6B110264@phys.washington.edu> References: <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> <4613CAAA-A646-427D-A0CD-975E493B7ABC@phys.washington.edu> <20091104051511.GA15880@whirlpool.galois.com> <58F6A0DB-9AB5-472B-A969-CECA6B110264@phys.washington.edu> Message-ID: <20091104052506.GD15880@whirlpool.galois.com> gcross: > Oh, that's strange... the type class "UA" is defined twice, once in > Data.Array.Vector and once in Data.Array.Vector.UArr; in the first No, its exported from the former. > module indexU is a separate function with the sources I exhibited, in > the second module it is a method of the UA type-class which seems to > have O(1) access for most of the defined instances. > > That's incredibly confusing... There's direct and stream-based versions. You can choose which version you need. If you use the stream-based implementations, the compiler will apply the stream fusion optimization to your loops. If you use the direct versions, that won't apply. I'd be happy to talk more about the design of the library, if you like. -- Don From briand at aracnet.com Wed Nov 4 00:25:42 2009 From: briand at aracnet.com (brian) Date: Wed Nov 4 00:01:55 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <20091104051511.GA15880@whirlpool.galois.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> <4613CAAA-A646-427D-A0CD-975E493B7ABC@phys.washington.edu> <20091104051511.GA15880@whirlpool.galois.com> Message-ID: <79D8E323-88C3-4C26-AA46-2566B7A57372@aracnet.com> Don, There is more than one indexU ? In Data.Array.Vector there is only 1 indexU that I can find. Brian On Nov 3, 2009, at 9:15 PM, Don Stewart wrote: > Well, it depends on which indexU the OP means. The one linked in the > docs is > the O(1) UA type class version. > > -- Don > > gcross: >> Actually, it's not a typo. If you look at the source, what you'll >> see >> is >> >> indexU arr n = indexS (streamU arr) n >> >> and then tracking down indexS, you'll see >> >> >> indexS (Stream next s0 _) n0 >> | n0 < 0 = error "Data.Array.Vector.Stream.indexS: negative >> index" >> | otherwise = loop_index n0 s0 >> where >> loop_index n s = case next s of >> Yield x s' | n == 0 -> x >> | otherwise -> s' `seq` loop_index (n-1) s' >> Skip s' -> s' `seq` loop_index n s' >> Done -> error >> "Data.Array.Vector.Stream.indexS: >> index too large" >> >> >> So in other words, indexU really does have O(n) complexity since it >> first converts the array into a stream and then walks down the >> stream in >> order to find the desired element. >> >> Cheers, >> Greg >> >> >> On Nov 3, 2009, at 6:25 PM, Roman Leshchinskiy wrote: >> >>> On 04/11/2009, at 13:12, brian wrote: >>> >>>> indexU :: UA e => UArr e -> Int -> e >>>> >>>> O(n). indexU extracts an element out of an immutable unboxed array. >>> >>> This is a typo (unless Don inserted a nop loop into the original DPH >>> code). >>> >>> Roman >>> >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From john at repetae.net Wed Nov 4 00:28:19 2009 From: john at repetae.net (John Meacham) Date: Wed Nov 4 00:04:29 2009 Subject: [Haskell-cafe] Re: CComplex in jhc (was: Word128, Word256) In-Reply-To: References: <20091022184554.GK7802@sliver.repetae.net> <20091025084200.GD16411@sliver.repetae.net> Message-ID: <20091104052819.GD5072@sliver.repetae.net> On Mon, Oct 26, 2009 at 12:24:39AM -0200, Maur??cio CA wrote: > > Well, before trying to get it standardized, you need to get it > > implemented and tested by at least one compiler to explore the > > design space and tradeoffs. I would happily accept any patches > > into jhc that a support for such types, I don't even think it > > would be that difficult to do. > > One should say jhc code is really clear. It's the first compiler > code I try to read and for a moment I actually believed I could > write the patch :) excellent :) > > Below is my completely naive attempt. If you want to tell me > where to go from here, I'll try. (For instance: how do I get > 'rt_bits_double_complex_' to exist.) However, I think this is far > beyond my skills... A fairly good first attempt. The main issue is that 'primitives.txt' and its associated machinery is the old way of defining primitives that is slowly being phased out. Basically, what primitives.txt did was centralize a lot of 'compiler magic' as in, it created a lot of instances for things like Num and Storable that one might expect for built in types. However, as jhc progressed, it became clear that having things built into the compiler is a real pain. Hence, for newer primitives, they are simply implemented in pure haskell. as in, instead of some magic 'data Int' somewhere and a lot of compiler defined primitives, we have 'data Int = Int Word32_' and plain instance declarations like 'instance Num Int where ...' and so forth, with primitive operators being foreign imported. So, Double and Float have both been fully converted to the new way of doing things, so look at their implementation to see how complex versions of them should be handled. John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From dons at galois.com Wed Nov 4 00:28:28 2009 From: dons at galois.com (Don Stewart) Date: Wed Nov 4 00:05:19 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <79D8E323-88C3-4C26-AA46-2566B7A57372@aracnet.com> References: <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> <4613CAAA-A646-427D-A0CD-975E493B7ABC@phys.washington.edu> <20091104051511.GA15880@whirlpool.galois.com> <79D8E323-88C3-4C26-AA46-2566B7A57372@aracnet.com> Message-ID: <20091104052828.GE15880@whirlpool.galois.com> UArr operations subject to stream fusion: http://code.haskell.org/~dons/code/uvector/Data/Array/Vector/Strict/ Direct-style operations, not subject to the optimization: http://code.haskell.org/~dons/code/uvector/Data/Array/Vector/UArr.hs /me needs to write a tutorial on this. -- Don briand: > Don, > > There is more than one indexU ? > > In Data.Array.Vector there is only 1 indexU that I can find. > > Brian > > On Nov 3, 2009, at 9:15 PM, Don Stewart wrote: > >> Well, it depends on which indexU the OP means. The one linked in the >> docs is >> the O(1) UA type class version. >> >> -- Don >> >> gcross: >>> Actually, it's not a typo. If you look at the source, what you'll >>> see >>> is >>> >>> indexU arr n = indexS (streamU arr) n >>> >>> and then tracking down indexS, you'll see >>> >>> >>> indexS (Stream next s0 _) n0 >>> | n0 < 0 = error "Data.Array.Vector.Stream.indexS: negative >>> index" >>> | otherwise = loop_index n0 s0 >>> where >>> loop_index n s = case next s of >>> Yield x s' | n == 0 -> x >>> | otherwise -> s' `seq` loop_index (n-1) s' >>> Skip s' -> s' `seq` loop_index n s' >>> Done -> error >>> "Data.Array.Vector.Stream.indexS: >>> index too large" >>> >>> >>> So in other words, indexU really does have O(n) complexity since it >>> first converts the array into a stream and then walks down the >>> stream in >>> order to find the desired element. >>> >>> Cheers, >>> Greg >>> >>> >>> On Nov 3, 2009, at 6:25 PM, Roman Leshchinskiy wrote: >>> >>>> On 04/11/2009, at 13:12, brian wrote: >>>> >>>>> indexU :: UA e => UArr e -> Int -> e >>>>> >>>>> O(n). indexU extracts an element out of an immutable unboxed array. >>>> >>>> This is a typo (unless Don inserted a nop loop into the original DPH >>>> code). >>>> >>>> Roman >>>> >>>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > From mpm at alumni.caltech.edu Wed Nov 4 00:35:33 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Wed Nov 4 00:11:44 2009 Subject: [Haskell-cafe] multi-line regex Message-ID: <4AF112A5.6090901@alumni.caltech.edu> I have some very simple regex-matching needs, and Text.Regex.Posix will work fine, EXCEPT I need to match multi-line patterns, and/or find all occurrences of text that may occur several times on different lines. So I need to turn on some kind of flag. Can someone show me how to do that? I have worked the examples in RWH so I basically know how to run the thing. From dons at galois.com Wed Nov 4 00:45:32 2009 From: dons at galois.com (Don Stewart) Date: Wed Nov 4 00:21:42 2009 Subject: [Haskell-cafe] multi-line regex In-Reply-To: <4AF112A5.6090901@alumni.caltech.edu> References: <4AF112A5.6090901@alumni.caltech.edu> Message-ID: <20091104054532.GA16075@whirlpool.galois.com> mpm: > I have some very simple regex-matching needs, and Text.Regex.Posix will > work fine, EXCEPT I need to match multi-line patterns, and/or find all > occurrences of text that may occur several times on different lines. So I > need to turn on some kind of flag. Can someone show me how to do that? I > have worked the examples in RWH so I basically know how to run the thing. Is that something that requires the PCRE bindings? From haskellmail at gmail.com Wed Nov 4 00:48:44 2009 From: haskellmail at gmail.com (kenny lu) Date: Wed Nov 4 00:24:52 2009 Subject: [Haskell-cafe] multi-line regex In-Reply-To: <4AF112A5.6090901@alumni.caltech.edu> References: <4AF112A5.6090901@alumni.caltech.edu> Message-ID: <90bba1dc0911032148w26ab1d54o9332602bd4575bbf@mail.gmail.com> Hi Michael, Could you give an example of what patterns you want to write? Regards, Kenny On Wed, Nov 4, 2009 at 1:35 PM, Michael Mossey wrote: > I have some very simple regex-matching needs, and Text.Regex.Posix will > work fine, EXCEPT I need to match multi-line patterns, and/or find all > occurrences of text that may occur several times on different lines. So I > need to turn on some kind of flag. Can someone show me how to do that? I > have worked the examples in RWH so I basically know how to run the thing. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/e5291573/attachment.html From mpm at alumni.caltech.edu Wed Nov 4 01:04:23 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Wed Nov 4 00:40:33 2009 Subject: [Haskell-cafe] multi-line regex In-Reply-To: <90bba1dc0911032148w26ab1d54o9332602bd4575bbf@mail.gmail.com> References: <4AF112A5.6090901@alumni.caltech.edu> <90bba1dc0911032148w26ab1d54o9332602bd4575bbf@mail.gmail.com> Message-ID: <4AF11967.50605@alumni.caltech.edu> kenny lu wrote: > Hi Michael, > > Could you give an example of what patterns you want to write? > > Regards, > Kenny > Something like text = "11\n abcd \n22" answer = text =~ "11.*22" :: and have it find the entire string. The default behavior is to stop matching when it encounters a newline. There is mention in the Text.Regex.Posix docs of a flag to control this behavior, but it is not easy to figure out from the docs how to provide flags. The left-hand side of the =~ is a very complex type. From Ben.Lippmeier at anu.edu.au Wed Nov 4 01:44:30 2009 From: Ben.Lippmeier at anu.edu.au (Ben Lippmeier) Date: Wed Nov 4 01:20:41 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <3e1162e60911031545g75f07716w7f9c84afb9707953@mail.gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <4AF0B95E.3080102@anu.edu.au> <3e1162e60911031545g75f07716w7f9c84afb9707953@mail.gmail.com> Message-ID: <4AF122CE.3080501@anu.edu.au> David Leimbach wrote: > I have to admit, the first time I hit the wiki page for DDC I said to > myself "Self, this sounds crazy complicated". Then I read part of the > PDF (your thesis I believe) about Region Types on the bus ride to work > and thought. "Gee I think I scared myself off too quickly". > > Uniqueness typing is quite interesting in Clean, but to control > aliasing, like really *control* aliasing, that's just far out man. > > So I still have to wrap my head around "why this isn't going to get > completely out of control" and see why it's all safer than just > writing C code but I must say the attention I will be paying to DDC > has just gone quite a bit up. :) A correct C program is just as safe as a correct Haskell/Disciple program. If you're using destructive update then aliasing, side effects and mutability all start to matter. It might look complicated when you reflect all these things in the type system, but you're really just getting a handle on the inherent complications of the underlying program. I suppose the trick is to be able to ignore said complications when you just don't care, or they're not relevant for your particular problem... Ben. From shelby at coolpage.com Wed Nov 4 02:07:01 2009 From: shelby at coolpage.com (Shelby Moore) Date: Wed Nov 4 01:43:08 2009 Subject: [Haskell-cafe] Essence of Functional Programming for Imperative Programmers Message-ID: <3265.121.97.54.144.1257318421.squirrel@webmail12.pair.com> New concise guide I am creating: http://www.coolpage.com/commentary/economic/shelby/Functional_Programming_Essence.html I was able to condense Category theory and implementation of Monads to one screen: http://www.coolpage.com/commentary/economic/shelby/Functional_Programming_Essence.html#Monads Overall, I think I have a unique method for comparing and condensing the explanation of the transistion from imperative to pure functional. What you think? It is a work-in-progress, so corrections, feedback, and flames are welcome. I will do the OOP section next and incorporate the explanations from these posts: http://www.haskell.org/pipermail/haskell-cafe/2009-November/068440.html (data vs. Module) http://www.haskell.org/pipermail/haskell-cafe/2009-November/068432.html (interface vs. virtual) P.S. The link will not change if you want to link to it now. If you mirror it, please update your mirrors periodically. There is no copyright claimed, I don't believe in copyrights any more. I intend to publish everything as PUBLIC DOMAIN (i.e. no license at all, because licenses impact composability). If I want to charge, I will put functionality behind an unpublished interface (i.e. Module). P.P.S. I only started learning functional programming about a week ago. From emax at chalmers.se Wed Nov 4 03:53:25 2009 From: emax at chalmers.se (Emil Axelsson) Date: Wed Nov 4 03:29:37 2009 Subject: [Haskell-cafe] ANNOUNCE: feldspar-language In-Reply-To: <9e5767b0911032003o28292050rba2f8efa20c0fda@mail.gmail.com> References: <4AF0F78B.2090405@chalmers.se> <9e5767b0911032003o28292050rba2f8efa20c0fda@mail.gmail.com> Message-ID: <4AF14105.6080906@chalmers.se> One thing I forgot to make clear in the announcement is that the language is still highly experimental, and some obvious things, such as complex numbers, are currently missing. So this first release should probably not be used for real applications. However, while I don't know how autotuning works, I don't see why you shouldn't be able to code it in Feldspar a few releases from now. I don't know if it will be "easy" though :) / Emil Warren Henning skrev: > I see that section 4.1 of the user guide - > http://feldspar.sourceforge.net/documents/language/FeldsparLanguage.html#htoc23 > - includes an example involving autocorrelation. > > Does this mean I could use Feldspare to easily build my own Autotune > program? I love T-Pain and Autotune the News! > > Warren > > On Tue, Nov 3, 2009 at 7:39 PM, Emil Axelsson wrote: >> I'm happy to announce the first release of Feldspar, which is an embedded >> domain-specific language with associated code generator mainly targeting DSP >> algorithms. The language is developed in cooperation by Ericsson, Chalmers >> University and E?tv?s Lor?nd University. >> >> Feldspar stands for *F*unctional *E*mbedded *L*anguage for *DSP* and >> *PAR*allelism. >> >> The language front-end is available on Hackage: >> >> http://hackage.haskell.org/package/feldspar-language >> >> The back-end C code generator will be uploaded and announced shortly. For >> more information, see: >> >> http://feldspar.sourceforge.net/ >> >> / Emil >> >> _______________________________________________ >> 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 From martindemello at gmail.com Wed Nov 4 03:56:48 2009 From: martindemello at gmail.com (Martin DeMello) Date: Wed Nov 4 03:32:58 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> Message-ID: On Wed, Nov 4, 2009 at 10:34 AM, Richard O'Keefe wrote: > (4) It comes with its own IDE. ?I don't think it can do anything much that > ? ?Haskell tools can't do, but if you don't like looking for things, it's > ? ?a help. And a well-integrated GUI toolkit. If it weren't for the Windows bias I'd have definitely taken the time to learn the language. martin From agocorona at gmail.com Wed Nov 4 04:47:14 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Wed Nov 4 04:23:25 2009 Subject: Fwd: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <5fdc56d70911031449h3314c9b9l5d1a43ab485c540@mail.gmail.com> <4AF0E65B.6060601@freegeek.org> Message-ID: The code executed by uniqueness types is somehow similar to the internal code executed in a state monad (or in the case of IO, the IO monad). The main difference is that the pairs of results (state, value) are explicitly written in Clean by the programmer and the type sytem assures that the order of executions makes sense at compile time, whereas in the case of the state monad the sequence of instructions is lazily assembled at runtime in the first step and executed in a second step. So there is a little more overhead in haskell but the code is higher level. Am I right? 2009/11/4 wren ng thornton > Stephen Tetley wrote: > >> 2009/11/3 Andrew Coppin : >> >> As far as I can tell, Clean is to Haskell as C is to Pascal. I.e., Clean >>> is >>> notionally very similar to Haskell, but with lots of added clutter, >>> complexity and general ugliness - but it's probably somehow more >>> machine-efficient as a result. >>> >>> (All of which makes the name "Clean" rather ironic, IMHO.) >>> >> >> OUuch - you really could put it the other way round. >> > > Part of this really comes down to how one feels about the monads vs > uniqueness types argument. It's a silly argument to have since the ideas are > orthogonal and only really intersect at IO, but there's history there which > lead to the current state of things. > > Sometimes in Haskell I've thought about how uniqueness typing would make > something faster, but in general all the plumbing associated with it in > Clean makes me feel like I'm writing systems-level code (i.e. C, asm) > instead of using a high-level language. The extra plumbing really makes it > feel dirtier to work with. That doesn't mean Clean is bad, but I think it > does contribute to the "cluttered" feeling Haskellers get. > > But as I said, it's a silly argument and folks should use whichever gives > them warm fuzzies. I also have a vague unnameable distaste whenever working > with Python, and rather enjoy working with Perl. Nobody's perfect :) > > -- > Live well, > ~wren > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/7d03c831/attachment.html From saihemanth at gmail.com Wed Nov 4 04:50:10 2009 From: saihemanth at gmail.com (Hemanth Kapila) Date: Wed Nov 4 04:26:20 2009 Subject: [Haskell-cafe] Storable Vector as a Storable record? Message-ID: <60d0a32f0911040150l2b00e94fu53f1be2046d0e70c@mail.gmail.com> Hi, Is it possible to somehow make a StorableVector of a StorableVector via store-record or something? If yes, could some one please provide me with some hint? I need a very fast and efficient array of a large number of $ arrays of *Int *s. And the storableVector seems to be extremely nice. Am trying to understand the way a tuple is made a storable record in the synthesizer package on hackage but I thought I will ask it here too. Thanks in advance Hemanth K -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/92b89efa/attachment.html From duncan.coutts at googlemail.com Wed Nov 4 04:56:49 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Wed Nov 4 04:33:00 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> Message-ID: <1257328609.25369.2468.camel@localhost> On Tue, 2009-11-03 at 18:12 -0800, brian wrote: > Really, arrays in Haskell are the most @#!$! confusing thing in the > world. > > There's a bunch of different array structures. > > I can't tell which one works best, and all I want to do is x[i] = value. > I thought uvector was the answer, you know, fast unboxed ARRAYs. Rather than confusing yourself with new packages like uvector I suggest you just use the arrays from the standard 'array' package that comes with GHC. It provides mutable and immutable, boxed and unboxed arrays. The mutable ones have to be used in a monad (ST or IO). The boxed ones can be used with any element type (eg an array of records) while unboxed ones work with simple primitive types like ints, floats etc. The difference is about memory layout and therefore performance: unboxed ones are simple flat C-like arrays while the boxed ones are arrays of pointers to heap objects. Duncan From ketil at malde.org Wed Nov 4 05:14:21 2009 From: ketil at malde.org (Ketil Malde) Date: Wed Nov 4 04:50:40 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <1257328609.25369.2468.camel@localhost> (Duncan Coutts's message of "Wed, 04 Nov 2009 09:56:49 +0000") References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> <1257328609.25369.2468.camel@localhost> Message-ID: <87vdhqvbpe.fsf@malde.org> Duncan Coutts writes: > The boxed [array types] can be used with any element type (eg an array of > records) while unboxed ones work with simple primitive types like ints, > floats etc. The difference is about memory layout and therefore > performance ...and of strictness. A boxed array can contain pointers to unevaluated thunks (including references to other cells in the array), an unboxed array only contains evaluated values. But yes, it'd be nice to tidy up the set of available array libraries, and perhaps related functionality (bytestring, text) to provide a unified and non-redundant, whole. Platform prime, anyone? -k -- If I haven't seen further, it is by standing in the footprints of giants From artyom.shalkhakov at gmail.com Wed Nov 4 05:17:54 2009 From: artyom.shalkhakov at gmail.com (Artyom Shalkhakov) Date: Wed Nov 4 04:54:03 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <5fdc56d70911031449h3314c9b9l5d1a43ab485c540@mail.gmail.com> <4AF0E65B.6060601@freegeek.org> Message-ID: <2076f2f90911040217u52c353e0wb691599dfd9044c0@mail.gmail.com> Hello, 2009/11/4 Alberto G. Corona : > The code executed by uniqueness types is somehow similar to the internal > code executed in a state monad (or in the case of IO, the IO monad). The > main difference is that the pairs of results ?(state, value) are explicitly > written in Clean by the programmer and the ?type sytem assures that the > order of executions makes sense?at compile time, whereas in the case of the > state monad the sequence of instructions is lazily assembled at runtime in > the first step and executed in a second step. So there is a little more > overhead in haskell but the code is?higher?level. > Am I right? I would rather say: code with uniqueness types allows for safe destructive updates. In Clean, a variable of unique type is ensured to have only one reference to it, at any time (that's why it's called "uniqueness typing"). So you can't write the code like this > f(x) + f(x) where f : *a -> int (x is of unique type), because x is clearly referenced two times here. What to do? Let f yield another reference to x! That also means that the old reference is not usable any more, since you have new one. f becomes: > f : *a -> (int, *a) and the code looks very familiar: > let (a, x') = f(x) > (b, x'') = f(x') > in a + b The function f can use destructive updates under the hood though it doesn't violate referential transparency. I bet you can you see why. I'd say that call-by-need is orthogonal to uniqueness typing. Cheers, Artyom Shalkhakov. From mklklk at hotmail.com Wed Nov 4 05:34:50 2009 From: mklklk at hotmail.com (Kui Ma) Date: Wed Nov 4 05:11:01 2009 Subject: [Haskell-cafe] Re: socket error In-Reply-To: References: Message-ID: I am having the similar problem when running TCP server application on windows XP. The server can only reads once from the handle of socket, then any operation on the handle will cause error because it is already finalized. It seems a platform issues but I have no idea about it. Date: Tue, 3 Nov 2009 17:16:06 +0100 From: agocorona@gmail.com To: haskell-cafe@haskell.org Subject: [Haskell-cafe] Re: socket error I?m running windows, ghc 6.10.3 and 6.10.4 in two different machines. 2009/11/3 Alberto G. Corona : hPutBuf: illegal operation (handle is finalized) I?m a bit lost trying to find the source of this error. I?m running an hack application (package hack). Basically it is a handler of web requests. hack can be used with different web servers: Hyena, simpleserver, HappStack.... all of them produce this error after a few interactions., Supposedly, it happens within the socket module since neither my module, nor hack, nor the hack simpleserver (package hack-handler-simpleserver) call explicitly hPutBuf I tried to reproduce the error under linux, but my ubuntu installation is too old and I?m in the process of reinstalling everything again. In the meantime, Any of you can give me any hint about the error? _________________________________________________________________ Windows Live: Keep your friends up to date with what you do online. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/4cae0785/attachment.html From martijn at van.steenbergen.nl Wed Nov 4 05:38:21 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed Nov 4 05:14:35 2009 Subject: [Haskell-cafe] Re: Fair diagonals In-Reply-To: References: Message-ID: <4AF1599D.5090302@van.steenbergen.nl> Louis Wasserman wrote: > +1 on Control.Monad.Omega. In point of fact, your diagN function is simply > > diagN = runOmega . mapM Omega > > You'll find it an interesting exercise to grok the source of > Control.Monad.Omega, obviously, but essentially, you're replacing > concatMap with a fair (diagonal) traversal order version. Thanks for the replies! I've looked at Omega but it's not fair enough. The sums of the indices are not non-decreasing: map sum $ runOmega . mapM each $ [[1..], [1..], [1..]] [3,4,4,4,5,5,5,5,6,6,5,6,6,7,7,5,6,7,7,8,8,6,6,7,8,8,9,9,6,7,... Is there another way to use Omega that meets this (very important) criterion or is Omega not the right tool here? Thanks, Martijn. From phi500ac at yahoo.ca Wed Nov 4 05:48:17 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Wed Nov 4 05:24:26 2009 Subject: [Haskell-cafe] Arrays in Clean and Haskell In-Reply-To: <3DCC9ECC-CFE6-48B6-845B-F5268BE7BF3B@aracnet.com> Message-ID: <755421.7574.qm@web58802.mail.re1.yahoo.com> Brian wrote: > However if I had to guess, it seems to me that you want to read the data into > a list and then find some ST function which can initialize an array using a list (maybe ?) It is the other way around. I want to avoit lists. I would like to read the array elements from a file, and store then directly into the array. This approach would spare me from writing using a possibly expensive heap hungry intermediate structure. --- On Tue, 11/3/09, brian wrote: From: brian Subject: Re: [Haskell-cafe] Arrays in Clean and Haskell To: "Philippos Apolinarius" Cc: haskell-cafe@haskell.org Received: Tuesday, November 3, 2009, 9:34 PM On Nov 3, 2009, at 7:38 PM, Philippos Apolinarius wrote: > Brian wrote: > > Really, arrays in Haskell are the most @#!$! confusing thing in the world. > > Hi, Brian. > I am having a great difficulty with arrays in Haskell.? In the university where I study, functional programming is taught in Clean or in me too :-) > And here comes the reason for writing this article. In the previous version of the Gauss elimination algorithm, I have imported you're asking me ??? I have no idea.? I can't even figure out which package to use. However if I had to guess, it seems to me that you want to read the data into a list and then find some ST function which can initialize an array using a list (maybe ?) Brian __________________________________________________________________ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now http://ca.toolbar.yahoo.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/b85eb0cc/attachment.html From phi500ac at yahoo.ca Wed Nov 4 05:57:41 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Wed Nov 4 05:33:49 2009 Subject: [Haskell-cafe] Arrays in Clean and Haskell In-Reply-To: <42784f260911032031l4111f0e6tea9be50d9bfe8522@mail.gmail.com> Message-ID: <884320.53729.qm@web58805.mail.re1.yahoo.com> Jason Dusek wrote: > How do you read in the IOUArray? By parsing a character string > or do you treat the file as binary numbers or ... ? I always pare the file. Parsing the file has the advantage of alowing me to have files of any format. In general, in homeworks, TA generate files using different tools.? For instance, a professor of electrical protection of hardware made a lot of measurements of transient currents due to lightning. The file has thousands of three column lines, each one containing time, voltage and current.? Students are supposed to read the file, and plot voltage and current time series. Even the numbers are in a strange format... So, one needs to parse the file. --- On Tue, 11/3/09, Jason Dusek wrote: From: Jason Dusek Subject: Re: [Haskell-cafe] Arrays in Clean and Haskell To: "Philippos Apolinarius" Cc: haskell-cafe@haskell.org Received: Tuesday, November 3, 2009, 9:31 PM ? How do you read in the IOUArray? By parsing a character string ? or do you treat the file as binary numbers or ... ? -- Jason Dusek __________________________________________________________________ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now http://ca.toolbar.yahoo.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/e1e3ffea/attachment.html From bulat.ziganshin at gmail.com Wed Nov 4 07:02:04 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Nov 4 06:43:13 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <20091104051957.GB15880@whirlpool.galois.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> Message-ID: <844075476.20091104150204@gmail.com> Hello Don, > http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=ghc&lang2=clean&box=1 > http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=ghc&lang2=ocaml&box=1 > The Haskell compiler isn't the bottleneck. Use it when performance matters. I do. Don, shootout times may be used to measure how many people was contributed solutions for each language, but nothing more. these tests depends mainly on libraries bundled with each compiler and, secondary, on enthusiasts writing low-level code -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From felipe.lessa at gmail.com Wed Nov 4 07:23:45 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Wed Nov 4 06:59:58 2009 Subject: [Haskell-cafe] Gauss Elimination -> More Clean2Haskell In-Reply-To: <2f9b2d30911031230x39c7cc7dx467fa9612c29cbd7@mail.gmail.com> References: <647041.32282.qm@web58805.mail.re1.yahoo.com> <2f9b2d30911031230x39c7cc7dx467fa9612c29cbd7@mail.gmail.com> Message-ID: <20091104122345.GC17687@kira.casa> On Tue, Nov 03, 2009 at 12:30:48PM -0800, Ryan Ingram wrote: > ] prtSol i n1 arr > ] | i < 1 = return () > ] | otherwise = do > ] b <- readArray arr (i, n1) > ] putStr ((show b)++" ") > ] prtSol (i-1) n1 arr Which is just > prtSol i n1 arr = unless (i < 1) $ do > b <- readArray arr (i, n1) > putStr ((show b)++" ") > prtSol (i-1) n1 arr -- Felipe. From sjoerd at w3future.com Wed Nov 4 07:39:13 2009 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Wed Nov 4 07:15:29 2009 Subject: [Haskell-cafe] Fair diagonals In-Reply-To: <4AF095D0.9030105@van.steenbergen.nl> References: <4AF095D0.9030105@van.steenbergen.nl> Message-ID: <44F139D4-0B29-42A1-8D45-EF80333DB182@w3future.com> I believe this does what you want: diagN :: [[a]] -> [[a]] diagN = diagN' 0 diagN' :: Integer -> [[a]] -> [[a]] diagN' i xss = case r of [] -> [] _ -> r ++ diagN' (i + 1) xss where r = diagN_i i xss diagN_i :: Integer -> [[a]] -> [[a]] diagN_i 0 [] = [[]] diagN_i _ [] = [] diagN_i _ ([]:xss) = [] diagN_i 0 ((x:xs):xss) = [ x : r | r <- diagN_i 0 xss ] diagN_i i ((x:xs):xss) = diagN_i (i - 1) (xs:xss) ++ [ x : r | r <- diagN_i i xss ] diagN_i produces all the diagonals where the sum of indices sum to i. The order of the arguments to ++ in the last line determines the bias to the earlier or later axes. Where you say you want diagN (map (:[]) xs) == map (:[]) xs, I think you mean diagN (map (:[]) xs) == [xs], which can never finish when xs is infinite, because diagN has to check there isn't an empty list in the list of lists it gets, in which case diagN must return []. Sjoerd On Nov 3, 2009, at 9:42 PM, Martijn van Steenbergen wrote: > Dear caf?, > > I am looking for a function that does an N-dimensional diagonal > traversal. I want the traversal to be fair: the sum of the indices > of the produced combinations should be non-decreasing. Let me > illustrate with an example. > > The type of a 2-dimensional traversal would look like this: >> diag2 :: [a] -> [b] -> [(a, b)] > > The first two arguments are the two half-axes of the grid and the > result is a fair diagonal traversal of all the points. For example: >>> diag2 [1,2,3] [4,5,6,7] >> [(1,4),(2,4),(1,5),(3,4),(1,6),(2,5),(1,7),(3,5),(2,6),(2,7),(3,6), >> (3,7)] > > Of course the function should work on infinite lists: >>> diag2 [1..] [1..] >> [(1,1),(2,1),(1,2),(3,1),... > > Or a combination of finite and infinite lists: >>> diag2 [1,2] [1..] >> [(1,1),(2,1),(1,2),(1,3),(2,2),(1,4),... > > Notice that in each case the sum of the pairs (which can seen as > indices in these particular examples) are non-decreasing: >>> let sums = map (uncurry (+)) >>> sums $ diag2 [1,2,3] [4,5,6,7] >> [5,6,6,7,7,7,8,8,8,9,9,10] >>> sums $ diag2 [1..] [1..] >> [2,3,3,4,4,4,5,5,5,5,6,... >>> sums $ diag2 [1,2] [1..] >> [2,3,3,4,4,5,5,6,6,7,7,... > > Similarly for 3 dimensions the type would be: >> diag3 :: [a] -> [b] -> [c] -> [(a, b, c)] > > For N dimensions we have to sacrifice some generality and ask all > axes to be of the same type and produce lists instead of tuples, but > I'm perfectly happy with that: >> diagN :: [[a]] -> [[a]] > > I have implemented diag2 and diag3 [1] but noticed that the function > bodies increase in size exponentially following Pascal's triangle > and have no clue how to generialize to N dimensions. Can you help me > write diagN? > > Bonus points for the following: > * An infinite number of singleton axes produces [origin] (and > finishes computing), e.g. forall (infinite) xs. diagN (map (:[]) xs) > == map (:[]) xs > * For equal indices, the traversal biases to axes that are occur > early in the input (but I don't know how to formalize this). > * The implementation shows regularity and elegance. > > Many thanks, > > Martijn. > > [1] http://hpaste.org/fastcgi/hpaste.fcgi/view?id=11515 > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Sjoerd Visscher sjoerd@w3future.com From florbitous at gmail.com Wed Nov 4 08:03:32 2009 From: florbitous at gmail.com (Bernie Pope) Date: Wed Nov 4 07:39:41 2009 Subject: [Haskell-cafe] Announce: language-python version 0.2 now available Message-ID: <4d8ad03a0911040503h7b75dd69m6026b86b6160ce70@mail.gmail.com> I'm pleased to announce that version 0.2 of the language-python package is now available on hackage: http://hackage.haskell.org/package/language-python language-python provides lexical analysis and parsing for Python. Major features of this release: - Support for versions 2.x and 3.x of Python (previously only 3.x was supported). - Lexical tokens and AST nodes are annotated with accurate source span information. - Comments are retained as tokens, and are collected by the parser. Main shortcomings of this release: - Support for Unicode is limited (waiting on Unicode support in Alex). - It has only undergone minimal testing (testing infrastructure is still being built). I've also written a small client of the package, called language-python-colour, which renders Python source code as XHTML for colouring etc. The main purpose of this is to demonstrate how to use language-python, and the utility of accurate source spans. http://hackage.haskell.org/package/language-python-colour Example output: http://www.cs.mu.oz.au/~bjpop/code/lsystem.py.html Cheers, Bernie. From gour at gour-nitai.com Wed Nov 4 08:30:37 2009 From: gour at gour-nitai.com (Gour) Date: Wed Nov 4 08:06:26 2009 Subject: [Haskell-cafe] Re: Best Editor In Windows In-Reply-To: <8740041C-68EA-4940-A8AA-80A4A1BD2C47@phys.washington.edu> References: <581589.80982.qm@web58804.mail.re1.yahoo.com> <20091103212609.6e72e0ab@gaura-nitai.no-ip.org> <8740041C-68EA-4940-A8AA-80A4A1BD2C47@phys.washington.edu> Message-ID: <20091104143037.2e076462@gaura-nitai.no-ip.org> On Tue, 3 Nov 2009 12:47:40 -0800 >>>>>> "Gregory" == Gregory Crosswhite >>>>>> wrote: Gregory> The problem with Leo is that although there are rarely Gregory> performance problems when navigating and editing the outline, Gregory> the text pane can be very slow at times when using the Gregory> Tk-based GUI --- even on modern hardware --- because the Gregory> syntax highlighter is written in Python. (Incidentally, as Gregory> much as I love Leo, I also hold it up as an example of how Gregory> slow scripting languages aren't always "fast enough" as their Gregory> proponents claim. :-) ) :-) Gregory> There are two solutions to this: First, you can use the Gregory> Qt-based Leo GUI, which uses the native C++ colorizer built Gregory> into QtScintilla, which I have never had any performance Gregory> problems with. Since you (reasonably) really like Gregory> haskell-mode in Emacs, though, you can alternatively use the Gregory> Emacs plugin so that you end up using Leo to navigate through Gregory> your code to the chunk that you want to edit, and then using Gregory> Emacs to do the actual editing. This might sound like an Gregory> awkward setup, but I actually find that navigating in this way Gregory> requires much less mental energy than scanning through Gregory> multiple flat files to pick out the code that you want to edit Gregory> next, and the plugin makes this type of workflow fairly Gregory> painless. Thanks to your help, now I made Qt Leo to work with my Emacs. :-) Gregory> Viewing Leo as a "meta-editor" is a good way to think about it. Good. Let me try to imbibe this view more... Sincerely, Gour -- Gour | Hlapicina, Croatia | GPG key: F96FF5F6 ---------------------------------------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/5b2ee4f2/signature.bin From ketil at malde.org Wed Nov 4 08:31:20 2009 From: ketil at malde.org (Ketil Malde) Date: Wed Nov 4 08:10:09 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <844075476.20091104150204@gmail.com> (Bulat Ziganshin's message of "Wed, 4 Nov 2009 15:02:04 +0300") References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> Message-ID: <871vkev2l3.fsf@malde.org> Bulat Ziganshin writes: >> http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=ghc&lang2=clean&box=1 >> http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=ghc&lang2=ocaml&box=1 >> The Haskell compiler isn't the bottleneck. Use it when performance matters. I do. > Don, shootout times may be used to measure how many people was > contributed solutions for each language, but nothing more. Well, it clearly demonstrates that it is possible to write fast code in Haskell. Last time I looked, much of the shootout code was overly complicated (i.e. "enthusiasts writing low-level code"). And I can't help but notice that Clean beats Haskell on code compactness. It'd be interesting to see how well more na?ve/idiomatic code fares. While it's nice to be able to write fast programs, the main reason to use Haskell is to write succinct and correct programs. (Is it possible to have an alternative Haskell "track" in the shootouts?) Since this was done, there has been great strides in available libraries and GHC optimizations, and it'd also be interesting to see whether we now are able to optimize ourselves away from much of the overhead. -k -- If I haven't seen further, it is by standing in the footprints of giants From agocorona at gmail.com Wed Nov 4 08:36:05 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Wed Nov 4 08:12:14 2009 Subject: Fwd: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <5fdc56d70911031449h3314c9b9l5d1a43ab485c540@mail.gmail.com> <4AF0E65B.6060601@freegeek.org> <2076f2f90911040217u52c353e0wb691599dfd9044c0@mail.gmail.com> Message-ID: Artyom. I know what uniqueness means. What I meant is that the context in which uniqueness is used, for imperative sequences: (y, s')= proc1 s x (z, s'')= proc2 s' y ..... is essentially the same sequence as if we rewrite an state monad to make the state explicit. When the state is the "world" state, then it is similar to the IO monad. An state monad forces a single use of the implicit state variable too (unless you pass it trough the next step without changes. That can be done in Clean too. 2009/11/4 Artyom Shalkhakov Hello, > > 2009/11/4 Alberto G. Corona : > > The code executed by uniqueness types is somehow similar to the internal > > code executed in a state monad (or in the case of IO, the IO monad). The > > main difference is that the pairs of results (state, value) are > explicitly > > written in Clean by the programmer and the type sytem assures that the > > order of executions makes sense at compile time, whereas in the case of > the > > state monad the sequence of instructions is lazily assembled at runtime > in > > the first step and executed in a second step. So there is a little more > > overhead in haskell but the code is higher level. > > Am I right? > > I would rather say: code with uniqueness types allows for safe > destructive updates. > > In Clean, a variable of unique type is ensured to have only one > reference to it, at any time (that's why it's called "uniqueness > typing"). So you can't write the code like this > > > f(x) + f(x) > > where f : *a -> int (x is of unique type), because x is clearly > referenced two times here. What to do? Let f yield another reference > to x! That also means that the old reference is not usable any more, > since you have new one. f becomes: > > > f : *a -> (int, *a) > > and the code looks very familiar: > > > let (a, x') = f(x) > > (b, x'') = f(x') > > in a + b > > The function f can use destructive updates under the hood though it > doesn't violate referential transparency. I bet you can you see why. > > I'd say that call-by-need is orthogonal to uniqueness typing. > > Cheers, > Artyom Shalkhakov. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/f0eb5930/attachment.html From bulat.ziganshin at gmail.com Wed Nov 4 08:45:58 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Nov 4 08:23:21 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <871vkev2l3.fsf@malde.org> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> Message-ID: <1128936951.20091104164558@gmail.com> Hello Ketil, Wednesday, November 4, 2009, 4:31:20 PM, you wrote: > Well, it clearly demonstrates that it is possible to write fast code in > Haskell. my measures says that by psending 3x more time than for C you can optimize haskell code to be only 3x slower than C one > succinct and correct programs. (Is it possible to have an alternative > Haskell "track" in the shootouts?) even w/o enthusiasts Shootout mainly measure speed of libraries > Since this was done, there has been great strides in available libraries > and GHC optimizations, and it'd also be interesting to see whether we > now are able to optimize ourselves away from much of the overhead. eh, if it was possible, we have seen this. both on shootout and here when people are crying that their code isn't as fast as those ads say. haskell compilation can't yet automatically avoid laziness and convert pure high-level code into equivalent of C one. libraries doesn't change anything - they provide low-level optimized solutions for particular tasks but can't optimize your own code once you started to write it -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From niklas.broberg at gmail.com Wed Nov 4 09:05:09 2009 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Wed Nov 4 08:41:17 2009 Subject: [Haskell-cafe] ANN: haskell-src-exts-1.3.0 Message-ID: Fellow Haskelleers, I'm pleased to announce the release of haskell-src-exts-1.3.0! * On hackage: http://hackage.haskell.org/package/haskell-src-exts * Via cabal: cabal install haskell-src-exts * Darcs repo: http://code.haskell.org/haskell-src-exts Version 1.3.0 is a new major release, following the PVP, as it contains a few backwards-incompatible changes, making the 1.2.x branch a very short parenthesis in history. There are two main new things in 1.3.0: fixity application is now handled uniformly regardless of which AST you use, simple or annotated, and the parser now supports multiple modules in the same source file. haskell-src-exts-1.3.0: ==================== * The *.Fixity modules now export the same Fixity type (incidentally the one previously used by the simple un-annotated parsing) and the same helper functions. If you've done all your Fixity handling using the helper functions (infix_, infixl_, infixr_), or if you've only used fixities for the un-annotated AST, you're safe. Only if you've manually created values of the annotated Fixity type will you need to pay attention. * A new entry point in the parser allows multiple modules to be parsed from the same source file ( parseModules[With[Mode|Comments]] ). * SpecialCon is now an instance of Pretty (don't ask me why it wasn't before). * fromParseResult now displays the filename in case of a failed parse. * A few bug fixes to the exact-printer (that not many seem to be using just yet). Please help me test and report! Grab a darcs version, put your source files in the Test/examples dir, and go cabal test (in the top dir). Any failing cases not due to CPP or literate source files (for the exact-printer), please report to the trac: http://trac.haskell.org/haskell-src-exts Cheers, /Niklas From haskellmail at gmail.com Wed Nov 4 09:17:30 2009 From: haskellmail at gmail.com (kenny lu) Date: Wed Nov 4 08:53:38 2009 Subject: [Haskell-cafe] multi-line regex In-Reply-To: <4AF11967.50605@alumni.caltech.edu> References: <4AF112A5.6090901@alumni.caltech.edu> <90bba1dc0911032148w26ab1d54o9332602bd4575bbf@mail.gmail.com> <4AF11967.50605@alumni.caltech.edu> Message-ID: <90bba1dc0911040617j30c0541eqab1057e260a83bf9@mail.gmail.com> Michael, Here is how I do it. > module Main where > import Text.Regex.Posix.ByteString > import Data.Maybe > import qualified Data.ByteString.Char8 as S > text = S.pack "11\n abcd \n22" > p = S.pack "11\n(.*)\n22" > main :: IO () > main = > do { (Right pat) <- compile compExtended execBlank p > ; res <- regexec pat text > ; case res of > { (Right (Just (_,_,_,m))) -> putStrLn (show m) > ; _ -> putStrLn "not matched." > } > } You may swap out ByteString with String, PCRE should be similar, too. Regards, Kenny On Wed, Nov 4, 2009 at 2:04 PM, Michael Mossey wrote: > > > kenny lu wrote: > >> Hi Michael, >> >> Could you give an example of what patterns you want to write? >> >> Regards, >> Kenny >> >> > Something like > > text = "11\n abcd \n22" > answer = text =~ "11.*22" :: > > and have it find the entire string. The default behavior is to stop > matching when it encounters a newline. There is mention in the > Text.Regex.Posix docs of a flag to control this behavior, but it is not easy > to figure out from the docs how to provide flags. The left-hand side of the > =~ is a very complex type. > > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/9554dc36/attachment.html From twanvl at gmail.com Wed Nov 4 09:21:46 2009 From: twanvl at gmail.com (Twan van Laarhoven) Date: Wed Nov 4 08:57:53 2009 Subject: [Haskell-cafe] Fair diagonals In-Reply-To: <44F139D4-0B29-42A1-8D45-EF80333DB182@w3future.com> References: <4AF095D0.9030105@van.steenbergen.nl> <44F139D4-0B29-42A1-8D45-EF80333DB182@w3future.com> Message-ID: <4AF18DFA.7020602@gmail.com> Sjoerd Visscher wrote: > I believe this does what you want: > > The attached code should be more efficient, since it doesn't use integer indices. Note that this is just a 'level' monad: the list is stratified into levels, when combining two levels, the level of the result is the sum of the levels of the inputs. map (map sum) . runDiags . traverse each $ [[1..], [1..], [1..]] [[3],[4,4,4],[5,5,5,5,5,5],[6,6,6,6,6,6,6,6,6,6],[7,7,7,7,7,7,7,7,7,7,7,... I looked on hackage but I was surprised that I couldn't find this simple monad. The package level-monad does look very similar, only it uses a different list type for the representation. By the way, it seems Omega intentionally doesn't use this design. To quote the documentation "... a breadth-first search of a data structure can fall short if it has an infinitely branching node. Omega addresses this problem ..." Twan -------------- next part -------------- A non-text attachment was scrubbed... Name: MonadDiag.hs Type: text/x-haskell Size: 1226 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/b0a07eb0/MonadDiag.bin From sjoerd at w3future.com Wed Nov 4 09:37:20 2009 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Wed Nov 4 09:13:30 2009 Subject: [Haskell-cafe] Fair diagonals In-Reply-To: <4AF18DFA.7020602@gmail.com> References: <4AF095D0.9030105@van.steenbergen.nl> <44F139D4-0B29-42A1-8D45-EF80333DB182@w3future.com> <4AF18DFA.7020602@gmail.com> Message-ID: <3B0A27AE-F76F-4F38-AD4D-8561007B6595@w3future.com> On Nov 4, 2009, at 3:21 PM, Twan van Laarhoven wrote: > > I looked on hackage but I was surprised that I couldn't find this > simple monad. The package level-monad does look very similar, only > it uses a different list type for the representation. > indeed, level-monad works as well: import Control.Monad.Levels import Data.FMList (fromList) diagN = bfs . mapM fromList -- Sjoerd Visscher sjoerd@w3future.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/4609dcee/attachment.html From jvranish at gmail.com Wed Nov 4 09:48:21 2009 From: jvranish at gmail.com (Job Vranish) Date: Wed Nov 4 09:24:31 2009 Subject: [Haskell-cafe] IORefs and weak pointers In-Reply-To: <1257192259.939.1343203007@webmail.messagingengine.com> References: <1257184127.11636.1343178769@webmail.messagingengine.com> <1257192259.939.1343203007@webmail.messagingengine.com> Message-ID: Wow, this looks like a bug to me. If it's not a bug, then it's horribly unintuitive. I extended your example in an effort to figure out what was going on. Apparently weak pointers loath live IORefs: import Data.IORef import Data.Maybe import System.Mem import System.Mem.Weak import Control.Monad data A = A String data B = B String (IORef Int) showA (A s) = s showB (B s _) = s main = do -- works as expected: ref <- return $ A "A" ptr <- mkWeak ref 21 Nothing performGC print . isNothing =<< deRefWeak ptr print (showA ref) -- why doesn't this work? ref <- liftM (B "B") $ newIORef 42 ptr <- mkWeak ref 21 Nothing performGC print . isNothing =<< deRefWeak ptr print (showB ref) -- this works, wtf??? ref <- liftM (B "B") $ return undefined ptr <- mkWeak ref 21 Nothing performGC print . isNothing =<< deRefWeak ptr print (showB ref) I don't think this is the expected behavior. The docs on Weak pointers don't mention anything like this. I suspect something in the GC is getting confused by the IORef somehow. - Job 2009/11/2 Patai Gergely > > Could mkWeakPair do what you want? > > > http://haskell.org/ghc/docs/latest/html/libraries/base/System-Mem-Weak.html#v:mkWeakPair > No, it's just a convenience function that doesn't help much, because the > value already refers to the IORef anyway. > > Here's a minimal example to illustrate the problem: > > import Data.IORef > import Data.Maybe > import System.Mem > import System.Mem.Weak > > main = do > ref <- newIORef 42 > ptr <- mkWeak ref 21 Nothing > performGC > print . isNothing =<< deRefWeak ptr > print =<< readIORef ref > > Depending on whether you compile with optimisations, the weak reference > might be reported dead, even though the IORef is alive and kicking. > Switching to mkWeakPair (or just mentioning ref in the value somehow) > doesn't affect that. > > > Or are you trying to do something else? > The goal is to create mutable objects whose update codes are tracked by > the main program, but they can be thrown out when all the other > references to the objects are lost. Creating weak pointers with MutVar#s > seems to do the trick, but I'm not confident if it is a solution I can > trust... > > Gergely > > -- > http://www.fastmail.fm - A fast, anti-spam email service. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/404d68bc/attachment.html From apfelmus at quantentunnel.de Wed Nov 4 09:56:28 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Wed Nov 4 09:33:09 2009 Subject: [Haskell-cafe] Re: Fair diagonals In-Reply-To: <7ca3f0160911031310i7846ce2dx48ac50fa1b31b95b@mail.gmail.com> References: <4AF095D0.9030105@van.steenbergen.nl> <7ca3f0160911031310i7846ce2dx48ac50fa1b31b95b@mail.gmail.com> Message-ID: Luke Palmer wrote: > I believe you can get what you want using the diagonal function from > Control.Monad.Omega. > > product xs ys = [ [ (x,y) | y <- ys ] | x <- xs ] > diag2 xs ys = diagonal (product xs ys) > > I think if you separate taking the cartesian product and flattening > it, like this, you might have an easier time wrangling all the > different variants you want. Note that Control.Monad.Omega is not a monad. The law of associativity is broken, at least in a direct sense. Regards, apfelmus -- http://apfelmus.nfshost.com From pepeiborra at gmail.com Wed Nov 4 09:57:15 2009 From: pepeiborra at gmail.com (Jose Iborra) Date: Wed Nov 4 09:33:26 2009 Subject: [Haskell-cafe] ANN: haskell-src-exts-1.3.0 In-Reply-To: References: Message-ID: Brilliant ! This release promptly fixes an annoying bug I was about to report with the pretty printing (not exact) of infix function declarations like > instance Applicative (Either e) where > pure = Right > > Right f <*> Right x = Right (f x) > Left e <*> _ = Left e > _ <*> Left e = Left e Thanks, pepe On 04/11/2009, at 15:05, Niklas Broberg wrote: > Fellow Haskelleers, > > I'm pleased to announce the release of haskell-src-exts-1.3.0! > > * On hackage: http://hackage.haskell.org/package/haskell-src-exts > * Via cabal: cabal install haskell-src-exts > * Darcs repo: http://code.haskell.org/haskell-src-exts > > Version 1.3.0 is a new major release, following the PVP, as it > contains a few backwards-incompatible changes, making the 1.2.x branch > a very short parenthesis in history. There are two main new things in > 1.3.0: fixity application is now handled uniformly regardless of which > AST you use, simple or annotated, and the parser now supports multiple > modules in the same source file. > > haskell-src-exts-1.3.0: > ==================== > > * The *.Fixity modules now export the same Fixity type (incidentally > the one previously used by the simple un-annotated parsing) and the > same helper functions. If you've done all your Fixity handling using > the helper functions (infix_, infixl_, infixr_), or if you've only > used fixities for the un-annotated AST, you're safe. Only if you've > manually created values of the annotated Fixity type will you need to > pay attention. > > * A new entry point in the parser allows multiple modules to be parsed > from the same source file ( parseModules[With[Mode|Comments]] ). > > * SpecialCon is now an instance of Pretty (don't ask me why it > wasn't before). > > * fromParseResult now displays the filename in case of a failed parse. > > * A few bug fixes to the exact-printer (that not many seem to be using > just yet). > > Please help me test and report! Grab a darcs version, put your source > files in the Test/examples dir, and go cabal test (in the top dir). > Any failing cases not due to CPP or literate source files (for the > exact-printer), please report to the trac: > http://trac.haskell.org/haskell-src-exts > > Cheers, > > /Niklas > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From agocorona at gmail.com Wed Nov 4 09:58:31 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Wed Nov 4 09:34:41 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <1128936951.20091104164558@gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> Message-ID: I personally don?t care about raw performance. Haskell is in the top of the list of language performance. It has all the ingredients for improving performance in the coming years: A core language, clear execution strategy, analysis and parsing, transformations based on math rules. So my code will improve with each new compiler version at the same or better pace than any other language. Moreover I can not care less about how fast is C, when I simply can not program many things I need in C or C++ or Java and in general any of the language of the performance list that are above... or below, because they lack the necessary type safety, expressiveness, abstraction.etc. Not to mention time. Not to mention the growing community etc. Regards. 2009/11/4 Bulat Ziganshin > Hello Ketil, > > Wednesday, November 4, 2009, 4:31:20 PM, you wrote: > > > Well, it clearly demonstrates that it is possible to write fast code in > > Haskell. > > my measures says that by psending 3x more time than for C you can > optimize haskell code to be only 3x slower than C one > > > succinct and correct programs. (Is it possible to have an alternative > > Haskell "track" in the shootouts?) > > even w/o enthusiasts Shootout mainly measure speed of libraries > > > Since this was done, there has been great strides in available libraries > > and GHC optimizations, and it'd also be interesting to see whether we > > now are able to optimize ourselves away from much of the overhead. > > eh, if it was possible, we have seen this. both on shootout and here > when people are crying that their code isn't as fast as those ads say. > haskell compilation can't yet automatically avoid laziness and convert > pure high-level code into equivalent of C one. libraries doesn't > change anything - they provide low-level optimized solutions for > particular tasks but can't optimize your own code once you started to > write it > > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/92a18066/attachment.html From edskodevries at gmail.com Wed Nov 4 10:11:58 2009 From: edskodevries at gmail.com (Edsko de Vries) Date: Wed Nov 4 09:51:29 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <5fdc56d70911031449h3314c9b9l5d1a43ab485c540@mail.gmail.com> <4AF0E65B.6060601@freegeek.org> <2076f2f90911040217u52c353e0wb691599dfd9044c0@mail.gmail.com> Message-ID: <4EFDB41F-AA0B-4C76-9AE5-AA49384A6A6F@gmail.com> On 4 Nov 2009, at 13:36, Alberto G. Corona wrote: > Artyom. > > I know what uniqueness means. What I meant is that the context in > which uniqueness is used, for imperative sequences: > > (y, s')= proc1 s x > (z, s'')= proc2 s' y > ..... > > is essentially the same sequence as if we rewrite an state monad to > make the state explicit. When the state is the "world" state, then > it is similar to the IO monad. Yes, as long as there is a single thing that is being updated there's little difference between the state monad and a unique type. But uniqueness typing is more general. For instance, a function which updates two arrays f (arr1, arr2) = (update arr1 0 'x', update arr2 0 'y') is easily written in functional style in Clean, whereas in Haskell we need to sequentialize the two updates: f (arr1, arr2) = do writeArray arr1 0 'x' writeArray arr2 0 'y' You can find a more detailed comparison in my thesis (https://www.cs.tcd.ie/Edsko.de.Vries/pub/MakingUniquenessTypingLessUnique-screen.pdf , Section 2.8.7). -Edsko From leimy2k at gmail.com Wed Nov 4 10:25:38 2009 From: leimy2k at gmail.com (David Leimbach) Date: Wed Nov 4 10:01:47 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <4AF122CE.3080501@anu.edu.au> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <4AF0B95E.3080102@anu.edu.au> <3e1162e60911031545g75f07716w7f9c84afb9707953@mail.gmail.com> <4AF122CE.3080501@anu.edu.au> Message-ID: <3e1162e60911040725l2ff52169kef697ae5a00d9226@mail.gmail.com> On Tue, Nov 3, 2009 at 10:44 PM, Ben Lippmeier wrote: > David Leimbach wrote: > >> I have to admit, the first time I hit the wiki page for DDC I said to >> myself "Self, this sounds crazy complicated". Then I read part of the PDF >> (your thesis I believe) about Region Types on the bus ride to work and >> thought. "Gee I think I scared myself off too quickly". >> >> Uniqueness typing is quite interesting in Clean, but to control aliasing, >> like really *control* aliasing, that's just far out man. >> >> So I still have to wrap my head around "why this isn't going to get >> completely out of control" and see why it's all safer than just writing C >> code but I must say the attention I will be paying to DDC has just gone >> quite a bit up. >> > > :) A correct C program is just as safe as a correct Haskell/Disciple > program. > Well, of course, the question is in what sort of guarantees a language or compiler provides I guess. > > If you're using destructive update then aliasing, side effects and > mutability all start to matter. It might look complicated when you reflect > all these things in the type system, but you're really just getting a handle > on the inherent complications of the underlying program. > So it's just really more notation to let you know which tools are being used when you use them? Does Disciple completely avoid the need for such things as unsafePerformIO? (a perhaps overly paranoid comment but...) I realize we're probably not supposed to worry about the existence of unsafePerformIO, and that library authors "know what they're doing". But doesn't it automatically mean that there's a bit of implicit trust whenever I see a function that's of type (a -> a) that there *isn't* IO going on in there? :-) If Disciple can guarantee that no one is allowed to cheat, is that not a better approach? > I suppose the trick is to be able to ignore said complications when you > just don't care, or they're not relevant for your particular problem... > Yes, the Disciple documentation says that this stuff can be inferred, but I don't even let Haskell infer my types for *any* functions I write in any code. I like to restrict what can go in and out of the function even if it's more general. Perhaps this is the knee-jerk reaction of an angry Erlang programmer who really wanted some types to reign in the overly-dynamic evaluations that are allowed in that environment, but that's how I roll baby! I will admit that on occasion I will write and expression that I think does what I want, and look at in in ghci, having it tell me the type because sometimes I've not had enough coffee to do it in my head, but I either look at the inferred type and realize that it's what I originally wanted, or add further restrictions. Dave > > Ben. > > > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/967ad9ee/attachment.html From leimy2k at gmail.com Wed Nov 4 10:27:26 2009 From: leimy2k at gmail.com (David Leimbach) Date: Wed Nov 4 10:03:34 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <4EFDB41F-AA0B-4C76-9AE5-AA49384A6A6F@gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <5fdc56d70911031449h3314c9b9l5d1a43ab485c540@mail.gmail.com> <4AF0E65B.6060601@freegeek.org> <2076f2f90911040217u52c353e0wb691599dfd9044c0@mail.gmail.com> <4EFDB41F-AA0B-4C76-9AE5-AA49384A6A6F@gmail.com> Message-ID: <3e1162e60911040727y3b516038x257daeed0dc49fb1@mail.gmail.com> On Wed, Nov 4, 2009 at 7:11 AM, Edsko de Vries wrote: > > On 4 Nov 2009, at 13:36, Alberto G. Corona wrote: > > Artyom. >> >> I know what uniqueness means. What I meant is that the context in which >> uniqueness is used, for imperative sequences: >> >> (y, s')= proc1 s x >> (z, s'')= proc2 s' y >> ..... >> >> is essentially the same sequence as if we rewrite an state monad to make >> the state explicit. When the state is the "world" state, then it is similar >> to the IO monad. >> > > Yes, as long as there is a single thing that is being updated there's > little difference between the state monad and a unique type. But uniqueness > typing is more general. For instance, a function which updates two arrays > > f (arr1, arr2) = (update arr1 0 'x', update arr2 0 'y') > > is easily written in functional style in Clean, whereas in Haskell we need > to sequentialize the two updates: > > f (arr1, arr2) > = do writeArray arr1 0 'x' > writeArray arr2 0 'y' > Those sequential updates can be run concurrently on both, just with different syntax though right? > > You can find a more detailed comparison in my thesis ( > https://www.cs.tcd.ie/Edsko.de.Vries/pub/MakingUniquenessTypingLessUnique-screen.pdf, > Section 2.8.7). > > -Edsko > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/60ea9583/attachment.html From leimy2k at gmail.com Wed Nov 4 10:30:35 2009 From: leimy2k at gmail.com (David Leimbach) Date: Wed Nov 4 10:06:43 2009 Subject: [Haskell-cafe] multi-line regex In-Reply-To: <90bba1dc0911040617j30c0541eqab1057e260a83bf9@mail.gmail.com> References: <4AF112A5.6090901@alumni.caltech.edu> <90bba1dc0911032148w26ab1d54o9332602bd4575bbf@mail.gmail.com> <4AF11967.50605@alumni.caltech.edu> <90bba1dc0911040617j30c0541eqab1057e260a83bf9@mail.gmail.com> Message-ID: <3e1162e60911040730o79d28285k40d0a05c0117a50f@mail.gmail.com> Multi-line regular expressions are indeed powerful. Rob Pike has a good paper on it available at: http://doc.cat-v.org/bell_labs/structural_regexps/se.pdf Explains how line-based regular expressions are limiting etc. The Sam and Acme editors supported these. Python does too now. http://code.google.com/p/sregex/ On Wed, Nov 4, 2009 at 6:17 AM, kenny lu wrote: > Michael, > > Here is how I do it. > > > > module Main where > > > import Text.Regex.Posix.ByteString > > import Data.Maybe > > import qualified Data.ByteString.Char8 as S > > > text = S.pack "11\n abcd \n22" > > p = S.pack "11\n(.*)\n22" > > > > main :: IO () > > main = > > do { (Right pat) <- compile compExtended execBlank p > > ; res <- regexec pat text > > ; case res of > > { (Right (Just (_,_,_,m))) -> putStrLn (show m) > > ; _ -> putStrLn "not matched." > > } > > } > > You may swap out ByteString with String, > PCRE should be similar, too. > > Regards, > Kenny > > > > On Wed, Nov 4, 2009 at 2:04 PM, Michael Mossey wrote: > >> >> >> kenny lu wrote: >> >>> Hi Michael, >>> >>> Could you give an example of what patterns you want to write? >>> >>> Regards, >>> Kenny >>> >>> >> Something like >> >> text = "11\n abcd \n22" >> answer = text =~ "11.*22" :: >> >> and have it find the entire string. The default behavior is to stop >> matching when it encounters a newline. There is mention in the >> Text.Regex.Posix docs of a flag to control this behavior, but it is not easy >> to figure out from the docs how to provide flags. The left-hand side of the >> =~ is a very complex type. >> >> >> >> >> >> _______________________________________________ >> 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 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/ea7df4e6/attachment.html From bulat.ziganshin at gmail.com Wed Nov 4 10:34:32 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Nov 4 10:11:30 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> Message-ID: <702506707.20091104183432@gmail.com> Hello Alberto, Wednesday, November 4, 2009, 5:58:31 PM, you wrote: > I personally don?t care about raw performance. me too. actually, i write time-critical parts of my app in c++ > Haskell is in the > top of the list of language performance. this list is meaningless, as i said before > It has all the?ingredients > for improving?performance in the coming years: that's different question. i think that at the last end lazy languages will become as efficient as assembler, it just may happen not in my lifespan :) > I can not care less about how fast is C, when I simply can not > program many things I need in C or C++ or Java ?and in general any > of the language of the performance list that are above... if you don't know how to implement things in C, you cannot do it efficiently in Haskell too. when i write efficient code in Haskell, i actually use Haskell as obscure assembler (the same holds for C) > or below, > because they lack the necessary type safety, expressiveness, > abstraction.etc. they also can't make you coffee but it's is different story. i use Haskell too. i just know that it is slow and use other languages when i really need speed. it's why my archiver is world's fastest one :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From anotheraddress at gmx.de Wed Nov 4 10:49:28 2009 From: anotheraddress at gmx.de (Daniel =?iso-8859-1?q?Sch=FCssler?=) Date: Wed Nov 4 10:25:38 2009 Subject: [Haskell-cafe] Emacs: Haskell snippets for YASnippet Message-ID: <200911041649.28663.anotheraddress@gmx.de> Hi List, this is rather trivial, but maybe someone else finds these useful: darcs get http://code.haskell.org/~daniels/haskell-snippets/ Especially the LANGUAGE ones have saved me quite some typing :) Additions welcome. Usage: If not already installed, get YASnippet: http://code.google.com/p/yasnippet/ and put this into your .emacs: (load-file "some-path/haskell-snippets.el") to expand a snippet, just enter the macro string (these are listed in the haskell-snippets.el file) and press . If the snippet has holes, press again to jump to the next hole. Greetings, Daniel From deniz.a.m.dogan at gmail.com Wed Nov 4 11:41:05 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Wed Nov 4 11:17:33 2009 Subject: [Haskell-cafe] Emacs: Haskell snippets for YASnippet In-Reply-To: <200911041649.28663.anotheraddress@gmx.de> References: <200911041649.28663.anotheraddress@gmx.de> Message-ID: <7b501d5c0911040841s5a14615dra680d91336d018a8@mail.gmail.com> 2009/11/4 Daniel Sch?ssler : > Hi List, > > this is rather trivial, but maybe someone else finds these useful: > > darcs get http://code.haskell.org/~daniels/haskell-snippets/ > > Especially the LANGUAGE ones have saved me quite some typing :) Additions > welcome. > > Usage: If not already installed, get YASnippet: > http://code.google.com/p/yasnippet/ > > and put this into your .emacs: > > (load-file "some-path/haskell-snippets.el") > > to expand a snippet, just enter the macro string (these are listed in the > haskell-snippets.el file) and press . If the snippet has holes, press > again to jump to the next hole. > > > Greetings, > Daniel > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > Cool stuff, I will probably be using this! In my opinion, the naming convention is a bit inconsistent. Extension snippets all begin with "-x" but imports begin with "imp". I'd prefer seeing import snippets begin with "-i" and use names easier to remember, e.g. instead of "impcms", use "-istate" and instead of "impdm.Map" use "-imap", etc. At least consider it! :) And about the "bot" -> "?" rule... Is ? really valid Haskell? -- Deniz Dogan From ketil at malde.org Wed Nov 4 11:43:38 2009 From: ketil at malde.org (Ketil Malde) Date: Wed Nov 4 11:19:45 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <1128936951.20091104164558@gmail.com> (Bulat Ziganshin's message of "Wed, 4 Nov 2009 16:45:58 +0300") References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> Message-ID: <87tyxatf45.fsf@malde.org> Bulat Ziganshin writes: >> Well, it clearly demonstrates that it is possible to write fast code >> in Haskell. > my measures says that by psending 3x more time than for C you can > optimize haskell code to be only 3x slower than C one Right?, the interesting thing is not how fast I can get with N times the effort, but if I can get fast enough with 1/N. > when people are crying that their code isn't as fast as those ads say. > haskell compilation can't yet automatically avoid laziness and convert > pure high-level code into equivalent of C one. Many of those people are making fairly simple mistakes. I think a somewhat seasoned programmer using good libraries can write declarative, concise, and readable code that still is reasonably fast. -k ?) At least for some approximation of the word. Only one benchmark on the shootout has C at a 3x advantage. -- If I haven't seen further, it is by standing in the footprints of giants From noel.kalman at googlemail.com Wed Nov 4 11:53:49 2009 From: noel.kalman at googlemail.com (Kalman Noel) Date: Wed Nov 4 11:29:49 2009 Subject: [Haskell-cafe] Re: How to optimize the performance of a code in Haskell? In-Reply-To: References: Message-ID: <4AF1B19D.2010403@googlemail.com> (I take it you accidently wrote to fa.haskell, which is just a mirror of -cafe and -beginners, so I'm cc-ing the Caf? with a full quote.) Masayuki Takagi: > I'm writing fluid simulation programs with SPH(Smoothed particle > hydrodynamics) in Haskell and C++. (The purpose that I write in two > languages is to make a workflow that first i write in Haskell for > rapid prototyping and accuracy then rewrite in C++ for performance.) > > I've compared them in performance. Then, although I have already done > optimization with profiler, the Haskell code is 20 times slower than > the C++ code. > > I think the performance of the Haskell code is so slow that there can > be room for optimization. I'm happy if the Haskell code work 3 times > slower than the C++ code at worst. > > How can I make the Haskell code faster? > What information should I refer? > > The codes are here: > http://kamonama.sakura.ne.jp/sph/20091101/sph.hs.zip > http://kamonama.sakura.ne.jp/sph/20091101/sph.cpp > > To run the code in Haskell: > $ ghc --make -O sph.hs > $ ./sph 300 > (300 is the time step to be conputed) > > To run the code in C++: > $ g++ -O2 -o sph sph.cpp > $ ./sph 300 > (300 is the time step to be conputed) > > thanks > I've not looked at the code, but you'll want ghc to do better optimizations than -O. -O2 is what you should use in general. Also, number-crunching often profits from -fexcess-precision. From bulat.ziganshin at gmail.com Wed Nov 4 12:01:49 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Nov 4 11:38:03 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <87tyxatf45.fsf@malde.org> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> Message-ID: <597965808.20091104200149@gmail.com> Hello Ketil, Wednesday, November 4, 2009, 7:43:38 PM, you wrote: > Right?, the interesting thing is not how fast I can get with N times the > effort, but if I can get fast enough with 1/N. it depends entirely on how fast you need. so it's again changing the topic - while i say that haskell is slow compared to other languages, i don't say that it is slow for you or that you need sped at all. why it's repeated again and again? why you don't write to Don what you don't need speed when he wrote that haslkell is fast but wrote this to me? :( >> when people are crying that their code isn't as fast as those ads say. >> haskell compilation can't yet automatically avoid laziness and convert >> pure high-level code into equivalent of C one. > Many of those people are making fairly simple mistakes. I think a > somewhat seasoned programmer using good libraries can write declarative, > concise, and readable code that still is reasonably fast. i don't think that omitting strictness declarations is a mistake :) > ?) At least for some approximation of the word. Only one benchmark on > the shootout has C at a 3x advantage. oh, can we stop saying about shootout? if you want to see speed of pure haskell code, look at papers about fast arrays/strings - their authors have measured that lazy lists are hundreds times slower than idiomatic C code. is use of lazy lists counted as mistake too and paper authors had too small haskell experience? -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Wed Nov 4 12:04:28 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Nov 4 11:40:41 2009 Subject: [Haskell-cafe] Re: How to optimize the performance of a code in Haskell? In-Reply-To: <4AF1B19D.2010403@googlemail.com> References: <4AF1B19D.2010403@googlemail.com> Message-ID: <113711647.20091104200428@gmail.com> Hello Kalman, Wednesday, November 4, 2009, 7:53:49 PM, you wrote: > I've not looked at the code, but you'll want ghc to do better optimizations > than -O. -O2 is what you should use in general. Also, number-crunching often > profits from -fexcess-precision. also, floating-point number crunching usually faster with -fvia-C -optc-O3 -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From edskodevries at gmail.com Wed Nov 4 12:08:23 2009 From: edskodevries at gmail.com (Edsko de Vries) Date: Wed Nov 4 11:47:53 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <3e1162e60911040727y3b516038x257daeed0dc49fb1@mail.gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <5fdc56d70911031449h3314c9b9l5d1a43ab485c540@mail.gmail.com> <4AF0E65B.6060601@freegeek.org> <2076f2f90911040217u52c353e0wb691599dfd9044c0@mail.gmail.com> <4EFDB41F-AA0B-4C76-9AE5-AA49384A6A6F@gmail.com> <3e1162e60911040727y3b516038x257daeed0dc49fb1@mail.gmail.com> Message-ID: <6324D32C-7660-47D7-AC37-5843211FAFF1@gmail.com> I'm not sure I follow you? The compiler can't reorder the two updates or do them in parallel (IO is not a commutative monad). You might tell the compiler this explicitly, but then are you writing lower and lower level code, further removed from the functional paradigm. Edsko On 4 Nov 2009, at 15:27, David Leimbach wrote: > > > On Wed, Nov 4, 2009 at 7:11 AM, Edsko de Vries > wrote: > > On 4 Nov 2009, at 13:36, Alberto G. Corona wrote: > > Artyom. > > I know what uniqueness means. What I meant is that the context in > which uniqueness is used, for imperative sequences: > > (y, s')= proc1 s x > (z, s'')= proc2 s' y > ..... > > is essentially the same sequence as if we rewrite an state monad to > make the state explicit. When the state is the "world" state, then > it is similar to the IO monad. > > Yes, as long as there is a single thing that is being updated > there's little difference between the state monad and a unique type. > But uniqueness typing is more general. For instance, a function > which updates two arrays > > f (arr1, arr2) = (update arr1 0 'x', update arr2 0 'y') > > is easily written in functional style in Clean, whereas in Haskell > we need to sequentialize the two updates: > > f (arr1, arr2) > = do writeArray arr1 0 'x' > writeArray arr2 0 'y' > > Those sequential updates can be run concurrently on both, just with > different syntax though right? > > > You can find a more detailed comparison in my thesis (https://www.cs.tcd.ie/Edsko.de.Vries/pub/MakingUniquenessTypingLessUnique-screen.pdf > , Section 2.8.7). > > -Edsko > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/2460b566/attachment.html From korpios at korpios.com Wed Nov 4 12:12:11 2009 From: korpios at korpios.com (Tom Tobin) Date: Wed Nov 4 11:48:19 2009 Subject: [Haskell-cafe] Announce: language-python version 0.2 now available In-Reply-To: <4d8ad03a0911040503h7b75dd69m6026b86b6160ce70@mail.gmail.com> References: <4d8ad03a0911040503h7b75dd69m6026b86b6160ce70@mail.gmail.com> Message-ID: On Wed, Nov 4, 2009 at 7:03 AM, Bernie Pope wrote: > I'm pleased to announce that version 0.2 of the language-python > package is now available on hackage: > > ? http://hackage.haskell.org/package/language-python > > language-python provides lexical analysis and parsing for Python. Thanks for working on this; coming from a Python background (and still using Python at work), this sounds like a fun way to combine my efforts at learning Haskell with something that might actually prove useful for my day job (as I haven't been happy with any of the Python lint tools out there). :-) From deniz.a.m.dogan at gmail.com Wed Nov 4 12:18:46 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Wed Nov 4 11:55:14 2009 Subject: [Haskell-cafe] Announce: language-python version 0.2 now available In-Reply-To: <4d8ad03a0911040503h7b75dd69m6026b86b6160ce70@mail.gmail.com> References: <4d8ad03a0911040503h7b75dd69m6026b86b6160ce70@mail.gmail.com> Message-ID: <7b501d5c0911040918q402adff2hf422274b0eabbb69@mail.gmail.com> 2009/11/4 Bernie Pope : > Main shortcomings of this release: > > ? - Support for Unicode is limited (waiting on Unicode support in Alex). There was an announcement a while back on this list from Jean-Philippe Bernardy about successfully adding Unicode support to Alex. http://www.mail-archive.com/haskell-cafe@haskell.org/msg62848.html -- Deniz Dogan From sjoerd at w3future.com Wed Nov 4 13:01:50 2009 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Wed Nov 4 12:38:09 2009 Subject: [Haskell-cafe] Fair diagonals (code golf) In-Reply-To: <4AF18DFA.7020602@gmail.com> References: <4AF095D0.9030105@van.steenbergen.nl> <44F139D4-0B29-42A1-8D45-EF80333DB182@w3future.com> <4AF18DFA.7020602@gmail.com> Message-ID: The code by Twan can be reduced to this: diagN = concat . foldr f [[[]]] f :: [a] -> [[[a]]] -> [[[a]]] f xs ys = foldr (g ys) [] xs g :: [[[a]]] -> a -> [[[a]]] -> [[[a]]] g ys x xs = merge (map (map (x:)) ys) ([] : xs) merge :: [[a]] -> [[a]] -> [[a]] merge [] ys = ys merge xs [] = xs merge (x:xs) (y:ys) = (x++y) : merge xs ys But my feeling is that this can still be simplified further. Or at least refactored so it is clear what actually is going on! -- Sjoerd Visscher sjoerd@w3future.com From anotheraddress at gmx.de Wed Nov 4 13:41:35 2009 From: anotheraddress at gmx.de (Daniel =?utf-8?q?Sch=C3=BCssler?=) Date: Wed Nov 4 13:17:51 2009 Subject: [Haskell-cafe] Emacs: Haskell snippets for YASnippet In-Reply-To: <7b501d5c0911040841s5a14615dra680d91336d018a8@mail.gmail.com> References: <200911041649.28663.anotheraddress@gmx.de> <7b501d5c0911040841s5a14615dra680d91336d018a8@mail.gmail.com> Message-ID: <200911041941.35753.anotheraddress@gmx.de> Hi Deniz, > Cool stuff, I will probably be using this! thanks :) > > In my opinion, the naming convention is a bit inconsistent. Extension > snippets all begin with "-x" but imports begin with "imp". I'd prefer > seeing import snippets begin with "-i" and use names easier to > remember, e.g. instead of "impcms", use "-istate" and instead of > "impdm.Map" use "-imap", etc. At least consider it! :) Ah, the rationale behind the "-x" was that these are also GHC command line flags ;) But I also like "-i" better than "imp". About the names: In one sense the current scheme is easier to remember because the abbreviation can be deduced from the module name. But I suppose you're right and "state" etc. are still easier to remember in practice, so feel free to send in a patch. > > And about the "bot" -> "?" rule... Is ? really valid Haskell? > Well yes, but it's an operator name token, so valid haskell would be: x ? y = x + y or (?) = undefined with this use as a constant you'd have to use the parentheses every time, so it probably isn't very useful indeed. Greetings, Daniel From dons at galois.com Wed Nov 4 13:56:02 2009 From: dons at galois.com (Don Stewart) Date: Wed Nov 4 13:32:14 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <597965808.20091104200149@gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> Message-ID: <20091104185602.GD18694@whirlpool.galois.com> bulat.ziganshin: > oh, can we stop saying about shootout? if you want to see speed of > pure haskell code, look at papers about fast arrays/strings - their > authors have measured that lazy lists are hundreds times slower than > idiomatic C code. is use of lazy lists counted as mistake too and > paper authors had too small haskell experience? Comparing apples against oranges is a mistake, yes. -- Don From max.rabkin at gmail.com Wed Nov 4 14:02:03 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Wed Nov 4 13:38:31 2009 Subject: [Haskell-cafe] ANN: fdo-notify 0.1, a client for the Desktop Notifications protocol Message-ID: Haskellers, I present to you fdo-notify, a client library for FreeDesktop.org's Desktop Notifications protocol. This is the DBUS protocol served by NotifyOSD and other notifications systems, which allows a wide variety of applications to present notifications to the user in a uniform way. The library should not require knowledge of DBus or the Desktop Notifications protocol itself, at least once fully documented (there should be enough haddocumentation for basic use already). Hackage: http://hackage.haskell.org/package/fdo-notify Mercurial: http://bitbucket.org/taejo/fdo-notify/ Basic notifications and updated/replacement notifications are supported. Images are not yet supported (adding support should be easy, but which Image type? Is there a de facto standard imaging library like the Python Imaging Library?) and nor are signals. Signals allow an application to be informed when some action is taken on the notification (NotifyOSD doesn't support actions, but other implementations might). The library is released under the 3-clause BSD license, but depends on the dbus-core and dbus-client libraries which are GPLed. I hope you find this library useful. Regards, Max From monnier at iro.umontreal.ca Wed Nov 4 14:50:06 2009 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Wed Nov 4 14:26:46 2009 Subject: [Haskell-cafe] Daniel =?iso-8859-1?q?Sch=FCssler?= References: <200911041649.28663.anotheraddress@gmx.de> Message-ID: > this is rather trivial, but maybe someone else finds these useful: > darcs get http://code.haskell.org/~daniels/haskell-snippets/ Since Emacs already comes bundled with several template systems (at least skeleton.el and tempo.el, where the first seems to be marginally more "canonical"), I think it would be better to define your templates using skeleton and thus remove the dependency on yasnippet. Stefan From deniz.a.m.dogan at gmail.com Wed Nov 4 14:59:02 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Wed Nov 4 14:35:30 2009 Subject: =?ISO-8859-1?Q?Re=3A_=5BHaskell=2Dcafe=5D_Daniel_Sch=FCssler_=3Canotheraddress?= =?ISO-8859-1?Q?=40gmx=2Ede=3E?= In-Reply-To: References: <200911041649.28663.anotheraddress@gmx.de> Message-ID: <7b501d5c0911041159w7bf3b3abp69b9337add612d3e@mail.gmail.com> 2009/11/4 Stefan Monnier : >> this is rather trivial, but maybe someone else finds these useful: > >> darcs get http://code.haskell.org/~daniels/haskell-snippets/ > > Since Emacs already comes bundled with several template systems > (at least skeleton.el and tempo.el, where the first seems to be > marginally more "canonical"), I think it would be better to define your > templates using skeleton and thus remove the dependency on yasnippet. > > > ? ? ? ?Stefan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > You guys sure have been good at hiding skeleton.el... The impression I've gotten from a couple of years in #emacs is that yasnippet is the way to go. I'll translate my own snippets to skeleton a.s.a.p. :P -- Deniz Dogan From warren.henning at gmail.com Wed Nov 4 15:20:04 2009 From: warren.henning at gmail.com (Warren Henning) Date: Wed Nov 4 14:56:11 2009 Subject: [Haskell-cafe] ANNOUNCE: feldspar-language In-Reply-To: <4AF14105.6080906@chalmers.se> References: <4AF0F78B.2090405@chalmers.se> <9e5767b0911032003o28292050rba2f8efa20c0fda@mail.gmail.com> <4AF14105.6080906@chalmers.se> Message-ID: <9e5767b0911041220k5f8a972h2c4b988d218adc23@mail.gmail.com> On Wed, Nov 4, 2009 at 12:53 AM, Emil Axelsson wrote: > I don't see why you shouldn't > I don't know I'll take that as an unqualified "yes". Shawty snappin'! Warren From tittoassini at gmail.com Wed Nov 4 16:03:09 2009 From: tittoassini at gmail.com (Pasqualino "Titto" Assini) Date: Wed Nov 4 15:39:16 2009 Subject: [Haskell-cafe] representing Haskell objects in a uniform way Message-ID: <2d34474e0911041303j546d9e03ya3124b349411ad7a@mail.gmail.com> Hi, I am writing a little IPC system to make Haskell values and functions remotely invokable. To do so, I need (or so I believe) to make my objects accessible via a generic interface as in: class AFun f where afun :: Data a => f -> ([Dynamic] -> a) So my generic object is something that takes an array of parameters, that being Dynamic can be anything, and returns a Data, that I can easily serialise and send back on the wire. I start by defining an instance for functions: instance (Typeable a,AFun b) => AFun (a->b) where afun f (p:ps) = let Just v = fromDynamic p in afun (f v) ps afun _ _ = error "Too few arguments" So far so good, but when I try to define an instance for values: instance Data v => AFun v where afun f [] = f afun _ _ = error "Too many arguments" I get: Couldn't match expected type `a' against inferred type `v' `a' is a rigid type variable bound by the type signature for `afun' at /home/titto/.quid2/state/ubuntu.local.8080/wikidata/haskell/package/haskelld/src/HaskellD/Test.hs:7:17 `v' is a rigid type variable bound by the instance declaration .... Why is that? a and v are both declared to be a Data, why should they not match? The full code follows: {-# LANGUAGE FlexibleInstances ,UndecidableInstances ,OverlappingInstances #-} import Data.Data import Data.Dynamic class AFun f where afun :: Data a => f -> ([Dynamic] -> a) instance (Typeable a,AFun b) => AFun (a->b) where afun f (p:ps) = let Just v = fromDynamic p in afun (f v) ps afun _ _ = error "Too few arguments" instance Data v => AFun v where afun f [] = f afun _ _ = error "Too many arguments" Thanks in advance, titto From ok at cs.otago.ac.nz Wed Nov 4 16:14:38 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Wed Nov 4 15:50:51 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> Message-ID: On Nov 4, 2009, at 9:56 PM, Martin DeMello wrote [about Clean]: > And a well-integrated GUI toolkit. If it weren't for the Windows bias > I'd have definitely taken the time to learn the language. The GUI toolkit was originally available on the Mac. But now, ah, now! "The Object I/O Library 1.2 is currently only available for the Wintel platform. " The last time I tried Clean on a SPARC, using even the old GUI toolkit required you to locate and install a graphics library (XView) that Sun abandoned a _long_ time ago. They have some _really_ interesting ideas about building web sites using generics. I paid for the Intel C compiler. I'd pay for Clean, if only I _could_ use it. From gcross at phys.washington.edu Wed Nov 4 16:16:10 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Wed Nov 4 15:52:18 2009 Subject: [Haskell-cafe] representing Haskell objects in a uniform way In-Reply-To: <2d34474e0911041303j546d9e03ya3124b349411ad7a@mail.gmail.com> References: <2d34474e0911041303j546d9e03ya3124b349411ad7a@mail.gmail.com> Message-ID: <929D916B-F021-4DA6-A250-5DBB39EBBCC0@phys.washington.edu> The problem lies in the definition of your class: > class AFun f where > afun :: Data a => f -> ([Dynamic] -> a) You are saying that afun can return any type "a" that the user wants as long as it is an instance of "Data", whereas here > instance Data v => AFun v where > afun f [] = f > afun _ _ = error "Too many arguments" you are restricting the type returned by afun. What you probably want is a class that looks more like class Data r => AFun f r where afun :: f -> ([Dynamic] -> r) so that the return type is explicitly included in the definition of the type. Also, you might consider requiring that the argument and result be instances of Binary rather than Data, since this gives you fast binary serialization for free. Then you could write a class like class (Binary a, Binary b) => AFun a b where afun :: f -> (a -> b) And your code can take care of the serialization/deserialization and then just hand the values of the correct type over to afun. Cheers, Greg From jason.dusek at gmail.com Wed Nov 4 16:22:11 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Nov 4 15:58:18 2009 Subject: [Haskell-cafe] Arrays in Clean and Haskell In-Reply-To: <884320.53729.qm@web58805.mail.re1.yahoo.com> References: <42784f260911032031l4111f0e6tea9be50d9bfe8522@mail.gmail.com> <884320.53729.qm@web58805.mail.re1.yahoo.com> Message-ID: <42784f260911041322m55c8c87du2e685bc65c3e581c@mail.gmail.com> 2009/11/4 Philippos Apolinarius > Jason Dusek wrote: > > How do you read in the IOUArray? By parsing a character > > string or do you treat the file as binary numbers or ... ? > > I always pare the file. Parsing the file has the advantage of > alowing me to have files of any format. From this description, it's hard for me to see what is hard for you. When you "parse the file" I imagine you in face "parse a String" or "parse a lazy ByteString" (a much better idea). Take that `String` or `ByteString` and pass it to an `ST` computation that parses it to make an `ST` array and then operates on the array. -- Jason Dusek From daniel.is.fischer at web.de Wed Nov 4 16:26:09 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Nov 4 16:04:46 2009 Subject: [Haskell-cafe] representing Haskell objects in a uniform way In-Reply-To: <2d34474e0911041303j546d9e03ya3124b349411ad7a@mail.gmail.com> References: <2d34474e0911041303j546d9e03ya3124b349411ad7a@mail.gmail.com> Message-ID: <200911042226.10271.daniel.is.fischer@web.de> Am Mittwoch 04 November 2009 22:03:09 schrieb Pasqualino "Titto" Assini: > Hi, > > I am writing a little IPC system to make Haskell values and functions > remotely invokable. > > To do so, I need (or so I believe) to make my objects accessible via a > generic interface as in: > > class AFun f where > ? ?afun :: Data a => f -> ([Dynamic] -> a) > > So my generic object is something that takes an array of parameters, > that being Dynamic can be anything, and returns a Data, that I can > easily serialise and send back on the wire. > > I start by defining an instance for functions: > > instance (Typeable a,AFun b) => AFun (a->b) where > ? afun f (p:ps) = let Just v = fromDynamic p in afun (f v) ps > ? afun _ _ ? ? ?= error "Too few arguments" > > So far so good, but when I try to define an instance for values: > > instance Data v => AFun v where > ? afun f [] = f > ? afun _ _ ?= error "Too many arguments" > > I get: > > Couldn't match expected type `a' against inferred type `v' > ? ? ? `a' is a rigid type variable bound by > ? ? ? ? ? the type signature for `afun' > ? ? ? ? ? ? at > /home/titto/.quid2/state/ubuntu.local.8080/wikidata/haskell/package/haskell >d/src/HaskellD/Test.hs:7:17 `v' is a rigid type variable bound by > ? ? ? ? ? the instance declaration .... > > > Why is that? a and v are both declared to be a Data, why should they not > match? afun's type sgnature says "whatever type you (the caller) want, I can give it to you, as long as it's a member of Data" But v is one particular type belonging to Data, and it's the only one, the implementation of afun can provide. Maybe you want class (Data a) => AFun f a | f -> a where afun :: f -> ([Dynamic] -> a) or, with type families: class AFun f where type RType f :: * afun :: (Data (RType f)) => f -> ([Dynamic] -> RType f) I'm not quite sure whether that compiles, let alone does what you want, but it might be worth a try. From t-otto-news at gmx.de Wed Nov 4 17:21:13 2009 From: t-otto-news at gmx.de (Torsten Otto) Date: Wed Nov 4 16:57:23 2009 Subject: [Haskell-cafe] Interactive chatbot Message-ID: <497D4F71-8839-40C6-8521-9806CA666438@gmx.de> Hi! My students have the task to program an interactive chatbot. We have run into a problem that I can't solve either: When we read the user's input through > t <- getLine it is not possible to delete typos before hitting enter and thereby sending the input off to the system (at least in OS X, bash). I didn't find that terribly problematic, but of course it is a bit of a show stopper from their point of view. The input is then used to generate a reply in purely functional code, and the reply sent to the command line via putStr. Is there a more clever way to interact with the user that would allow editing ones text before sending it to the bot? I guess we could try with a website, but don't know off hand how to do that, either, although I've seen beautiful webservers made in Haskell... Regards, Torsten Otto From rl at cse.unsw.edu.au Wed Nov 4 17:22:10 2009 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Wed Nov 4 16:58:26 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <597965808.20091104200149@gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> Message-ID: <66E0D397-3318-4DD8-ACBC-FD9C3A0E117E@cse.unsw.edu.au> On 05/11/2009, at 04:01, Bulat Ziganshin wrote: > oh, can we stop saying about shootout? if you want to see speed of > pure haskell code, look at papers about fast arrays/strings - their > authors have measured that lazy lists are hundreds times slower than > idiomatic C code. is use of lazy lists counted as mistake too and > paper authors had too small haskell experience? In the papers I coauthored, I don't think we measured any such thing. What we measured was that in algorithms that are best implemented with (unboxed) arrays, using boxed lists is going to cost you. That's not a very surprising conclusion and it's by no means specific to Haskell. The problem was/is the lack of nice purely declarative array libraries but that changing, albeit slowly. It's a question of using the right data structure for the algorithm, not a C vs. Haskell thing. Roman From gcross at phys.washington.edu Wed Nov 4 17:25:44 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Wed Nov 4 17:01:56 2009 Subject: [Haskell-cafe] Interactive chatbot In-Reply-To: <497D4F71-8839-40C6-8521-9806CA666438@gmx.de> References: <497D4F71-8839-40C6-8521-9806CA666438@gmx.de> Message-ID: The library at http://hackage.haskell.org/package/readline might solve your problem. Cheers, Greg On Nov 4, 2009, at 2:21 PM, Torsten Otto wrote: > Hi! > > My students have the task to program an interactive chatbot. We have > run into a problem that I can't solve either: > > When we read the user's input through > > t <- getLine > it is not possible to delete typos before hitting enter and thereby > sending the input off to the system (at least in OS X, bash). I > didn't find that terribly problematic, but of course it is a bit of > a show stopper from their point of view. > > The input is then used to generate a reply in purely functional > code, and the reply sent to the command line via putStr. Is there a > more clever way to interact with the user that would allow editing > ones text before sending it to the bot? > I guess we could try with a website, but don't know off hand how to > do that, either, although I've seen beautiful webservers made in > Haskell... > > Regards, > Torsten Otto > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From thomas.dubuisson at gmail.com Wed Nov 4 17:27:59 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Wed Nov 4 17:04:05 2009 Subject: [Haskell-cafe] Interactive chatbot In-Reply-To: <497D4F71-8839-40C6-8521-9806CA666438@gmx.de> References: <497D4F71-8839-40C6-8521-9806CA666438@gmx.de> Message-ID: <4c44d90b0911041427l3993c82eg94465208920ccdf0@mail.gmail.com> On Wed, Nov 4, 2009 at 2:21 PM, Torsten Otto wrote: > Hi! > > My students have the task to program an interactive chatbot. We have run > into a problem that I can't solve either: > > When we read the user's input through >> ? t <- getLine > it is not possible to delete typos before hitting enter and thereby sending > the input off to the system (at least in OS X, bash). Why reinvent the shell? Is the program not setup in such a way as to make the ShellAC package a useful solution? I see someone already chimed in with readline. You might want to look at haskeline too, if you go that path (both are a step lower than ShellAC wrt abstraction). Thomas From mhady7 at gmail.com Wed Nov 4 18:10:53 2009 From: mhady7 at gmail.com (Mohamed Ayed) Date: Wed Nov 4 17:47:03 2009 Subject: [Haskell-cafe] question Message-ID: Hi, I want to write a program that will take an AST and a cost vector that represents a cost for each operation and produce a simplified version of the tree based on cost reduction. Can any one give me some ideas ? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/ce240971/attachment.html From dagit at codersbase.com Wed Nov 4 18:14:31 2009 From: dagit at codersbase.com (Jason Dagit) Date: Wed Nov 4 17:50:37 2009 Subject: [Haskell-cafe] Interactive chatbot In-Reply-To: <497D4F71-8839-40C6-8521-9806CA666438@gmx.de> References: <497D4F71-8839-40C6-8521-9806CA666438@gmx.de> Message-ID: On Wed, Nov 4, 2009 at 2:21 PM, Torsten Otto wrote: > Hi! > > My students have the task to program an interactive chatbot. We have run > into a problem that I can't solve either: > > When we read the user's input through > > t <- getLine > it is not possible to delete typos before hitting enter and thereby sending > the input off to the system (at least in OS X, bash). I didn't find that > terribly problematic, but of course it is a bit of a show stopper from their > point of view. > Is it possible that you need to tweak the input buffering settings? http://haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html#v:hSetBuffering You probably want to look at 'interact' also. Or just switch to readline as others have suggested. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/617f50bf/attachment.html From florbitous at gmail.com Wed Nov 4 18:28:40 2009 From: florbitous at gmail.com (Bernie Pope) Date: Wed Nov 4 18:04:47 2009 Subject: [Haskell-cafe] Announce: language-python version 0.2 now available In-Reply-To: References: <4d8ad03a0911040503h7b75dd69m6026b86b6160ce70@mail.gmail.com> Message-ID: <4d8ad03a0911041528y5365443fn34839c0e7dc35f3b@mail.gmail.com> 2009/11/5 Tom Tobin : > On Wed, Nov 4, 2009 at 7:03 AM, Bernie Pope wrote: >> I'm pleased to announce that version 0.2 of the language-python >> package is now available on hackage: >> >> ? http://hackage.haskell.org/package/language-python >> >> language-python provides lexical analysis and parsing for Python. > > Thanks for working on this; coming from a Python background (and still > using Python at work), this sounds like a fun way to combine my > efforts at learning Haskell with something that might actually prove > useful for my day job (as I haven't been happy with any of the Python > lint tools out there). ?:-) I'm keen for people to write Python tools using language-python, so please let me know if you do, or if you have any good ideas. From florbitous at gmail.com Wed Nov 4 18:30:14 2009 From: florbitous at gmail.com (Bernie Pope) Date: Wed Nov 4 18:06:21 2009 Subject: [Haskell-cafe] Announce: language-python version 0.2 now available In-Reply-To: <7b501d5c0911040918q402adff2hf422274b0eabbb69@mail.gmail.com> References: <4d8ad03a0911040503h7b75dd69m6026b86b6160ce70@mail.gmail.com> <7b501d5c0911040918q402adff2hf422274b0eabbb69@mail.gmail.com> Message-ID: <4d8ad03a0911041530i741db050o25fafc772bccbeb7@mail.gmail.com> 2009/11/5 Deniz Dogan : > 2009/11/4 Bernie Pope : >> Main shortcomings of this release: >> >> ? - Support for Unicode is limited (waiting on Unicode support in Alex). > > There was an announcement a while back on this list from Jean-Philippe > Bernardy about successfully adding Unicode support to Alex. > > http://www.mail-archive.com/haskell-cafe@haskell.org/msg62848.html Thanks Deniz, Yes, I saw that posting a while ago. I'm waiting for it to be included in the main branch of Alex (and looking forward to it too). Cheers, Bernie. From shachaf at gmail.com Wed Nov 4 18:32:25 2009 From: shachaf at gmail.com (Shachaf Ben-Kiki) Date: Wed Nov 4 18:08:32 2009 Subject: [Haskell-cafe] Interactive chatbot In-Reply-To: References: <497D4F71-8839-40C6-8521-9806CA666438@gmx.de> Message-ID: <20594c670911041532j6f393c27m7fec1dd58738414f@mail.gmail.com> On Wed, Nov 4, 2009 at 3:14 PM, Jason Dagit wrote: > > > On Wed, Nov 4, 2009 at 2:21 PM, Torsten Otto wrote: >> >> Hi! >> >> My students have the task to program an interactive chatbot. We have run >> into a problem that I can't solve either: >> >> When we read the user's input through >> > ? t <- getLine >> it is not possible to delete typos before hitting enter and thereby >> sending the input off to the system (at least in OS X, bash). I didn't find >> that terribly problematic, but of course it is a bit of a show stopper from >> their point of view. > > Is it possible that you need to tweak the input buffering settings? > http://haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html#v:hSetBuffering > You probably want to look at 'interact' also. > Or just switch to readline as others have suggested. > Jason Another possibility (perhaps simpler) is to use an external program such as rlwrap to handle input. Shachaf From jason.dusek at gmail.com Wed Nov 4 18:55:50 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Nov 4 18:31:57 2009 Subject: [Haskell-cafe] Arrays in Clean and Haskell In-Reply-To: <42784f260911041322m55c8c87du2e685bc65c3e581c@mail.gmail.com> References: <42784f260911032031l4111f0e6tea9be50d9bfe8522@mail.gmail.com> <884320.53729.qm@web58805.mail.re1.yahoo.com> <42784f260911041322m55c8c87du2e685bc65c3e581c@mail.gmail.com> Message-ID: <42784f260911041555j6aaa0ebcj1518f352989e9e23@mail.gmail.com> 2009/11/04 Jason Dusek : > ?...you "parse the file" I imagine you in face... in face -> in fact Sorry. -- Jason Dusek From agarcia at babel.ls.fi.upm.es Wed Nov 4 18:58:54 2009 From: agarcia at babel.ls.fi.upm.es (=?ISO-8859-1?Q?=C1lvaro_Garc=EDa_P=E9rez?=) Date: Wed Nov 4 18:35:03 2009 Subject: [Haskell-cafe] Strict Monad Message-ID: Hi, I'm trying to characterise some strict monads to work with a particular lambda-calculus evaluator, as an alternative to CPS monad. In the thread "Stupid question #852: Strict monad" the implementation of some strict monads (and pseudo-monads, not meeting the identity laws) is discussed. It's clear form that thread that using pattern-matching in the (>>=) operation will force evaluation, then the Id monad defined with pattern-matching is strict (and it's indeed a monad): > newtype Id a = Id a > > instance Monad Id where > return = Id > (Id a) >>= f = f a But it's impossible to derive a monad transformer from it, because you don't know the constructors of the monads you're transforming. I then tried to use strict application ($!). My first attempt was > newtype Strict a = InSt { outSt :: a } > > instance Monad Strict where > return = InSt > m >>= f = (\x -> f x) $! (outSt m) which is not a monad (doesn't meet the left identity law). (return undefined) >>= (\x -> const (return 1) x) =/= (return 1) Then I wondered if it was enough to force the evaluation of the whole monad, instead of the value inside the monad, yielding the second attempt: > newtype Strict a = InSt { outSt :: a } > > instance Monad Strict where > return = InSt > m >>= f = (\x -> f (outSt x)) $! m I placed the outSt inside the anonymous function, leaving the monad on the right of the ($!). This meets the identity laws and surprisingly (I was expecting a lazy behaviour) implements strict semantics (it behaves like CPS, which is strict as well). A transformer from this monad can be easily written: > newtype StrictT m a = InStT { outStT :: m a } > > instance Monad m => Monad (StrictT m) where > return = InStT . return > m >>= t = InStT $ (\x -> x >>= (\a -> outStT $ t a)) $! (outStT m) > > instance MonadTrans StrictT where > lift = InStT Is it common practice to use this monad and this transformer? Why is it not in the standard library? I looked for this monad in the literature but I didn't find anything similar. It seems naive to me that this has never been previously described. Am I doing something wrong and this is not a monad at all? Alvaro. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/408c9b25/attachment.html From ziman at centrum.sk Wed Nov 4 19:52:04 2009 From: ziman at centrum.sk (Matus Tejiscak) Date: Wed Nov 4 19:28:12 2009 Subject: [Haskell-cafe] Master's thesis topic sought Message-ID: <1257382324.5965.97.camel@idefix.localdomain> Hello, -Cafe, I'm looking for an interesting topic to hack on in my thesis. The thesis should be rather "theoretical"/abstract (writing a mail client in Haskell is not, for example), dealing with FP or related fields. I've had a few (blurry) ideas, ranging from investigating (possibilities for) Haskell extensions, to zygohistomorphic prepromorphisms, but nothing concrete, possibly because I'm not familiar with these areas enough to see what could be done -- which brings up a question whether it is a good idea to even try hacking on a topic like this. However, I'm eager to learn so if you have a topic you'd need somebody to work on, or just an interesting (or maybe even an uninteresting) idea, i'd be grateful for suggestions. :) Thanks, Matus From haskell at benmachine.co.uk Wed Nov 4 20:00:13 2009 From: haskell at benmachine.co.uk (Ben Millwood) Date: Wed Nov 4 19:36:20 2009 Subject: [Haskell-cafe] Interactive chatbot In-Reply-To: References: <497D4F71-8839-40C6-8521-9806CA666438@gmx.de> Message-ID: Oops, I clicked "reply" instead of "reply to all". Duplicating the message below. I suppose this means someone is going to get two copies of this. Sorry someone! On Thu, Nov 5, 2009 at 12:56 AM, Ben Millwood wrote: > On Wed, Nov 4, 2009 at 10:21 PM, Torsten Otto wrote: >> >> When we read the user's input through >>> ? t <- getLine >> it is not possible to delete typos before hitting enter and thereby sending >> the input off to the system (at least in OS X, bash). I didn't find that >> terribly problematic, but of course it is a bit of a show stopper from their >> point of view. >> > > As people have said it's worth checking what buffering settings you > are using (especially note that ghci changes some interesting settings > in relation to how input is handled, and compiled code may behave > differently), but it might also be worth checking the terminal > application's preferences to see if there are settings related to the > interpretation of the backspace key that you need to twiddle one way > or the other. In particular, if you are finding that pressing delete > makes ^H appear on the input line instead of deleting things, or if > pressing ctrl-H deletes stuff where the delete key fails to do so, it > might be a problem with your terminal rather than with your program. > This is only based on what I vaguely remember from faffing with the > Mac Terminal application some time ago when it wouldn't co-operate > with screen, but it may be worth a look. > > yours, > Ben Millwood > From jwlato at gmail.com Wed Nov 4 20:49:48 2009 From: jwlato at gmail.com (John Lato) Date: Wed Nov 4 20:26:00 2009 Subject: [Haskell-cafe] Re: How to optimize the performance of a code in Haskell? Message-ID: <9979e72e0911041749rcd0e105p3513ae99bed2d3e6@mail.gmail.com> For me, the Haskell version is about 1.5x slower than the C++ version, 19.6 seconds compared to 12.9. There wasn't an appreciable difference between -O and -O2. Which compiler (and version) are you using? I got: john$ g++ -O2 -o sph sph.cpp john$ time ./sph 300 real 0m12.914s user 0m11.015s sys 0m0.326s john$ g++ --version i686-apple-darwin9-g++-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5490) Copyright (C) 2005 Free Software Foundation, Inc. and john$ ghc --make -O2 sph.hs john$ time ./sph 300 real 0m19.606s user 0m18.933s sys 0m0.304s john$ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.10.4 on a recent model MacBook, OSX 10.5.8. Cheers, John > > Message: 4 > Date: Wed, 04 Nov 2009 17:53:49 +0100 > From: Kalman Noel > Subject: [Haskell-cafe] Re: How to optimize the performance of a code > ? ? ? ?in ? ? ?Haskell? > To: Masayuki Takagi > Cc: Haskell Cafe > Message-ID: <4AF1B19D.2010403@googlemail.com> > Content-Type: text/plain; charset=ISO-8859-15; format=flowed > > (I take it you accidently wrote to fa.haskell, which is just a mirror of -cafe > and -beginners, so I'm cc-ing the Caf? with a full quote.) > > Masayuki Takagi: >> I'm writing fluid simulation programs with SPH(Smoothed particle >> hydrodynamics) in Haskell and C++. (The purpose that I write in two >> languages is to make a workflow that first i write in Haskell for >> rapid prototyping and accuracy then rewrite in C++ for performance.) >> >> I've compared them in performance. Then, although I have already done >> optimization with profiler, the Haskell code is 20 times slower than >> the C++ code. >> >> I think the performance of the Haskell code is so slow that there can >> be room for optimization. I'm happy if the Haskell code work 3 times >> slower than the C++ code at worst. >> >> How can I make the Haskell code faster? >> What information should I refer? >> >> The codes are here: >> http://kamonama.sakura.ne.jp/sph/20091101/sph.hs.zip >> http://kamonama.sakura.ne.jp/sph/20091101/sph.cpp >> >> To run the code in Haskell: >> $ ghc --make -O sph.hs >> $ ./sph 300 >> (300 is the time step to be conputed) >> >> To run the code in C++: >> $ g++ -O2 -o sph sph.cpp >> $ ./sph 300 >> (300 is the time step to be conputed) >> >> thanks >> > > I've not looked at the code, but you'll want ghc to do better optimizations > than -O. -O2 is what you should use in general. Also, number-crunching often > profits from -fexcess-precision. > From jwlato at gmail.com Wed Nov 4 21:27:29 2009 From: jwlato at gmail.com (John Lato) Date: Wed Nov 4 21:03:39 2009 Subject: [Haskell-cafe] Re: How to optimize the performance of a code in Haskell? In-Reply-To: <9979e72e0911041749rcd0e105p3513ae99bed2d3e6@mail.gmail.com> References: <9979e72e0911041749rcd0e105p3513ae99bed2d3e6@mail.gmail.com> Message-ID: <9979e72e0911041827k7556b566j4b2707a7d9586d6c@mail.gmail.com> I forgot to add that changing your definition of Particle and adding some optimization tunings yields an appreciable speedup. > data Particle = Particle { pos, vel :: {-# UNPACK #-} !Vector3, > mass, rho, prs :: {-# UNPACK #-} !Scalar } john$ ghc --make -O2 -fexcess-precision -fforce-recomp sph.hs -funfolding-creation-threshold=600 -funfolding-use-threshold=200 john$ time ./sph 300 real 0m14.963s user 0m14.307s sys 0m0.265s and john$ ghc --make -O2 -fexcess-precision -fvia-c -optc=-O3 -fforce-recomp sph.hs -funfolding-creation-threshold=600 -funfolding-use-threshold=200 john$ time ./sph 300 real 0m13.393s user 0m12.771s sys 0m0.247s which is quite close to the C++ performance. Using ByteStrings instead of Strings for output gets it the rest of the way. If you want to put on your Dons hat, the next steps would be using something like Acovea to fine-tune the compiler options, and/or using DPH. Best, John On Thu, Nov 5, 2009 at 1:49 AM, John Lato wrote: > For me, the Haskell version is about 1.5x slower than the C++ version, > 19.6 seconds compared to 12.9. ?There wasn't an appreciable difference > between -O and -O2. > > Which compiler (and version) are you using? > > I got: > > john$ g++ -O2 -o sph sph.cpp > john$ time ./sph 300 > > real ? ?0m12.914s > user ? ?0m11.015s > sys ? ? 0m0.326s > > john$ g++ --version > i686-apple-darwin9-g++-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5490) > Copyright (C) 2005 Free Software Foundation, Inc. > > and > > john$ ghc --make -O2 sph.hs > john$ time ./sph 300 > > real ? ?0m19.606s > user ? ?0m18.933s > sys ? ? 0m0.304s > > john$ ghc --version > The Glorious Glasgow Haskell Compilation System, version 6.10.4 > > on a recent model MacBook, OSX 10.5.8. > > Cheers, > John > >> >> Message: 4 >> Date: Wed, 04 Nov 2009 17:53:49 +0100 >> From: Kalman Noel >> Subject: [Haskell-cafe] Re: How to optimize the performance of a code >> ? ? ? ?in ? ? ?Haskell? >> To: Masayuki Takagi >> Cc: Haskell Cafe >> Message-ID: <4AF1B19D.2010403@googlemail.com> >> Content-Type: text/plain; charset=ISO-8859-15; format=flowed >> >> (I take it you accidently wrote to fa.haskell, which is just a mirror of -cafe >> and -beginners, so I'm cc-ing the Caf? with a full quote.) >> >> Masayuki Takagi: >>> I'm writing fluid simulation programs with SPH(Smoothed particle >>> hydrodynamics) in Haskell and C++. (The purpose that I write in two >>> languages is to make a workflow that first i write in Haskell for >>> rapid prototyping and accuracy then rewrite in C++ for performance.) >>> >>> I've compared them in performance. Then, although I have already done >>> optimization with profiler, the Haskell code is 20 times slower than >>> the C++ code. >>> >>> I think the performance of the Haskell code is so slow that there can >>> be room for optimization. I'm happy if the Haskell code work 3 times >>> slower than the C++ code at worst. >>> >>> How can I make the Haskell code faster? >>> What information should I refer? >>> >>> The codes are here: >>> http://kamonama.sakura.ne.jp/sph/20091101/sph.hs.zip >>> http://kamonama.sakura.ne.jp/sph/20091101/sph.cpp >>> >>> To run the code in Haskell: >>> $ ghc --make -O sph.hs >>> $ ./sph 300 >>> (300 is the time step to be conputed) >>> >>> To run the code in C++: >>> $ g++ -O2 -o sph sph.cpp >>> $ ./sph 300 >>> (300 is the time step to be conputed) >>> >>> thanks >>> >> >> I've not looked at the code, but you'll want ghc to do better optimizations >> than -O. -O2 is what you should use in general. Also, number-crunching often >> profits from -fexcess-precision. >> > From shelby at coolpage.com Wed Nov 4 21:29:00 2009 From: shelby at coolpage.com (Shelby Moore) Date: Wed Nov 4 21:05:09 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <1257382324.5965.97.camel@idefix.localdomain> References: <1257382324.5965.97.camel@idefix.localdomain> Message-ID: <3643.121.97.54.144.1257388140.squirrel@webmail12.pair.com> > Hello, -Cafe, > > I'm looking for an interesting topic to hack on in my thesis. > > The thesis should be rather "theoretical"/abstract (writing a mail > client in Haskell is not, for example), dealing with FP or related > fields. The theoretical concept of how to make lazy evaluation less discontinuously correlated to allocation space determinism: http://www.haskell.org/pipermail/haskell-cafe/2009-November/068436.html http://www.haskell.org/pipermail/cvs-ghc/2009-October/050928.html http://www.haskell.org/pipermail/cvs-ghc/2009-November/050946.html http://www.haskell.org/pipermail/cvs-ghc/2009-November/050949.html (should have written "stochastic" instead of "statistical") I think this would make you a hero also if you succeed, as I see this problem as the main problem stopping its adoption as a mainstream language. The problem as I see it (Google "space leak Haskell" for examples), is that even a very small change in the code can cause a huge space leak that slows the program to molasses due to paging (faults) load. And these effects are not predictable or easy to reason about. When these discontinuous effects occur, we have to stop our development, do profiling, and try to isolate the obscure cause, then restructure code in bizzarre ways to try to get some determinism in space allocation. My abstract idea is that it should be possible to stochastically throttle these effects, by throtting whether (and whic) thunks get cached to (WH)NF or re-valuated on each use. I do think it is possible to teach people how to program in FP succinctly and without making their head hurt: http://www.haskell.org/pipermail/haskell-cafe/2009-November/068564.html You may not find many people here openly expressing their interest in these topics, but I think there are millions of people out there who would benefit. From john at n-brain.net Wed Nov 4 22:12:54 2009 From: john at n-brain.net (John A. De Goes) Date: Wed Nov 4 21:49:05 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <3643.121.97.54.144.1257388140.squirrel@webmail12.pair.com> References: <1257382324.5965.97.camel@idefix.localdomain> <3643.121.97.54.144.1257388140.squirrel@webmail12.pair.com> Message-ID: Generally, a form of lenient evaluation + lazy data structures can provide the benefits of Haskell non-strict evaluation without the drawbacks. A "reimagining" of Haskell cast in this mold might make for a very practical thesis. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Nov 4, 2009, at 7:29 PM, Shelby Moore wrote: >> Hello, -Cafe, >> >> I'm looking for an interesting topic to hack on in my thesis. >> >> The thesis should be rather "theoretical"/abstract (writing a mail >> client in Haskell is not, for example), dealing with FP or related >> fields. > > The theoretical concept of how to make lazy evaluation less > discontinuously correlated to allocation space determinism: > > http://www.haskell.org/pipermail/haskell-cafe/2009-November/ > 068436.html > http://www.haskell.org/pipermail/cvs-ghc/2009-October/050928.html > http://www.haskell.org/pipermail/cvs-ghc/2009-November/050946.html > http://www.haskell.org/pipermail/cvs-ghc/2009-November/050949.html > (should have written "stochastic" instead of "statistical") > > I think this would make you a hero also if you succeed, as I see this > problem as the main problem stopping its adoption as a mainstream > language. > > The problem as I see it (Google "space leak Haskell" for examples), is > that even a very small change in the code can cause a huge space > leak that > slows the program to molasses due to paging (faults) load. And these > effects are not predictable or easy to reason about. When these > discontinuous effects occur, we have to stop our development, do > profiling, and try to isolate the obscure cause, then restructure > code in > bizzarre ways to try to get some determinism in space allocation. > > My abstract idea is that it should be possible to stochastically > throttle > these effects, by throtting whether (and whic) thunks get cached to > (WH)NF > or re-valuated on each use. > > I do think it is possible to teach people how to program in FP > succinctly > and without making their head hurt: > > http://www.haskell.org/pipermail/haskell-cafe/2009-November/ > 068564.html > > You may not find many people here openly expressing their interest in > these topics, but I think there are millions of people out there who > would > benefit. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From mhady7 at gmail.com Wed Nov 4 22:42:56 2009 From: mhady7 at gmail.com (Mohamed Ayed) Date: Wed Nov 4 22:19:03 2009 Subject: [Haskell-cafe] Re: question In-Reply-To: References: Message-ID: Can you please help ? On Wed, Nov 4, 2009 at 6:10 PM, Mohamed Ayed wrote: > Hi, > > I want to write a program that will take an AST and a cost vector that > represents a cost for each operation and produce a simplified version of the > tree based on cost reduction. > > Can any one give me some ideas ? > > Thanks > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/d5e61803/attachment.html From phi500ac at yahoo.ca Wed Nov 4 22:52:25 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Wed Nov 4 22:28:32 2009 Subject: [Haskell-cafe] Arrays in Clean and Haskell In-Reply-To: <42784f260911041322m55c8c87du2e685bc65c3e581c@mail.gmail.com> Message-ID: <950451.93455.qm@web58806.mail.re1.yahoo.com> Let me see whether I understoodnd you correctly... If I read the contents of a file, the string will may be lazy (or something like that) and? not consume memory? In fewer words,? will the string behave like the infinite list of random numbers that I have used in the examples I posted? --- On Wed, 11/4/09, Jason Dusek wrote: From: Jason Dusek Subject: Re: [Haskell-cafe] Arrays in Clean and Haskell To: "Philippos Apolinarius" Cc: haskell-cafe@haskell.org Received: Wednesday, November 4, 2009, 2:22 PM 2009/11/4 Philippos Apolinarius > Jason Dusek wrote: > > How do you read in the IOUArray? By parsing a character > > string or do you treat the file as binary numbers or ... ? > > I always pare the file. Parsing the file has the advantage of > alowing me to have files of any format. ? From this description, it's hard for me to see what is hard ? for you. When you "parse the file" I imagine you in face ? "parse a String" or "parse a lazy ByteString" (a much better ? idea). Take that `String` or `ByteString` and pass it to an ? `ST` computation that parses it to make an `ST` array and then ? operates on the array. -- Jason Dusek __________________________________________________________________ Make your browsing faster, safer, and easier with the new Internet Explorer? 8. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091104/a3211a90/attachment.html From jfredett at gmail.com Wed Nov 4 23:14:07 2009 From: jfredett at gmail.com (Joe Fredette) Date: Wed Nov 4 22:50:19 2009 Subject: [Haskell-cafe] Re: question In-Reply-To: References: Message-ID: Well, what have you got so far? This sounds like a pretty homeworky question, so I don't want to give it away. But try to think about the types involved. ASTs in Haskell are just Datatypes, cost minimization is a transformation on that type. Try to think about how to combine the cost vector and an AST type, and then how to use that combined information to "tear down" the structure into the new (minimized) structure. HTH /Joe On Nov 4, 2009, at 10:42 PM, Mohamed Ayed wrote: > Can you please help ? > > On Wed, Nov 4, 2009 at 6:10 PM, Mohamed Ayed wrote: > Hi, > > I want to write a program that will take an AST and a cost vector > that represents a cost for each operation and produce a simplified > version of the tree based on cost reduction. > > Can any one give me some ideas ? > > Thanks > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From shelby at coolpage.com Wed Nov 4 23:34:43 2009 From: shelby at coolpage.com (Shelby Moore) Date: Wed Nov 4 23:10:49 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: References: <1257382324.5965.97.camel@idefix.localdomain> <3643.121.97.54.144.1257388140.squirrel@webmail12.pair.com> Message-ID: <3751.121.97.54.144.1257395683.squirrel@webmail12.pair.com> Throttling at the thunk+GC interaction as I suggested, thus transparent to the semantics of Haskell language, is an experimental concept that potentially convolves with the system-at-large. Perhaps I would also pursue an orthogonal strategy at the semantics layer, which is less global in scope. Perhaps it is possible to categorize and generalize many of the types of structures that cause space leaks, then handle them at the semantic layer (but afaics this can not be argued to most optimal in all respects). The latter is successful every time you generalize a case and are able to identify it automatically with an analyzer. > Generally, a form of lenient evaluation + lazy data structures can > provide the benefits of Haskell non-strict evaluation without the > drawbacks. A "reimagining" of Haskell cast in this mold might make for > a very practical thesis. > > Regards, > > John A. De Goes > N-Brain, Inc. > The Evolution of Collaboration > > http://www.n-brain.net | 877-376-2724 x 101 > > On Nov 4, 2009, at 7:29 PM, Shelby Moore wrote: > >>> Hello, -Cafe, >>> >>> I'm looking for an interesting topic to hack on in my thesis. >>> >>> The thesis should be rather "theoretical"/abstract (writing a mail >>> client in Haskell is not, for example), dealing with FP or related >>> fields. >> >> The theoretical concept of how to make lazy evaluation less >> discontinuously correlated to allocation space determinism: >> >> http://www.haskell.org/pipermail/haskell-cafe/2009-November/ >> 068436.html >> http://www.haskell.org/pipermail/cvs-ghc/2009-October/050928.html >> http://www.haskell.org/pipermail/cvs-ghc/2009-November/050946.html >> http://www.haskell.org/pipermail/cvs-ghc/2009-November/050949.html >> (should have written "stochastic" instead of "statistical") >> >> I think this would make you a hero also if you succeed, as I see this >> problem as the main problem stopping its adoption as a mainstream >> language. >> >> The problem as I see it (Google "space leak Haskell" for examples), is >> that even a very small change in the code can cause a huge space >> leak that >> slows the program to molasses due to paging (faults) load. And these >> effects are not predictable or easy to reason about. When these >> discontinuous effects occur, we have to stop our development, do >> profiling, and try to isolate the obscure cause, then restructure >> code in >> bizzarre ways to try to get some determinism in space allocation. >> >> My abstract idea is that it should be possible to stochastically >> throttle >> these effects, by throtting whether (and whic) thunks get cached to >> (WH)NF >> or re-valuated on each use. >> >> I do think it is possible to teach people how to program in FP >> succinctly >> and without making their head hurt: >> >> http://www.haskell.org/pipermail/haskell-cafe/2009-November/ >> 068564.html >> >> You may not find many people here openly expressing their interest in >> these topics, but I think there are millions of people out there who >> would >> benefit. >> _______________________________________________ >> 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 > From jason.dusek at gmail.com Thu Nov 5 00:19:47 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Nov 4 23:55:54 2009 Subject: [Haskell-cafe] Arrays in Clean and Haskell In-Reply-To: <950451.93455.qm@web58806.mail.re1.yahoo.com> References: <42784f260911041322m55c8c87du2e685bc65c3e581c@mail.gmail.com> <950451.93455.qm@web58806.mail.re1.yahoo.com> Message-ID: <42784f260911042119j2617d191u3ce0b57c21a1d2ad@mail.gmail.com> 2009/11/04 Philippos Apolinarius > Let me see whether I understoodnd you correctly... If I read > the contents of a file, the string will may be lazy (or > something like that) and?not consume memory? A `String` or a lazy `ByteString` will be lazy and consume minimal memory. You can parse lazy `ByteString`s with AttoParsec. To the best of my knowledge, the most patched up and version of that parser is here: http://hackage.haskell.org/package/bytestringparser-temporary/ It is really in your best interest to parse with `ByteString`s instead of `String`s. Disclosure of conflict of interest: The package I mention is my own fork of Bryan O'Sullivan's AttoParsec (which is a little broken in places). > In fewer words, will the string behave like the infinite list > of random numbers that I have used in the examples I posted? In so far as it is lazy, yes. Lazy IO. A terrible idea, except when it's a good idea. -- Jason Dusek From lrpalmer at gmail.com Thu Nov 5 01:00:51 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Nov 5 00:36:57 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <1257382324.5965.97.camel@idefix.localdomain> References: <1257382324.5965.97.camel@idefix.localdomain> Message-ID: <7ca3f0160911042200s7021075kbe3fe4d074352bc@mail.gmail.com> On Wed, Nov 4, 2009 at 5:52 PM, Matus Tejiscak wrote: > Hello, -Cafe, > > I'm looking for an interesting topic to hack on in my thesis. > > The thesis should be rather "theoretical"/abstract (writing a mail > client in Haskell is not, for example), dealing with FP or related > fields. I've had a few (blurry) ideas, ranging from investigating > (possibilities for) Haskell extensions, to zygohistomorphic > prepromorphisms, but nothing concrete, possibly because I'm not familiar > with these areas enough to see what could be done -- which brings up a > question whether it is a good idea to even try hacking on a topic like > this. > > However, I'm eager to learn so if you have a topic you'd need somebody > to work on, or just an interesting (or maybe even an uninteresting) > idea, i'd be grateful for suggestions. :) Yes! I have been trying to experiment with lazy specializing virtual machine, but I am starting a company so basically have no time for such academic pursuits. Here is a short brainstormy introduction I wrote about lazy specialization to whet your appetite: http://lukepalmer.wordpress.com/2009/07/07/emphasizing-specialization/ And an overnight hack proof of concept: http://github.com/luqui/vatican But I think the area deserves *much* more research than it is currently getting, and could end up being a influential piece of functional programming. There are a fair amount of topics in there -- the one I am most interested in is simply the art of engineering for a lazy specializer. I.e. how does having a lazy specializing language affect the way we write efficient purely functional programs? If you are interested, I would be happy to guide you through what I know so you can find something interesting and pick it up quickly. Luke From ryani.spam at gmail.com Thu Nov 5 01:19:26 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Nov 5 00:55:33 2009 Subject: [Haskell-cafe] Strict Monad In-Reply-To: References: Message-ID: <2f9b2d30911042219lf9446e2qb0adabfdfa1213a9@mail.gmail.com> 2009/11/4 ?lvaro Garc?a P?rez : > Hi, > > I'm trying to characterise some strict monads to work with a particular > lambda-calculus evaluator, as an alternative to CPS monad. > > In the thread "Stupid question #852: Strict monad" the implementation of > some strict monads (and pseudo-monads, not meeting the identity laws) is > discussed. It's clear form that thread that using pattern-matching in the > (>>=) operation will force evaluation, then the Id monad defined with > pattern-matching is strict (and it's indeed a monad): > >> newtype Id a = Id a >> >> instance Monad Id where >>???? return = Id >>???? (Id a) >>= f = f a > > But it's impossible to derive a monad transformer from?it, because you don't > know the constructors of the monads you're transforming. I then tried to use > strict application ($!). My first attempt was > >>?newtype Strict a = InSt { outSt :: a } >> >> instance Monad Strict where >>???? return = InSt >>?????m >>= f = (\x -> f x) $! (outSt m) > > which is not a monad (doesn't meet the left identity law). > > ????(return undefined)?>>=?(\x -> const (return 1) x) > =/=????????(return 1) > > Then I wondered if it was enough to force the evaluation of the whole monad, > instead of the value inside the monad, yielding the second attempt: > >> newtype Strict a = InSt { outSt :: a } >> >> instance Monad Strict where >>???? return = InSt >>???? m >>= f = (\x -> f (outSt x)) $! m > > I placed the outSt inside the anonymous function, leaving the monad on the > right of the ($!). This meets the identity laws and surprisingly (I was > expecting a lazy behaviour) implements strict semantics (it behaves like > CPS, which is strict as well). A transformer from this monad can be easily > written: This seems like it has the same problem to me: return undefined >>= const return 1 = InSt undefined >>= const return 1 = (\x -> (const return 1) (outSt x)) $! (InSt undefined) = let y = InSt undefined in seq y ((\x -> (const return 1) (outSt x)) y) = undefined -- since InSt is a newtype. You would get different behavior with data InStD a = InStD a which puts another element in the domain: InSt () contains [_|_, InSt ()] only whereas InStD () contains [_|_, InStD _|_, InStD ()] -- ryan From shelby at coolpage.com Thu Nov 5 01:39:23 2009 From: shelby at coolpage.com (Shelby Moore) Date: Thu Nov 5 01:15:29 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <7ca3f0160911042200s7021075kbe3fe4d074352bc@mail.gmail.com> References: <1257382324.5965.97.camel@idefix.localdomain> <7ca3f0160911042200s7021075kbe3fe4d074352bc@mail.gmail.com> Message-ID: <3978.121.97.54.144.1257403163.squirrel@webmail12.pair.com> > Here is a short brainstormy introduction I wrote about lazy > specialization to whet your appetite: > http://lukepalmer.wordpress.com/2009/07/07/emphasizing-specialization/ Quoting from your linked page: "...The key point about data structures is that they can be decomposed; you can peel off the root of a tree and leave yourself with only one of the branches, and the other branch will be garbage collected. A lazy specializer promotes full-blown functions to the level of data structures. Functions can now be decomposed (by composing!) in the same way, sharing important pieces and forgetting unimportant ones... ...removes the encouragement to fiddle with the details of a function for more speed... ...thus arbitrary functions separate us from the enclosed Behavior, about which we must selectively forget things. However, the lazy specializer has no trouble looking through those functions, and will modify the behavior anyway, ridding us of the dreaded space leak..." Analyzing structure (for optimization of speed and unconflating data) at the semantic layer can also eliminate space leaks, which was an area of work I was suggesting here: http://www.haskell.org/pipermail/haskell-cafe/2009-November/068638.html "...Perhaps it is possible to categorize and generalize many of the types of structures that cause space leaks, then handle them at the semantic layer..." From mhady7 at gmail.com Thu Nov 5 01:39:31 2009 From: mhady7 at gmail.com (Mohamed Ayed) Date: Thu Nov 5 01:15:40 2009 Subject: [Haskell-cafe] debugging Message-ID: can you please let me know how to debug Haskell programs? I got the observe module but it is complainnig about some "concurrent " moduel that it can not find . Also, how to change the path that Hugs uses to search for files ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091105/d8566739/attachment.html From z_axis at 163.com Thu Nov 5 02:17:40 2009 From: z_axis at 163.com (zaxis) Date: Thu Nov 5 01:53:48 2009 Subject: [Haskell-cafe] What's the new type ? Message-ID: <26208600.post@talk.nabble.com> type Parser a = GenParser Char () a newtype GenParser tok st a = Parser (State tok st -> Consumed (Reply tok st a)) As i know, the Parser type is just an alias of GenParser. Then can the second line be replaced as below? newtype GenParser tok st a = GenParser Char () (State tok st -> Consumed (Reply tok st a)) If it can , then what is the new type ? Sincerely! ----- fac n = foldr (*) 1 [1..n] -- View this message in context: http://old.nabble.com/What%27s-the-new-type---tp26208600p26208600.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From dons at galois.com Thu Nov 5 02:47:27 2009 From: dons at galois.com (Don Stewart) Date: Thu Nov 5 02:23:36 2009 Subject: [Haskell-cafe] debugging In-Reply-To: References: Message-ID: <20091105074727.GA21753@whirlpool.galois.com> mhady7: > can you please let me know how to debug Haskell programs? I got the observe > module but it is complainnig about some "concurrent " moduel that it can not > find . Also, how to change the path that Hugs uses to search for files ? You should probably upgrade to GHC first (via the Haskell Platform: http://haskell.org/platform), and then look at Debug.Trace or the GHCi debugger. http://www.haskell.org/ghc/docs/6.10-latest/html/users_guide/ghci-debugger.html -- Don From ryani.spam at gmail.com Thu Nov 5 03:23:57 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Nov 5 03:00:02 2009 Subject: [Haskell-cafe] What's the new type ? In-Reply-To: <26208600.post@talk.nabble.com> References: <26208600.post@talk.nabble.com> Message-ID: <2f9b2d30911050023v1df4318x6f3839d2ae6fd07a@mail.gmail.com> "newtype" creates a wrapper for an existing type that gets erased (so it has no cost) at runtime, but is distinct during typechecking. "type" creates an alias for an existing type, which is interchangeable (so it doesn't really exist during typechecking). In this case: GenParser tok st a is a function of the type State tok st -> Consumed (Reply tok st a) But you have to extract the value (via pattern matching) to call the function; to the typechecker they are distinct types. On the other hand, anywhere you see "Parser a", you could write "GenParser Char () a" and it would work the same. It's just giving you a shorter name for that common parser type. -- ryan On Wed, Nov 4, 2009 at 11:17 PM, zaxis wrote: > > type Parser a = GenParser Char () a > newtype GenParser tok st a = Parser (State tok st -> Consumed (Reply tok st > a)) > > As i know, the Parser type is just an alias of GenParser. Then ?can the > second line be replaced as below? > > newtype GenParser tok st a = GenParser Char () (State tok st -> Consumed > (Reply tok st a)) > > If it can , then what is the new type ? > > Sincerely! > > ----- > fac n = foldr (*) 1 [1..n] > -- > View this message in context: http://old.nabble.com/What%27s-the-new-type---tp26208600p26208600.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 > From miguelimo38 at yandex.ru Thu Nov 5 03:28:06 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Thu Nov 5 03:05:30 2009 Subject: [Haskell-cafe] What's the new type ? In-Reply-To: <26208600.post@talk.nabble.com> References: <26208600.post@talk.nabble.com> Message-ID: <4AF28C96.9010706@yandex.ru> In "type Parser" Parser is a type synonym. In GenParser, Parser is a data constructor; they live in separate namespaces. Yes, I admit, it's confusing. zaxis wrote: > type Parser a = GenParser Char () a > newtype GenParser tok st a = Parser (State tok st -> Consumed (Reply tok st > a)) > > As i know, the Parser type is just an alias of GenParser. Then can the > second line be replaced as below? > > newtype GenParser tok st a = GenParser Char () (State tok st -> Consumed > (Reply tok st a)) > > If it can , then what is the new type ? > > Sincerely! > > ----- > fac n = foldr (*) 1 [1..n] From ketil at malde.org Thu Nov 5 04:00:44 2009 From: ketil at malde.org (Ketil Malde) Date: Thu Nov 5 03:36:44 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <597965808.20091104200149@gmail.com> (Bulat Ziganshin's message of "Wed, 4 Nov 2009 20:01:49 +0300") References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> Message-ID: <87zl71s5vn.fsf@malde.org> Bulat Ziganshin writes: >> Right, the interesting thing is not how fast I can get with N times the >> effort, but if I can get fast enough with 1/N. > - while i say that haskell is slow compared to other languages, The "other languages" being C and C++. I believe Haskell is fast compared to Ruby, Python or Lisp. > i don't say that it is slow for you or that you need sped at all. > why it's repeated again and again? why you don't write to Don what you > don't need speed when he wrote that haslkell is fast I'm not saying I don't need speed. I need programs that are fast *enough*, and I would like to build them with a minimum of effort on my part. Which is why I would like to see how fast GHC can make more idiomatic Haskell code. > but wrote this to me? :( Because I am trying to agree with you. :-) >> Many of those people are making fairly simple mistakes. I think a >> somewhat seasoned programmer using good libraries can write declarative, >> concise, and readable code that still is reasonably fast. > i don't think that omitting strictness declarations is a mistake :) If your program is slow because you misunderstand how laziness affects execution, and if it's easily fixed by adding a bit of strictness, then, yes, that is the kind of mistake I'm talking about. >> At least for some approximation of the word. Only one benchmark on >> the shootout has C at a 3x advantage. > oh, can we stop saying about shootout? I'm using the numbers that are available, you are free to suggest better benchmarks. > if you want to see speed of pure haskell code, look at papers about > fast arrays/strings - their authors have measured that lazy lists are > hundreds times slower than idiomatic C code. is use of lazy lists > counted as mistake too Yes!? You don't have to program a lot of Haskell to realize that for performance sensitive data, you need to use ByteStrings or some other packed data structure, not lazy lists of Chars. Many of those complaining on poor performance are advised to use ByteStrings instead, and more often than not, it helps tremendously. Again, I'm not contradicting your claim that C will usually be faster, or that writing very fast programs in Haskell takes a lot of effort. I'm saying that programs have to be fast *enough* and correct *enough*, and when those goals are achieved, the question is how we can achieve them with a minimum of effort, and with a maximum of clarity. -k ?) Probably not a mistake in those papers, that depends on what the authors wanted to illustrate. But clearly a mistake in a performance sensitive program, and clearly a mistake if you want to argue that Haskell is too slow to use for real programs. -- If I haven't seen further, it is by standing in the footprints of giants From tittoassini at gmail.com Thu Nov 5 04:27:36 2009 From: tittoassini at gmail.com (Pasqualino "Titto" Assini) Date: Thu Nov 5 04:03:41 2009 Subject: [Haskell-cafe] representing Haskell objects in a uniform way In-Reply-To: <200911042226.10271.daniel.is.fischer@web.de> References: <2d34474e0911041303j546d9e03ya3124b349411ad7a@mail.gmail.com> <200911042226.10271.daniel.is.fischer@web.de> Message-ID: <2d34474e0911050127k397a57fer3adfac3c1330bc28@mail.gmail.com> Thank you both very much, I now see my mistake! titto From martijn at van.steenbergen.nl Thu Nov 5 04:33:51 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Nov 5 04:10:04 2009 Subject: [Haskell-cafe] Fair diagonals In-Reply-To: <3B0A27AE-F76F-4F38-AD4D-8561007B6595@w3future.com> References: <4AF095D0.9030105@van.steenbergen.nl> <44F139D4-0B29-42A1-8D45-EF80333DB182@w3future.com> <4AF18DFA.7020602@gmail.com> <3B0A27AE-F76F-4F38-AD4D-8561007B6595@w3future.com> Message-ID: <4AF29BFF.8050204@van.steenbergen.nl> Sjoerd Visscher wrote: > diagN = bfs . mapM fromList This is awesome guys, thanks so much. Martijn. From bulat.ziganshin at gmail.com Thu Nov 5 04:42:36 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Nov 5 04:21:42 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <87zl71s5vn.fsf@malde.org> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> <87zl71s5vn.fsf@malde.org> Message-ID: <1277670210.20091105124236@gmail.com> Hello Ketil, Thursday, November 5, 2009, 12:00:44 PM, you wrote: >> - while i say that haskell is slow compared to other languages, > The "other languages" being C and C++. I believe Haskell is fast > compared to Ruby, Python or Lisp. of course >> i don't say that it is slow for you or that you need sped at all. >> why it's repeated again and again? why you don't write to Don what you >> don't need speed when he wrote that haslkell is fast > I'm not saying I don't need speed. I need programs that are fast > *enough*, and I would like to build them with a minimum of effort on my > part. well, why you don't write this to Don? what i said is just what ghc generates much slower code that gcc. there is nothing in my letter about your haskell usage, so why it's all? > Which is why I would like to see how fast GHC can make more idiomatic > Haskell code. i think it would be more natural to write this to someone who thinks that haskell is fast based on measurements on non-idiomatic code rather than to me >> but wrote this to me? :( > Because I am trying to agree with you. :-) really? :/ >>> Many of those people are making fairly simple mistakes. I think a >>> somewhat seasoned programmer using good libraries can write declarative, >>> concise, and readable code that still is reasonably fast. >> i don't think that omitting strictness declarations is a mistake :) > If your program is slow because you misunderstand how laziness affects > execution, and if it's easily fixed by adding a bit of strictness, then, > yes, that is the kind of mistake I'm talking about. for me, analyzing of slow program and finding where to add "bit of strictness" isn't something easy. it's whole optimization work and finally you got with need of strict lists or strict arrays >>> At least for some approximation of the word. Only one benchmark on >>> the shootout has C at a 3x advantage. >> oh, can we stop saying about shootout? > I'm using the numbers that are available, you are free to suggest better > benchmarks. it's here: >> if you want to see speed of pure haskell code, look at papers about >> fast arrays/strings - their authors have measured that lazy lists are >> hundreds times slower than idiomatic C code. is use of lazy lists >> counted as mistake too > Yes!? You don't have to program a lot of Haskell to realize that for > performance sensitive data, you need to use ByteStrings or some other > packed data structure, not lazy lists of Chars. Many of those > complaining on poor performance are advised to use ByteStrings instead, > and more often than not, it helps tremendously. the problems is what it's string-only and doesn't speed up even all programs using strings (for example, we have hand-made BS.readInt operation since it cannot be made efficient w/o low-level coding). another example - afaik, there is no BS version of ParseC what demonstrates substantial speed increase > Again, I'm not contradicting your claim that C will usually be faster, > or that writing very fast programs in Haskell takes a lot of effort. > I'm saying that programs have to be fast *enough* and correct *enough*, > and when those goals are achieved, the question is how we can achieve > them with a minimum of effort, and with a maximum of clarity. it's obvious. why i don't write to everyone complaining about lack of some haskell features that i don't need it? > ?) Probably not a mistake in those papers, that depends on what the authors > wanted to illustrate. But clearly a mistake in a performance sensitive > program, and clearly a mistake if you want to argue that Haskell is too > slow to use for real programs. i don't say that haskell is slow for real programs. i say that idiomatic haskell is much slower than idiomatic C and these papers demonstrates how much, for simple computation-intensive loops -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From dav.vire+haskell at gmail.com Thu Nov 5 04:49:38 2009 From: dav.vire+haskell at gmail.com (David Virebayre) Date: Thu Nov 5 04:25:46 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <87zl71s5vn.fsf@malde.org> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> <87zl71s5vn.fsf@malde.org> Message-ID: <4c88418c0911050149q446b7f9eu53136811f962ed2e@mail.gmail.com> I used to think, was I clueless !, that if the compiler was good enough, then I'd perform magic for me; like transforming that list-based quicksort in a unboxed, mutable array based one, automatically, if that made sense. Like I said, I was clueless. Since then, I understood that while modern GHC compilers are awesome, they don't compete with Gandalf yet. I think that's in a way what's Bulat is saying : for Haskell to really compete with C in *his view*, if I understand it, the compiler has to be able to take idiomatic Haskell code, and translate it in idomatic C code or better. Or said another way, we have to be able to write things like SDL, jpeg or mpeg processing in Haskell, instead of writing bindings to C libraries, without losing on performance. In short, maybe Bulat wishes to be able to write the time-critical parts of his archiver, in Haskell, without resorting to low-level hacking. Then he'd be happy with Haskell speed ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091105/bc9c00c2/attachment.html From bulat.ziganshin at gmail.com Thu Nov 5 05:05:45 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Nov 5 04:42:03 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <4c88418c0911050149q446b7f9eu53136811f962ed2e@mail.gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> <87zl71s5vn.fsf@malde.org> <4c88418c0911050149q446b7f9eu53136811f962ed2e@mail.gmail.com> Message-ID: <476159506.20091105130545@gmail.com> Hello David, Thursday, November 5, 2009, 12:49:38 PM, you wrote: > I think that's in a way what's Bulat is saying : for Haskell to > really compete with C in *his view*, if I understand it, the > compiler has to be able to take idiomatic Haskell code, and > translate it in idomatic C code or better. > In short, maybe Bulat wishes to be able to write the time-critical > parts of his archiver, in Haskell, without resorting to low-level > hacking. Then he'd be happy with Haskell speed ? i'm happy with haskell speed since i don't expect that it may be used for time-critical parts (btw, i mostly use C libraries written by other people). what i mean is that other people shouldn't expect that Haskell may compete with C based on meaningless shootout numbers or rare successful benchmarks published here (unsuccessful benchmarks are just not published, i hope it's obvious?). the same people that are proving that haskell is as fast as C when they want, will prove that Haskell is much slower when they need opposite conclusion. don't believe ads - check it yourself with code you actually write -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From stevech1097 at yahoo.com.au Thu Nov 5 05:32:38 2009 From: stevech1097 at yahoo.com.au (Steve) Date: Thu Nov 5 05:02:45 2009 Subject: [Haskell-cafe] Re: Simple FAST lazy functional primes In-Reply-To: <20091103155227.E721A324918@www.haskell.org> References: <20091103155227.E721A324918@www.haskell.org> Message-ID: <1257417158.3701.17.camel@localhost> On Tue, 2009-11-03 at 10:52 -0500, Will wrote: > I've just tried it and it was twice slower than mine. (?) I didn't use > the [Int] > signature in both. Maybe it's not real issues we're dealing with here, > but > compiler/OS/CPU issues? (or have you've forgotten to put the [Int] > signature > into my code too, when tested? It runs twice as fast with it). > Although your > code has an advantage that it is very easy to add the wheel > optimization to it. I used [Int] for both. If you didn't use [Int] then it defaults to [Integer] and you are probably testing the speed of GMP integer operations (rather than the speed of Haskell Int operations) which could give differing conclusions. I had looked into using a wheel before. Its nice in theory, but not so useful in practice. At least that's my experience where using a wheel made the primes function slower. > What I have now, is this: > > qprimes = 2: 3: sieve emptyQ primes' 5 where > primes' = tail qprimes > sieve q (p:ps) x > = h ++ sieve (addQ q' (2*p) (p*p+2*p)) ps (p*p+2) > where > (h,q') = noComps q [x,x+2..p*p-2] > ...... Adding your code and conclusions to "Prime numbers" on the Haskell wiki, could be useful. http://www.haskell.org/haskellwiki/Prime_numbers I've just updated the page to split it into "Finding Primes" and "Testing Primality". Steve From hectorg87 at gmail.com Thu Nov 5 05:54:24 2009 From: hectorg87 at gmail.com (Hector Guilarte) Date: Thu Nov 5 05:30:52 2009 Subject: [Haskell-cafe] Memory Leak - Artificial Neural Network Message-ID: <69630b260911050254y1c1330f8t56ead9be5fda0534@mail.gmail.com> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: Parte2New.hs Type: text/x-haskell Size: 12122 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091105/92d5bc0d/Parte2New.bin From hectorg87 at gmail.com Thu Nov 5 05:57:25 2009 From: hectorg87 at gmail.com (Hector Guilarte) Date: Thu Nov 5 05:35:01 2009 Subject: [Haskell-cafe] Re: Memory Leak - Artificial Neural Network In-Reply-To: <69630b260911050254y1c1330f8t56ead9be5fda0534@mail.gmail.com> References: <69630b260911050254y1c1330f8t56ead9be5fda0534@mail.gmail.com> Message-ID: <69630b260911050257o1e65a768k9dec2be578a5737a@mail.gmail.com> By the way, there is a line where I'm using unsafePerformIO to print the sum of the squared erros, feel free to delete it, I was checking convergence on smaller training sets before I realized the huge memory leak... Once again, Thanks in advance Hector Guilarte On Thu, Nov 5, 2009 at 6:24 AM, Hector Guilarte wrote: > Hello everyone, > > I just implemented an Artificial Neural Network but I'm having a serious > memory leak. I was very careful of using tail recursion all over my code, > but for some reason (a.k.a lazyness) my program is misusing incredible > ammounts of RAM. I read the whole chapter 25 of Real World Haskell trying to > find a solution with no luck. Maybe somebody can take a look at the code to > help me out with this problem, I would really appreciate it. > > Thanks A LOT in advance, > > Hector Guilarte > > Ps: The file is also attached > > Ps2: The code is written in Spanglish, sorry for that, I'm working on that > bad habbit... > > module Main where > > import Control.Monad > import System.IO > import qualified Random > import System.IO.Unsafe > import System.Environment > import Data.List > > data ANN = ANN Layer Layer Layer -- ^ Red Neuronal de 3 capas > deriving (Eq, Show) > > type Layer = [Neuron] -- ^ Lista de Neuronas que conforman la capa > > data Neuron = Neuron [(Float,Float)] Float -- ^ Lista de (pesos,xs) y > umbral asociado > deriving (Eq, Show) > > neurona:: Neuron -> -- ^ [(Pesos,Xs)] y Umbral > Float > neurona (Neuron entrada umbral) = > let entradaTupla = unzip entrada > pesos = fst entradaTupla > xs = snd entradaTupla > suma = foldl' (+) (-umbral) (zipWith (*) xs pesos) > in sigmoidal suma > > neurona2:: [(Float,Float)] -> -- ^ [(Pesos,Xs)] > Float -> -- ^ Umbral > Float > neurona2 valores umbral = > let entradaTupla = unzip valores > pesos = fst entradaTupla > xs = snd entradaTupla > suma = foldl' (+) umbral (zipWith (*) xs pesos) > in sigmoidal suma > > -- ANN [] [Neuron [(4.7621,0.9993291),(4.7618,0.94501287)] 7.3061,Neuron > [(6.3917,0.9993291),(6.3917,0.94501287)] 2.8441] [Neuron > [(-10.3788,0.9993291),(9.7691,0.94501287)] 4.5589] > > sigmoidal:: Float -> Float > sigmoidal x = 1 / (1 + (exp (-x))) > > main:: IO() > main = do > -- nombreArchivo <- getArgs > -- archivo <- readFile (head nombreArchivo) > pesos <- pesosIniciales 10000 > randomXs <- generarRandomXs 5000 > randomYs <- generarRandomYs 5000 > let conjunto = generar 200 0 0 randomXs randomYs [] > --print conjunto > -- let lista = parsearString archivo [[]] > -- let splitted = split lista [] > let (a,b,c) = (unzip3 (take 200 conjunto)) > --let (a,b,c) = ([0,1,0,1],[0,0,1,1],[0,1,1,0]) > let ejemplos = zipWith (ajustarEjemplos) a b > -- print ejemplos > let nuevaRed = armarRed 2 8 1 pesos > let entrenada = train nuevaRed ejemplos c > let redInicializada = map (iniciarXsRed entrenada) ejemplos > let resultados = map resultadoRed1Output (map evaluarRed > redInicializada) > print nuevaRed > print entrenada > print resultados > return () > > ajustarEjemplos:: Float -> Float -> [Float] > ajustarEjemplos a b = [a,b] > > train:: ANN -> [[Float]] -> [Float] -> ANN > train red ejemplosTodos esperadosTodos = > let entrenado = entrenamiento red ejemplosTodos esperadosTodos [] 200 > squaredErrors = snd entrenado > in if squaredErrors < 3 then fst entrenado > else train (fst entrenado) ejemplosTodos esperadosTodos > > -- ENTRENAMIENTO > > entrenamiento:: ANN -> [[Float]] -> [Float] -> [Float] -> Int -> > (ANN,Float) > entrenamiento red _ _ accum 0 = > let squaredErrors = foldl' (+) 0 (map (**2) accum) > in (red,squaredErrors) > entrenamiento red ejemplos esperados accum epoch = > let redInicializada = iniciarXsRed red (head ejemplos) > redEvaluada = evaluarRed redInicializada > redAjustada = ajustarPesos redEvaluada (head esperados) > error = (head esperados) - (resultadoRed1Output redAjustada) > in entrenamiento redAjustada (tail ejemplos) (tail esperados) (accum ++ > [error]) (epoch-1) > > resultadoRed1Output:: ANN -> Float > resultadoRed1Output (ANN _ _ [(Neuron ((_,xs):_) _)]) = xs > > iniciarXsRed:: ANN -> [Float] -> ANN > iniciarXsRed (ANN inputLayer hiddenLayer outputLayer) valores = > let inputNueva = zipWith ajustarXsInput inputLayer valores > in (ANN inputNueva hiddenLayer outputLayer) > > ajustarXsInput:: Neuron -> Float -> Neuron > ajustarXsInput (Neuron listaNeurona threshold) xsInput = > let listaNueva = map (ajustarXs xsInput) listaNeurona > in (Neuron listaNueva threshold) > -- FIN ENTRENAMIENTO > > pesosIniciales :: Int -> IO [Float] > pesosIniciales n = do > (replicateM n (Random.getStdRandom intervalo)) > where > intervalo = Random.randomR (-0.5,0.5) > > parsearString:: String -> [String] -> [String] > parsearString [] lista = (tail lista) > parsearString (x:xs) lista = if x == '\n' then parsearString xs ([]:lista) > else parsearString xs (((head lista) ++ > [x]):(tail lista)) > > split:: [String] -> [(Float,Float,Float)] -> [(Float,Float,Float)] > split [] accum = accum > split (x:xs) accum = > let first = readNum x "" > fstNum = read $ fst first > second = readNum (snd first) "" > sndNum = read $ fst second > third = readNum (snd second) "" > thrdNum = if (head $ fst third) == 'A' then 0 > else 1 > in split xs ([(fstNum,sndNum,thrdNum)]++accum) > > readNum:: String -> String -> (String,String) > readNum [] num = ([(head num)],num) > readNum (x:xs) num = if x == ' ' then (num,xs) > else (if x == '\n' then (num,xs) > else readNum xs (num ++ [x]) > ) > > generar:: Int -> Int -> Int -> [Float] -> [Float] -> [(Float,Float,Float)] > -> [(Float,Float,Float)] > generar total dentro fuera randomXs randomYs accum > | total == dentro + fuera = accum > | dentro == total `div` 2 = > let x = head randomXs > y = head randomYs > isDentro = ((x-15)**2) + ((y-6)**2) <= 9 > in if isDentro then generar total dentro fuera (tail randomXs) > (tail randomYs) accum > else generar total dentro (fuera+1) (tail randomXs) (tail > randomYs) (accum ++ [(x,y,0)]) > | fuera == total `div` 2 = > let x = head randomXs > y = head randomYs > isDentro = ((x-15)**2) + ((y-6)**2) <= 9 > in if isDentro then generar total (dentro+1) fuera (tail randomXs) > (tail randomYs) (accum ++ [(x,y,1)]) > else generar total dentro fuera (tail randomXs) (tail > randomYs) accum > | otherwise = > let x = head randomXs > y = head randomYs > isDentro = ((x-15)**2) + ((y-6)**2) <= 9 > in if isDentro then generar total (dentro+1) fuera (tail randomXs) > (tail randomYs) (accum ++ [(x,y,1)]) > else generar total dentro (fuera+1) (tail randomXs) (tail > randomYs) (accum ++ [(x,y,0)]) > > generarRandomXs :: Int -> IO [Float] > generarRandomXs n = do > (replicateM n (Random.getStdRandom intervalo)) > where > intervalo = Random.randomR (0.0,20.0) > > generarRandomYs :: Int -> IO [Float] > generarRandomYs n = do > (replicateM n (Random.getStdRandom intervalo)) > where > intervalo = Random.randomR (0.0,12.0) > > -- ARMAR RED > armarRed:: Int -> Int -> Int -> [Float] -> ANN > armarRed numNeuronasInput numNeuronasHidden numNeuronasOutput randoms = > let layerInput = armarLayerInput numNeuronasInput numNeuronasHidden > randoms [] > layerHidden = armarLayerHidden numNeuronasHidden numNeuronasOutput > (snd layerInput) [] > layerOutput = armarLayerOutput numNeuronasOutput (snd layerHidden) > [] > in (ANN (fst layerInput) (fst layerHidden) layerOutput) > > armarLayerInput:: Int -> Int -> [Float] -> Layer -> (Layer,[Float]) > armarLayerInput 0 _ randoms accum = (accum,randoms) > armarLayerInput numNeuronasInput numNeuronasHidden randoms accum = > let listaNeurona = armarListaNeuronasInput numNeuronasHidden randoms [] > newRandoms = snd listaNeurona > neurona = [(Neuron (fst listaNeurona) 0)] > in armarLayerInput (numNeuronasInput-1) numNeuronasHidden newRandoms > (accum ++ neurona) > > armarLayerHidden:: Int-> Int -> [Float] -> Layer -> (Layer,[Float]) > armarLayerHidden 0 _ randoms accum = (accum,randoms) > armarLayerHidden numNeuronasHidden numNeuronasOutput randoms accum = > let listaNeurona = armarListaNeuronasHidden numNeuronasOutput randoms > [] > neurona = [(Neuron (fst listaNeurona) (head $ snd listaNeurona))] > in armarLayerHidden (numNeuronasHidden-1) numNeuronasOutput (tail $ snd > listaNeurona) (accum ++ neurona) > > armarListaNeuronasHidden:: Int -> [Float] -> [(Float,Float)] -> > ([(Float,Float)],[Float]) > armarListaNeuronasHidden 0 randoms accum = (accum,randoms) > armarListaNeuronasHidden numElems randoms accum = > let pesosYxs = [((head randoms),(head $ tail randoms))] > in armarListaNeuronasHidden (numElems-1) (tail $ tail randoms) (accum > ++ pesosYxs) > > armarListaNeuronasInput:: Int -> [Float] -> [(Float,Float)] -> > ([(Float,Float)],[Float]) > armarListaNeuronasInput 0 randoms accum = (accum,randoms) > armarListaNeuronasInput numElems randoms accum = > let pesosYxs = [((head randoms),0)] > in armarListaNeuronasInput (numElems-1) (tail randoms) (accum ++ > pesosYxs) > > armarLayerOutput:: Int -> [Float] -> Layer -> Layer > armarLayerOutput 0 _ accum = accum > armarLayerOutput numNeuronasHidden randoms accum = > let neurona = [(Neuron [(0,(head randoms))] (head $ tail randoms))] > in armarLayerOutput (numNeuronasHidden-1) (tail $ tail randoms) (accum > ++ neurona) > > -- FIN ARMAR RED > > -- EVALUAR RED > > evaluarRed:: ANN -> ANN > evaluarRed (ANN inputLayer hiddenLayer outputLayer) = > let newHidden = ajustarLayer inputLayer hiddenLayer [] 0 > newOutput = ajustarLayer newHidden outputLayer [] 0 > in (ANN inputLayer newHidden newOutput) > > ajustarLayer:: Layer -> Layer -> Layer -> Int -> Layer > ajustarLayer _ [] accum numNeurona = accum > ajustarLayer leftLayer ((Neuron listaNeurona threshold):rightLayer) accum > numNeurona = > let valorLayer = evaluarLayer leftLayer threshold numNeurona > listaNeuronaNew = map (ajustarXs valorLayer) listaNeurona > in ajustarLayer leftLayer rightLayer (accum ++ [(Neuron listaNeuronaNew > threshold)]) (numNeurona+1) > > ajustarXs:: Float -> (Float,Float) -> (Float,Float) > ajustarXs xs (peso,_) = (peso,xs) > > evaluarLayer:: Layer -> Float -> Int -> Float > evaluarLayer layer threshold numNeurona = > let listaTuplas = extraerTuplaLayer layer numNeurona [] > valor = neurona2 listaTuplas threshold > in valor > > extraerTuplaLayer:: Layer -> Int -> [(Float,Float)] -> [(Float,Float)] > extraerTuplaLayer [] _ accum = accum > extraerTuplaLayer ((Neuron tupla _):resto) numNeurona accum = > extraerTuplaLayer resto numNeurona (accum ++ [(tupla !! numNeurona)]) > > -- FIN EVALUAR RED > > -- AJUSTAR RED > > ajustarPesos:: ANN -> Float -> ANN > ajustarPesos salida@(ANN inputLayer hiddenLayer outputLayer) esperado = > let outputNuevo = map (ajustarPesoOutput esperado) outputLayer > gradientes = snd $ unzip outputNuevo > hiddenNuevo = map (ajustarPesoHidden gradientes) hiddenLayer > gradientes2 = snd $ unzip hiddenNuevo > inputNuevo = map (ajustarPesoInput gradientes2) inputLayer > in (ANN inputNuevo (fst $ unzip hiddenNuevo) (fst $ unzip outputNuevo)) > > ajustarPesoOutput:: Float -> Neuron -> (Neuron,Float) > ajustarPesoOutput esperado (Neuron [(peso,obtenido)] threshold) = > let error = esperado-obtenido > gradiente = obtenido*(1-obtenido)*error > deltaTheta = tasaAprendizaje*(-1)*gradiente > thresholdNuevo = threshold + deltaTheta > in ((Neuron [(peso,obtenido)] thresholdNuevo),gradiente) > > ajustarPesoHidden:: [Float] -> Neuron -> (Neuron,Float) > ajustarPesoHidden gradientes (Neuron listaNeurona threshold) = > let (pesosViejos,xsViejos) = unzip listaNeurona > pesosAjustados = zipWith ajustarPesosHidden listaNeurona gradientes > sumatoriaGradientes = foldl' (+) 0 (zipWith (*) gradientes > pesosViejos) > gradiente = (head xsViejos)*(1-(head xsViejos))*sumatoriaGradientes > thresholdNuevo = tasaAprendizaje*(-1)*gradiente > in ((Neuron pesosAjustados thresholdNuevo),gradiente) > > ajustarPesoInput:: [Float] -> Neuron -> Neuron > ajustarPesoInput gradientes (Neuron listaNeurona threshold) = > let (pesosViejos,xsViejos) = unzip listaNeurona > pesosAjustados = zipWith (+) pesosViejos (map (*tasaAprendizaje) > (zipWith (*) gradientes xsViejos)) > listaNeuronaNueva = zip pesosAjustados xsViejos > in (Neuron listaNeuronaNueva threshold) > > > ajustarPesosHidden:: (Float,Float) -> Float -> (Float,Float) > ajustarPesosHidden (pesoViejo,xs) gradiente = > let deltaW = tasaAprendizaje*xs*gradiente > pesoNuevo = pesoViejo + deltaW > in (pesoNuevo,xs) > > -- FIN AJUSTAR RED > > tasaAprendizaje = 0.1 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091105/16ba4ab2/attachment-0001.html From jwlato at gmail.com Thu Nov 5 05:59:14 2009 From: jwlato at gmail.com (John Lato) Date: Thu Nov 5 05:35:21 2009 Subject: [Haskell-cafe] Re: What's the deal with Clean? Message-ID: <9979e72e0911050259w13128032l88ac778fdd2a65e5@mail.gmail.com> Hi Bulat, I hope you don't mind me asking this, but when you state that "idiomatic haskell is much slower than idiomatic C", what do you mean by "much slower"? 2 times? 3 times? 20 times? Order of magnitude? I'm not going to disagree with you, however it seems to me the gap is closing. My opinion may be colored by having just examined Masayuki Takagi's SPH code, which I considered very idiomatic Haskell and for me performed equivalently to his C++ code with the changes I detailed in an earlier email (none of which involved any substantial changes to his code or style in my opinion). Best, John > From: Bulat Ziganshin > > i don't say that haskell is slow for real programs. i say that > idiomatic haskell is much slower than idiomatic C and these papers > demonstrates how much, for simple computation-intensive loops > > -- > Best regards, > ?Bulat ? ? ? ? ? ? ? ? ? ? ? ? ? ?mailto:Bulat.Ziganshin@gmail.com > From shelby at coolpage.com Thu Nov 5 06:07:04 2009 From: shelby at coolpage.com (Shelby Moore) Date: Thu Nov 5 05:43:08 2009 Subject: [Haskell-cafe] Memory Leak - Artificial Neural Network In-Reply-To: <69630b260911050254y1c1330f8t56ead9be5fda0534@mail.gmail.com> References: <69630b260911050254y1c1330f8t56ead9be5fda0534@mail.gmail.com> Message-ID: <4321.121.97.54.144.1257419224.squirrel@webmail12.pair.com> > Hello everyone, > > I just implemented an Artificial Neural Network but I'm having a serious > memory leak. I was very careful of using tail recursion all over my code, > but for some reason (a.k.a lazyness) my program is misusing incredible > ammounts of RAM. I read the whole chapter 25 of Real World Haskell trying > to > find a solution with no luck. Maybe somebody can take a look at the code > to > help me out with this problem, I would really appreciate it. I suggested an idea for fix to Haskell in general for these: http://www.haskell.org/pipermail/haskell-cafe/2009-November/068633.html Maybe you might want to vote for my Proposal at the bug tracker for Haskell: http://hackage.haskell.org/trac/ghc/ticket/3630 (note Hackage has been down and this page is still giving errors, even though the page intially came up when hackage came back up) From hectorg87 at gmail.com Thu Nov 5 06:15:28 2009 From: hectorg87 at gmail.com (Hector Guilarte) Date: Thu Nov 5 05:51:41 2009 Subject: [Haskell-cafe] Re: Memory Leak - Artificial Neural Network In-Reply-To: <69630b260911050257o1e65a768k9dec2be578a5737a@mail.gmail.com> References: <69630b260911050254y1c1330f8t56ead9be5fda0534@mail.gmail.com><69630b260911050257o1e65a768k9dec2be578a5737a@mail.gmail.com> Message-ID: <1186946808-1257419732-cardhu_decombobulator_blackberry.rim.net-867547441-@bda078.bisx.prod.on.blackberry> There's one more thing I forgot to mention, there's a line in the main function that calls the function that builds the initial neural network, in that call you can specify how many input, Hidden and Output Neurons you want, please leave the input in 2 and the output in 1, but feel free to play with the hidden Neurons value, the best performance I got was for 6 Neurons... The line I'm talking about it the one that says: ??????? let nuevaRed = armarRed 2 8 1 pesos 8 is the number of hidden layers... -----Original Message----- From: Hector Guilarte Date: Thu, 5 Nov 2009 06:27:25 To: Subject: Re: Memory Leak - Artificial Neural Network By the way, there is a line where I'm using unsafePerformIO to print the sum of the squared erros, feel free to delete it, I was checking convergence on smaller training sets before I realized the huge memory leak... Once again, Thanks in advance Hector Guilarte On Thu, Nov 5, 2009 at 6:24 AM, Hector Guilarte wrote: > Hello everyone, > > I just implemented an Artificial Neural Network but I'm having a serious > memory leak. I was very careful of using tail recursion all over my code, > but for some reason (a.k.a lazyness) my program is misusing incredible > ammounts of RAM. I read the whole chapter 25 of Real World Haskell trying to > find a solution with no luck. Maybe somebody can take a look at the code to > help me out with this problem, I would really appreciate it. > > Thanks A LOT in advance, > > Hector Guilarte > > Ps: The file is also attached > > Ps2: The code is written in Spanglish, sorry for that, I'm working on that > bad habbit... > > module Main where > > import Control.Monad > import System.IO > import qualified Random > import System.IO.Unsafe > import System.Environment > import Data.List > > data ANN = ANN Layer Layer Layer -- ^ Red Neuronal de 3 capas > deriving (Eq, Show) > > type Layer = [Neuron] -- ^ Lista de Neuronas que conforman la capa > > data Neuron = Neuron [(Float,Float)] Float -- ^ Lista de (pesos,xs) y > umbral asociado > deriving (Eq, Show) > > neurona:: Neuron -> -- ^ [(Pesos,Xs)] y Umbral > Float > neurona (Neuron entrada umbral) = > let entradaTupla = unzip entrada > pesos = fst entradaTupla > xs = snd entradaTupla > suma = foldl' (+) (-umbral) (zipWith (*) xs pesos) > in sigmoidal suma > > neurona2:: [(Float,Float)] -> -- ^ [(Pesos,Xs)] > Float -> -- ^ Umbral > Float > neurona2 valores umbral = > let entradaTupla = unzip valores > pesos = fst entradaTupla > xs = snd entradaTupla > suma = foldl' (+) umbral (zipWith (*) xs pesos) > in sigmoidal suma > > -- ANN [] [Neuron [(4.7621,0.9993291),(4.7618,0.94501287)] 7.3061,Neuron > [(6.3917,0.9993291),(6.3917,0.94501287)] 2.8441] [Neuron > [(-10.3788,0.9993291),(9.7691,0.94501287)] 4.5589] > > sigmoidal:: Float -> Float > sigmoidal x = 1 / (1 + (exp (-x))) > > main:: IO() > main = do > -- nombreArchivo <- getArgs > -- archivo <- readFile (head nombreArchivo) > pesos <- pesosIniciales 10000 > randomXs <- generarRandomXs 5000 > randomYs <- generarRandomYs 5000 > let conjunto = generar 200 0 0 randomXs randomYs [] > --print conjunto > -- let lista = parsearString archivo [[]] > -- let splitted = split lista [] > let (a,b,c) = (unzip3 (take 200 conjunto)) > --let (a,b,c) = ([0,1,0,1],[0,0,1,1],[0,1,1,0]) > let ejemplos = zipWith (ajustarEjemplos) a b > -- print ejemplos > let nuevaRed = armarRed 2 8 1 pesos > let entrenada = train nuevaRed ejemplos c > let redInicializada = map (iniciarXsRed entrenada) ejemplos > let resultados = map resultadoRed1Output (map evaluarRed > redInicializada) > print nuevaRed > print entrenada > print resultados > return () > > ajustarEjemplos:: Float -> Float -> [Float] > ajustarEjemplos a b = [a,b] > > train:: ANN -> [[Float]] -> [Float] -> ANN > train red ejemplosTodos esperadosTodos = > let entrenado = entrenamiento red ejemplosTodos esperadosTodos [] 200 > squaredErrors = snd entrenado > in if squaredErrors < 3 then fst entrenado > else train (fst entrenado) ejemplosTodos esperadosTodos > > -- ENTRENAMIENTO > > entrenamiento:: ANN -> [[Float]] -> [Float] -> [Float] -> Int -> > (ANN,Float) > entrenamiento red _ _ accum 0 = > let squaredErrors = foldl' (+) 0 (map (**2) accum) > in (red,squaredErrors) > entrenamiento red ejemplos esperados accum epoch = > let redInicializada = iniciarXsRed red (head ejemplos) > redEvaluada = evaluarRed redInicializada > redAjustada = ajustarPesos redEvaluada (head esperados) > error = (head esperados) - (resultadoRed1Output redAjustada) > in entrenamiento redAjustada (tail ejemplos) (tail esperados) (accum ++ > [error]) (epoch-1) > > resultadoRed1Output:: ANN -> Float > resultadoRed1Output (ANN _ _ [(Neuron ((_,xs):_) _)]) = xs > > iniciarXsRed:: ANN -> [Float] -> ANN > iniciarXsRed (ANN inputLayer hiddenLayer outputLayer) valores = > let inputNueva = zipWith ajustarXsInput inputLayer valores > in (ANN inputNueva hiddenLayer outputLayer) > > ajustarXsInput:: Neuron -> Float -> Neuron > ajustarXsInput (Neuron listaNeurona threshold) xsInput = > let listaNueva = map (ajustarXs xsInput) listaNeurona > in (Neuron listaNueva threshold) > -- FIN ENTRENAMIENTO > > pesosIniciales :: Int -> IO [Float] > pesosIniciales n = do > (replicateM n (Random.getStdRandom intervalo)) > where > intervalo = Random.randomR (-0.5,0.5) > > parsearString:: String -> [String] -> [String] > parsearString [] lista = (tail lista) > parsearString (x:xs) lista = if x == '\n' then parsearString xs ([]:lista) > else parsearString xs (((head lista) ++ > [x]):(tail lista)) > > split:: [String] -> [(Float,Float,Float)] -> [(Float,Float,Float)] > split [] accum = accum > split (x:xs) accum = > let first = readNum x "" > fstNum = read $ fst first > second = readNum (snd first) "" > sndNum = read $ fst second > third = readNum (snd second) "" > thrdNum = if (head $ fst third) == 'A' then 0 > else 1 > in split xs ([(fstNum,sndNum,thrdNum)]++accum) > > readNum:: String -> String -> (String,String) > readNum [] num = ([(head num)],num) > readNum (x:xs) num = if x == ' ' then (num,xs) > else (if x == '\n' then (num,xs) > else readNum xs (num ++ [x]) > ) > > generar:: Int -> Int -> Int -> [Float] -> [Float] -> [(Float,Float,Float)] > -> [(Float,Float,Float)] > generar total dentro fuera randomXs randomYs accum > | total == dentro + fuera = accum > | dentro == total `div` 2 = > let x = head randomXs > y = head randomYs > isDentro = ((x-15)**2) + ((y-6)**2) <= 9 > in if isDentro then generar total dentro fuera (tail randomXs) > (tail randomYs) accum > else generar total dentro (fuera+1) (tail randomXs) (tail > randomYs) (accum ++ [(x,y,0)]) > | fuera == total `div` 2 = > let x = head randomXs > y = head randomYs > isDentro = ((x-15)**2) + ((y-6)**2) <= 9 > in if isDentro then generar total (dentro+1) fuera (tail randomXs) > (tail randomYs) (accum ++ [(x,y,1)]) > else generar total dentro fuera (tail randomXs) (tail > randomYs) accum > | otherwise = > let x = head randomXs > y = head randomYs > isDentro = ((x-15)**2) + ((y-6)**2) <= 9 > in if isDentro then generar total (dentro+1) fuera (tail randomXs) > (tail randomYs) (accum ++ [(x,y,1)]) > else generar total dentro (fuera+1) (tail randomXs) (tail > randomYs) (accum ++ [(x,y,0)]) > > generarRandomXs :: Int -> IO [Float] > generarRandomXs n = do > (replicateM n (Random.getStdRandom intervalo)) > where > intervalo = Random.randomR (0.0,20.0) > > generarRandomYs :: Int -> IO [Float] > generarRandomYs n = do > (replicateM n (Random.getStdRandom intervalo)) > where > intervalo = Random.randomR (0.0,12.0) > > -- ARMAR RED > armarRed:: Int -> Int -> Int -> [Float] -> ANN > armarRed numNeuronasInput numNeuronasHidden numNeuronasOutput randoms = > let layerInput = armarLayerInput numNeuronasInput numNeuronasHidden > randoms [] > layerHidden = armarLayerHidden numNeuronasHidden numNeuronasOutput > (snd layerInput) [] > layerOutput = armarLayerOutput numNeuronasOutput (snd layerHidden) > [] > in (ANN (fst layerInput) (fst layerHidden) layerOutput) > > armarLayerInput:: Int -> Int -> [Float] -> Layer -> (Layer,[Float]) > armarLayerInput 0 _ randoms accum = (accum,randoms) > armarLayerInput numNeuronasInput numNeuronasHidden randoms accum = > let listaNeurona = armarListaNeuronasInput numNeuronasHidden randoms [] > newRandoms = snd listaNeurona > neurona = [(Neuron (fst listaNeurona) 0)] > in armarLayerInput (numNeuronasInput-1) numNeuronasHidden newRandoms > (accum ++ neurona) > > armarLayerHidden:: Int-> Int -> [Float] -> Layer -> (Layer,[Float]) > armarLayerHidden 0 _ randoms accum = (accum,randoms) > armarLayerHidden numNeuronasHidden numNeuronasOutput randoms accum = > let listaNeurona = armarListaNeuronasHidden numNeuronasOutput randoms > [] > neurona = [(Neuron (fst listaNeurona) (head $ snd listaNeurona))] > in armarLayerHidden (numNeuronasHidden-1) numNeuronasOutput (tail $ snd > listaNeurona) (accum ++ neurona) > > armarListaNeuronasHidden:: Int -> [Float] -> [(Float,Float)] -> > ([(Float,Float)],[Float]) > armarListaNeuronasHidden 0 randoms accum = (accum,randoms) > armarListaNeuronasHidden numElems randoms accum = > let pesosYxs = [((head randoms),(head $ tail randoms))] > in armarListaNeuronasHidden (numElems-1) (tail $ tail randoms) (accum > ++ pesosYxs) > > armarListaNeuronasInput:: Int -> [Float] -> [(Float,Float)] -> > ([(Float,Float)],[Float]) > armarListaNeuronasInput 0 randoms accum = (accum,randoms) > armarListaNeuronasInput numElems randoms accum = > let pesosYxs = [((head randoms),0)] > in armarListaNeuronasInput (numElems-1) (tail randoms) (accum ++ > pesosYxs) > > armarLayerOutput:: Int -> [Float] -> Layer -> Layer > armarLayerOutput 0 _ accum = accum > armarLayerOutput numNeuronasHidden randoms accum = > let neurona = [(Neuron [(0,(head randoms))] (head $ tail randoms))] > in armarLayerOutput (numNeuronasHidden-1) (tail $ tail randoms) (accum > ++ neurona) > > -- FIN ARMAR RED > > -- EVALUAR RED > > evaluarRed:: ANN -> ANN > evaluarRed (ANN inputLayer hiddenLayer outputLayer) = > let newHidden = ajustarLayer inputLayer hiddenLayer [] 0 > newOutput = ajustarLayer newHidden outputLayer [] 0 > in (ANN inputLayer newHidden newOutput) > > ajustarLayer:: Layer -> Layer -> Layer -> Int -> Layer > ajustarLayer _ [] accum numNeurona = accum > ajustarLayer leftLayer ((Neuron listaNeurona threshold):rightLayer) accum > numNeurona = > let valorLayer = evaluarLayer leftLayer threshold numNeurona > listaNeuronaNew = map (ajustarXs valorLayer) listaNeurona > in ajustarLayer leftLayer rightLayer (accum ++ [(Neuron listaNeuronaNew > threshold)]) (numNeurona+1) > > ajustarXs:: Float -> (Float,Float) -> (Float,Float) > ajustarXs xs (peso,_) = (peso,xs) > > evaluarLayer:: Layer -> Float -> Int -> Float > evaluarLayer layer threshold numNeurona = > let listaTuplas = extraerTuplaLayer layer numNeurona [] > valor = neurona2 listaTuplas threshold > in valor > > extraerTuplaLayer:: Layer -> Int -> [(Float,Float)] -> [(Float,Float)] > extraerTuplaLayer [] _ accum = accum > extraerTuplaLayer ((Neuron tupla _):resto) numNeurona accum = > extraerTuplaLayer resto numNeurona (accum ++ [(tupla !! numNeurona)]) > > -- FIN EVALUAR RED > > -- AJUSTAR RED > > ajustarPesos:: ANN -> Float -> ANN > ajustarPesos salida@(ANN inputLayer hiddenLayer outputLayer) esperado = > let outputNuevo = map (ajustarPesoOutput esperado) outputLayer > gradientes = snd $ unzip outputNuevo > hiddenNuevo = map (ajustarPesoHidden gradientes) hiddenLayer > gradientes2 = snd $ unzip hiddenNuevo > inputNuevo = map (ajustarPesoInput gradientes2) inputLayer > in (ANN inputNuevo (fst $ unzip hiddenNuevo) (fst $ unzip outputNuevo)) > > ajustarPesoOutput:: Float -> Neuron -> (Neuron,Float) > ajustarPesoOutput esperado (Neuron [(peso,obtenido)] threshold) = > let error = esperado-obtenido > gradiente = obtenido*(1-obtenido)*error > deltaTheta = tasaAprendizaje*(-1)*gradiente > thresholdNuevo = threshold + deltaTheta > in ((Neuron [(peso,obtenido)] thresholdNuevo),gradiente) > > ajustarPesoHidden:: [Float] -> Neuron -> (Neuron,Float) > ajustarPesoHidden gradientes (Neuron listaNeurona threshold) = > let (pesosViejos,xsViejos) = unzip listaNeurona > pesosAjustados = zipWith ajustarPesosHidden listaNeurona gradientes > sumatoriaGradientes = foldl' (+) 0 (zipWith (*) gradientes > pesosViejos) > gradiente = (head xsViejos)*(1-(head xsViejos))*sumatoriaGradientes > thresholdNuevo = tasaAprendizaje*(-1)*gradiente > in ((Neuron pesosAjustados thresholdNuevo),gradiente) > > ajustarPesoInput:: [Float] -> Neuron -> Neuron > ajustarPesoInput gradientes (Neuron listaNeurona threshold) = > let (pesosViejos,xsViejos) = unzip listaNeurona > pesosAjustados = zipWith (+) pesosViejos (map (*tasaAprendizaje) > (zipWith (*) gradientes xsViejos)) > listaNeuronaNueva = zip pesosAjustados xsViejos > in (Neuron listaNeuronaNueva threshold) > > > ajustarPesosHidden:: (Float,Float) -> Float -> (Float,Float) > ajustarPesosHidden (pesoViejo,xs) gradiente = > let deltaW = tasaAprendizaje*xs*gradiente > pesoNuevo = pesoViejo + deltaW > in (pesoNuevo,xs) > > -- FIN AJUSTAR RED > > tasaAprendizaje = 0.1 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091105/61011bfd/attachment.html From lrpalmer at gmail.com Thu Nov 5 06:24:44 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Nov 5 06:00:49 2009 Subject: [Haskell-cafe] Memory Leak - Artificial Neural Network In-Reply-To: <69630b260911050254y1c1330f8t56ead9be5fda0534@mail.gmail.com> References: <69630b260911050254y1c1330f8t56ead9be5fda0534@mail.gmail.com> Message-ID: <7ca3f0160911050324s65b601f1g4b3cf53bc67bb486@mail.gmail.com> On Thu, Nov 5, 2009 at 3:54 AM, Hector Guilarte wrote: > entrenamiento:: ANN -> [[Float]] -> [Float] -> [Float] -> Int -> (ANN,Float) > entrenamiento red _ _ accum 0 = > ??? let squaredErrors = foldl' (+) 0 (map (**2) accum) > ??? in (red,squaredErrors) > entrenamiento red ejemplos esperados accum epoch = > ??? let redInicializada = iniciarXsRed red (head ejemplos) > ??????? redEvaluada = evaluarRed redInicializada > ??????? redAjustada = ajustarPesos redEvaluada (head esperados) > ??????? error = (head esperados) - (resultadoRed1Output redAjustada) > ??? in entrenamiento redAjustada (tail ejemplos) (tail esperados) (accum ++ > [error]) (epoch-1) Well, I don't speak spanish (portuguese?), which makes this especially hard to read. But just from your introductory paragraph, maybe I can give you a few hints. They probably won't be able to fix your program, just treat them as things to keep in mind in the future. When I write in Haskell, my functions are usually *not* tail recursive. Tail recursion is good when you are reducing to a flat, strict domain (Int, Bool, ...), but when you are building up inductive, lazy structures, the relevant term is *corecursion* (IIRC), which is a whole different thing. Take eg. a tail recursive map function on lists: map f = go [] where go accum [] = accum go accum (x:xs) = go (accum ++ [f x]) xs map f [1,2,3] will reduce like this before anything else: map f [1,2,3] go [] [1,2,3] go ([] ++ [1]) [2,3] go (([] ++ [1]) ++ [2]) [3] go ((([] ++ [1]) ++ [2]) ++ [3]) [] (([] ++ [1]) ++ [2]) ++ [3] If the tail recursion has saved any stack space, it has paid for it in heap space. (Additionally, the way ++ is used here and in the code I quoted causes quadratic time behavior, becuase ++ is linear in the length of its left argument). The corecursive way to write map is the canonical example: map f (x:xs) = f x : map f xs Notice how the recursive call to map is "under" the (:) constructor? The new structure goes on the outside of the recursive call, not passed as an argument. IOW, we can generate some of the output without looking at all of the input. And this has very good behavior: map f [1,2,3] f 1 : map f [2,3] -- and when you get around to evaluating the tail.... ... : f 2 : map f [3] -- ditto ... : f 3 : map f [] -- ditto ... : [] I used ...s to emphasize that we could have forgotten about of the head of the list by now, only processing its tail, so it can be garbage collected. map has constant space complexity, in some sense. The art of programming corecursively is one of the joys of Haskell, but if you are used to either imperative programming or strict functional programming (basically... any other language at all), it takes time to get the hang of. Luke From bulat.ziganshin at gmail.com Thu Nov 5 06:25:03 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Nov 5 06:02:14 2009 Subject: [Haskell-cafe] Re[2]: What's the deal with Clean? In-Reply-To: <9979e72e0911050259w13128032l88ac778fdd2a65e5@mail.gmail.com> References: <9979e72e0911050259w13128032l88ac778fdd2a65e5@mail.gmail.com> Message-ID: <1641856875.20091105142503@gmail.com> Hello John, Thursday, November 5, 2009, 1:59:14 PM, you wrote: > I hope you don't mind me asking this, but when you state that > "idiomatic haskell is much slower than idiomatic C", what do you mean > by "much slower"? 2 times? 3 times? 20 times? Order of magnitude? it depends on task, of course. with a number crunching code, it may be hundreds or even thousands, but this application area isn't typical for haskell, after all. for typical apps like text processing it may be dozens. when we are going into real life, use of FFI libraries and OS calls makes difference even smaller, so i think that practical difference is 3-10 times, in most cases > I'm not going to disagree with you, however it seems to me the gap is > closing. except for BS library, i don't see too much practical improvements. GHC by itself was made ~20% faster with pointer tagging > My opinion may be colored by having just examined Masayuki > Takagi's SPH code, which I considered very idiomatic Haskell and for > me performed equivalently to his C++ code with the changes I detailed > in an earlier email (none of which involved any substantial changes to > his code or style in my opinion). i don't know why his haskell code is so fast - it may be due to improvements in ghc about compiling tight loops, unoptimal C code, bounds placed by memory speed. well, i know one problem in his C compilation - he doesn't used -O3 -fexcess-precision and other funny optimization tricks there is difference in treating good and bad comparisons. when someone shows that haskell is much slower, there are lot of suggestions how to improve the code, add strictness, use other libs, apply tricky compiling options, even unroll loops by hand. when someone shows small gap between C and Haskell, noone checks that C code is optimized as much as possible. of course, it's mainly because many haskellers can't optimize C code. but this should lead to the conclusion "i'm incompetent in comparison" rather than "haskell is fast" > Best, > John >> From: Bulat Ziganshin >> >> i don't say that haskell is slow for real programs. i say that >> idiomatic haskell is much slower than idiomatic C and these papers >> demonstrates how much, for simple computation-intensive loops >> >> -- >> Best regards, >> ?Bulat ? ? ? ? ? ? ? ? ? ? ? ? ? ?mailto:Bulat.Ziganshin@gmail.com >> -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From z_axis at 163.com Thu Nov 5 06:39:50 2009 From: z_axis at 163.com (zaxis) Date: Thu Nov 5 06:15:55 2009 Subject: [Haskell-cafe] About Regex question Message-ID: <26211696.post@talk.nabble.com> import Text.Regex.Posix import Data.Char import Data.List guessKeys line = concat $ intersperse "-" (modifiers ++ [map toLower key]) where modifiers = map (!!1) (line =~ "(mod|shift|control)Mask") (_, _, _, [key]) = line =~ "xK_(\\w+)" :: (String, String, String, [String]) aaa line = map (!!1) (line =~ "(mod|shift|control)Mask") bbb line = line =~ "xK_(\\w+)" :: (String, String, String, [String]) In ghci >guessKeys "modF1" "*** Exception: Test.hs:8:10-85: Irrefutable pattern failed for pattern (_, _, _ , [key]) > aaa "modF1" :1:0: No instance for (Text.Regex.Base.RegexLike.RegexContext Regex [Char] [[a]]) arising from a use of `aaa' at :1:0-10 > bbb "modF1" ("modF1","","",[]) I just extract the functions from where clause of guessKeys. But why are there different running result ? Sincerely! ----- fac n = foldr (*) 1 [1..n] -- View this message in context: http://old.nabble.com/About-Regex-question-tp26211696p26211696.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From lykahb at gmail.com Thu Nov 5 06:46:57 2009 From: lykahb at gmail.com (Boris Lykah) Date: Thu Nov 5 06:23:01 2009 Subject: [Haskell-cafe] Code generated by pointfree does not compile Message-ID: <26211701.post@talk.nabble.com> Hi all! I was playing with pointfree tool from hackage and found that it produces wrong code for some functions which use list comprehension. Here are several examples: :main f x = concat [x:f x| x<-[0..x-1]] f = fix ((join .) . flip flip [] . ((:) .) . ap (:) . (`ap` (enumFromTo 0 . subtract 1)) . ((<-) .) . ((|) =<<)) This does not compile because (<-) and (|) are used as functions whereas they are not. :main map (+1) [x| x<-[0..x]] [x | x <- [0..x] + 1] This does not compile either because the result code tries to add one to list. Why does this happen? This looks like a bug. Thanks, Boris Lykah -- View this message in context: http://old.nabble.com/Code-generated-by-pointfree-does-not-compile-tp26211701p26211701.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From emax at chalmers.se Thu Nov 5 06:58:14 2009 From: emax at chalmers.se (Emil Axelsson) Date: Thu Nov 5 06:34:35 2009 Subject: [Haskell-cafe] ANNOUNCE: feldspar-compiler Message-ID: <4AF2BDD6.10902@chalmers.se> On behalf of my project colleagues at ELTE University, I'm happy to announce the release of feldspar-compiler: http://hackage.haskell.org/package/feldspar-compiler This package contains the C code back-end for the Feldspar EDSL, announced yesterday: http://hackage.haskell.org/package/feldspar-language For more information, see http://feldspar.sourceforge.net/ / Emil From shelby at coolpage.com Thu Nov 5 07:10:06 2009 From: shelby at coolpage.com (Shelby Moore) Date: Thu Nov 5 06:46:11 2009 Subject: [Haskell-cafe] Base classes can be _ELIMINATED_ with interfaces In-Reply-To: <4483.121.97.54.144.1257142003.squirrel@webmail4.pair.com> References: <4232.121.97.54.144.1257129548.squirrel@webmail4.pair.com> <4279.121.97.54.144.1257131565.squirrel@webmail4.pair.com> <4483.121.97.54.144.1257142003.squirrel@webmail4.pair.com> Message-ID: <4354.121.97.54.144.1257423006.squirrel@webmail12.pair.com> > Shelby Moore wrote: >> In Haskel, subtyping is done with Module... > > data is analogous to a public class members. Use Module to make some > implementation private: > > http://www.cs.auckland.ac.nz/references/haskell/haskell-intro-html/modules.html#sect9.2 > > Thus use type classes (interfaces) when consuming the public Module > interfaces in functions (i.e. only consume the exported Module interfaces > in the sense they implement a type class, never directly consume the > Module name space). A strong argument against hiding internal functionality of an ADT (against using Module), and favoring fully composable functional programming (i.e Haskell without Module) for GUIs: http://lambda-the-ultimate.org/node/3668#comment-51993 (concise and sweet) From jwlato at gmail.com Thu Nov 5 08:04:51 2009 From: jwlato at gmail.com (John Lato) Date: Thu Nov 5 07:40:57 2009 Subject: [Haskell-cafe] Re: Re[2]: What's the deal with Clean? In-Reply-To: <1641856875.20091105142503@gmail.com> References: <9979e72e0911050259w13128032l88ac778fdd2a65e5@mail.gmail.com> <1641856875.20091105142503@gmail.com> Message-ID: <9979e72e0911050504h2a826629g9f50f1a2ee4ca11b@mail.gmail.com> On Thu, Nov 5, 2009 at 11:25 AM, Bulat Ziganshin wrote: > Hello John, > > Thursday, November 5, 2009, 1:59:14 PM, you wrote: > >> I hope you don't mind me asking this, but when you state that >> "idiomatic haskell is much slower than idiomatic C", what do you mean >> by "much slower"? ?2 times? ?3 times? ?20 times? ?Order of magnitude? > > it depends on task, of course. with a number crunching code, it may be > hundreds or even thousands, but this application area isn't typical > for haskell, after all. for typical apps like text processing it may > be dozens. when we are going into real life, use of FFI libraries and > OS calls makes difference even smaller, so i think that practical > difference is 3-10 times, in most cases Ok, this is a reasonable starting point. > >> I'm not going to disagree with you, however it seems to me the gap is >> closing. > > except for BS library, i don't see too much practical improvements. > GHC by itself was made ~20% faster with pointer tagging > I'm really only interested in looking at data of comparisons here. >> My opinion may be colored by having just examined Masayuki >> Takagi's SPH code, which I considered very idiomatic Haskell and for >> me performed equivalently to his C++ code with the changes I detailed >> in an earlier email (none of which involved any substantial changes to >> his code or style in my opinion). > > i don't know why his haskell code is so fast - it may be due to > improvements in ghc about compiling tight loops, unoptimal C code, > bounds placed by memory speed. well, i know one problem in his C > compilation - he doesn't used -O3 -fexcess-precision and other funny > optimization tricks True enough. If I did so with ghc, it's only fair to give g++ the chance as well. Although when I tried it with -O3 -ffast-math, I didn't see any gross changes in runtime speed gained from -O2. There may be benefits, but it would take statistical analysis to determine their significance. Also, you may not believe it, but the results I posted were for the first unfolding thresholds I picked. Those could probably be tuned further as well. > > there is difference in treating good and bad comparisons. when someone > shows that haskell is much slower, there are lot of suggestions how to > improve the code, add strictness, use other libs, apply tricky > compiling options, even unroll loops by hand. when someone shows small > gap between C and Haskell, noone checks that C code is optimized as > much as possible. of course, it's mainly because many haskellers can't > optimize C code. but this should lead to the conclusion "i'm > incompetent in comparison" rather than "haskell is fast" > Re: most optimal C code I will agree that for most discussions on this list nobody checks that the C versions are as optimal as possible, however I would suggest it's for a different reason. Many C libraries and programs are already widely available in a highly-optimized form, often as a result of years of work. Programs like the shootout lead to a similar effect (that is, Haskellers don't bother checking that C is optimized because the C submitters will be doing that). When doing comparisons against code like that, I think it's fair to assume that the C versions are already, if not as fast as possible, within a close enough percentage to establish a fair benchmark. For this specific case, I would look at it slightly differently. The C++ version has a level of performance the author was satisfied with. It presumably isn't optimized to the hilt, but it's very readable. The Haskell version is similarly readable, however the author wasn't happy with the performance (I never saw anything as poor as originally reported, BTW) and asked how it could be improved. I made a few suggestions, as did you and others, none of which IMO make the code non-idiomatic Haskell, and none of which takes more than a few minutes to implement. Could the speed of the C++ version be improved? Probably so, but it wouldn't look as nice. This is probably true for the Haskell code too. Doing either one would likely take a significant amount of work. Neither one may be most optimal, but I would argue that the C++ and Haskell (with suggestions from this list incorporated) programs are basically equivalent in being idiomatic to the language and performance. You could say that both are essentially optimized to the same standard, which is good enough for the task at hand. Even without any changes, for me the starting difference was roughly 50%, which is under your threshold of 3x as "much slower". Most of that difference was made up with compiler flags, whereas I doubt that any flags you pass to g++ (on top of -O3) will yield anything close to a 40% improvement. Cheers, John From haskellmail at gmail.com Thu Nov 5 08:07:04 2009 From: haskellmail at gmail.com (kenny lu) Date: Thu Nov 5 07:43:12 2009 Subject: [Haskell-cafe] About Regex question In-Reply-To: <26211696.post@talk.nabble.com> References: <26211696.post@talk.nabble.com> Message-ID: <90bba1dc0911050507h6eb3fdadqdeec752e3478033b@mail.gmail.com> Hi, First of all In ghci > > >guessKeys "modF1" > "*** Exception: Test.hs:8:10-85: Irrefutable pattern failed for pattern (_, > _, _ > , [key]) > > Because, the pattern "xK_(\\w+)" does not match with your input "modF1", as you already tried in the bbb function. *Main> bbb "modF1" ("modF1","","",[]) Note that the 4th component is an empty list, which does not match with your specify in 2nd where clause (_, _, _, [key]) = line =~ "xK_(\\w+)" :: (String, String, String, [String]) > > aaa "modF1" > :1:0: > No instance for (Text.Regex.Base.RegexLike.RegexContext > Regex [Char] [[a]]) > arising from a use of `aaa' at :1:0-10 > > You need to give a type annotation to the function aaa so that the type class instance can be "resolved". Regards, Kenny -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091105/014adb59/attachment.html From hectorg87 at gmail.com Thu Nov 5 08:29:27 2009 From: hectorg87 at gmail.com (Hector Guilarte) Date: Thu Nov 5 08:05:41 2009 Subject: [Haskell-cafe] Memory Leak - Artificial Neural Network In-Reply-To: <7ca3f0160911050324s65b601f1g4b3cf53bc67bb486@mail.gmail.com> References: <69630b260911050254y1c1330f8t56ead9be5fda0534@mail.gmail.com><7ca3f0160911050324s65b601f1g4b3cf53bc67bb486@mail.gmail.com> Message-ID: <1591563045-1257427771-cardhu_decombobulator_blackberry.rim.net-195397140-@bda078.bisx.prod.on.blackberry> Hi Luke, The code is mainly in Spanish with son parts in English... Thanks for the explanation, I got the idea very well, but now I got some questions about that. How does the Prelude functions for managing lists work? I mean, what does zip, unzip, foldl, foldr, map and zipWith do? Tail recursion or corecursion? I know, thanks to the profiling I did, that my main memory leak is in the function "entrenamiento" (which means training in Spanish), and I hardly believe it is in when I use of those functions I mentioned before, so if they are tail recursive and I change them to my own corecursive version, maybe I'll get rid of the problem, won't I? Thanks, Hector Guilarte -----Original Message----- From: Luke Palmer Date: Thu, 5 Nov 2009 04:24:44 To: Hector Guilarte Cc: Subject: Re: [Haskell-cafe] Memory Leak - Artificial Neural Network On Thu, Nov 5, 2009 at 3:54 AM, Hector Guilarte wrote: > entrenamiento:: ANN -> [[Float]] -> [Float] -> [Float] -> Int -> (ANN,Float) > entrenamiento red__ accum 0 = > ??? let squaredErrors = foldl' (+) 0 (map (**2) accum) > ??? in (red,squaredErrors) > entrenamiento red ejemplos esperados accum epoch = > ??? let redInicializada = iniciarXsRed red (head ejemplos) > ??????? redEvaluada = evaluarRed redInicializada > ??????? redAjustada = ajustarPesos redEvaluada (head esperados) > ??????? error = (head esperados) - (resultadoRed1Output redAjustada) > ??? in entrenamiento redAjustada (tail ejemplos) (tail esperados) (accum ++ > [error]) (epoch-1) Well, I don't speak spanish (portuguese?), which makes this especially hard to read. But just from your introductory paragraph, maybe I can give you a few hints. They probably won't be able to fix your program, just treat them as things to keep in mind in the future. When I write in Haskell, my functions are usually *not* tail recursive. Tail recursion is good when you are reducing to a flat, strict domain (Int, Bool, ...), but when you are building up inductive, lazy structures, the relevant term is *corecursion* (IIRC), which is a whole different thing. Take eg. a tail recursive map function on lists: map f = go [] where go accum [] = accum go accum (x:xs) = go (accum ++ [f x]) xs map f [1,2,3] will reduce like this before anything else: map f [1,2,3] go [] [1,2,3] go ([] ++ [1]) [2,3] go (([] ++ [1]) ++ [2]) [3] go ((([] ++ [1]) ++ [2]) ++ [3]) [] (([] ++ [1]) ++ [2]) ++ [3] If the tail recursion has saved any stack space, it has paid for it in heap space. (Additionally, the way ++ is used here and in the code I quoted causes quadratic time behavior, becuase ++ is linear in the length of its left argument). The corecursive way to write map is the canonical example: map f (x:xs) = f x : map f xs Notice how the recursive call to map is "under" the (:) constructor? The new structure goes on the outside of the recursive call, not passed as an argument. IOW, we can generate some of the output without looking at all of the input. And this has very good behavior: map f [1,2,3] f 1 : map f [2,3] -- and when you get around to evaluating the tail.... ... : f 2 : map f [3] -- ditto ... : f 3 : map f [] -- ditto ... : [] I used ...s to emphasize that we could have forgotten about of the head of the list by now, only processing its tail, so it can be garbage collected. map has constant space complexity, in some sense. The art of programming corecursively is one of the joys of Haskell, but if you are used to either imperative programming or strict functional programming (basically... any other language at all), it takes time to get the hang of. Luke From agarcia at babel.ls.fi.upm.es Thu Nov 5 08:50:49 2009 From: agarcia at babel.ls.fi.upm.es (=?ISO-8859-1?Q?=C1lvaro_Garc=EDa_P=E9rez?=) Date: Thu Nov 5 08:27:01 2009 Subject: [Haskell-cafe] Strict Monad In-Reply-To: <2f9b2d30911042219lf9446e2qb0adabfdfa1213a9@mail.gmail.com> References: <2f9b2d30911042219lf9446e2qb0adabfdfa1213a9@mail.gmail.com> Message-ID: You're right. It must be "data" not "newtype". I first wrote it with "data", but then I consider using "newtype" instead, as the identity monad does, and the fact that the transformer worked right with "newtype" got me confused. After some tests I finally realised that whenever you use "newtype" in your underlying monad then the transformer gives something which is not a monad. The problem (I think) is as follows: If you write a transformer which turns your monads into strict ones, then it may give something which is not a monad for some particular strict monads. If you relax your trasnformer in order to always have a monad, then it won't be strict for some particular lazy monads. Is the same old problem lifted to the transformers world. Does this intuition make any sense? I'm always referring to using Haskell strict primitives, not CPS. Alvaro. El 5 de noviembre de 2009 06:19, Ryan Ingram escribi?: > 2009/11/4 ?lvaro Garc?a P?rez : > > Hi, > > > > I'm trying to characterise some strict monads to work with a particular > > lambda-calculus evaluator, as an alternative to CPS monad. > > > > In the thread "Stupid question #852: Strict monad" the implementation of > > some strict monads (and pseudo-monads, not meeting the identity laws) is > > discussed. It's clear form that thread that using pattern-matching in the > > (>>=) operation will force evaluation, then the Id monad defined with > > pattern-matching is strict (and it's indeed a monad): > > > >> newtype Id a = Id a > >> > >> instance Monad Id where > >> return = Id > >> (Id a) >>= f = f a > > > > But it's impossible to derive a monad transformer from it, because you > don't > > know the constructors of the monads you're transforming. I then tried to > use > > strict application ($!). My first attempt was > > > >> newtype Strict a = InSt { outSt :: a } > >> > >> instance Monad Strict where > >> return = InSt > >> m >>= f = (\x -> fDoes this make sense, or am I wrong intuition? x) > $! (outSt m) > > > > which is not a monad (doesn't meet the left identity law). > > > > (return undefined) >>= (\x -> const (return 1) x) > > =/= (return 1) > > > > Then I wondered if it was enough to force the evaluation of the whole > monad, > > instead of the value inside the monad, yielding the second attempt: > > > >> newtype Strict a = InSt { outSt :: a } > >> > >> instance Monad Strict where > >> return = InSt > >> m >>= f = (\x -> f (outSt x)) $! m > > > > I placed the outSt inside the anonymous function, leaving the monad on > the > > right of the ($!). This meets the identity laws and surprisingly (I was > > expecting a lazy behaviour) implements strict semantics (it behaves like > > CPS, which is strict as well). A transformer from this monad can be > easily > > written: > > This seems like it has the same problem to me: > > return undefined >>= const return 1 > = InSt undefined >>= const return 1 > = (\x -> (const return 1) (outSt x)) $! (InSt undefined) > = let y = InSt undefined in seq y ((\x -> (const return 1) (outSt x)) y) > = undefined -- since InSt is a newtype. > > You would get different behavior with > > data InStD a = InStD a > > which puts another element in the domain: > > InSt () contains > [_|_, InSt ()] only > > whereas InStD () contains > [_|_, InStD _|_, InStD ()] > > -- ryan > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091105/c2592eb2/attachment-0001.html From briand at aracnet.com Thu Nov 5 09:46:51 2009 From: briand at aracnet.com (brian) Date: Thu Nov 5 09:23:00 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <4c88418c0911050149q446b7f9eu53136811f962ed2e@mail.gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> <87zl71s5vn.fsf@malde.org> <4c88418c0911050149q446b7f9eu53136811f962ed2e@mail.gmail.com> Message-ID: On Nov 5, 2009, at 1:49 AM, David Virebayre wrote: > I think that's in a way what's Bulat is saying : for Haskell to > really compete with C in *his view*, if I understand it, the > compiler has to be able to take idiomatic Haskell code, and > translate it in idomatic C code or better. > > Or said another way, we have to be able to write things like SDL, > jpeg or mpeg processing in Haskell, instead of writing bindings to C > libraries, without losing on performance. > And this is confusing to those of us who are not compiler experts. Haskell knows when I have a list of Doubles, you know, because it's strongly typed. Then it proceeds to box them. Huh ? The laziness thing has many example od _reducing_ efficiency, but there seems to be a real lack of example where it helps. In fact it seems to _always_ hurt. People sure seem excited about it. Me, not so excited. I've asked this question before and the answer, apparently, is polymorphism. Maybe I'm oversimplifying :-) Maybe the folks at MLTON will add type classes to ML ;-) Brian From ketil at malde.org Thu Nov 5 09:57:54 2009 From: ketil at malde.org (Ketil Malde) Date: Thu Nov 5 09:33:57 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: (brian's message of "Thu, 5 Nov 2009 06:46:51 -0800") References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> <87zl71s5vn.fsf@malde.org> <4c88418c0911050149q446b7f9eu53136811f962ed2e@mail.gmail.com> Message-ID: <87ws2510jx.fsf@malde.org> brian writes: > Haskell knows when I have a list of Doubles, you know, because it's > strongly typed. Right - so you can do foo, bar :: [Double] foo = 1:2:3:foo bar = [1,2,3,undefined,4,5,6] > Then it proceeds to box them. Huh ? Otherwise, the above wouldn't work. For lists of known constants, they could be unboxed and packed into an array. But that means you'd have to have two different types of lists, and if you really want an unboxed array, why not use one explicitly? > The laziness thing has many example of _reducing_ efficiency, but > there seems to be a real lack of example where it helps. In fact it > seems to _always_ hurt. People sure seem excited about it. Me, not > so excited. Well - it allows me to easily process files larger than memory. Many of my programs tend to follow a pattern like (build operation based on command line switches etc) writeFile of =<< map operation . readFile if Lazy bytestrings is my current favorite, since it reads bytes in an efficient, packed format, presents a list-like interface, and is chunkwise lazy, so streaming can be done in constant time. The "build operation" part often ends up a bit gross, but I have a plan for that which I hope to come back to later on. > I've asked this question before and the answer, apparently, is > polymorphism. Really? -k -- If I haven't seen further, it is by standing in the footprints of giants From bulat.ziganshin at gmail.com Thu Nov 5 09:58:03 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Nov 5 09:34:22 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> <87zl71s5vn.fsf@malde.org> <4c88418c0911050149q446b7f9eu53136811f962ed2e@mail.gmail.com> Message-ID: <1735470976.20091105175803@gmail.com> Hello brian, Thursday, November 5, 2009, 5:46:51 PM, you wrote: > The laziness thing has many example od _reducing_ efficiency, but > there seems to be a real lack of example > where it helps. main = interact id -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From sfvisser at cs.uu.nl Thu Nov 5 10:09:01 2009 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Thu Nov 5 09:45:08 2009 Subject: [Haskell-cafe] proposal: point free case expressions Message-ID: Hello all, Wouldn't it be nice if we could write point free case statements? I regularly find myself writing down something like this: > myFunc = anotherFunc $ \x -> case x of > Left err -> print err > Right msg -> putStrLn msg We could really use a case statement in which we skip the scrutinee and make `(case of {})' be syntactic sugar for `(\x -> case x of {})'. So we could write: > myFunc = anotherFunc $ case of > Left err -> print err > Right msg -> putStrLn msg A minor syntactical addition, a big win! Cheers, -- Sebastiaan Visser From noteed at gmail.com Thu Nov 5 10:15:41 2009 From: noteed at gmail.com (minh thu) Date: Thu Nov 5 09:52:08 2009 Subject: [Haskell-cafe] proposal: point free case expressions In-Reply-To: References: Message-ID: <40a414c20911050715je3b4f9cjcbe9dbf06b175bab@mail.gmail.com> 2009/11/5 Sebastiaan Visser : > Hello all, > > Wouldn't it be nice if we could write point free case statements? > > I regularly find myself writing down something like this: > >> myFunc = anotherFunc $ \x -> case x of >> Left err -> print err >> Right msg -> putStrLn msg > > We could really use a case statement in which we skip the scrutinee and make > `(case of {})' be syntactic sugar for `(\x -> case x of {})'. > > So we could write: > >> myFunc = anotherFunc $ case of >> Left err -> print err >> Right msg -> putStrLn msg > > A minor syntactical addition, a big win! Hi, In this particular case, myFunc = anotherFun (either print putStrLn) seems fine... So, unless there are too many variants in your scrutinee, writing a function such as 'either' would be a win too. Cheers, Thu From doaitse at swierstra.net Thu Nov 5 10:19:49 2009 From: doaitse at swierstra.net (S. Doaitse Swierstra) Date: Thu Nov 5 09:55:57 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> Message-ID: <1BFBEDAF-236D-4645-A0C2-8A7AB83FD213@swierstra.net> One of this differences between Haskell and Clean I did not see mentioned in this discussion is that Clean does not allow so-called partial parametrisation. I.e. all function calls have to be fully saturated. Although the GHC can sometimes (often) find out that a call is saturated, this becomes more complicated if higher-order functions are involved. As a consequence extra tests have to be performed at each call, which partially explains the speed difference. I have no idea how much difference it would make if such tests could completely be avoided in Haskell implementations. We hope to to be able to say something more about this difference in the future, based on the global (GRIN-based) analysis done in the Utrecht Haskell Compiler. Doaitse On 3 nov 2009, at 21:30, Deniz Dogan wrote: > Recently there has been a lot of discussion on this list about the > programming language Clean and converting Clean programs to Haskell. > Reading the Wikipedia article on the language, I can't really see any > major difference between that and Haskell, except for the monads vs. > uniqueness types. > > So what's the deal with Clean? Why is it preferable to Haskell? Why > is it not? > > -- > Deniz Dogan > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ekmett at gmail.com Thu Nov 5 10:22:23 2009 From: ekmett at gmail.com (Edward Kmett) Date: Thu Nov 5 09:58:31 2009 Subject: [Haskell-cafe] proposal: point free case expressions In-Reply-To: References: Message-ID: <7fb8f82f0911050722x75fdf422je80b76ad05ef368f@mail.gmail.com> I seem to recall this proposal being included on the Haskell' proposals. Ah, here it is: http://hackage.haskell.org/trac/haskell-prime/ticket/41 -Edward Kmett On Thu, Nov 5, 2009 at 10:09 AM, Sebastiaan Visser wrote: > Hello all, > > Wouldn't it be nice if we could write point free case statements? > > I regularly find myself writing down something like this: > > > myFunc = anotherFunc $ \x -> case x of > > Left err -> print err > > Right msg -> putStrLn msg > > We could really use a case statement in which we skip the scrutinee and > make `(case of {})' be syntactic sugar for `(\x -> case x of {})'. > > So we could write: > > > myFunc = anotherFunc $ case of > > Left err -> print err > > Right msg -> putStrLn msg > > A minor syntactical addition, a big win! > > Cheers, > > -- > Sebastiaan Visser > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091105/2dd0aaef/attachment.html From vandijk.roel at gmail.com Thu Nov 5 10:24:39 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Thu Nov 5 10:00:45 2009 Subject: [Haskell-cafe] proposal: point free case expressions In-Reply-To: References: Message-ID: On Thu, Nov 5, 2009 at 4:09 PM, Sebastiaan Visser wrote: > Wouldn't it be nice if we could write point free case statements? Yes, it would! I would definitively support such a proposal. From sfvisser at cs.uu.nl Thu Nov 5 10:25:42 2009 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Thu Nov 5 10:01:48 2009 Subject: [Haskell-cafe] proposal: point free case expressions In-Reply-To: <7fb8f82f0911050722x75fdf422je80b76ad05ef368f@mail.gmail.com> References: <7fb8f82f0911050722x75fdf422je80b76ad05ef368f@mail.gmail.com> Message-ID: <65912BF8-69C9-436A-B7E4-6A39301BA240@cs.uu.nl> Neat! Thanks for this link. On Nov 5, 2009, at 4:22 PM, Edward Kmett wrote: I seem to recall this proposal being included on the Haskell' proposals. Ah, here it is: > http://hackage.haskell.org/trac/haskell-prime/ticket/41 > > -Edward Kmett > > On Thu, Nov 5, 2009 at 10:09 AM, Sebastiaan Visser > wrote: > Hello all, > > Wouldn't it be nice if we could write point free case statements? > > I regularly find myself writing down something like this: > > > myFunc = anotherFunc $ \x -> case x of > > Left err -> print err > > Right msg -> putStrLn msg > > We could really use a case statement in which we skip the scrutinee > and make `(case of {})' be syntactic sugar for `(\x -> case x of {})'. > > So we could write: > > > myFunc = anotherFunc $ case of > > Left err -> print err > > Right msg -> putStrLn msg > > A minor syntactical addition, a big win! > > Cheers, > > -- > Sebastiaan Visser From duncan.coutts at googlemail.com Thu Nov 5 10:34:45 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Thu Nov 5 10:10:53 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <87ws2510jx.fsf@malde.org> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> <87zl71s5vn.fsf@malde.org> <4c88418c0911050149q446b7f9eu53136811f962ed2e@mail.gmail.com> <87ws2510jx.fsf@malde.org> Message-ID: <1257435285.25369.4289.camel@localhost> On Thu, 2009-11-05 at 15:57 +0100, Ketil Malde wrote: > Lazy bytestrings is my current favorite, since it reads bytes in an > efficient, packed format, presents a list-like interface, and is > chunkwise lazy, so streaming can be done in constant time. > > The "build operation" part often ends up a bit gross, but I have a plan > for that which I hope to come back to later on. Yes, they're not good for construction atm. The Builder monoid from the binary package is pretty good though. I've considered pulling it out and putting it in the bytestring package. Duncan From sjoerd at w3future.com Thu Nov 5 10:42:07 2009 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Thu Nov 5 10:18:15 2009 Subject: [Haskell-cafe] proposal: point free case expressions In-Reply-To: References: Message-ID: <00203022-6829-46A4-B723-7083A82ACB7B@w3future.com> Let's add point free pattern matching too then: > > myFunc = anotherFunc $ case of > > Left -> print > > Right -> putStrLn Sjoerd On Nov 5, 2009, at 4:09 PM, Sebastiaan Visser wrote: > Hello all, > > Wouldn't it be nice if we could write point free case statements? > > I regularly find myself writing down something like this: > > > myFunc = anotherFunc $ \x -> case x of > > Left err -> print err > > Right msg -> putStrLn msg > > We could really use a case statement in which we skip the scrutinee > and make `(case of {})' be syntactic sugar for `(\x -> case x of {})'. > > So we could write: > > > myFunc = anotherFunc $ case of > > Left err -> print err > > Right msg -> putStrLn msg > > A minor syntactical addition, a big win! > > Cheers, > > -- > Sebastiaan Visser > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Sjoerd Visscher sjoerd@w3future.com From sfvisser at cs.uu.nl Thu Nov 5 10:46:14 2009 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Thu Nov 5 10:22:24 2009 Subject: [Haskell-cafe] proposal: point free case expressions In-Reply-To: <00203022-6829-46A4-B723-7083A82ACB7B@w3future.com> References: <00203022-6829-46A4-B723-7083A82ACB7B@w3future.com> Message-ID: Yeah. I wanted to propose that as well, but I don't really know how well that scales to larger patterns. On Nov 5, 2009, at 4:42 PM, Sjoerd Visscher wrote: > Let's add point free pattern matching too then: > >> > myFunc = anotherFunc $ case of >> > Left -> print >> > Right -> putStrLn > > Sjoerd > > On Nov 5, 2009, at 4:09 PM, Sebastiaan Visser wrote: > >> Hello all, >> >> Wouldn't it be nice if we could write point free case statements? >> >> I regularly find myself writing down something like this: >> >> > myFunc = anotherFunc $ \x -> case x of >> > Left err -> print err >> > Right msg -> putStrLn msg >> >> We could really use a case statement in which we skip the scrutinee >> and make `(case of {})' be syntactic sugar for `(\x -> case x of >> {})'. >> >> So we could write: >> >> > myFunc = anotherFunc $ case of >> > Left err -> print err >> > Right msg -> putStrLn msg >> >> A minor syntactical addition, a big win! >> >> Cheers, >> >> -- >> Sebastiaan Visser From martijn at van.steenbergen.nl Thu Nov 5 10:54:36 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Nov 5 10:30:49 2009 Subject: [Haskell-cafe] proposal: point free case expressions In-Reply-To: References: Message-ID: <4AF2F53C.4060001@van.steenbergen.nl> Sebastiaan Visser wrote: > > myFunc = anotherFunc $ case of > > Left err -> print err > > Right msg -> putStrLn msg > > A minor syntactical addition, a big win! +1! Martijn. From ekirpichov at gmail.com Thu Nov 5 10:56:28 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Thu Nov 5 10:32:44 2009 Subject: [Haskell-cafe] proposal: point free case expressions In-Reply-To: <4AF2F53C.4060001@van.steenbergen.nl> References: <4AF2F53C.4060001@van.steenbergen.nl> Message-ID: <5e0214850911050756r5e36e12cqd1fa93e1cb72f143@mail.gmail.com> Me too. Looks cool! 2009/11/5 Martijn van Steenbergen : > Sebastiaan Visser wrote: >> >> ?> myFunc = anotherFunc $ case of >> ?> ? ? ? ? ? ? ? ? ? ? ? ? ?Left err -> print err >> ?> ? ? ? ? ? ? ? ? ? ? ? ? ?Right msg -> putStrLn msg >> >> A minor syntactical addition, a big win! > > +1! > > Martijn. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From monnier at iro.umontreal.ca Thu Nov 5 10:59:34 2009 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Thu Nov 5 10:36:05 2009 Subject: [Haskell-cafe] Re: proposal: point free case expressions References: Message-ID: > We could really use a case statement in which we skip the scrutinee and make > (case of {})' be syntactic sugar for `(\x -> case x of {})'. > So we could write: >> myFunc = anotherFunc $ case of >> Left err -> print err >> Right msg -> putStrLn msg > A minor syntactical addition, a big win! Since this "case" really defines a function, it seems like it would make more sense to allow defining anonymous functions by pattern matching. I.e. instead of "case of", I think it should use "?", "\", "fn", or ... Stefan From ekirpichov at gmail.com Thu Nov 5 11:02:17 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Thu Nov 5 10:38:22 2009 Subject: [Haskell-cafe] Re: proposal: point free case expressions In-Reply-To: References: Message-ID: <5e0214850911050802h3a6f9c60wdeb0527fb6dabe91@mail.gmail.com> How about \{Left err -> print err; Right msg -> putStrLn msg} ? 2009/11/5 Stefan Monnier : >> We could really use a case statement in which we skip the scrutinee and make >> (case of {})' be syntactic sugar for `(\x -> case x of {})'. > >> So we could write: > >>> myFunc = anotherFunc $ case of >>> Left err -> print err >>> Right msg -> putStrLn msg > >> A minor syntactical addition, a big win! > > Since this "case" really defines a function, it seems like it would make > more sense to allow defining anonymous functions by pattern matching. > I.e. instead of "case of", I think it should use "?", "\", "fn", or ... > > > ? ? ? ?Stefan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From ekirpichov at gmail.com Thu Nov 5 11:11:43 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Thu Nov 5 10:48:02 2009 Subject: [Haskell-cafe] Re: proposal: point free case expressions In-Reply-To: <5e0214850911050802h3a6f9c60wdeb0527fb6dabe91@mail.gmail.com> References: <5e0214850911050802h3a6f9c60wdeb0527fb6dabe91@mail.gmail.com> Message-ID: <5e0214850911050811i68c4e869hc9118cfceb49b692@mail.gmail.com> Addendum: This would also work nicely for matching on multiple arguments. elem = \(_ Leaf -> False; x (Fork a l r) | a==x -> True; | a>x -> elem x l; | otherwise -> elem x r) 2009/11/5 Eugene Kirpichov : > How about \{Left err -> print err; Right msg -> putStrLn msg} ? > > 2009/11/5 Stefan Monnier : >>> We could really use a case statement in which we skip the scrutinee and make >>> (case of {})' be syntactic sugar for `(\x -> case x of {})'. >> >>> So we could write: >> >>>> myFunc = anotherFunc $ case of >>>> Left err -> print err >>>> Right msg -> putStrLn msg >> >>> A minor syntactical addition, a big win! >> >> Since this "case" really defines a function, it seems like it would make >> more sense to allow defining anonymous functions by pattern matching. >> I.e. instead of "case of", I think it should use "?", "\", "fn", or ... >> >> >> ? ? ? ?Stefan >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru > -- Eugene Kirpichov Web IR developer, market.yandex.ru From dagit at codersbase.com Thu Nov 5 11:26:02 2009 From: dagit at codersbase.com (Jason Dagit) Date: Thu Nov 5 11:02:08 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> <87zl71s5vn.fsf@malde.org> <4c88418c0911050149q446b7f9eu53136811f962ed2e@mail.gmail.com> Message-ID: On Thu, Nov 5, 2009 at 6:46 AM, brian wrote: > > On Nov 5, 2009, at 1:49 AM, David Virebayre wrote: > > I think that's in a way what's Bulat is saying : for Haskell to really >> compete with C in *his view*, if I understand it, the compiler has to be >> able to take idiomatic Haskell code, and translate it in idomatic C code or >> better. >> >> Or said another way, we have to be able to write things like SDL, jpeg or >> mpeg processing in Haskell, instead of writing bindings to C libraries, >> without losing on performance. >> >> > And this is confusing to those of us who are not compiler experts. > > Haskell knows when I have a list of Doubles, you know, because it's > strongly typed. > > Then it proceeds to box them. Huh ? > Imagine a computation which will yield a Double if evaluated, but has not yet been evaluated. How do you store that in the list? > The laziness thing has many example od _reducing_ efficiency, but there > seems to be a real lack of example > where it helps. In fact it seems to _always_ hurt. People sure seem > excited about it. Me, not so excited. > > I've asked this question before and the answer, apparently, is > polymorphism. > I can't really think of how laziness and polymorphism are related. For me the big win with laziness is composability. Laziness allows us to express things in ways that are more natural. The prelude function 'take' is a perfect example. It allows you to use finite portions of infinite lists. You could then express an infinite series very naturally and then decouple from that the logic to process finite parts. The implication here is that laziness allows you to use data structures for control flow. This all works together to enable separation of concerns. Which is generally a very good thing if you want to reason about your source code. Laziness can also be thought of as a transformation on the time complexity of algorithms. Sure, the worst-case complexity still remains but often you can get a better average case by only computing as much as you need. I hope that helps, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091105/4ecc85df/attachment.html From drcygnus at gmail.com Thu Nov 5 12:26:04 2009 From: drcygnus at gmail.com (Jonathan Daugherty) Date: Thu Nov 5 12:02:15 2009 Subject: [Haskell-cafe] proposal: point free case expressions In-Reply-To: References: Message-ID: <20091105172603.GA16587@janrain.com> > So we could write: > > > myFunc = anotherFunc $ case of > > Left err -> print err > > Right msg -> putStrLn msg > > A minor syntactical addition, a big win! +1. While we're on the topic, what do people think of a related problem, case expressions over monadic values? I run into this often enough that it's a pain. I'd like to take result <- act1 case result of ... -> actN and drop the bind entirely to get case act1 of ... -> actN I know that there are many helper functions and constructs to make this sort of thing more readable, but sometimes a case expression is a good fit and the preceding bind just ends up being noisy. -- Jonathan Daugherty From sfvisser at cs.uu.nl Thu Nov 5 12:39:52 2009 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Thu Nov 5 12:15:59 2009 Subject: [Haskell-cafe] proposal: point free case expressions In-Reply-To: <20091105172603.GA16587@janrain.com> References: <20091105172603.GA16587@janrain.com> Message-ID: <248CFF61-4716-4786-BD98-2141ACE9BD88@cs.uu.nl> On Nov 5, 2009, at 6:26 PM, Jonathan Daugherty wrote: >> So we could write: >> >>> myFunc = anotherFunc $ case of >>> Left err -> print err >>> Right msg -> putStrLn msg >> >> A minor syntactical addition, a big win! > > +1. > > While we're on the topic, what do people think of a related problem, > case expressions over monadic values? I run into this often enough > that it's a pain. I'd like to take > > result <- act1 > case result of > ... -> actN > > and drop the bind entirely to get > > case act1 of > ... -> actN > > I know that there are many helper functions and constructs to make > this sort of thing more readable, but sometimes a case expression is a > good fit and the preceding bind just ends up being noisy. > > -- > Jonathan Daugherty I think your example is ambiguous in the sense that the case cannot know whether it should pattern match on the entire `m a' or just on the value `a' pulled out of the monad . Or maybe I don't entirely understand your example. With the proposed `case of' it would become something like this: act1 >>= case of ... -> actN Cheers, Sebastiaan From drcygnus at gmail.com Thu Nov 5 12:42:00 2009 From: drcygnus at gmail.com (Jonathan Daugherty) Date: Thu Nov 5 12:18:11 2009 Subject: [Haskell-cafe] proposal: point free case expressions In-Reply-To: <248CFF61-4716-4786-BD98-2141ACE9BD88@cs.uu.nl> References: <20091105172603.GA16587@janrain.com> <248CFF61-4716-4786-BD98-2141ACE9BD88@cs.uu.nl> Message-ID: <20091105174159.GB16587@janrain.com> > I think your example is ambiguous in the sense that the case cannot > know whether it should pattern match on the entire `m a' or just on > the value `a' pulled out of the monad . Or maybe I don't entirely > understand your example. You're right; it's ambiguous. :) > With the proposed `case of' it would become something like this: > > act1 >>= case of > ... -> actN That would work perfectly. -- Jonathan Daugherty From ekmett at gmail.com Thu Nov 5 13:09:10 2009 From: ekmett at gmail.com (Edward Kmett) Date: Thu Nov 5 12:45:14 2009 Subject: [Haskell-cafe] Re: proposal: point free case expressions In-Reply-To: References: Message-ID: <7fb8f82f0911051009p3609b60fje361843b891a9583@mail.gmail.com> On Thu, Nov 5, 2009 at 10:59 AM, Stefan Monnier wrote: > > We could really use a case statement in which we skip the scrutinee and > make > > (case of {})' be syntactic sugar for `(\x -> case x of {})'. > > > So we could write: > > >> myFunc = anotherFunc $ case of > >> Left err -> print err > >> Right msg -> putStrLn msg > > > A minor syntactical addition, a big win! > > Since this "case" really defines a function, it seems like it would make > more sense to allow defining anonymous functions by pattern matching. > I.e. instead of "case of", I think it should use "?", "\", "fn", or ... > The problem with all of those options is that they introduce a new keyword into the language and can potentially break existing code. Eugene's \{ } avoids that by using a different hole in the grammar, but at the expense of 'un-Haskelly' braces. That and I question how easy it would be to get to parse, because a common idiom seems to be to parse patterns as expressions before converting them to patterns to avoid certain other ambiguities in the grammar, so this requires a { } expression, which may introduce a lot more ambiguity and problems to the grammar than it would seem at first glance. -Edward Kmett -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091105/35eb9333/attachment.html From newsham at lava.net Thu Nov 5 13:20:20 2009 From: newsham at lava.net (Tim Newsham) Date: Thu Nov 5 12:56:28 2009 Subject: [Haskell-cafe] proposal: point free case expressions In-Reply-To: References: Message-ID: > Wouldn't it be nice if we could write point free case statements? Yes. Haskell should automatically define destructors for each data type you define in addition to defining constructors. > I regularly find myself writing down something like this: > >> myFunc = anotherFunc $ \x -> case x of >> Left err -> print err >> Right msg -> putStrLn msg When you define "data Either a b = Left a | Right b" it should define "Left", "Right" and "destruct_Either" (or whatever other name you want to give it). Of course "destruct_Either" is just "either" from the prelude, and you also get "maybe", but these shouldn't be prelude functions, they should be automatically derived. Then your points free version is just: myFunc = anotherFunc $ either print putStrLn In the meantime, the Data.Derive library http://community.haskell.org/~ndm/derive/ has a function for deriving these using TH: http://hackage.haskell.org/packages/archive/derive/latest/doc/html/Data-Derive-Fold.html This derives a non-recursive definition for recursive data types. Its also possible to derive a similar recursive definition for recursive data types. > Sebastiaan Visser Tim Newsham http://www.thenewsh.com/~newsham/ From jfredett at gmail.com Thu Nov 5 14:33:34 2009 From: jfredett at gmail.com (Joe Fredette) Date: Thu Nov 5 14:09:43 2009 Subject: [Haskell-cafe] Re: proposal: point free case expressions In-Reply-To: <7fb8f82f0911051009p3609b60fje361843b891a9583@mail.gmail.com> References: <7fb8f82f0911051009p3609b60fje361843b891a9583@mail.gmail.com> Message-ID: Don't these things generally get added as LANGUAGE pragmas though? If it's off by default then peoples code should be okay. Also, I'd prefer something like `cases` as the keyword, rather than `case of`, mostly for aesthetics, but also so that, upon visual inspection, I wouldn't wonder where the pattern went and potentially try to 'fix" the point-free case match. /Joe On Nov 5, 2009, at 1:09 PM, Edward Kmett wrote: > On Thu, Nov 5, 2009 at 10:59 AM, Stefan Monnier > wrote: > > We could really use a case statement in which we skip the > scrutinee and make > > (case of {})' be syntactic sugar for `(\x -> case x of {})'. > > > So we could write: > > >> myFunc = anotherFunc $ case of > >> Left err -> print err > >> Right msg -> putStrLn msg > > > A minor syntactical addition, a big win! > > Since this "case" really defines a function, it seems like it would > make > more sense to allow defining anonymous functions by pattern matching. > I.e. instead of "case of", I think it should use "?", "\", "fn", > or ... > > The problem with all of those options is that they introduce a new > keyword into the language and can potentially break existing code. > > Eugene's \{ } avoids that by using a different hole in the grammar, > but at the expense of 'un-Haskelly' braces. That and I question how > easy it would be to get to parse, because a common idiom seems to be > to parse patterns as expressions before converting them to patterns > to avoid certain other ambiguities in the grammar, so this requires > a { } expression, which may introduce a lot more ambiguity and > problems to the grammar than it would seem at first glance. > > -Edward Kmett > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From reiner.pope at gmail.com Thu Nov 5 15:24:10 2009 From: reiner.pope at gmail.com (Reiner Pope) Date: Thu Nov 5 15:00:35 2009 Subject: [Haskell-cafe] proposal: point free case expressions In-Reply-To: References: Message-ID: <4cf038ee0911051224l5f569ba2l66efd69733fc0a01@mail.gmail.com> 2009/11/5 Sebastiaan Visser : > Hello all, > > Wouldn't it be nice if we could write point free case statements? > > I regularly find myself writing down something like this: > >> myFunc = anotherFunc $ \x -> case x of >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Left err -> print err >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Right msg -> putStrLn msg > > We could really use a case statement in which we skip the scrutinee and make > `(case of {})' be syntactic sugar for `(\x -> case x of {})'. > > So we could write: > >> myFunc = anotherFunc $ case of >> ? ? ? ? ? ? ? ? ? ? ? ? ?Left err -> print err >> ? ? ? ? ? ? ? ? ? ? ? ? ?Right msg -> putStrLn msg > > A minor syntactical addition, a big win! > > Cheers, > > -- > Sebastiaan Visser > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > Morten Rhiger implemented "Type-safe pattern combinators" [1], which are essentially a library for pattern matching, entirely within Haskell98. As an example, he implemented "anonymous pattern-matching" with this library, which is similar to what you ask for. It would be certainly be possible to implement your proposal with his library. My library "first-class-patterns" [2] on Hackage essentially follows Morten Rhiger's approach, but makes the types more understandable. I implemented point free case expressions (the 'elim' function) and monadic pattern matches (the 'mmatch' function) in version 0.2.0, which I just uploaded. For instance, you could write > import Data.Pattern > > ---- anonymous matching > ex6 :: Show a => Either a String -> IO () > ex6 = elim $ > left var ->> print > <|> right var ->> putStrLn > > -- monadic matching > ex8 :: IO () > ex8 = mmatch getLine $ > cst "" ->> return () > <|> var ->> putStrLn . ("You said " ++) Cheers, Reiner [1] http://www.itu.dk/people/mir/typesafepatterns.pdf [2] http://hackage.haskell.org/package/first-class-patterns From nicolas.pouillard at gmail.com Thu Nov 5 15:44:00 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Thu Nov 5 15:20:06 2009 Subject: [Haskell-cafe] proposal: point free case expressions In-Reply-To: <4AF2F53C.4060001@van.steenbergen.nl> References: <4AF2F53C.4060001@van.steenbergen.nl> Message-ID: <1257453832-sup-1763@peray> Excerpts from Martijn van Steenbergen's message of Thu Nov 05 16:54:36 +0100 2009: > Sebastiaan Visser wrote: > > > myFunc = anotherFunc $ case of > > > Left err -> print err > > > Right msg -> putStrLn msg > > > > A minor syntactical addition, a big win! > > +1! +1 -- Nicolas Pouillard http://nicolaspouillard.fr From donn at avvanta.com Thu Nov 5 15:51:54 2009 From: donn at avvanta.com (Donn Cave) Date: Thu Nov 5 15:27:59 2009 Subject: [Haskell-cafe] proposal: point free case expressions References: <4AF2F53C.4060001@van.steenbergen.nl><1257453832-sup-1763@peray> Message-ID: <20091105205154.EF79993C46@mail.avvanta.com> > +1 If we're counting increments, should add in previous instances of the same proposal - Andrew Pimlott Sep 2005 on haskell-cafe, at least. I agree with Stefan Monnier, might as well allow pattern alternatives in lambda expressions - essentially the same idea and allows multiple case parameters. Donn Cave, donn@avvanta.com From wasserman.louis at gmail.com Thu Nov 5 16:04:35 2009 From: wasserman.louis at gmail.com (Louis Wasserman) Date: Thu Nov 5 15:41:04 2009 Subject: [Haskell-cafe] Re: Fair diagonals In-Reply-To: <4AF1599D.5090302@van.steenbergen.nl> References: <4AF1599D.5090302@van.steenbergen.nl> Message-ID: I figured out an inductive approach as follows, which lets you derive stripeN from stripe(N-1). This could be TemplateHaskell'd if you have a bound on N; I'm still trying to figure out a type-magical alternative. Suppose stripe(N-1) :: x -> [b] -> [c] Then stripeN :: (a -> [b]) -> x -> [a] -> [[c]] stripeN f x [] = [] stripeN f x (a:as) = case stripe(N-1) x (f a) of [] -> stripeN f x as (b:bs) -> [b]:zipCons bs (stripeN f x as) and then diagN is obtained by applying concat an appropriate number of times. It's fair. The real-question is how to type-magically work it for arbitrarily many coordinates... Louis Wasserman wasserman.louis@gmail.com http://profiles.google.com/wasserman.louis On Wed, Nov 4, 2009 at 4:38 AM, Martijn van Steenbergen < martijn@van.steenbergen.nl> wrote: > Louis Wasserman wrote: > >> +1 on Control.Monad.Omega. In point of fact, your diagN function is >> simply >> >> diagN = runOmega . mapM Omega >> >> You'll find it an interesting exercise to grok the source of >> Control.Monad.Omega, obviously, but essentially, you're replacing concatMap >> with a fair (diagonal) traversal order version. >> > > Thanks for the replies! > > I've looked at Omega but it's not fair enough. The sums of the indices are > not non-decreasing: > > map sum $ runOmega . mapM each $ [[1..], [1..], [1..]] > [3,4,4,4,5,5,5,5,6,6,5,6,6,7,7,5,6,7,7,8,8,6,6,7,8,8,9,9,6,7,... > > Is there another way to use Omega that meets this (very important) > criterion or is Omega not the right tool here? > > Thanks, > > Martijn. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091105/33771970/attachment-0001.html From andrewcoppin at btinternet.com Thu Nov 5 16:34:57 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Nov 5 16:10:53 2009 Subject: [Haskell-cafe] Are all arrows functors? In-Reply-To: <1257254743-sup-8857@peray> References: <4AF025F6.2020200@kent.ac.uk> <1257254743-sup-8857@peray> Message-ID: <4AF34501.2010405@btinternet.com> Nicolas Pouillard wrote: > Excerpts from Neil Brown's message of Tue Nov 03 13:45:42 +0100 2009: > >> Hi, >> >> I was thinking about some of my code today, and I realised that where I >> have an arrow in my code, A b c, the type (A b) is also a functor. The >> definition is (see >> http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Arrow.html): >> >> fmap = (^<<) >> -- Or, in long form: >> fmap f x = arr f <<< x >> >> Out of curiosity, and since this is a typical haskell-cafe question, >> does this definition of fmap hold for all arrows? >> > > Yes, as shown by the 'WrappedArrow' newtype: > > http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Applicative.html#t%3AWrappedMonad > While I don't wish to suggest that "all arrows are functors" is false, I think the argument "yes, because this library says so" is not too strong. Let us not forget, according to *the libraries*, Double is in Enum - which, I think you'll agree, is just weird... From andrewcoppin at btinternet.com Thu Nov 5 16:52:20 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Nov 5 16:28:16 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> Message-ID: <4AF34914.3020108@btinternet.com> Martin DeMello wrote: > On Wed, Nov 4, 2009 at 10:34 AM, Richard O'Keefe wrote: > >> (4) It comes with its own IDE. I don't think it can do anything much that >> Haskell tools can't do, but if you don't like looking for things, it's >> a help. >> > > And a well-integrated GUI toolkit. If it weren't for the Windows bias > I'd have definitely taken the time to learn the language. > I'm dissapointed that Haskell doesn't have *more* of a Windows bias. It _is_ the platform used by 90% of the desktop computers, after all. (As unfortunate as that undeniably is...) In particular, I really wish we could make is so that stuff from Hackage actually compiles on Windows. (Disclaimer: Stuff written in Haskell compiles just fine. It's FFI bindings that unanimously refuse to compile.) It's also somewhat irritating that the I/O libraries have a few quirks apparently related to mingw32. But hey, that one at least should be fixable... From ekirpichov at gmail.com Thu Nov 5 16:53:04 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Thu Nov 5 16:29:08 2009 Subject: [Haskell-cafe] Re: proposal: point free case expressions In-Reply-To: <7fb8f82f0911051009p3609b60fje361843b891a9583@mail.gmail.com> References: <7fb8f82f0911051009p3609b60fje361843b891a9583@mail.gmail.com> Message-ID: <5e0214850911051353m7609a2ebj23bc8f084d5cac3b@mail.gmail.com> 2009/11/5 Edward Kmett : > On Thu, Nov 5, 2009 at 10:59 AM, Stefan Monnier > wrote: >> >> > We could really use a case statement in which we skip the scrutinee and >> > make >> > (case of {})' be syntactic sugar for `(\x -> case x of {})'. >> >> > So we could write: >> >> >> myFunc = anotherFunc $ case of >> >> Left err -> print err >> >> Right msg -> putStrLn msg >> >> > A minor syntactical addition, a big win! >> >> Since this "case" really defines a function, it seems like it would make >> more sense to allow defining anonymous functions by pattern matching. >> I.e. instead of "case of", I think it should use "?", "\", "fn", or ... > > The problem with all of those options is that they introduce a new keyword > into the language and can potentially break existing code. > > Eugene's \{ } avoids that by using a different hole in the grammar, but at > the expense of 'un-Haskelly' braces. That and I question how easy it would > be to get to parse, because a common idiom seems to be to parse patterns as > expressions before converting them to patterns to avoid certain other > ambiguities in the grammar, so this requires a { } expression, which may > introduce a lot more ambiguity and problems to the grammar than it would > seem at first glance. Hey, the braces are not that un-Haskelly. After all, you already can write "case x of {Left err -> ...; Right res -> ...}" - that's exactly why I suggested this notation. So, I am just suggesting to replace "case of" with "\" and that's all. > > -Edward Kmett > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Eugene Kirpichov Web IR developer, market.yandex.ru From lemming at henning-thielemann.de Thu Nov 5 16:54:51 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Nov 5 16:30:57 2009 Subject: [Haskell-cafe] Storable Vector as a Storable record? In-Reply-To: <60d0a32f0911040150l2b00e94fu53f1be2046d0e70c@mail.gmail.com> References: <60d0a32f0911040150l2b00e94fu53f1be2046d0e70c@mail.gmail.com> Message-ID: > Hi, > Is it possible to somehow make a StorableVector of a StorableVector via store-record or > something? > If yes, could some one please provide me with some hint?? storable-record just assists with generating Storable instances. It helps using correct aligment and correct order of entries. It doesn't do any magic to the Storable class. > I need a very fast and efficient array of a large number of $ arrays of Ints. > And the storableVector seems to be extremely nice. Are the sub-arrays of the same size? If not, you might have a look into Data Parallel Haskell, that flattens arrays of arrays into one array and does the bookkeeping and optimizations for you. In other languages you might use an array of pointers to the sub-arrays, but I'm uncertain whether Ptrs are storable. From dave at zednenem.com Thu Nov 5 16:55:19 2009 From: dave at zednenem.com (David Menendez) Date: Thu Nov 5 16:31:22 2009 Subject: [Haskell-cafe] Are all arrows functors? In-Reply-To: <4AF34501.2010405@btinternet.com> References: <4AF025F6.2020200@kent.ac.uk> <1257254743-sup-8857@peray> <4AF34501.2010405@btinternet.com> Message-ID: <49a77b7a0911051355j6c369bfakb8edc6605ce6cc89@mail.gmail.com> On Thu, Nov 5, 2009 at 4:34 PM, Andrew Coppin wrote: > Nicolas Pouillard wrote: >> >> Excerpts from Neil Brown's message of Tue Nov 03 13:45:42 +0100 2009: >> >>> >>> Hi, >>> >>> I was thinking about some of my code today, and I realised that where I >>> have an arrow in my code, A b c, the type (A b) is also a functor. ?The >>> definition is (see >>> http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Arrow.html): >>> >>> fmap = (^<<) >>> -- Or, in long form: >>> fmap f x = arr f <<< x >>> >>> Out of curiosity, and since this is a typical haskell-cafe question, does >>> this definition of fmap hold for all arrows? >>> >> >> Yes, as shown by the 'WrappedArrow' newtype: >> >> >> http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Applicative.html#t%3AWrappedMonad >> > > While I don't wish to suggest that "all arrows are functors" is false, I > think the argument "yes, because this library says so" is not too strong. > Let us not forget, according to *the libraries*, Double is in Enum - which, > I think you'll agree, is just weird... It's fairly simple to prove the functor laws using the arrow laws. Among the nine laws for arrows are a >>> arr id = a a >>> arr f >>> arr g = a >>> arr (g . f) Using the definition fmap f a = a >>> arr f, it's pretty simple to prove the functor laws: fmap id = id fmap f . fmap g = fmap (f . g) -- Dave Menendez From mle+hs at mega-nerd.com Thu Nov 5 17:02:30 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Thu Nov 5 16:38:36 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <4AF34914.3020108@btinternet.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF34914.3020108@btinternet.com> Message-ID: <20091106090230.445a9182.mle+hs@mega-nerd.com> Andrew Coppin wrote: > I'm dissapointed that Haskell doesn't have *more* of a Windows bias. It > _is_ the platform used by 90% of the desktop computers, after all. (As > unfortunate as that undeniably is...) That is not true in my home and its not true where I work. In addition, saying "90% of all desktop computers" is misleading; instead we should be talking about the computers of software developers and there, the figure is almost certainly well below 90%. > In particular, I really wish we could make is so that stuff from Hackage > actually compiles on Windows. (Disclaimer: Stuff written in Haskell > compiles just fine. It's FFI bindings that unanimously refuse to > compile.) It's also somewhat irritating that the I/O libraries have a > few quirks apparently related to mingw32. But hey, that one at least > should be fixable... The problem here is that window is the odd one out. Stuff written for userspace Linux will usually compile with little more than minor alterations on OSX and all the other Unix-like systems. Making that same code build on windows can be a significant amount of work and that work should not be the responsibility of the people who write code on Linux and Mac. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From andrewcoppin at btinternet.com Thu Nov 5 17:11:50 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Nov 5 16:47:46 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <1257382324.5965.97.camel@idefix.localdomain> References: <1257382324.5965.97.camel@idefix.localdomain> Message-ID: <4AF34DA6.2010701@btinternet.com> Matus Tejiscak wrote: > zygohistomorphic prepromorphisms Please tell me this isn't a real technical term. o_O As for concrete suggestions... I've always thought we could do more to use static information about the program to aid runtime GC. It's no deep secret that destructive updates are essentially like a compile-time / coding-time GC operation. You determine before runtime that the old version of the data will never be needed again, and hence update it in-place. Making this kind of thing more automatic could be interesting theoretically and practically. The other thing is connectedness; a GC performs a sweep of a big chunk of memory to find live objects, but if you somehow knew from compile-time analysis something about what the runtime linking structure is going to be, you might be able to do something interesting. (OTOH, laziness and sharing probably spoils this.) From lemming at henning-thielemann.de Thu Nov 5 17:24:59 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Nov 5 17:01:30 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: control-monad-exception 0.5 with monadic call traces In-Reply-To: References: <4AF02F06.2030105@henning-thielemann.de> Message-ID: On Tue, 3 Nov 2009, Jose Iborra wrote: > On 03/11/2009, at 14:24, Henning Thielemann wrote: > >> Sure, this is a nice functionality. But isn't it about debugging, not >> exception handling? Internal Server Error means to me, the server has a >> bug, thus we want to know, how to reproduce it, thus the stack trace. >> For handling expected irregularites, what exceptions are, you would not >> need that, right? > > This is about error handling and reporting. Catching an exception does > not tell you where the exception comes from, in the same way that a > "head of empty list" error does not point at the source of the error. > You need a stack trace to know that. So the output above, generated by a > regular exception handler Thomas Hartman tphyahoo at gmail.com Tue Nov 3 08:59:50 EST 2009 > When using happstack, I find it really annoying to get a Prelude.head: > null list error (or similar) in my web browser window because somewhere, > some library used something unsafe -- and of course, since this is > haskell, no stack trace. > if c-m-e can offer benefits around this, I would be very interested in > adopting it. That's what I meant with my post: Programming errors (like "head []") are not handled by control-monad-exception. As far as I understand, control-monad-exception makes _exceptions_ explicit in the type signatures, not programming errors. Why and how would you make possible programming errors explicit in the type? But for exceptions (e.g. "file could not be found") a detailed stack trace is not of much use. It seems again to me, that mixing of (programming) errors and exceptions is going on, and I assumed that the purpose of control-monad-exception is to separate them in a better way. From andrewcoppin at btinternet.com Thu Nov 5 17:28:11 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Nov 5 17:04:08 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <20091106090230.445a9182.mle+hs@mega-nerd.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF34914.3020108@btinternet.com> <20091106090230.445a9182.mle+hs@mega-nerd.com> Message-ID: <4AF3517B.6030201@btinternet.com> Erik de Castro Lopo wrote: > Andrew Coppin wrote: > > >> I'm dissapointed that Haskell doesn't have *more* of a Windows bias. It >> _is_ the platform used by 90% of the desktop computers, after all. (As >> unfortunate as that undeniably is...) >> > > That is not true in my home and its not true where I work. > > In addition, saying "90% of all desktop computers" is misleading; > instead we should be talking about the computers of software developers > and there, the figure is almost certainly well below 90%. > Depends what you develop. I know of plenty of developers who use MS Visual Studio for everything, for example. You can pretend that Windows isn't popular and thus there's no need to support it, but to me that seems like a fairly unrealistic point of view. > The problem here is that window is the odd one out. > This, it seems, is why there are programs in this world that are designed for Windows but (sometimes) also run on Unix, and other programs which are designed for Unix but (sometimes) also run on Windows. I would like to add that GHC itself is really rather well-behaved under Windows. Many Unix programs simply get recompiled under Cygwin or something, resulting in a program that *runs* on Windows, but doesn't follow any Windows-related conventions and so forth. GHC actually behaves very well under Windows. And we have some quite nice library support for writing Haskell programs which compile unmodified under Windows and Linux. (E.g., filepath, ansi-terminal, etc.) I'm just saying, we could still do better... From deniz.a.m.dogan at gmail.com Thu Nov 5 17:28:48 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Thu Nov 5 17:05:13 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <20091106090230.445a9182.mle+hs@mega-nerd.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF34914.3020108@btinternet.com> <20091106090230.445a9182.mle+hs@mega-nerd.com> Message-ID: <7b501d5c0911051428p4d1effd1xc8c4b9fcae583614@mail.gmail.com> 2009/11/5 Erik de Castro Lopo : > Andrew Coppin wrote: > >> I'm dissapointed that Haskell doesn't have *more* of a Windows bias. It >> _is_ the platform used by 90% of the desktop computers, after all. (As >> unfortunate as that undeniably is...) > > That is not true in my home and its not true where I work. > > In addition, saying "90% of all desktop computers" is misleading; > instead we should be talking about the computers of software developers > and there, the figure is almost certainly well below 90%. > Why? After all, software is always (in one way or another) written for users, not other software developers. -- Deniz Dogan From daniel.is.fischer at web.de Thu Nov 5 17:30:20 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Nov 5 17:07:51 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <20091106090230.445a9182.mle+hs@mega-nerd.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF34914.3020108@btinternet.com> <20091106090230.445a9182.mle+hs@mega-nerd.com> Message-ID: <200911052330.20769.daniel.is.fischer@web.de> Am Donnerstag 05 November 2009 23:02:30 schrieb Erik de Castro Lopo: > Andrew Coppin wrote: > > I'm dissapointed that Haskell doesn't have *more* of a Windows bias. It > > _is_ the platform used by 90% of the desktop computers, after all. (As > > unfortunate as that undeniably is...) > > That is not true in my home and its not true where I work. Neither is it true in the group of people I know. However, the number of computers in that group which had Windows installed when they were bought may be close 90% - it's close to impossible to buy a completely assembled, ready to go computer without here - which is easily remedied by inserting an openSuse or Ubuntu disk as soon as it's connected to power :) > > In addition, saying "90% of all desktop computers" is misleading; > instead we should be talking about the computers of software developers > and there, the figure is almost certainly well below 90%. > > > In particular, I really wish we could make is so that stuff from Hackage > > actually compiles on Windows. (Disclaimer: Stuff written in Haskell > > compiles just fine. It's FFI bindings that unanimously refuse to > > compile.) It's also somewhat irritating that the I/O libraries have a > > few quirks apparently related to mingw32. But hey, that one at least > > should be fixable... > > The problem here is that window is the odd one out. Still it would be nice if things were easily installable on Windows, so maybe some Windows user should write a tool which makes installing C libraries on windows feasible. > > Stuff written for userspace Linux will usually compile with little > more than minor alterations on OSX and all the other Unix-like > systems. Making that same code build on windows can be a significant > amount of work and that work should not be the responsibility of > the people who write code on Linux and Mac. > > Erik From deniz.a.m.dogan at gmail.com Thu Nov 5 17:31:29 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Thu Nov 5 17:07:59 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <4AF34DA6.2010701@btinternet.com> References: <1257382324.5965.97.camel@idefix.localdomain> <4AF34DA6.2010701@btinternet.com> Message-ID: <7b501d5c0911051431u624ab25eg45b7f108ba0ea9bf@mail.gmail.com> 2009/11/5 Andrew Coppin : > Matus Tejiscak wrote: >> >> zygohistomorphic prepromorphisms > > Please tell me this isn't a real technical term. o_O http://www.haskell.org/haskellwiki/Zygohistomorphic_prepromorphisms Still can't tell if it's a joke or not... -- Deniz Dogan From stefan at cs.uu.nl Thu Nov 5 17:36:04 2009 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Thu Nov 5 17:12:09 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <4AF34DA6.2010701@btinternet.com> References: <1257382324.5965.97.camel@idefix.localdomain> <4AF34DA6.2010701@btinternet.com> Message-ID: <2367E3EE-2A0B-490A-AA35-2AD99966C1B5@cs.uu.nl> Andrew, > As for concrete suggestions... I've always thought we could do more > to use static information about the program to aid runtime GC. It's > no deep secret that destructive updates are essentially like a > compile-time / coding-time GC operation. You determine before > runtime that the old version of the data will never be needed again, > and hence update it in-place. Making this kind of thing more > automatic could be interesting theoretically and practically. [Warning: shameless plug follows.] Have you had a look at our 2008 PEPM paper? Jurriaan Hage and Stefan Holdermans. Heap recyling for lazy languages. In John Hatcliff, Robert Gl?ck, and Oege de Moor, editors, Proceedings of the 2008 ACM SIGPLAN Symposium on Partial Evaluation and Semantics- Based Program Manipulation, PEPM 2008, San Francisco, California, USA, January 7?8, 2008, pages 189?197. ACM Press, 2008. http://people.cs.uu.nl/stefan/pubs/hage08heap.html As far as automatic detection of opportunities for in-place updates is concerned, the Clean compiler seems to do some interesting things. http://clean.cs.ru.nl/ I am not quite sure whether the details (a formal semantics, for example) have ever been published. I would be very much interested in such a description myself, actually, so if someone knows of any... Cheers, Stefan From brannanster at gmail.com Thu Nov 5 17:36:18 2009 From: brannanster at gmail.com (Patrick Brannan) Date: Thu Nov 5 17:12:28 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <7b501d5c0911051431u624ab25eg45b7f108ba0ea9bf@mail.gmail.com> References: <1257382324.5965.97.camel@idefix.localdomain> <4AF34DA6.2010701@btinternet.com> <7b501d5c0911051431u624ab25eg45b7f108ba0ea9bf@mail.gmail.com> Message-ID: And we wonder why Haskell isn't mainstream... On Thu, Nov 5, 2009 at 4:31 PM, Deniz Dogan wrote: > 2009/11/5 Andrew Coppin : >> Matus Tejiscak wrote: >>> >>> zygohistomorphic prepromorphisms >> >> Please tell me this isn't a real technical term. o_O > > http://www.haskell.org/haskellwiki/Zygohistomorphic_prepromorphisms > > Still can't tell if it's a joke or not... > > -- > Deniz Dogan > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From anton at appsolutions.com Thu Nov 5 17:43:37 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Thu Nov 5 17:19:47 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <7b501d5c0911051431u624ab25eg45b7f108ba0ea9bf@mail.gmail.com> References: <1257382324.5965.97.camel@idefix.localdomain> <4AF34DA6.2010701@btinternet.com> <7b501d5c0911051431u624ab25eg45b7f108ba0ea9bf@mail.gmail.com> Message-ID: <4AF35519.801@appsolutions.com> Deniz Dogan wrote: > 2009/11/5 Andrew Coppin : >> Matus Tejiscak wrote: >>> zygohistomorphic prepromorphisms >> Please tell me this isn't a real technical term. o_O > > http://www.haskell.org/haskellwiki/Zygohistomorphic_prepromorphisms > > Still can't tell if it's a joke or not... You might also be interested in Chapter 9 of the upcoming book described here: http://www.haskell.org/haskellwiki/Real_World From mle+hs at mega-nerd.com Thu Nov 5 17:45:45 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Thu Nov 5 17:21:52 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <7b501d5c0911051428p4d1effd1xc8c4b9fcae583614@mail.gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF34914.3020108@btinternet.com> <20091106090230.445a9182.mle+hs@mega-nerd.com> <7b501d5c0911051428p4d1effd1xc8c4b9fcae583614@mail.gmail.com> Message-ID: <20091106094545.ff82dfbc.mle+hs@mega-nerd.com> Deniz Dogan wrote: > 2009/11/5 Erik de Castro Lopo : > > > In addition, saying "90% of all desktop computers" is misleading; > > instead we should be talking about the computers of software developers > > and there, the figure is almost certainly well below 90%. > > > > Why? After all, software is always (in one way or another) written for > users, not other software developers. We're talking about Haskell libraries. The *only* people who are interested in Haskell libraries are Haskell developers (ie not even developers in general). Counting desktop users who use nothing more than Word, Excel and IE are not interested in Haskell libraries. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From vandijk.roel at gmail.com Thu Nov 5 17:51:27 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Thu Nov 5 17:27:32 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <4AF34DA6.2010701@btinternet.com> References: <1257382324.5965.97.camel@idefix.localdomain> <4AF34DA6.2010701@btinternet.com> Message-ID: On Thu, Nov 5, 2009 at 11:11 PM, Andrew Coppin wrote: > Matus Tejiscak wrote: >> >> zygohistomorphic prepromorphisms > > Please tell me this isn't a real technical term. o_O > You can even generalize them: g_prepro_zygo :: (Functor f, Comonad w) => GAlgebra f w b -> Dist f w -> GAlgebra f (ZygoT w b) a -> (f :~> f) -> FixF f -> a Brought to you by the wonderful world of category theory: http://hackage.haskell.org/packages/archive/category-extras/0.53.5/doc/html/Control-Morphism-Zygo.html Here is an explanatory diagram: http://bifunctor.homelinux.net/~roel/zygohistomorphic_prepromorphism.gif From agocorona at gmail.com Thu Nov 5 17:54:00 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Thu Nov 5 17:30:06 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <20091104185602.GD18694@whirlpool.galois.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> <20091104185602.GD18694@whirlpool.galois.com> Message-ID: A comparison of the evolution in speed of Haskell from version to version rather than with other languages could have been very informative about the progress in haskell speed. I think that the progression has been astonishing. I though that while seeing this language shootout in windows http://dada.perl.it/shootout/ where ghc performance is rather mean. Until I realized that the version used was GHC 5.04.2 2009/11/4 Don Stewart > bulat.ziganshin: > > oh, can we stop saying about shootout? if you want to see speed of > > pure haskell code, look at papers about fast arrays/strings - their > > authors have measured that lazy lists are hundreds times slower than > > idiomatic C code. is use of lazy lists counted as mistake too and > > paper authors had too small haskell experience? > > Comparing apples against oranges is a mistake, yes. > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091105/8424fe13/attachment.html From mle+hs at mega-nerd.com Thu Nov 5 17:59:19 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Thu Nov 5 17:35:26 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <4AF3517B.6030201@btinternet.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF34914.3020108@btinternet.com> <20091106090230.445a9182.mle+hs@mega-nerd.com> <4AF3517B.6030201@btinternet.com> Message-ID: <20091106095919.de8e4319.mle+hs@mega-nerd.com> Andrew Coppin wrote: > Depends what you develop. I know of plenty of developers who use MS > Visual Studio for everything, for example. And those developers do not care whether Haskell libraries compile on windows or not. > You can pretend that Windows isn't popular and thus there's no need to > support it, but to me that seems like a fairly unrealistic point of view. Windows is popular amongst general computer users, but less popular amongst developers and less popular still amongst Haskell developers. > > The problem here is that window is the odd one out. > > This, it seems, is why there are programs in this world that are > designed for Windows but (sometimes) also run on Unix, This is a very small proportion of all windows applications and many/ most of them run via Wine, a code base of 1.8 million lines with a worth according to Ohloh of $29Mil (which I consider very conservative): http://www.ohloh.net/p/wine > and other > programs which are designed for Unix but (sometimes) also run on Windows. A far larger proportion of Unix program run on windows, due to two factors: - Unix people write command line apps and libraries which are always easier to port to windows. - Unix people doing things like windows backends to GTK+ and QT to make GUI applications portable to windows. > I'm just saying, we could still do better... My point is that its up to people who care about windows to fix things for windows. I am a user of Debian and Ubuntu. About a year ago I became sick and tired of the poor state of haskell in Debian. I didn't complain, I joined the debian-haskell-maintainers group and started packaging haskell stuff for Debian. Now, the situation has improved vastly. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From lrpalmer at gmail.com Thu Nov 5 17:59:46 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Nov 5 17:35:51 2009 Subject: [Haskell-cafe] Code generated by pointfree does not compile In-Reply-To: <26211701.post@talk.nabble.com> References: <26211701.post@talk.nabble.com> Message-ID: <7ca3f0160911051459n3d790fc5s36769899043fba0@mail.gmail.com> On Thu, Nov 5, 2009 at 4:46 AM, Boris Lykah wrote: > > Hi all! > > I was playing with pointfree tool from hackage and found that it produces > wrong code for some functions which use list comprehension. > > Here are several examples: > > :main f x = concat [x:f x| x<-[0..x-1]] > f = fix ((join .) . flip flip [] . ((:) .) . ap (:) . (`ap` (enumFromTo 0 . > subtract 1)) . ((<-) .) . ((|) =<<)) > This does not compile because (<-) and (|) are used as functions whereas > they are not. Looks like pointfree doesn't understand list comprehension syntax. Convert to normal functional notation instead: main f x = concat (map (\x -> x : f x) [0..x-1]) Luke From mle+hs at mega-nerd.com Thu Nov 5 18:23:19 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Thu Nov 5 17:59:24 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <2367E3EE-2A0B-490A-AA35-2AD99966C1B5@cs.uu.nl> References: <1257382324.5965.97.camel@idefix.localdomain> <4AF34DA6.2010701@btinternet.com> <2367E3EE-2A0B-490A-AA35-2AD99966C1B5@cs.uu.nl> Message-ID: <20091106102319.29a28600.mle+hs@mega-nerd.com> Stefan Holdermans wrote: > http://people.cs.uu.nl/stefan/pubs/hage08heap.html Getting connection refused on that. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From deniz.a.m.dogan at gmail.com Thu Nov 5 18:32:48 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Thu Nov 5 18:09:14 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <20091106102319.29a28600.mle+hs@mega-nerd.com> References: <1257382324.5965.97.camel@idefix.localdomain> <4AF34DA6.2010701@btinternet.com> <2367E3EE-2A0B-490A-AA35-2AD99966C1B5@cs.uu.nl> <20091106102319.29a28600.mle+hs@mega-nerd.com> Message-ID: <7b501d5c0911051532m5cb03ddve1e1fd4118bef243@mail.gmail.com> 2009/11/6 Erik de Castro Lopo : > Stefan Holdermans wrote: > >> ? ?http://people.cs.uu.nl/stefan/pubs/hage08heap.html > > Getting connection refused on that. > Try this one, from Google's cache: http://preview.tinyurl.com/ydjuw2j -- Deniz Dogan From deniz.a.m.dogan at gmail.com Thu Nov 5 18:34:18 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Thu Nov 5 18:10:41 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <7b501d5c0911051532m5cb03ddve1e1fd4118bef243@mail.gmail.com> References: <1257382324.5965.97.camel@idefix.localdomain> <4AF34DA6.2010701@btinternet.com> <2367E3EE-2A0B-490A-AA35-2AD99966C1B5@cs.uu.nl> <20091106102319.29a28600.mle+hs@mega-nerd.com> <7b501d5c0911051532m5cb03ddve1e1fd4118bef243@mail.gmail.com> Message-ID: <7b501d5c0911051534g416edb5eic58f8f461e943af4@mail.gmail.com> 2009/11/6 Deniz Dogan : > 2009/11/6 Erik de Castro Lopo : >> Stefan Holdermans wrote: >> >>> ? ?http://people.cs.uu.nl/stefan/pubs/hage08heap.html >> >> Getting connection refused on that. >> > > Try this one, from Google's cache: > http://preview.tinyurl.com/ydjuw2j > > -- > Deniz Dogan > Oops, those were slides. Here is the paper: http://preview.tinyurl.com/ycmneko -- Deniz Dogan From lemming at henning-thielemann.de Thu Nov 5 18:58:13 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Nov 5 18:34:18 2009 Subject: [Haskell-cafe] ANNOUNCE: feldspar-language In-Reply-To: <9e5767b0911032003o28292050rba2f8efa20c0fda@mail.gmail.com> References: <4AF0F78B.2090405@chalmers.se> <9e5767b0911032003o28292050rba2f8efa20c0fda@mail.gmail.com> Message-ID: On Tue, 3 Nov 2009, Warren Henning wrote: > I see that section 4.1 of the user guide - > http://feldspar.sourceforge.net/documents/language/FeldsparLanguage.html#htoc23 > - includes an example involving autocorrelation. > > Does this mean I could use Feldspare to easily build my own Autotune > program? I love T-Pain and Autotune the News! There are several packages on hackage for performing signal processing: like dsp and fftw, that can assist doing autocorrelation. From lemming at henning-thielemann.de Thu Nov 5 18:59:42 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Nov 5 18:35:45 2009 Subject: [Haskell-cafe] ANNOUNCE: feldspar-language In-Reply-To: <4AF0F78B.2090405@chalmers.se> References: <4AF0F78B.2090405@chalmers.se> Message-ID: On Wed, 4 Nov 2009, Emil Axelsson wrote: > I'm happy to announce the first release of Feldspar, which is an embedded > domain-specific language with associated code generator mainly targeting DSP > algorithms. The language is developed in cooperation by Ericsson, Chalmers > University and E?tv?s Lor?nd University. > > Feldspar stands for *F*unctional *E*mbedded *L*anguage for *DSP* and > *PAR*allelism. > > The language front-end is available on Hackage: > > http://hackage.haskell.org/package/feldspar-language 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?) From lemming at henning-thielemann.de Thu Nov 5 19:04:33 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Nov 5 18:41:23 2009 Subject: [Haskell-cafe] Fair diagonals In-Reply-To: <3B0A27AE-F76F-4F38-AD4D-8561007B6595@w3future.com> References: <4AF095D0.9030105@van.steenbergen.nl> <44F139D4-0B29-42A1-8D45-EF80333DB182@w3future.com> <4AF18DFA.7020602@gmail.com> <3B0A27AE-F76F-4F38-AD4D-8561007B6595@w3future.com> Message-ID: On Wed, 4 Nov 2009, Sjoerd Visscher wrote: > > On Nov 4, 2009, at 3:21 PM, Twan van Laarhoven wrote: > > I looked on hackage but I was surprised that I couldn't find this simple > monad. The package level-monad does look very similar, only it uses a > different list type for the representation. > > > indeed, level-monad works as well: > > import Control.Monad.Levels > import Data.FMList (fromList) > > diagN = bfs . mapM fromList Can someone explain the difference between control-monad-omega and level-monad? From wren at freegeek.org Thu Nov 5 20:13:28 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu Nov 5 19:49:37 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> <4AF0E87F.7000306@freegeek.org> Message-ID: <4AF37838.90703@freegeek.org> Roman Leshchinskiy wrote: > wren ng thornton wrote: >> Roman Leshchinskiy wrote: >>> On 04/11/2009, at 13:23, Daniel Peebles wrote: >>>> In the presence of fusion (as is the case in uvector), it's hard to >>>> give meaningful time complexities for operations as they depend on >>>> what operations they are paired with. We need to think of a better way >>>> to express this behavior in the documentation though. >>> >>> I have to disagree here. Fusion never makes the complexity of >>> operations worse. If it does, it's a bug. >> >> I think the point was more that the relevant complexity bound can >> change in the presence of fusion. For a poor example: the first map >> over a list is O(n) but all subsequent ones in a chain of maps are >> O(1) with fusion. I'm sure there are better examples than that, but >> you get the idea. Some people may care to know about that latter >> complexity rather than just the "independent" complexity. > > I think asymptotic complexity is the wrong tool for what you're trying > to do. [...] Executing the two maps, be it one after another or interlocked, > is linear simply because O(n) + O(n) = O(n), not because of fusion. As I said, it was a bad example. Off-hand I can't think of any examples where fusion actually does affect asymptotic complexity rather than just reducing the constant factor. But I think such examples (if they exist) are what Daniel was concerned with, rather than any bugs where fusion makes the complexity (or constant factors) worse. -- Live well, ~wren From will_n48 at yahoo.com Thu Nov 5 20:43:00 2009 From: will_n48 at yahoo.com (Will Ness) Date: Thu Nov 5 20:19:28 2009 Subject: [Haskell-cafe] Re: Simple FAST lazy functional primes References: <20091103155227.E721A324918@www.haskell.org> <1257417158.3701.17.camel@localhost> Message-ID: Steve yahoo.com.au> writes: > > On Tue, 2009-11-03 at 10:52 -0500, Will wrote: > > I've just tried it and it was twice slower than mine. (?) I didn't use > > the [Int] > > signature in both. [...] It runs twice as fast with it). > > Although your > > code has an advantage that it is very easy to add the wheel > > optimization to it. > > I used [Int] for both. If you didn't use [Int] then it defaults to > [Integer] and you are probably testing the speed of GMP integer > operations (rather than the speed of Haskell Int operations) which could > give differing conclusions. When both are declared [Int], the ratios are [1.50, 1.40, 1.35, 1.26, 1.26] for speed of your version vs mine in producing 100,000, 300,000, 1, 2 and 3 million primes, on my laptop, with memory consistently at 120% (as reported by GHCi with :s +s switch). Haven't tried any above that, as it's old and slow. But clearly the two versions are on par with each other. The reason I prefer my version is that it's in a form easy to be tweaked with further. :) > I had looked into using a wheel before. Its nice in theory, but not so > useful in practice. At least that's my experience where using a wheel > made the primes function slower. interesting. > Adding your code and conclusions to "Prime numbers" on the Haskell wiki, > could be useful. > http://www.haskell.org/haskellwiki/Prime_numbers Thank you for pointing me to that page. I've just done that. :) The short description that I've arrived at in the end, is that my version explicitly uses successive prefixes of the primes list to test batches of odds between successive squares of primes. Now it's short and clear. Thanks! > I've just updated the page to split it into "Finding Primes" and > "Testing Primality". > > Steve > From briand at aracnet.com Thu Nov 5 21:15:04 2009 From: briand at aracnet.com (brian) Date: Thu Nov 5 20:51:14 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> <87zl71s5vn.fsf@malde.org> <4c88418c0911050149q446b7f9eu53136811f962ed2e@mail.gmail.com> Message-ID: <4F7E36CF-D386-40DC-AAF0-30A7992D32E5@aracnet.com> On Nov 5, 2009, at 8:26 AM, Jason Dagit wrote: > > I can't really think of how laziness and polymorphism are related. > For me the big win with laziness is composability. Laziness allows > us to express things in ways that are more natural. The prelude > function 'take' is a perfect example. It allows you to use finite > portions of infinite lists. You could then express an infinite > series very naturally and then decouple from that the logic to > process finite parts. The implication here is that laziness allows > you to use data structures for control flow. This all works > together to enable separation of concerns. Which is generally a > very good thing if you want to reason about your source code. > My bad, I meant polymorphism as the answer as to why things are boxed. > Laziness can also be thought of as a transformation on the time > complexity of algorithms. Sure, the worst-case complexity still > remains but often you can get a better average case by only > computing as much as you need. > > I hope that helps, It does. From briand at aracnet.com Thu Nov 5 21:15:49 2009 From: briand at aracnet.com (brian) Date: Thu Nov 5 20:51:55 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> <87zl71s5vn.fsf@malde.org> <4c88418c0911050149q446b7f9eu53136811f962ed2e@mail.gmail.com> Message-ID: On Nov 5, 2009, at 8:26 AM, Jason Dagit wrote: > > > Haskell knows when I have a list of Doubles, you know, because it's > strongly typed. > > Then it proceeds to box them. Huh ? > > Imagine a computation which will yield a Double if evaluated, but > has not yet been evaluated. How do you store that in the list? > So laziness is causing the boxing to be necessary ? From wren at freegeek.org Thu Nov 5 22:00:44 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu Nov 5 21:36:49 2009 Subject: [Haskell-cafe] Memory Leak - Artificial Neural Network In-Reply-To: <1591563045-1257427771-cardhu_decombobulator_blackberry.rim.net-195397140-@bda078.bisx.prod.on.blackberry> References: <69630b260911050254y1c1330f8t56ead9be5fda0534@mail.gmail.com><7ca3f0160911050324s65b601f1g4b3cf53bc67bb486@mail.gmail.com> <1591563045-1257427771-cardhu_decombobulator_blackberry.rim.net-195397140-@bda078.bisx.prod.on.blackberry> Message-ID: <4AF3915C.8060600@freegeek.org> Hector Guilarte wrote: > Hi Luke, > > The code is mainly in Spanish with son parts in English... > > Thanks for the explanation, I got the idea very well, but now I got some questions about that. > > How does the Prelude functions for managing lists work? I mean, what does zip, unzip, foldl, foldr, map and zipWith do? Tail recursion or corecursion? I know, thanks to the profiling I did, that my main memory leak is in the function "entrenamiento" (which means training in Spanish), and I hardly believe it is in when I use of those functions I mentioned before, so if they are tail recursive and I change them to my own corecursive version, maybe I'll get rid of the problem, won't I? Don't worry about the Prelude definitions, by and large they're the "right" definitions. If you're curious then just search for Prelude.hs on your system, or check it out online[1]. As a more general high-level suggestion, the most efficient way to implement feedforward ANNs is to treat them as matrix multiplication problems and use matrices/arrays rather than lists. For a three layer network of N, M, and O nodes we thus: * start with an N-wide vector of inputs * multiply by the N*M matrix of weights, to get an M-vector * map sigmoid or other activation function * multiply by the M*O matrix of weights for the next layer to get an O-vector * apply some interpretation (e.g. winner-take-all) to the output There are various libraries for optimized matrix multiplication, but even just using an unboxed array for the matrices will make it much faster to traverse through things. [1] http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html See the "Source Code" link at the top of the page. -- Live well, ~wren From emax at chalmers.se Fri Nov 6 00:28:09 2009 From: emax at chalmers.se (Emil Axelsson) Date: Fri Nov 6 00:04:15 2009 Subject: [Haskell-cafe] ANNOUNCE: feldspar-language In-Reply-To: References: <4AF0F78B.2090405@chalmers.se> Message-ID: <4AF3B3E9.4040005@chalmers.se> Henning Thielemann skrev: > On Wed, 4 Nov 2009, Emil Axelsson wrote: > >> I'm happy to announce the first release of Feldspar, which is an embedded >> domain-specific language with associated code generator mainly targeting DSP >> algorithms. The language is developed in cooperation by Ericsson, Chalmers >> University and E?tv?s Lor?nd University. >> >> Feldspar stands for *F*unctional *E*mbedded *L*anguage for *DSP* and >> *PAR*allelism. >> >> The language front-end is available on Hackage: >> >> http://hackage.haskell.org/package/feldspar-language > > 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! / Emil From dagit at codersbase.com Fri Nov 6 01:14:49 2009 From: dagit at codersbase.com (Jason Dagit) Date: Fri Nov 6 00:50:52 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> <87zl71s5vn.fsf@malde.org> <4c88418c0911050149q446b7f9eu53136811f962ed2e@mail.gmail.com> Message-ID: On Thu, Nov 5, 2009 at 6:15 PM, brian wrote: > > On Nov 5, 2009, at 8:26 AM, Jason Dagit wrote: > > >> >> Haskell knows when I have a list of Doubles, you know, because it's >> strongly typed. >> >> Then it proceeds to box them. Huh ? >> >> Imagine a computation which will yield a Double if evaluated, but has not >> yet been evaluated. How do you store that in the list? >> >> > So laziness is causing the boxing to be necessary ? > > "Necessary" is a strong word within formal/mathematical communities. If you mean it in that sense, then I'm not sure it's necessary. My (incomplete) understanding is that no one has a better way than boxing that has as wide applicability as boxing. Perhaps there are techniques that work better. My guess is that they are either 1) special cases; or 2) have yet to be discovered. I wonder if perhaps supercompilation or perhaps whole program optimizations will eventually be able to eliminate much of the boxing we have today. Strictness analysis has done a lot to remove boxing but it is not perfect due to the halting problem. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091106/056e9688/attachment.html From stefan at cs.uu.nl Fri Nov 6 01:22:07 2009 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Fri Nov 6 00:58:09 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <20091106102319.29a28600.mle+hs@mega-nerd.com> References: <1257382324.5965.97.camel@idefix.localdomain> <4AF34DA6.2010701@btinternet.com> <2367E3EE-2A0B-490A-AA35-2AD99966C1B5@cs.uu.nl> <20091106102319.29a28600.mle+hs@mega-nerd.com> Message-ID: <6E3A5E7F-0A7F-45A5-9833-3EE6CFE61EB1@cs.uu.nl> Erik, >> http://people.cs.uu.nl/stefan/pubs/hage08heap.html > Getting connection refused on that. Don't know: it still works for me. Cheers, Stefan From qdunkan at gmail.com Fri Nov 6 02:01:57 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Fri Nov 6 01:38:00 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> <87zl71s5vn.fsf@malde.org> <4c88418c0911050149q446b7f9eu53136811f962ed2e@mail.gmail.com> Message-ID: <2518b95d0911052301w4bcf403dl77eaa192b69eca26@mail.gmail.com> > And this is confusing to those of us who are not compiler experts. > > Haskell knows when I have a list of Doubles, you know, because it's strongly > typed. > > Then it proceeds to box them. Huh ? > > The laziness thing has many example od _reducing_ efficiency, but there > seems to be a real lack of example > where it helps. ?In fact it seems to _always_ hurt. ?People sure seem > excited about it. ?Me, not so excited. I have a program that involves a somewhat involved "compilation" pipeline. As a result of laziness, it's all done incrementally and I can start getting results right away, which is essential to my application. Without laziness I'd have to do something awkward and complicated like break it into a lot of message passing threads or process in chunks (and it's impossible to know how much context each chunk will need without further hackery). I can abort the computation cleanly by simply stopping the consumer, and everything gets GCed. And I get all sorts of convenient idioms like 'zip [0..]' and calculating stuff in 'where' that I may not need. And it's just fun. So I'm still excited about it :) From mle+hs at mega-nerd.com Fri Nov 6 02:36:09 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Fri Nov 6 02:12:14 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <6E3A5E7F-0A7F-45A5-9833-3EE6CFE61EB1@cs.uu.nl> References: <1257382324.5965.97.camel@idefix.localdomain> <4AF34DA6.2010701@btinternet.com> <2367E3EE-2A0B-490A-AA35-2AD99966C1B5@cs.uu.nl> <20091106102319.29a28600.mle+hs@mega-nerd.com> <6E3A5E7F-0A7F-45A5-9833-3EE6CFE61EB1@cs.uu.nl> Message-ID: <20091106183609.9ee80dae.mle+hs@mega-nerd.com> Stefan Holdermans wrote: > Erik, > > >> http://people.cs.uu.nl/stefan/pubs/hage08heap.html > > > Getting connection refused on that. > > Don't know: it still works for me. Working for me as well now. Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From ketil at malde.org Fri Nov 6 02:45:02 2009 From: ketil at malde.org (Ketil Malde) Date: Fri Nov 6 02:21:09 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <1257435285.25369.4289.camel@localhost> (Duncan Coutts's message of "Thu, 05 Nov 2009 15:34:45 +0000") References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <20091104051957.GB15880@whirlpool.galois.com> <844075476.20091104150204@gmail.com> <871vkev2l3.fsf@malde.org> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> <87zl71s5vn.fsf@malde.org> <4c88418c0911050149q446b7f9eu53136811f962ed2e@mail.gmail.com> <87ws2510jx.fsf@malde.org> <1257435285.25369.4289.camel@localhost> Message-ID: <87fx8sm70h.fsf@malde.org> Duncan Coutts writes: >> The "build operation" part often ends up a bit gross, but I have a plan >> for that which I hope to come back to later on. > > Yes, they're not good for construction atm. The Builder monoid from the I've used that a bit, but that's not what I'm talking about. Serializing and deserializing to/from bytestrings is sometimes complicated, but usually straightforward enough. The operation in between is what is giving me headaches. Basically, I have a bunch of command line options - filter on this, modify on that, produce some kind of output to some file - that must be interpreted in order to produce a combined filter/modifier processing. The pipeline looks something like this: readFoo :: IO [Foo] process :: [Foo] -> IO [Foo] writeFoo :: [Foo] -> IO () The hard part is how to elegantly construct the "process" part. If it were just filtering or modifications, it could be a pure function. The complexity comes from sometimes needing to split off some output to some file. Currently, I'm opening handles in advance, and processing one Foo at a time, writing it to the correct handles, and finally closing handles when done. This is a rather pedestrian approach. I'm now considering defining branch :: ([Foo] -> IO ()) -> [Foo] -> IO [Foo] branch iop fs = do forkIO (iop fs) return fs Which, if I understand correctly, would allow me to write process = filterM this >>= mapM that >>= branch (writeBar . map foo2bar) >>= filterM theother So - is this a good way to approach it? I feel slightly queasy about using concurrency for this, although I think it'll work well in practice. It is very important that this is lazy - the list of Foos can be larger than available memory, so one risk is that one thread might run off with the list of Foos with the other trailing far behind, leading to increased memory use. Previous experience seems to indicate that the 'head' thread will be slowed by disk/memory and allow the trailing threads to keep up. I do have a nagging feeling that this could be solved more elegantly with arrows or a lazy writer monad, or something else that I don't know enough about. I'd be happy to hear any suggestions. -k PS: I probably need to catch the threadID, and wait for all threads to finish as well. This is left as an excercise for the writer. :-) -- If I haven't seen further, it is by standing in the footprints of giants From dav.vire+haskell at gmail.com Fri Nov 6 03:12:00 2009 From: dav.vire+haskell at gmail.com (David Virebayre) Date: Fri Nov 6 02:48:03 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <87fx8sm70h.fsf@malde.org> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <1128936951.20091104164558@gmail.com> <87tyxatf45.fsf@malde.org> <597965808.20091104200149@gmail.com> <87zl71s5vn.fsf@malde.org> <4c88418c0911050149q446b7f9eu53136811f962ed2e@mail.gmail.com> <87ws2510jx.fsf@malde.org> <1257435285.25369.4289.camel@localhost> <87fx8sm70h.fsf@malde.org> Message-ID: <4c88418c0911060012q20043661k251585ebfccca85c@mail.gmail.com> On Fri, Nov 6, 2009 at 8:45 AM, Ketil Malde wrote: > > enough about. I'd be happy to hear any suggestions. > This is more a question than a suggestion, but would the iteratees package fit your needs ? David. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091106/57926515/attachment.html From bos at serpentine.com Fri Nov 6 03:21:01 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Fri Nov 6 02:57:04 2009 Subject: [Haskell-cafe] [ANN] Criterion 0.2, an improved Haskell benchmarking library Message-ID: I?m pleased to announce the availability of version 0.2 of my criterion library for Haskell performance evaluation. For details, please see below: - http://www.serpentine.com/blog/2009/11/06/criterion-0-2-an-improved-haskell-benchmarking-library/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091106/6cc064ad/attachment.html From bertram.felgenhauer at googlemail.com Fri Nov 6 04:37:06 2009 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Fri Nov 6 04:16:54 2009 Subject: [Haskell-cafe] Fair diagonals In-Reply-To: <4AF095D0.9030105@van.steenbergen.nl> References: <4AF095D0.9030105@van.steenbergen.nl> Message-ID: <20091106093706.GA2194@24f89f8c-e6a1-4e75-85ee-bb8a3743bb9f> Martijn van Steenbergen wrote: > Bonus points for the following: > * An infinite number of singleton axes produces [origin] (and > finishes computing), e.g. forall (infinite) xs. diagN (map (:[]) xs) > == map (:[]) xs This can't be done - you can not produce any output before you have checked that all the lists are not empty: diag (replicate n [0] ++ [[]]) == [] Bertram From martijn at van.steenbergen.nl Fri Nov 6 05:06:33 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Nov 6 04:42:41 2009 Subject: [Haskell-cafe] Fair diagonals In-Reply-To: References: <4AF095D0.9030105@van.steenbergen.nl> <44F139D4-0B29-42A1-8D45-EF80333DB182@w3future.com> <4AF18DFA.7020602@gmail.com> <3B0A27AE-F76F-4F38-AD4D-8561007B6595@w3future.com> Message-ID: <4AF3F529.1010403@van.steenbergen.nl> Henning Thielemann wrote: > > On Wed, 4 Nov 2009, Sjoerd Visscher wrote: > >> >> On Nov 4, 2009, at 3:21 PM, Twan van Laarhoven wrote: >> >> I looked on hackage but I was surprised that I couldn't find >> this simple >> monad. The package level-monad does look very similar, only it >> uses a >> different list type for the representation. >> >> >> indeed, level-monad works as well: >> >> import Control.Monad.Levels >> import Data.FMList (fromList) >> >> diagN = bfs . mapM fromList > > Can someone explain the difference between control-monad-omega and > level-monad? So from what I understand this is the difference: Omega is biased towards the lower dimensions while Levels treats all dimensions equally, or at least more equally. You can formalize the latter by saying: the sums of the indices should be non-decreasing. From Omega's documentation I understand this is on purpose: "(...) Likewise, a breadth-first search of a data structure can fall short if it has an infinitely branching node. Omega addresses this problem by using a "diagonal" traversal that gracefully dissolves such data." However, I can't verify this: > runOmega . mapM each $ map (:[]) [1..] > *** Exception: stack overflow Or maybe I misunderstood Omega's documentation. Martijn. From lrpalmer at gmail.com Fri Nov 6 05:17:25 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Nov 6 04:53:28 2009 Subject: [Haskell-cafe] Fair diagonals In-Reply-To: <4AF3F529.1010403@van.steenbergen.nl> References: <4AF095D0.9030105@van.steenbergen.nl> <44F139D4-0B29-42A1-8D45-EF80333DB182@w3future.com> <4AF18DFA.7020602@gmail.com> <3B0A27AE-F76F-4F38-AD4D-8561007B6595@w3future.com> <4AF3F529.1010403@van.steenbergen.nl> Message-ID: <7ca3f0160911060217l33925bc6i712b226d6c60da5e@mail.gmail.com> On Fri, Nov 6, 2009 at 3:06 AM, Martijn van Steenbergen wrote: > "(...) Likewise, a breadth-first search of a data structure can fall short > if it has an infinitely branching node. Omega addresses this problem by > using a "diagonal" traversal that gracefully dissolves such data." > > However, I can't verify this: >> >> ?runOmega . mapM each $ map (:[]) [1..] >> *** Exception: stack overflow > > Or maybe I misunderstood Omega's documentation. You are asking for the impossible. >>> runOmega . mapM each $ [[1],[2],[3],[4],[5],[6]] [[1,2,3,4,5,6]] Replace one of them with the empty list >>> runOmega . mapM each $ [[1],[2],[3],[],[5],[6]] [] If any of the lists is empty, the output will be empty. So if you give it an infinite number of lists, it cannot ever return any information to you, since at some point in the future it may come across an empty list. Unless, of course, it *does* encounter an empty list, in which case it knows the answer: runOmega . mapM each $ map (:[]) [1..10] ++ [] ++ map (:[]) [12..] [] Luke From martijn at van.steenbergen.nl Fri Nov 6 05:31:01 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Nov 6 05:07:09 2009 Subject: [Haskell-cafe] Fair diagonals In-Reply-To: <7ca3f0160911060217l33925bc6i712b226d6c60da5e@mail.gmail.com> References: <4AF095D0.9030105@van.steenbergen.nl> <44F139D4-0B29-42A1-8D45-EF80333DB182@w3future.com> <4AF18DFA.7020602@gmail.com> <3B0A27AE-F76F-4F38-AD4D-8561007B6595@w3future.com> <4AF3F529.1010403@van.steenbergen.nl> <7ca3f0160911060217l33925bc6i712b226d6c60da5e@mail.gmail.com> Message-ID: <4AF3FAE5.6030507@van.steenbergen.nl> Luke Palmer wrote: > On Fri, Nov 6, 2009 at 3:06 AM, Martijn van Steenbergen > wrote: >> "(...) Likewise, a breadth-first search of a data structure can fall short >> if it has an infinitely branching node. Omega addresses this problem by >> using a "diagonal" traversal that gracefully dissolves such data." >> >> However, I can't verify this: >>> runOmega . mapM each $ map (:[]) [1..] >>> *** Exception: stack overflow >> Or maybe I misunderstood Omega's documentation. > > You are asking for the impossible. Oh, and I realise now that this has been mentioned two times before already in this thread. *hangs head in shame* Are there examples of infinitely branching nodes where it is possible to give some output? Otherwise I'm not sure what the documentation is saying. Martijn. From shelby at coolpage.com Fri Nov 6 05:49:04 2009 From: shelby at coolpage.com (Shelby Moore) Date: Fri Nov 6 05:25:08 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <3751.121.97.54.144.1257395683.squirrel@webmail12.pair.com> References: <1257382324.5965.97.camel@idefix.localdomain> <3643.121.97.54.144.1257388140.squirrel@webmail12.pair.com> <3751.121.97.54.144.1257395683.squirrel@webmail12.pair.com> Message-ID: <2525.121.97.54.144.1257504544.squirrel@webmail9.pair.com> > Throttling at the thunk+GC interaction as I suggested, thus transparent to > the semantics of Haskell language, is an experimental concept that > potentially convolves with the system-at-large. I added a refined description of the algorithm I am proposing (as a starting point for further work): http://hackage.haskell.org/trac/ghc/ticket/3630#comment:4 From johnvg at cs.ru.nl Fri Nov 6 06:50:20 2009 From: johnvg at cs.ru.nl (John van Groningen) Date: Fri Nov 6 06:26:25 2009 Subject: [Haskell-cafe] What's the deal with Clean? In-Reply-To: <1BFBEDAF-236D-4645-A0C2-8A7AB83FD213@swierstra.net> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <1BFBEDAF-236D-4645-A0C2-8A7AB83FD213@swierstra.net> Message-ID: Doaitse Swierstra wrote: >One of this differences between Haskell and Clean I did not see mentioned in this discussion is that Clean does not allow so-called partial parametrisation. I.e. all function calls have to be fully saturated I don't understand what you mean. Can you give an example ? Kind regards, John van Groningen From johan.tibell at gmail.com Fri Nov 6 08:36:16 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Fri Nov 6 08:12:40 2009 Subject: [Haskell-cafe] ANN: ZuriHac: Haskell hackathon in Zurich, March 19-21 Message-ID: <90889fe70911060536g61368cf6v372be96d029f7a1@mail.gmail.com> Hi all! I am very pleased to officially announce ZuriHac, a Haskell hackathon/get-together to be held March 19-21 at the Google Office in Zurich, Switzerland. Thanks to everyone who has already expressed interest in attending. I want to stress that everyone is welcome---you do not have to be a Haskell guru to attend! Helping hack on someone else's project could be a great way to increase your Haskell-fu. If you plan on coming, please officially register [1], even if you already put your name on the wiki. Registration, travel, lodging and many other details will soon be available on the ZuriHac wiki [2]. WHEN Friday March 19 2:30pm to 6:30pm Saturday March 20 10am to 6pm Sunday March 21 10am to 6pm WHERE We will be in the TechTalk area of the Google Office at Brandschenkestrasse 110. Please see the wiki [3] for directions. ORGANIZERS Johan Tibell Christophe Poucet Hope to see you in Zurich! - The ZuriHac team [1] http://haskell.org/haskellwiki/ZuriHac/Register [2] http://haskell.org/haskellwiki/ZuriHac [3] http://haskell.org/haskellwiki/ZuriHac#Getting_to_the_Google_Office From sebf at informatik.uni-kiel.de Fri Nov 6 09:05:43 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Fri Nov 6 08:41:48 2009 Subject: [Haskell-cafe] Fair diagonals In-Reply-To: <4AF3FAE5.6030507@van.steenbergen.nl> References: <4AF095D0.9030105@van.steenbergen.nl> <44F139D4-0B29-42A1-8D45-EF80333DB182@w3future.com> <4AF18DFA.7020602@gmail.com> <3B0A27AE-F76F-4F38-AD4D-8561007B6595@w3future.com> <4AF3F529.1010403@van.steenbergen.nl> <7ca3f0160911060217l33925bc6i712b226d6c60da5e@mail.gmail.com> <4AF3FAE5.6030507@van.steenbergen.nl> Message-ID: <091B57D2-A785-460C-A401-15495F14DF6F@informatik.uni-kiel.de> Hello, like Luke said, the `diagonal` function from `Control.Monad.Omega` is what Martijn was looking for and unlike what Louis said, it is not equivalent to `runOmega . each`: ghci> take 10 $ diagonal [[(x,y) | y <-[1..]] | x <- [1..]] [(1,1),(1,2),(2,1),(1,3),(2,2),(3,1),(1,4),(2,3),(3,2),(4,1)] ghci> take 10 $ (runOmega . mapM each) [[(x,y) | y <-[1..]] | x <- [1..]] *** Exception: stack overflow Here is an alternative implementation of `diagonal` by Mike Spivey [1]: diagonal = concat . diag diag [] = [] diag (xs:xss) = zipCons xs ([]:diag xss) zipCons [] yss = yss zipCons xs [] = map (:[]) xs zipCons (x:xs) (ys:yss) = (x:ys) : zipCons xs yss It looks subtly different to Luke's version (no special case for empty `xs` in the definition of `diag`) but shows the same behaviour on the above input. This diagonal function (as well as Luke's) also satisfies the property diagonal (map (:[]) xs) == xs for all (even infinite) lists `xs`. Neither `(runOmega . mapM each)` nor `(bfs . mapM fromList)` terminate if `xs` is infinite. They both yield `[[1,2,3]]` if `xs == [1,2,3]` whereas `diag` yields `[[1],[2],[3]]`. Unlike the omega monad, the level monad enumerates the search tree of a nondeterministic monadic computation in breadth-first order if `mplus` and `return` are the inner and leaf nodes of the search tree, respectively. The omega monad enumerates results in a different order than the level monad which hints at the problem with the associativity law mentioned by Heinrich: ghci> let inc x = return x `mplus` return (x+1) ghci> runOmega (each [0,10] >>= inc >>= inc) [0,1,1,2,10,11,11,12] ghci> runOmega (each [0,10] >>= \x -> inc x >>= inc) [0,1,10,1,11,2,11,12] ghci> bfs (fromList [0,10] >>= inc >>= inc) [0,1,1,2,10,11,11,12] ghci> bfs (fromList [0,10] >>= \x -> inc x >>= inc) [0,1,1,2,10,11,11,12] Both `bfs` and `runOmega` use a lot of memory for larger examples. `idfsBy 1` returns the results in the same order as `bfs` but uses much less memory at the price of iteratively recomputing the search tree. The stream-monad package provides a fair nondeterminism monad which avoids recomputations and has quite good memory performance (not as good as `idfs` though). Cheers, Sebastian [1]: The Fun of Programming, Chapter 9: Combinators for logic programming -- Underestimating the novelty of the future is a time-honored tradition. (D.G.) From ekmett at gmail.com Fri Nov 6 09:34:12 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Nov 6 09:10:17 2009 Subject: [Haskell-cafe] What's the new type ? In-Reply-To: <26208600.post@talk.nabble.com> References: <26208600.post@talk.nabble.com> Message-ID: <7fb8f82f0911060634v2b0345aaj711b094c78685c27@mail.gmail.com> Given a newtype declaration: newtype Foo a = Bar (...) The newtype is Foo a, and it uses a constructor Bar, which gets 'erased' at compile time, unlike a data declaration. By convention, usually Foo and Bar are the same thing. In this case the constructor for GenParser is named Parser instead. To understand the GenParser type, you must consider that originally, 'GenParser' probably didn't exist. And if it did, there is a pedagogical justification to just explaining the simpler 'Parser' case first without appealing to the notion of a parser in its full generality. So if you started from a type like newtype Parser a = Parser (State Char () -> Consumed (Reply Char () a)) and later want to generalize that to a more permissive signature, without breaking all of the code that uses that constructor, then the upgrade path for that code is to keep the same constructor name, but generalize the type. So Parser becomes a type alias: type Parser = GenParser Char () and GenParser is introduced as a newtype, which happens to use the constructor Parser for the dual reasons of backwards compatibility and so that people working on simple parsers don't need to think about alternative user state and token types. newtype GenParser tok st a = Parser (State tok st -> Consumed (Reply tok st a)) Now the only thing that breaks is that any code that previously defined instances for Parser before the notion of GenParser must add a LANGUAGE pragma indicating that TypeSynonymInstances are allowed. -Edward Kmett On Thu, Nov 5, 2009 at 2:17 AM, zaxis wrote: > > type Parser a = GenParser Char () a > newtype GenParser tok st a = Parser (State tok st -> Consumed (Reply tok st > a)) > > As i know, the Parser type is just an alias of GenParser. Then can the > second line be replaced as below? > > newtype GenParser tok st a = GenParser Char () (State tok st -> Consumed > (Reply tok st a)) > > If it can , then what is the new type ? > > Sincerely! > > ----- > fac n = foldr (*) 1 [1..n] > -- > View this message in context: > http://old.nabble.com/What%27s-the-new-type---tp26208600p26208600.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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091106/e42d4c58/attachment.html From eeoam at ukfsn.org Fri Nov 6 09:49:13 2009 From: eeoam at ukfsn.org (Eric Macaulay) Date: Fri Nov 6 09:25:20 2009 Subject: [Haskell-cafe] Parsing Haskell Message-ID: <20091106144918.23255DF267@mail.ukfsn.org> Hi all, I was hoping to use Language.Haskell.Parser to parse fragments of Haskell code. However, it appears that one can only use this module to parse complete Haskell programs. Is there anyway around this, or must I write a Haskell parser from scratch? Eric M. From ekmett at gmail.com Fri Nov 6 09:59:30 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Nov 6 09:35:32 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <7b501d5c0911051431u624ab25eg45b7f108ba0ea9bf@mail.gmail.com> References: <1257382324.5965.97.camel@idefix.localdomain> <4AF34DA6.2010701@btinternet.com> <7b501d5c0911051431u624ab25eg45b7f108ba0ea9bf@mail.gmail.com> Message-ID: <7fb8f82f0911060659j7eaae56fl68eab26163821f25@mail.gmail.com> I'm to blame for that page. I made the various 'greco'-morphisms from constructive algorithmics into independently combinable features in category-extras, and page spun out of a joke on the #haskell channel from people making fun of the ever more complicated recursion schemes I was supporting. It is a fairly useless technical term for a recursion scheme that no one in their right mind would use, but 'zygo-' 'histomorphic' and 'prepromorphism' all have real meanings. Each of these features can be composed. They are also fairly painfully abstract. A catamorphism is just a generalization of 'unfoldr' to arbitrary algebraic data types. A generalized catamorphism is a catamorphism that uses a distributive law for some comonad. A zygomorphism introduces mutual recursion with a helper function. It is just a generalized catamorphism using the reader/product comonad. However, in category-extras I defined 'comonad transformers', including a reader/product comonad transformer, so you can modify more complicated recursion schemes by adding 'zygo'. A histomorphism gives access to 'results obtained so far', and a prepromorphism is a modified catamorphism that also applies a natural transformation each time it recurses. This can be done by utilizing the fact that there is a "cofree comonad" for any functor f, which has a natural distributive law over f. So a histomorphism is just another generalized catamorphism. A prepromorphism is a slightly different animal, it applies a natural transformation each time it recurses. This lets you build up recursive operations like 'iterate' in a more formal manner. I generalized prepromorphisms, the way that you can generalize catamorphisms, allowing them to be parameterized on an arbitrary comonad. This means that all of the machinery you can use to parameterize your catamorphisms, can now be exploited to parameterize prepromorphism. Since you can apply the comonad transformer for reader to the cofree comonad of your base functor you can make a zygohistomorphic prepromorphism. The nice thing is that you can readily dualize each of these notions and start talking about the equivalent way to build UP a structure. One might argue that for consistency the name should be a zygohistoprepromorphism, but that starts to become unwieldy. The downside is that few people have read all of the papers to know what each of those terms mean in isolation, let alone when rolled into the same recursion scheme, so I wouldn't recommend using one in production maintainable code. =) -Edward Kmett On Thu, Nov 5, 2009 at 5:31 PM, Deniz Dogan wrote: > 2009/11/5 Andrew Coppin : > > Matus Tejiscak wrote: > >> > >> zygohistomorphic prepromorphisms > > > > Please tell me this isn't a real technical term. o_O > > http://www.haskell.org/haskellwiki/Zygohistomorphic_prepromorphisms > > Still can't tell if it's a joke or not... > > -- > Deniz Dogan > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091106/634f6dbc/attachment.html From john at n-brain.net Fri Nov 6 10:17:38 2009 From: john at n-brain.net (John A. De Goes) Date: Fri Nov 6 09:53:42 2009 Subject: [Haskell-cafe] Parsing Haskell In-Reply-To: <20091106144918.23255DF267@mail.ukfsn.org> References: <20091106144918.23255DF267@mail.ukfsn.org> Message-ID: <1A1E5117-676D-4632-B233-A2AC61E8E3E1@n-brain.net> You need a bottom-up parser to do fragment parsing. I'm not sure one exists for Haskell. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Nov 6, 2009, at 7:49 AM, Eric Macaulay wrote: > Hi all, > > I was hoping to use Language.Haskell.Parser to parse fragments of > Haskell code. However, it appears that one can only use this module > to parse complete Haskell programs. Is there anyway around this, or > must I write a Haskell parser from scratch? > > Eric M. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From stephen.tetley at gmail.com Fri Nov 6 10:29:47 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Fri Nov 6 10:05:49 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <7fb8f82f0911060659j7eaae56fl68eab26163821f25@mail.gmail.com> References: <1257382324.5965.97.camel@idefix.localdomain> <4AF34DA6.2010701@btinternet.com> <7b501d5c0911051431u624ab25eg45b7f108ba0ea9bf@mail.gmail.com> <7fb8f82f0911060659j7eaae56fl68eab26163821f25@mail.gmail.com> Message-ID: <5fdc56d70911060729r39fee9fap680bd51c5bfecd2@mail.gmail.com> Hello all, Are any of the of the more exotic recursion schemes definable without a least-fixed point /Mu/ type? The only definitions of zygomorphism etc. I've seen use it. Thanks Stephen From shelby at coolpage.com Fri Nov 6 10:39:21 2009 From: shelby at coolpage.com (Shelby Moore) Date: Fri Nov 6 10:15:24 2009 Subject: [Haskell-cafe] Memory Leak - Artificial Neural Network Message-ID: <2658.121.97.54.144.1257521961.squirrel@webmail3.pair.com> wren ng thornton wrote: http://www.haskell.org/pipermail/haskell-cafe/2009-November/068728.html >...use matrices/arrays rather than lists... >...even just using an unboxed array for the matrices > will make it much faster to traverse through... Matrix multiplication is the sequential order inner or outer product of the columns/rows of one matrix and rows/columns of 2nd matrix: http://en.wikipedia.org/wiki/Matrix_multiplication#Relationship_with_the_inner_product_and_the_outer_product Afaics, optimize matrix multiplication with lists. Random arrays incurs a huge performance penality in Haskell, unless you revert to non-lazy implementation, in which case you have voided multi-core speed ups for very large arrays (aren't ANNs huge matrices?). From paolo.losi at gmail.com Fri Nov 6 11:10:48 2009 From: paolo.losi at gmail.com (Paolo Losi) Date: Fri Nov 6 10:47:16 2009 Subject: [Haskell-cafe] Re: What's the deal with Clean? In-Reply-To: <20091104052506.GD15880@whirlpool.galois.com> References: <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> <4613CAAA-A646-427D-A0CD-975E493B7ABC@phys.washington.edu> <20091104051511.GA15880@whirlpool.galois.com> <58F6A0DB-9AB5-472B-A969-CECA6B110264@phys.washington.edu> <20091104052506.GD15880@whirlpool.galois.com> Message-ID: <4AF44A88.6090308@gmail.com> Don Stewart wrote: > I'd be happy to talk more about the design of the library, if you like. Don, I would be personally grateful if you could talk about the design of the library and/or point to some comprehensive documentation. Can you confirm that uvector is going to stay almost api compatible with dph, and that the knowledge investment is going to be "reusable" on dph? Paolo From lemming at henning-thielemann.de Fri Nov 6 11:13:06 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Nov 6 10:49:09 2009 Subject: [Haskell-cafe] ANNOUNCE: feldspar-language In-Reply-To: <4AF3B3E9.4040005@chalmers.se> References: <4AF0F78B.2090405@chalmers.se> <4AF3B3E9.4040005@chalmers.se> Message-ID: 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. From marlowsd at gmail.com Fri Nov 6 11:13:49 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Fri Nov 6 10:50:00 2009 Subject: [Haskell-cafe] Re: Parsing Haskell In-Reply-To: <1A1E5117-676D-4632-B233-A2AC61E8E3E1@n-brain.net> References: <20091106144918.23255DF267@mail.ukfsn.org> <1A1E5117-676D-4632-B233-A2AC61E8E3E1@n-brain.net> Message-ID: <4AF44B3D.1040905@gmail.com> On 06/11/2009 15:17, John A. De Goes wrote: > > You need a bottom-up parser to do fragment parsing. I'm not sure one > exists for Haskell. In Happy you can define multiple entry points to a grammar, which is how GHCi parses statements using the same parser that is used to parse complete modules. You'd have to modify the parser in haskell-src(-exts) to do add the entry points, though. Cheers, Simon From emax at chalmers.se Fri Nov 6 11:23:10 2009 From: emax at chalmers.se (Emil Axelsson) Date: Fri Nov 6 10:59:12 2009 Subject: [Haskell-cafe] ANNOUNCE: feldspar-language In-Reply-To: References: <4AF0F78B.2090405@chalmers.se> <4AF3B3E9.4040005@chalmers.se> Message-ID: <4AF44D6E.7010306@chalmers.se> 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. / Emil From niklas.broberg at gmail.com Fri Nov 6 11:23:48 2009 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Fri Nov 6 10:59:51 2009 Subject: [Haskell-cafe] Re: Parsing Haskell In-Reply-To: <4AF44B3D.1040905@gmail.com> References: <20091106144918.23255DF267@mail.ukfsn.org> <1A1E5117-676D-4632-B233-A2AC61E8E3E1@n-brain.net> <4AF44B3D.1040905@gmail.com> Message-ID: > You'd have to modify the parser in haskell-src(-exts) to do add the entry > points, though. Actually haskell-src-exts already defines entry points for Module, Stmt, Exp, Pat and Type (as well as [Module] in 1.3.x). Not sure if this message reaches the original poster though. Cheers, /Niklas From rl at cse.unsw.edu.au Fri Nov 6 11:32:18 2009 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Fri Nov 6 11:08:23 2009 Subject: [Haskell-cafe] Re: What's the deal with Clean? In-Reply-To: <4AF44A88.6090308@gmail.com> References: <4AF0A299.7010007@btinternet.com> <3e1162e60911031357w32443407uf9572d049c35ecf7@mail.gmail.com> <3e1162e60911031542y71ebd1f8y6a560279f0cf4206@mail.gmail.com> <8F3AB680-14B2-4E00-BD47-03113E839B54@aracnet.com> <4613CAAA-A646-427D-A0CD-975E493B7ABC@phys.washington.edu> <20091104051511.GA15880@whirlpool.galois.com> <58F6A0DB-9AB5-472B-A969-CECA6B110264@phys.washington.edu> <20091104052506.GD15880@whirlpool.galois.com> <4AF44A88.6090308@gmail.com> Message-ID: On 07/11/2009, at 03:10, Paolo Losi wrote: > Don Stewart wrote: >> I'd be happy to talk more about the design of the library, if you >> like. > > Don, > > I would be personally grateful if you could talk about the design of > the library and/or point to some comprehensive documentation. > > Can you confirm that uvector is going to stay almost api compatible > with dph, and that the knowledge investment is going to be "reusable" > on dph? uvector has (almost) nothing in common with DPH's API. It is forked off the flat sequential array layer which DPH uses internally and which the users aren't supposed to even know about. Also, the fork happened quite a while ago, DPH has changed a lot since then and is going to change a lot more in the future. My plan is to eventually use my vector package to replace those flat arrays but sadly I don't have a lot of time to work on it (although vector is quite usable by now and even implements recycling which should improve DPH's performance by quite a bit). The fact that everything DPH depends on will have to be distributed with GHC doesn't help, either, since adding a new package into the mix is a pretty big step. Roman From deb at pudlak.name Fri Nov 6 13:08:10 2009 From: deb at pudlak.name (Petr Pudlak) Date: Fri Nov 6 12:44:12 2009 Subject: [Haskell-cafe] a problem defining a monad instance Message-ID: <20091106180809.GA20150@pudlak.name> Hi all, (This is a literate Haskell post.) I've encountered a small problem when trying to define a specialized monad instance. Maybe someone will able to help me or to tell me that it's impossible :-). To elaborate: I wanted to define a data type which is a little bit similar to the [] monad. Instead of just having a list of possible outcomes of a computation, I wanted to have a probability associated with each possible outcome. A natural way to define such a structure is to use a map from possible values to numbers, let's say Floats: > module Distribution where > > import qualified Data.Map as M > > newtype Distrib a = Distrib { undistrib :: M.Map a Float } Defining functions to get a monad instance is not difficult. "return" is just a singleton: > dreturn :: a -> Distrib a > dreturn k = Distrib (M.singleton k 1) Composition is a little bit more difficult, but the functionality is quite natural. (I welcome suggestions how to make the code nicer / more readable.) However, the exact definition is not so important. > dcompose :: (Ord b) => Distrib a -> (a -> Distrib b) -> Distrib b > dcompose (Distrib m) f = Distrib $ M.foldWithKey foldFn M.empty m > where > foldFn a prob umap = M.unionWith (\psum p -> psum + prob * p) umap (undistrib $ f a) The problem is the (Ord b) condition, which is required for the Map functions. When I try to define the monad instance as > instance Monad Distrib where > return = dreturn > (>>=) = dcompose obviously, I get an error at (>>=): Could not deduce (Ord b) from the context. Is there some way around? Either to somehow define the monad, or to achieve the same functionality without using Map, which requires Ord instances? Thanks a lot, Petr From nccb2 at kent.ac.uk Fri Nov 6 13:19:56 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Fri Nov 6 12:55:57 2009 Subject: [Haskell-cafe] a problem defining a monad instance In-Reply-To: <20091106180809.GA20150@pudlak.name> References: <20091106180809.GA20150@pudlak.name> Message-ID: <4AF468CC.2080903@kent.ac.uk> Petr Pudlak wrote: > The problem is the (Ord b) condition, which is required for the Map > functions. When I try to define the monad instance as >> instance Monad Distrib where >> return = dreturn >> (>>=) = dcompose >> > obviously, I get an error at (>>=): > Could not deduce (Ord b) from the context. > > Is there some way around? Either to somehow define the monad, or to > achieve the same functionality without using Map, which requires Ord > instances? > Not being allowed constraints on the variables for class methods is probably the problem I have most frequently run into recently in Haskell (is there any way to fix this, or does it open up a whole can of worms?). There is no easy way around it, but for your problem, do you require that the items be kept unique as you go along? Could you not use a list of items with probabilities -- that can potentially contain duplicate items (but all the summed probabilities should add to one at every stage, presumably), and then combine them at the end? i.e. your code would look like: newtype Distrib a = Distrib { undistrib :: [(a, Float)] } runDistrib :: Ord a => Distrib a -> Map.Map a Float runDistrib = Map.fromListWith (+) . undistrib This would push the Ord constraint to runDistrib, and allow you to leave it off (>>=). Neil. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091106/50088a9a/attachment.html From sjoerd at w3future.com Fri Nov 6 13:28:36 2009 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Fri Nov 6 13:04:39 2009 Subject: [Haskell-cafe] a problem defining a monad instance In-Reply-To: <20091106180809.GA20150@pudlak.name> References: <20091106180809.GA20150@pudlak.name> Message-ID: <0AF755F3-BE74-4E97-92E6-3A51DAFEE924@w3future.com> You cannot make it an instance of Monad, but you can use do syntax: {-# LANGUAGE NoImplicitPrelude #-} module Distribution where import Prelude hiding (return, (>>=)) import qualified Data.Map as M newtype Distrib a = Distrib { undistrib :: M.Map a Float } deriving Show return :: a -> Distrib a return k = Distrib (M.singleton k 1) (>>=) :: (Ord b) => Distrib a -> (a -> Distrib b) -> Distrib b Distrib m >>= f = Distrib $ M.foldWithKey foldFn M.empty m where foldFn a prob umap = M.unionWith (\psum p -> psum + prob * p) umap (undistrib $ f a) test = do a <- Distrib $ M.fromList [(1, 1), (2, 1)] b <- Distrib $ M.fromList [(10, 1), (20, 1)] return (a + b) Sjoerd On Nov 6, 2009, at 7:08 PM, Petr Pudlak wrote: > Hi all, > > (This is a literate Haskell post.) > > I've encountered a small problem when trying to define a specialized > monad instance. Maybe someone will able to help me or to tell me that > it's impossible :-). > > To elaborate: I wanted to define a data type which is a little bit > similar to the [] monad. Instead of just having a list of possible > outcomes of a computation, I wanted to have a probability associated > with each possible outcome. > > A natural way to define such a structure is to use a map from possible > values to numbers, let's say Floats: > >> module Distribution where >> >> import qualified Data.Map as M >> >> newtype Distrib a = Distrib { undistrib :: M.Map a Float } > > Defining functions to get a monad instance is not difficult. > "return" is just a singleton: > >> dreturn :: a -> Distrib a >> dreturn k = Distrib (M.singleton k 1) > > Composition is a little bit more difficult, but the functionality is > quite natural. (I welcome suggestions how to make the code nicer / > more > readable.) However, the exact definition is not so important. > >> dcompose :: (Ord b) => Distrib a -> (a -> Distrib b) -> Distrib b >> dcompose (Distrib m) f = Distrib $ M.foldWithKey foldFn M.empty m >> where >> foldFn a prob umap = M.unionWith (\psum p -> psum + prob * p) >> umap (undistrib $ f a) > > The problem is the (Ord b) condition, which is required for the Map > functions. When I try to define the monad instance as > >> instance Monad Distrib where >> return = dreturn >> (>>=) = dcompose > > obviously, I get an error at (>>=): > Could not deduce (Ord b) from the context. > > Is there some way around? Either to somehow define the monad, or to > achieve the same functionality without using Map, which requires Ord > instances? > > Thanks a lot, > Petr > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Sjoerd Visscher sjoerd@w3future.com From tomahawkins at gmail.com Fri Nov 6 13:35:30 2009 From: tomahawkins at gmail.com (Tom Hawkins) Date: Fri Nov 6 13:11:31 2009 Subject: [Haskell-cafe] ANNOUNCE: feldspar-language In-Reply-To: <4AF3B3E9.4040005@chalmers.se> References: <4AF0F78B.2090405@chalmers.se> <4AF3B3E9.4040005@chalmers.se> Message-ID: <594c1e830911061035m75e98ebbv2dbb33a19125bdca@mail.gmail.com> On Fri, Nov 6, 2009 at 6:28 AM, Emil Axelsson wrote: >> >> 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. Atom may be another option. Though it is not intended for high performance DSP, we do use it for basic signal processing. Here is an IIR filter that is used is some fault detection logic on our application: -- | IIR filter implemented using direct form 2. iirFilter :: Name -> Float -> [(Float, Float)] -> E Float -> Atom (E Float) iirFilter name b0 coeffs x = do -- Create the filter taps. vs <- mapM (\ i -> float (name ++ show i) 0) [1 .. length coeffs] -- Cascade the filter taps together. mapM_ (\ (vA, vB) -> vA <== value vB) $ zip (tail vs) vs -- Calculate the input to the chain of taps. let w0 = sum ( x : [ (value v) * Const (-a) | (v, (a, _)) <- zip vs coeffs ]) bs = b0 : (snd $ unzip coeffs) ws = w0 : map value vs us = [ w * Const b | (w, b) <- zip ws bs ] head vs <== w0 -- Return the output. return $ sum us http://hackage.haskell.org/package/atom From miguelimo38 at yandex.ru Fri Nov 6 13:40:15 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Fri Nov 6 13:16:24 2009 Subject: [Haskell-cafe] a problem defining a monad instance In-Reply-To: <20091106180809.GA20150@pudlak.name> References: <20091106180809.GA20150@pudlak.name> Message-ID: The usual continuation trick: fromDistrib :: Ord a => Distrib a -> Cont (Distrib r) a fromDistrib da = Cont (\c -> dcompose da c) toDistrib :: Cont (Distrib r) r -> Distrib r toDistrib (Cont f) = f dreturn "Cont anything" is a monad. On 6 Nov 2009, at 21:08, Petr Pudlak wrote: > Hi all, > > (This is a literate Haskell post.) > > I've encountered a small problem when trying to define a specialized > monad instance. Maybe someone will able to help me or to tell me that > it's impossible :-). > > To elaborate: I wanted to define a data type which is a little bit > similar to the [] monad. Instead of just having a list of possible > outcomes of a computation, I wanted to have a probability associated > with each possible outcome. > > A natural way to define such a structure is to use a map from possible > values to numbers, let's say Floats: > >> module Distribution where >> >> import qualified Data.Map as M >> >> newtype Distrib a = Distrib { undistrib :: M.Map a Float } > > Defining functions to get a monad instance is not difficult. > "return" is just a singleton: > >> dreturn :: a -> Distrib a >> dreturn k = Distrib (M.singleton k 1) > > Composition is a little bit more difficult, but the functionality is > quite natural. (I welcome suggestions how to make the code nicer / > more > readable.) However, the exact definition is not so important. > >> dcompose :: (Ord b) => Distrib a -> (a -> Distrib b) -> Distrib b >> dcompose (Distrib m) f = Distrib $ M.foldWithKey foldFn M.empty m >> where >> foldFn a prob umap = M.unionWith (\psum p -> psum + prob * p) >> umap (undistrib $ f a) > > The problem is the (Ord b) condition, which is required for the Map > functions. When I try to define the monad instance as > >> instance Monad Distrib where >> return = dreturn >> (>>=) = dcompose > > obviously, I get an error at (>>=): > Could not deduce (Ord b) from the context. > > Is there some way around? Either to somehow define the monad, or to > achieve the same functionality without using Map, which requires Ord > instances? > > Thanks a lot, > Petr > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From dagit at codersbase.com Fri Nov 6 14:15:44 2009 From: dagit at codersbase.com (Jason Dagit) Date: Fri Nov 6 13:51:45 2009 Subject: [Haskell-cafe] a problem defining a monad instance In-Reply-To: <4AF468CC.2080903@kent.ac.uk> References: <20091106180809.GA20150@pudlak.name> <4AF468CC.2080903@kent.ac.uk> Message-ID: On Fri, Nov 6, 2009 at 10:19 AM, Neil Brown wrote: > Petr Pudlak wrote: > > The problem is the (Ord b) condition, which is required for the Map > functions. When I try to define the monad instance as > > instance Monad Distrib where > return = dreturn > (>>=) = dcompose > > > obviously, I get an error at (>>=): > Could not deduce (Ord b) from the context. > > Is there some way around? Either to somehow define the monad, or to > achieve the same functionality without using Map, which requires Ord > instances? > > > Not being allowed constraints on the variables for class methods is > probably the problem I have most frequently run into recently in Haskell (is > there any way to fix this, or does it open up a whole can of worms?). > I believe this paper is intended to propose a solution: http://tomschrijvers.blogspot.com/2009/11/haskell-type-constraints-unleashed.html Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091106/7e781819/attachment.html From jake.mcarthur at gmail.com Fri Nov 6 14:36:41 2009 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Fri Nov 6 14:13:05 2009 Subject: [Haskell-cafe] a problem defining a monad instance In-Reply-To: <20091106180809.GA20150@pudlak.name> References: <20091106180809.GA20150@pudlak.name> Message-ID: <4AF47AC9.9080600@gmail.com> Petr Pudlak wrote: > The problem is the (Ord b) condition, which is required for the Map > functions. When I try to define the monad instance as > >> instance Monad Distrib where >> return = dreturn >> (>>=) = dcompose > > obviously, I get an error at (>>=): > Could not deduce (Ord b) from the context. This is the same reason we do not have e.g. a Monad instance for Set. One solution is a concept of "restricted" monads, and one implementation of restricted monads is given here: http://okmij.org/ftp/Haskell/types.html#restricted-datatypes - Jake From abemud at gmail.com Fri Nov 6 16:31:58 2009 From: abemud at gmail.com (Jian Fan) Date: Fri Nov 6 16:08:22 2009 Subject: [Haskell-cafe] cabal install on Windows Message-ID: Does cabal install --user or --prefix work on Windows at all? I tried: cabal install colour --user cabal install --user colour etc and all failed because install try to install at c:Program Files which I don't have permission writing. I have: cabal-install version 0.6.2 using version 1.6.0.3 of the Cabal library The Glorious Glasgow Haskell Compilation System, version 6.10.4 Thanks Jian ~ ~ ~ ~ ~ ~ From haskell at colquitt.org Fri Nov 6 16:35:49 2009 From: haskell at colquitt.org (John Dorsey) Date: Fri Nov 6 16:11:53 2009 Subject: [Haskell-cafe] ANNOUNCE: NetSNMP-0.1.6 Message-ID: <20091106213549.GB23495@colquitt.org> I'm pleased to annonce the release of NetSNMP-0.1.6, a partial (but useful) binding to the net-snmp library.[1] NetSNMP is a simple and self-contained client interface for doing basic SNMP GET, NEXT, and WALK operations. As far as I know it should work with any version of the C library (net-snmp) from version 5. This release improves threaded performance, and the management of foreign memory objects. I've been using it successfully in a threaded polling daemon which I'm running on 32-bit and 64-bit Linux systems. If you try out NetSNMP, or if you decide it doesn't meet your need, please drop me a line! Regards, John Dorsey From doaitse at swierstra.net Fri Nov 6 17:03:16 2009 From: doaitse at swierstra.net (S. Doaitse Swierstra) Date: Fri Nov 6 16:39:19 2009 Subject: [Haskell-cafe] Parsing Haskell In-Reply-To: <20091106144918.23255DF267@mail.ukfsn.org> References: <20091106144918.23255DF267@mail.ukfsn.org> Message-ID: <1B8924A6-3621-4441-9175-A6702CF3DD8C@swierstra.net> The UHC compiler contains a combinator based Haskell parser from which you can borrow fragments, Doaitse Swierstra On 6 nov 2009, at 15:49, Eric Macaulay wrote: > Hi all, > > I was hoping to use Language.Haskell.Parser to parse fragments of > Haskell code. However, it appears that one can only use this module > to parse complete Haskell programs. Is there anyway around this, or > must I write a Haskell parser from scratch? > > Eric M. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From byorgey at seas.upenn.edu Fri Nov 6 17:05:42 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Fri Nov 6 16:41:43 2009 Subject: [Haskell-cafe] ANN: MonadRandom-0.1.4 Message-ID: <20091106220542.GA22609@seas.upenn.edu> Just a quick note: I've uploaded a new version of the MonadRandom which adds Applicative instances for Rand and RandT. Now you can write your random code in an applicative style! -Brent From tittoassini at gmail.com Fri Nov 6 17:08:59 2009 From: tittoassini at gmail.com (Pasqualino "Titto" Assini) Date: Fri Nov 6 16:45:03 2009 Subject: [Haskell-cafe] Is () a 0-length tuple? Message-ID: <2d34474e0911061408od1c1d65xb5a41cd6ee0892dc@mail.gmail.com> Hi, I just noticed that the json library maps () to a JSON empty array: []. This makes sense if () is a 0-length tuple, the (2,"hi") tuple for example maps to [2,"hi"] But is it so in Haskell? In what sense () is a 0-length tuple? Thanks, titto From byorgey at seas.upenn.edu Fri Nov 6 17:09:41 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Fri Nov 6 16:45:42 2009 Subject: [Haskell-cafe] a problem defining a monad instance In-Reply-To: <20091106180809.GA20150@pudlak.name> References: <20091106180809.GA20150@pudlak.name> Message-ID: <20091106220941.GB22609@seas.upenn.edu> On Fri, Nov 06, 2009 at 07:08:10PM +0100, Petr Pudlak wrote: > Hi all, > > (This is a literate Haskell post.) > > I've encountered a small problem when trying to define a specialized > monad instance. Maybe someone will able to help me or to tell me that > it's impossible :-). See the rmonad package on Hackage, which solves exactly this problem: http://hackage.haskell.org/package/rmonad -Brent From rmm-haskell at z.odi.ac Fri Nov 6 17:13:59 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Fri Nov 6 16:50:07 2009 Subject: [Haskell-cafe] Is () a 0-length tuple? In-Reply-To: <2d34474e0911061408od1c1d65xb5a41cd6ee0892dc@mail.gmail.com> References: <2d34474e0911061408od1c1d65xb5a41cd6ee0892dc@mail.gmail.com> Message-ID: It is kind of a 0-length tuple, if you squint, though it's usually called "unit". Each tuple type is entirely distinct from each other, so there's nothing that indicates that something is a tuple except for the spelling -- (a,b,c). For example, unlike python, there is no way to determine the length of a tuple at runtime (e.g. length ()) nor iterate at runtime (as the types are heterogeneous). -Ross On Nov 6, 2009, at 5:08 PM, Pasqualino Titto Assini wrote: > Hi, > > I just noticed that the json library maps () to a JSON empty array: > []. > > This makes sense if () is a 0-length tuple, the (2,"hi") tuple for > example maps to [2,"hi"] > > But is it so in Haskell? > > In what sense () is a 0-length tuple? > > Thanks, > > titto > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From sebf at informatik.uni-kiel.de Fri Nov 6 17:21:00 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Fri Nov 6 16:57:09 2009 Subject: [Haskell-cafe] Fair diagonals In-Reply-To: <091B57D2-A785-460C-A401-15495F14DF6F@informatik.uni-kiel.de> References: <4AF095D0.9030105@van.steenbergen.nl> <44F139D4-0B29-42A1-8D45-EF80333DB182@w3future.com> <4AF18DFA.7020602@gmail.com> <3B0A27AE-F76F-4F38-AD4D-8561007B6595@w3future.com> <4AF3F529.1010403@van.steenbergen.nl> <7ca3f0160911060217l33925bc6i712b226d6c60da5e@mail.gmail.com> <4AF3FAE5.6030507@van.steenbergen.nl> <091B57D2-A785-460C-A401-15495F14DF6F@informatik.uni-kiel.de> Message-ID: Hello, Sjoerd's intuition to reuse a nondeterminism monad in order to implement fair diagonalisation was insightful and one can implement a diagonalisation function that satisfies the property diagonal (map (:[]) xs) == xs for all (even infinite) lists `xs` using the level monad. Here is how. Start with a convoluted definition of `concat` that uses a list comprehension which does nothing: flatten :: [[a]] -> [a] flatten xss = concat [ [ x | x <- xs ] | xs <- xss ] Now, generalise this definition to an arbitrary nondeterminism monad by translating list comprehension syntax into do notation: merge :: MonadPlus m => [[a]] -> m a merge xss = join(do xs<-anyOf xss;return(do x<-anyOf xs;return x)) The `anyOf` function is a generalisation of `Data.FMList.fromList` and `Control.Monad.Omega.each` that is not specific to a specific nondeterminism monad: anyOf :: MonadPlus m => [a] -> m a anyOf = msum . map return In the list monad `merge` is equivalent to `flatten` but different monads merge the lists in different orders. It turns out that `merge` implements diagonalisation in the level monad. The pointfree program [1] knows how to simplify the body of `merge`: # pointfree -v "\xss->join(anyOf xss>>=\xs->return(anyOf xs>>=\x- >return x))" Transformed to pointfree style: join . flip ((>>=) . anyOf) (return . flip ((>>=) . anyOf) return) Optimized expression: join . flip ((>>=) . anyOf) (return . flip ((>>=) . anyOf) return) join . (>>= return . flip ((>>=) . anyOf) return) . anyOf join . (return . flip ((>>=) . anyOf) return =<<) . anyOf join . (return . (>>= return) . anyOf =<<) . anyOf join . (return . (return =<<) . anyOf =<<) . anyOf join . (return . id . anyOf =<<) . anyOf join . (return . anyOf =<<) . anyOf join . (anyOf `fmap`) . anyOf (anyOf =<<) . anyOf Now, specialise for the level monad to get fair diagonalisation: diagonal :: [[a]] -> [a] diagonal = bfs . (>>= fromList) . fromList A quick check shows that this function really works for infinite lists: ghci> take 10 $ diagonal [[(x,y) | y <- [1..]] | x <- [1..]] [(1,1),(1,2),(2,1),(1,3),(2,2),(3,1),(1,4),(2,3),(3,2),(4,1)] SmallCheck [2] helps to recognise that the omega monad produces a different order on some inputs: ghci> bfs (anyOf [[1,2,3],[],[],[4]] >>= anyOf) [1,2,3,4] ghci> runOmega (anyOf [[1,2,3],[],[],[4]] >>= anyOf) [1,2,4,3] In this example, each number n is on the nth diagonal of the corresponding matrix. Unlike in the omega monad, `merge` faithfully implements diagonalisation in the level monad. Cheers, Sebastian [1]: http://hackage.haskell.org/package/pointfree [2]: http://hackage.haskell.org/package/smallcheck -- Underestimating the novelty of the future is a time-honored tradition. (D.G.) From byorgey at seas.upenn.edu Fri Nov 6 17:25:06 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Fri Nov 6 17:01:07 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <5fdc56d70911060729r39fee9fap680bd51c5bfecd2@mail.gmail.com> References: <1257382324.5965.97.camel@idefix.localdomain> <4AF34DA6.2010701@btinternet.com> <7b501d5c0911051431u624ab25eg45b7f108ba0ea9bf@mail.gmail.com> <7fb8f82f0911060659j7eaae56fl68eab26163821f25@mail.gmail.com> <5fdc56d70911060729r39fee9fap680bd51c5bfecd2@mail.gmail.com> Message-ID: <20091106222506.GC22609@seas.upenn.edu> On Fri, Nov 06, 2009 at 03:29:47PM +0000, Stephen Tetley wrote: > Hello all, > > Are any of the of the more exotic recursion schemes definable without > a least-fixed point /Mu/ type? Note that Haskell datatypes have a built-in implicit "mu" (that is, every recursive Haskell datatype can be thought of as the fixed point of some suitable functor); the "Mu" type you see in the types of those recursion schemes just makes the knot-tying explicit. Given any particular recursive type, it should be possible to implement any of the recursion schemes specifically for that type without mentioning Mu. However, to write recursion schemes that work generally over *any* recursive type (aside from generic programming techniques) requires the explicit use of the Mu type, because you need to be able to refer to the functor of which the recursive type is a fixed point, and there's no (easy) way to take a recursive Haskell data type and "unfix" it to get the underlying structure functor. -Brent From haskell at colquitt.org Fri Nov 6 17:38:57 2009 From: haskell at colquitt.org (John Dorsey) Date: Fri Nov 6 17:14:59 2009 Subject: [Haskell-cafe] Is () a 0-length tuple? In-Reply-To: <2d34474e0911061408od1c1d65xb5a41cd6ee0892dc@mail.gmail.com> References: <2d34474e0911061408od1c1d65xb5a41cd6ee0892dc@mail.gmail.com> Message-ID: <20091106223857.GC23495@colquitt.org> > In what sense () is a 0-length tuple? In what sense isn't it? Data.Tuple is much to narrow to be of any use here. () is in at least most, if not all, of the type classes that tuples are in. The syntax is strikingly similar. If you ask me, it walks/quacks/smells like a duck, so it's a duck. Regards, John From z_axis at 163.com Fri Nov 6 19:53:00 2009 From: z_axis at 163.com (zaxis) Date: Fri Nov 6 19:29:02 2009 Subject: [Haskell-cafe] What's the new type ? In-Reply-To: <7fb8f82f0911060634v2b0345aaj711b094c78685c27@mail.gmail.com> References: <26208600.post@talk.nabble.com> <7fb8f82f0911060634v2b0345aaj711b094c78685c27@mail.gmail.com> Message-ID: <26233954.post@talk.nabble.com> very clear ! thank you edwardk wrote: > > Given a newtype declaration: > > newtype Foo a = Bar (...) > > The newtype is Foo a, and it uses a constructor Bar, which gets 'erased' > at > compile time, unlike a data declaration. By convention, usually Foo and > Bar > are the same thing. In this case the constructor for GenParser is named > Parser instead. > > To understand the GenParser type, you must consider that originally, > 'GenParser' probably didn't exist. And if it did, there is a pedagogical > justification to just explaining the simpler 'Parser' case first without > appealing to the notion of a parser in its full generality. > > So if you started from a type like > > newtype Parser a = Parser (State Char () -> Consumed (Reply Char () a)) > > and later want to generalize that to a more permissive signature, without > breaking all of the code that uses that constructor, then the upgrade path > for that code is to keep the same constructor name, but generalize the > type. > > So Parser becomes a type alias: > > type Parser = GenParser Char () > > and GenParser is introduced as a newtype, which happens to use the > constructor Parser for the dual reasons of backwards compatibility and so > that people working on simple parsers don't need to think about > alternative > user state and token types. > > newtype GenParser tok st a = Parser (State tok st -> Consumed (Reply tok > st > a)) > > Now the only thing that breaks is that any code that previously defined > instances for Parser before the notion of GenParser must add a LANGUAGE > pragma indicating that TypeSynonymInstances are allowed. > > -Edward Kmett > > On Thu, Nov 5, 2009 at 2:17 AM, zaxis wrote: > >> >> type Parser a = GenParser Char () a >> newtype GenParser tok st a = Parser (State tok st -> Consumed (Reply tok >> st >> a)) >> >> As i know, the Parser type is just an alias of GenParser. Then can the >> second line be replaced as below? >> >> newtype GenParser tok st a = GenParser Char () (State tok st -> Consumed >> (Reply tok st a)) >> >> If it can , then what is the new type ? >> >> Sincerely! >> >> ----- >> fac n = foldr (*) 1 [1..n] >> -- >> View this message in context: >> http://old.nabble.com/What%27s-the-new-type---tp26208600p26208600.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 mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ----- fac n = foldr (*) 1 [1..n] -- View this message in context: http://old.nabble.com/What%27s-the-new-type---tp26208600p26233954.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From z_axis at 163.com Fri Nov 6 19:55:48 2009 From: z_axis at 163.com (zaxis) Date: Fri Nov 6 19:31:47 2009 Subject: [Haskell-cafe] What's the new type ? In-Reply-To: <7fb8f82f0911060634v2b0345aaj711b094c78685c27@mail.gmail.com> References: <26208600.post@talk.nabble.com> <7fb8f82f0911060634v2b0345aaj711b094c78685c27@mail.gmail.com> Message-ID: <26234071.post@talk.nabble.com> very clear ! thank you edwardk wrote: > > Given a newtype declaration: > > newtype Foo a = Bar (...) > > The newtype is Foo a, and it uses a constructor Bar, which gets 'erased' > at > compile time, unlike a data declaration. By convention, usually Foo and > Bar > are the same thing. In this case the constructor for GenParser is named > Parser instead. > > To understand the GenParser type, you must consider that originally, > 'GenParser' probably didn't exist. And if it did, there is a pedagogical > justification to just explaining the simpler 'Parser' case first without > appealing to the notion of a parser in its full generality. > > So if you started from a type like > > newtype Parser a = Parser (State Char () -> Consumed (Reply Char () a)) > > and later want to generalize that to a more permissive signature, without > breaking all of the code that uses that constructor, then the upgrade path > for that code is to keep the same constructor name, but generalize the > type. > > So Parser becomes a type alias: > > type Parser = GenParser Char () > > and GenParser is introduced as a newtype, which happens to use the > constructor Parser for the dual reasons of backwards compatibility and so > that people working on simple parsers don't need to think about > alternative > user state and token types. > > newtype GenParser tok st a = Parser (State tok st -> Consumed (Reply tok > st > a)) > > Now the only thing that breaks is that any code that previously defined > instances for Parser before the notion of GenParser must add a LANGUAGE > pragma indicating that TypeSynonymInstances are allowed. > > -Edward Kmett > > On Thu, Nov 5, 2009 at 2:17 AM, zaxis wrote: > >> >> type Parser a = GenParser Char () a >> newtype GenParser tok st a = Parser (State tok st -> Consumed (Reply tok >> st >> a)) >> >> As i know, the Parser type is just an alias of GenParser. Then can the >> second line be replaced as below? >> >> newtype GenParser tok st a = GenParser Char () (State tok st -> Consumed >> (Reply tok st a)) >> >> If it can , then what is the new type ? >> >> Sincerely! >> >> ----- >> fac n = foldr (*) 1 [1..n] >> -- >> View this message in context: >> http://old.nabble.com/What%27s-the-new-type---tp26208600p26208600.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 mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ----- fac n = foldr (*) 1 [1..n] -- View this message in context: http://old.nabble.com/What%27s-the-new-type---tp26208600p26234071.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From klondikehaskellcafe at xiscosoft.es Fri Nov 6 20:54:26 2009 From: klondikehaskellcafe at xiscosoft.es (klondike) Date: Fri Nov 6 20:30:31 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: control-monad-exception 0.5 with monadic call traces In-Reply-To: References: <4AF02F06.2030105@henning-thielemann.de> Message-ID: <4AF4D352.1090107@xiscosoft.es> Henning Thielemann escribi?: > That's what I meant with my post: Programming errors (like "head []") > are not handled by control-monad-exception. As far as I understand, > control-monad-exception makes _exceptions_ explicit in the type > signatures, not programming errors. Why and how would you make > possible programming errors explicit in the type? But for exceptions > (e.g. "file could not be found") a detailed stack trace is not of much > use. I think you have overlooked a few things. First, not every developer knows each one of the lines in the code well enough as to see where a exception comes from, specially when you are not the author of that code. Of course, that wouldn't mind so much unless you see another thing, if we don't know which exceptions can be launched by a operation then you will get it on the upper frame and rendered unable to solve it. Use typed exceptions (as this library intends to) you may say. Ok, now we have another problem, the strange habit of coders to keep the exceptions they don't know/can't treat going up and up and up, until then usually hit the top frame and you are screwed. You can check some Java code (to see an example on how this happens) as some of these exceptional conditions are put on the method's signature. About detecting programming errors making them explicit on the type you can use IOized versions of the dangerous functions and use a special Exception type for them which would, usually, be caught at the top frame then showed. > It seems again to me, that mixing of (programming) errors and > exceptions is going on, and I assumed that the purpose of > control-monad-exception is to separate them in a better way. You know, could you tell me when using head on an empty list is a programming error and when it is a exception, I have seen both cases... -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 262 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091106/cd48ebbb/signature.bin From jfredett at gmail.com Sat Nov 7 01:04:45 2009 From: jfredett at gmail.com (jfredett@gmail.com) Date: Sat Nov 7 00:40:46 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 138 - November 07, 2009 Message-ID: <4af50dfd.9653f10a.68f4.2d64@mx.google.com> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20091107 Issue 138 - November 07, 2009 --------------------------------------------------------------------------- Welcome to issue 138 of HWN, a newsletter covering developments in the [1]Haskell community. Lots of discussion about [2]Clean this week. As well there was a new DSL, feldspar, announced. It deals with digital signal processing applications. Announcements MonadRandom-0.1.4. Brent Yorgey [3]announced a new version of MonadRandom which adds applicative instances for Rand and RantT, so you can write your code in applicative style. Criterion 0.2, an improved Haskell benchmarking library. Bryan O'Sullivan [4]announced a new version of Criterion, all the details of this release are available on his [5]blog feldspar-language. Emil Axelsson [6]announced feldspar, a DSL for digital signal processing. feldspar-compiler. Emil Axelsson [7]announced the C code backend for the `feldspar` language. fdo-notify 0.1, a client for the Desktop Notifications protocol. Max Rabkin [8]announced a library for FreeDesktop.org's Desktop Notifications Protocol. language-python version 0.2 now available. Bernie Pope [9]announced a new version of the language-python package, which provides an AST and parser for Python 2.x-3.x (previously, only 3.x was supported). timeplot. Eugene Kirpichov [10]announced timeplot, which is useful visualizing log files. Singapore FP Users Group First Meeting. Max Cantor [11]announced the first meeting of the Singapore FP Users Group, it will be Monday, November 2nd at 6pm. Advgame 0.1.1. Tim Wawrzynczak [12]announced his port of Conrad Barski's 'Casting SPELs in Lisp' to Haskell. BlogLiterately-0.2. Robert Greayer [13]announced version 0.2 of BlogLiterately, a simple tool for uploading posts written in markdown and Literate Haskell to blogs. haskell-mode 2.6. Svein Ove Aas [14]announced a bugfix release of the Emac's Haskell mode. Discussion A Problem Defining a Monad instance. Petr Pudlak [15]asked about how to defined an instance of the Monad class for a monad whose argument is restricted by another typeclass. Point Free Case Expressions. Sebastiaan Visser [16]suggested that a new syntax be added for 'point-free' case expressions. Master's thesis topic sought. Matus Tejiscak [17]asked for suggestions for possible Master's Thesis topics. What's the deal with Clean? Deniz Dogan [18]asked about the recent discussion on the -cafe list about Clean, another Pure, Lazy, Strictly Typed language. Blog noise [19]Haskell news from the [20]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Neil Brown: [21]Text.Printf and monad transformers. * Bryan O'Sullivan: [22]Criterion 0.2, an improved Haskell benchmarking library. * Galois, Inc: [23]Tech Talk: Hoare-Logic â fiddly details and small print. * Gtk2HS: [24]Writing concurrent programs.. * Tom Schrijvers: [25]Postdoc/PhD Positions on the Monadic Constraint Programming project. * Darcs: [26]darcs weekly news #45. * Tom Schrijvers: [27]Haskell Type Constraints unleashed. * Luke Plant: [28]Building GHC is fun.... * Manuel M T Chakravarty: [29]Status Update of the Glasgow Haskell Compiler, October 2009. * Chris Smith: [30]Monads from Two Perspectives. * Neil Brown: [31]Concurrent Testing and Tracing: Useful Output for Test Failures. * Dan Piponi (sigfpe): [32]Buffon's Needle, the Easy Way. Buffon's needle is a popular probability problem. Rule lines on the floor a distance d apart and toss a needle of length l Quotes of the Week * blackdog: [About Hubris] I tell the Ruby guys that Haskell will help them speed up their Ruby code and keep their apps going, and I tell Haskell guys that it'll Trojan Horse those poor unsuspecting rubyists... * lispy: Great, I leave the channel for a few hours and suddenly Haskell has a new found work ethic. * roconnor: ivanm: I will keep the fail in the code * lament: just remember to ask, 'What are your questions', as opposed to 'Do you have any questions' * mauke: @unpl const (flip const) lambdabot: (\ _ c d -> d) About the Haskell Weekly News New editions are posted to [33]the Haskell mailing list as well as to [34]the Haskell Sequence and [35]Planet Haskell. [36]RSS is also available, and headlines appear on [37]haskell.org. To help create new editions of this newsletter, please see the information on [38]how to contribute. Send stories to jfredett . at . gmail . dot . com. The darcs repository is available at darcs get [39]http://patch-tag.com/r/jfredett/HWN2/pullrepo HWN2 . References 1. http://haskell.org/ 2. http://en.wikipedia.org/wiki/Clean_(programming_language) 3. http://article.gmane.org/gmane.comp.lang.haskell.cafe/65844 4. http://article.gmane.org/gmane.comp.lang.haskell.cafe/65813 5. http://www.serpentine.com/blog/2009/11/06/criterion-0-2-an-improved-haskell-benchmarking-library/ 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/65617 7. http://article.gmane.org/gmane.comp.lang.haskell.cafe/65741 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/65686 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/65656 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/65575 11. http://article.gmane.org/gmane.comp.lang.haskell.cafe/65471 12. http://article.gmane.org/gmane.comp.lang.haskell.cafe/65462 13. http://article.gmane.org/gmane.comp.lang.haskell.cafe/65567 14. http://article.gmane.org/gmane.comp.lang.haskell.cafe/65487 15. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/65834 16. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/65750 17. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/65706 18. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/65589 19. http://planet.haskell.org/ 20. http://haskell.org/haskellwiki/Blog_articles 21. http://chplib.wordpress.com/2009/11/06/text-printf-and-monad-transformers/ 22. http://www.serpentine.com/blog/2009/11/06/criterion-0-2-an-improved-haskell-benchmarking-library/ 23. http://www.galois.com/blog/2009/11/04/chapman-hoare/ 24. http://haskell.org/gtk2hs/archives/2009/11/04/writing-concurrent-programs/ 25. http://tomschrijvers.blogspot.com/2009/11/postdocphd-positions-on-monadic.html 26. http://blog.darcs.net/2009/11/darcs-weekly-news-45.html 27. http://tomschrijvers.blogspot.com/2009/11/haskell-type-constraints-unleashed.html 28. http://lukeplant.me.uk/blog.php?id=1107301703 29. http://justtesting.org/post/232566357 30. http://cdsmith.wordpress.com/2009/11/02/monads-from-two-perspectives/ 31. http://chplib.wordpress.com/2009/11/02/concurrent-testing-and-tracing-useful-output-for-test-failures/ 32. http://blog.sigfpe.com/2009/10/buffons-needle-easy-way.html 33. http://www.haskell.org/mailman/listinfo/haskell 34. http://sequence.complete.org/ 35. http://planet.haskell.org/ 36. http://sequence.complete.org/node/feed 37. http://haskell.org/ 38. http://haskell.org/haskellwiki/HWN 39. http://patch-tag.com/r/jfredett/HWN2/pullrepo%20HWN2 From felipe.lessa at gmail.com Sat Nov 7 04:31:18 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Nov 7 04:07:23 2009 Subject: [Haskell-cafe] [Haskell-beginners] Re: Is Haskell for me? Message-ID: <20091107093118.GD26690@kira.casa> Sorry for not sending to the list. ----- Forwarded message from Felipe Lessa ----- On Fri, Nov 06, 2009 at 07:58:30PM -0200, Felipe Lessa wrote: > On 11/6/09, Gaius Hammond wrote: > > To be fair, Python offloads its heavy lifting to C libraries - NumPy > > and SciPy run at very close to full C speed on large datasets. This is > > also how Matlab works. Unladen Swallow is an upcoming JIT compiler for > > Python. > > > > Where Haskell shines for computation is when you can leverage lazy > > evaluation. > > *If* you can offload most of your work to SciPy. Depending on what you > do this is at least difficult. I don't know how much of a neural > network can be represented as big fat matrix :). I would also like to add that Haskell shines for parallel computation, being easy and rewarding to use multiple cores or processors in a SMP machine. Parallel computing in Python is at least ugly because you need to use multiple processes, while the same task in C++ needs to be dealt with manually using concurrency. -- Felipe. ----- End forwarded message ----- From felipe.lessa at gmail.com Sat Nov 7 04:48:41 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Nov 7 04:24:45 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 138 - November 07, 2009 In-Reply-To: <4af50dfd.9653f10a.68f4.2d64@mx.google.com> References: <4af50dfd.9653f10a.68f4.2d64@mx.google.com> Message-ID: <20091107094841.GA3526@kira.casa> On Fri, Nov 06, 2009 at 10:04:45PM -0800, jfredett@gmail.com wrote: > * mauke: @unpl const (flip const) > lambdabot: (\ _ c d -> d) I didn't get this one, is it just because lambdabot didn't change 'c' to an underscore? Thanks for the HWN, as always :), -- Felipe. From svein.ove at aas.no Sat Nov 7 05:09:38 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Sat Nov 7 04:45:40 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 138 - November 07, 2009 In-Reply-To: <20091107094841.GA3526@kira.casa> References: <4af50dfd.9653f10a.68f4.2d64@mx.google.com> <20091107094841.GA3526@kira.casa> Message-ID: <221b53ab0911070209m6da76a20kd5e6d29b89e1d852@mail.gmail.com> On Sat, Nov 7, 2009 at 10:48 AM, Felipe Lessa wrote: > On Fri, Nov 06, 2009 at 10:04:45PM -0800, jfredett@gmail.com wrote: >> ? ? ?* mauke: @unpl const (flip const) >> ? ? ? ?lambdabot: (\ _ c d -> d) > > I didn't get this one, is it just because lambdabot didn't change > 'c' to an underscore? > We were experimenting with @pl and yes, that's part of it, but it's also that it skipped a entirely in this case. Just struck me as weird. -- Svein Ove Aas From felipe.lessa at gmail.com Sat Nov 7 05:54:51 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Nov 7 05:30:54 2009 Subject: [Haskell-cafe] Card games Message-ID: <20091107105451.GA7384@kira.casa> Hi! I would like to know if anybody has already thought of or tried to code an EDSL for card games. Ideally you should be able to write the rules the games and get "for free": - Game generator: given an input deck, construct the initial state of the game. - Random game generator: besides just creating a random deck and using the item above, it should be nice to be able to randomly construct the game from the final positions. This should guarantee that all random games are solvable. - "Hints" generator: IOW list possible moves given a game state. - Playable game: probably the EDSL should include at least some information to be able to properly place the cards on the screen. - Game solver: this is somewhat harder to do efficiently, but an inneficient one should be doable. - Demo mode: related to the above, an auto-play distract-me mode. - Tutorial mode: show a screen for each of the rules written? - ...anything more? Just curious, this looks like a perfect job for an EDSL. Also, I guess anybody trying to do something like this should read PySol's code to have some ideas. -- Felipe. From jfredett at gmail.com Sat Nov 7 05:58:12 2009 From: jfredett at gmail.com (Joe Fredette) Date: Sat Nov 7 05:34:13 2009 Subject: [Haskell-cafe] Card games In-Reply-To: <20091107105451.GA7384@kira.casa> References: <20091107105451.GA7384@kira.casa> Message-ID: You might peek at my library HCard (it's on Hackage), it uses associated datatypes to allow for a very general playing-card interface. It was only ever a toy to play w/ Assoc. types for me, but I imagine it could be a decent starting point for someone interested in turning it into a real EDSL. It's got a cribbage counter example program bundled with it. /Joe On Nov 7, 2009, at 5:54 AM, Felipe Lessa wrote: > Hi! > > I would like to know if anybody has already thought of or tried > to code an EDSL for card games. Ideally you should be able to > write the rules the games and get "for free": > > - Game generator: given an input deck, construct the initial > state of the game. > > - Random game generator: besides just creating a random deck and > using the item above, it should be nice to be able to randomly > construct the game from the final positions. This should > guarantee that all random games are solvable. > > - "Hints" generator: IOW list possible moves given a game state. > > - Playable game: probably the EDSL should include at least some > information to be able to properly place the cards on the > screen. > > - Game solver: this is somewhat harder to do efficiently, but an > inneficient one should be doable. > > - Demo mode: related to the above, an auto-play distract-me mode. > > - Tutorial mode: show a screen for each of the rules written? > > - ...anything more? > > Just curious, this looks like a perfect job for an EDSL. Also, I > guess anybody trying to do something like this should read > PySol's code to have some ideas. > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From eeoam at ukfsn.org Sat Nov 7 06:33:32 2009 From: eeoam at ukfsn.org (Eric Macaulay) Date: Sat Nov 7 06:09:38 2009 Subject: [Haskell-cafe] Parsing Haskell In-Reply-To: <1B8924A6-3621-4441-9175-A6702CF3DD8C@swierstra.net> References: <20091106144918.23255DF267@mail.ukfsn.org> <1B8924A6-3621-4441-9175-A6702CF3DD8C@swierstra.net> Message-ID: <20091107113338.202ECDEC4F@mail.ukfsn.org> Thanks, I'll check it out. At 22:03 06/11/2009, S. Doaitse Swierstra wrote: >The UHC compiler contains a combinator based Haskell parser from which >you can borrow fragments, > > Doaitse Swierstra > > >On 6 nov 2009, at 15:49, Eric Macaulay wrote: > >>Hi all, >> >>I was hoping to use Language.Haskell.Parser to parse fragments of >>Haskell code. However, it appears that one can only use this module >>to parse complete Haskell programs. Is there anyway around this, or >>must I write a Haskell parser from scratch? >> >>Eric M. >> >>_______________________________________________ >>Haskell-Cafe mailing list >>Haskell-Cafe@haskell.org >>http://www.haskell.org/mailman/listinfo/haskell-cafe From eeoam at ukfsn.org Sat Nov 7 06:34:19 2009 From: eeoam at ukfsn.org (Eric Macaulay) Date: Sat Nov 7 06:10:24 2009 Subject: [Haskell-cafe] Re: Parsing Haskell In-Reply-To: References: <20091106144918.23255DF267@mail.ukfsn.org> <1A1E5117-676D-4632-B233-A2AC61E8E3E1@n-brain.net> <4AF44B3D.1040905@gmail.com> Message-ID: <20091107113424.21B7DDEC1B@mail.ukfsn.org> It has indeed reached me. Thanks! At 16:23 06/11/2009, Niklas Broberg wrote: > > You'd have to modify the parser in haskell-src(-exts) to do add the entry > > points, though. > >Actually haskell-src-exts already defines entry points for Module, >Stmt, Exp, Pat and Type (as well as [Module] in 1.3.x). > >Not sure if this message reaches the original poster though. > >Cheers, > >/Niklas >_______________________________________________ >Haskell-Cafe mailing list >Haskell-Cafe@haskell.org >http://www.haskell.org/mailman/listinfo/haskell-cafe From stephen.tetley at gmail.com Sat Nov 7 06:34:56 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sat Nov 7 06:10:59 2009 Subject: [Haskell-cafe] Card games In-Reply-To: <20091107105451.GA7384@kira.casa> References: <20091107105451.GA7384@kira.casa> Message-ID: <5fdc56d70911070334x581a48b2ree69050de2bd5bc9@mail.gmail.com> Hi Felipe Close (or maybe not...), Martin Erwig and Eric Walkingshaw have a few papers on embedding a DSL in Haskell for game theory available from Martin's web site: http://web.engr.oregonstate.edu/~erwig/papers/abstracts.html Best wishes Stephen 2009/11/7 Felipe Lessa : > Hi! > > I would like to know if anybody has already thought of or tried > to code an EDSL for card games. ?Ideally you should be able to > write the rules the games and get "for free": From matthias.goergens at googlemail.com Sat Nov 7 08:46:07 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Sat Nov 7 08:22:26 2009 Subject: [Haskell-cafe] Card games In-Reply-To: <20091107105451.GA7384@kira.casa> References: <20091107105451.GA7384@kira.casa> Message-ID: Hi Felipe, Interesting idea. But I guess you should clarify what kind of card games you want to support. E.g, a DSL for trick taking games like Bridge, Skat or Doppelkopf might be different from one that's good for Canasta or Rummy. Or do you aim at Solitaire? I'd suggest starting with a very small scope of the domain for a very first version. Good luck writing a `solver' for Doppelkopf! Cheers, Matthias. From felipe.lessa at gmail.com Sat Nov 7 09:07:53 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Nov 7 08:43:56 2009 Subject: [Haskell-cafe] Card games In-Reply-To: References: <20091107105451.GA7384@kira.casa> Message-ID: <20091107140753.GB23128@kira.casa> On Sat, Nov 07, 2009 at 08:46:07AM -0500, Matthias G?rgens wrote: > Interesting idea. But I guess you should clarify what kind of card > games you want to support. E.g, a DSL for trick taking games like > Bridge, Skat or Doppelkopf might be different from one that's good for > Canasta or Rummy. Or do you aim at Solitaire? I'd suggest starting > with a very small scope of the domain for a very first version. Hmm, good catch. I was thinking about solitaire, i.e. single player, games. Multiplayer card games certainly have their own set of interesting challenges. If I ever get to develop something capable of expressing nicely Patience, Spider, Pyramid and Black Hole I'll be more than satisfied :). Cheers, -- Felipe. From klondikehaskellcafe at xiscosoft.es Sat Nov 7 09:40:13 2009 From: klondikehaskellcafe at xiscosoft.es (klondike) Date: Sat Nov 7 09:16:23 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: control-monad-exception 0.5 with monadic call traces In-Reply-To: <7ca3f0160911061847k763c6073g4f055069b53c577d@mail.gmail.com> References: <4AF02F06.2030105@henning-thielemann.de> <4AF4D352.1090107@xiscosoft.es> <7ca3f0160911061847k763c6073g4f055069b53c577d@mail.gmail.com> Message-ID: <4AF586CD.9010504@xiscosoft.es> Luke Palmer escribi?: > On Fri, Nov 6, 2009 at 6:54 PM, klondike > wrote: > >> Henning Thielemann escribi?: >> >>> That's what I meant with my post: Programming errors (like "head []") >>> are not handled by control-monad-exception. As far as I understand, >>> control-monad-exception makes _exceptions_ explicit in the type >>> signatures, not programming errors. Why and how would you make >>> possible programming errors explicit in the type? But for exceptions >>> (e.g. "file could not be found") a detailed stack trace is not of much >>> use. >>> >> I think you have overlooked a few things. First, not every developer >> knows each one of the lines in the code well enough as to see where a >> exception comes from, specially when you are not the author of that code. >> >> Of course, that wouldn't mind so much unless you see another thing, if >> we don't know which exceptions can be launched by a operation then you >> will get it on the upper frame and rendered unable to solve it. Use >> typed exceptions (as this library intends to) you may say. Ok, now we >> have another problem, the strange habit of coders to keep the exceptions >> they don't know/can't treat going up and up and up, until then usually >> hit the top frame and you are screwed. You can check some Java code (to >> see an example on how this happens) as some of these exceptional >> conditions are put on the method's signature. >> > > You sound like you are expecting something that works exactly like the > imperative exception handling mechanisms you are used to, and are not > willing to accept anything else. > No, I sound like I am expecting programmers comming from the imperative world to do ugly things, maybe because I once was one. > This "strange habit" of programmers is simply bad practice, and leads > to just as brittle code as no exception handling, except that you get > inexplicable error message boxes with OK buttons instead of crashes. > You might as well just put the whole program in a catch block in IO > and bail with something noncomittal. > Now comes the time when I have to show you that not every exception could be handled, IE a file not found exception when looking for the config file can be fatal and force the program to stop. But what if this is on a library? How do you suggest that the programmer knows that the File Not Found exception is due to the lack of that config file, specially when the code is badly (or not) documented. > IMO, Haskell's typed exceptions (via eg. explicit-exception) *are* the > way to go. They keep the number of exceptional conditions that can > occur in a body of code small -- if some code has many exceptional > conditions, it forces you to *compose* them somehow, to come up with a > more precise idea of what your code is doing and how it can fail. > Yeah, the thing comes when you get the same kind of exceptions from different places, you need a way to tell them appart. > If you are just blindly passing exceptions up from the code below, the > interface to your code is getting more and more complex. With typed > exceptions, the types are reflecting the complexity of the interface > (which is precisely the purpose of types). > Well, it's not like blindly pass exceptions up but more like passing exceptions I don't know how to handle up. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 262 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091107/c0acb1c5/signature.bin From dvde at gmx.net Sat Nov 7 10:28:24 2009 From: dvde at gmx.net (Daniel van den Eijkel) Date: Sat Nov 7 10:04:28 2009 Subject: [Haskell-cafe] virus/trojan in bamse package? Message-ID: <4AF59218.6020604@gmx.net> hi, my Avira antivirus program says that there is a trojan in the bamse-0.9.5 package. I downloaded the hackage-torrent a week ago, and Avira says "TR/Crypt.CFI.Gen" is in bamse. To be sure, I downloaded bamse-0.9.5 from hackage today, and now avira says less specificly that there are "some viruses and/or unwanted programs" inside. Since I have some trojan trouble for a few days now, bamse might be the reason for that, but I am not sure. Maybe it is a false alarm, I can't determine this. (bamse is a framework for building Windows Installer, so it might contain code that looks like a virus or alike wrongly?) Does anybody know if this is really a virus/trojan? Best regards, Daniel From gue.schmidt at web.de Sat Nov 7 12:09:54 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Sat Nov 7 11:45:53 2009 Subject: [Haskell-cafe] Monad Comprehensions In-Reply-To: References: Message-ID: Hello Ryan, thank you for your email, it's much appreciated. In summary I'd like to say that in the 2 years that I have been using Haskell I have managed to get a good working knowledge of the language which allows me to construct programs that are concise, correct and without greater redundancy. However I also realize more and more that in order to harness the full power of Haskell I need to gain a greater understanding of the underlying math and go beyond mechanical application. It is only lately that I am recognizing the significance of the often used term "abstraction". Certainly this is pointed out in the Haskell world often enough, but hey I'm a noob. For someone like me this is not immediately apparent. I mean there seems to be almost no end of what I still have to learn, barely scratching the surface, tip of the iceberg, that sort of thing. DSLs are apparently *the* way to go in the abstraction department. Oleg & Co's "Finally Tagless" style is my favorite when it comes to implementation. It bears this simplicity and elegance that I have come to recognize and what to me *is* "mathematical". Not all of my dealings in Haskell are goal-oriented. Well there is that of course, but mostly there are all these shiny beautiful things. I get distracted quite a lot too. Trying to dig deeper on the subject of Dan Piponis video for instance. BTW I found Phil Wadlers paper "Comprehending Monads" quite helpful here. I also find my focus of interest on the topics of articles on haskell-cafe shift. Before I would basically skip "deep stuff", ie. theoretical / abstract topics, and focus on technical details. Now I focus much more on "mathematical" issues despite the fact that I can barely understand them, it'll come to me eventually. Because now I consider the mathematical discussions far more fundamental and more "lasting". Technical details I can look up as the need arises and they will likely change over time, so no need to bother with them beforehand, they may be out-dated when you need them. Mathematical ones won't, they'll be good forever. Well that's my 2 cents for now. G?nther Am 07.11.2009, 09:37 Uhr, schrieb Ryan Grant : > 2009/11/1 G?nther Schmidt : >> In short, I'm truly lost. If anyone else, with roughly the same starting >> point as me, has found their way through this jungle I'd certainly >> appreciate some tips. In particular I wonder if someone has been able to >> follow what Dan demonstrates in this video, or was it a jaw-dropping >> experience for everyone else just as me? > > G?nther, i have been lurking in H-cafe, and enjoying your pace of > exploration. AFAIK, you are trying to understand how to make > excellent languages using Haskell. you are asking some practical > questions that i find relevant to my own journey into Haskell. > > "best practices" for specifying a DSL are not well agreed upon, > partly due to recent advances. i sense this problem in your > question and in the newsworthiness of Dan's talk, (which i also > enjoyed with a jaw-drop). > > i encourage you to say exactly what you want from your DSL (do it > again, if you have already). > > i hope to follow your footsteps, maybe not in exact DSL needs, > but in path of discovery. > From Malcolm.Wallace at cs.york.ac.uk Sat Nov 7 12:09:51 2009 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Sat Nov 7 11:46:57 2009 Subject: [Haskell-cafe] Parsing Haskell In-Reply-To: <1B8924A6-3621-4441-9175-A6702CF3DD8C@swierstra.net> References: <20091106144918.23255DF267@mail.ukfsn.org> <1B8924A6-3621-4441-9175-A6702CF3DD8C@swierstra.net> Message-ID: <9F149B58-2372-479B-87BC-BEE90241AA4C@cs.york.ac.uk> > The UHC compiler contains a combinator based Haskell parser from > which you can borrow fragments, ... and the nhc98/yhc compiler likewise has a combinator parser for full Haskell'98 (the combinators are in applicative style). Regards, Malcolm From jannis at harderweb.de Sat Nov 7 12:06:54 2009 From: jannis at harderweb.de (Jannis (jix) Harder) Date: Sat Nov 7 11:51:03 2009 Subject: [Haskell-cafe] Re: virus/trojan in bamse package? References: <4AF59218.6020604@gmx.net> Message-ID: Am 07.11.2009, 16:28 Uhr, schrieb Daniel van den Eijkel : > hi, > > my Avira antivirus program says that there is a trojan in the > bamse-0.9.5 package. I downloaded the hackage-torrent a week ago, and > Avira says "TR/Crypt.CFI.Gen" is in bamse. To be sure, I downloaded > bamse-0.9.5 from hackage today, and now avira says less specificly that > there are "some viruses and/or unwanted programs" inside. .Gen usually means that the file isn't a known virus but some heuristics triggered. This can also happen if a file is compressed with an executable packer that the virus scanner can't decompress, which wouldn't be strange for an installer tool. I don't know if that's the problem in this case but I had a lot of trouble with virus scanners in combination with executable packers so it might be. -- Jannis From hjgtuyl at chello.nl Sat Nov 7 12:20:39 2009 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Sat Nov 7 11:56:34 2009 Subject: [Haskell-cafe] WinGHCi stuck in a loop Message-ID: L.S., I changed the options in WinGHCi and now WinGHCi is stuck in a loop each time I start it; how can I edit the options? I cannot find them in the registry. -- Met vriendelijke groet, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html -- From jno at di.uminho.pt Sat Nov 7 12:27:36 2009 From: jno at di.uminho.pt (J.N. Oliveira) Date: Sat Nov 7 12:03:25 2009 Subject: [Haskell-cafe] RE: Haskell as a first language? In-Reply-To: <1247572115.22466.8968.camel@localhost> References: <4A59097D.4070605@googlemail.com><638ABD0A29C8884A91BC5FB5C349B1 C3478D52E257@EA-EXMSG-C334.europe.corp.microsoft.com><4A5C5788.9030802@cs.c altech.edu> <1247572115.22466.8968.camel@localhost> Message-ID: <4AF5AE08.8070500@di.uminho.pt> Duncan Coutts wrote: >On Tue, 2009-07-14 at 03:01 -0700, Michael Vanier wrote: > > >>Charles, >> >>Haskell is a wonderful language (my favorite language by far) but it is >>pretty difficult for a beginner. In fact, it is pretty difficult for >>anyone to learn in my experience, because it has so many advanced >>concepts that simply don't exist in other languages, and trying to >>absorb them all at once will likely be overwhelming. >> >> > >As a contrary data-point, at Oxford we teach functional programming >(using Haskell) as the first course at the very beginning of the >computer science degree. I know several other universities also use FP >and Haskell very early on in their CS courses. > At Minho we've been using Haskell as first programming course in CS degrees since 1997-98. Such a 'functional first' approach is the natural way to start a background on programming. Look at the hardware side, for instance: which of the following kinds of digital system is taught first: combinatorial (eg. nand, nor gates) or sequential (eg. flip-flops)? The first, of course, because such circuits are functional (no state, no feedback). More recently I had a go at teaching Haskell to beginners in a non CS context (to arts students studying musicology, actually). If you are interested, have a look at the slides available from the course's URL: www.di.uminho.pt/~jno/html/ipm.html#sec:mp (Under Acrobat some scores will start playing music once you click the "pin" symbol on the right.) All comments, suggestions etc are welcome. jno From korpios at korpios.com Sat Nov 7 12:33:49 2009 From: korpios at korpios.com (Tom Tobin) Date: Sat Nov 7 12:09:48 2009 Subject: [Haskell-cafe] Card games In-Reply-To: <20091107140753.GB23128@kira.casa> References: <20091107105451.GA7384@kira.casa> <20091107140753.GB23128@kira.casa> Message-ID: On Sat, Nov 7, 2009 at 8:07 AM, Felipe Lessa wrote: > On Sat, Nov 07, 2009 at 08:46:07AM -0500, Matthias G?rgens wrote: >> Interesting idea. ?But I guess you should clarify what kind of card >> games you want to support. ?E.g, a DSL for trick taking games like >> Bridge, Skat or Doppelkopf might be different from one that's good for >> Canasta or Rummy. ?Or do you aim at Solitaire? ?I'd suggest starting >> with a very small scope of the domain for a very first version. > > Hmm, good catch. ?I was thinking about solitaire, i.e. single > player, games. ?Multiplayer card games certainly have their own > set of interesting challenges. > > If I ever get to develop something capable of expressing nicely > Patience, Spider, Pyramid and Black Hole I'll be more than > satisfied :). I'd be interested in something which could model games of Dominion [1], as it's my current addiction; it's a (non-collectable) card game where you build and tune your deck as you play, and aside from money and victory point cards (which are always available) randomly has available ten possible "action" card types to buy each game (out of the total set of action card types ? 76, as of the latest expansion). There have already been various basic analyses of various possible strategies assuming simple rules; if a strategy can't beat the "baseline" strategy "Big Money" (which involves buying nothing but money and victory points the entire game), it should probably be scrapped. [1] http://www.boardgamegeek.com/boardgame/36218 From pepeiborra at gmail.com Sat Nov 7 12:44:45 2009 From: pepeiborra at gmail.com (Jose Iborra) Date: Sat Nov 7 12:20:47 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: control-monad-exception 0.5 with monadic call traces In-Reply-To: References: <4AF02F06.2030105@henning-thielemann.de> Message-ID: > > >> When using happstack, I find it really annoying to get a >> Prelude.head: null list error (or similar) in my web browser window >> because somewhere, some library used something unsafe -- and of >> course, since this is haskell, no stack trace. > >> if c-m-e can offer benefits around this, I would be very interested >> in adopting it. > > > That's what I meant with my post: Programming errors (like "head > []") are not handled by control-monad-exception. As far as I > understand, control-monad-exception makes _exceptions_ explicit in > the type signatures, not programming errors. Why and how would you > make possible programming errors explicit in the type? But for > exceptions (e.g. "file could not be found") a detailed stack trace > is not of much use. It seems again to me, that mixing of > (programming) errors and exceptions is going on, and I assumed that > the purpose of control-monad-exception is to separate them in a > better way. > Sorry for the confusion, I never meant that c-m-e can show stack traces for asynchronous exceptions. It can not. I used the head of empty list error to draw a simile of why you would like to have a stack trace. I do not share your opinion that monadic call traces are not of much use. Your example looks a bit conspicuous to me. Consider a web application using HDBC to interface with a database, where a SQLError can arise and there is no way to find out where it is coming from. The safe-failure package (not officially released yet, but an early version is available in Hackage) provides monadic versions of several partial functions in the Prelude. An applicative interface is available which can make programming with those much more palatable. That means you can in effect obtain a stack trace for a head of empty list error. I would like, as much as anyone else, to see stack traces available for pure Haskell code. There are others already pursuing that goal, but as the situation stands now, stack traces are available only through expensive program transformations which cannot be used in production code. And I don't believe that situation is going to change in the close future. In contrast, monadic call traces have a simple implementation model by extending the bind operation with source locations. They are available now through the MonadLoc preprocessor which is not tied in any way to c-m-e. And moreover, they are unexpensive, can be used in production code, and can make your life much easier in many, many cases. I'm not sure if I managed to dispel your doubts, if not perhaps you could make your points more clear. Thanks, pepe From ziman at centrum.sk Sat Nov 7 12:45:09 2009 From: ziman at centrum.sk (Matus Tejiscak) Date: Sat Nov 7 12:21:11 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <20091106222506.GC22609@seas.upenn.edu> References: <1257382324.5965.97.camel@idefix.localdomain> <4AF34DA6.2010701@btinternet.com> <7b501d5c0911051431u624ab25eg45b7f108ba0ea9bf@mail.gmail.com> <7fb8f82f0911060659j7eaae56fl68eab26163821f25@mail.gmail.com> <5fdc56d70911060729r39fee9fap680bd51c5bfecd2@mail.gmail.com> <20091106222506.GC22609@seas.upenn.edu> Message-ID: <1257615909.6212.31.camel@idefix.localdomain> On Pi, 2009-11-06 at 17:25 -0500, Brent Yorgey wrote: > On Fri, Nov 06, 2009 at 03:29:47PM +0000, Stephen Tetley wrote: > > Hello all, > > > > Are any of the of the more exotic recursion schemes definable without > > a least-fixed point /Mu/ type? > > Note that Haskell datatypes have a built-in implicit "mu" (that is, I'd say Mu gets you a greatest-fixed point. I don't have a proof, I just note that Mu(?X. 1 + A x X) contains infinite lists, too. I wonder whether this is a problem; if I want to define an initial algebra of a functor, I should take a least fixed point (if I understand it correctly) -- but all I have is Mu. Inductively defined functions will loop on infinite lists, which are included in the resulting type, and -- i imagine -- the type system might prevent such errors, by not enabling casting from greatest-Mu(F) to least-Mu(F). But that's probably too restrictive to be useful. Anyway, is there a possibility to restrict Mu to a least-fixed-point operator? Matus From nccb2 at kent.ac.uk Sat Nov 7 13:57:34 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Sat Nov 7 13:33:34 2009 Subject: [Haskell-cafe] Names for properties of operators Message-ID: <4AF5C31E.6080302@kent.ac.uk> Hi, We have names for properties of operators/functions. For example, if this holds: a % b = b % a for some operator %, we say that % is commutative. Similarly, if this holds: (a % b) % c = a % (b % c) we say that % is associative. Is there a name for this property, which I'm numbering 1, (where (%) :: a -> b -> b; i.e. the operator is potentially, but not necessarily, asymmetrically typed): 1: a % (b % c) = b % (a % c) For example, `Set.insert` obeys 1 for any values of a, b and c. (Any operator that is both associative and commutative automatically satisfies this property, but this property can be satisfied without the operator being either of those.) Given this property, we could prove useful follow-on results, such as: foldr (%) x ys = foldr (%) x (reverse ys) foldr (%) x ys = foldl (flip (%)) x ys The property 1 effectively states that the far-right hand element in a chain of such operators is special, but the ordering of everything to the left of it doesn't matter. One could conceive of a mirror property (where (%) :: a -> b -> a): 2: (a % b) % c = (a % c) % b If (%) obeys 1, flip (%) obeys 2 (and vice versa). I think these properties are useful -- I'd like to know if they have names already to describe them by. A similar property of two relations (where ((%), (~)) :: (a -> b -> b, c -> b -> b) ) would be: 3: a % (b ~ c) = b ~ (a % c) with mirror version (and adjusted types): 4: (a % b) ~ c = (a ~ c) % b Do these have a name? As an example, `Set.insert` and `Set.union` obey property 3 for all values of a, b and c. There are also symmetrically-typed examples of these operators, but the Set operations are easy and familiar. Thanks, Neil. From tittoassini at gmail.com Sat Nov 7 14:00:12 2009 From: tittoassini at gmail.com (Pasqualino "Titto" Assini) Date: Sat Nov 7 13:36:11 2009 Subject: Fwd: [Haskell-cafe] Is () a 0-length tuple? In-Reply-To: <2d34474e0911071059j56ffece3vf5ecf9e2f13c943b@mail.gmail.com> References: <2d34474e0911061408od1c1d65xb5a41cd6ee0892dc@mail.gmail.com> <20091106223857.GC23495@colquitt.org> <2d34474e0911071059j56ffece3vf5ecf9e2f13c943b@mail.gmail.com> Message-ID: <2d34474e0911071100r18a7fafem2dd03f88ea798708@mail.gmail.com> The syntax is similar, but what else is? In JavaScript there is a "null" value, that is the only value of the null type. Isn't () the same thing? ?The only value of the unary type? Best, ? ? ? ? ? ? ? ? titto 2009/11/6 John Dorsey : >> In what sense () is a 0-length tuple? > > In what sense isn't it? > > Data.Tuple is much to narrow to be of any use here. ?() is in at least most, > if not all, of the type classes that tuples are in. ?The syntax is > strikingly similar. > > If you ask me, it walks/quacks/smells like a duck, so it's a duck. > > Regards, > John > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Pasqualino "Titto" Assini, Ph.D. http://quicquid.org/ From ekirpichov at gmail.com Sat Nov 7 14:09:32 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sat Nov 7 13:45:33 2009 Subject: [Haskell-cafe] Is () a 0-length tuple? In-Reply-To: <2d34474e0911071100r18a7fafem2dd03f88ea798708@mail.gmail.com> References: <2d34474e0911061408od1c1d65xb5a41cd6ee0892dc@mail.gmail.com> <20091106223857.GC23495@colquitt.org> <2d34474e0911071059j56ffece3vf5ecf9e2f13c943b@mail.gmail.com> <2d34474e0911071100r18a7fafem2dd03f88ea798708@mail.gmail.com> Message-ID: <5e0214850911071109jb5e6a06neb6dede729e5c428@mail.gmail.com> 2009/11/7 Pasqualino "Titto" Assini : > The syntax is similar, but what else is? > > In JavaScript there is a "null" value, that is the only value of the null type. > > Isn't () the same thing? ?The only value of the unary type? > No, () has two values: () and undefined (t.i., _|_). > Best, > > ? ? ? ? ? ? ? ? titto > > > 2009/11/6 John Dorsey : >>> In what sense () is a 0-length tuple? >> >> In what sense isn't it? >> >> Data.Tuple is much to narrow to be of any use here. ?() is in at least most, >> if not all, of the type classes that tuples are in. ?The syntax is >> strikingly similar. >> >> If you ask me, it walks/quacks/smells like a duck, so it's a duck. >> >> Regards, >> John >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > > -- > Pasqualino "Titto" Assini, Ph.D. > http://quicquid.org/ > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From wikigracenotes at gmail.com Sat Nov 7 14:20:42 2009 From: wikigracenotes at gmail.com (Matthew Gruen) Date: Sat Nov 7 13:56:42 2009 Subject: [Haskell-cafe] Is () a 0-length tuple? In-Reply-To: References: <2d34474e0911061408od1c1d65xb5a41cd6ee0892dc@mail.gmail.com> <20091106223857.GC23495@colquitt.org> <2d34474e0911071059j56ffece3vf5ecf9e2f13c943b@mail.gmail.com> <2d34474e0911071100r18a7fafem2dd03f88ea798708@mail.gmail.com> Message-ID: Forgot to cc haskell-cafe. Trying again: ---------- Forwarded message ---------- From: Matthew Gruen Date: Sat, Nov 7, 2009 at 2:16 PM Subject: Re: [Haskell-cafe] Is () a 0-length tuple? To: Pasqualino Titto Assini On Sat, Nov 7, 2009 at 2:00 PM, Pasqualino "Titto" Assini wrote: > The syntax is similar, but what else is? > > In JavaScript there is a "null" value, that is the only value of the null type. > > Isn't () the same thing? ?The only value of the unary type? > > Best, > > ? ? ? ? ? ? ? ? titto > > Pasqualino "Titto" Assini, Ph.D. > http://quicquid.org/ In JavaScript's case, there is not a null type. The null value belongs to the 'object' type, whereas the undefined value belongs to the 'undefined' type. This is all a lot less useful when you realize that JavaScript has a dynamic type system. But this is JSON, not JavaScript. In JSON, arrays, objects, strings, and numbers can be any number of values. Booleans can be two values. Null can only be one value. Personally, I think a better mapping for () would be JSNull, since both have only one value in normal form. However, there is not necessarily any natural mapping between Haskell values and JSON values. The library tries to provide as many as possible, including (), which it happens to map to JSArray [] instead of JSNull. As long as the library is internally consistent, though, it should be fine. From lemming at henning-thielemann.de Sat Nov 7 14:54:06 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Nov 7 14:30:05 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: control-monad-exception 0.5 with monadic call traces In-Reply-To: References: <4AF02F06.2030105@henning-thielemann.de> Message-ID: On Sat, 7 Nov 2009, Jose Iborra wrote: > Sorry for the confusion, I never meant that c-m-e can show stack traces for > asynchronous exceptions. It can not. My post was not related in any way to asynchronous exceptions. It's just the everlasting issue of the distinction of programming errors and exceptions. > I'm not sure if I managed to dispel your doubts, if not perhaps you could > make your points more clear. I'm trying that for years now, repeatedly in this mailing list and on the Wiki: http://www.haskell.org/haskellwiki/Error http://www.haskell.org/haskellwiki/Exception I don't know how I can make it still clearer. It's just like concurrency vs. parallelism - somehow related, but it is important to distinguish them. From wren at freegeek.org Sat Nov 7 15:46:30 2009 From: wren at freegeek.org (wren ng thornton) Date: Sat Nov 7 15:22:30 2009 Subject: [Haskell-cafe] Master's thesis topic sought In-Reply-To: <1257615909.6212.31.camel@idefix.localdomain> References: <1257382324.5965.97.camel@idefix.localdomain> <4AF34DA6.2010701@btinternet.com> <7b501d5c0911051431u624ab25eg45b7f108ba0ea9bf@mail.gmail.com> <7fb8f82f0911060659j7eaae56fl68eab26163821f25@mail.gmail.com> <5fdc56d70911060729r39fee9fap680bd51c5bfecd2@mail.gmail.com> <20091106222506.GC22609@seas.upenn.edu> <1257615909.6212.31.camel@idefix.localdomain> Message-ID: <4AF5DCA6.7080405@freegeek.org> Matus Tejiscak wrote: > On Pi, 2009-11-06 at 17:25 -0500, Brent Yorgey wrote: >> On Fri, Nov 06, 2009 at 03:29:47PM +0000, Stephen Tetley wrote: >>> Hello all, >>> >>> Are any of the of the more exotic recursion schemes definable without >>> a least-fixed point /Mu/ type? >> Note that Haskell datatypes have a built-in implicit "mu" (that is, > > I'd say Mu gets you a greatest-fixed point. I don't have a proof, I just > note that Mu(?X. 1 + A x X) contains infinite lists, too. Mu is the notation for least-fixed, Nu is the notation for greatest-fixed. In Haskell, the two fixed points coincide due to laziness and _|_. > I wonder whether this is a problem; if I want to define an initial > algebra of a functor, I should take a least fixed point (if I understand > it correctly) -- but all I have is Mu. Inductively defined functions > will loop on infinite lists, which are included in the resulting type, > and -- i imagine -- the type system might prevent such errors, by not > enabling casting from greatest-Mu(F) to least-Mu(F). But that's probably > too restrictive to be useful. If you want the type system to catch infinite looping like this, then you'll need to switch to a total functional programming language which distinguishes data and codata (and hence what can be inducted on vs what needs to be coinducted on). -- Live well, ~wren From gpnair78 at yahoo.com Sat Nov 7 16:08:41 2009 From: gpnair78 at yahoo.com (Gokul P. Nair) Date: Sat Nov 7 15:44:39 2009 Subject: [Haskell-cafe] help with Haskell performance Message-ID: <119795.11181.qm@web51912.mail.re2.yahoo.com> Hi all, The task I'm trying to accomplish: Given a log file containing several lines of white space delimited entries like this: [Sat Oct 24 08:12:37 2009] [error] GET /url1 HTTP/1.1]: Requested URI does not exist [Sat Oct 24 08:12:37 2009] [error] GET /url2 HTTP/1.0]: Requested URI does not exist [Sat Oct 24 08:12:37 2009] [error] GET /url1 HTTP/1.1]: Requested URI does not exist [Sat Oct 24 12:12:37 2009] [error] GET /url1 HTTP/1.1]: Requested URI does not exist filter lines that match the string " 08:", extract the 6th, 7th and 8th words from that line, group all lines that have the the same resulting string, do a count on them and sort the result in descending order of counts and print it out. So in the example above we'd end up with an output like this: ("GET /url1 HTTP/1.1]:", 2) ("GET /url2 HTTP/1.0]:", 1) Seems pretty straightforward, so I wrote a simple perl script to achieve this task (see the bottom of this email). The input file is 335 MB in size and contains about 2 million log line entires in it. The perl script does a pretty decent job and finishes in about 3 seconds. Now the interesting part. I decided to implememt this in Haskell (being my favorite language and all) and ended up with the following code: --- begin haskell code --- import Text.Regex.Posix ( (=~) ) import qualified Data.List as List ? import qualified Data.Map as Map import qualified Data.ByteString.Lazy.Char8 as LB main = do ? contents <- LB.readFile "log_file" ? putStr . unlines . map ( show . (\(x, y) -> ((LB.unpack x), y)) ) . ??? -- create a Map grouping & counting matching tokens and sort based on the counts ??? List.sortBy (\(_, x) (_, y) -> y `compare` x) . Map.toList . Map.fromListWith (+) . filtertokens . ??? LB.lines $ contents ? where filtertokens = foldr (\x acc -> if (f x) then ((g x) : acc) else acc) [] ????????? -- filter lines starting with " 08:" ????????? where f = (=~ " 08:") . LB.unpack ??????????????? -- extract tokens 6, 7 & 8 and create an association list like so ("GET /url2 HTTP/1.0]:", 1) ??????????????? g line = flip (,) 1 . LB.unwords . map (xs !!) $ [6, 7, 8] where xs = LB.words line --- end haskell code --- This haskell implementation takes a whopping 27 seconds to complete! About 9 times slower than the perl version! I'm using ghc 6.10.4, compiling with -O2 and even went to the extent of fusing an adjacent map and filter using a foldr like so: map f (filter g) => foldr ( if g x then f x ... ), fusing adjacents maps etc. Still the same result. I really hope I'm missing some obvious optimization that's making it so slow compared to the perl version, hence this email soliciting feedback. Thanks in advance. P.S. For reference, here's my corresponding perl implementation: --- start perl code --- #!/usr/bin/perl use strict; use warnings FATAL => 'all'; my %urls; open(FILE, '<', $ARGV[0]); while() { ??? if (/ 08:/) { ??????? my @words = split; ??????? my $key = join(" ", ($words[6], $words[7], $words[8])); ??????? if (exists $urls{$key}) { $urls{$key}++ } ??????? else { $urls{$key} = 1 } ??? } } for (sort { $urls{$b} <=> $urls{$a} } keys %urls) { print "($_, $urls{$_})\n" } --- end perl code --- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091107/108ec6a4/attachment.html From ekirpichov at gmail.com Sat Nov 7 16:15:57 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sat Nov 7 15:51:55 2009 Subject: [Haskell-cafe] help with Haskell performance In-Reply-To: <119795.11181.qm@web51912.mail.re2.yahoo.com> References: <119795.11181.qm@web51912.mail.re2.yahoo.com> Message-ID: <5e0214850911071315m761d80f1g186c28ce42c2592a@mail.gmail.com> 2009/11/8 Gokul P. Nair > > Hi all, > > The task I'm trying to accomplish: > > Given a log file containing several lines of white space delimited entries like this: > > [Sat Oct 24 08:12:37 2009] [error] GET /url1 HTTP/1.1]: Requested URI does not exist > [Sat Oct 24 08:12:37 2009] [error] GET /url2 HTTP/1.0]: Requested URI does not exist > [Sat Oct 24 08:12:37 2009] [error] GET /url1 HTTP/1.1]: Requested URI does not exist > [Sat Oct 24 12:12:37 2009] [error] GET /url1 HTTP/1.1]: Requested URI does not exist > > filter lines that match the string " 08:", extract the 6th, 7th and 8th words from that line, group all lines that have the the same resulting string, do a count on them and sort the result in descending order of counts and print it out. So in the example above we'd end up with an output like this: > > ("GET /url1 HTTP/1.1]:", 2) > ("GET /url2 HTTP/1.0]:", 1) > > Seems pretty straightforward, so I wrote a simple perl script to achieve this task (see the bottom of this email). > > The input file is 335 MB in size and contains about 2 million log line entires in it. The perl script does a pretty decent job and finishes in about 3 seconds. > > Now the interesting part. I decided to implememt this in Haskell (being my favorite language and all) and ended up with the following code: > > --- begin haskell code --- > > import Text.Regex.Posix ( (=~) ) First, you are using Text.Regex.Posix which is dog slow. Use regex-tdfa or regex-pcre. Second, you are using it on a String! Third, you are unpacking a lazy bytestring for that! This alone is more than enough to make things ridiculously slow. > > import qualified Data.List as List > import qualified Data.Map as Map > import qualified Data.ByteString.Lazy.Char8 as LB > > main = do > ? contents <- LB.readFile "log_file" > ? putStr . unlines . map ( show . (\(x, y) -> ((LB.unpack x), y)) ) . This piece of code also does unpacking. If the output is small, it's ok, otherwise assemble output in the form of a bytestring and print it with B.putStr. > ??? -- create a Map grouping & counting matching tokens and sort based on the counts > ??? List.sortBy (\(_, x) (_, y) -> y `compare` x) . Map.toList . Map.fromListWith (+) . filtertokens . The lambda can be replaced by "flip (comparing snd)" > ??? LB.lines $ contents Here, you should not use Map.fromListWith (+) because Map is not strict in its entries and you end up having big fat thunks there. You should use Map.fromListWith plus where x `plus` y = x `seq` y `seq` x+y. > ? where filtertokens = foldr (\x acc -> if (f x) then ((g x) : acc) else acc) [] > ????????? -- filter lines starting with " 08:" > ????????? where f = (=~ " 08:") . LB.unpack > ??????????????? -- extract tokens 6, 7 & 8 and create an association list like so ("GET /url2 HTTP/1.0]:", 1) > ??????????????? g line = flip (,) 1 . LB.unwords . map (xs !!) $ [6, 7, 8] where xs = LB.words line You are using random access on a list three times in a row. map (xs!!) [6,7,8] is much faster when implemented as "take 3 (drop 6 xs)". So.. Well. Try these suggestions, show the resulting performance and then we'll see. > > --- end haskell code --- > > This haskell implementation takes a whopping 27 seconds to complete! About 9 times slower than the perl version! I'm using ghc 6.10.4, compiling with -O2 and even went to the extent of fusing an adjacent map and filter using a foldr like so: map f (filter g) => foldr ( if g x then f x ... ), fusing adjacents maps etc. Still the same result. > > I really hope I'm missing some obvious optimization that's making it so slow compared to the perl version, hence this email soliciting feedback. > > Thanks in advance. > > P.S. For reference, here's my corresponding perl implementation: > > --- start perl code --- > > #!/usr/bin/perl > use strict; > use warnings FATAL => 'all'; > > my %urls; > open(FILE, '<', $ARGV[0]); > while() { > ??? if (/ 08:/) { > ??????? my @words = split; > ??????? my $key = join(" ", ($words[6], $words[7], $words[8])); > ??????? if (exists $urls{$key}) { $urls{$key}++ } > ??????? else { $urls{$key} = 1 } > ??? } > } > for (sort { $urls{$b} <=> $urls{$a} } keys %urls) { print "($_, $urls{$_})\n" } > > --- end perl code --- > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From felipe.lessa at gmail.com Sat Nov 7 16:29:17 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Nov 7 16:05:24 2009 Subject: [Haskell-cafe] help with Haskell performance In-Reply-To: <5e0214850911071315m761d80f1g186c28ce42c2592a@mail.gmail.com> References: <119795.11181.qm@web51912.mail.re2.yahoo.com> <5e0214850911071315m761d80f1g186c28ce42c2592a@mail.gmail.com> Message-ID: <20091107212917.GA15294@kira.casa> On Sun, Nov 08, 2009 at 12:15:57AM +0300, Eugene Kirpichov wrote: > Here, you should not use Map.fromListWith (+) because Map is not > strict in its entries and you end up having big fat thunks there. > You should use Map.fromListWith plus where x `plus` y = x `seq` y `seq` x+y. fromListWith is implemented with insertWithKey; is defining plus like above enough? I would guess that we need fromListWith' implemented with insertWithKey'. The problem is that it will build a thunk (x `plus` y) and your seq's only say that whenever you evaluate that thunk you'll evaluate the arguments as well. If the thunk itself isn't needed, it won't be evaluated. -- Felipe. From dons at galois.com Sat Nov 7 16:50:57 2009 From: dons at galois.com (Don Stewart) Date: Sat Nov 7 16:26:58 2009 Subject: [Haskell-cafe] help with Haskell performance In-Reply-To: <119795.11181.qm@web51912.mail.re2.yahoo.com> References: <119795.11181.qm@web51912.mail.re2.yahoo.com> Message-ID: <20091107215057.GA2474@whirlpool.galois.com> gpnair78: > I really hope I'm missing some obvious optimization that's making it so slow > compared to the perl version, hence this email soliciting feedback. Here's my first attempt. 1.5s on a 2M line log file in the format you give. General notes: * unpack is almost always wrong. * list indexing with !! is almost always wrong. * words/lines are often wrong for parsing large files (they build large list structures). * toList/fromList probably aren't the best strategy * sortBy (comparing snd) * use insertWith' Spefically, avoid constructing intermediate lists, when you can process the entire file in a single pass. Use O(1) bytestring substring operations like take and drop. Compiling: $ ghc -O2 /tmp/B.hs --make Running: $ time /tmp/B ("GET /url1 HTTP/1.1]",1000000) ("GET /url2 HTTP/1.0]",500000) /tmp/B 1.38s user 0.21s system 99% cpu 1.595 total And the code: {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE BangPatterns #-} import qualified Data.ByteString.Char8 as L import qualified Data.Map as M main = do l <- L.readFile "/tmp/x" mapM_ print . M.toList $ go l M.empty where go !s !acc | L.null s = acc | " 08:" `L.isPrefixOf` s1 = go s4 acc' | otherwise = go s4 acc where s1 = L.drop 11 s -- drop prefix to timestamp -- now extract the key (_,s2) = L.breakSubstring "GET" s1 (k,s3) = L.break ((==) ':') s2 -- drop the rest of the line s4 = L.tail (L.dropWhile ((/=) '\n') s3) acc' = M.insertWith' (+) k 1 acc ------------------------------------------------------------------------ From ekirpichov at gmail.com Sat Nov 7 16:51:44 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sat Nov 7 16:27:42 2009 Subject: [Haskell-cafe] help with Haskell performance In-Reply-To: <20091107212917.GA15294@kira.casa> References: <119795.11181.qm@web51912.mail.re2.yahoo.com> <5e0214850911071315m761d80f1g186c28ce42c2592a@mail.gmail.com> <20091107212917.GA15294@kira.casa> Message-ID: <5e0214850911071351j18e97a7ds2cf2116a776dbf4f@mail.gmail.com> Ah, you're right. Then we need a foldl' insertWith with a strict plus. 2009/11/8 Felipe Lessa : > On Sun, Nov 08, 2009 at 12:15:57AM +0300, Eugene Kirpichov wrote: >> Here, you should not use Map.fromListWith (+) because Map is not >> strict in its entries and you end up having big fat thunks there. >> You should use Map.fromListWith plus where x `plus` y = x `seq` y `seq` x+y. > > fromListWith is implemented with insertWithKey; is defining plus > like above enough? ?I would guess that we need fromListWith' > implemented with insertWithKey'. > > The problem is that it will build a thunk (x `plus` y) and your > seq's only say that whenever you evaluate that thunk you'll > evaluate the arguments as well. ?If the thunk itself isn't > needed, it won't be evaluated. > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From michael at snoyman.com Sat Nov 7 16:55:14 2009 From: michael at snoyman.com (Michael Snoyman) Date: Sat Nov 7 16:31:13 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: control-monad-exception 0.5 with monadic call traces In-Reply-To: References: <4AF02F06.2030105@henning-thielemann.de> Message-ID: <29bf512f0911071355n47f3b559w40a99b5818f17d92@mail.gmail.com> On Sat, Nov 7, 2009 at 9:54 PM, Henning Thielemann < lemming@henning-thielemann.de> wrote: > > On Sat, 7 Nov 2009, Jose Iborra wrote: > > Sorry for the confusion, I never meant that c-m-e can show stack traces >> for asynchronous exceptions. It can not. >> > > My post was not related in any way to asynchronous exceptions. It's just > the everlasting issue of the distinction of programming errors and > exceptions. > > > I'm not sure if I managed to dispel your doubts, if not perhaps you could >> make your points more clear. >> > > I'm trying that for years now, repeatedly in this mailing list and on the > Wiki: > http://www.haskell.org/haskellwiki/Error > http://www.haskell.org/haskellwiki/Exception > I don't know how I can make it still clearer. It's just like concurrency > vs. parallelism - somehow related, but it is important to distinguish them. > > And yet if I use library ABC, which I expected to be error-free, and it in fact has a programming error, is this an error or an exception from my point of view? Based on the definitions you posted, I believe the correct answer is "error." However, I'd much rather have a way to recover from that kind of error if it's logical. For example, let's say that I'm writing a web browser in Haskell (it could happen). If there's an error in the HTTP library which causes it to die on certain types of headers, I'd much rather be able to tell the user sorry and let them continue browsing than to up and die with a "Prelude.head" message in their console. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091107/ea9eff49/attachment.html From chaddai.fouche at gmail.com Sat Nov 7 18:05:42 2009 From: chaddai.fouche at gmail.com (=?UTF-8?B?Q2hhZGRhw68gRm91Y2jDqQ==?=) Date: Sat Nov 7 17:41:41 2009 Subject: [Haskell-cafe] help with Haskell performance In-Reply-To: <5e0214850911071351j18e97a7ds2cf2116a776dbf4f@mail.gmail.com> References: <119795.11181.qm@web51912.mail.re2.yahoo.com> <5e0214850911071315m761d80f1g186c28ce42c2592a@mail.gmail.com> <20091107212917.GA15294@kira.casa> <5e0214850911071351j18e97a7ds2cf2116a776dbf4f@mail.gmail.com> Message-ID: 2009/11/7 Eugene Kirpichov : > Ah, you're right. Then we need a foldl' insertWith with a strict plus. We "only" need a foldl' insertWith' : (+) is already strict for all the numeric types in the Prelude. -- Jeda? From phi500ac at yahoo.ca Sat Nov 7 19:44:04 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Sat Nov 7 19:20:02 2009 Subject: [Haskell-cafe] Small Japi binding for GHC Message-ID: <818070.71552.qm@web58806.mail.re1.yahoo.com> JAPI is by far my favorite GUI library.? Since every machine has Java RE installed, JAPI offers GUI with a very small footprint. Besides this, it is very easy to code, and delivers GUI programs that are hardly larger than console applications. I use Jorlano's version of JAPI, coded for Java 2, which is very cool. I study Computer Science in a small college, and I always handle my homework in JAPI. When I? took functional programming one year ago,? the language chosen by Professor Lopes was Clean, that has a GUI.? However, I feel that JAPI is much easier than ObjectIO; therefore, I used JAPI for my homework. So, I searched for JAPI bindings for Haskell. The only library I found was something called Small Japi binding for GHC.? The package? is incomplete, and? bug ridden. I wonder whether the author fixed the bugs, completed the package, and added more examples. I would appreciate if people could send me links to a complete Japi binding for GHC. In the mean time, I fixed the bugs of Small Japi Binding, and added a few important components (j_textfield, j_settext, j_gettext, j_button, etc.) Of course, a link to a more recent version of the official binding will save me a? lot of work. __________________________________________________________________ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091107/5aaaa33f/attachment.html From jadenb1729 at yahoo.com Sat Nov 7 19:44:42 2009 From: jadenb1729 at yahoo.com (L Spice) Date: Sat Nov 7 19:26:02 2009 Subject: [Haskell-cafe] Re: What's the deal with Clean? References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <1BFBEDAF-236D-4645-A0C2-8A7AB83FD213@swierstra.net> Message-ID: John van Groningen cs.ru.nl> writes: > Doaitse Swierstra wrote: > >One of this differences between Haskell and Clean I did not see mentioned in this discussion is that Clean > does not allow so-called partial parametrisation. I.e. all function calls have to be fully saturated > > I don't understand what you mean. Can you give an example ? > > Kind regards, > > John van Groningen I think the idea was that Clean doesn't support a syntax like "map (**2)" for a function that will take a list and square its elements. The call to map there is not fully saturated, since it's waiting for another argument. (As a disclaimer, I've not used Clean, so I could be speaking nonsense; it's just how I read the original statement.) From tdanecker at gmail.com Sat Nov 7 20:01:07 2009 From: tdanecker at gmail.com (Thomas Danecker) Date: Sat Nov 7 19:37:25 2009 Subject: [Haskell-cafe] Names for properties of operators In-Reply-To: <4AF5C31E.6080302@kent.ac.uk> References: <4AF5C31E.6080302@kent.ac.uk> Message-ID: <479362e0911071701x3c53cd9dwabecf25c3cc4eb07@mail.gmail.com> 1. and 2. are called left- and right-commutative. And I think that 3. and 4. are left- and right-commutative rings (please correct me if I'm wrong here). Cheers, Thomas 2009/11/7 Neil Brown : > Hi, > > We have names for properties of operators/functions. ?For example, if this > holds: > > a % b = b % a > > for some operator %, we say that % is commutative. ?Similarly, if this > holds: > > (a % b) % c = a % (b % c) > > we say that % is associative. ?Is there a name for this property, which I'm > numbering 1, (where (%) :: a -> b -> b; i.e. the operator is potentially, > but not necessarily, asymmetrically typed): > > 1: a % (b % c) = b % (a % c) > > For example, `Set.insert` obeys 1 for any values of a, b and c. ?(Any > operator that is both associative and commutative automatically satisfies > this property, but this property can be satisfied without the operator being > either of those.) ?Given this property, we could prove useful follow-on > results, such as: > > foldr (%) x ys = foldr (%) x (reverse ys) > foldr (%) x ys = foldl (flip (%)) x ys > > The property 1 effectively states that the far-right hand element in a chain > of such operators is special, but the ordering of everything to the left of > it doesn't matter. > > One could conceive of a mirror property (where (%) :: a -> b -> a): > > 2: (a % b) % c = (a % c) % b > > If (%) obeys 1, flip (%) obeys 2 (and vice versa). ?I think these properties > are useful -- I'd like to know if they have names already to describe them > by. ?A similar property of two relations (where ((%), (~)) :: (a -> b -> b, > c -> b -> b) ) would be: > > 3: a % (b ~ c) = b ~ (a % c) > > with mirror version (and adjusted types): > > 4: (a % b) ~ c = (a ~ c) % b > > Do these have a name? ?As an example, `Set.insert` and `Set.union` obey > property 3 for all values of a, b and c. > > There are also symmetrically-typed examples of these operators, but the Set > operations are easy and familiar. > > Thanks, > > Neil. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From tdanecker at gmail.com Sat Nov 7 20:09:33 2009 From: tdanecker at gmail.com (Thomas Danecker) Date: Sat Nov 7 19:45:51 2009 Subject: [Haskell-cafe] Names for properties of operators In-Reply-To: <479362e0911071701x3c53cd9dwabecf25c3cc4eb07@mail.gmail.com> References: <4AF5C31E.6080302@kent.ac.uk> <479362e0911071701x3c53cd9dwabecf25c3cc4eb07@mail.gmail.com> Message-ID: <479362e0911071709x26d0d0a9jfb4dfb7b8da70b6f@mail.gmail.com> No, they aren't rings, because rings are distributive... 2009/11/8 Thomas Danecker : > 1. and 2. are called left- and right-commutative. > And I think that 3. and 4. are left- and right-commutative rings > (please correct me if I'm wrong here). > > Cheers, Thomas > > 2009/11/7 Neil Brown : >> Hi, >> >> We have names for properties of operators/functions. ?For example, if this >> holds: >> >> a % b = b % a >> >> for some operator %, we say that % is commutative. ?Similarly, if this >> holds: >> >> (a % b) % c = a % (b % c) >> >> we say that % is associative. ?Is there a name for this property, which I'm >> numbering 1, (where (%) :: a -> b -> b; i.e. the operator is potentially, >> but not necessarily, asymmetrically typed): >> >> 1: a % (b % c) = b % (a % c) >> >> For example, `Set.insert` obeys 1 for any values of a, b and c. ?(Any >> operator that is both associative and commutative automatically satisfies >> this property, but this property can be satisfied without the operator being >> either of those.) ?Given this property, we could prove useful follow-on >> results, such as: >> >> foldr (%) x ys = foldr (%) x (reverse ys) >> foldr (%) x ys = foldl (flip (%)) x ys >> >> The property 1 effectively states that the far-right hand element in a chain >> of such operators is special, but the ordering of everything to the left of >> it doesn't matter. >> >> One could conceive of a mirror property (where (%) :: a -> b -> a): >> >> 2: (a % b) % c = (a % c) % b >> >> If (%) obeys 1, flip (%) obeys 2 (and vice versa). ?I think these properties >> are useful -- I'd like to know if they have names already to describe them >> by. ?A similar property of two relations (where ((%), (~)) :: (a -> b -> b, >> c -> b -> b) ) would be: >> >> 3: a % (b ~ c) = b ~ (a % c) >> >> with mirror version (and adjusted types): >> >> 4: (a % b) ~ c = (a ~ c) % b >> >> Do these have a name? ?As an example, `Set.insert` and `Set.union` obey >> property 3 for all values of a, b and c. >> >> There are also symmetrically-typed examples of these operators, but the Set >> operations are easy and familiar. >> >> Thanks, >> >> Neil. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From matthew at brecknell.net Sat Nov 7 20:47:08 2009 From: matthew at brecknell.net (Matthew Brecknell) Date: Sat Nov 7 20:23:09 2009 Subject: [Haskell-cafe] Names for properties of operators In-Reply-To: <4AF5C31E.6080302@kent.ac.uk> References: <4AF5C31E.6080302@kent.ac.uk> Message-ID: <1257644828.8512.182.camel@localhost> Hi Neil, You wrote: > [...] Is there a name for this property, which > I'm numbering 1, (where (%) :: a -> b -> b; i.e. the operator is > potentially, but not necessarily, asymmetrically typed): > > 1: a % (b % c) = b % (a % c) I don't know any snappy names for this, but the following might help to reveal some structure. Pick some specific (but arbitrary) types: (%) :: A -> B -> B And some values: x, y :: A z :: B f, g :: B -> B f = (x%) g = (y%) Then: x % (y % z) == f (g z) == (f . g) z y % (x % z) == g (f z) == (g . f) z So (%) has property 1 iff the sub-monoid of Endo [1], which is generated by Endo (x%) forall x :: A, is commutative. Property 3 is the same, but with a larger generator set. Note that in your examples, the sub-monoid generated by insert+union is just the same as that generated by insert alone (assuming no infinite sets). This particular sub-monoid also happens to be a bounded join-semilattice (isomorphic to the finite subsets of A), which also makes it idempotent. Regards, Matthew [1]http://haskell.org/ghc/docs/latest/html/libraries/base/src/Data-Monoid.html#Endo From mauricio.antunes at gmail.com Sat Nov 7 23:47:32 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Sat Nov 7 23:23:52 2009 Subject: [Haskell-cafe] Re: Nice addition to Foreign: castAny In-Reply-To: <20091104043439.GA5072@sliver.repetae.net> References: <20091104043439.GA5072@sliver.repetae.net> Message-ID: >> castAny :: (Storable a, Storable b) => a -> b >> castAny = unsafePerformIO . genericCast >> where >> genericCast :: (Storable a, Storable b) => a -> IO b >> genericCast v = return undefined >>= \r -> >> allocaBytes (max (sizeOf v) (sizeOf r)) $ \p -> >> poke p v >> if False then return r else peek (castPtr p) >> > let a = -1000 :: Int16 >> > castAny a :: Word16 --> >> 64536 >> > castAny a :: Ptr () >> 0xb4c2fc18 > Try it on a big endian architecture, or one that has alignment > restrictions, or a different size for HsChar or so forth. Casting by > 'punning' (as the C folks like to call it) does have uses, but they are > generally hardware dependent and useful only in certain rare > circumstances that a generic cast probably isn't likely to fill. Do you think this could be used as a way to handle C unions? If I had something like union example { struct firstview { char c; int n; } fv; long double ld; }; and 'firstview' had been mapped in Haskell as, say, FirstView {firstViewC :: CChar, firstVewN :: CInt} I could check what I would get after pokeing values using: (firstViewN . unionCast) (pi :: CDouble) Note that I changed the name from castAny to unionCast to reflect its use. Thanks for your comments, Maur?cio From ketil at malde.org Sun Nov 8 03:36:42 2009 From: ketil at malde.org (Ketil Malde) Date: Sun Nov 8 03:12:33 2009 Subject: [Haskell-cafe] Re: What's the deal with Clean? In-Reply-To: (L. Spice's message of "Sun, 8 Nov 2009 00:44:42 +0000 (UTC)") References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <1BFBEDAF-236D-4645-A0C2-8A7AB83FD213@swierstra.net> Message-ID: <87iqdlh0px.fsf@malde.org> L Spice writes: >> Doaitse Swierstra wrote: >>>One of this differences between Haskell and Clean I did not see mentioned in >>> this discussion is that Clean does not allow so-called partial >>> parametrisation. I.e. all function calls have to be fully saturated >> I don't understand what you mean. Can you give an example ? > I think the idea was that Clean doesn't support a syntax like "map > (**2)" This terminology is new to me, I would normally call that "partial application". Googling "partial parametrization" gives me some papers? that appear to use this term as a synonym. I'm surprised that (if) Clean doesn't support it. -k ? http://cat.inist.fr/?aModele=afficheN&cpsidt=5420616 and http://www.springerlink.com/content/wg64116566522061/ -- If I haven't seen further, it is by standing in the footprints of giants From nccb2 at kent.ac.uk Sun Nov 8 03:44:25 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Sun Nov 8 03:20:29 2009 Subject: [Haskell-cafe] Names for properties of operators In-Reply-To: <4AF5C31E.6080302@kent.ac.uk> References: <4AF5C31E.6080302@kent.ac.uk> Message-ID: <4AF684E9.60200@kent.ac.uk> Hi, Thanks for the replies so far. If it helps, after I sent my post, I spotted a couple of arithmetic examples: Neil Brown wrote: > 2: (a % b) % c = (a % c) % b Division (on rationals) obeys this property (a / b) / c = (a / c) / b -- which is actually equal to a / (b * c), but that doesn't matter for my property. > 4: (a % b) ~ c = (a ~ c) % b Division and multiplication on rationals obey this property: (a / b) * c = (a * c) / b. Thanks, Neil. From ketil at malde.org Sun Nov 8 03:52:05 2009 From: ketil at malde.org (Ketil Malde) Date: Sun Nov 8 03:27:55 2009 Subject: [Haskell-cafe] Is () a 0-length tuple? In-Reply-To: <5e0214850911071109jb5e6a06neb6dede729e5c428@mail.gmail.com> (Eugene Kirpichov's message of "Sat, 7 Nov 2009 22:09:32 +0300") References: <2d34474e0911061408od1c1d65xb5a41cd6ee0892dc@mail.gmail.com> <20091106223857.GC23495@colquitt.org> <2d34474e0911071059j56ffece3vf5ecf9e2f13c943b@mail.gmail.com> <2d34474e0911071100r18a7fafem2dd03f88ea798708@mail.gmail.com> <5e0214850911071109jb5e6a06neb6dede729e5c428@mail.gmail.com> Message-ID: <87eio9h00a.fsf@malde.org> Eugene Kirpichov writes: >> In JavaScript there is a "null" value, that is the only value of the null type. >> Isn't () the same thing? ?The only value of the unary type? > No, () has two values: () and undefined (t.i., _|_). I'd argue that yes, they're the same thing, since any function returning "null" in JS might also fail to terminate or terminate with an exception. -k -- If I haven't seen further, it is by standing in the footprints of giants From stephen.tetley at gmail.com Sun Nov 8 03:57:06 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sun Nov 8 03:33:03 2009 Subject: [Haskell-cafe] Re: What's the deal with Clean? In-Reply-To: References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <1BFBEDAF-236D-4645-A0C2-8A7AB83FD213@swierstra.net> Message-ID: <5fdc56d70911080057j6e0c9b13k3e86a9d6bb913ee5@mail.gmail.com> Why speak nonsense when you can test it? // ---------------------------------------------------------------------------- module nonsense import StdEnv nonsense = map ((^) 2) Start = nonsense [1,2,3] // ---------------------------------------------------------------------------- .... Running gives: [2,4,8] Best wishes Stephen 2009/11/8 L Spice : > John van Groningen cs.ru.nl> writes: > >> Doaitse Swierstra wrote: >> >One of this differences between Haskell and Clean I did not see mentioned in > this discussion is that Clean >> does not allow so-called partial parametrisation. I.e. all function calls have > to be fully saturated >> >> I don't understand what you mean. Can you give an example ? >> >> Kind regards, >> >> John van Groningen > > I think the idea was that Clean doesn't support a syntax like "map (**2)" for a > function that will take a list and square its elements. ?The call to map there > is not fully saturated, since it's waiting for another argument. > > (As a disclaimer, I've not used Clean, so I could be speaking nonsense; it's > just how I read the original statement.) > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ketil at malde.org Sun Nov 8 04:02:27 2009 From: ketil at malde.org (Ketil Malde) Date: Sun Nov 8 03:38:16 2009 Subject: [Haskell-cafe] Small Japi binding for GHC In-Reply-To: <818070.71552.qm@web58806.mail.re1.yahoo.com> (Philippos Apolinarius's message of "Sat, 7 Nov 2009 16:44:04 -0800 (PST)") References: <818070.71552.qm@web58806.mail.re1.yahoo.com> Message-ID: <878wehfkyk.fsf@malde.org> Philippos Apolinarius writes: > So, I searched for JAPI bindings for Haskell. The only library I found > was something called Small Japi binding for GHC.? The package? is > incomplete, and? bug ridden. I don't know anything about this particular library, but this happens. Now that we have Cabal and Hackage making tons of libraries easily available, what's still missing is a good way of ranking equivalent libraries by completeness and usefulness. > I wonder whether the author fixed the > bugs, completed the package, and added more examples. Did you try to identify and email the original author? > In the mean time, I fixed the bugs of Small Japi Binding, and > added a few important components (j_textfield, j_settext, j_gettext, > j_button, etc.) Of course, a link to a more recent version of the > official binding will save me a? lot of work. If nothing else, perhaps you would make your modifications available? That way, the next JAPI user will have less trouble than you did. (Assming the license allows it, of course.) -k -- If I haven't seen further, it is by standing in the footprints of giants From stephen.tetley at gmail.com Sun Nov 8 04:22:13 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sun Nov 8 03:58:11 2009 Subject: [Haskell-cafe] Re: What's the deal with Clean? In-Reply-To: <5fdc56d70911080057j6e0c9b13k3e86a9d6bb913ee5@mail.gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <1BFBEDAF-236D-4645-A0C2-8A7AB83FD213@swierstra.net> <5fdc56d70911080057j6e0c9b13k3e86a9d6bb913ee5@mail.gmail.com> Message-ID: <5fdc56d70911080122t2656e722l123856c9cfa739cf@mail.gmail.com> My impression is the saturated-ness that Doaitse speaks of is covered in Urban Boquist's phd thesis on the GRIN intermediate language - circa page 31. http://www.cs.chalmers.se/~boquist/phd/ As per the code snippet above Clean handles partial application entirely adequately. Best wishes Stephen >>> Doaitse Swierstra wrote: >>> >One of this differences between Haskell and Clean I did not see mentioned in >> this discussion is that Clean >>> does not allow so-called partial parametrisation. I.e. all function calls have >> to be fully saturated From pierreetienne.meunier at gmail.com Sun Nov 8 04:51:28 2009 From: pierreetienne.meunier at gmail.com (Pierre-Etienne Meunier) Date: Sun Nov 8 04:27:27 2009 Subject: [Haskell-cafe] Memoizing in parallel Message-ID: Hi, I'm designing an algorithm that uses dynamic programming. I've written it with an array, and it works, but it is still very slow and needs way too much memory. Then I realized that the array was very sparse (at most a O(\sqrt(n)) of its size is actually used). Now I want to rewrite it with a Data.Map, but since I do not know a priori what the keys are, I need a mutable ref somewhere. Which is fine, but... the array solution allowed me to explore the subsolutions in parallel with Control.Parallel, and use items already evaluated by other threads in the array, while an STRef forbids it. Can someone know how to do it (outside IO, and without using unsafePerformIO, of course) ? Thanks Pierre-Etienne Meunier From svein.ove at aas.no Sun Nov 8 04:53:39 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Sun Nov 8 04:29:37 2009 Subject: [Haskell-cafe] Is () a 0-length tuple? In-Reply-To: <87eio9h00a.fsf@malde.org> References: <2d34474e0911061408od1c1d65xb5a41cd6ee0892dc@mail.gmail.com> <20091106223857.GC23495@colquitt.org> <2d34474e0911071059j56ffece3vf5ecf9e2f13c943b@mail.gmail.com> <2d34474e0911071100r18a7fafem2dd03f88ea798708@mail.gmail.com> <5e0214850911071109jb5e6a06neb6dede729e5c428@mail.gmail.com> <87eio9h00a.fsf@malde.org> Message-ID: <221b53ab0911080153kd014233p8937e0bd00cb1695@mail.gmail.com> On Sun, Nov 8, 2009 at 9:52 AM, Ketil Malde wrote: > Eugene Kirpichov writes: > >>> In JavaScript there is a "null" value, that is the only value of the null type. >>> Isn't () the same thing? ?The only value of the unary type? > >> No, () has two values: () and undefined (t.i., _|_). > How should I put it..? undefined is bottom, but bottom is not undefined? There are plenty of other constructions that are bottom. Infinite loops, throws, errors.. common for all of them, of course, is that you can't pattern-match on them or otherwise use them in pure code, and they generally don't act like values. So, can't we just say that () has a single value, namely ()? It'd make this much simpler, and we won't have to deal with the Nihil monoid. == data Nihil instance Monoid Nihil where mappend _ _ = undefined -- Svein Ove Aas From conor at strictlypositive.org Sun Nov 8 05:03:38 2009 From: conor at strictlypositive.org (Conor McBride) Date: Sun Nov 8 04:39:45 2009 Subject: [Haskell-cafe] Is () a 0-length tuple? In-Reply-To: <221b53ab0911080153kd014233p8937e0bd00cb1695@mail.gmail.com> References: <2d34474e0911061408od1c1d65xb5a41cd6ee0892dc@mail.gmail.com> <20091106223857.GC23495@colquitt.org> <2d34474e0911071059j56ffece3vf5ecf9e2f13c943b@mail.gmail.com> <2d34474e0911071100r18a7fafem2dd03f88ea798708@mail.gmail.com> <5e0214850911071109jb5e6a06neb6dede729e5c428@mail.gmail.com> <87eio9h00a.fsf@malde.org> <221b53ab0911080153kd014233p8937e0bd00cb1695@mail.gmail.com> Message-ID: How about this? {-# LANGUAGE ThinkTotal #-} On 8 Nov 2009, at 09:53, Svein Ove Aas wrote: > On Sun, Nov 8, 2009 at 9:52 AM, Ketil Malde wrote: >> Eugene Kirpichov writes: >> >>>> In JavaScript there is a "null" value, that is the only value of >>>> the null type. >>>> Isn't () the same thing? The only value of the unary type? >> >>> No, () has two values: () and undefined (t.i., _|_). () is the only value of (). If we could agree a standard set of email pragmas, we could save ourselves a lot of violent agreement. Cheers Conor From jon.fairbairn at cl.cam.ac.uk Sun Nov 8 05:14:07 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Sun Nov 8 04:50:26 2009 Subject: [Haskell-cafe] Re: Fwd: Is () a 0-length tuple? References: <2d34474e0911061408od1c1d65xb5a41cd6ee0892dc@mail.gmail.com> <20091106223857.GC23495@colquitt.org> <2d34474e0911071059j56ffece3vf5ecf9e2f13c943b@mail.gmail.com> <2d34474e0911071100r18a7fafem2dd03f88ea798708@mail.gmail.com> Message-ID: "Pasqualino \"Titto\" Assini" writes: > The syntax is similar, but what else is? What would you expect from an empty tuple? (a,b,c) has a constructor function p3 a b c = (a,b,c) and three destructor functions s3_1 (a,b,c) = a, s3_2 (a,b,c) = b and s3_3 (a,b,c)=c (a,b) has a constructor function p2 a b = (a,b) and two destructor functions s2_1 (a,b) = a and s2_2 (a,b) = b (a) has a constructor function p1 a = (a) and one destructor function s1_1 a = a () has a constructor function p0 = () and zero destructor functions. > In JavaScript there is a "null" value, that is the only value of the > null type. I'm not sure that Javascript is a suitable place to get intuitions for Haskell (null type would seem more like empty than single), but anyway, the thing is that the sole (non-bottom) value of the /unit/ type is the same as the empty tuple?. > Isn't () the same thing? ?The only value of the unary type? The "empty" type in Haskell would be (forall a.a) which has no non-bottom values. [1] Aside: I wanted haskell to share the same type for all empty values (ie lists would have been symmetric unions of pairs with the unit type List t = (t,List t) || ()), but that didn't fit with algebraic datatypes so the design went a different way. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From deniz.a.m.dogan at gmail.com Sun Nov 8 06:21:26 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Sun Nov 8 05:57:44 2009 Subject: [Haskell-cafe] Is () a 0-length tuple? In-Reply-To: References: <2d34474e0911061408od1c1d65xb5a41cd6ee0892dc@mail.gmail.com> <20091106223857.GC23495@colquitt.org> <2d34474e0911071059j56ffece3vf5ecf9e2f13c943b@mail.gmail.com> <2d34474e0911071100r18a7fafem2dd03f88ea798708@mail.gmail.com> Message-ID: <7b501d5c0911080321u4b6fcd77g11ded95dd06153a8@mail.gmail.com> 2009/11/7 Matthew Gruen : > Forgot to cc haskell-cafe. Trying again: > > ---------- Forwarded message ---------- > From: Matthew Gruen > Date: Sat, Nov 7, 2009 at 2:16 PM > Subject: Re: [Haskell-cafe] Is () a 0-length tuple? > To: Pasqualino Titto Assini > > On Sat, Nov 7, 2009 at 2:00 PM, Pasqualino "Titto" Assini > wrote: >> The syntax is similar, but what else is? >> >> In JavaScript there is a "null" value, that is the only value of the null type. >> >> Isn't () the same thing? ?The only value of the unary type? >> >> Best, >> >> ? ? ? ? ? ? ? ? titto >> >> Pasqualino "Titto" Assini, Ph.D. >> http://quicquid.org/ > > In JavaScript's case, there is not a null type. The null value belongs > to the 'object' type, whereas the undefined value belongs to the > 'undefined' type. This is all a lot less useful when you realize that > JavaScript has a dynamic type system. But this is JSON, not > JavaScript. > > In JSON, arrays, objects, strings, and numbers can be any number of > values. Booleans can be two values. Null can only be one value. > Personally, I think a better mapping for () would be JSNull, since > both have only one value in normal form. However, there is not > necessarily any natural mapping between Haskell values and JSON > values. The library tries to provide as many as possible, including > (), which it happens to map to JSArray [] instead of JSNull. As long > as the library is internally consistent, though, it should be fine. What point are you trying to make by distinguishing JSON from JavaScript? JSON is a subset of JavaScript, they share the same type system. "Null can be only one value." This doesn't make sense to me, since as you say null is not a type, but a value. -- Deniz Dogan From ketil at malde.org Sun Nov 8 06:44:06 2009 From: ketil at malde.org (Ketil Malde) Date: Sun Nov 8 06:19:56 2009 Subject: [Haskell-cafe] Re: Fwd: Is () a 0-length tuple? In-Reply-To: (Jon Fairbairn's message of "Sun, 08 Nov 2009 10:14:07 +0000") References: <2d34474e0911061408od1c1d65xb5a41cd6ee0892dc@mail.gmail.com> <20091106223857.GC23495@colquitt.org> <2d34474e0911071059j56ffece3vf5ecf9e2f13c943b@mail.gmail.com> <2d34474e0911071100r18a7fafem2dd03f88ea798708@mail.gmail.com> Message-ID: <874op5fdh5.fsf@malde.org> Jon Fairbairn writes: > The "empty" type in Haskell would be (forall a.a) which has no > non-bottom values. With an extension, you can also define: data Void -- without any constructors which is perhaps closer to null types in other languages? -k -- If I haven't seen further, it is by standing in the footprints of giants From sjoerd at w3future.com Sun Nov 8 06:45:11 2009 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Sun Nov 8 06:21:10 2009 Subject: [Haskell-cafe] Names for properties of operators In-Reply-To: <4AF5C31E.6080302@kent.ac.uk> References: <4AF5C31E.6080302@kent.ac.uk> Message-ID: <0E2D2253-5EB1-4507-A74B-F65ECA1FF54E@w3future.com> This seems related: http://en.wikipedia.org/wiki/Semigroup_action But I'm not entirely sure. Sjoerd On Nov 7, 2009, at 7:57 PM, Neil Brown wrote: > Hi, > > We have names for properties of operators/functions. For example, > if this holds: > > a % b = b % a > > for some operator %, we say that % is commutative. Similarly, if > this holds: > > (a % b) % c = a % (b % c) > > we say that % is associative. Is there a name for this property, > which I'm numbering 1, (where (%) :: a -> b -> b; i.e. the operator > is potentially, but not necessarily, asymmetrically typed): > > 1: a % (b % c) = b % (a % c) > > For example, `Set.insert` obeys 1 for any values of a, b and c. > (Any operator that is both associative and commutative automatically > satisfies this property, but this property can be satisfied without > the operator being either of those.) Given this property, we could > prove useful follow-on results, such as: > > foldr (%) x ys = foldr (%) x (reverse ys) > foldr (%) x ys = foldl (flip (%)) x ys > > The property 1 effectively states that the far-right hand element in > a chain of such operators is special, but the ordering of everything > to the left of it doesn't matter. > > One could conceive of a mirror property (where (%) :: a -> b -> a): > > 2: (a % b) % c = (a % c) % b > > If (%) obeys 1, flip (%) obeys 2 (and vice versa). I think these > properties are useful -- I'd like to know if they have names already > to describe them by. A similar property of two relations (where > ((%), (~)) :: (a -> b -> b, c -> b -> b) ) would be: > > 3: a % (b ~ c) = b ~ (a % c) > > with mirror version (and adjusted types): > > 4: (a % b) ~ c = (a ~ c) % b > > Do these have a name? As an example, `Set.insert` and `Set.union` > obey property 3 for all values of a, b and c. > > There are also symmetrically-typed examples of these operators, but > the Set operations are easy and familiar. > > Thanks, > > Neil. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Sjoerd Visscher sjoerd@w3future.com From lrpalmer at gmail.com Sun Nov 8 08:08:35 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun Nov 8 07:44:32 2009 Subject: [Haskell-cafe] Memoizing in parallel In-Reply-To: References: Message-ID: <7ca3f0160911080508l13a81741jd3c1100dd81424e9@mail.gmail.com> On Sun, Nov 8, 2009 at 2:51 AM, Pierre-Etienne Meunier wrote: > Hi, > > I'm designing an algorithm that uses dynamic programming. I've written it > with an array, and it works, but it is still very slow and needs way too > much memory. > > Then I realized that the array was very sparse (at most a O(\sqrt(n)) of its > size is actually used). Now I want to rewrite it with a Data.Map, but since > I do not know a priori what the keys are, I need a mutable ref somewhere. I don't know how you drew that conclusion. In fact, no mutable ref is necessary. Your keys are (or can be mapped to) integers, since you used an array. A solution is to use a trie of integers. You could, for example, store the values at the nodes of an infinite tree that looks like: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ... There are various implementations of this around. For a quick solution, though, you can try the data-memocombinators package: import qualified Data.MemoCombinators as Memo let f = Memo.integral go where go = ... f ... See how that performs. It has asymptotically better space performance for sparse usage, but the devil can be in the constant factors. Luke From pierreetienne.meunier at gmail.com Sun Nov 8 09:20:52 2009 From: pierreetienne.meunier at gmail.com (Pierre-Etienne Meunier) Date: Sun Nov 8 08:56:51 2009 Subject: [Haskell-cafe] Memoizing in parallel In-Reply-To: <7ca3f0160911080508l13a81741jd3c1100dd81424e9@mail.gmail.com> References: <7ca3f0160911080508l13a81741jd3c1100dd81424e9@mail.gmail.com> Message-ID: In fact, I could simply write a fibonacci function like this : fibonacci n= fst $ fib n Map.empty where fib 0 m=(0,m) fib 1 m=(1,m) fib n m= case Map.lookup n m of Just x->(x,m) Nothing-> let (n',m')=memoMap (n-2) m (n'',m'')=memoMap (n-1) m' in (n'+n'',Map.insert n (n'+n'') m'') And I could do it even with the implementation of maps in Data.IntMap. I've tried your solution, and looked at your source code; There is a small performance difference between your solution and this one : since you rely on laziness, and my structure is really sparse (a O(\sqrt(n)) is used in the best cases), it performs slightly better than an array, but this is still too slow : the tree does not rebalance itself, contrarily to what the trees in Data.IntMap do. But my question is mainly a question about Haskell's parallelism : imagine I'm solving the problem of attributing m pairs of skis to n skiers, while trying to minimize the sum of the differences between the size of the skiers and the size of their skis. With an array, I'd write : import GHC.Arr import Control.Parallel n=1000 --skiers m=1500 --skis skis=listArray (1,m) [150..] skiers=listArray (1,n) [139..] costs=listArray ((1,1), (n,m)) $ map cost $ range ((1,1),(n,m)) cost (i,j) | j On Sun, Nov 8, 2009 at 2:51 AM, Pierre-Etienne Meunier > wrote: >> Hi, >> >> I'm designing an algorithm that uses dynamic programming. I've >> written it >> with an array, and it works, but it is still very slow and needs >> way too >> much memory. >> >> Then I realized that the array was very sparse (at most a >> O(\sqrt(n)) of its >> size is actually used). Now I want to rewrite it with a Data.Map, >> but since >> I do not know a priori what the keys are, I need a mutable ref >> somewhere. > > I don't know how you drew that conclusion. > > In fact, no mutable ref is necessary. Your keys are (or can be mapped > to) integers, since you used an array. A solution is to use a trie of > integers. You could, for example, store the values at the nodes of > an infinite tree that looks like: > > 0 > 1 2 > 3 4 5 6 > 7 8 9 10 11 12 13 14 > ... > > There are various implementations of this around. For a quick > solution, though, you can try the data-memocombinators package: > > import qualified Data.MemoCombinators as Memo > > let f = Memo.integral go > where > go = ... f ... > > See how that performs. It has asymptotically better space performance > for sparse usage, but the devil can be in the constant factors. > > Luke From max.rabkin at gmail.com Sun Nov 8 09:34:26 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Sun Nov 8 09:10:43 2009 Subject: [Haskell-cafe] Haskell image libraries Message-ID: Haskellers, To add image support to fdo-notify, I need an image type. Looking through Hackage, I didn't find any image library with the following features: * Load from a variety of formats (at least PNG and JPG, I'd say) * Efficient per-pixel access, or a way to dump the image into a ByteString as a bitmap (I need to serialise them into the protocol's bitmap format) Preferably, it should be possible to construct images programmatically too. Is there really no such library? It would be nice to have something like a Haskell equivalent of the Python Imaging Library, which is the de facto standard image library in Python and supports just about every type of operation on images you could ask for. Regards, Max From colin at colina.demon.co.uk Sun Nov 8 09:40:39 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sun Nov 8 09:16:35 2009 Subject: [Haskell-cafe] Haskell image libraries In-Reply-To: (Max Rabkin's message of "Sun\, 8 Nov 2009 16\:34\:26 +0200") References: Message-ID: >>>>> "Max" == Max Rabkin writes: Max> Haskellers, To add image support to fdo-notify, I need an Max> image type. Looking through Hackage, I didn't find any image Max> library with the following features: * Load from a variety of Max> formats (at least PNG and JPG, I'd say) * Efficient per-pixel Max> access, or a way to dump the image into a ByteString as a Max> bitmap (I need to serialise them into the protocol's bitmap Max> format) Preferably, it should be possible to construct images Max> programmatically too. Max> Is there really no such library? It would be nice to have Max> something like a Haskell equivalent of the Python Imaging Max> Library, which is the de facto standard image library in Max> Python and supports just about every type of operation on Max> images you could ask for. I've found nothing either, having searched recently. -- Colin Adams Preston Lancashire From jeremy at n-heptane.com Sun Nov 8 09:55:44 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Sun Nov 8 09:32:00 2009 Subject: [Haskell-cafe] Haskell image libraries In-Reply-To: References: Message-ID: There is a partial binding to libgd: http://hackage.haskell.org/packages/archive/gd/3000.4.0/doc/html/Graphics-GD.html http://www.libgd.org/Main_Page But GD itself may not do what you want. - jeremy On Nov 8, 2009, at 8:34 AM, Max Rabkin wrote: > Haskellers, > > To add image support to fdo-notify, I need an image type. Looking > through Hackage, I didn't find any image library with the following > features: > * Load from a variety of formats (at least PNG and JPG, I'd say) > * Efficient per-pixel access, or a way to dump the image into a > ByteString as a bitmap (I need to serialise them into the protocol's > bitmap format) > Preferably, it should be possible to construct images > programmatically too. > > Is there really no such library? It would be nice to have something > like a Haskell equivalent of the Python Imaging Library, which is the > de facto standard image library in Python and supports just about > every type of operation on images you could ask for. > > Regards, > Max > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From andrewcoppin at btinternet.com Sun Nov 8 09:58:00 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Nov 8 09:33:55 2009 Subject: [Haskell-cafe] Haskell image libraries In-Reply-To: References: Message-ID: <4AF6DC78.6090706@btinternet.com> Max Rabkin wrote: > Haskellers, > > To add image support to fdo-notify, I need an image type. Looking > through Hackage, I didn't find any image library with the following > features: > * Load from a variety of formats (at least PNG and JPG, I'd say) > * Efficient per-pixel access, or a way to dump the image into a > ByteString as a bitmap (I need to serialise them into the protocol's > bitmap format) > Preferably, it should be possible to construct images programmatically too. > > Is there really no such library? It would be nice to have something > like a Haskell equivalent of the Python Imaging Library, which is the > de facto standard image library in Python and supports just about > every type of operation on images you could ask for. > > Regards, > Max > Try AC-EasyRaster-GTK. It's a thin layer over Gtk2hs that I wrote precisely because it's so fiddly to do bitmapped graphics with Gtk2hs. (Vector graphics is delightfully easy with Cairo, but bitmap graphics requires manual bit-twiddling, and lots of simple but non-obvious API calls.) In particular, Easy Raster will trivially load and save PNG and JPEG images, and provide pixel-level read/write functions (either with or without bounds checks). What I haven't implemented is access to the underlying pixel array. There's a function ib_pixmap which will get you the GTK Pixmap object, from which you can obtain the pixel array. But it's not an IOArray or STArray or anything like that; it's some other datatype that implements the MArray class, so it doesn't buy you much. You might as well just use the pixel read/write functions from Easy Raster and manually iterate all pixels... (Another annoying quirk is that Gtk2hs doesn't provide a way to read or write an image from a handle, only from a real file, so naturally Easy Raster shares the same limitation.) From colin at colina.demon.co.uk Sun Nov 8 10:16:30 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sun Nov 8 09:52:27 2009 Subject: [Haskell-cafe] Haskell image libraries In-Reply-To: (Jeremy Shaw's message of "Sun\, 8 Nov 2009 08\:55\:44 -0600") References: Message-ID: >>>>> "Jeremy" == Jeremy Shaw writes: Jeremy> There is a partial binding to libgd: Jeremy> http://hackage.haskell.org/packages/archive/gd/3000.4.0/doc/html/Graphics-GD.html Jeremy> http://www.libgd.org/Main_Page Jeremy> But GD itself may not do what you want. I ended up using this myself, but it is an unsatisfactory compromise (no support for TIFF - and many other formats, trashes EXIF information). In my innocence I had imagined that GTK (the GIMP ToolKit) would provide all the image manipulation facilities that the GIMP offers. But no. -- Colin Adams Preston Lancashire From deduktionstheorem at web.de Sun Nov 8 10:50:22 2009 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Sun Nov 8 10:26:22 2009 Subject: [Haskell-cafe] Haskell image libraries In-Reply-To: References: Message-ID: <1257695422.14927.8.camel@Garten.fritz.box> On Sun, 2009-11-08 at 16:34 +0200, Max Rabkin wrote: > To add image support to fdo-notify, I need an image type. Looking > through Hackage, I didn't find any image library with the following > features: > * Load from a variety of formats (at least PNG and JPG, I'd say) > * Efficient per-pixel access, or a way to dump the image into a > ByteString as a bitmap (I need to serialise them into the protocol's > bitmap format) > Preferably, it should be possible to construct images programmatically too. What about the imlib bindings [1]? The only problem is, that imlib doesn't provide a functional image type (you'll end up processing the image in the IO monad), but it works quite well (I used it for my Piet interpreter, which required basic image processing tasks like a labelling algorithm). HTH - Stephan [1] http://hackage.haskell.org/package/Imlib -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From deb at pudlak.name Sun Nov 8 10:57:01 2009 From: deb at pudlak.name (Petr Pudlak) Date: Sun Nov 8 10:32:58 2009 Subject: [Haskell-cafe] a problem defining a monad instance In-Reply-To: <20091106180809.GA20150@pudlak.name> References: <20091106180809.GA20150@pudlak.name> Message-ID: <20091108155701.GA8004@pudlak.name> Hi, thanks to all for all the helpful answers and references. Maybe I'll try to collect them into a wiki page, if I have time. It looks like that I'm not the only one facing this problem and many people know different tricks how to handle it. Yes, I was thinking about using lists of pairs instead of Maps. But since I expect to have just a little distinct elements, but many >>= operations, lists would probably grow to an enormous sizes, while Maps will remain quite small. The most intriguing idea for me was wrapping my pseudo-monad into the continuation monad. I didn't have time to think it over, but I wondered if the same (or similar) trick could be used to applicative functors (which are not monads) or arrows. (I found out that J. Hughes faced a similar problem in his paper "Programming with Arrows" (p.42), but not with monads but arrows.) Now I can enjoy playing with probabilities :-). Maybe having complex numbers instead of Floats in the Distrib type would be a nice way how to simulate (at least some) quantum computations. RMonad also seems quite promising, and it looks like a more general solution, but I had no time to try it out yet. With best regards, Petr On Fri, Nov 06, 2009 at 07:08:10PM +0100, Petr Pudlak wrote: > Hi all, > > (This is a literate Haskell post.) > > I've encountered a small problem when trying to define a specialized > monad instance. Maybe someone will able to help me or to tell me that > it's impossible :-). > > To elaborate: I wanted to define a data type which is a little bit > similar to the [] monad. Instead of just having a list of possible > outcomes of a computation, I wanted to have a probability associated > with each possible outcome. > > A natural way to define such a structure is to use a map from possible > values to numbers, let's say Floats: > > > module Distribution where > > > > import qualified Data.Map as M > > > > newtype Distrib a = Distrib { undistrib :: M.Map a Float } > > Defining functions to get a monad instance is not difficult. > "return" is just a singleton: > > > dreturn :: a -> Distrib a > > dreturn k = Distrib (M.singleton k 1) > > Composition is a little bit more difficult, but the functionality is > quite natural. (I welcome suggestions how to make the code nicer / more > readable.) However, the exact definition is not so important. > > > dcompose :: (Ord b) => Distrib a -> (a -> Distrib b) -> Distrib b > > dcompose (Distrib m) f = Distrib $ M.foldWithKey foldFn M.empty m > > where > > foldFn a prob umap = M.unionWith (\psum p -> psum + prob * p) umap (undistrib $ f a) > > The problem is the (Ord b) condition, which is required for the Map > functions. When I try to define the monad instance as > > > instance Monad Distrib where > > return = dreturn > > (>>=) = dcompose > > obviously, I get an error at (>>=): > Could not deduce (Ord b) from the context. > > Is there some way around? Either to somehow define the monad, or to > achieve the same functionality without using Map, which requires Ord > instances? > > Thanks a lot, > Petr > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From andrewcoppin at btinternet.com Sun Nov 8 11:02:32 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Nov 8 10:38:27 2009 Subject: [Haskell-cafe] Haskell image libraries In-Reply-To: References: <4AF6DC78.6090706@btinternet.com> Message-ID: <4AF6EB98.10209@btinternet.com> Max Rabkin wrote: > On Sun, Nov 8, 2009 at 5:09 PM, Max Rabkin wrote: > >> On Sun, Nov 8, 2009 at 4:58 PM, Andrew Coppin >> wrote: >> >>> Try AC-EasyRaster-GTK. >>> >> Thanks, I'll give that a try >> > > Having downloaded it, I must admit I was a bit put off by seeing things like > init_system :: IO () > process_event :: IO () > wait_event :: IO () > main_loop :: IO () > in an image library. > > But it's the best we've got right now, so I've got a couple questions: > is it safe to call init_system more than once? And what do I need the > event-handling functions for, if anything? > If all you want to do is load/save images and do pixel I/O on them, you can completely ignore process_event, wait_event, main_loop, etc. All you need to do is make sure you call init_system at the start of your program. (You see the ib_display function? If you want *that* to work properly, you need to run the GTK event loop, which is what these event-related functions are all about. If you're not trying to display the image on screen, you can ignore all that.) I should probably make the documentation clearer... From felipe.lessa at gmail.com Sun Nov 8 11:32:06 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sun Nov 8 11:08:11 2009 Subject: [Haskell-cafe] Haskell image libraries In-Reply-To: References: Message-ID: <20091108163205.GA14024@kira.casa> On Sun, Nov 08, 2009 at 04:34:26PM +0200, Max Rabkin wrote: > To add image support to fdo-notify, I need an image type. Looking > through Hackage, I didn't find any image library with the following > features: > * Load from a variety of formats (at least PNG and JPG, I'd say) > * Efficient per-pixel access, or a way to dump the image into a > ByteString as a bitmap (I need to serialise them into the protocol's > bitmap format) If all you want is loading, dumping and saving, there's DevIL[1]. http://hackage.haskell.org/package/Codec-Image-DevIL http://openil.sourceforge.net/ -- Felipe. From nowgate at yahoo.com Sun Nov 8 14:51:21 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Nov 8 14:27:16 2009 Subject: [Haskell-cafe] Area from [(x,y)] using foldl Message-ID: <523481.14037.qm@web31106.mail.mud.yahoo.com> Here's an (Fortran) algorithm for calculating an area, given? one dimensional arrays of Xs and Ys. I wrote a recursive Haskell function that works, and one using FOLDL that doesn't. Why would Haskell be "expecting" (t, t) out of ((*) (xold-x) (yold+y))? Michael ==================== ?? AREA = 0.0 ?? XOLD = XVERT(NVERT) ?? YOLD = YVERT(NVERT) ?? DO 10 N = 1, NVERT ?????????? X = XVERT(N) ?????????? Y = YVERT(N) ?????????? AREA = AREA + (XOLD - X)*(YOLD + Y) ?????????? XOLD = X ?????????? YOLD = Y 10 CONTINUE ?? AREA = 0.5*AREA ==================== area :: [(Double,Double)] -> Double area ps = abs $ (/2) $ area' (last ps) ps ??????????? where area' _ [] = 0 ????????????????? area' (x0,y0) ((x,y):ps) = (x0-x)*(y0+y) + area' (x,y) ps *Main> let p = [(0.0,0.0),(1.0,0.0),(1.0,1.0),(0.0,1.0),(0.0,0.0)] *Main> area (last p) p 1.0 *Main> ==================== area :: [(Double,Double)] -> Double area p = foldl (\ (xold,yold) (x,y) -> ((*) (xold-x) (yold+y))) 0 ((last p):p) Prelude> :l area [1 of 1] Compiling Main???????????? ( area.hs, interpreted ) area.hs:29:40: ??? Occurs check: cannot construct the infinite type: t = (t, t) ????? Expected type: (t, t) ????? Inferred type: t ??? In the expression: ((*) (xold - x) (yold + y)) ??? In the first argument of `foldl', namely ??????? `(\ (xold, yold) (x, y) -> ((*) (xold - x) (yold + y)))' Failed, modules loaded: none. Prelude> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091108/2442e0ee/attachment.html From ekirpichov at gmail.com Sun Nov 8 14:56:02 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sun Nov 8 14:31:57 2009 Subject: [Haskell-cafe] Area from [(x,y)] using foldl In-Reply-To: <523481.14037.qm@web31106.mail.mud.yahoo.com> References: <523481.14037.qm@web31106.mail.mud.yahoo.com> Message-ID: <5e0214850911081156k691dc53ard7eabd6c1cd2d91b@mail.gmail.com> The type of foldl is: (b -> a -> b) -> b -> [a] -> b What do you expect 'a' and 'b' to be in your algorithm? 2009/11/8 michael rice > Here's an (Fortran) algorithm for calculating an area, given one > dimensional > arrays of Xs and Ys. I wrote a recursive Haskell function that works, and > one using > FOLDL that doesn't. Why would Haskell be "expecting" (t, t) out of ((*) > (xold-x) (yold+y))? > > Michael > > ==================== > > AREA = 0.0 > XOLD = XVERT(NVERT) > YOLD = YVERT(NVERT) > DO 10 N = 1, NVERT > X = XVERT(N) > Y = YVERT(N) > AREA = AREA + (XOLD - X)*(YOLD + Y) > XOLD = X > YOLD = Y > 10 CONTINUE > > AREA = 0.5*AREA > > ==================== > > area :: [(Double,Double)] -> Double > area ps = abs $ (/2) $ area' (last ps) ps > where area' _ [] = 0 > area' (x0,y0) ((x,y):ps) = (x0-x)*(y0+y) + area' (x,y) ps > > > > *Main> let p = [(0.0,0.0),(1.0,0.0),(1.0,1.0),(0.0,1.0),(0.0,0.0)] > *Main> area (last p) p > 1.0 > *Main> > > ==================== > > area :: [(Double,Double)] -> Double > area p = foldl (\ (xold,yold) (x,y) -> ((*) (xold-x) (yold+y))) 0 ((last > p):p) > > > Prelude> :l area > [1 of 1] Compiling Main ( area.hs, interpreted ) > > area.hs:29:40: > Occurs check: cannot construct the infinite type: t = (t, t) > Expected type: (t, t) > Inferred type: t > In the expression: ((*) (xold - x) (yold + y)) > In the first argument of `foldl', namely > `(\ (xold, yold) (x, y) -> ((*) (xold - x) (yold + y)))' > Failed, modules loaded: none. > Prelude> > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Eugene Kirpichov Web IR developer, market.yandex.ru -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091108/b08ae3f2/attachment.html From nowgate at yahoo.com Sun Nov 8 15:04:03 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Nov 8 14:39:59 2009 Subject: [Haskell-cafe] Area from [(x,y)] using foldl In-Reply-To: <5e0214850911081156k691dc53ard7eabd6c1cd2d91b@mail.gmail.com> Message-ID: <936366.47978.qm@web31101.mail.mud.yahoo.com> Of course! Back to the drawing board. Thanks, Michael --- On Sun, 11/8/09, Eugene Kirpichov wrote: From: Eugene Kirpichov Subject: Re: [Haskell-cafe] Area from [(x,y)] using foldl To: "michael rice" Cc: haskell-cafe@haskell.org Date: Sunday, November 8, 2009, 2:56 PM The type of foldl is:(b -> a -> b) -> b -> [a] -> b What do you expect 'a' and 'b' to be in your algorithm? 2009/11/8 michael rice Here's an (Fortran) algorithm for calculating an area, given? one dimensional arrays of Xs and Ys. I wrote a recursive Haskell function that works, and one using FOLDL that doesn't. Why would Haskell be "expecting" (t, t) out of ((*) (xold-x) (yold+y))? Michael ==================== ?? AREA = 0.0 ?? XOLD = XVERT(NVERT) ?? YOLD = YVERT(NVERT) ?? DO 10 N = 1, NVERT ?????????? X = XVERT(N) ?????????? Y = YVERT(N) ?????????? AREA = AREA + (XOLD - X)*(YOLD + Y) ?????????? XOLD = X ?????????? YOLD = Y 10 CONTINUE ?? AREA = 0.5*AREA ==================== area :: [(Double,Double)] -> Double area ps = abs $ (/2) $ area' (last ps) ps ??????????? where area' _ [] = 0 ????????????????? area' (x0,y0) ((x,y):ps) = (x0-x)*(y0+y) + area' (x,y) ps *Main> let p = [(0.0,0.0),(1.0,0.0),(1.0,1.0),(0.0,1.0),(0.0,0.0)] *Main> area (last p) p 1.0 *Main> ==================== area :: [(Double,Double)] -> Double area p = foldl (\ (xold,yold) (x,y) -> ((*) (xold-x) (yold+y))) 0 ((last p):p) Prelude> :l area [1 of 1] Compiling Main???????????? ( area.hs, interpreted ) area.hs:29:40: ??? Occurs check: cannot construct the infinite type: t = (t, t) ????? Expected type: (t, t) ????? Inferred type: t ??? In the expression: ((*) (xold - x) (yold + y)) ??? In the first argument of `foldl', namely ??????? `(\ (xold, yold) (x, y) -> ((*) (xold - x) (yold + y)))' Failed, modules loaded: none. Prelude> _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Eugene Kirpichov Web IR developer, market.yandex.ru -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091108/4ca892dc/attachment.html From phi500ac at yahoo.ca Sun Nov 8 15:18:01 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Sun Nov 8 14:53:57 2009 Subject: [Haskell-cafe] Small Japi binding for GHC In-Reply-To: <878wehfkyk.fsf@malde.org> Message-ID: <13882.49461.qm@web58802.mail.re1.yahoo.com> Ketil Malde wrote: > If nothing else, perhaps you would make your modifications available? > That way, the next JAPI user will have less trouble than you did. > (Assming the license allows it, of course.) JAPI? license allows it. In fact, it is one of the most liberal licenses I saw. It says: is free software. You can use under the conditions of the licence GNU Lesser General Public License In short this means that you can use free of charge and you can also embed it into proprietary, non-free software. Could you tell me what should I do to make my version and examples available? > Did you try to identify and email the original author? No, the author does not provide an email. In fact, I am not sure whether my implementation is idiomatic. Therefore, I would prefer to use the patches of the original author. --- On Sun, 11/8/09, Ketil Malde wrote: From: Ketil Malde Subject: Re: [Haskell-cafe] Small Japi binding for GHC To: haskell-cafe@haskell.org Received: Sunday, November 8, 2009, 2:02 AM Philippos Apolinarius writes: > So, I searched for JAPI bindings for Haskell. The only library I found > was something called Small Japi binding for GHC.? The package? is > incomplete, and? bug ridden. I don't know anything about this particular library, but this happens. Now that we have Cabal and Hackage making tons of libraries easily available, what's still missing is a good way of ranking equivalent libraries by completeness and usefulness. > I wonder whether the author fixed the > bugs, completed the package, and added more examples. Did you try to identify and email the original author? > In the mean time, I fixed the bugs of Small Japi Binding, and > added a few important components (j_textfield, j_settext, j_gettext, > j_button, etc.) Of course, a link to a more recent version of the > official binding will save me a? lot of work. If nothing else, perhaps you would make your modifications available? That way, the next JAPI user will have less trouble than you did. (Assming the license allows it, of course.) -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 __________________________________________________________________ Get a sneak peak at messages with a handy reading pane with All new Yahoo! Mail: http://ca.promos.yahoo.com/newmail/overview2/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091108/78fe6f0e/attachment.html From ketil at malde.org Sun Nov 8 15:25:41 2009 From: ketil at malde.org (Ketil Malde) Date: Sun Nov 8 15:01:30 2009 Subject: [Haskell-cafe] Small Japi binding for GHC In-Reply-To: <13882.49461.qm@web58802.mail.re1.yahoo.com> (Philippos Apolinarius's message of "Sun, 8 Nov 2009 12:18:01 -0800 (PST)") References: <13882.49461.qm@web58802.mail.re1.yahoo.com> Message-ID: <87ws20epbu.fsf@malde.org> Philippos Apolinarius writes: > Could you tell me what should I do to make my version and examples available? 1) Make sure it builds with cabal. 2) Upload it to Hackage And optionally, 3) make the darcs repository available on the web The process is nicely described here: http://www.haskell.org/haskellwiki/How_to_write_a_Haskell_program#Structure_of_a_simple_project -k -- If I haven't seen further, it is by standing in the footprints of giants From dvde at gmx.net Sun Nov 8 15:44:35 2009 From: dvde at gmx.net (Daniel van den Eijkel) Date: Sun Nov 8 15:20:47 2009 Subject: [Haskell-cafe] Re: virus/trojan in bamse package? In-Reply-To: References: <4AF59218.6020604@gmx.net> Message-ID: <4AF72DB3.3050701@gmx.net> Thank you for that answer. All I could find out is that the file that causes the alarm is named "folder.exe" (size: 82kb). I don't know for sure what that is, but since I don't need the package I simply deleted it. Probably it was just a coincidence that I had some trojan problems just after zipping and unzipping that hackage torrent... Regards, Daniel Jannis (jix) Harder schrieb: > Am 07.11.2009, 16:28 Uhr, schrieb Daniel van den Eijkel : > >> hi, >> >> my Avira antivirus program says that there is a trojan in the >> bamse-0.9.5 package. I downloaded the hackage-torrent a week ago, and >> Avira says "TR/Crypt.CFI.Gen" is in bamse. To be sure, I downloaded >> bamse-0.9.5 from hackage today, and now avira says less specificly >> that there are "some viruses and/or unwanted programs" inside. > > .Gen usually means that the file isn't a known virus but some heuristics > triggered. This can also happen if a file is compressed with an > executable > packer that the virus scanner can't decompress, which wouldn't be strange > for an installer tool. I don't know if that's the problem in this case > but I had a lot of trouble with virus scanners in combination with > executable packers so it might be. > > -- > Jannis > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From chaddai.fouche at gmail.com Sun Nov 8 15:52:12 2009 From: chaddai.fouche at gmail.com (=?UTF-8?B?Q2hhZGRhw68gRm91Y2jDqQ==?=) Date: Sun Nov 8 15:28:09 2009 Subject: [Haskell-cafe] Area from [(x,y)] using foldl In-Reply-To: <936366.47978.qm@web31101.mail.mud.yahoo.com> References: <5e0214850911081156k691dc53ard7eabd6c1cd2d91b@mail.gmail.com> <936366.47978.qm@web31101.mail.mud.yahoo.com> Message-ID: On Sun, Nov 8, 2009 at 9:04 PM, michael rice wrote: > Of course! Back to the drawing board. > > If I understand the problem correctly, I'm not convinced that foldl is the right approach (nevermind that foldl is almost never what you want, foldl' and foldr being the correct choice almost always). My proposition would be the following : > area ps = abs . (/2) . sum $ zipWith (\(x,y) (x',y') -> (x - x') * (y + y')) ps (tail $ cycle ps) I think it express the algorithm more clearly. -- Jeda? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091108/3c9a81c8/attachment.html From ganesh at earth.li Sun Nov 8 15:57:53 2009 From: ganesh at earth.li (Ganesh Sittampalam) Date: Sun Nov 8 15:33:49 2009 Subject: [Haskell-cafe] call for help: FOSDEM devroom Message-ID: Hi, I'm thinking of trying to get a devroom for haskell.org at the next FOSDEM, which is Saturday-Sunday February 6th-7th 2010 in Brussels: http://www.fosdem.org/2010/call-developer-rooms The idea would be to try to introduce Haskell to people at FOSDEM who were interested, and thus help build our ties with We'd try to have a few introductory talks about Haskell, and some demos etc. It would probably also make sense to talk about/demo darcs at the same time. Apparently there's a lot of demand so it's a bit of a long shot, and I expect we'd only get one day, which is probably all we'd need. To make this work, we'll need several reasonably experienced Haskellers to turn up to help out with the talks, demos and talking to people in general. I've got a couple of people interested already but need more. So, please could you let me know, preferably within the next week, whether you would be interested in coming along and helping. You can email me directly or on-list as you prefer. The deadline for actually making the application for the devroom is 22nd November. Cheers, Ganesh From wikigracenotes at gmail.com Sun Nov 8 16:10:12 2009 From: wikigracenotes at gmail.com (Matthew Gruen) Date: Sun Nov 8 15:46:06 2009 Subject: [Haskell-cafe] Is () a 0-length tuple? In-Reply-To: <7b501d5c0911080321u4b6fcd77g11ded95dd06153a8@mail.gmail.com> References: <2d34474e0911061408od1c1d65xb5a41cd6ee0892dc@mail.gmail.com> <20091106223857.GC23495@colquitt.org> <2d34474e0911071059j56ffece3vf5ecf9e2f13c943b@mail.gmail.com> <2d34474e0911071100r18a7fafem2dd03f88ea798708@mail.gmail.com> <7b501d5c0911080321u4b6fcd77g11ded95dd06153a8@mail.gmail.com> Message-ID: On Sun, Nov 8, 2009 at 6:21 AM, Deniz Dogan wrote: > What point are you trying to make by distinguishing JSON from > JavaScript? JSON is a subset of JavaScript, they share the same type > system. "Null can be only one value." This doesn't make sense to me, > since as you say null is not a type, but a value. > > -- > Deniz Dogan > It seems I underestimated the typedness of null in JavaScript :) I checked the ECMAScript specification, and it does refer to a "null type".. so titto was right.[1] My opinion is that JSON's 'type system' should be analyzed orthogonal to JavaScript's regardless. If JSON is a subset of JavaScript, it is primarily a syntactic one. When I said "Null can be only one value", implying that null is a type, I was referring to JSON's null, not JavaScript's null. In JSON, null *is* definitely a unit type. When considering mappings between Haskell and JSON in the case of (), we should see that () is a unit type in Haskell, null is a unit type in JSON (regardless of its role in JavaScript), and maybe try to associate them. ?Matt [1] I was misled by the fact that typeof null = 'object'. The logic behind this, I think, is that null is meant to be bound to a variable that would otherwise be a reference to an actual object value. Many have criticized this result, e.g. Douglas Crockford ( http://javascript.crockford.com/remedial.html) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091108/a10bb2af/attachment.html From nowgate at yahoo.com Sun Nov 8 16:30:18 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Nov 8 16:06:14 2009 Subject: [Haskell-cafe] Area from [(x,y)] using foldl In-Reply-To: Message-ID: <449242.92412.qm@web31105.mail.mud.yahoo.com> That's certainly better than mine, but I'm lost again, with the following. What seemed like a simple improvement doesn't compile. Michael =============== This works. area :: [(Double,Double)] -> Double area ps = abs $ (/2) $ area' (last ps) ps ??????????? where area' _ [] = 0 ????????????????? area' (x0,y0) ((x,y):ps) = (x0-x)*(y0+y) + area' (x,y) ps *Main> let p = [(0.0,0.0),(1.0,0.0),(1.0,1.0),(0.0,1.0),(0.0,0.0)] *Main> area (last p) p 1.0 *Main> =============== This doesn't. area :: [(Double,Double)] -> Double area p = abs $ (/2) $ area' (last p):p ???????? where area' [] = 0 ?????????????? area' ((x0,y0),(x,y):ps) = ((x0-x)*(y0+y)) + area' (x,y):ps?? --- On Sun, 11/8/09, Chadda? Fouch? wrote: From: Chadda? Fouch? Subject: Re: [Haskell-cafe] Area from [(x,y)] using foldl To: "michael rice" Cc: "Eugene Kirpichov" , haskell-cafe@haskell.org Date: Sunday, November 8, 2009, 3:52 PM On Sun, Nov 8, 2009 at 9:04 PM, michael rice wrote: Of course! Back to the drawing board. If I understand the problem correctly, I'm not convinced that foldl is the right approach (nevermind that foldl is almost never what you want, foldl' and foldr being the correct choice almost always). My proposition would be the following : > area ps = abs . (/2) . sum $ zipWith (\(x,y) (x',y') -> (x - x') * (y + y')) ps (tail $ cycle ps) I think it express the algorithm more clearly. -- Jeda? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091108/f0671c3c/attachment.html From nowgate at yahoo.com Sun Nov 8 16:42:13 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Nov 8 16:18:09 2009 Subject: [Haskell-cafe] Area from [(x,y)] using foldl In-Reply-To: <449242.92412.qm@web31105.mail.mud.yahoo.com> Message-ID: <86196.62362.qm@web31102.mail.mud.yahoo.com> I see what one problem is, what happens when I end up with (x,y):[]? However, I'm confused about how Haskell is "expecting" and "inferring" upon compilation. Michael --- On Sun, 11/8/09, michael rice wrote: From: michael rice Subject: Re: [Haskell-cafe] Area from [(x,y)] using foldl To: "Chadda? Fouch?" Cc: haskell-cafe@haskell.org Date: Sunday, November 8, 2009, 4:30 PM That's certainly better than mine, but I'm lost again, with the following. What seemed like a simple improvement doesn't compile. Michael =============== This works. area :: [(Double,Double)] -> Double area ps = abs $ (/2) $ area' (last ps) ps ??????????? where area' _ [] = 0 ????????????????? area' (x0,y0) ((x,y):ps) = (x0-x)*(y0+y) + area' (x,y) ps *Main> let p = [(0.0,0.0),(1.0,0.0),(1.0,1.0),(0.0,1.0),(0.0,0.0)] *Main> area (last p) p 1.0 *Main> =============== This doesn't. area :: [(Double,Double)] -> Double area p = abs $ (/2) $ area' (last p):p ???????? where area' [] = 0 ?????????????? area' ((x0,y0),(x,y):ps) = ((x0-x)*(y0+y)) + area' (x,y):ps?? --- On Sun, 11/8/09, Chadda? Fouch? wrote: From: Chadda? Fouch? Subject: Re: [Haskell-cafe] Area from [(x,y)] using foldl To: "michael rice" Cc: "Eugene Kirpichov" , haskell-cafe@haskell.org Date: Sunday, November 8, 2009, 3:52 PM On Sun, Nov 8, 2009 at 9:04 PM, michael rice wrote: Of course! Back to the drawing board. If I understand the problem correctly, I'm not convinced that foldl is the right approach (nevermind that foldl is almost never what you want, foldl' and foldr being the correct choice almost always). My proposition would be the following : > area ps = abs . (/2) . sum $ zipWith (\(x,y) (x',y') -> (x - x') * (y + y')) ps (tail $ cycle ps) I think it express the algorithm more clearly. -- Jeda? -----Inline Attachment Follows----- _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091108/cad0ff60/attachment-0001.html From deniz.a.m.dogan at gmail.com Sun Nov 8 16:48:51 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Sun Nov 8 16:25:06 2009 Subject: [Haskell-cafe] Is () a 0-length tuple? In-Reply-To: References: <2d34474e0911061408od1c1d65xb5a41cd6ee0892dc@mail.gmail.com> <20091106223857.GC23495@colquitt.org> <2d34474e0911071059j56ffece3vf5ecf9e2f13c943b@mail.gmail.com> <2d34474e0911071100r18a7fafem2dd03f88ea798708@mail.gmail.com> <7b501d5c0911080321u4b6fcd77g11ded95dd06153a8@mail.gmail.com> Message-ID: <7b501d5c0911081348j3a7dd4b0kec96702d685626@mail.gmail.com> 2009/11/8 Matthew Gruen : > On Sun, Nov 8, 2009 at 6:21 AM, Deniz Dogan > wrote: >> What point are you trying to make by distinguishing JSON from >> JavaScript? JSON is a subset of JavaScript, they share the same type >> system. "Null can be only one value." This doesn't make sense to me, >> since as you say null is not a type, but a value. >> >> -- >> Deniz Dogan >> > > It seems I underestimated the typedness of null in JavaScript :) I checked > the ECMAScript specification, and it does refer to a "null type".. so titto > was right.[1] My opinion is that JSON's 'type system' should be analyzed > orthogonal to JavaScript's regardless. If JSON is a subset of JavaScript, it > is primarily a syntactic one. When I said "Null can be only one value", > implying that null is a type, I was referring to JSON's null, not > JavaScript's null. In JSON, null *is* definitely a unit type. When > considering mappings between Haskell and JSON in the case of (), we should > see that () is a unit type in Haskell, null is a unit type in JSON > (regardless of its role in JavaScript), and maybe try to associate them. > > ?Matt > > [1] I was misled by the fact that typeof null = 'object'. The logic behind > this, I think, is that null is meant to be bound to a variable that would > otherwise be a reference to an actual object value. Many have criticized > this result, e.g. Douglas Crockford > (http://javascript.crockford.com/remedial.html) > Let's keep in mind when reading the ECMAScript specification that JavaScript is merely based on it and breaks it on several different points. :) -- Deniz Dogan From caseyh at istar.ca Sun Nov 8 17:05:58 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Sun Nov 8 16:42:00 2009 Subject: [Haskell-cafe] Area from [(x,y)] using foldl In-Reply-To: <86196.62362.qm@web31102.mail.mud.yahoo.com> References: <449242.92412.qm@web31105.mail.mud.yahoo.com> <86196.62362.qm@web31102.mail.mud.yahoo.com> Message-ID: <51gef5di3j4or1mri0c5m69smnvglfrfth@4ax.com> How about these type signatures. import Data.List poly1 = [(0,1),(5,0),(3,4)]::[(Double,Double)] areaPoly :: [(Double,Double)] -> Double areaPolyCalc :: (Double,(Double,Double)) -> (Double,Double) -> (Double,(Double,Double)) areaPoly (pt:pts) = 0.5 * (fst (foldl' areaPolyCalc (0,pt) pts)) areaPolyCalc (sum,(x,y)) (xNext,yNext) = (sum + (x * yNext - xNext * y),(xNext,yNext)) -- Regards, Casey From caseyh at istar.ca Sun Nov 8 17:13:38 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Sun Nov 8 16:49:38 2009 Subject: [Haskell-cafe] Area from [(x,y)] using foldl In-Reply-To: <86196.62362.qm@web31102.mail.mud.yahoo.com> References: <449242.92412.qm@web31105.mail.mud.yahoo.com> <86196.62362.qm@web31102.mail.mud.yahoo.com> Message-ID: How about these BETTER type signatures. -- Area of a Polygon import Data.List type X = Double type Y = Double type Area = Double poly1 = [(0,1),(5,0),(3,4)]::[(X,Y)] areaPoly :: [(X,Y)] -> Area areaPolyCalc :: (Area,(X,Y)) -> (X,Y) -> (Area,(X,Y)) areaPoly (pt:pts) = 0.5 * (fst (foldl' areaPolyCalc (0,pt) pts)) areaPolyCalc (sum,(x,y)) (xNext,yNext) = (sum + (x * yNext - xNext * y),(xNext,yNext)) -- Regards, Casey From hjgtuyl at chello.nl Sun Nov 8 17:16:46 2009 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Sun Nov 8 16:52:43 2009 Subject: [Haskell-cafe] Haskell image libraries In-Reply-To: References: Message-ID: wxHaskell contains functions to read and write images, for example imageGetPixels [1] and imageCreateFromPixelArray [2] Met vriendelijke groet, Henk-Jan van Tuyl [1] http://hackage.haskell.org/packages/archive/wxcore/0.10.13.0/doc/html/Graphics-UI-WXCore-Image.html#v:imageGetPixels [2] http://hackage.haskell.org/packages/archive/wxcore/0.10.13.0/doc/html/Graphics-UI-WXCore-Image.html#v%3AimageCreateFromPixelArray -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html -- On Sun, 08 Nov 2009 15:34:26 +0100, Max Rabkin wrote: > Haskellers, > > To add image support to fdo-notify, I need an image type. Looking > through Hackage, I didn't find any image library with the following > features: > * Load from a variety of formats (at least PNG and JPG, I'd say) > * Efficient per-pixel access, or a way to dump the image into a > ByteString as a bitmap (I need to serialise them into the protocol's > bitmap format) > Preferably, it should be possible to construct images programmatically > too. > > Is there really no such library? It would be nice to have something > like a Haskell equivalent of the Python Imaging Library, which is the > de facto standard image library in Python and supports just about > every type of operation on images you could ask for. > > Regards, > Max From kowey at darcs.net Sun Nov 8 17:19:42 2009 From: kowey at darcs.net (Eric Kow) Date: Sun Nov 8 16:55:41 2009 Subject: [Haskell-cafe] getting ready to sprint! darcs: 14-15 Nov, Portland/Vienna Message-ID: <20091108221941.GA6648@dewdrop.local> Hi everybody, We're less than one week away from the third Darcs Hacking Sprint, taking place in Portland and in Vienna on 14-15 November. Everybody is welcome (Haskell and Darcs newbies included), but please do let us know if you're thinking of attending! Preflight checklist ------------------- We've got our work cut out for us, so we want to make sure that we can hit the ground running. Here are three things each participant can do to help: 1. Request a code.haskell.org account http://community.haskell.org/admin/ 2. Build Darcs (install the Haskell Platform if needed) cabal install darcs darcs get --lazy http://darcs.net darcs cd darcs cabal install 3. Tell Eric your code.haskell.org login This is so that I can add you to the Darcs group Vienna Friday ------------- There's going to be quite a few of us arriving in Vienna on Friday. I propose we meet up at the Hostel Ruthensteiner, say at 11:00 for morning arrivals and 16:30 for those of us getting there in the afternoon. Perhaps we could walk around a bit, have a nice relaxed chat, find some food :-) http://www.hostelruthensteiner.com/ Meetings -------- There are few things we'll be talking about over the sprint (eg, darcs 2.4, SVN integration, filecache). If you're interested in joining in, please put your name down on the wiki so that we can work out a rough schedule. http://wiki.darcs.net/Sprints/2009-11 Nothing formal. Maybe just lunch and me scribbling in a notebook. Or maybe Darcs Hackers gesticulating wildly in front a white board. See you there -------------- That's all for now. Please shout if you have any questions or last minute comments. Otherwise, I'm really excited about this and looking forward to seeing you all this weekend! -- Eric Kow PGP Key ID: 08AC04F9 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 195 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091108/4f707702/attachment.bin From aca08sas at shef.ac.uk Sun Nov 8 17:24:59 2009 From: aca08sas at shef.ac.uk (spot135) Date: Sun Nov 8 17:00:54 2009 Subject: [Haskell-cafe] bit of help with n-ary please... Message-ID: <26258006.post@talk.nabble.com> Hi, Ok what im trying to do is replace an element in an n-ary and display the completed tree. So this is what ive got so far. data Tree a = Empty |Leaf a|Branch a [Tree a] deriving (Show) replace :: Eq a=>a->a->Tree a -> (Tree a) replace x y Empty = Element x replace x y (Leaf z) | x==z = (Leaf y) -- | otherwise = replace x y (Branch z lis) | x==z = (Branch y lis) |otherwise = replaceA x y clis replaceA :: Eq a=> a->a->[Tree a]->(Tree a) replaceA _ _ [] = Empty -- run out replaceA x y (h:r) |Q suc = suc |otherwise = replaceA x y r where suc=replace x y h Q :: a -> Bool Q a = True Q a = False Theres two main problems i am having. One is I'm not sure what should be the "otherwise" in the leaf function. Another problem is it doesn't show the whole tree just the part after the replacement. If you think this is complete bull I'll quite happily start over if somebody could give me some insight into what is the best way of tackling this problem is. Many thanks in advance spot -- View this message in context: http://old.nabble.com/bit-of-help-with-n-ary-please...-tp26258006p26258006.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From akshay.v.dave at hotmail.com Sun Nov 8 17:39:51 2009 From: akshay.v.dave at hotmail.com (Akshay Dave) Date: Sun Nov 8 17:15:49 2009 Subject: [Haskell-cafe] Urgent: Please suggest me for Flow Caml Compiler Message-ID: Hello, I undertsand that this is Haskell cafe discussion forum. But I would highly appreciate if anyone can tell me where can I get Compiler and editor for FLow Caml ( it's a ML based language)) as I am not able to find it on net :(. Thanks in Adavnce! Akshay _________________________________________________________________ Hotmail: Trusted email with Microsoft's powerful SPAM protection. http://clk.atdmt.com/GBL/go/177141664/direct/01/ http://clk.atdmt.com/GBL/go/177141664/direct/01/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091108/fc9e660f/attachment.html From caseyh at istar.ca Sun Nov 8 17:44:29 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Sun Nov 8 17:20:30 2009 Subject: [Haskell-cafe] Area from [(x,y)] using foldl In-Reply-To: <86196.62362.qm@web31102.mail.mud.yahoo.com> References: <449242.92412.qm@web31105.mail.mud.yahoo.com> <86196.62362.qm@web31102.mail.mud.yahoo.com> Message-ID: Sorry, I forgot to add that if the polygon is very far from the origin, you may have overflow or increased round off error; it is better to translate the polygon back to the origin, before doing the area calculation. How about these BETTER type signatures. -- Area of a Polygon import Data.List type X = Double type Y = Double type Area = Double poly1 = [(0,1),(5,0),(3,4)]::[(X,Y)] areaPoly :: [(X,Y)] -> Area areaPolyCalc :: (Area,(X,Y)) -> (X,Y) -> (Area,(X,Y)) areaPoly (pt:pts) = 0.5 * (fst (foldl' areaPolyCalc (0,pt) pts)) areaPolyCalc (sum,(x,y)) (xNext,yNext) = (sum + (x * yNext - xNext * y),(xNext,yNext)) -- Regards, Casey From nowgate at yahoo.com Sun Nov 8 18:07:45 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Nov 8 17:43:40 2009 Subject: [Haskell-cafe] Area from [(x,y)] using foldl In-Reply-To: Message-ID: <793939.40495.qm@web31108.mail.mud.yahoo.com> Hi Casey, I was already aware of the translation thing, but didn't want to complicate. Lot's of ways to skin a cat. I wrote a Lispy solution, then had the feeling I could improve on it w/Haskell. Picking the right tool takes practice. Thanks, Michael --- On Sun, 11/8/09, Casey Hawthorne wrote: From: Casey Hawthorne Subject: Re: [Haskell-cafe] Area from [(x,y)] using foldl To: haskell-cafe@haskell.org Date: Sunday, November 8, 2009, 5:44 PM Sorry, I forgot to add that if the polygon is very far from the origin, you may have overflow or increased round off error; it is better to translate the polygon back to the origin, before doing the area calculation. How about these BETTER type signatures. -- Area of a Polygon ? ? import Data.List type X = Double type Y = Double type Area = Double ? ? poly1 = [(0,1),(5,0),(3,4)]::[(X,Y)] areaPoly :: [(X,Y)] -> Area areaPolyCalc :: (Area,(X,Y)) -> (X,Y) -> (Area,(X,Y)) areaPoly (pt:pts) = 0.5 * (fst (foldl' areaPolyCalc (0,pt) pts)) areaPolyCalc (sum,(x,y)) (xNext,yNext) = ??? ??? ??? (sum + (x * yNext - xNext * y),(xNext,yNext)) -- Regards, Casey _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091108/ee8342a0/attachment.html From mle+hs at mega-nerd.com Sun Nov 8 18:14:56 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Sun Nov 8 17:50:57 2009 Subject: [Haskell-cafe] Urgent: Please suggest me for Flow Caml Compiler In-Reply-To: References: Message-ID: <20091109101456.6c9b0c66.mle+hs@mega-nerd.com> Akshay Dave wrote: > I undertsand that this is Haskell cafe discussion forum. But > I would highly appreciate if anyone can tell me where can I get > Compiler and editor for FLow Caml ( it's a ML based language)) as > I am not able to find it on net :(. I suggest that the ocaml mailing list would be a much better place to ask: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From aca08sas at shef.ac.uk Sun Nov 8 18:40:03 2009 From: aca08sas at shef.ac.uk (spot135) Date: Sun Nov 8 18:15:57 2009 Subject: [Haskell-cafe] bit of help with n-ary please... In-Reply-To: <26258006.post@talk.nabble.com> References: <26258006.post@talk.nabble.com> Message-ID: <26259268.post@talk.nabble.com> Anybody? thanks spot135 wrote: > > > Hi, > > Ok what im trying to do is replace an element in an n-ary and display the > completed tree. > > So this is what ive got so far. > > data Tree a = Empty |Leaf a|Branch a [Tree a] > deriving (Show) > > > replace :: Eq a=>a->a->Tree a -> (Tree a) > > replace x y Empty = Element x > > replace x y (Leaf z) > | x==z = (Leaf y) > -- | otherwise = > > replace x y (Branch z lis) > | x==z = (Branch y lis) > |otherwise = replaceA x y clis > > > replaceA :: Eq a=> a->a->[Tree a]->(Tree a) > replaceA _ _ [] = Empty -- run out > replaceA x y (h:r) > |Q suc = suc > |otherwise = replaceA x y r > where suc=replace x y h > > Q :: a -> Bool > Q a = True > Q a = False > > Theres two main problems i am having. One is I'm not sure what should be > the "otherwise" in the leaf function. Another problem is it doesn't show > the whole tree just the part after the replacement. > > If you think this is complete bull I'll quite happily start over if > somebody could give me some insight > into what is the best way of tackling this problem is. > > Many thanks in advance > > spot > > > > -- View this message in context: http://old.nabble.com/bit-of-help-with-n-ary-please...-tp26258006p26259268.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From caseyh at istar.ca Sun Nov 8 18:44:03 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Sun Nov 8 18:20:16 2009 Subject: [Haskell-cafe] Area from [(x,y)] using foldl In-Reply-To: <793939.40495.qm@web31108.mail.mud.yahoo.com> References: <793939.40495.qm@web31108.mail.mud.yahoo.com> Message-ID: On Sun, 8 Nov 2009 15:07:45 -0800 (PST), you wrote: >Hi Casey, > >I was already aware of the translation thing, but didn't want to complicate. > >Lot's of ways to skin a cat. I wrote a Lispy solution, then had the feeling I could improve on it w/Haskell. Picking the right tool takes practice. > >Thanks, > >Michael Since Haskell is a pure functional language, it adds lazy evaluation as another tool to your modularity toolbox. Lazy evaluation separates control from computation, so, if the computation of sum is going off the rails (and I don't mean Ruby on Rails), one can prematurely terminate the calculation, without evaluating more points. > >--- On Sun, 11/8/09, Casey Hawthorne wrote: > >From: Casey Hawthorne >Subject: Re: [Haskell-cafe] Area from [(x,y)] using foldl >To: haskell-cafe@haskell.org >Date: Sunday, November 8, 2009, 5:44 PM > >Sorry, I forgot to add that if the polygon is very far from the >origin, you may have overflow or increased round off error; it is >better to translate the polygon back to the origin, before doing the >area calculation. > > >How about these BETTER type signatures. > >-- Area of a Polygon >? ? >import Data.List > >type X = Double >type Y = Double >type Area = Double > >? ? >poly1 = [(0,1),(5,0),(3,4)]::[(X,Y)] > > >areaPoly :: [(X,Y)] -> Area > > >areaPolyCalc :: (Area,(X,Y)) -> (X,Y) -> (Area,(X,Y)) > > > > > > > > > > > > > > > > > > > > > > > > > >areaPoly (pt:pts) = 0.5 * (fst (foldl' areaPolyCalc (0,pt) pts)) > >areaPolyCalc (sum,(x,y)) (xNext,yNext) = >??? ??? ??? (sum + (x * yNext - xNext * y),(xNext,yNext)) -- Regards, Casey From caseyh at istar.ca Sun Nov 8 19:05:36 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Sun Nov 8 18:41:36 2009 Subject: [Haskell-cafe] bit of help with n-ary please... In-Reply-To: <26259268.post@talk.nabble.com> References: <26258006.post@talk.nabble.com> <26259268.post@talk.nabble.com> Message-ID: <7qmef55hvdasvbsqa2oraf7m4eohpsonrd@4ax.com> I don't know if this is homework. I suppose what you mean is the following: I'm trying to replace an element in an n-ary tree and display the completed tree. A more precise specification might help. - is the tree ordered - are all the elements in the leaves (not internal nodes) - is the location of the element to be replaced given? -- if so how? - is the tree supposed to be balanced? On Sun, 8 Nov 2009 15:40:03 -0800 (PST), you wrote: > > >Anybody? thanks > > > > >spot135 wrote: >> >> >> Hi, >> >> Ok what im trying to do is replace an element in an n-ary and display the >> completed tree. >> >> So this is what ive got so far. >> -- Regards, Casey From daniel.is.fischer at web.de Sun Nov 8 19:12:40 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Nov 8 18:52:06 2009 Subject: [Haskell-cafe] bit of help with n-ary please... In-Reply-To: <26258006.post@talk.nabble.com> References: <26258006.post@talk.nabble.com> Message-ID: <200911090112.41128.daniel.is.fischer@web.de> Am Sonntag 08 November 2009 23:24:59 schrieb spot135: > Hi, > > Ok what im trying to do is replace an element in an n-ary and display the > completed tree. > > So this is what ive got so far. > > data Tree a = Empty |Leaf a|Branch a [Tree a] > deriving (Show) > replace x y tree should give a tree with the same structure, values equal to x should be replaced by y, all other values left as they are? > > replace :: Eq a=>a->a->Tree a -> (Tree a) > > replace x y Empty = Element x That should surely be replace _ _ Empty = Empty ? > > replace x y (Leaf z) > > | x==z = (Leaf y) > > -- | otherwise = | otherwise = Leaf z > > replace x y (Branch z lis) > > | x==z = (Branch y lis) > |otherwise = replaceA x y clis You'd want to recur, I believe, use map (replace x y) > > replaceA :: Eq a=> a->a->[Tree a]->(Tree a) > replaceA _ _ [] = Empty -- run out > replaceA x y (h:r) > > |Q suc = suc > |otherwise = replaceA x y r > > where suc=replace x y h > > Q :: a -> Bool > Q a = True > Q a = False > > Theres two main problems i am having. One is I'm not sure what should be > the "otherwise" in the leaf function. Another problem is it doesn't show > the whole tree just the part after the replacement. > > If you think this is complete bull I'll quite happily start over if > somebody could give me some insight > into what is the best way of tackling this problem is. > > Many thanks in advance > > spot From aca08sas at shef.ac.uk Sun Nov 8 19:28:17 2009 From: aca08sas at shef.ac.uk (spot135) Date: Sun Nov 8 19:04:13 2009 Subject: [Haskell-cafe] bit of help with n-ary please... In-Reply-To: <7qmef55hvdasvbsqa2oraf7m4eohpsonrd@4ax.com> References: <26258006.post@talk.nabble.com> <26259268.post@talk.nabble.com> <7qmef55hvdasvbsqa2oraf7m4eohpsonrd@4ax.com> Message-ID: <26259580.post@talk.nabble.com> Hi Casey, Answers to spec. the tree is not ordered, it holds string varying in length. the element value is given, but not its location ie (replace "Two" "Five" Tree a) would find the location of element "Two" and replace it with "Five" the tree is not balanced, Nodes can have other Nodes coming off them as well as Leaves, the number of leaves per node vary as well. Is that ok? Casey Hawthorne wrote: > > I don't know if this is homework. > > I suppose what you mean is the following: I'm trying to replace an > element in an n-ary tree and display the completed tree. > > A more precise specification might help. > - is the tree ordered > - are all the elements in the leaves (not internal nodes) > - is the location of the element to be replaced given? > -- if so how? > - is the tree supposed to be balanced? > > > > On Sun, 8 Nov 2009 15:40:03 -0800 (PST), you wrote: > >> >> >>Anybody? thanks >> >> >> >> >>spot135 wrote: >>> >>> >>> Hi, >>> >>> Ok what im trying to do is replace an element in an n-ary and display >>> the >>> completed tree. >>> >>> So this is what ive got so far. >>> > > > > -- > Regards, > Casey > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://old.nabble.com/bit-of-help-with-n-ary-please...-tp26258006p26259580.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ok at cs.otago.ac.nz Sun Nov 8 20:03:16 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Sun Nov 8 19:39:14 2009 Subject: [Haskell-cafe] Re: What's the deal with Clean? In-Reply-To: <87iqdlh0px.fsf@malde.org> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <1BFBEDAF-236D-4645-A0C2-8A7AB83FD213@swierstra.net> <87iqdlh0px.fsf@malde.org> Message-ID: <521E35F4-E00C-42EB-B24C-0ADE26BADFF5@cs.otago.ac.nz> >>>> >>>> One of this differences between Haskell and Clean I did not see >>>> mentioned in >>>> this discussion is that Clean does not allow so-called partial >>>> parametrisation. I.e. all function calls have to be fully saturated I think there may be a misunderstanding here. Beware: I haven't used Clean in a while. (1) Clean didn't have sections. This is no big deal. Clean does have "flip" in StdFunc. (x +) => (+) x (+ y) => (flip (+)) y (2) Clean requires saturated *DEFINITIONS*. If you declare f :: A B C -> D then each rule you give for f must have exactly three arguments. If you declare f :: A -> B -> C -> D then each rule you give for f must have exactly one argument. See section 3.7 of the Clean 2.1 language report. This has no consequences for how you can *apply* such a function. Section 3.7.1 of the report is explicit: In CLEAN all symbols (functions and constructors) are defined with fixed arity. However, in an application it is of course allowed to apply them to an arbitrary number of arguments. A curried application of a function is an application of a function with a number of arguments which is less than its arity (note that in CLEAN the arity of a function can be derived from its type). With the aid of the predefined internal function _AP a curried function applied on the required number of arguments is transformed into an equivalent uncurried function application. The type axiom's (sic.) of the CLEAN type system include for all s defined with arity n the equivalence of s::(t1->(t2->(...(tn->tr)...)) with s::t1 t2 ... tn -> tr. From phi500ac at yahoo.ca Sun Nov 8 22:29:12 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Sun Nov 8 22:05:06 2009 Subject: [Haskell-cafe] Cabal Message-ID: <334011.49628.qm@web58806.mail.re1.yahoo.com> I made small improvements in the Small Japi Binding, and asked how to make it available. I received a few private messages advising me to build and package the library using a tool called cabal. Since I have used installation tools for PLT, R? and LaTeX libraries, I thought cabal was something similar. However, I noticed that there are a lot of complaints against cabal.? Therefore, I decided to install cabal, and try it. It seems that it is easier to install packages by hand than using cabal.? Here is a typical cabal session: D:\ghc\ghcapi>cabal update Downloading the latest package list from hackage.haskell.org D:\ghc\ghcapi>cabal install mkcabal Resolving dependencies... Downloading pcre-light-0.3.1... Configuring pcre-light-0.3.1... Downloading readline-1.0.1.0... Configuring readline-1.0.1.0... cabal: Error: some packages failed to install: mkcabal-0.4.2 depends on readline-1.0.1.0 which failed to install. pcre-light-0.3.1 failed during the configure step. The exception was: exit: ExitFailure 1 readline-1.0.1.0 failed during the configure step. The exception was: exit: ExitFailure 1 As one can see, it is much more difficult to use than R installation tools, or MikTeX installation tools.? If cabal is so difficult, why use it? I am sure that I have done something very stupid mistake, but believe me, a lot of people is trying to use cabal and failing. I am not? sure that it is a good idea to distribute libraries using cabal. However, this is irrelevant, because I am sure that creating a package with cabal is well beyond my powers. It is much easier to write a complete JAPI library, than packaging it in cabal. __________________________________________________________________ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091108/0adc04e2/attachment.html From gcross at phys.washington.edu Sun Nov 8 23:28:19 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Sun Nov 8 23:04:30 2009 Subject: [Haskell-cafe] Cabal In-Reply-To: <334011.49628.qm@web58806.mail.re1.yahoo.com> References: <334011.49628.qm@web58806.mail.re1.yahoo.com> Message-ID: <2AF030F8-EA18-4BEB-97C6-1EB0F8352918@phys.washington.edu> I have rarely encountered problems when creating or installing packages using Cabal. In fact, the opposite is the case: I find it annoying when installing packages that haven't been cabalized because they don't pull in all of their dependencies automatically. It looks like there was a problem building readline, perhaps because it had trouble finding libreadline on your system. If this is the case, then the problem has nothing to do with Cabal but merely with the fact that a single dependent package failed to install. Have you tried building readline by itself and seeing the error message that it gives? Cheers, Greg On Nov 8, 2009, at 7:29 PM, Philippos Apolinarius wrote: > I made small improvements in the Small Japi Binding, and asked how > to make it available. I received a few private messages advising me > to build and package the library using a tool called cabal. Since I > have used installation tools for PLT, R and LaTeX libraries, I > thought cabal was something similar. However, I noticed that there > are a lot of complaints against cabal. Therefore, I decided to > install cabal, and try it. It seems that it is easier to install > packages by hand than using cabal. Here is a typical cabal session: > > D:\ghc\ghcapi>cabal update > Downloading the latest package list from hackage.haskell.org > > D:\ghc\ghcapi>cabal install mkcabal > Resolving dependencies... > Downloading pcre-light-0.3.1... > Configuring pcre-light-0.3.1... > Downloading readline-1.0.1.0... > Configuring readline-1.0.1.0... > cabal: Error: some packages failed to install: > mkcabal-0.4.2 depends on readline-1.0.1.0 which failed to install. > pcre-light-0.3.1 failed during the configure step. The exception was: > exit: ExitFailure 1 > readline-1.0.1.0 failed during the configure step. The exception was: > exit: ExitFailure 1 > > As one can see, it is much more difficult to use than R installation > tools, or MikTeX installation tools. If cabal is so difficult, why > use it? I am sure that I have done something very stupid mistake, > but believe me, a lot of people is trying to use cabal and failing. > I am not sure that it is a good idea to distribute libraries using > cabal. However, this is irrelevant, because I am sure that creating > a package with cabal is well beyond my powers. It is much easier to > write a complete JAPI library, than packaging it in cabal. > > > Looking for the perfect gift? Give the gift of Flickr! > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091108/126ee3d2/attachment.html From gcross at phys.washington.edu Sun Nov 8 23:47:52 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Sun Nov 8 23:24:03 2009 Subject: [Haskell-cafe] Cabal In-Reply-To: <2AF030F8-EA18-4BEB-97C6-1EB0F8352918@phys.washington.edu> References: <334011.49628.qm@web58806.mail.re1.yahoo.com> <2AF030F8-EA18-4BEB-97C6-1EB0F8352918@phys.washington.edu> Message-ID: <9D3E6EE2-0FD0-45B2-BD15-E4008AB6C28B@phys.washington.edu> Actually, let me clarify my point: I have rarely encountered problems when using Cabal as a package distribution system, but I have run into problems when using it as a build system in a non-trivial manner. For example, when I wanted to build a lot of small utility programs I found that it was re-compiling commonly-shared source files for each program, rather than compiling the source file once and re-using the object file. This was sufficiently annoying that I migrated the build process of my utilities to scons. Having said that, most libraries tend not to have special needs as far as the build process is concerned (unless they are doing complicated things to interface with a foreign framework), so the limitations of Cabal is not usually be a problem in practice, and the Cabal infrastructure makes installing packages very convenient. Cheers, Greg On Nov 8, 2009, at 8:28 PM, Gregory Crosswhite wrote: > I have rarely encountered problems when creating or installing > packages using Cabal. In fact, the opposite is the case: I find it > annoying when installing packages that haven't been cabalized > because they don't pull in all of their dependencies automatically. > > It looks like there was a problem building readline, perhaps because > it had trouble finding libreadline on your system. If this is the > case, then the problem has nothing to do with Cabal but merely with > the fact that a single dependent package failed to install. Have > you tried building readline by itself and seeing the error message > that it gives? > > Cheers, > Greg > > On Nov 8, 2009, at 7:29 PM, Philippos Apolinarius wrote: > >> I made small improvements in the Small Japi Binding, and asked how >> to make it available. I received a few private messages advising me >> to build and package the library using a tool called cabal. Since I >> have used installation tools for PLT, R and LaTeX libraries, I >> thought cabal was something similar. However, I noticed that there >> are a lot of complaints against cabal. Therefore, I decided to >> install cabal, and try it. It seems that it is easier to install >> packages by hand than using cabal. Here is a typical cabal session: >> >> D:\ghc\ghcapi>cabal update >> Downloading the latest package list from hackage.haskell.org >> >> D:\ghc\ghcapi>cabal install mkcabal >> Resolving dependencies... >> Downloading pcre-light-0.3.1... >> Configuring pcre-light-0.3.1... >> Downloading readline-1.0.1.0... >> Configuring readline-1.0.1.0... >> cabal: Error: some packages failed to install: >> mkcabal-0.4.2 depends on readline-1.0.1.0 which failed to install. >> pcre-light-0.3.1 failed during the configure step. The exception was: >> exit: ExitFailure 1 >> readline-1.0.1.0 failed during the configure step. The exception was: >> exit: ExitFailure 1 >> >> As one can see, it is much more difficult to use than R >> installation tools, or MikTeX installation tools. If cabal is so >> difficult, why use it? I am sure that I have done something very >> stupid mistake, but believe me, a lot of people is trying to use >> cabal and failing. I am not sure that it is a good idea to >> distribute libraries using cabal. However, this is irrelevant, >> because I am sure that creating a package with cabal is well beyond >> my powers. It is much easier to write a complete JAPI library, than >> packaging it in cabal. >> >> >> Looking for the perfect gift? Give the gift of Flickr! >> _______________________________________________ >> 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091108/044df7d0/attachment.html From stefan at cs.uu.nl Mon Nov 9 02:31:05 2009 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Mon Nov 9 02:07:01 2009 Subject: [Haskell-cafe] bit of help with n-ary please... In-Reply-To: <26259580.post@talk.nabble.com> References: <26258006.post@talk.nabble.com> <26259268.post@talk.nabble.com> <7qmef55hvdasvbsqa2oraf7m4eohpsonrd@4ax.com> <26259580.post@talk.nabble.com> Message-ID: <1F08A912-78BE-4875-B8F5-24A1A5313D2C@cs.uu.nl> > Answers to spec. You didn't answered the "homework" question: >> I don't know if this is homework. I'm a bit suspicious: http://www.dcs.shef.ac.uk/intranet/teaching/modules/level2/com2010.html . See http://www.haskell.org/haskellwiki/Homework_help . Cheers, Stefan From lrpalmer at gmail.com Mon Nov 9 02:39:31 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Nov 9 02:15:25 2009 Subject: [Haskell-cafe] bit of help with n-ary please... In-Reply-To: <1F08A912-78BE-4875-B8F5-24A1A5313D2C@cs.uu.nl> References: <26258006.post@talk.nabble.com> <26259268.post@talk.nabble.com> <7qmef55hvdasvbsqa2oraf7m4eohpsonrd@4ax.com> <26259580.post@talk.nabble.com> <1F08A912-78BE-4875-B8F5-24A1A5313D2C@cs.uu.nl> Message-ID: <7ca3f0160911082339s3ded0032ie8fc2c0d72d93085@mail.gmail.com> On Mon, Nov 9, 2009 at 12:31 AM, Stefan Holdermans wrote: >> Answers to spec. > > > You didn't answered the "homework" question: > >>> I don't know if this is homework. > > I'm a bit suspicious: > http://www.dcs.shef.ac.uk/intranet/teaching/modules/level2/com2010.html ?. > > See http://www.haskell.org/haskellwiki/Homework_help . This is the typical bottled response to people asking for homework help. But spot135 has done a good job so far: stated his problems, shown his work so far, asking for guidance not answers. And the community has done a good job helping: no answers, but hints and leading questions. I would say, so far, this has been a "textbook example" of a homework exchange. Luke From ketil at malde.org Mon Nov 9 02:42:18 2009 From: ketil at malde.org (Ketil Malde) Date: Mon Nov 9 02:18:04 2009 Subject: [Haskell-cafe] bit of help with n-ary please... In-Reply-To: <26258006.post@talk.nabble.com> (spot's message of "Sun, 8 Nov 2009 14:24:59 -0800 (PST)") References: <26258006.post@talk.nabble.com> Message-ID: <87skcodu05.fsf@malde.org> spot135 writes: > So this is what ive got so far. > > data Tree a = Empty | Leaf a | Branch a [Tree a] [Homework mode on, i.e. hints and careful nudges to help you work it out on your own] The definition above gives two ways to build a Tree with only one data element. Can you see which ones? Is this a good thing? What is the difference between your definition and data Tree a = Empty | Branch a [Tree a] What would the consequences be if you replaced your definition with this one? -k -- If I haven't seen further, it is by standing in the footprints of giants From stefan at cs.uu.nl Mon Nov 9 02:44:41 2009 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Mon Nov 9 02:20:36 2009 Subject: [Haskell-cafe] bit of help with n-ary please... In-Reply-To: <7ca3f0160911082339s3ded0032ie8fc2c0d72d93085@mail.gmail.com> References: <26258006.post@talk.nabble.com> <26259268.post@talk.nabble.com> <7qmef55hvdasvbsqa2oraf7m4eohpsonrd@4ax.com> <26259580.post@talk.nabble.com> <1F08A912-78BE-4875-B8F5-24A1A5313D2C@cs.uu.nl> <7ca3f0160911082339s3ded0032ie8fc2c0d72d93085@mail.gmail.com> Message-ID: <45F2F05C-6E4E-466C-9245-44BA9DD72450@cs.uu.nl> Luke, > This is the typical bottled response to people asking for homework > help. But spot135 has done a good job so far: stated his problems, > shown his work so far, asking for guidance not answers. And the > community has done a good job helping: no answers, but hints and > leading questions. I would say, so far, this has been a "textbook > example" of a homework exchange. Agreed. But still... I think that one (if that's the case) should clearly indicate that their question relates to homework. [No desire to fork this thread into an extensive discussion on homework help, though.] Cheers, Stefan From ketil at malde.org Mon Nov 9 03:04:18 2009 From: ketil at malde.org (Ketil Malde) Date: Mon Nov 9 02:40:03 2009 Subject: [Haskell-cafe] bit of help with n-ary please... In-Reply-To: <87skcodu05.fsf@malde.org> (Ketil Malde's message of "Mon, 09 Nov 2009 08:42:18 +0100") References: <26258006.post@talk.nabble.com> <87skcodu05.fsf@malde.org> Message-ID: <87k4y0dszh.fsf@malde.org> Ketil Malde writes: > data Tree a = Empty | Branch a [Tree a] > What would the consequences be if you replaced your definition with > this one? And, for extra credit, can you identify similar issues with this definition? Can you improve on it? -k -- If I haven't seen further, it is by standing in the footprints of giants From chaddai.fouche at gmail.com Mon Nov 9 03:49:36 2009 From: chaddai.fouche at gmail.com (=?UTF-8?B?Q2hhZGRhw68gRm91Y2jDqQ==?=) Date: Mon Nov 9 03:25:32 2009 Subject: [Haskell-cafe] Area from [(x,y)] using foldl In-Reply-To: <449242.92412.qm@web31105.mail.mud.yahoo.com> References: <449242.92412.qm@web31105.mail.mud.yahoo.com> Message-ID: On Sun, Nov 8, 2009 at 10:30 PM, michael rice wrote: > > This doesn't. > > area :: [(Double,Double)] -> Double > area p = abs $ (/2) $ area' (last p):p > > where area' [] = 0 > area' ((x0,y0),(x,y):ps) = ((x0-x)*(y0+y)) + area' > (x,y):ps > > This function is almost correct except you got your priorities wrong : application priority is always stronger than any operator's so "area' (last p):p" is read as "(area' (last p)) : p"... Besides your second pattern is also wrong, the correct code is : area :: [(Double,Double)] -> Double area p = abs $ (/2) $ area' (last p : p) where area' ((x0,y0):(x,y):ps) = ((x0-x)*(y0+y)) + area' (x,y):ps area' _ = 0 -- Jeda? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091109/9ca89309/attachment-0001.html From nicolas.pouillard at gmail.com Mon Nov 9 03:56:05 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Mon Nov 9 03:31:59 2009 Subject: [Haskell-cafe] Re: [Haskell] ANNOUNCE: control-monad-exception 0.5 with monadic call traces In-Reply-To: <29bf512f0911071355n47f3b559w40a99b5818f17d92@mail.gmail.com> References: <4AF02F06.2030105@henning-thielemann.de> <29bf512f0911071355n47f3b559w40a99b5818f17d92@mail.gmail.com> Message-ID: <1257756112-sup-7705@peray> Excerpts from Michael Snoyman's message of Sat Nov 07 22:55:14 +0100 2009: > On Sat, Nov 7, 2009 at 9:54 PM, Henning Thielemann < > lemming@henning-thielemann.de> wrote: > > > > > On Sat, 7 Nov 2009, Jose Iborra wrote: > > > > Sorry for the confusion, I never meant that c-m-e can show stack traces > >> for asynchronous exceptions. It can not. > >> > > > > My post was not related in any way to asynchronous exceptions. It's just > > the everlasting issue of the distinction of programming errors and > > exceptions. > > > > > > I'm not sure if I managed to dispel your doubts, if not perhaps you could > >> make your points more clear. > >> > > > > I'm trying that for years now, repeatedly in this mailing list and on the > > Wiki: > > http://www.haskell.org/haskellwiki/Error > > http://www.haskell.org/haskellwiki/Exception > > I don't know how I can make it still clearer. It's just like concurrency > > vs. parallelism - somehow related, but it is important to distinguish them. > > > > And yet if I use library ABC, which I expected to be error-free, and it in > fact has a programming error, is this an error or an exception from my point > of view? Based on the definitions you posted, I believe the correct answer > is "error." However, I'd much rather have a way to recover from that kind of > error if it's logical. > > For example, let's say that I'm writing a web browser in Haskell (it could > happen). If there's an error in the HTTP library which causes it to die on > certain types of headers, I'd much rather be able to tell the user sorry and > let them continue browsing than to up and die with a "Prelude.head" message > in their console. If there is an "error" raised by the HTTP library on some headers, then this is a bug (a programming error), and so by using it your program is buggy too. However I would say that in this case wrapping the buggy function into safely-failing one is a valid temporary hack. A way to help distinguishing errors and exceptions would be to have pre and post conditions on function (as in "Static Contract Checking for Haskell"[1]). For instance head would have the following contract: {-# CONTRACT head :: { xs | not (null xs) } -> Ok #-} head :: [a] -> a head [] = error "head: empty list" head (x:_) = x When there is a pre-condition (or a contract) like here, it is a programming error to give an empty list to head. This means that checking if the list is empty must be done before the call. It has to statically deductible from the call site. If you write a function and cannot prove that you will not call head on the empty list then either you check before calling, or you use a safe-head function or you add a pre-condition to your function. [1]: http://www.cl.cam.ac.uk/~nx200/ -- Nicolas Pouillard http://nicolaspouillard.fr From pepe.haskell at gmail.com Mon Nov 9 04:02:57 2009 From: pepe.haskell at gmail.com (Pepe Gallardo) Date: Mon Nov 9 03:38:52 2009 Subject: [Haskell-cafe] WinGHCi stuck in a loop In-Reply-To: References: Message-ID: <84f82ca10911090102u4548f0a7xadfbe04cebe4a06a@mail.gmail.com> WinGHCi options are stored under HKEY_CURRENT_USER\Software\Haskell\WinGhci in the Windows registry. Cheers, Pepe 2009/11/7 Henk-Jan van Tuyl > > L.S., > > I changed the options in WinGHCi and now WinGHCi is stuck in a loop each > time I start it; how can I edit the options? I cannot find them in the > registry. > > -- > Met vriendelijke groet, > Henk-Jan van Tuyl > > > -- > http://Van.Tuyl.eu/ > http://members.chello.nl/hjgtuyl/tourdemonad.html > -- > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091109/7b72d450/attachment.html From emax at chalmers.se Mon Nov 9 04:09:55 2009 From: emax at chalmers.se (Emil Axelsson) Date: Mon Nov 9 03:46:05 2009 Subject: [Haskell-cafe] ANNOUNCE: feldspar-language In-Reply-To: <594c1e830911061035m75e98ebbv2dbb33a19125bdca@mail.gmail.com> References: <4AF0F78B.2090405@chalmers.se> <4AF3B3E9.4040005@chalmers.se> <594c1e830911061035m75e98ebbv2dbb33a19125bdca@mail.gmail.com> Message-ID: <4AF7DC63.7040906@chalmers.se> Tom Hawkins skrev: > On Fri, Nov 6, 2009 at 6:28 AM, Emil Axelsson wrote: > >>> 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. > > Atom may be another option. Though it is not intended for high > performance DSP, we do use it for basic signal processing. Here is an > IIR filter that is used is some fault detection logic on our > application: > > -- | IIR filter implemented using direct form 2. > iirFilter :: Name -> Float -> [(Float, Float)] -> E Float -> Atom (E Float) > iirFilter name b0 coeffs x = do > -- Create the filter taps. > vs <- mapM (\ i -> float (name ++ show i) 0) [1 .. length coeffs] > -- Cascade the filter taps together. > mapM_ (\ (vA, vB) -> vA <== value vB) $ zip (tail vs) vs > -- Calculate the input to the chain of taps. > let w0 = sum ( x : [ (value v) * Const (-a) | (v, (a, _)) <- zip vs coeffs ]) > bs = b0 : (snd $ unzip coeffs) > ws = w0 : map value vs > us = [ w * Const b | (w, b) <- zip ws bs ] > head vs <== w0 > -- Return the output. > return $ sum us > > http://hackage.haskell.org/package/atom Nice! One of our project members has been looking at Atom, not for numerical computations, but for real-time scheduling (which Feldspar should deal with eventually). What kind of code (in terms of efficiency) does the above description compile to? / Emil From pierreetienne.meunier at gmail.com Mon Nov 9 05:24:27 2009 From: pierreetienne.meunier at gmail.com (Pierre-Etienne Meunier) Date: Mon Nov 9 05:00:23 2009 Subject: [Haskell-cafe] Haskell image libraries Message-ID: <3F6E7427-6330-46D4-95DA-572311201BFA@gmail.com> there is also a binding for libGD on hackage : http://hackage.haskell.org/package/gd And, of course, you can improve it, or write a binding to a more complete library. Or, even better, write a mix between http://www.libpng.org/pub/png/pngdocs.html and http://hackage.haskell.org/package/binary From gracjanpolak at gmail.com Mon Nov 9 05:27:23 2009 From: gracjanpolak at gmail.com (Gracjan Polak) Date: Mon Nov 9 05:03:40 2009 Subject: [Haskell-cafe] ANN: acme-dont Message-ID: Hello fellow haskellers, While reading reddit in the morning today: http://www.reddit.com/r/programming/comments/a26fe/dont/ I was shocked and surprised to see that Haskell lacks a very important feature present in Perl. It appeared that Haskell cannot not do monadic actions! I decided to act as fast as possible. Luckily, monads enable us to create control flow constructs on enterprise level. I'm proud to present the Acme.Dont module, that implements the indispensable don't monadic action. http://hackage.haskell.org/package/acme-dont-1.0 With special apologies to Luke Palmer that it took the Haskell community 7.5 years to catch up with Perl. Thanks go to Damian Conway. Have fun! Gracjan From deniz.a.m.dogan at gmail.com Mon Nov 9 05:56:12 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Mon Nov 9 05:32:25 2009 Subject: [Haskell-cafe] ANN: acme-dont In-Reply-To: References: Message-ID: <7b501d5c0911090256l57342094n6739af99d9fede3@mail.gmail.com> 2009/11/9 Gracjan Polak : > Hello fellow haskellers, > > While reading reddit in the morning today: > > http://www.reddit.com/r/programming/comments/a26fe/dont/ > > I was shocked and surprised to see that Haskell lacks a very important > feature present in Perl. It appeared that Haskell cannot not do > monadic actions! > > I decided to act as fast as possible. > > Luckily, monads enable us to create control flow constructs on > enterprise level. I'm proud to present the Acme.Dont module, that > implements the indispensable don't monadic action. > > http://hackage.haskell.org/package/acme-dont-1.0 > > With special apologies to Luke Palmer that it took the Haskell > community 7.5 years to catch up with Perl. > > Thanks go to Damian Conway. > > Have fun! > Gracjan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > Are you sure you want to license this as BSD? -- Deniz Dogan From gracjanpolak at gmail.com Mon Nov 9 07:01:52 2009 From: gracjanpolak at gmail.com (Gracjan Polak) Date: Mon Nov 9 06:38:10 2009 Subject: [Haskell-cafe] Re: ANN: acme-dont References: <7b501d5c0911090256l57342094n6739af99d9fede3@mail.gmail.com> Message-ID: Deniz Dogan gmail.com> writes: > > Are you sure you want to license this as BSD? > Yes, BSD3 to be more exact. Of course commercial options are available on case by case basis. -- Gracjan From warren.henning at gmail.com Mon Nov 9 07:05:14 2009 From: warren.henning at gmail.com (Warren Henning) Date: Mon Nov 9 06:41:07 2009 Subject: [Haskell-cafe] Re: ANN: acme-dont In-Reply-To: References: <7b501d5c0911090256l57342094n6739af99d9fede3@mail.gmail.com> Message-ID: <9e5767b0911090405y7fc236bbmc858a19cf250ba78@mail.gmail.com> On Mon, Nov 9, 2009 at 4:01 AM, Gracjan Polak wrote: > Of course commercial options are available on case by case basis. When Acme.Dont licensing has made you a billionaire, remember the little people. From poolwsh at hotmail.com Mon Nov 9 07:17:28 2009 From: poolwsh at hotmail.com (shengwang) Date: Mon Nov 9 06:53:25 2009 Subject: [Haskell-cafe] O'Haskell Message-ID: Hi, Somebody has idea, how to achieve reactive in O'Haskell? Shawn Wang _________________________________________________________________ MSN????????????????25???????????2010????????? http://kaba.msn.com.cn/?k=1 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091109/455f4ec7/attachment.html From duncan.coutts at googlemail.com Mon Nov 9 07:39:10 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Mon Nov 9 07:15:05 2009 Subject: [Haskell-cafe] Cabal In-Reply-To: <9D3E6EE2-0FD0-45B2-BD15-E4008AB6C28B@phys.washington.edu> References: <334011.49628.qm@web58806.mail.re1.yahoo.com> <2AF030F8-EA18-4BEB-97C6-1EB0F8352918@phys.washington.edu> <9D3E6EE2-0FD0-45B2-BD15-E4008AB6C28B@phys.washington.edu> Message-ID: <1257770350.4680.327.camel@localhost> On Sun, 2009-11-08 at 20:47 -0800, Gregory Crosswhite wrote: > Actually, let me clarify my point: I have rarely encountered problems > when using Cabal as a package distribution system, but I have run into > problems when using it as a build system in a non-trivial manner. For > example, when I wanted to build a lot of small utility programs I > found that it was re-compiling commonly-shared source files for each > program, rather than compiling the source file once and re-using the > object file. This was sufficiently annoying that I migrated the build > process of my utilities to scons. You'll be glad to know this is addressed in Cabal-1.8, though not in a fully automatic way. The problem with sharing automatically is knowing when it is safe to do so and when it is not. Each component that shares a source file can use different compiler options, cpp flags, and include dirs (and perhaps other stuff that we cannot easily track). Also, when you link it into a library you actually compile it differently than when you compile it into an executable (the -package-name flag is different). So what we've done is to let executables depend on libraries. That makes the sharing explicit. At some point I also want to add support for private libs which would make this feature useful in more cases. Duncan From stephen.tetley at gmail.com Mon Nov 9 08:08:06 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Mon Nov 9 07:44:01 2009 Subject: [Haskell-cafe] Cabal In-Reply-To: <9D3E6EE2-0FD0-45B2-BD15-E4008AB6C28B@phys.washington.edu> References: <334011.49628.qm@web58806.mail.re1.yahoo.com> <2AF030F8-EA18-4BEB-97C6-1EB0F8352918@phys.washington.edu> <9D3E6EE2-0FD0-45B2-BD15-E4008AB6C28B@phys.washington.edu> Message-ID: <5fdc56d70911090508r5415f1fdkfba59ecd202abacf@mail.gmail.com> Hello Gregory and Philippos Gregory, methinks you are a unix user as "Cabal" gives you a carefree existence (the scare quotes do highlight that it's not poor Cabal's fault). Philippos, the problems you are having aren't which cabal per-se but Haskell libraries that bind C libraries. On Windows I strongly recommend you install Cygwin, outside of the Microsoft toolchain (Visual Studio, C# etc.) any serious development on Windows really is troublesome without it, some development still is but that's another story. Installing Cygwin will pull in a huge amount of code first time round but after that it it manageable. Once you have Cygwin ? here's how to install the pcre and readline bindings. Re-run the cygwin installer. For pcre you will need Devel/pcre and Libs/libpcre. For readline you will need Devel/readline and Lib/libreadlineN ? I have both libreadline5 and libreadline6 installed, so clearly they can coexist. To build the Haskell bindings you want to be running Cygwin naturally. I'd make a directory in /usr/local tagged to the version of GHC I'm using eg Haskell_ghc_6_10_3 and copy the tar.gz's there (having a directory for a particular GHC version makes it easier to track which packages you are depending upon across GHC updates). Untar the packages with tar (some Windows archivers don't handle Unixed archives well) > tar xvfz readline-1.0.1.0.tar.gz > tar xvfz pcre-0.3.1.tar.gz At this point I'd edit the *.cabal files in each component ? this is not 'the done thing', but both libraries need extra flags and as I have to compile them rarely I tend to forget the format (which appears to be Windows style full paths even though you are running Cygwin). Append this to the end of readline.cabal extra-lib-dirs: C:\cygwin\lib include-dirs: C:\cygwin\usr\include\readline C:\cygwin\usr\include Append this to the end of pcre-light.cabal extra-lib-dirs: C:\cygwin\lib include-dirs: C:\cygwin\usr\include Provide you have cygwin at the root of C: (which is very wise!), you should be able to build with the usual runhaskell Setup.lhs { configure | build | install | hadock } Best wishes Stephen From duncan.coutts at googlemail.com Mon Nov 9 08:13:47 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Mon Nov 9 07:49:42 2009 Subject: [Haskell-cafe] Cabal In-Reply-To: <334011.49628.qm@web58806.mail.re1.yahoo.com> References: <334011.49628.qm@web58806.mail.re1.yahoo.com> Message-ID: <1257772427.4680.398.camel@localhost> On Sun, 2009-11-08 at 19:29 -0800, Philippos Apolinarius wrote: > I made small improvements in the Small Japi Binding, and asked how to > make it available. I received a few private messages advising me to > build and package the library using a tool called cabal. Since I have > used installation tools for PLT, R and LaTeX libraries, I thought > cabal was something similar. However, I noticed that there are a lot > of complaints against cabal. Therefore, I decided to install cabal, > and try it. It seems that it is easier to install packages by hand > than using cabal. Here is a typical cabal session: > > D:\ghc\ghcapi>cabal update > Downloading the latest package list from hackage.haskell.org > > D:\ghc\ghcapi>cabal install mkcabal > Resolving dependencies... > Downloading pcre-light-0.3.1... > Configuring pcre-light-0.3.1... > Downloading readline-1.0.1.0... > Configuring readline-1.0.1.0... > cabal: Error: some packages failed to install: > mkcabal-0.4.2 depends on readline-1.0.1.0 which failed to install. > pcre-light-0.3.1 failed during the configure step. The exception was: > exit: ExitFailure 1 > readline-1.0.1.0 failed during the configure step. The exception was: > exit: ExitFailure 1 Hmm, I get a slightly different error that indicates somewhat better the actual cause. It says that it cannot find sh.exe. The real problem here is that those two packages use ./configure scripts. Those rarely work under windows. For starters you need msys and mingw installed. Even once you've done that however we get the problem of missing C libs. Duncan From d.kahlenberg at googlemail.com Mon Nov 9 08:50:17 2009 From: d.kahlenberg at googlemail.com (Daniel Kahlenberg) Date: Mon Nov 9 08:26:21 2009 Subject: [Haskell-cafe] cabal with non-default cc1 Message-ID: <4AF81E19.4080308@googlemail.com> Hello friends, I want a package which can't be built with the version of gcc coming with the current release of ghc, so I installed a sufficient version of gcc and called cabal with the parameters that should override it's default settings (see the failure.log, line 112). But I have the impression(*) that the remaining process doesn't use my settings related to the version of cc1 to use but still uses the one coming with ghc (6.10.4). Can you help further? Cheers Daniel * See: "*** Assembler:", "*** Linker:" -------------- next part -------------- searching for ghc in path. found ghc at e:\programme\ghc\ghc-6.10.4\bin\ghc.exe ("e:\\programme\\ghc\\ghc-6.10.4\\bin\\ghc.exe",["--numeric-version"]) e:\programme\ghc\ghc-6.10.4\bin\ghc.exe is version 6.10.4 looking for package tool: ghc-pkg near compiler in e:\programme\ghc\ghc-6.10.4\bin found package tool in e:\programme\ghc\ghc-6.10.4\bin\ghc-pkg.exe ("e:\\programme\\ghc\\ghc-6.10.4\\bin\\ghc-pkg.exe",["--version"]) e:\programme\ghc\ghc-6.10.4\bin\ghc-pkg.exe is version 6.10.4 ("e:\\programme\\ghc\\ghc-6.10.4\\bin\\ghc.exe",["--supported-languages"]) Reading installed packages... ("e:\\programme\\ghc\\ghc-6.10.4\\bin\\ghc-pkg.exe",["dump","--global"]) ("e:\\programme\\ghc\\ghc-6.10.4\\bin\\ghc-pkg.exe",["dump","--package-conf=h:\\.homedir\\ghc\\i386-mingw32-6.10.4\\package.conf"]) Reading available packages... Resolving dependencies... selecting bindings-common-1.3.3 (hackage) and discarding bindings-common-0.1, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.2, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.2.5, 0.2.6, 1.0, 1.1, 1.2, 1.3, 1.3.1 and 1.3.2 selecting base-3.0.3.1 (installed) and 4.1.0.0 (installed) and discarding syb-0.1.0.0 and 0.1.0.1 selecting ghc-prim-0.1.0.0 (installed) selecting integer-0.1.0.1 (installed) selecting rts-1.0 (installed) selecting syb-0.1.0.1 (installed) In order, the following would be installed: bindings-common-1.3.3 (new package) bindings-common-1.3.3 has already been downloaded. Extracting C:\Dokumente und Einstellungen\Zyx\Anwendungsdaten\cabal\packages\hackage.haskell.org\bindings-common\1.3.3\bindings-common-1.3.3.tar.gz to c:\DOKUME~1\Zyx\LOKALE~1\Temp\bindings-common-1.3.31176... Using external setup method with build-type Simple Creating h:\.homedir\hugsdata\setup (and its parents) Using Cabal library version 1.6.0.3 Using h:\.homedir\hugsdata\setup\setup.hs as setup script. Setup script is out of date, compiling... ("e:\\programme\\ghc\\ghc-6.10.4\\bin\\ghc.exe",["-v","--make","h:\\.homedir\\hugsdata\\setup\\setup.hs","-o","h:\\.homedir\\hugsdata\\setup\\setup.exe","-odir","h:\\.homedir\\hugsdata\\setup","-hidir","h:\\.homedir\\hugsdata\\setup","-i","-ic:\\DOKUME~1\\Zyx\\LOKALE~1\\Temp\\bindings-common-1.3.31176\\bindings-common-1.3.3","-no-user-package-conf","-package-conf","h:\\.homedir\\ghc\\i386-mingw32-6.10.4\\package.conf","-package","Cabal-1.6.0.3"]) Glasgow Haskell Compiler, Version 6.10.4, for Haskell 98, stage 2 booted by GHC version 6.10.1 Using package config file: E:\programme\ghc\ghc-6.10.4\package.conf Using package config file: h:\.homedir\ghc\i386-mingw32-6.10.4\package.conf Using package config file: h:\.homedir\ghc\i386-mingw32-6.10.4\package.conf hiding package base-3.0.3.1 to avoid conflict with later version base-4.1.0.0 hiding package regex-base-0.72.0.2 to avoid conflict with later version regex-base-0.93.1 hiding package parsec-2.1.0.1 to avoid conflict with later version parsec-3.0.1 hiding package QuickCheck-1.2.0.0 to avoid conflict with later version QuickCheck-2.1.0.2 wired-in package ghc-prim mapped to ghc-prim-0.1.0.0 wired-in package integer mapped to integer-0.1.0.1 wired-in package base mapped to base-4.1.0.0 wired-in package rts mapped to rts-1.0 wired-in package haskell98 mapped to haskell98-1.0.1.0 wired-in package syb mapped to syb-0.1.0.1 wired-in package template-haskell mapped to template-haskell-2.3.0.1 wired-in package dph-seq mapped to dph-seq-0.3 wired-in package dph-par mapped to dph-par-0.3 Hsc static flags: -static *** Chasing dependencies: Chasing modules from: *H:\.homedir\hugsdata\setup\setup.hs Stable obj: [] Stable BCO: [] Ready for upsweep [NONREC ModSummary { ms_hs_date = Mon Nov 9 14:45:34 Westeurop?ische Normalzeit 2009 ms_mod = main:Main, ms_imps = [Distribution.Simple] ms_srcimps = [] }] compile: input file H:\.homedir\hugsdata\setup\setup.hs Created temporary directory: C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0 *** Checking old interface for main:Main: [1 of 1] Compiling Main ( H:\.homedir\hugsdata\setup\setup.hs, H:\.homedir\hugsdata\setup\Main.o ) *** Parser: *** Renamer/typechecker: *** Desugar: Result size = 8 *** Simplify: Result size = 6 Result size = 6 *** Tidy Core: Result size = 6 writeBinIface: 1 Names writeBinIface: 28 dict entries *** CorePrep: Result size = 6 *** Stg2Stg: *** CodeGen: *** CodeOutput: *** Assembler: E:\programme\ghc\ghc-6.10.4\gcc -BE:\programme\ghc\ghc-6.10.4\gcc-lib/ -IE:\programme\ghc\ghc-6.10.4\include/mingw -IH:\.homedir\hugsdata\setup -c C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0/ghc2388_0.s -o h:\.homedir\hugsdata\setup\Main.o *** Deleting temp files: Deleting: C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0/ghc2388_0.s Upsweep completely successful. *** Deleting temp files: Deleting: link: linkables are ... LinkableM (Mon Nov 9 14:45:34 Westeurop?ische Normalzeit 2009) main:Main [DotO h:\.homedir\hugsdata\setup\Main.o] Linking h:\.homedir\hugsdata\setup\setup.exe ... *** Windres: E:\programme\ghc\ghc-6.10.4\bin/windres --preprocessor="E:\programme\ghc\ghc-6.10.4\gcc" "-BE:\programme\ghc\ghc-6.10.4\gcc-lib/" "-IE:\programme\ghc\ghc-6.10.4\include/mingw" "-E" "-xc" "-DRC_INVOKED" --use-temp-file --input=C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0/ghc2388_0.rc --output=C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0/ghc2388_0.o --output-format=coff *** Linker: E:\programme\ghc\ghc-6.10.4\gcc -BE:\programme\ghc\ghc-6.10.4\gcc-lib/ -IE:\programme\ghc\ghc-6.10.4\include/mingw -v -o h:\.homedir\hugsdata\setup\setup.exe -DDONT_WANT_WIN32_DLL_SUPPORT h:\.homedir\hugsdata\setup\Main.o C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0/ghc2388_0.o -Lh:\.homedir\.cabal\Cabal-1.6.0.3\ghc-6.10.4 -LE:\programme\ghc\ghc-6.10.4\process-1.0.1.1 -LE:\programme\ghc\ghc-6.10.4\pretty-1.0.1.0 -LE:\programme\ghc\ghc-6.10.4\directory-1.0.0.3 -LE:\programme\ghc\ghc-6.10.4\old-time-1.0.0.2 -LE:\programme\ghc\ghc-6.10.4\old-locale-1.0.0.1 -LE:\programme\ghc\ghc-6.10.4\filepath-1.1.0.2 -LE:\programme\ghc\ghc-6.10.4\Win32-2.2.0.0 -LE:\programme\ghc\ghc-6.10.4\bytestring-0.9.1.4 -LE:\programme\ghc\ghc-6.10.4\containers-0.2.0.1 -LE:\programme\ghc\ghc-6.10.4\array-0.2.0.0 -LE:\programme\ghc\ghc-6.10.4\syb-0.1.0.1 -LE:\programme\ghc\ghc-6.10.4\base-4.1.0.0 -LE:\programme\ghc\ghc-6.10.4\integer-0.1.0.1 -LE:\programme\ghc\ghc-6.10.4\ghc-prim-0.1.0.0 -LE:\programme\ghc\ghc-6.10.4 -LE:\programme\ghc\ghc-6.10.4/gcc-lib -lHSCabal-1.6.0.3 -lHSprocess-1.0.1.1 -lHSpretty-1.0.1.0 -lHSdirectory-1.0.0.3 -lHSold-time-1.0.0.2 -lHSold-locale-1.0.0.1 -lHSfilepath-1.1.0.2 -lHSWin32-2.2.0.0 -luser32 -lgdi32 -lwinmm -ladvapi32 -lHSbytestring-0.9.1.4 -lHScontainers-0.2.0.1 -lHSarray-0.2.0.0 -lHSsyb-0.1.0.1 -lHSbase-4.1.0.0 -lwsock32 -luser32 -lshell32 -lHSinteger-0.1.0.1 -lHSghc-prim-0.1.0.0 -lHSrts -lm -lffi -lgmp -lwsock32 -u _ghczmprim_GHCziTypes_Izh_static_info -u _ghczmprim_GHCziTypes_Czh_static_info -u _ghczmprim_GHCziTypes_Fzh_static_info -u _ghczmprim_GHCziTypes_Dzh_static_info -u _base_GHCziPtr_Ptr_static_info -u _base_GHCziWord_Wzh_static_info -u _base_GHCziInt_I8zh_static_info -u _base_GHCziInt_I16zh_static_info -u _base_GHCziInt_I32zh_static_info -u _base_GHCziInt_I64zh_static_info -u _base_GHCziWord_W8zh_static_info -u _base_GHCziWord_W16zh_static_info -u _base_GHCziWord_W32zh_static_info -u _base_GHCziWord_W64zh_static_info -u _base_GHCziStable_StablePtr_static_info -u _ghczmprim_GHCziTypes_Izh_con_info -u _ghczmprim_GHCziTypes_Czh_con_info -u _ghczmprim_GHCziTypes_Fzh_con_info -u _ghczmprim_GHCziTypes_Dzh_con_info -u _base_GHCziPtr_Ptr_con_info -u _base_GHCziPtr_FunPtr_con_info -u _base_GHCziStable_StablePtr_con_info -u _ghczmprim_GHCziBool_False_closure -u _ghczmprim_GHCziBool_True_closure -u _base_GHCziPack_unpackCString_closure -u _base_GHCziIOBase_stackOverflow_closure -u _base_GHCziIOBase_heapOverflow_closure -u _base_ControlziExceptionziBase_nonTermination_closure -u _base_GHCziIOBase_blockedOnDeadMVar_closure -u _base_GHCziIOBase_blockedIndefinitely_closure -u _base_ControlziExceptionziBase_nestedAtomically_closure -u _base_GHCziWeak_runFinalizzerBatch_closure -u _base_GHCziTopHandler_runIO_closure -u _base_GHCziTopHandler_runNonIO_closure -u _base_GHCziConc_runHandlers_closure -u _base_GHCziConc_ensureIOManagerIsRunning_closure Reading specs from E:/programme/ghc/ghc-6.10.4/gcc-lib/specs Configured with: ../gcc-3.4.5-20060117-3/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization --enable-libstdcxx-debug Thread model: win32 gcc version 3.4.5 (mingw-vista special r3) E:/programme/ghc/ghc-6.10.4/gcc-lib/collect2.exe -Bdynamic -o h:\.homedir\hugsdata\setup\setup.exe -u _ghczmprim_GHCziTypes_Izh_static_info -u _ghczmprim_GHCziTypes_Czh_static_info -u _ghczmprim_GHCziTypes_Fzh_static_info -u _ghczmprim_GHCziTypes_Dzh_static_info -u _base_GHCziPtr_Ptr_static_info -u _base_GHCziWord_Wzh_static_info -u _base_GHCziInt_I8zh_static_info -u _base_GHCziInt_I16zh_static_info -u _base_GHCziInt_I32zh_static_info -u _base_GHCziInt_I64zh_static_info -u _base_GHCziWord_W8zh_static_info -u _base_GHCziWord_W16zh_static_info -u _base_GHCziWord_W32zh_static_info -u _base_GHCziWord_W64zh_static_info -u _base_GHCziStable_StablePtr_static_info -u _ghczmprim_GHCziTypes_Izh_con_info -u _ghczmprim_GHCziTypes_Czh_con_info -u _ghczmprim_GHCziTypes_Fzh_con_info -u _ghczmprim_GHCziTypes_Dzh_con_info -u _base_GHCziPtr_Ptr_con_info -u _base_GHCziPtr_FunPtr_con_info -u _base_GHCziStable_StablePtr_con_info -u _ghczmprim_GHCziBool_False_closure -u _ghczmprim_GHCziBool_True_closure -u _base_GHCziPack_unpackCString_closure -u _base_GHCziIOBase_stackOverflow_closure -u _base_GHCziIOBase_heapOverflow_closure -u _base_ControlziExceptionziBase_nonTermination_closure -u _base_GHCziIOBase_blockedOnDeadMVar_closure -u _base_GHCziIOBase_blockedIndefinitely_closure -u _base_ControlziExceptionziBase_nestedAtomically_closure -u _base_GHCziWeak_runFinalizzerBatch_closure -u _base_GHCziTopHandler_runIO_closure -u _base_GHCziTopHandler_runNonIO_closure -u _base_GHCziConc_runHandlers_closure -u _base_GHCziConc_ensureIOManagerIsRunning_closure E:/programme/ghc/ghc-6.10.4/gcc-lib/crt2.o E:/programme/ghc/ghc-6.10.4/gcc-lib/crtbegin.o -Lh:\.homedir\.cabal\Cabal-1.6.0.3\ghc-6.10.4 -LE:\programme\ghc\ghc-6.10.4\process-1.0.1.1 -LE:\programme\ghc\ghc-6.10.4\pretty-1.0.1.0 -LE:\programme\ghc\ghc-6.10.4\directory-1.0.0.3 -LE:\programme\ghc\ghc-6.10.4\old-time-1.0.0.2 -LE:\programme\ghc\ghc-6.10.4\old-locale-1.0.0.1 -LE:\programme\ghc\ghc-6.10.4\filepath-1.1.0.2 -LE:\programme\ghc\ghc-6.10.4\Win32-2.2.0.0 -LE:\programme\ghc\ghc-6.10.4\bytestring-0.9.1.4 -LE:\programme\ghc\ghc-6.10.4\containers-0.2.0.1 -LE:\programme\ghc\ghc-6.10.4\array-0.2.0.0 -LE:\programme\ghc\ghc-6.10.4\syb-0.1.0.1 -LE:\programme\ghc\ghc-6.10.4\base-4.1.0.0 -LE:\programme\ghc\ghc-6.10.4\integer-0.1.0.1 -LE:\programme\ghc\ghc-6.10.4\ghc-prim-0.1.0.0 -LE:\programme\ghc\ghc-6.10.4 -LE:\programme\ghc\ghc-6.10.4/gcc-lib -LE:/programme/ghc/ghc-6.10.4/gcc-lib h:\.homedir\hugsdata\setup\Main.o C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0/ghc2388_0.o -lHSCabal-1.6.0.3 -lHSprocess-1.0.1.1 -lHSpretty-1.0.1.0 -lHSdirectory-1.0.0.3 -lHSold-time-1.0.0.2 -lHSold-locale-1.0.0.1 -lHSfilepath-1.1.0.2 -lHSWin32-2.2.0.0 -luser32 -lgdi32 -lwinmm -ladvapi32 -lHSbytestring-0.9.1.4 -lHScontainers-0.2.0.1 -lHSarray-0.2.0.0 -lHSsyb-0.1.0.1 -lHSbase-4.1.0.0 -lwsock32 -luser32 -lshell32 -lHSinteger-0.1.0.1 -lHSghc-prim-0.1.0.0 -lHSrts -lm -lffi -lgmp -lwsock32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt E:/programme/ghc/ghc-6.10.4/gcc-lib/crtend.o link: done *** Deleting temp files: Deleting: C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0/ghc2388_0.o C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0/ghc2388_0.rc *** Deleting temp dirs: Deleting: C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0 h:\.homedir\hugsdata\setup\setup.exe configure --verbose=3 --builddir=h:\.homedir\hugsdata --ghc --prefix=h:\.homedir\.cabal --datadir=h:\.homedir\.cabal --configure-option=CC=e:\programme\mingw-gcc4\bin\gcc.exe --user --package-db=h:\.homedir\ghc\i386-mingw32-6.10.4\package.conf --extra-include-dirs=e:/programme/ghc/mingw-gcc4/include --extra-lib-dirs=e:/programme/ghc/mingw-gcc4/lib --constraint=base ==3.0.3.1 --with-gcc=e:\programme\ghc\mingw-gcc4\bin\gcc.exe --with-ld=e:\programme\ghc\mingw-gcc4\bin\ld.exe --gcc-option=-v --gcc-option=-Wall Redirecting build log to {handle: h:\.homedir\hugsdata\build-bindings-common-1.3.3-ghc-6.10.4.log} Using external setup method with build-type Simple Creating h:\.homedir\hugsdata\setup (and its parents) Using Cabal library version 1.6.0.3 Using h:\.homedir\hugsdata\setup\setup.hs as setup script. h:\.homedir\hugsdata\setup\setup.exe build --verbose=3 --builddir=h:\.homedir\hugsdata Redirecting build log to {handle: h:\.homedir\hugsdata\build-bindings-common-1.3.3-ghc-6.10.4.log} cabal.exe: Error: some packages failed to install: bindings-common-1.3.3 failed during the building phase. The exception was: exit: ExitFailure 1 From haskell at gimbo.org.uk Mon Nov 9 09:23:42 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Mon Nov 9 08:59:46 2009 Subject: [Haskell-cafe] Observer pattern in Haskell? Message-ID: <7A5CB0CB-3B3A-4639-9C42-E75B551293F6@gimbo.org.uk> Hi all, I've been doing some GUI programming recently, using wx. To help manage dependencies between state and UI elements, I looked for a Haskell version of the Observer design pattern, and I found an implementation written by Bastiaan Heeren of ou.nl [1]. It pretty much did what I wanted, though I made a few changes along the way. Since this seems to be of general use (ie beyond wx), I've proposed to Bastiaan that I package it up for release on hackage, and he's happy for me to do so. Before I do so, I thought I'd ask for comments. The code is on github: http://github.com/gimbo/observer.hs where we have: Control.Observer - a typeclass for observable objects. Control.Observer.Synchronous - an implementation based on IORefs. This is essentially the same as Bastiaan's original, except I've changed the names, split it into two modules, commented it, added one or two small things, and Cabalised it. I've also made a branch where Control.Observer.Synchronous uses MVars instead of IORefs, in an attempt to achieve thread safety: http://github.com/gimbo/observer.hs/blob/threadsafeSync/Control/Observer/Synchronous.hs Now, before I make a hackage release: 0. Is this completely insane, in a Haskell setting? Are there better ways to do this that aren't laden with OO-worldview baggage? 1. Does anyone have any comments, on either version? 2. In particular, is the MVar version sensible? I'm aiming for mutual exclusion between threads. I _think_ I've got it, but I'm perhaps not familiar enough with the semantics of MVar to be certain. Advice appreciated. If it _is_ sensible, then is there any reason not to just use this, and discard the IORef version? The current implementation is synchronous, in that any observer functions are called immediately and synchronously (and in the same thread as the change of subject value). I'm pondering extending the package with an asynchronous version where the update just trips a flag, and the observer function picks this up later - possibly in another thread. The idea there is to help in cases where certain operations have to be in a particular thread. But this will mean a change to the typeclass too, I guess - or the addition of another one for observers themselves. Again, any thoughts? Thanks! -Andy [1] http://www.cs.uu.nl/wiki/bin/view/Afp0607/ExerciseWXHaskell From nccb2 at kent.ac.uk Mon Nov 9 09:50:43 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Mon Nov 9 09:26:36 2009 Subject: [Haskell-cafe] Observer pattern in Haskell? In-Reply-To: <7A5CB0CB-3B3A-4639-9C42-E75B551293F6@gimbo.org.uk> References: <7A5CB0CB-3B3A-4639-9C42-E75B551293F6@gimbo.org.uk> Message-ID: <4AF82C43.7070701@kent.ac.uk> Andy Gimblett wrote: > Hi all, > > I've been doing some GUI programming recently, using wx. To help > manage dependencies between state and UI elements, I looked for a > Haskell version of the Observer design pattern, and I found an > implementation written by Bastiaan Heeren of ou.nl [1]. > > Now, before I make a hackage release: > > 1. Does anyone have any comments, on either version? There is no way to remove an observer, which is something I'd expect to have available. I realise this would require assigning a key to each observer (and thus perhaps storing them in an associative map) or some way to filter them, but I think if you can only ever add observers, it will get awkward. > 2. In particular, is the MVar version sensible? I'm aiming for mutual > exclusion between threads. I _think_ I've got it, but I'm perhaps not > familiar enough with the semantics of MVar to be certain. Advice > appreciated. If it _is_ sensible, then is there any reason not to > just use this, and discard the IORef version? It looks fine (and thread-safe) to me, but I'd agree that you may as well just use the MVar version and leave out the IORef version. > The current implementation is synchronous, in that any observer > functions are called immediately and synchronously (and in the same > thread as the change of subject value). I'm pondering extending the > package with an asynchronous version where the update just trips a > flag, and the observer function picks this up later - possibly in > another thread. The idea there is to help in cases where certain > operations have to be in a particular thread. But this will mean a > change to the typeclass too, I guess - or the addition of another one > for observers themselves. Again, any thoughts? I was a bit surprised at first that the observers were called synchronously. Asynchronous is what I'd expect, and it's also harder to code the asynchronous handlers wrongly. One blocking call (such as putMVar) in a synchronous handler can screw up your whole program by delaying the subsequent observers (and at that stage, the order in which the observers were added begins to matter). But my idea of how asynchronous would be implemented seems different to yours, judging by your description. Why not just augment this function in the synchronous version: notifyObservers :: Subject sub val => sub -> IO () notifyObservers subject = do value <- getValue subject observers <- getObservers subject mapM_ ($ value) observers to become: notifyObserversAsync :: Subject sub val => sub -> IO () notifyObserversAsync subject = do value <- getValue subject observers <- getObservers subject mapM_ (forkIO . ($ value)) observers This is what I was expecting to happen -- all the observer actions are spawned off into their own thread to run whatever code they want (either communicating back to an existing thread, or performing some long in-depth action). Thanks, Neil. From Eduard.Sergeev at gmail.com Mon Nov 9 10:21:38 2009 From: Eduard.Sergeev at gmail.com (Eduard Sergeev) Date: Mon Nov 9 09:57:30 2009 Subject: [Haskell-cafe] Observer pattern in Haskell? In-Reply-To: <7A5CB0CB-3B3A-4639-9C42-E75B551293F6@gimbo.org.uk> References: <7A5CB0CB-3B3A-4639-9C42-E75B551293F6@gimbo.org.uk> Message-ID: <26268135.post@talk.nabble.com> Andy Gimblett-2 wrote: > To help manage dependencies between state and UI elements, I looked for a > Haskell version of the Observer design pattern Isn't Reactive Programming approach more suitable than Observer if we talk about Haskell? -- View this message in context: http://old.nabble.com/Observer-pattern-in-Haskell--tp26267269p26268135.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From haskell at gimbo.org.uk Mon Nov 9 10:28:30 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Mon Nov 9 10:04:29 2009 Subject: [Haskell-cafe] Observer pattern in Haskell? In-Reply-To: <4AF82C43.7070701@kent.ac.uk> References: <7A5CB0CB-3B3A-4639-9C42-E75B551293F6@gimbo.org.uk> <4AF82C43.7070701@kent.ac.uk> Message-ID: <41577DB6-3339-4D10-91A5-F675418A989E@gimbo.org.uk> Hi Neil, On 9 Nov 2009, at 14:50, Neil Brown wrote: >> 1. Does anyone have any comments, on either version? > There is no way to remove an observer, which is something I'd expect > to have available. I realise this would require assigning a key to > each observer (and thus perhaps storing them in an associative map) > or some way to filter them, but I think if you can only ever add > observers, it will get awkward. Good point. This occurred to me when I referred to the Gang of Four book, while changing names for consistency. I must confess, in my current project I haven't needed it, but I see your point. >> 2. In particular, is the MVar version sensible? I'm aiming for >> mutual exclusion between threads. I _think_ I've got it, but I'm >> perhaps not familiar enough with the semantics of MVar to be >> certain. Advice appreciated. If it _is_ sensible, then is there >> any reason not to just use this, and discard the IORef version? > It looks fine (and thread-safe) to me, but I'd agree that you may as > well just use the MVar version and leave out the IORef version. Cool, thanks. >> was a bit surprised at first that the observers were called >> synchronously. Asynchronous is what I'd expect, and it's also >> harder to code the asynchronous handlers wrongly. One blocking >> call (such as putMVar) in a synchronous handler can screw up your >> whole program by delaying the subsequent observers (and at that >> stage, the order in which the observers were added begins to matter). True, but the observers shouldn't be able to access the MVars directly, I think? They should only be able to use the exposed interface, which won't let that happen? > But my idea of how asynchronous would be implemented seems different > to yours, judging by your description. Why not just augment this > function in the synchronous version: > > notifyObservers :: Subject sub val => sub -> IO () > notifyObservers subject = > do value <- getValue subject > observers <- getObservers subject > mapM_ ($ value) observers to become: > > notifyObserversAsync :: Subject sub val => sub -> IO () > notifyObserversAsync subject = > do value <- getValue subject > observers <- getObservers subject > mapM_ (forkIO . ($ value)) observers > > This is what I was expecting to happen -- all the observer actions > are spawned off into their own thread to run whatever code they want > (either communicating back to an existing thread, or performing some > long in-depth action). Interesting. That might be quite sensible. My thoughts have probably been coloured by how I've been doing things in wx. Ta for the suggestion. Cheers, -Andy From haskell at gimbo.org.uk Mon Nov 9 10:39:30 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Mon Nov 9 10:15:31 2009 Subject: [Haskell-cafe] Observer pattern in Haskell? In-Reply-To: <26268135.post@talk.nabble.com> References: <7A5CB0CB-3B3A-4639-9C42-E75B551293F6@gimbo.org.uk> <26268135.post@talk.nabble.com> Message-ID: On 9 Nov 2009, at 15:21, Eduard Sergeev wrote: > Andy Gimblett-2 wrote: >> To help manage dependencies between state and UI elements, I looked >> for a >> Haskell version of the Observer design pattern > > Isn't Reactive Programming approach more suitable than Observer if > we talk > about Haskell? Possibly. Care to expand? If you have a more elegant solution, which fits in well with ordinary wxHaskell, I'd be interested. Cheers, -Andy From abemud at gmail.com Mon Nov 9 11:02:40 2009 From: abemud at gmail.com (Michael Fan) Date: Mon Nov 9 10:39:09 2009 Subject: [Haskell-cafe] Re: cabal install on Windows References: Message-ID: I figured it out. It appears to be "Colour" package specific. The datadir still point to "c:\Program File" even with --user. I manually edit the dist/setup-config and get Colour installed. After that, other packages seem working fine. Jian Fan wrote: > Does cabal install --user or --prefix work on Windows at all? > I tried: > > cabal install colour --user > cabal install --user colour > etc > > and all failed because install try to install at c:Program Files > which I don't have permission writing. > > I have: > cabal-install version 0.6.2 > using version 1.6.0.3 of the Cabal library > The Glorious Glasgow Haskell Compilation System, version 6.10.4 > > Thanks > > Jian > ~ > ~ > ~ > ~ > ~ > ~ From duncan.coutts at googlemail.com Mon Nov 9 11:45:10 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Mon Nov 9 11:21:07 2009 Subject: [Haskell-cafe] Re: cabal install on Windows In-Reply-To: References: Message-ID: <1257785110.4680.629.camel@localhost> On Mon, 2009-11-09 at 16:02 +0000, Michael Fan wrote: > I figured it out. It appears to be "Colour" package specific. > The datadir still point to "c:\Program File" even with --user. > I manually edit the dist/setup-config and get Colour installed. > After that, other packages seem working fine. >From the ticket: http://hackage.haskell.org/trac/hackage/ticket/466 On Windows the --datadir is set independently of the --prefix (at least for libraries). This is actually quite annoying because it's not discoverable and when you do discover it you've got to set the datadir along with the prefix on the command line or in the config file. The problem is to do with relocatable packages and data files. Suppose you have a library that has data files. For a hypothetical example how about some Unicode library that uses data files of character traits. Now we want to use that library in a program and we want to have that program be relocatable. That means that at runtime the library needs to be able to locate its data files. But the place where the library was installed is completely independent of where the .exe is being run from. One way to make this appear to work is for the library data directory to not really be relocatable, then it looks like we can relocate the .exe and have it still work. Of course the .exe is not very re-locatable, in particular it cannot be relocated to another machine. This is often the use case for relocatable packages on Windows. Perhaps another solution would be to place the burden of finding the data files on the executable, or at least on the process of preparing the relocatable executable. If we made the process of generating a relocatable package more explicit we could include in that process checking for dependent library packages that use data files. We could then inform the packager and/or copy/link the necessary data files into a place where the library code will be able to find them relative to the executable. See #469. From Eduard.Sergeev at gmail.com Mon Nov 9 11:47:02 2009 From: Eduard.Sergeev at gmail.com (Eduard Sergeev) Date: Mon Nov 9 11:22:55 2009 Subject: [Haskell-cafe] Observer pattern in Haskell? In-Reply-To: References: <7A5CB0CB-3B3A-4639-9C42-E75B551293F6@gimbo.org.uk> <26268135.post@talk.nabble.com> Message-ID: <26269564.post@talk.nabble.com> Andy Gimblett-2 wrote: > Possibly. Care to expand? If you have a more elegant solution, which > fits in well with ordinary wxHaskell, I'd be interested. I believe there are a few experimental frameworks built on top of wxHaskell which use Functional Reactive Programming, like http://www.haskell.org/haskellwiki/Phooey Phooey . They seem to be more ellegant, but probably less practical for now since they are still experimental. I just thought that FRP is more suitable for Haskell but probably in case of wxHaskell it is not a case. Sorry if it was off topic. -- View this message in context: http://old.nabble.com/Observer-pattern-in-Haskell--tp26267269p26269564.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From duncan.coutts at googlemail.com Mon Nov 9 11:50:12 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Mon Nov 9 11:26:08 2009 Subject: [Haskell-cafe] Cabal In-Reply-To: <5fdc56d70911090508r5415f1fdkfba59ecd202abacf@mail.gmail.com> References: <334011.49628.qm@web58806.mail.re1.yahoo.com> <2AF030F8-EA18-4BEB-97C6-1EB0F8352918@phys.washington.edu> <9D3E6EE2-0FD0-45B2-BD15-E4008AB6C28B@phys.washington.edu> <5fdc56d70911090508r5415f1fdkfba59ecd202abacf@mail.gmail.com> Message-ID: <1257785412.4680.638.camel@localhost> On Mon, 2009-11-09 at 13:08 +0000, Stephen Tetley wrote: > At this point I'd edit the *.cabal files in each component ? this is > not 'the done thing', but both libraries need extra flags and as I > have to compile them rarely I tend to forget the format (which appears > to be Windows style full paths even though you are running Cygwin). Does it not work to say: cabal install readline \ --extra-lib-dirs=C:\cygwin\lib \ --extra-include-dirs=C:\cygwin\usr\include \ --extra-include-dirs=C:\cygwin\usr\include\readline That should work, and probably the recommendation should be for cygwin users to edit their cabal config to at add C:\cygwin\lib and C:\cygwin \usr\include as standard. Duncan From haskell at gimbo.org.uk Mon Nov 9 12:00:12 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Mon Nov 9 11:36:26 2009 Subject: [Haskell-cafe] Observer pattern in Haskell? In-Reply-To: <26269564.post@talk.nabble.com> References: <7A5CB0CB-3B3A-4639-9C42-E75B551293F6@gimbo.org.uk> <26268135.post@talk.nabble.com> <26269564.post@talk.nabble.com> Message-ID: On 9 Nov 2009, at 16:47, Eduard Sergeev wrote: > Andy Gimblett-2 wrote: >> Possibly. Care to expand? If you have a more elegant solution, >> which >> fits in well with ordinary wxHaskell, I'd be interested. > > I believe there are a few experimental frameworks built on top of > wxHaskell > which use Functional Reactive Programming, like > http://www.haskell.org/haskellwiki/Phooey Phooey . They seem to be > more > ellegant, but probably less practical for now since they are still > experimental. I just thought that FRP is more suitable for Haskell but > probably in case of wxHaskell it is not a case. Sorry if it was off > topic. In that case, I am 100% in agreement with you. :-) I do look forward to using such technology in the future... Thanks! -Andy From stephen.tetley at gmail.com Mon Nov 9 12:40:01 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Mon Nov 9 12:15:57 2009 Subject: [Haskell-cafe] Cabal In-Reply-To: <1257785412.4680.638.camel@localhost> References: <334011.49628.qm@web58806.mail.re1.yahoo.com> <2AF030F8-EA18-4BEB-97C6-1EB0F8352918@phys.washington.edu> <9D3E6EE2-0FD0-45B2-BD15-E4008AB6C28B@phys.washington.edu> <5fdc56d70911090508r5415f1fdkfba59ecd202abacf@mail.gmail.com> <1257785412.4680.638.camel@localhost> Message-ID: <5fdc56d70911090940h2f500f87q3d12b5274bb708d4@mail.gmail.com> 2009/11/9 Duncan Coutts : > > That should work, and probably the recommendation should be for cygwin > users to edit their cabal config to at add C:\cygwin\lib and C:\cygwin > \usr\include as standard. Hi Duncan That would definitely be the best idea, but where does the cabal config live? I have the cabal that ships with GHC-6.10.3 and can't find anything: cabal-install version 0.6.0 using version 1.6.0.1 of the Cabal library By the way, this one should be unnecessary, it was a legacy of me hacking all sorts of things to get readline installed: --extra-include-dirs=C:\cygwin\usr\include\readline Best wishes Stephen From tomahawkins at gmail.com Mon Nov 9 12:41:25 2009 From: tomahawkins at gmail.com (Tom Hawkins) Date: Mon Nov 9 12:17:22 2009 Subject: [Haskell-cafe] ANNOUNCE: feldspar-language In-Reply-To: <4AF7DC63.7040906@chalmers.se> References: <4AF0F78B.2090405@chalmers.se> <4AF3B3E9.4040005@chalmers.se> <594c1e830911061035m75e98ebbv2dbb33a19125bdca@mail.gmail.com> <4AF7DC63.7040906@chalmers.se> Message-ID: <594c1e830911090941s195e9902k717937c5ee534ef2@mail.gmail.com> On Mon, Nov 9, 2009 at 10:09 AM, Emil Axelsson wrote: > Nice! > > One of our project members has been looking at Atom, not for numerical > computations, but for real-time scheduling (which Feldspar should deal with > eventually). > > What kind of code (in terms of efficiency) does the above description > compile to? Here's and example: module Main (main) where import Language.Atom main :: IO () main = do compile "filter" defaults design return () design :: Atom () design = atom "filter" $ do input <- float' "input" output <- float' "output" x <- iirFilter "filter" 1 [(2,3), (4,5)] (value input) output <== x -- | IIR filter implemented using direct form 2. iirFilter :: Name -> Float -> [(Float, Float)] -> E Float -> Atom (E Float) iirFilter name b0 coeffs x = do -- Create the filter taps. vs <- mapM (\ i -> float (name ++ show i) 0) [1 .. length coeffs] -- Cascade the filter taps together. mapM_ (\ (vA, vB) -> vA <== value vB) $ zip (tail vs) vs -- Calculate the input to the chain of taps. let w0 = sum ( x : [ (value v) * Const (-a) | (v, (a, _)) <- zip vs coeffs ]) bs = b0 : (snd $ unzip coeffs) ws = w0 : map value vs us = [ w * Const b | (w, b) <- zip ws bs ] head vs <== w0 -- Return the output. return $ sum us Here's the generated C. Note the filter calculation is done entirely by function __r0: static unsigned long long __global_clock = 0; static const unsigned long __coverage_len = 1; static unsigned long __coverage[1] = {0}; static unsigned long __coverage_index = 0; static float __v1 = 0; /* filter.filter.filter2 */ static float __v0 = 0; /* filter.filter.filter1 */ /* filter.filter */ static void __r0(void) { unsigned char __0 = 1; float __1 = 0.0; float __2 = input; float __3 = __1 + __2; float __4 = __v0 /* filter.filter.filter1 */ ; float __5 = -2.0; float __6 = __4 * __5; float __7 = __3 + __6; float __8 = __v1 /* filter.filter.filter2 */ ; float __9 = -4.0; float __10 = __8 * __9; float __11 = __7 + __10; float __12 = 1.0; float __13 = __11 * __12; float __14 = __1 + __13; float __15 = 3.0; float __16 = __4 * __15; float __17 = __14 + __16; float __18 = 5.0; float __19 = __8 * __18; float __20 = __17 + __19; if (__0) { __coverage[0] = __coverage[0] | (1 << 0); } output = __20; __v0 /* filter.filter.filter1 */ = __11; __v1 /* filter.filter.filter2 */ = __4; } void filter(void) { { static unsigned char __scheduling_clock = 0; if (__scheduling_clock == 0) { __r0(); /* filter.filter */ __scheduling_clock = 0; } else { __scheduling_clock = __scheduling_clock - 1; } } __global_clock = __global_clock + 1; } From nccb2 at kent.ac.uk Mon Nov 9 12:41:32 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Mon Nov 9 12:17:34 2009 Subject: [Haskell-cafe] Observer pattern in Haskell? In-Reply-To: <41577DB6-3339-4D10-91A5-F675418A989E@gimbo.org.uk> References: <7A5CB0CB-3B3A-4639-9C42-E75B551293F6@gimbo.org.uk> <4AF82C43.7070701@kent.ac.uk> <41577DB6-3339-4D10-91A5-F675418A989E@gimbo.org.uk> Message-ID: <4AF8544C.10405@kent.ac.uk> Andy Gimblett wrote: >>> was a bit surprised at first that the observers were called >>> synchronously. Asynchronous is what I'd expect, and it's also >>> harder to code the asynchronous handlers wrongly. One blocking call >>> (such as putMVar) in a synchronous handler can screw up your whole >>> program by delaying the subsequent observers (and at that stage, the >>> order in which the observers were added begins to matter). > > True, but the observers shouldn't be able to access the MVars > directly, I think? They should only be able to use the exposed > interface, which won't let that happen? > Just to clarify -- I meant access to another MVar. Basically, if I do this: do v <- newMVar addObserver sub (putMVar v) If when the observers are run, the MVar v (that I've allocated) is non-empty, my code will block until it is empty, which will also block all the subsequent observers from being run (and block the code that called setValue) until the MVar is cleared by another thread. So my one poorly-written observer could deadlock (or cause stutter in) the system, whereas in the forkIO version, this observer would be fine -- it would block in its own new thread. Thanks, Neil. From jfredett at gmail.com Mon Nov 9 13:11:21 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Nov 9 12:47:18 2009 Subject: [Haskell-cafe] O'Haskell In-Reply-To: References: Message-ID: <2874E41C-2C47-4FF2-9075-308E3A681C5D@gmail.com> That sounds vaguely ominous... "Sir, we've achieved reactive in O'Haskell, we'll have ten minutes till the VB GUI detects his IP address!" ... But in all seriousness, it is my understanding that O'Haskell has fallen into disuse. IIRC Timber is the spiritual successor, but I have no idea how accurate that information is. As for implementing reactive in such a language, I imagine it would be pretty easy, as FRP is a _functional_ (hence the name) construct. Objects ought only get in the way (assuming they introduce possibly conflicting syntax) /Joe On Nov 9, 2009, at 7:17 AM, shengwang wrote: > Hi, > > Somebody has idea, how to achieve reactive in O'Haskell? > > > Shawn Wang > > ????? Windows Live Messenger ???????? ????? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From haskell at gimbo.org.uk Mon Nov 9 13:15:52 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Mon Nov 9 12:51:58 2009 Subject: [Haskell-cafe] Observer pattern in Haskell? In-Reply-To: <4AF8544C.10405@kent.ac.uk> References: <7A5CB0CB-3B3A-4639-9C42-E75B551293F6@gimbo.org.uk> <4AF82C43.7070701@kent.ac.uk> <41577DB6-3339-4D10-91A5-F675418A989E@gimbo.org.uk> <4AF8544C.10405@kent.ac.uk> Message-ID: On 9 Nov 2009, at 17:41, Neil Brown wrote: > Just to clarify -- I meant access to another MVar. Basically, if I > do this: > > do v <- newMVar > addObserver sub (putMVar v) > > If when the observers are run, the MVar v (that I've allocated) is > non-empty, my code will block until it is empty, which will also > block all the subsequent observers from being run (and block the > code that called setValue) until the MVar is cleared by another > thread. So my one poorly-written observer could deadlock (or cause > stutter in) the system, whereas in the forkIO version, this observer > would be fine -- it would block in its own new thread. Ah yes, of course - I understand. Of course, there's nothing really to stop application authors doing such things in the main thread too... ;-) Thanks for the clarification, -Andy From paul.tokarev at rwth-aachen.de Mon Nov 9 13:44:01 2009 From: paul.tokarev at rwth-aachen.de (Paul Tokarev) Date: Mon Nov 9 13:19:54 2009 Subject: [Haskell-cafe] classes question Message-ID: <26271257.post@talk.nabble.com> Hi. I am using Hugs 98 I have that piece of code: class PlusTimes a where plus :: a -> a -> a instance PlusTimes Int where plus x y = x + y when I run : "plus 2 3" I get this error: ERROR - Unresolved overloading *** Type : (Num a, PlusTimes a) => a *** Expression : plus 2 3 What am I doing wrong? Thanks. -- View this message in context: http://old.nabble.com/classes-question-tp26271257p26271257.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From rmm-haskell at z.odi.ac Mon Nov 9 13:47:41 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Mon Nov 9 13:23:41 2009 Subject: [Haskell-cafe] classes question In-Reply-To: <26271257.post@talk.nabble.com> References: <26271257.post@talk.nabble.com> Message-ID: <4EF573C4-F139-4D7D-87BA-3A8B98CC53E1@z.odi.ac> You did not specify what type of number it is -- in Haskell numeric constants like "1" are actually typed as forall a. Num a -- that is, can be any type of Num. Try: plus (2::Int) 3 -Ross On Nov 9, 2009, at 1:44 PM, Paul Tokarev wrote: > > Hi. > > I am using Hugs 98 > I have that piece of code: > > class PlusTimes a where > plus :: a -> a -> a > > instance PlusTimes Int where > plus x y = x + y > > when I run : "plus 2 3" I get this error: > ERROR - Unresolved overloading > *** Type : (Num a, PlusTimes a) => a > *** Expression : plus 2 3 > > What am I doing wrong? > Thanks. > > -- > View this message in context: http://old.nabble.com/classes-question-tp26271257p26271257.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 From jfredett at gmail.com Mon Nov 9 13:48:22 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Nov 9 13:24:17 2009 Subject: [Haskell-cafe] classes question In-Reply-To: <26271257.post@talk.nabble.com> References: <26271257.post@talk.nabble.com> Message-ID: (+) is a name that is already taken by the Num typeclass, you're trying to overload it with a different class. It's equivalent to doing: foo :: Int foo = 1 foo :: String foo = "abc" this would cause an (obvious) namespace collision. If you want to redefine (+), you'll have to import a qualified prelude, by using the NoImplicitPrelude pragma and `import qualified Prelude`. A better alternative is to use a different name, `+`, `++` are both taken (for normal addition and list concatenation, resp.). /Joe On Nov 9, 2009, at 1:44 PM, Paul Tokarev wrote: > > Hi. > > I am using Hugs 98 > I have that piece of code: > > class PlusTimes a where > plus :: a -> a -> a > > instance PlusTimes Int where > plus x y = x + y > > when I run : "plus 2 3" I get this error: > ERROR - Unresolved overloading > *** Type : (Num a, PlusTimes a) => a > *** Expression : plus 2 3 > > What am I doing wrong? > Thanks. > > -- > View this message in context: http://old.nabble.com/classes-question-tp26271257p26271257.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 From jfredett at gmail.com Mon Nov 9 13:49:17 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Nov 9 13:25:12 2009 Subject: [Haskell-cafe] classes question In-Reply-To: <26271257.post@talk.nabble.com> References: <26271257.post@talk.nabble.com> Message-ID: <45344D32-9062-4EB8-BDD1-C34FAF44B382@gmail.com> Oh, crap, I'm sorry, I completely misread your post... Disregard my previous message. /Joe On Nov 9, 2009, at 1:44 PM, Paul Tokarev wrote: > > Hi. > > I am using Hugs 98 > I have that piece of code: > > class PlusTimes a where > plus :: a -> a -> a > > instance PlusTimes Int where > plus x y = x + y > > when I run : "plus 2 3" I get this error: > ERROR - Unresolved overloading > *** Type : (Num a, PlusTimes a) => a > *** Expression : plus 2 3 > > What am I doing wrong? > Thanks. > > -- > View this message in context: http://old.nabble.com/classes-question-tp26271257p26271257.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 From duncan.coutts at googlemail.com Mon Nov 9 16:04:40 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Mon Nov 9 15:40:36 2009 Subject: [Haskell-cafe] Cabal In-Reply-To: <334011.49628.qm@web58806.mail.re1.yahoo.com> References: <334011.49628.qm@web58806.mail.re1.yahoo.com> Message-ID: <1257800680.4680.1153.camel@localhost> On Sun, 2009-11-08 at 19:29 -0800, Philippos Apolinarius wrote: > D:\ghc\ghcapi>cabal install mkcabal Note that as of cabal-install-0.8, the "mkcabal" functionality is integrated as "cabal init" (thanks to Brent Yorgey). This does not depend on less portable packages like pcre and readline (meaning it will work on Windows). > Resolving dependencies... > Downloading pcre-light-0.3.1... > Configuring pcre-light-0.3.1... There's no reason pcre-light needs a configure script. It should be removed. (It's also not used consistently, the Setup.hs is for a different build-type than the one specified in the .cabal file). > Downloading readline-1.0.1.0... > Configuring readline-1.0.1.0... > cabal: Error: some packages failed to install: > mkcabal-0.4.2 depends on readline-1.0.1.0 which failed to install. > pcre-light-0.3.1 failed during the configure step. The exception was: > exit: ExitFailure 1 > readline-1.0.1.0 failed during the configure step. The exception was: > exit: ExitFailure 1 As of Cabal-1.8 the error is reported as: cabal: The package has a './configure' script. This requires a Unix compatibility toolchain such as MinGW+MSYS or Cygwin. Duncan From paolo.losi at gmail.com Mon Nov 9 17:07:28 2009 From: paolo.losi at gmail.com (Paolo Losi) Date: Mon Nov 9 16:43:57 2009 Subject: [Haskell-cafe] strict mapM implementation correctness Message-ID: Hi all, while coding recently I came across the need for a strict mapM (that I indicidently use for m = MaybeT IO). I implementented this with the following simple code (it works for my use case): mapM' :: Monad m => (a-> m b) -> [a] -> m [b] mapM' _ [] = return [] mapM' f (x:xs) = do y <- f x ys <- y `seq` mapM' f xs return (y:ys) Now a couple of questions: 1. is it so "rare" to need such a beast? Why there isn't anything like that in standard libraries? 2. Is my implementation correct? 3. I've seen that mapM is implemented in base via sequence (which is in turn based on foldr). Is that any specific reason to prefer base implementation to mine? Thanks! Pao From paul.tokarev at rwth-aachen.de Mon Nov 9 17:09:48 2009 From: paul.tokarev at rwth-aachen.de (Paul Tokarev) Date: Mon Nov 9 16:45:41 2009 Subject: [Haskell-cafe] classes question In-Reply-To: <4EF573C4-F139-4D7D-87BA-3A8B98CC53E1@z.odi.ac> References: <26271257.post@talk.nabble.com> <4EF573C4-F139-4D7D-87BA-3A8B98CC53E1@z.odi.ac> Message-ID: <26274624.post@talk.nabble.com> Thanks, that works. But how sould I change my class definition, so that it works without (2::Int), but just with 2? Ross Mellgren wrote: > > You did not specify what type of number it is -- in Haskell numeric > constants like "1" are actually typed as forall a. Num a -- that is, > can be any type of Num. > > Try: plus (2::Int) 3 > > -Ross > > On Nov 9, 2009, at 1:44 PM, Paul Tokarev wrote: > >> >> Hi. >> >> I am using Hugs 98 >> I have that piece of code: >> >> class PlusTimes a where >> plus :: a -> a -> a >> >> instance PlusTimes Int where >> plus x y = x + y >> >> when I run : "plus 2 3" I get this error: >> ERROR - Unresolved overloading >> *** Type : (Num a, PlusTimes a) => a >> *** Expression : plus 2 3 >> >> What am I doing wrong? >> Thanks. >> >> -- >> View this message in context: >> http://old.nabble.com/classes-question-tp26271257p26271257.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 mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://old.nabble.com/classes-question-tp26271257p26274624.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From rmm-haskell at z.odi.ac Mon Nov 9 17:13:30 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Mon Nov 9 16:49:23 2009 Subject: [Haskell-cafe] classes question In-Reply-To: <26274624.post@talk.nabble.com> References: <26271257.post@talk.nabble.com> <4EF573C4-F139-4D7D-87BA-3A8B98CC53E1@z.odi.ac> <26274624.post@talk.nabble.com> Message-ID: It's not your class definition that is the problem -- your class definition is good. The problem is that when you interact with it using the REPL, you don't specify any particular type you want so it's ambiguous. Usually this is not a problem in actual programs that you compile because there's enough context for the type inferencer to figure out what type 'a' should be. You can give it enough context in the REPL either by annotating the value or by using some other typed thing, e.g. let a = 1:: Int If you really want it to only work on Int, then you shouldn't use a typeclass, instead just write the function directly -- plus :: Int -> Int -> Int plus = (+) -Ross On Nov 9, 2009, at 5:09 PM, Paul Tokarev wrote: > > Thanks, that works. But how sould I change my class definition, so > that it > works without (2::Int), but just with 2? > > > Ross Mellgren wrote: >> >> You did not specify what type of number it is -- in Haskell numeric >> constants like "1" are actually typed as forall a. Num a -- that is, >> can be any type of Num. >> >> Try: plus (2::Int) 3 >> >> -Ross >> >> On Nov 9, 2009, at 1:44 PM, Paul Tokarev wrote: >> >>> >>> Hi. >>> >>> I am using Hugs 98 >>> I have that piece of code: >>> >>> class PlusTimes a where >>> plus :: a -> a -> a >>> >>> instance PlusTimes Int where >>> plus x y = x + y >>> >>> when I run : "plus 2 3" I get this error: >>> ERROR - Unresolved overloading >>> *** Type : (Num a, PlusTimes a) => a >>> *** Expression : plus 2 3 >>> >>> What am I doing wrong? >>> Thanks. >>> >>> -- >>> View this message in context: >>> http://old.nabble.com/classes-question-tp26271257p26271257.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 mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > -- > View this message in context: http://old.nabble.com/classes-question-tp26271257p26274624.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 From muad.dib.space at gmail.com Mon Nov 9 17:22:00 2009 From: muad.dib.space at gmail.com (muad) Date: Mon Nov 9 16:57:52 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <25860155.post@talk.nabble.com> References: <25860155.post@talk.nabble.com> Message-ID: <26274773.post@talk.nabble.com> I have come across an example: > However, the following proof of the lovely identity: > sum . map (^3) $ [1..n] = (sum $ [1..n])^2 is perfectly rigorous. > > Proof: True for n = 0, 1, 2, 3, 4 (check!), hence true for all n. QED. > > In order to turn this into a full-?edged proof, all you have to do is > mumble the following incantation: > Both sides are polynomials of degree ? 4, hence it is enough to check the > identity at ?ve distinct > values. > from http://www.math.rutgers.edu/~zeilberg/mamarim/mamarimPDF/enquiry.pdf Now this sort of idea surely applies to more than just number theory? -- View this message in context: http://old.nabble.com/is-proof-by-testing-possible--tp25860155p26274773.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From duncan.coutts at googlemail.com Mon Nov 9 17:23:35 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Mon Nov 9 16:59:30 2009 Subject: [Haskell-cafe] Cabal In-Reply-To: <5fdc56d70911090940h2f500f87q3d12b5274bb708d4@mail.gmail.com> References: <334011.49628.qm@web58806.mail.re1.yahoo.com> <2AF030F8-EA18-4BEB-97C6-1EB0F8352918@phys.washington.edu> <9D3E6EE2-0FD0-45B2-BD15-E4008AB6C28B@phys.washington.edu> <5fdc56d70911090508r5415f1fdkfba59ecd202abacf@mail.gmail.com> <1257785412.4680.638.camel@localhost> <5fdc56d70911090940h2f500f87q3d12b5274bb708d4@mail.gmail.com> Message-ID: <1257805415.4680.1369.camel@localhost> On Mon, 2009-11-09 at 17:40 +0000, Stephen Tetley wrote: > 2009/11/9 Duncan Coutts : > > > > > That should work, and probably the recommendation should be for cygwin > > users to edit their cabal config to at add C:\cygwin\lib and C:\cygwin > > \usr\include as standard. > > > Hi Duncan > > That would definitely be the best idea, but where does the cabal > config live? If you were running the current version then "cabal --help" would say. To upgrade run: cabal install cabal-install Otherwise, it's somewhere like C:\Documents and Settings\$user\Application Data\cabal\config though on some systems (vista perhaps?) I think it's under the user's roaming profile directory. Duncan From tom at lokhorst.eu Mon Nov 9 18:08:45 2009 From: tom at lokhorst.eu (Tom Lokhorst) Date: Mon Nov 9 17:45:05 2009 Subject: [Haskell-cafe] Observer pattern in Haskell? In-Reply-To: <4AF82C43.7070701@kent.ac.uk> References: <7A5CB0CB-3B3A-4639-9C42-E75B551293F6@gimbo.org.uk> <4AF82C43.7070701@kent.ac.uk> Message-ID: <317ca7670911091508o569f066em83449e156cc9690@mail.gmail.com> I haven't looked at the code extensively, I just wanted to comment on this point: > There is no way to remove an observer, which is something I'd expect to have > available. I realise this would require assigning a key to each observer > (and thus perhaps storing them in an associative map) or some way to filter > them, but I think if you can only ever add observers, it will get awkward. It might be convenient to have the `addObserver` function return a "detachment function" as its result. At Microsoft, Erik Meijer is working on an "Rx framework" [1], which is an implementation of the GoF Observer pattern. The implementation is, as Erik describes it, the mathematical dual of the Enumerable pattern. In the Rx framework, the `addObserver` method returns an `IDisposable` object with a single method `dispose()`, this will detach the observer from its subject. This is more convenient than trying to remember the unique object identity of the observer (as that disallows anonymous lambdas). I don't know how this would work in a Haskell context, but it might be interesting to think about. - Tom Lokhorst [1]: http://channel9.msdn.com/shows/Going+Deep/Expert-to-Expert-Brian-Beckman-and-Erik-Meijer-Inside-the-NET-Reactive-Framework-Rx/ On Mon, Nov 9, 2009 at 3:50 PM, Neil Brown wrote: > Andy Gimblett wrote: >> >> Hi all, >> >> I've been doing some GUI programming recently, using wx. ?To help manage >> dependencies between state and UI elements, I looked for a Haskell version >> of the Observer design pattern, and I found an implementation written by >> Bastiaan Heeren of ou.nl [1]. >> >> Now, before I make a hackage release: >> >> 1. Does anyone have any comments, on either version? > > There is no way to remove an observer, which is something I'd expect to have > available. ?I realise this would require assigning a key to each observer > (and thus perhaps storing them in an associative map) or some way to filter > them, but I think if you can only ever add observers, it will get awkward. > >> 2. In particular, is the MVar version sensible? ?I'm aiming for mutual >> exclusion between threads. ?I _think_ I've got it, but I'm perhaps not >> familiar enough with the semantics of MVar to be certain. ?Advice >> appreciated. ?If it _is_ sensible, then is there any reason not to just use >> this, and discard the IORef version? > > It looks fine (and thread-safe) to me, but I'd agree that you may as well > just use the MVar version and leave out the IORef version. > >> The current implementation is synchronous, in that any observer functions >> are called immediately and synchronously (and in the same thread as the >> change of subject value). ?I'm pondering extending the package with an >> asynchronous version where the update just trips a flag, and the observer >> function picks this up later - possibly in another thread. ?The idea there >> is to help in cases where certain operations have to be in a particular >> thread. ?But this will mean a change to the typeclass too, I guess - or the >> addition of another one for observers themselves. ?Again, any thoughts? > > I was a bit surprised at first that the observers were called synchronously. > ?Asynchronous is what I'd expect, and it's also harder to code the > asynchronous handlers wrongly. ?One blocking call (such as putMVar) in a > synchronous handler can screw up your whole program by delaying the > subsequent observers (and at that stage, the order in which the observers > were added begins to matter). ?But my idea of how asynchronous would be > implemented seems different to yours, judging by your description. ?Why not > just augment this function in the synchronous version: > > notifyObservers :: Subject sub val => sub -> IO () > notifyObservers subject = > ?do value <- getValue subject > ? ? observers <- getObservers subject > ? ? mapM_ ($ value) observers to become: > > notifyObserversAsync :: Subject sub val => sub -> IO () > notifyObserversAsync subject = > ?do value <- getValue subject > ? ? observers <- getObservers subject > ? ? mapM_ (forkIO . ($ value)) observers > > This is what I was expecting to happen -- all the observer actions are > spawned off into their own thread to run whatever code they want (either > communicating back to an existing thread, or performing some long in-depth > action). > > Thanks, > > Neil. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From byorgey at seas.upenn.edu Mon Nov 9 18:09:21 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Mon Nov 9 17:45:14 2009 Subject: [Haskell-cafe] Type-indexed expressions with fixpoint Message-ID: <20091109230921.GA25152@seas.upenn.edu> Hi all, This email is literate Haskell. I'm struggling to come up with the right way to add a fixpoint constructor to an expression language described by a type-indexed GADT (details below). Any suggestions, comments, or pointers welcome. > {-# LANGUAGE KindSignatures, GADTs #-} Consider the following type-indexed GADT, which encodes descriptions of polymorphic regular types: > data U :: (* -> *) -> * where > Unit :: U None > Var :: U Id > (:+:) :: U f -> U g -> U (Sum f g) > (:*:) :: U f -> U g -> U (Prod f g) > > data None a = None > data Id a = Id a > data Sum f g a = Inl (f a) | Inr (g a) > data Prod f g a = Prod (f a) (g a) Given u :: U f, thanks to the type indexing, we can write the following function to enumerate all the shapes of a given size described by u: > enumShapes :: Int -> U f -> [f ()] > enumShapes 0 Unit = [None] > enumShapes _ Unit = [] > enumShapes 1 Var = [Id ()] > enumShapes _ Var = [] > enumShapes n (f :+: g) = map Inl (enumShapes n f) ++ map Inr (enumShapes n g) > enumShapes n (f :*: g) = [ Prod x y | x <- enumShapes n f, y <- enumShapes n g ] But of course this isn't very interesting without adding a least fixpoint constructor. That is, I'd like to have something like data U :: (* -> *) -> * where Unit :: U None Var :: U Id (:+:) :: U f -> U g -> U (Sum f g) (:*:) :: U f -> U g -> U (Prod f g) Mu :: ??? enumShapes n (Mu ...) = ... But I am quite at a loss as far as expressing the type of Mu. If the GADT wasn't type-indexed, I'd just use HOAS, i.e. Mu :: (U -> U) -> U; but since Haskell doesn't have type-level lambdas, I don't see how to make that work. Suggestions greatly appreciated! Pointing out that I am looking at this in the wrong way (if you think such is the case) would be highly appreciated as well. thanks, -Brent From gabor at karamaan.com Mon Nov 9 18:28:18 2009 From: gabor at karamaan.com (siki) Date: Mon Nov 9 18:04:08 2009 Subject: [Haskell-cafe] Exciting job opportunity Message-ID: <26275652.post@talk.nabble.com> Principal investment firm based in Manhattan is looking for an outstanding software developer to maintain and develop proprietary accounting and portfolio management systems. You should have at least a bachelor?s degree in computer science from a top university and impeccable coding style. This is a high-impact, high-visibility job opportunity where successful candidates will be entrusted with a lot of responsibility for products that have a direct effect on the P&L of the firm and influences our workflow. This is a very small hedge fund with me being the only developer right now. The next hire will have a very direct say into how this side of our business progresses from here. We are a growth oriented firm that values people who take a craftsman?s pride in their work. We always like to take a contrarian view of things and value experimenting and using often overlooked technologies. That is one of the main reasons why we currently started using Haskell in developing our quantitative models. We are looking for a canditate who shows strong analytical, organizational, and communication skills. Attention to detail is essential, i.e. we fully document everything we do and pay a lot of attention to coding style. The majority of our existing code was written in Java, so candidates must have at least some experience with Java and related technologies. Experience working with SQL would be desired as well. Background in accounting is not necessary but is definitely a plus. Please send your CV and cover letter to recruitment at karamaan.com, or reply to this post if you have any questions. Thanks -- View this message in context: http://old.nabble.com/Exciting-job-opportunity-tp26275652p26275652.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ok at cs.otago.ac.nz Mon Nov 9 23:48:41 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Mon Nov 9 23:24:40 2009 Subject: [Haskell-cafe] ANN: acme-dont In-Reply-To: References: Message-ID: On Nov 9, 2009, at 11:27 PM, Gracjan Polak wrote: > With special apologies to Luke Palmer that it took the Haskell > community 7.5 years to catch up with Perl. We may not have had the simple name "don't", but we've been able to write "const $ return ()" for a long time. From phi500ac at yahoo.ca Tue Nov 10 00:04:05 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Mon Nov 9 23:39:56 2009 Subject: [Haskell-cafe] Help Haskell driving Medical Instruments Message-ID: <608498.76745.qm@web58803.mail.re1.yahoo.com> Recently, I received as gift medical instruments designed by one of my father former students. There is a description of these instruments on my web page. Here is the address: http://www.discenda.org/med/ By the way, I am not that guy that appears in a picture wearing emg sensors. That said, the instruments and everything else are programmed in Clean. Then I have a new opportunity of translating Clean programs to Haskell and test them in a real application application. Of course, I simplified the programs to see how they work. The medical instruments have on-board computers, that record signals (electromyograms, electroencephalograms, electrocardiograms, end-tydal CO2 partial pressure and temperature), pre-process them and send them to the main computer. The main-computer recognizes patterns in the signals, and use the result to drive a wheelchair, or to call a doctor. On my page you wil find more complete explanations and pictures of the instruments. For ready reference, here is my address: http://www.discenda.org/med/ I decided start my translation work from the most simple programs, the graphical interface and the communication protocol.? After substituting a Haskell program for the Clean original, I discovered that the system did not work anymore if I exited the Haskell program. In few words, after leaving the Haskell program without turning off the computer or the sensors, and entering the Haskell program again, Haskell failed to communicate with the sensors. I did what I always do in? such a situation: I simplified the program until I reduced it to a few lines. I discovered that Haskell failed to close the serial port.? There is a serial to UART-0 driver that allows me to plug the serial cable to a USB port, that both feeds the sensors, and permit communication. I fixed the bug by passing a useless integer argument to the function used to close the port. Since I don't like this kind of patch (useless arguments), I would like to know why the original program does not work, and also I would appreciate if someone could suggest a way to get rid of the argument whose sole job is force Haskell to close the port.? The GUI is based on the Small JAPI biding, fixed and incremented with text processing components. Here is the fixed Haskell program: import Gui.Binding import Gui.Types import Gui.Constants import SER.IAL import Control.Monad import Data.Char main = do rv <- j_start ????????? frame <- j_frame "Sensors" ??? ? exit_button <- j_button frame "Exit" ??? ? j_setpos exit_button 50 50 ??? ? j_setsize exit_button 80 30 ??? ? fld <- j_textfield frame 30 ??? ? j_setpos fld 50 100 ????????? j_show frame ????????? opencport(4) ????????? waitForFrameAction frame fld exit_button ????????? let r = closecport 7? {- without the argument, closecport does not work -} ????????? print r ????????? return j_quit ??????? waitForFrameAction :: Frame ->? Object -> Object -> IO Bool waitForFrameAction frame f b = ??? do obj <-? j_nextaction ?????? again <- if obj == event b ???????????????????? then return False ??? ??? ???? else ??? ??? ?????? do {- nm <- j_gettext f 200 -} ??? ??? ????????? tx <- sendMessage 1 "t" ??? ??? ????????? let tp= filter (> ' ') tx ??? ??? ????????? rx <- sendMessage 1 "x" ??? ??? ????????? let rd= filter (> ' ') rx ??? ??? ????????? let x = hex2dec rd ??? ??? ????????? let tt= (fromIntegral x)*209.0/1024 - 67.5 ??? ??? ????????? j_settext f ((show tt)++" ==> "++tp) ??? ??? ????????? return True ?????? if not again ??? ? then return True ??? ? else waitForFrameAction frame f? b hex2dec :: String -> Int hex2dec h= sum (zipWith (*) ??????????????????? (map (16^) [3,2,1,0]) ??????????????????? [digitToInt c | c <- h]) ??????????????????? convert d r s0= (fromIntegral (hex2dec d))*r/1024.0- s0 As I told before, let r = closecport 7? did not work until I gave it an argument. Here is the interface between the C-side, and the Haskell-side of the program: {-# LANGUAGE ForeignFunctionInterface #-} module SER.IAL where ? ?import Control.Monad ?import Foreign ?import Foreign.C.Types ?import Foreign.C ?foreign import ccall "rs232.h opencport" opencport :: CInt -> IO () ?foreign import ccall "rs232.h closecport" closecport :: CInt -> CInt ?foreign import ccall "rs232.h rdrs232" c_sendmsg :: CInt -> CString -> CString ?sendMessage :: Int -> String -> IO String ?sendMessage? n msg = ?? withCString msg $ ????? \str -> peekCString (c_sendmsg (fromIntegral n) str) ????? Originally, I had the following line (that did not work properly): foreign import ccall "rs232.h closecport" closecport ::? IO () You will find below the C-program. The original program (that did not work) had the following definition for closecport: int closecport() { ?? CloseComport(); ?? return 3; } This deffinition (that did not work) was replaced by the following one: int closecport(int n) { ?? CloseComport(); ?? return n; } Here is the complete C program: #include "serial.h" #include #include /* Possible baudrates on a normal pc: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200 */ #define BAUD "baud=9600 data=8 parity=N stop=1" HANDLE Cport; char comports[16][10]={"\\\\.\\COM1",? "\\\\.\\COM2",? "\\\\.\\COM3",? "\\\\.\\COM4", ?????????????????????? "\\\\.\\COM5",? "\\\\.\\COM6",? "\\\\.\\COM7",? "\\\\.\\COM8", ?????????????????????? "\\\\.\\COM9",? "\\\\.\\COM10", "\\\\.\\COM11", "\\\\.\\COM12", ?????????????????????? "\\\\.\\COM13", "\\\\.\\COM14", "\\\\.\\COM15", "\\\\.\\COM16"}; int OpenComport(int comport_number) { ? if(comport_number>15) ? { ??? printf("illegal comport number\n"); ??? return(1); ? } ? Cport = CreateFileA(comports[comport_number], ????????????????????? GENERIC_READ|GENERIC_WRITE, ????????????????????? 0,????????????????????????? /* no share? */ ????????????????????? NULL,?????????????????????? /* no security */ ????????????????????? OPEN_EXISTING, ????????????????????? 0,????????????????????????? /* no threads */ ????????????????????? NULL);????????????????????? /* no templates */ ? if(Cport==INVALID_HANDLE_VALUE) ? { ??? printf("unable to open comport\n"); ??? return(1); ? } ? DCB port_settings; ? memset(&port_settings, 0, sizeof(port_settings));? /* clear the new struct? */ ? port_settings.DCBlength = sizeof(port_settings); ? if(!BuildCommDCBA(BAUD, &port_settings)) ? { ??? printf("unable to set comport dcb settings\n"); ??? CloseHandle(Cport); ??? return(1); ? } ? if(!SetCommState(Cport, &port_settings)) ? { ??? printf("unable to set comport cfg settings\n"); ??? CloseHandle(Cport); ??? return(1); ? } ? COMMTIMEOUTS Cptimeouts; ? Cptimeouts.ReadIntervalTimeout???????? = MAXDWORD; ? Cptimeouts.ReadTotalTimeoutMultiplier? = 10; ? Cptimeouts.ReadTotalTimeoutConstant??? = 10; ? Cptimeouts.WriteTotalTimeoutMultiplier = 10; ? Cptimeouts.WriteTotalTimeoutConstant?? = 10; ? if(!SetCommTimeouts(Cport, &Cptimeouts)) ? { ??? printf("unable to set comport time-out settings\n"); ??? CloseHandle(Cport); ??? return(1); ? } ? return(0); } int PollComport(unsigned char *buf, int size) { ? int n; ? if(size>4096)? size = 4096; /* added the void pointer cast, otherwise gcc will complain about */ /* "warning: dereferencing type-punned pointer will break strict aliasing rules" */ ? ReadFile(Cport, buf, size, (LPDWORD)((void *)&n), NULL); ? return(n); } int RdByte(unsigned char* m) { ? int n; ? ReadFile(Cport, m, 1, (LPDWORD)((void *)&n), NULL); ? return(n); } int SendByte(unsigned char byte) { ? int n; ? WriteFile(Cport, &byte, 1, (LPDWORD)((void *)&n), NULL); ? if(n<0)? return(1); ? return(0); } int SendBuf(unsigned char *buf, int size) { ? int n; ? if(WriteFile(Cport, buf, size, (LPDWORD)((void *)&n), NULL)) ? { ??? return(n); ? } ? return(-1); } int CloseComport(void) { ? CloseHandle(Cport); ? return(0); } int IsCTSEnabled(void) { ? int status; ? GetCommModemStatus(Cport, (LPDWORD)((void *)&status)); ? if(status&MS_CTS_ON) return(1); ? else return(0); } int cprintf(const char *text)? /* sends a string to serial port */ { ? while(*text != 0)?? SendByte(*(text++)); ? return(0); } int opencport(int p) { ?? OpenComport(p-1); ?? return 3; } int closecport(int n) { ?? CloseComport(); ?? return n; } char* rdrs232(int n, char* msg) { ??? char *str; ??? char mm; ??? int i, j; ??? for (j=0; j0 && str[0]==0) { str[0]= ' ';} ??? return(str); } Finally, here is the serial.h file: #ifndef rs232_INCLUDED #define rs232_INCLUDED #ifdef __cplusplus extern "C" { #endif #include #include #ifdef __linux__ #include #include #include #include #include #include #include #else #include #endif int OpenComport(int); int PollComport(unsigned char *, int); int SendByte(unsigned char); int SendBuf(unsigned char *, int); int CloseComport(void); int cprintf(const char *); int IsCTSEnabled(void); char *topa(int n); int opencport(int p); int closecport(int n); char* rdrs232(int n, char* msg); #ifdef __cplusplus } /* extern "C" */ #endif #endif __________________________________________________________________ Make your browsing faster, safer, and easier with the new Internet Explorer? 8. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091109/202f3ff0/attachment.html From cjs at starling-software.com Tue Nov 10 00:52:21 2009 From: cjs at starling-software.com (Curt Sampson) Date: Tue Nov 10 00:28:14 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <26274773.post@talk.nabble.com> References: <25860155.post@talk.nabble.com> <26274773.post@talk.nabble.com> Message-ID: <20091110055219.GI19475@poetic.cynic.net> On 2009-11-09 14:22 -0800 (Mon), muad wrote: > > Proof: True for n = 0, 1, 2, 3, 4 (check!), hence true for all n. QED. > > ... Actually, the test is that it's true for 0 through 4 is not sufficient for a proof; you also need to prove in some way that you need do no further tests. Showing that particular point in this case appears to me to lie outside the realm of testing. cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com From jason.dusek at gmail.com Tue Nov 10 01:41:16 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Tue Nov 10 01:17:07 2009 Subject: [Haskell-cafe] Help Haskell driving Medical Instruments In-Reply-To: <608498.76745.qm@web58803.mail.re1.yahoo.com> References: <608498.76745.qm@web58803.mail.re1.yahoo.com> Message-ID: <42784f260911092241u5ba921b1p7978129ddae07ec9@mail.gmail.com> Does marking the call `unsafe` make any difference? This is running on a *NIX of some flavour? -- Jason Dusek From conor at strictlypositive.org Tue Nov 10 03:24:51 2009 From: conor at strictlypositive.org (Conor McBride) Date: Tue Nov 10 03:00:42 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <20091110055219.GI19475@poetic.cynic.net> References: <25860155.post@talk.nabble.com> <26274773.post@talk.nabble.com> <20091110055219.GI19475@poetic.cynic.net> Message-ID: <8C050871-A63B-4A08-9803-0F815B678B08@strictlypositive.org> On 10 Nov 2009, at 05:52, Curt Sampson wrote: > On 2009-11-09 14:22 -0800 (Mon), muad wrote: > >>> Proof: True for n = 0, 1, 2, 3, 4 (check!), hence true for all n. >>> QED. >>> ... > > Actually, the test is that it's true for 0 through 4 is not sufficient > for a proof; It's enough testing... > you also need to prove in some way that you need do no > further tests. ...and you can calculate how much testing is enough by computing an upper bound on the polynomial degree of the expression. (The summation operator increments degree, the difference operator decreases it, like in calculus.) > Showing that particular point in this case appears to me > to lie outside the realm of testing. You need to appeal to a general theorem about expressions of a particular form, but if that theorem is in the library, the only work you need do is to put the expressions in that form. This is sometimes described as the "reflective" proof method: express problem in language capturing decidable fragment; hit with big stick. There are lots of other examples of this phenomenon. The zero-one principle for sorting networks is a favourite of mine. I'm sure there's more to be found here. It smells a bit of theorems for free: the strength comes from knowing what you don't. All the best Conor From d.w.mead at gmail.com Tue Nov 10 05:16:44 2009 From: d.w.mead at gmail.com (Dan Mead) Date: Tue Nov 10 04:52:41 2009 Subject: [Haskell-cafe] pattern match failure as control structure Message-ID: <59ba068d0911100216n41748d75uc8c8f7b6426570ba@mail.gmail.com> hey all, is there something special about pattern match exceptions? i'm attempting to catch pattern match failures to use as control for a production system. so i want to be able to do something like catch (head []) (\e -> print "that theres pattern fail!" ) any suggestions? From apfelmus at quantentunnel.de Tue Nov 10 05:46:08 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Tue Nov 10 05:22:24 2009 Subject: [Haskell-cafe] Re: is proof by testing possible? In-Reply-To: <8C050871-A63B-4A08-9803-0F815B678B08@strictlypositive.org> References: <25860155.post@talk.nabble.com> <26274773.post@talk.nabble.com> <20091110055219.GI19475@poetic.cynic.net> <8C050871-A63B-4A08-9803-0F815B678B08@strictlypositive.org> Message-ID: Conor McBride wrote: > ....and you can calculate how much testing is enough by > computing an upper bound on the polynomial degree of the > expression. (The summation operator increments degree, > the difference operator decreases it, like in calculus.) > > This is sometimes described > as the "reflective" proof method: express problem in > language capturing decidable fragment; hit with big stick. The fact that summation maps polynomials to polynomials needs to be proven, of course, and I guess that this proof is not much simpler than proving sum . map (^3) $ [1..n] = (sum $ [1..n])^2 in the first place. But once proven, the former can be reused ad libitum. Regards, apfelmus -- http://apfelmus.nfshost.com From vandijk.roel at gmail.com Tue Nov 10 05:50:45 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Tue Nov 10 05:26:36 2009 Subject: [Haskell-cafe] pattern match failure as control structure In-Reply-To: <59ba068d0911100216n41748d75uc8c8f7b6426570ba@mail.gmail.com> References: <59ba068d0911100216n41748d75uc8c8f7b6426570ba@mail.gmail.com> Message-ID: Have a look at this recently uploaded package: http://hackage.haskell.org/package/first-class-patterns Examine the "tryMatch" function in particular. From kdamodar2000 at gmail.com Tue Nov 10 06:47:54 2009 From: kdamodar2000 at gmail.com (damodar kulkarni) Date: Tue Nov 10 06:23:44 2009 Subject: [Haskell-cafe] filter using foldr point-free? Message-ID: Hi, We can define filter using foldr as under: filter1 p = foldr (\x xs -> (if (p x) then (x:xs) else xs)) [] Can we define filter using foldr but in pointfree style? Thanks -DM -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091110/c3370878/attachment.html From svein.ove at aas.no Tue Nov 10 06:56:56 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Tue Nov 10 06:32:47 2009 Subject: [Haskell-cafe] filter using foldr point-free? In-Reply-To: References: Message-ID: <221b53ab0911100356n50d3a8b6rbb313bce7fa459f4@mail.gmail.com> On Tue, Nov 10, 2009 at 12:47 PM, damodar kulkarni wrote: > Hi, > We can define filter using foldr as under: > > filter1 p = foldr (\x xs -> (if (p x) then (x:xs) else xs))? [] > > Can we define filter using foldr but in pointfree style? > Pointfree code is (nearly) always possible, but sometimes not very desirable. The first thing to do is to ask lambdabot for help; in this case, the answer is.. this: filter1 = flip foldr [] . flip flip id . (ap .) . (`ap` (:)) . (((.) . if') .) if' p a b = if p then a else b Now, there may be a better way to go about this, but I don't think I'd bother trying. The pointful variant seems quite readable as-is. :P -- Svein Ove Aas From oleg at okmij.org Tue Nov 10 07:12:27 2009 From: oleg at okmij.org (oleg@okmij.org) Date: Tue Nov 10 06:48:38 2009 Subject: [Haskell-cafe] Type-indexed expressions with fixpoint Message-ID: <20091110121227.1831A1727F@Adric.ern.nps.edu> Brent Yorgey wrote: > This email is literate Haskell. I'm struggling to come up with the > right way to add a fixpoint constructor to an expression language > described by a type-indexed GADT (details below). > > but since Haskell doesn't have type-level lambdas, I don't see how > to make that work. John Reynolds showed long ago that any higher-order language can be encoded in first-order. We witness this every day: higher-order language like Haskell is encoded in first-order language (machine code). The trick is just to add a layer of interpretive overhead -- I mean, a layer of interpretation. The closure conversion on type level was shown in http://okmij.org/ftp/Computation/lambda-calc.html#haskell-type-level Here's how a similar technique applies to the problem at hand. There is an alternative solution: encode higher-order functors by means of SKI combinators. Somehow I prefer the pointed solution. The complete code follows. {-# LANGUAGE TypeFamilies, KindSignatures, GADTs, FlexibleInstances #-} data U :: (* -> *) -> * where Unit :: U None Var :: U Id (:+:) :: U f -> U g -> U (Sum f g) (:*:) :: U f -> U g -> U (Prod f g) Mu :: HOFunctor f => f -> U (MU f) data None a = None deriving Show data Id a = Id a deriving Show data Sum f g a = Inl (f a) | Inr (g a) deriving Show data Prod f g a = Prod (f a) (g a) deriving Show newtype MU f a = MU (Res f (MU f) a) type family Res f self :: * -> * type instance Res List self = Sum None (Prod Id self) data List = List -- the code for the HO functor class HOFunctor f where fn :: f -> U g -> U (Res f g) instance HOFunctor List where fn _ self = Unit :+: (Var :*: self) enumShapes :: Int -> U f -> [f ()] enumShapes 0 Unit = [None] enumShapes _ Unit = [] enumShapes 1 Var = [Id ()] enumShapes _ Var = [] enumShapes n (f :+: g) = map Inl (enumShapes n f) ++ map Inr (enumShapes n g) enumShapes n (f :*: g) = [ Prod x y | x <- enumShapes n f, y <- enumShapes n g] enumShapes n self@(Mu f) = map MU $ enumShapes (n-1) (fn f self) test0 = enumShapes 0 (Unit :+: (Var :*: Var)) -- [Inl None] test1 = enumShapes 1 (Unit :+: (Var :*: Var)) -- [Inr (Prod (Id ()) (Id ()))] test2 = enumShapes 1 (Mu List) -- [Inl None] test3 = enumShapes 2 (Mu List) -- [Inr (Prod (Id ()) Inl None)] instance Show (MU List ()) where show (MU x) = show x From phi500ac at yahoo.ca Tue Nov 10 08:01:33 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Tue Nov 10 07:37:27 2009 Subject: [Haskell-cafe] Help Haskell driving Medical Instruments In-Reply-To: <42784f260911092241u5ba921b1p7978129ddae07ec9@mail.gmail.com> Message-ID: <140785.62981.qm@web58806.mail.re1.yahoo.com> Hi, Jason. I don't know how to mark the call unsafe. And I don't know what is a *Nix (perhaps unix?). I am running the main program on Windows.? Here is the compilation script: ghc -fglasgow-exts serial.c? %1.hs -L./ -ljapi --make erase *.hi erase *.o strip %1.exe BTW I figure out that passing an argument to closecport only makes the problem occur less often. Here is an example: D:\ghc\sensors>strip temper.exe D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe 4 D:\ghc\sensors>temper.exe unable to set comport cfg settings 4 --- On Mon, 11/9/09, Jason Dusek wrote: From: Jason Dusek Subject: Re: [Haskell-cafe] Help Haskell driving Medical Instruments To: "Philippos Apolinarius" Cc: "Haskell Cafe" Received: Monday, November 9, 2009, 11:41 PM ? Does marking the call `unsafe` make any difference? ? This is running on a *NIX of some flavour? -- Jason Dusek __________________________________________________________________ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091110/d0a54a25/attachment.html From cjs at starling-software.com Tue Nov 10 11:02:51 2009 From: cjs at starling-software.com (Curt Sampson) Date: Tue Nov 10 10:38:43 2009 Subject: [Haskell-cafe] is proof by testing possible? In-Reply-To: <8C050871-A63B-4A08-9803-0F815B678B08@strictlypositive.org> References: <25860155.post@talk.nabble.com> <26274773.post@talk.nabble.com> <20091110055219.GI19475@poetic.cynic.net> <8C050871-A63B-4A08-9803-0F815B678B08@strictlypositive.org> Message-ID: <20091110160251.GT19475@poetic.cynic.net> On 2009-11-10 08:24 +0000 (Tue), Conor McBride wrote: > On 10 Nov 2009, at 05:52, Curt Sampson wrote: > > This is sometimes described as the "reflective" proof method: express > problem in language capturing decidable fragment; hit with big stick. Well, that's pretty sweet. *And* you get to use a big stick. Who can argue with that? > I'm sure there's more to be found here. It smells a bit of theorems > for free: the strength comes from knowing what you don't. Yup. But this seems to me to be heading towards keeping proofs with your code (which we're already doing in sort of a simple way with our type systems; how long can it be until we're embedding Coq or Agda proofs in our production Haskell code?). That's heading well away from testing. (And I approve.) cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com From daniel.is.fischer at web.de Tue Nov 10 11:27:17 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Nov 10 11:04:34 2009 Subject: [Haskell-cafe] Help Haskell driving Medical Instruments In-Reply-To: <140785.62981.qm@web58806.mail.re1.yahoo.com> References: <140785.62981.qm@web58806.mail.re1.yahoo.com> Message-ID: <200911101727.17916.daniel.is.fischer@web.de> Am Dienstag 10 November 2009 14:01:33 schrieb Philippos Apolinarius: > Hi, Jason. > I don't know how to mark the call unsafe. And I don't know what is a *Nix > (perhaps unix?). Unix or unix-derivate (linux, BSD, ...) > I am running the main program on Windows. Then it might be necesary to let the foreign calls have the calling convention stdcall instead of ccall. From mauricio.antunes at gmail.com Tue Nov 10 11:46:57 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Tue Nov 10 11:23:18 2009 Subject: [Haskell-cafe] Sending patches to ghc related repositories Message-ID: Hi, all, I just tried to send a patch to a ghc tool. I see in hackage that the maintainer e-mail is 'cvs-fptools@haskell.org' (package is hsc2hs). I tried sending darcs patch to this e-mail, but it's refused as it's not on that server allowed e-mails table. The patch isn't really important, just a documentation typo, but I'm curious about what is the proper way to do it. Thanks, Maur?cio From mightybyte at gmail.com Tue Nov 10 14:09:46 2009 From: mightybyte at gmail.com (MightyByte) Date: Tue Nov 10 13:45:36 2009 Subject: [Haskell-cafe] Static Linking Problem Message-ID: I am trying to statically compile a simple haskell program so I can use it on a Linux computer without haskell and it's associated libraries. Here is a small example program that illustrates my problem: > module Main where > import Network.Fancy > main = do > withDgram (IP "127.0.0.1" 1234) (flip send "Hello network\n") After a bit of googling, I came to the conclusion that I needed to compile it with "ghc --make -static -optl-static Foo.hs". Using only "-static" or "-optl-static" by themselves did not generate a statically linked binary. But when I compile with both those parameters I get a bunch of linker errors: /home/mightybyte/.cabal/lib/network-fancy-0.1.4/ghc-6.10.4/libHSnetwork-fancy-0.1.4.a(Fancy.o): In function `s6ks_info': (.text+0x3068): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/ghc-6.10.4/libffi.a(closures.o): In function `init_mparams': (.text+0x3e): undefined reference to `pthread_mutex_lock' /usr/lib/ghc-6.10.4/libffi.a(closures.o): In function `init_mparams': (.text+0x52): undefined reference to `pthread_mutex_unlock' /usr/lib/ghc-6.10.4/libffi.a(closures.o): In function `init_mparams': (.text+0xd3): undefined reference to `pthread_mutex_init' /usr/lib/ghc-6.10.4/libffi.a(closures.o): In function `ffi_closure_free': (.text+0x59c): undefined reference to `pthread_mutex_lock' etc... I've tried this on both Fedora and Arch Linux and I get the same error. Anyone know how to solve this problem? From d.w.mead at gmail.com Tue Nov 10 14:23:26 2009 From: d.w.mead at gmail.com (Dan Mead) Date: Tue Nov 10 13:59:17 2009 Subject: [Haskell-cafe] pattern match failure as control structure In-Reply-To: References: <59ba068d0911100216n41748d75uc8c8f7b6426570ba@mail.gmail.com> Message-ID: <59ba068d0911101123r3b829725w68f32d6ec66dca97@mail.gmail.com> i think that may be too in depth. all i'm trying to do is catch a regular pattern match exception On Tue, Nov 10, 2009 at 5:50 AM, Roel van Dijk wrote: > Have a look at this recently uploaded package: > > http://hackage.haskell.org/package/first-class-patterns > > Examine the "tryMatch" function in particular. > From fernandohsanches at gmail.com Tue Nov 10 14:23:29 2009 From: fernandohsanches at gmail.com (Fernando Henrique Sanches) Date: Tue Nov 10 13:59:24 2009 Subject: [Haskell-cafe] Parsec - separating Parsing from Lexing Message-ID: <174c72ef0911101123o576827bfp394d364d00777975@mail.gmail.com> Hello. I'm currently implementing a MicroJava compiler for a college assignment (the implemented language was defined, the implementation language was of free choice). I've sucessfully implemented the lexer using Parsec. It has the type String -> Parser [MJVal], where MJVal are all the possible tokens. However, I don't know how to implement the parser, or at least how to do it keeping it distinguished from the lexer. For example, the MicroJava grammar specifies: Program = "program" ident {ConstDecl | VarDecl | ClassDecl} "{" {MethodDecl} "}". The natural solution (for me) would be: program = do string "program" programName <- identifier ... However, I can't do this because the file is already tokenized, what I have is something like: [Program_, identifier_ "testProgram", lBrace_, ...] for the example program: program testProgram { ... How should I implement the parser separated from the lexer? That is, how should I parse Tokens instead of Strings in the "Haskell way"? Fernando Henrique Sanches -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091110/7bdc8155/attachment.html From nicolas.pouillard at gmail.com Tue Nov 10 15:01:24 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Tue Nov 10 14:37:13 2009 Subject: [Haskell-cafe] pattern match failure as control structure In-Reply-To: <59ba068d0911101123r3b829725w68f32d6ec66dca97@mail.gmail.com> References: <59ba068d0911100216n41748d75uc8c8f7b6426570ba@mail.gmail.com> <59ba068d0911101123r3b829725w68f32d6ec66dca97@mail.gmail.com> Message-ID: <1257883035-sup-747@peray> Excerpts from Dan Mead's message of Tue Nov 10 20:23:26 +0100 2009: > i think that may be too in depth. > > all i'm trying to do is catch a regular pattern match exception > > On Tue, Nov 10, 2009 at 5:50 AM, Roel van Dijk wrote: > > Have a look at this recently uploaded package: > > > > http://hackage.haskell.org/package/first-class-patterns > > > > Examine the "tryMatch" function in particular. You can do this with Control.Exception.evaluate [1]. However while it looks like what you want I recommend you to not use it too often, catching "error" calls is not the best way of using Haskell. However if this is for debugging purpose or setting up a global exception catcher for a final product then this is fine. [1]: http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Exception.html#8 -- Nicolas Pouillard http://nicolaspouillard.fr From d.w.mead at gmail.com Tue Nov 10 15:05:55 2009 From: d.w.mead at gmail.com (Dan Mead) Date: Tue Nov 10 14:41:44 2009 Subject: [Haskell-cafe] pattern match failure as control structure In-Reply-To: <1257883035-sup-747@peray> References: <59ba068d0911100216n41748d75uc8c8f7b6426570ba@mail.gmail.com> <59ba068d0911101123r3b829725w68f32d6ec66dca97@mail.gmail.com> <1257883035-sup-747@peray> Message-ID: <59ba068d0911101205o65ddcb26ta37bb608f699ad92@mail.gmail.com> thanks, i've got it working i'll probably post the code when i'm done On Tue, Nov 10, 2009 at 3:01 PM, Nicolas Pouillard wrote: > Excerpts from Dan Mead's message of Tue Nov 10 20:23:26 +0100 2009: >> i think that may be too in depth. >> >> all i'm trying to do is catch a regular pattern match exception >> >> On Tue, Nov 10, 2009 at 5:50 AM, Roel van Dijk wrote: >> > Have a look at this recently uploaded package: >> > >> > http://hackage.haskell.org/package/first-class-patterns >> > >> > Examine the "tryMatch" function in particular. > > You can do this with Control.Exception.evaluate [1]. However > while it looks like what you want I recommend you to not use > it too often, catching "error" calls is not the best way of using > Haskell. However if this is for debugging purpose or setting up > a global exception catcher for a final product then this is fine. > > > [1]: http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Exception.html#8 > > -- > Nicolas Pouillard > http://nicolaspouillard.fr > From leather at cs.uu.nl Tue Nov 10 15:07:00 2009 From: leather at cs.uu.nl (Sean Leather) Date: Tue Nov 10 14:43:09 2009 Subject: [Haskell-cafe] Parsec - separating Parsing from Lexing In-Reply-To: <174c72ef0911101123o576827bfp394d364d00777975@mail.gmail.com> References: <174c72ef0911101123o576827bfp394d364d00777975@mail.gmail.com> Message-ID: <3c6288ab0911101207x5b9936bfg1097bd05c69e7d81@mail.gmail.com> > I've sucessfully implemented the lexer using Parsec. It has the type String > -> Parser [MJVal], where MJVal are all the possible tokens. > Great! You're partway there. > How should I implement the parser separated from the lexer? That is, how > should I parse Tokens instead of Strings in the "Haskell way"? > AFAIK, the difference is between having an input stream of type [Char] vs. having a stream of tokens, e.g. [MJVal]. I haven't used Parsec myself, but perhaps you want something of type 'GenParser MJVal s r' for some state s and return type r? There's an excellent set of lecture notes from a class we have at Utrecht, formerly called Grammars and Parsing and now Languages and Compilers, in which we use parser combinators in Haskell . http://people.cs.uu.nl/johanj/publications/MAIN.pdf It's not Parsec, but there's plenty of useful general information in there, cf. 4.5.1, 4.5.2. Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091110/37abb30b/attachment.html From jason.dusek at gmail.com Tue Nov 10 15:09:57 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Tue Nov 10 14:45:47 2009 Subject: [Haskell-cafe] Help Haskell driving Medical Instruments In-Reply-To: <140785.62981.qm@web58806.mail.re1.yahoo.com> References: <42784f260911092241u5ba921b1p7978129ddae07ec9@mail.gmail.com> <140785.62981.qm@web58806.mail.re1.yahoo.com> Message-ID: <42784f260911101209nca238f3rea1decb75356ffb9@mail.gmail.com> 2009/11/10 Philippos Apolinarius > I don't know how to mark the call unsafe. [...] I am running > the main program on Windows. Marking it unsafe is done by putting "unsafe" in the foreign import declaration. Even if it turns out not to fix the problem, it reduces the overhead of foreign calls (and is safe as long as they aren't going to call back into Haskell). Because your on Windows, you want to use "stdcall", as mentioned by Daniel Fischer. Thus the full declaration is: foreign import stdcall unsafe "rs232.h closecport" closecport :: IO () Let us know if this helps. > Here is the compilation script: > > ghc -fglasgow-exts serial.c? %1.hs -L./ -ljapi --make > erase *.hi > erase *.o > strip %1.exe I encourage you to look into Cabal soon :) -- Jason Dusek From jeanchristophe.mincke at gmail.com Tue Nov 10 15:18:34 2009 From: jeanchristophe.mincke at gmail.com (jean-christophe mincke) Date: Tue Nov 10 14:54:44 2009 Subject: [Haskell-cafe] (state) monad and CPS Message-ID: Hello, I would like to get some advice about state monad (or any other monad I guess) and CPS. Let's take a simple exemple (see the code below) 'walk' is a function written in CPS that compute the number of nodes & leaves in a tree. It use a counter which is explicitly passed through calls. 'walk2' is does the same using the state monad but is not written in CPS Is it possible to write a function 'walk3' written in CPS and using the state monad? Thank you Regards J-C module M where import Control.Monad.State data Node = Node (Node, Int, Node) |Leaf Int |Empty deriving (Show) walk Empty acc k = k acc walk (Leaf _) acc k = k (acc+1) walk (Node (l, _, r)) acc k = let k1 acc = walk r acc k in walk l (acc+1) k1 nb = Node (Leaf 1, 2, Leaf 3) nd = Node (nb, 4, Empty) nh = Node (Empty, 8, Leaf 9) ng = Node (Leaf 6, 7, nh) ne = Node (nd, 5, ng) r = walk ne 0 id walk2 Empty = return () walk2 (Leaf _ ) = do acc <- get put (acc+1) return () walk2 (Node (l, _, r)) = do acc <- get put (acc+1) walk2 l walk2 r return () r2 = runState (walk2 ne) 0 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091110/48cecc83/attachment.html From jake.mcarthur at gmail.com Tue Nov 10 15:19:58 2009 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Tue Nov 10 14:56:44 2009 Subject: [Haskell-cafe] Calling all Haskellers in Huntsville, Alabama, or surrounding areas! Message-ID: <4AF9CAEE.2060000@gmail.com> Shae Errisson, myself, Greg Bacon, and some other locals who I think might not have as big a presence online are starting a user's group in Huntsville, AL. Please join the Google group / mailing list [1] if you are interested! [1] http://groups.google.com/group/alabamahaskell - Jake McArthur From jason.dusek at gmail.com Tue Nov 10 15:21:04 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Tue Nov 10 14:56:54 2009 Subject: [Haskell-cafe] Parsec - separating Parsing from Lexing In-Reply-To: <174c72ef0911101123o576827bfp394d364d00777975@mail.gmail.com> References: <174c72ef0911101123o576827bfp394d364d00777975@mail.gmail.com> Message-ID: <42784f260911101221i4e109d23hf9fc4c8fcce4137a@mail.gmail.com> You have to bootstrap your parser with something that takes an `MJVal` and updates the parser state. Here is a simple example: http://github.com/jsnx/system-uuid/blob/master/Options.hs This is a parser for command line options. It parses a list of `String`s, not `Char`s (because `argv` is `char**` and not `char*`, right?) so we introduce `stringPrim` and then build up the primitives from that. -- Jason Dusek From gcross at phys.washington.edu Tue Nov 10 15:49:20 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Tue Nov 10 15:25:11 2009 Subject: [Haskell-cafe] (state) monad and CPS In-Reply-To: References: Message-ID: Yes; check out the module "Control.Monad.Cont", which has a monad for continuation passing style. In particular, note that most of the monads in Control.Monad.* are "stackable" in that there is a version of the monad which you can stack on top of an existing monad. So for example, you could use ContT to stack the CPS monad on top of the State monad, or StateT to stack the State monad on top of the CPS monad. Hope this helps, Greg On Nov 10, 2009, at 12:18 PM, jean-christophe mincke wrote: > Hello, > > I would like to get some advice about state monad (or any other > monad I guess) and CPS. > > Let's take a simple exemple (see the code below) > > 'walk' is a function written in CPS that compute the number of nodes > & leaves in a tree. It use a counter which is explicitly passed > through calls. > 'walk2' is does the same using the state monad but is not written in > CPS > > Is it possible to write a function 'walk3' written in CPS and using > the state monad? > > Thank you > > Regards > > J-C > > > module M where > > import Control.Monad.State > > data Node = > Node (Node, Int, Node) > |Leaf Int > |Empty > deriving (Show) > > walk Empty acc k = k acc > walk (Leaf _) acc k = k (acc+1) > walk (Node (l, _, r)) acc k = let k1 acc = walk r acc k > in > walk l (acc+1) k1 > > > nb = Node (Leaf 1, 2, Leaf 3) > nd = Node (nb, 4, Empty) > > nh = Node (Empty, 8, Leaf 9) > ng = Node (Leaf 6, 7, nh) > > ne = Node (nd, 5, ng) > > r = walk ne 0 id > > walk2 Empty = return () > walk2 (Leaf _ ) = do acc <- get > put (acc+1) > return () > walk2 (Node (l, _, r)) = do acc <- get > put (acc+1) > walk2 l > walk2 r > return () > > > r2 = runState (walk2 ne) 0 > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091110/c53e0ab4/attachment.html From icfp.publicity at googlemail.com Tue Nov 10 16:23:18 2009 From: icfp.publicity at googlemail.com (Wouter Swierstra) Date: Tue Nov 10 15:59:06 2009 Subject: [Haskell-cafe] ICFP 2010: Call for papers Message-ID: <53ff55480911101323v2ba8171ch63388baa705b8d1b@mail.gmail.com> ===================================================================== Call for Papers ICFP 2010: International Conference on Functional Programming Baltimore, Maryland, 27 -- 29 September 2010 http://www.icfpconference.org/icfp2010 ===================================================================== Important Dates (at 14:00 UTC) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Submission: 2 April 2010 Author response: 24 -- 25 May 2010 Notification: 7 June 2010 Final papers due: 12 July 2010 Scope ~~~~~ ICFP 2010 seeks original papers on the art and science of functional programming. Submissions are invited on all topics from principles to practice, from foundations to features, from abstraction to application. The scope includes all languages that encourage functional programming, including both purely applicative and imperative languages, as well as languages with objects or concurrency. Particular topics of interest include * Language Design: type systems; concurrency and distribution; modules; components and composition; metaprogramming; relations to object-oriented or logic programming; interoperability * Implementation: abstract machines; compilation; compile-time and run-time optimization; memory management; multi-threading; exploiting parallel hardware; interfaces to foreign functions, services, components or low-level machine resources * Software-Development Techniques: algorithms and data structures; design patterns; specification; verification; validation; proof assistants; debugging; testing; tracing; profiling * Foundations: formal semantics; lambda calculus; rewriting; type theory; monads; continuations; control; state; effects * Transformation and Analysis: abstract interpretation; partial evaluation; program transformation; program calculation; program proof * Applications and Domain-Specific Languages: symbolic computing; formal-methods tools; artificial intelligence; systems programming; distributed-systems and web programming; hardware design; databases; XML processing; scientific and numerical computing; graphical user interfaces; multimedia programming; scripting; system administration; security; education * Functional Pearls: elegant, instructive, and fun essays on functional programming The conference also solicits Experience Reports, which are short papers that provide evidence that functional programming really works or describe obstacles that have kept it from working in a particular application. Abbreviated instructions for authors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ By 2 April 2010, 14:00 UTC, submit an abstract of at most 300 words and a full paper of at most 12 pages (6 pages for an Experience Report), including bibliography and figures. The deadline will be strictly enforced and papers exceeding the page limits will be summarily rejected. Authors have the option to attach supplementary material to a submission, on the understanding that reviewers may choose not to look at it. A submission will be evaluated according to its relevance, correctness, significance, originality, and clarity. It should explain its contributions in both general and technical terms, clearly identifying what has been accomplished, explaining why it is significant, and comparing it with previous work. The technical content should be accessible to a broad audience. Functional Pearls and Experience Reports are separate categories of papers that need not report original research results and must be marked as such at the time of submission. Detailed guidelines on both categories are on the conference web site. Each submission must adhere to SIGPLAN's republication policy, as explained on the web at http://www.acm.org/sigplan/republicationpolicy.htm. Proceedings will be published by ACM Press. Authors of accepted submissions are expected to transfer the copyright to the ACM. Presentations will be videotaped and released online if the presenter consents by signing an additional permission form at the time of the presentation. Formatting: Submissions must be in PDF format printable in black and white on US Letter sized paper and interpretable by Ghostscript. If this requirement is a hardship, make contact with the program chair at least one week before the deadline. Papers must adhere to the standard ACM conference format: two columns, nine-point font on a ten-point baseline, with columns 20pc (3.33in) wide and 54pc (9in) tall, with a column gutter of 2pc (0.33in). A suitable document template for LATEX is available from SIGPLAN at http://www.acm.org/sigs/sigplan/authorInformation.htm. Submission: Submissions will be accepted electronically at a URL to be named later. Improved versions of a paper may be submitted at any point before the submission deadline using the same web interface. Author response: Authors will have a 48-hour period, starting at 14:00 UTC on 24 May 2010, to read and respond to reviews. Special Journal Issue: There will be a special issue of the Journal of Functional Programming with papers from ICFP 2010. The program committee will invite the authors of select accepted papers to submit a journal version to this issue. Organization ~~~~~~~~~~~~ Conference Chair Paul Hudak, Yale University Program Chair Stephanie Weirich, University of Pennsylvania Program Committee: Umut Acar, Max Planck Institute for Software Systems Zena Ariola, University of Oregon James Cheney, University of Edinburgh Peter Dybjer, Chalmers University of Technology Robert Bruce Findler, Northwestern University Andy Gill, Kansas University Fritz Henglein, University of Copenhagen Michael Hicks, University of Maryland, College Park Patricia Johann, University of Strathclyde Andres L?h, Utrecht University Simon L. Peyton Jones, Microsoft Research Didier R?my, INRIA Paris-Rocquencourt John Reppy, University of Chicago Manuel Serrano, INRIA Sophia-Antipolis Matthieu Sozeau, Harvard University From ketil at malde.org Tue Nov 10 16:29:26 2009 From: ketil at malde.org (Ketil Malde) Date: Tue Nov 10 16:05:06 2009 Subject: [Haskell-cafe] Static Linking Problem In-Reply-To: (mightybyte@gmail.com's message of "Tue, 10 Nov 2009 14:09:46 -0500") References: Message-ID: <87tyx2m5l5.fsf@malde.org> MightyByte writes: > After a bit of googling, I came to the conclusion that I needed to > compile it with "ghc --make -static -optl-static Foo.hs". Using only > "-static" or "-optl-static" by themselves did not generate a > statically linked binary. But when I compile with both those > parameters I get a bunch of linker errors: [..] > (.text+0x59c): undefined reference to `pthread_mutex_lock' For some reason, GHC doesn't link with the pthreads library, so you need to compile (link) with two options: -opt-static -optl-pthread -k -- If I haven't seen further, it is by standing in the footprints of giants From ezra.lalonde at gmail.com Tue Nov 10 17:10:47 2009 From: ezra.lalonde at gmail.com (Ezra Lalonde) Date: Tue Nov 10 16:46:35 2009 Subject: [Haskell-cafe] Help to solve simple problem ! In-Reply-To: <26249028.post@talk.nabble.com> References: <26249028.post@talk.nabble.com> Message-ID: <26292205.post@talk.nabble.com> The following program should work: =======compress.hs============= toList :: (Eq a) => [a] -> [[a]] toList [] = [] toList x = start : toList end where (start, end) = span (==(head x)) x toTuple :: [a] -> (a, Int) toTuple x = (head x, length x) compress :: Eq a => [a] -> [(a, Int)] compress x = map toTuple $ toList x ============================= The important thing to understand here, is the "span" function from the Prelude, and apply it recursively. *Main> span (=='A') "AAABCC" ("AAA","BCC") *Main> span (=='h') "hhhaskell" ("hhh","askell") I've used a function "toList" to separate each part of the string into a separate element of a list: *Main> toList "AAABCC" ["AAA","B","CC"] *Main> toList "EEEZZZRRAAAA!!" ["EEE","ZZZ","RR","AAAA","!!"] >From there, "toTuple" takes the first letter of the string, and puts it with its length in a tuple: *Main> toTuple "EEE" ('E',3) *Main> toTuple "EEEEE" ('E',5) Because of how it's defined, we also get the following: *Main> toTuple "Ezra" ('E',4) But that won't matter if we only use it after "toList", as in "compress". Also, I've used your type signature for my solution, not your example output; if you want it to be displayed like that, you'll have to write your own function for printing. This solution is probably not optimal, but it's a start. Hope that helps, Ezra Aneto wrote: > > Hi ! I am beginner in Haskell and have problems with this problem: > compress :: Eq a => [a] -> [(a, Int)] > If you have string "AAABCCC" it transforms it to : {A, 3} {B,1} {C,3} > > Could you help me with it ? > Thank you in advance ! > -- View this message in context: http://old.nabble.com/Help-to-solve-simple-problem-%21-tp26249028p26292205.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ramsdell0 at gmail.com Tue Nov 10 18:06:31 2009 From: ramsdell0 at gmail.com (John D. Ramsdell) Date: Tue Nov 10 17:42:24 2009 Subject: [Haskell-cafe] Cabal HackORama -- how to handle par and pseq on stable platforms Message-ID: <7687290b0911101506i2dcb8438idd20eaef5dc01961@mail.gmail.com> I am writing a Cabal file for an application that uses par and pseq. I want to support both modern distributions of GHC and the version that comes with Ubuntu Hardy Heron, a Long Term Support version of Ubuntu that will be retired in April 2011. It provides GHC 6.8.2 with Cabal 1.2.3.0 and no parallel package. You might be interested in my solution to supporting both releases. I did the obvious in my Cabal file. A defined a flag as follows: -- Disable with -f-par option during configuration. Flag Par Description: Enable use of the parallel construct par Default: True The description of the executable includes: if flag(par) Cpp-Options: -DHAVE_PAR GHC-Options: -threaded Build-Depends: parallel The C preprocessor is used to toggle between a parallel version of map and the usual one. #if defined HAVE_PAR parMap :: (a -> b) -> [a] -> [b] parMap _ [] = [] parMap f (x:xs) = par y (pseq ys (y:ys)) where y = f x ys = parMap f xs #else parMap :: (a -> b) -> [a] -> [b] parMap = map #endif Here is what makes this cabal file sweet. Cabal 1,2,3.0 supports flags, but ignores the Default specification. It assumes the default value of every flag is False. Thus, for both modern versions of GHC and the one on Hardy Heron, no user supplied flags are required during configuration. John From Eduard.Sergeev at gmail.com Tue Nov 10 20:07:11 2009 From: Eduard.Sergeev at gmail.com (Eduard Sergeev) Date: Tue Nov 10 19:42:59 2009 Subject: [Haskell-cafe] Help to solve simple problem ! In-Reply-To: <26249028.post@talk.nabble.com> References: <26249028.post@talk.nabble.com> Message-ID: <26294356.post@talk.nabble.com> Aneto wrote: > > compress :: Eq a => [a] -> [(a, Int)] > If you have string "AAABCCC" it transforms it to : {A, 3} {B,1} {C,3} > Basically you need to "group" equal elements of the list first and then transform every group (which is a list of equal elements) to the tuple of (first_element , the_ length_of_the_group). All necessary functions can be found in Prelude and Data.List: import Data.List compress :: Eq a => [a] -> [(a, Int)] compress xs = map (\g -> (head g, length g)) (group xs) PS You can express it somehow nicer with arrows thought: import Data.List import Control.Arrow compress :: Eq a => [a] -> [(a, Int)] compress = map (head &&& length) <<< group -- View this message in context: http://old.nabble.com/Help-to-solve-simple-problem-%21-tp26249028p26294356.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From gpnair78 at yahoo.com Tue Nov 10 20:20:44 2009 From: gpnair78 at yahoo.com (Gokul P. Nair) Date: Tue Nov 10 19:56:35 2009 Subject: [Haskell-cafe] help with Haskell performance In-Reply-To: <20091107215057.GA2474@whirlpool.galois.com> Message-ID: <433330.53895.qm@web51902.mail.re2.yahoo.com> --- On Sat, 11/7/09, Don Stewart wrote: > General notes: > >? * unpack is almost always wrong. >? * list indexing with !! is almost always wrong. >? * words/lines are often wrong for parsing large files (they build large list structures). >? * toList/fromList probably aren't the best strategy >? * sortBy (comparing snd) >? * use insertWith' > Spefically, avoid constructing intermediate lists, when you can process the > entire file in a single pass. Use O(1) bytestring substring operations like > take and drop. ? Thanks all for the valuable feedback. Switching from Regex.Posix to Regex.PCRE alone reduced the running time to about 6 secs and a few other optimizations suggested on this thread brought it down to about 5 secs ;) ? I then set out to profile the code out of curiosity to see where the bulk of the time was being spent and sure enough the culprit turned out to be "unpack". My question?therefore is, given?a?list L1?of type [(ByteString, Int)], how do I print it out so as to eliminate the "chunk, empty" markers associated with a bytestring? The suggestions posted here are along the lines of "mapM_ print L1" but that's far from desirable especially because the generated output is for perusal by non-technical users etc. ? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091110/b6c69ee6/attachment.html From dgorin at dc.uba.ar Tue Nov 10 20:42:21 2009 From: dgorin at dc.uba.ar (=?ISO-8859-1?Q?Daniel_Gor=EDn?=) Date: Tue Nov 10 20:18:21 2009 Subject: [Haskell-cafe] Problems with Language.Haskell.Interpreter and errors In-Reply-To: <1254291628.6704.2.camel@ios.cogsys.wiai.uni-bamberg.de> References: <1254225392.6118.80.camel@ios.cogsys.wiai.uni-bamberg.de> <799D986A-33A8-4C4F-B1AB-01C650EA1094@dc.uba.ar> <1254291628.6704.2.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <0919C693-2BE6-438C-9090-B6A92F7D9DEE@dc.uba.ar> On Sep 30, 2009, at 2:20 AM, Martin Hofmann wrote: > Thanks a lot. > >> You ought to be able to add a Control.Monad.CatchIO.catch clause to >> your interpreter to catch this kind of errors, if you want. > > I forgot to mention that this didn't work for me either. > >> Thanks for the report! > > You are welcome. If you come up with a work around or a fix, I would > appreciate if you let me know. > > Cheers, > > Martin Apologies for a very very very late follow-up on this thread (http://thread.gmane.org/gmane.comp.lang.haskell.cafe/64013 ). It turns out that Control.Monad.CatchIO.catch was the right thing to use; you were probably bitten, just like me, by the fact that "eval" builds a thunk and returns it, but does not execute it. The following works fine for me: import Prelude hiding ( catch ) import Language.Haskell.Interpreter import Control.Monad.CatchIO ( catch ) import Control.Exception.Extensible hiding ( catch ) main :: IO () main = print =<< (runInterpreter (code `catch` handler)) where s = "let lst [a] = a in lst []" code = do setImports ["Prelude"] forceM $ eval s handler (PatternMatchFail _) = return "catched!" forceM :: Monad m => m a -> m a forceM a = a >>= (\x -> return $! x) When run, it prints 'Right "catched!"'. Notice that if you change the line 'forceM $ eval s' by an 'eval s', then the offending thunk is reduced by the print statement and the exception is thrown outside the catch. Hope this helps Daniel From brad.larsen at gmail.com Tue Nov 10 22:24:59 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Tue Nov 10 22:00:48 2009 Subject: [Haskell-cafe] help with Haskell performance In-Reply-To: <433330.53895.qm@web51902.mail.re2.yahoo.com> References: <20091107215057.GA2474@whirlpool.galois.com> <433330.53895.qm@web51902.mail.re2.yahoo.com> Message-ID: On Tue, Nov 10, 2009 at 8:20 PM, Gokul P. Nair wrote: > --- On Sat, 11/7/09, Don Stewart wrote: > > General notes: > > > > * unpack is almost always wrong. > > * list indexing with !! is almost always wrong. > > * words/lines are often wrong for parsing large files (they build large > list structures). > > * toList/fromList probably aren't the best strategy > > * sortBy (comparing snd) > > * use insertWith' > > Spefically, avoid constructing intermediate lists, when you can process > the > > entire file in a single pass. Use O(1) bytestring substring operations > like > > take and drop. > > Thanks all for the valuable feedback. Switching from Regex.Posix to > Regex.PCRE alone reduced the running time to about 6 secs and a few other > optimizations suggested on this thread brought it down to about 5 secs ;) > > I then set out to profile the code out of curiosity to see where the bulk > of the time was being spent and sure enough the culprit turned out to be > "unpack". My question therefore is, given a list L1 of type [(ByteString, > Int)], how do I print it out so as to eliminate the "chunk, empty" markers > associated with a bytestring? The suggestions posted here are along the > lines of "mapM_ print L1" but that's far from desirable especially because > the generated output is for perusal by non-technical users etc. > > Thanks. > > Take a look at Data.ByteString.Lazy.Char8.putStrLn. That prints a lazy ByteString without unpacking it, and without the internal markers. Sincerely, Brad -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091110/d96400bf/attachment.html From phi500ac at yahoo.ca Tue Nov 10 22:41:54 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Tue Nov 10 22:17:45 2009 Subject: [Haskell-cafe] Opinion about JHC Message-ID: <567296.97882.qm@web58802.mail.re1.yahoo.com> I discovered a Haskell compiler that generates very small and fast code. In fact, it beats Clean. It has the following properties: 1 --- One can cross-compile programs easily. For instance, here is how I generated code for Windows: jhc --cross -mwin32 genetic.hs -o genetic 2 -- It seems to be quite complete. 3 -- However, it often compiles a file, but the program fails to run. I have the following questions about it: 1 -- How active is the team who is writing the JHC compiler? 2 -- Is it complete Haskell? The author claims that it is; it compiled all programs that I wrote, but that does not mean much, because my programs are quite simple. 3 -- Why the Haskell community almost never talks about JHC? __________________________________________________________________ The new Internet Explorer? 8 - Faster, safer, easier. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091110/eaa6e470/attachment.html From thomas.dubuisson at gmail.com Tue Nov 10 23:35:42 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Tue Nov 10 23:11:30 2009 Subject: [Haskell-cafe] Opinion about JHC In-Reply-To: <567296.97882.qm@web58802.mail.re1.yahoo.com> References: <567296.97882.qm@web58802.mail.re1.yahoo.com> Message-ID: <4c44d90b0911102035l7d8cb2bdk2e2fa5ea557e934e@mail.gmail.com> > 1 -- How active is the team who is writing the JHC compiler? The "Team" is John and Its not his day job afaik. Lemmih used to work on it before he forked it into "LHC" which has since evolved into a new (GRIN based) backend for GHC [1]. > 2 -- Is it complete Haskell? The author claims that it is; it compiled all programs that I wrote, but that does not mean much, because my programs are quite simple. "Complete Haskell" has different meaning to different people. Perhaps it is H98 with FFI and concurrency? Hopefully it supports some more of the extentions. > 3 -- Why the Haskell community almost never talks about JHC? A) I suppose the lack of information wrt what extentions are supported is one reason I avoid it. My previous experience with JHC was also negative what with it not including/compiling necessary packages such as bytestring. B) I just installed it and ran it against a recent project: "evcaCLI.hs:1 - Warning: The pragma 'LANGUAGE' is unknown". It then failed to parse something futher on (unknown, poor error message... perhaps a bang pattern). C) Poor cabal integration, it would seem. I know I saw a recent jhc-7.2 patch for cabal but for now I use cabal 1.6.0.3 and the --jhc option doesn't seem to work. So these are mostly community issues with perhaps too much focus on a single compiler ecosystem, but they are real issues none-the-less. None of this is ment as a knock on JHC, which is cool but not yet of use to me personally. Thomas [1] http://lhc.seize.it/ From ryani.spam at gmail.com Wed Nov 11 01:09:47 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Nov 11 00:45:36 2009 Subject: [Haskell-cafe] (state) monad and CPS In-Reply-To: References: Message-ID: <2f9b2d30911102209i306bc13cs77513096379bf7e2@mail.gmail.com> Something like this should work: newtype ContState r s a = ContState { runCS :: s -> (a -> s -> r) -> r } instance Monad (ContState r s) where return a = ContState $ \s k -> k a s m >>= f = ContState $ \s0 k -> runCS m s $ \a s1 -> runCS (f a) s1 k instance MonadState s (ContState r s) where get = ContState $ \s k -> k s s put s = ContState $ \_ k -> k () s instance MonadCont (ContState r s) where callCC f = ContState $ \s0 ka -> runCS (f $ \a -> ContState $ \s1 kb -> ka a s1) s0 ka There's a design choice as to whether the inner continuation should be called with s0 or s1; it depends if you want the continuation from callCC to abort any state changes or preserve them up to that point. -- ryan On Tue, Nov 10, 2009 at 12:18 PM, jean-christophe mincke wrote: > Hello, > > I would like to get some advice about state monad (or any other monad I > guess) and CPS. > > Let's take a simple exemple (see the code below) > > 'walk' is a function written in CPS that compute the number of nodes & > leaves in a tree. It use a counter which is explicitly passed through calls. > 'walk2' is does the same using the state monad but is not written in CPS > > Is it possible to write a function 'walk3' written in CPS and using the > state monad? > > Thank you > > Regards > > J-C > > > module M where > > import Control.Monad.State > > data Node = > ??? ?Node (Node, Int, Node) > ??? |Leaf Int > ??? |Empty > ??? deriving (Show) > > walk Empty acc k = k acc > walk (Leaf _) acc k = k (acc+1) > walk (Node (l, _, r)) acc k = let k1 acc = walk r acc k > ????????????????????????????? in > ????????????????????????????? walk l (acc+1) k1 > > > nb = Node (Leaf 1, 2, Leaf 3) > nd = Node (nb, 4, Empty) > > nh = Node (Empty, 8, Leaf 9) > ng = Node (Leaf 6, 7, nh) > > ne = Node (nd, 5, ng) > > r = walk ne 0 id > > walk2 Empty = return () > walk2 (Leaf _ ) = do acc <- get > ???????????????????? put (acc+1) > ???????????????????? return () > walk2 (Node (l, _, r)) = do acc <- get > ??????????????????????????? put (acc+1) > ??????????????????????????? walk2 l > ??????????????????????????? walk2 r > ??????????????????????????? return () > > > r2 = runState (walk2 ne) 0 > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From martin.hofmann at uni-bamberg.de Wed Nov 11 02:21:38 2009 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Wed Nov 11 01:56:46 2009 Subject: [Haskell-cafe] Problems with Language.Haskell.Interpreter and errors In-Reply-To: <0919C693-2BE6-438C-9090-B6A92F7D9DEE@dc.uba.ar> References: <1254225392.6118.80.camel@ios.cogsys.wiai.uni-bamberg.de> <799D986A-33A8-4C4F-B1AB-01C650EA1094@dc.uba.ar> <1254291628.6704.2.camel@ios.cogsys.wiai.uni-bamberg.de> <0919C693-2BE6-438C-9090-B6A92F7D9DEE@dc.uba.ar> Message-ID: <1257924098.3900.4.camel@ios.cogsys.wiai.uni-bamberg.de> Although late, still very much appreciated. Thanks a lot! Cheers, Martin From tonymorris at gmail.com Wed Nov 11 02:23:53 2009 From: tonymorris at gmail.com (Tony Morris) Date: Wed Nov 11 01:59:28 2009 Subject: [Haskell-cafe] Working with multiple projects Message-ID: <4AFA6689.8060501@gmail.com> I have two projects that I intend to put on hackage soon. One depends on the other. I have "cabaled" both. I am wondering how others work with this kind of set up where changes are made to both libraries as they work. -- Tony Morris http://tmorris.net/ From john at repetae.net Wed Nov 11 03:37:59 2009 From: john at repetae.net (John Meacham) Date: Wed Nov 11 03:13:47 2009 Subject: [Haskell-cafe] Opinion about JHC In-Reply-To: <567296.97882.qm@web58802.mail.re1.yahoo.com> References: <567296.97882.qm@web58802.mail.re1.yahoo.com> Message-ID: <20091111083759.GH21564@sliver.repetae.net> On Tue, Nov 10, 2009 at 07:41:54PM -0800, Philippos Apolinarius wrote: > I discovered a Haskell compiler that generates very small and fast > code. In fact, it beats Clean. It has the following properties: Excellent. that was my goal ;) > 1 --- One can cross-compile programs easily. For instance, here is how I generated code for Windows: > > jhc --cross -mwin32 genetic.hs -o genetic Yup. This was a major goal. compiling for iPhones and embedded arches is just as easy assuming you have a gcc toolchain set up. (at least with the hacked iPhone SDK.. I have never tried it with the official one) > > 2 -- It seems to be quite complete. > > 3 -- However, it often compiles a file, but the program fails to run. > > I have the following questions about it: > > 1 -- How active is the team who is writing the JHC compiler? Hi, I am the main contributor, but others are welcome and several have made signifigant contributions. Development tends to be spurty. A lot of work will get done in a short amount of time, this generally corresponds to when an external contributor gets involved and the back and forth helps stimulate patches on my part to complement theirs. Although I have not been able to devote a lot of my time to jhc in the past, hopefully this will change in the not to distant future and I will be able to work on it full time. > 2 -- Is it complete Haskell? The author claims that it is; it compiled > all programs that I wrote, but that does not mean much, because my > programs are quite simple. It does Haskell 98 and several extensions, which is pretty much what GHC does. However, it does not implement the same set of extensions as GHC so this causes issues as a lot of people use GHC extensions extensively. I plan on supporting all of Haskell' of course, and the popular GHC extensions to help compatibility. Not all are implemented. > 3 -- Why the Haskell community almost never talks about JHC? Part of it is that I am not very good at advocacy. I don't always post announcements on the main haskell lists figuring the interested parties are on the jhc list already. I do try to make jhc good, fast, and usable, I always hoped someone better at advocacy than me would join the project :) In truth, I think the spurty nature of development also affects this, the list will be quite for a long time with a flurry of development lasting a few weeks occasionally inspiring some discussion in the other groups. In any case, I am glad you liked what you found! please join the mailing list for jhc if you are interested in its development or using it. John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From martin.hofmann at uni-bamberg.de Wed Nov 11 03:39:17 2009 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Wed Nov 11 03:14:25 2009 Subject: [Haskell-cafe] Problems with Language.Haskell.Interpreter and errors In-Reply-To: <0919C693-2BE6-438C-9090-B6A92F7D9DEE@dc.uba.ar> References: <1254225392.6118.80.camel@ios.cogsys.wiai.uni-bamberg.de> <799D986A-33A8-4C4F-B1AB-01C650EA1094@dc.uba.ar> <1254291628.6704.2.camel@ios.cogsys.wiai.uni-bamberg.de> <0919C693-2BE6-438C-9090-B6A92F7D9DEE@dc.uba.ar> Message-ID: <1257928757.3900.8.camel@ios.cogsys.wiai.uni-bamberg.de> I still have problems and your code won't typecheck on my machine printing the following error: Test.hs:9:34: No instance for (Control.Monad.CatchIO.MonadCatchIO (InterpreterT IO)) arising from a use of `catch' at Test.hs:9:34-53 Possible fix: add an instance declaration for (Control.Monad.CatchIO.MonadCatchIO (InterpreterT IO)) In the first argument of `runInterpreter', namely `(code `catch` handler)' In the second argument of `(=<<)', namely `(runInterpreter (code `catch` handler))' In the expression: print =<< (runInterpreter (code `catch` handler)) I assume we are using different versions of some packages. Could you please send me the output of your 'ghc-pkg list'. Thanks, Martin From martijn at van.steenbergen.nl Wed Nov 11 03:47:08 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed Nov 11 03:23:06 2009 Subject: [Haskell-cafe] Working with multiple projects In-Reply-To: <4AFA6689.8060501@gmail.com> References: <4AFA6689.8060501@gmail.com> Message-ID: <4AFA7A0C.6060307@van.steenbergen.nl> Tony Morris wrote: > I have two projects that I intend to put on hackage soon. One depends > on the other. I have "cabaled" both. I am wondering how others work > with this kind of set up where changes are made to both libraries as > they work. You just update and re-upload the packages as necessary. It really helps here if you follow the versioning guidelines: http://www.haskell.org/haskellwiki/Package_versioning_policy HTH, Martijn. From d.kahlenberg at googlemail.com Wed Nov 11 05:17:42 2009 From: d.kahlenberg at googlemail.com (Daniel Kahlenberg) Date: Wed Nov 11 04:53:39 2009 Subject: [Haskell-cafe] caba install with external gcc toolchain not the ghc-bundled one Message-ID: <4AFA8F46.8090900@googlemail.com> Hello friends, I have a question regarding one thing I can't get my head around: First my problem is, that wanted to install 'bindings-common' here on my Windows machine. Usually that is no problem with the help of the glorious cabal. Now, 'bindings-common' needs a higher version of gcc than the one bundled with ghc-6.10.4 to build as the developer told me, so I install the gcc version 4.4.0 by mingw and try to give the needed options to 'cabal install bindings-common...' - '--with-gcc=... --with-ld=...' etc. - At the same time I log everything cabal is putting to the outside world when doing the tasks for building the 'binding-commons': For this sake I use the '--build-log=...' option of 'cabal install' and at the same time pipe what gets shown on the terminal with 'tee' as well as verbosity level 3 for 'cabal install'. So far nothing new... But the package isn't built, so I wonder what the transcript is saying and have a look at the two generated log files, stating that the one generated by 'tee' tells me another linker (the one coming with the ghc-6.10.4 bundle) than I thought to have specified is actually used. An excerpt from the tee built log file: *** Linker: E:\programme\ghc\ghc-6.10.4\gcc -BE:\programme\ghc\ghc-6.10.4\gcc-lib/ ... Configured with: ../gcc-3.4.5-20060117-3/configure --with-gcc ... Thread model: win32 gcc version 3.4.5 (mingw-vista special r3) (Sorry if I'm mis-interpreting something here) While the log file resulting from the '--build-log' cabal install option has nothing suspicious in it telling me to (plan to?) use exactly what I specified by options. A little excerpt from that log file: ("e:\\programme\\ghc\\ghc-6.10.4\\bin\\hsc2hs.exe",["--cc=e:/programme/ghc/mingw-gcc4/bin/gcc.exe","--ld=e:/programme/ghc/mingw-gcc4/bin/gcc.exe","--cflag=-Be:/programme/ghc/mingw-gcc4/lib/","--cflag=-Ie:/programme/ghc/mingw4-gcc/include","--cflag=-Le:/programme/ghc/mingw-gcc4/lib","--lflag=-Be:/programme/ghc/mingw-gcc4/lib/","--lflag=-Ie:/programme/ghc/mingw4-gcc/include","--lflag=-Le:/programme/ghc/mingw-gcc4/lib","--cflag=-D__GLASGOW_HASKELL__=610","--cflag=-Isrc","--cflag=-Ie:/programme/ghc/mingw-gcc4/include","--cflag=-D_ISOC99_SOURCE","--lflag=-Le:/programme/ghc/mingw-gcc4/lib","--cflag=-Ie:\\programme\\ghc\\ghc-6.10.4\\base-4.1.0.0\\include","--cflag=-Ie:\\programme\\ghc\\ghc-6.10.4/include","--lflag=-Le:\\programme\\ghc\\ghc-6.10.4\\base-3.0.3.1","--lflag=-Le:\\programme\\ghc\\ghc-6.10.4\\syb-0.1.0.1","--lflag=-Le:\\programme\\ghc\\ghc-6.10.4\\base-4.1.0.0","--lflag=-lwsock32","--lflag=-luser32","--lflag=-lshell32","--lflag=-Le:\\programme\\ghc\\ghc-6.10.4\\integer-0 .1.0.1","--lflag=-Le:\\programme\\ghc\\ghc-6.10.4\\ghc-prim-0.1.0.0","--lflag=-Le:\\programme\\ghc\\ghc-6.10.4","--lflag=-Le:\\programme\\ghc\\ghc-6.10.4/gcc-lib","--lflag=-lm","--lflag=-lffi","--lflag=-lgmp","--lflag=-lwsock32","-o","H:\\.homedir\\hugsdata\\build\\Bindings\\C\\Ctype.hs","src\\Bindings\\C\\Ctype.hsc"]) ... Using ld given by user at: e:/programme/ghc/mingw-gcc4/bin/ld.exe So now my question is: Can anybody give me a good hint or tell me how I would, aside from using hard links or other file system related tasks, specify the external compiler, linker or gcc-toolchain to be used by 'cabal install' (or in consequence by 'ghc')? Cheers and thanks for your Daniel -------------- next part -------------- searching for ghc in path. found ghc at e:\programme\ghc\ghc-6.10.4\bin\ghc.exe ("e:\\programme\\ghc\\ghc-6.10.4\\bin\\ghc.exe",["--numeric-version"]) e:\programme\ghc\ghc-6.10.4\bin\ghc.exe is version 6.10.4 looking for package tool: ghc-pkg near compiler in e:\programme\ghc\ghc-6.10.4\bin found package tool in e:\programme\ghc\ghc-6.10.4\bin\ghc-pkg.exe ("e:\\programme\\ghc\\ghc-6.10.4\\bin\\ghc-pkg.exe",["--version"]) e:\programme\ghc\ghc-6.10.4\bin\ghc-pkg.exe is version 6.10.4 ("e:\\programme\\ghc\\ghc-6.10.4\\bin\\ghc.exe",["--supported-languages"]) Reading installed packages... ("e:\\programme\\ghc\\ghc-6.10.4\\bin\\ghc-pkg.exe",["dump","--global"]) ("e:\\programme\\ghc\\ghc-6.10.4\\bin\\ghc-pkg.exe",["dump","--package-conf=h:\\.homedir\\ghc\\i386-mingw32-6.10.4\\package.conf"]) Reading available packages... Resolving dependencies... selecting bindings-common-1.3.3 (hackage) and discarding bindings-common-0.1, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.2, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.2.5, 0.2.6, 1.0, 1.1, 1.2, 1.3, 1.3.1 and 1.3.2 selecting base-3.0.3.1 (installed) and 4.1.0.0 (installed) and discarding syb-0.1.0.0 and 0.1.0.1 selecting ghc-prim-0.1.0.0 (installed) selecting integer-0.1.0.1 (installed) selecting rts-1.0 (installed) selecting syb-0.1.0.1 (installed) In order, the following would be installed: bindings-common-1.3.3 (new package) bindings-common-1.3.3 has already been downloaded. Extracting C:\Dokumente und Einstellungen\Zyx\Anwendungsdaten\cabal\packages\hackage.haskell.org\bindings-common\1.3.3\bindings-common-1.3.3.tar.gz to c:\DOKUME~1\Zyx\LOKALE~1\Temp\bindings-common-1.3.31176... Using external setup method with build-type Simple Creating h:\.homedir\hugsdata\setup (and its parents) Using Cabal library version 1.6.0.3 Using h:\.homedir\hugsdata\setup\setup.hs as setup script. Setup script is out of date, compiling... ("e:\\programme\\ghc\\ghc-6.10.4\\bin\\ghc.exe",["-v","--make","h:\\.homedir\\hugsdata\\setup\\setup.hs","-o","h:\\.homedir\\hugsdata\\setup\\setup.exe","-odir","h:\\.homedir\\hugsdata\\setup","-hidir","h:\\.homedir\\hugsdata\\setup","-i","-ic:\\DOKUME~1\\Zyx\\LOKALE~1\\Temp\\bindings-common-1.3.31176\\bindings-common-1.3.3","-no-user-package-conf","-package-conf","h:\\.homedir\\ghc\\i386-mingw32-6.10.4\\package.conf","-package","Cabal-1.6.0.3"]) Glasgow Haskell Compiler, Version 6.10.4, for Haskell 98, stage 2 booted by GHC version 6.10.1 Using package config file: E:\programme\ghc\ghc-6.10.4\package.conf Using package config file: h:\.homedir\ghc\i386-mingw32-6.10.4\package.conf Using package config file: h:\.homedir\ghc\i386-mingw32-6.10.4\package.conf hiding package base-3.0.3.1 to avoid conflict with later version base-4.1.0.0 hiding package regex-base-0.72.0.2 to avoid conflict with later version regex-base-0.93.1 hiding package parsec-2.1.0.1 to avoid conflict with later version parsec-3.0.1 hiding package QuickCheck-1.2.0.0 to avoid conflict with later version QuickCheck-2.1.0.2 wired-in package ghc-prim mapped to ghc-prim-0.1.0.0 wired-in package integer mapped to integer-0.1.0.1 wired-in package base mapped to base-4.1.0.0 wired-in package rts mapped to rts-1.0 wired-in package haskell98 mapped to haskell98-1.0.1.0 wired-in package syb mapped to syb-0.1.0.1 wired-in package template-haskell mapped to template-haskell-2.3.0.1 wired-in package dph-seq mapped to dph-seq-0.3 wired-in package dph-par mapped to dph-par-0.3 Hsc static flags: -static *** Chasing dependencies: Chasing modules from: *H:\.homedir\hugsdata\setup\setup.hs Stable obj: [] Stable BCO: [] Ready for upsweep [NONREC ModSummary { ms_hs_date = Mon Nov 9 14:45:34 Westeurop?ische Normalzeit 2009 ms_mod = main:Main, ms_imps = [Distribution.Simple] ms_srcimps = [] }] compile: input file H:\.homedir\hugsdata\setup\setup.hs Created temporary directory: C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0 *** Checking old interface for main:Main: [1 of 1] Compiling Main ( H:\.homedir\hugsdata\setup\setup.hs, H:\.homedir\hugsdata\setup\Main.o ) *** Parser: *** Renamer/typechecker: *** Desugar: Result size = 8 *** Simplify: Result size = 6 Result size = 6 *** Tidy Core: Result size = 6 writeBinIface: 1 Names writeBinIface: 28 dict entries *** CorePrep: Result size = 6 *** Stg2Stg: *** CodeGen: *** CodeOutput: *** Assembler: E:\programme\ghc\ghc-6.10.4\gcc -BE:\programme\ghc\ghc-6.10.4\gcc-lib/ -IE:\programme\ghc\ghc-6.10.4\include/mingw -IH:\.homedir\hugsdata\setup -c C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0/ghc2388_0.s -o h:\.homedir\hugsdata\setup\Main.o *** Deleting temp files: Deleting: C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0/ghc2388_0.s Upsweep completely successful. *** Deleting temp files: Deleting: link: linkables are ... LinkableM (Mon Nov 9 14:45:34 Westeurop?ische Normalzeit 2009) main:Main [DotO h:\.homedir\hugsdata\setup\Main.o] Linking h:\.homedir\hugsdata\setup\setup.exe ... *** Windres: E:\programme\ghc\ghc-6.10.4\bin/windres --preprocessor="E:\programme\ghc\ghc-6.10.4\gcc" "-BE:\programme\ghc\ghc-6.10.4\gcc-lib/" "-IE:\programme\ghc\ghc-6.10.4\include/mingw" "-E" "-xc" "-DRC_INVOKED" --use-temp-file --input=C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0/ghc2388_0.rc --output=C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0/ghc2388_0.o --output-format=coff *** Linker: E:\programme\ghc\ghc-6.10.4\gcc -BE:\programme\ghc\ghc-6.10.4\gcc-lib/ -IE:\programme\ghc\ghc-6.10.4\include/mingw -v -o h:\.homedir\hugsdata\setup\setup.exe -DDONT_WANT_WIN32_DLL_SUPPORT h:\.homedir\hugsdata\setup\Main.o C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0/ghc2388_0.o -Lh:\.homedir\.cabal\Cabal-1.6.0.3\ghc-6.10.4 -LE:\programme\ghc\ghc-6.10.4\process-1.0.1.1 -LE:\programme\ghc\ghc-6.10.4\pretty-1.0.1.0 -LE:\programme\ghc\ghc-6.10.4\directory-1.0.0.3 -LE:\programme\ghc\ghc-6.10.4\old-time-1.0.0.2 -LE:\programme\ghc\ghc-6.10.4\old-locale-1.0.0.1 -LE:\programme\ghc\ghc-6.10.4\filepath-1.1.0.2 -LE:\programme\ghc\ghc-6.10.4\Win32-2.2.0.0 -LE:\programme\ghc\ghc-6.10.4\bytestring-0.9.1.4 -LE:\programme\ghc\ghc-6.10.4\containers-0.2.0.1 -LE:\programme\ghc\ghc-6.10.4\array-0.2.0.0 -LE:\programme\ghc\ghc-6.10.4\syb-0.1.0.1 -LE:\programme\ghc\ghc-6.10.4\base-4.1.0.0 -LE:\programme\ghc\ghc-6.10.4\integer-0.1.0.1 -LE:\programme\ghc\ghc-6.10.4\ghc-prim-0.1.0.0 -LE:\programme\ghc\ghc-6.10.4 -LE:\programme\ghc\ghc-6.10.4/gcc-lib -lHSCabal-1.6.0.3 -lHSprocess-1.0.1.1 -lHSpretty-1.0.1.0 -lHSdirectory-1.0.0.3 -lHSold-time-1.0.0.2 -lHSold-locale-1.0.0.1 -lHSfilepath-1.1.0.2 -lHSWin32-2.2.0.0 -luser32 -lgdi32 -lwinmm -ladvapi32 -lHSbytestring-0.9.1.4 -lHScontainers-0.2.0.1 -lHSarray-0.2.0.0 -lHSsyb-0.1.0.1 -lHSbase-4.1.0.0 -lwsock32 -luser32 -lshell32 -lHSinteger-0.1.0.1 -lHSghc-prim-0.1.0.0 -lHSrts -lm -lffi -lgmp -lwsock32 -u _ghczmprim_GHCziTypes_Izh_static_info -u _ghczmprim_GHCziTypes_Czh_static_info -u _ghczmprim_GHCziTypes_Fzh_static_info -u _ghczmprim_GHCziTypes_Dzh_static_info -u _base_GHCziPtr_Ptr_static_info -u _base_GHCziWord_Wzh_static_info -u _base_GHCziInt_I8zh_static_info -u _base_GHCziInt_I16zh_static_info -u _base_GHCziInt_I32zh_static_info -u _base_GHCziInt_I64zh_static_info -u _base_GHCziWord_W8zh_static_info -u _base_GHCziWord_W16zh_static_info -u _base_GHCziWord_W32zh_static_info -u _base_GHCziWord_W64zh_static_info -u _base_GHCziStable_StablePtr_static_info -u _ghczmprim_GHCziTypes_Izh_con_info -u _ghczmprim_GHCziTypes_Czh_con_info -u _ghczmprim_GHCziTypes_Fzh_con_info -u _ghczmprim_GHCziTypes_Dzh_con_info -u _base_GHCziPtr_Ptr_con_info -u _base_GHCziPtr_FunPtr_con_info -u _base_GHCziStable_StablePtr_con_info -u _ghczmprim_GHCziBool_False_closure -u _ghczmprim_GHCziBool_True_closure -u _base_GHCziPack_unpackCString_closure -u _base_GHCziIOBase_stackOverflow_closure -u _base_GHCziIOBase_heapOverflow_closure -u _base_ControlziExceptionziBase_nonTermination_closure -u _base_GHCziIOBase_blockedOnDeadMVar_closure -u _base_GHCziIOBase_blockedIndefinitely_closure -u _base_ControlziExceptionziBase_nestedAtomically_closure -u _base_GHCziWeak_runFinalizzerBatch_closure -u _base_GHCziTopHandler_runIO_closure -u _base_GHCziTopHandler_runNonIO_closure -u _base_GHCziConc_runHandlers_closure -u _base_GHCziConc_ensureIOManagerIsRunning_closure Reading specs from E:/programme/ghc/ghc-6.10.4/gcc-lib/specs Configured with: ../gcc-3.4.5-20060117-3/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization --enable-libstdcxx-debug Thread model: win32 gcc version 3.4.5 (mingw-vista special r3) E:/programme/ghc/ghc-6.10.4/gcc-lib/collect2.exe -Bdynamic -o h:\.homedir\hugsdata\setup\setup.exe -u _ghczmprim_GHCziTypes_Izh_static_info -u _ghczmprim_GHCziTypes_Czh_static_info -u _ghczmprim_GHCziTypes_Fzh_static_info -u _ghczmprim_GHCziTypes_Dzh_static_info -u _base_GHCziPtr_Ptr_static_info -u _base_GHCziWord_Wzh_static_info -u _base_GHCziInt_I8zh_static_info -u _base_GHCziInt_I16zh_static_info -u _base_GHCziInt_I32zh_static_info -u _base_GHCziInt_I64zh_static_info -u _base_GHCziWord_W8zh_static_info -u _base_GHCziWord_W16zh_static_info -u _base_GHCziWord_W32zh_static_info -u _base_GHCziWord_W64zh_static_info -u _base_GHCziStable_StablePtr_static_info -u _ghczmprim_GHCziTypes_Izh_con_info -u _ghczmprim_GHCziTypes_Czh_con_info -u _ghczmprim_GHCziTypes_Fzh_con_info -u _ghczmprim_GHCziTypes_Dzh_con_info -u _base_GHCziPtr_Ptr_con_info -u _base_GHCziPtr_FunPtr_con_info -u _base_GHCziStable_StablePtr_con_info -u _ghczmprim_GHCziBool_False_closure -u _ghczmprim_GHCziBool_True_closure -u _base_GHCziPack_unpackCString_closure -u _base_GHCziIOBase_stackOverflow_closure -u _base_GHCziIOBase_heapOverflow_closure -u _base_ControlziExceptionziBase_nonTermination_closure -u _base_GHCziIOBase_blockedOnDeadMVar_closure -u _base_GHCziIOBase_blockedIndefinitely_closure -u _base_ControlziExceptionziBase_nestedAtomically_closure -u _base_GHCziWeak_runFinalizzerBatch_closure -u _base_GHCziTopHandler_runIO_closure -u _base_GHCziTopHandler_runNonIO_closure -u _base_GHCziConc_runHandlers_closure -u _base_GHCziConc_ensureIOManagerIsRunning_closure E:/programme/ghc/ghc-6.10.4/gcc-lib/crt2.o E:/programme/ghc/ghc-6.10.4/gcc-lib/crtbegin.o -Lh:\.homedir\.cabal\Cabal-1.6.0.3\ghc-6.10.4 -LE:\programme\ghc\ghc-6.10.4\process-1.0.1.1 -LE:\programme\ghc\ghc-6.10.4\pretty-1.0.1.0 -LE:\programme\ghc\ghc-6.10.4\directory-1.0.0.3 -LE:\programme\ghc\ghc-6.10.4\old-time-1.0.0.2 -LE:\programme\ghc\ghc-6.10.4\old-locale-1.0.0.1 -LE:\programme\ghc\ghc-6.10.4\filepath-1.1.0.2 -LE:\programme\ghc\ghc-6.10.4\Win32-2.2.0.0 -LE:\programme\ghc\ghc-6.10.4\bytestring-0.9.1.4 -LE:\programme\ghc\ghc-6.10.4\containers-0.2.0.1 -LE:\programme\ghc\ghc-6.10.4\array-0.2.0.0 -LE:\programme\ghc\ghc-6.10.4\syb-0.1.0.1 -LE:\programme\ghc\ghc-6.10.4\base-4.1.0.0 -LE:\programme\ghc\ghc-6.10.4\integer-0.1.0.1 -LE:\programme\ghc\ghc-6.10.4\ghc-prim-0.1.0.0 -LE:\programme\ghc\ghc-6.10.4 -LE:\programme\ghc\ghc-6.10.4/gcc-lib -LE:/programme/ghc/ghc-6.10.4/gcc-lib h:\.homedir\hugsdata\setup\Main.o C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0/ghc2388_0.o -lHSCabal-1.6.0.3 -lHSprocess-1.0.1.1 -lHSpretty-1.0.1.0 -lHSdirectory-1.0.0.3 -lHSold-time-1.0.0.2 -lHSold-locale-1.0.0.1 -lHSfilepath-1.1.0.2 -lHSWin32-2.2.0.0 -luser32 -lgdi32 -lwinmm -ladvapi32 -lHSbytestring-0.9.1.4 -lHScontainers-0.2.0.1 -lHSarray-0.2.0.0 -lHSsyb-0.1.0.1 -lHSbase-4.1.0.0 -lwsock32 -luser32 -lshell32 -lHSinteger-0.1.0.1 -lHSghc-prim-0.1.0.0 -lHSrts -lm -lffi -lgmp -lwsock32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt E:/programme/ghc/ghc-6.10.4/gcc-lib/crtend.o link: done *** Deleting temp files: Deleting: C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0/ghc2388_0.o C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0/ghc2388_0.rc *** Deleting temp dirs: Deleting: C:\DOKUME~1\Zyx\LOKALE~1\Temp\/ghc2388_0 h:\.homedir\hugsdata\setup\setup.exe configure --verbose=3 --builddir=h:\.homedir\hugsdata --ghc --prefix=h:\.homedir\.cabal --datadir=h:\.homedir\.cabal --configure-option=CC=e:\programme\mingw-gcc4\bin\gcc.exe --user --package-db=h:\.homedir\ghc\i386-mingw32-6.10.4\package.conf --extra-include-dirs=e:/programme/ghc/mingw-gcc4/include --extra-lib-dirs=e:/programme/ghc/mingw-gcc4/lib --constraint=base ==3.0.3.1 --with-gcc=e:\programme\ghc\mingw-gcc4\bin\gcc.exe --with-ld=e:\programme\ghc\mingw-gcc4\bin\ld.exe --gcc-option=-v --gcc-option=-Wall Redirecting build log to {handle: h:\.homedir\hugsdata\build-bindings-common-1.3.3-ghc-6.10.4.log} Using external setup method with build-type Simple Creating h:\.homedir\hugsdata\setup (and its parents) Using Cabal library version 1.6.0.3 Using h:\.homedir\hugsdata\setup\setup.hs as setup script. h:\.homedir\hugsdata\setup\setup.exe build --verbose=3 --builddir=h:\.homedir\hugsdata Redirecting build log to {handle: h:\.homedir\hugsdata\build-bindings-common-1.3.3-ghc-6.10.4.log} cabal.exe: Error: some packages failed to install: bindings-common-1.3.3 failed during the building phase. The exception was: exit: ExitFailure 1 From tonymorris at gmail.com Wed Nov 11 05:24:44 2009 From: tonymorris at gmail.com (Tony Morris) Date: Wed Nov 11 05:00:19 2009 Subject: [Haskell-cafe] Working with multiple projects In-Reply-To: <4AFA7A0C.6060307@van.steenbergen.nl> References: <4AFA6689.8060501@gmail.com> <4AFA7A0C.6060307@van.steenbergen.nl> Message-ID: <4AFA90EC.8050102@gmail.com> I don't want to have to upload every time I make a minor change as I am working. Surely there is an easier way. Martijn van Steenbergen wrote: > Tony Morris wrote: >> I have two projects that I intend to put on hackage soon. One depends >> on the other. I have "cabaled" both. I am wondering how others work >> with this kind of set up where changes are made to both libraries as >> they work. > > You just update and re-upload the packages as necessary. It really > helps here if you follow the versioning guidelines: > > http://www.haskell.org/haskellwiki/Package_versioning_policy > > HTH, > > Martijn. > > -- Tony Morris http://tmorris.net/ From ganesh.sittampalam at credit-suisse.com Wed Nov 11 05:26:32 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Wed Nov 11 05:02:25 2009 Subject: [Haskell-cafe] Working with multiple projects In-Reply-To: <4AFA90EC.8050102@gmail.com> References: <4AFA6689.8060501@gmail.com> <4AFA7A0C.6060307@van.steenbergen.nl> <4AFA90EC.8050102@gmail.com> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B03B9FC90@ELON17P32001A.csfb.cs-group.com> To install a package from local sources, just run 'cabal install' in the directory with the package's .cabal file. Tony Morris wrote: > I don't want to have to upload every time I make a minor change as I > am working. Surely there is an easier way. > > Martijn van Steenbergen wrote: >> Tony Morris wrote: >>> I have two projects that I intend to put on hackage soon. One >>> depends on the other. I have "cabaled" both. I am wondering how >>> others work with this kind of set up where changes are made to both >>> libraries as they work. >> >> You just update and re-upload the packages as necessary. It really >> helps here if you follow the versioning guidelines: >> >> http://www.haskell.org/haskellwiki/Package_versioning_policy >> >> HTH, >> >> Martijn. =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From felipe.lessa at gmail.com Wed Nov 11 06:07:10 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Wed Nov 11 05:43:04 2009 Subject: [Haskell-cafe] Working with multiple projects In-Reply-To: <16442B752A06A74AB4D9F9A5FF076E4B03B9FC90@ELON17P32001A.csfb.cs-group.com> References: <4AFA6689.8060501@gmail.com> <4AFA7A0C.6060307@van.steenbergen.nl> <4AFA90EC.8050102@gmail.com> <16442B752A06A74AB4D9F9A5FF076E4B03B9FC90@ELON17P32001A.csfb.cs-group.com> Message-ID: <20091111110710.GA32723@kira.casa> On Wed, Nov 11, 2009 at 10:26:32AM -0000, Sittampalam, Ganesh wrote: > To install a package from local sources, just run 'cabal install' in the > directory with the package's .cabal file. You can even have some kind of script like cd lib1 cabal install || exit 1 cd ../lib2 cabal install || exit 2 -- Felipe. From Tillmann.Vogt at rwth-aachen.de Wed Nov 11 06:58:12 2009 From: Tillmann.Vogt at rwth-aachen.de (Tillmann Vogt) Date: Wed Nov 11 06:34:05 2009 Subject: [Haskell-cafe] unboxed arrays restricted to simple types (Int, Float, ..) Message-ID: <4AFAA6D4.1070707@rwth-aachen.de> Hi, I tried to use unboxed arrays for generating an antialiased texture. To make it easier to understand, here is the stripped down code that produces an error: >import Control.Monad.ST >import Data.Array.ST >import Data.Array.Unboxed >import Data.Word >type BitMask = UArray Int Word16 -- for determining the grey value of a pixel >type Pixels = (Int, Int, T) >data T = N | B BitMask -- this does not work >-- type T = Int -- this works if int the next line N is replaced by ..lets say 0 >f = newArray (0,10) N :: (ST s (STUArray s Int T)) http://hackage.haskell.org/packages/archive/array/0.2.0.0/doc/html/Data-Array-MArray.html#t%3AMArray shows that mutable/unboxed arrays only allow simple types: i.e. MArray (STUArray s) Int32 (ST s) Isn't this ugly? Imagine this would be the case in C: struct stupidArrayElement{ int a; int b; // not allowed! } stupidArrayElement s[10]; Wouldn't it be nice to have something like: MArray (STUArray s) e (ST s) with e being a non-recursive data type (like data T = N | B Bitmask). My understanding of Haskell isn't deep enough to know if I have overlooked something or if the problem is solvable without a language extension. With a language extension I guess that it is not hard to find out if an abstract data type is non-recursive. Then this type should be serializable automatically. What do you think? From svein.ove at aas.no Wed Nov 11 07:28:50 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Wed Nov 11 07:04:39 2009 Subject: [Haskell-cafe] unboxed arrays restricted to simple types (Int, Float, ..) In-Reply-To: <4AFAA6D4.1070707@rwth-aachen.de> References: <4AFAA6D4.1070707@rwth-aachen.de> Message-ID: <221b53ab0911110428g1be008a7k349af62ca49df2c7@mail.gmail.com> On Wed, Nov 11, 2009 at 12:58 PM, Tillmann Vogt wrote: > Hi, > > I tried to use unboxed arrays for generating an antialiased texture. To make > it easier to understand, here is the stripped down code that produces an > error: > *snip* > > What do you think? > It is generally acknowledged that the array types bundled with GHC have serious shortcomings, such as for example the one you just pointed out. There is not, however, a consensus on how to change them. To solve your particular problem, I would suggest looking up the storablevector package on Hackage, which I know can handle arbitrary unboxed elements. That said, I'm sure someone will be along shortly to give you the full story. :-) -- Svein Ove Aas From saihemanth at gmail.com Wed Nov 11 07:30:51 2009 From: saihemanth at gmail.com (Hemanth Kapila) Date: Wed Nov 11 07:06:40 2009 Subject: [Haskell-cafe] unboxed arrays restricted to simple types (Int, Float, ..) In-Reply-To: <4AFAA6D4.1070707@rwth-aachen.de> References: <4AFAA6D4.1070707@rwth-aachen.de> Message-ID: <60d0a32f0911110430s225bd46bx9378a7be4703c579@mail.gmail.com> On Wed, Nov 11, 2009 at 5:28 PM, Tillmann Vogt wrote: > Hi, > > I tried to use unboxed arrays for generating an antialiased texture. To > make it easier to understand, here is the stripped down code that produces > an error: > > >import Control.Monad.ST > >import Data.Array.ST > >import Data.Array.Unboxed > >import Data.Word > >type BitMask = UArray Int Word16 -- for determining the grey value of a > pixel > >type Pixels = (Int, Int, T) > >data T = N | B BitMask -- this does not work > >-- type T = Int -- this works if int the next line N is replaced by ..lets > say 0 > >f = newArray (0,10) N :: (ST s (STUArray s Int T)) > > > http://hackage.haskell.org/packages/archive/array/0.2.0.0/doc/html/Data-Array-MArray.html#t%3AMArray > shows that mutable/unboxed arrays only allow simple types: > i.e. MArray (STUArray s) Int32 (ST s) > > Isn't this ugly? Imagine this would be the case in C: > > > struct stupidArrayElement{ > int a; > int b; // not allowed! > } > > stupidArrayElement s[10]; > > > Wouldn't it be nice to have something like: MArray (STUArray s) e (ST s) > with e being a non-recursive data type (like data T = N | B Bitmask). > My understanding of Haskell isn't deep enough to know if I have overlooked > something or if the problem is solvable without a language extension. With a > language extension I guess that it is not hard to find out if an abstract > data type is non-recursive. Then this type should be serializable > automatically. > > What do you think? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > Actually, there's a cool package called storable record. Could it be of some use to you? (Perhaps you *might* be able to use it if the BitMasks are of uniform length). Am not 100% sure though. Isn't this ugly? I am not sure if it is really *ugly*... and if am allowed to nit-pick, the analogy with C is not appropriate either. Arrays are just different. (At least thats how I console myself, when am looking for a high performance strict array). Also, on an approximately related issue, I was suggested to look into data parallel arrays. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/56171acc/attachment.html From phi500ac at yahoo.ca Wed Nov 11 07:32:05 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Wed Nov 11 07:07:55 2009 Subject: [Haskell-cafe] Problem with JHC In-Reply-To: <20091111083759.GH21564@sliver.repetae.net> Message-ID: <276827.64491.qm@web58807.mail.re1.yahoo.com> Hi, John. I am trying JHC in a small embedded system (Medical instruments). The software is written in Clean, and I am translating to Haskell. You may want to take a look at my page: http://www.discenda.org/med/ I am writing because I found something in JHC that smells like a bug. The program compiles without a single complaint both in GHC and JHC, but the resulting binary file does not work in JHC. I wrote a simplified example so you can spot the problem easily. The original program is used to design and simplify digital circuits for sensors (capnograms, electrocardiograms, electroencephalograms, electromyograms, and temperature). It seems that JHC is not able to deal with the trees representing the circuits. Here is a very small program. All it does is to read a tree and show it: {- file: tree.hs -} {- compile: jhc tree.hs -dc -o jtree } import System (getArgs) import System.IO import IO ? data Op = AND | OR | NOT deriving (Show, Read) ??? data Tree= L Int | T Op [Tree] deriving (Show, Read)? ? main= do ? putStrLn "Give me a tree:" ? s <- getLine ? let xx= read s ? putStrLn (show (xx::Tree)) ??? Here is what happens when I try to run it: philip@desktop:~/jhctut$ ./jtree Give me a tree: T AND (L 1, L 2) jtree_code.c:2670: case fell off Aborted It seems that the problem is in the Read class, since it works if I use the Show class only: import System (getArgs) import System.IO import IO ? data Op = AND | OR | NOT deriving (Show, Read) ??? data Tree= L Int | T Op [Tree] deriving (Show, Read)? ? main= do ? putStrLn "Give me a tree:" ? s <- getLine ? let xx= T AND [L 1, L 2] ? putStrLn (show (xx::Tree)) I hope you can fix it. --- On Wed, 11/11/09, John Meacham wrote: From: John Meacham Subject: Re: [Haskell-cafe] Opinion about JHC To: haskell-cafe@haskell.org Received: Wednesday, November 11, 2009, 1:37 AM On Tue, Nov 10, 2009 at 07:41:54PM -0800, Philippos Apolinarius wrote: > I discovered a Haskell compiler that generates very small and fast > code. In fact, it beats Clean. It has the following properties: Excellent. that was my goal ;) > 1 --- One can cross-compile programs easily. For instance, here is how I generated code for Windows: > > jhc --cross -mwin32 genetic.hs -o genetic Yup. This was a major goal. compiling for iPhones and embedded arches is just as easy assuming you have a gcc toolchain set up. (at least with the hacked iPhone SDK.. I have never tried it with the official one) > > 2 -- It seems to be quite complete. > > 3 -- However, it often compiles a file, but the program fails to run. > > I have the following questions about it: > > 1 -- How active is the team who is writing the JHC compiler? Hi, I am the main contributor, but others are welcome and several have made signifigant contributions. Development tends to be spurty. A lot of work will get done in a short amount of time, this generally corresponds to when an external contributor gets involved and the back and forth helps stimulate patches on my part to complement theirs. Although I have not been able to devote a lot of my time to jhc in the past, hopefully this will change in the not to distant future and I will be able to work on it full time. > 2 -- Is it complete Haskell? The author claims that it is; it compiled > all programs that I wrote, but that does not mean much, because my > programs are quite simple. It does Haskell 98 and several extensions, which is pretty much what GHC does. However, it does not implement the same set of extensions as GHC so this causes issues as a lot of people use GHC extensions extensively. I plan on supporting all of Haskell' of course, and the popular GHC extensions to help compatibility. Not all are implemented. > 3 -- Why the Haskell community almost never talks about JHC? Part of it is that I am not very good at advocacy. I don't always post announcements on the main haskell lists figuring the interested parties are on the jhc list already. I do try to make jhc good, fast, and usable, I always hoped someone better at advocacy than me would join the project :) In truth, I think the spurty nature of development also affects this, the list will be quite for a long time with a flurry of development lasting a few weeks occasionally inspiring some discussion in the other groups. In any case, I am glad you liked what you found! please join the mailing list for jhc if you are interested in its development or using it. ? ? ? ? John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe __________________________________________________________________ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/ba567d2c/attachment-0001.html From ekirpichov at gmail.com Wed Nov 11 07:34:50 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Wed Nov 11 07:10:36 2009 Subject: [Haskell-cafe] unboxed arrays restricted to simple types (Int, Float, ..) In-Reply-To: <4AFAA6D4.1070707@rwth-aachen.de> References: <4AFAA6D4.1070707@rwth-aachen.de> Message-ID: <5e0214850911110434u68d7251sb764b9214ef07597@mail.gmail.com> You might also look at how Data Parallel Haskell implements its arrays. IIRC, it implements an array of n-field records as n arrays. You can easily do that with typeclasses and type families. 2009/11/11 Tillmann Vogt : > Hi, > > I tried to use unboxed arrays for generating an antialiased texture. To make > it easier to understand, here is the stripped down code that produces an > error: > >>import Control.Monad.ST >>import Data.Array.ST >>import Data.Array.Unboxed >>import Data.Word >>type BitMask = UArray Int Word16 -- for determining the grey value of a >> pixel >>type Pixels = (Int, Int, T) >>data T = N | B BitMask -- this does not work >>-- type T = Int -- this works if int the next line N is replaced by ..lets >> say 0 >>f = newArray (0,10) N :: (ST s (STUArray s Int T)) > > http://hackage.haskell.org/packages/archive/array/0.2.0.0/doc/html/Data-Array-MArray.html#t%3AMArray > shows that mutable/unboxed arrays only allow simple types: > i.e. ?MArray (STUArray s) Int32 (ST s) > > Isn't this ugly? Imagine this would be the case in C: > > > struct stupidArrayElement{ > ?int a; > ?int b; // not allowed! > } > > stupidArrayElement s[10]; > > > Wouldn't it be nice to have something like: MArray (STUArray s) e (ST s) > with e being a non-recursive data type (like data T = N | B Bitmask). > My understanding of Haskell isn't deep enough to know if I have overlooked > something or if the problem is solvable without a language extension. With a > language extension I guess that it is not hard to find out if an abstract > data type is non-recursive. Then this type should be serializable > automatically. > > What do you think? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From tanielsen at gmail.com Wed Nov 11 07:49:50 2009 From: tanielsen at gmail.com (Tom Nielsen) Date: Wed Nov 11 07:25:58 2009 Subject: [Haskell-cafe] unboxed arrays restricted to simple types (Int, Float, ..) In-Reply-To: <4AFAA6D4.1070707@rwth-aachen.de> References: <4AFAA6D4.1070707@rwth-aachen.de> Message-ID: <78dc001e0911110449r2002f8c7t3a6d4e19a7888329@mail.gmail.com> There's a couple of things going on here: -If you use storablevector and storable-tuple, or uvector, you can store tuples of things. So your stupidArrayElement could be mimicked by (Int, Int). -But what you want to do is store a variable-sized data type. How would you do that in C? If you can spare another bit of memory, it might be better to define type T = (Bool, Bitmask) and use storablevector. Or maybe you want a sparse array of Bitmasks? -Yes it is a shame that Haskell does not have good support for unbounded polymorphic arrays. What if I want an array of functions? Here's a little trick that can make it a bit easier to store any data type in an unboxed array. I don't know, for instance, of any other way to define unrestricted functor/applicative for unboxed arrays. This trick should work with any other array library. {-# LANGUAGE GADTs#-} module FArray where import Data.StorableVector import Foreign.Storable import Control.Applicative data EqOrF a b where Eq :: EqOrF a a F :: (a->b) -> EqOrF a b data FArray a where FArray :: Storable a => Vector a -> EqOrF a b -> FArray b ConstArr :: a -> FArray a instance Functor FArray where fmap f (ConstArr x) = ConstArr $ f x fmap f (FArray sv Eq) = FArray sv $ F f fmap f (FArray sv (F g)) = FArray sv $ F $ f . g instance Applicative FArray where pure x = ConstArr x (ConstArr f) <*> farr = fmap f farr -- other cases left as an exercise. Which is to say, my bladder is bursting and I also need lunch. arrayOfInts = FArray (pack [1..10]) Eq arrayOfAdders = (+) `fmap` arrayOfInts Tom From hyangfji at gmail.com Wed Nov 11 07:52:48 2009 From: hyangfji at gmail.com (Hong Yang) Date: Wed Nov 11 07:28:36 2009 Subject: [Haskell-cafe] looking for a good algorithm Message-ID: The question is more about algorithm than Haskell. But I am going to code in Haskell which I am still learning. Suppose I have a large table, with hundreds of columns and thousands of rows. But not every cell has a value (of String, or Int, or Double type). I want to shuffle the rows to maximize the number of columns whose first 100 rows have at least one number, given a list of preferred column names since there is no guarantee that every number column will have at least one number in its first 100 rows after shuffling. Can someone provide a good algorithm for this problem? (I do not have any background in algorithms.) You can assume I already know which columns are of Int or Double type. This is not a homework. Thanks, Hong -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/e4dd8c9c/attachment.html From felipe.lessa at gmail.com Wed Nov 11 08:23:18 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Wed Nov 11 07:59:11 2009 Subject: [Haskell-cafe] Problem with JHC In-Reply-To: <276827.64491.qm@web58807.mail.re1.yahoo.com> References: <20091111083759.GH21564@sliver.repetae.net> <276827.64491.qm@web58807.mail.re1.yahoo.com> Message-ID: <20091111132318.GA16454@kira.casa> On Wed, Nov 11, 2009 at 04:32:05AM -0800, Philippos Apolinarius wrote: > data Op = AND | OR | NOT deriving (Show, Read) > data Tree= L Int | T Op [Tree] deriving (Show, Read)? Hmm, you see, > philip@desktop:~/jhctut$ ./jtree > Give me a tree: > T AND (L 1, L 2) > > jtree_code.c:2670: case fell off > Aborted you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' as the tree, right? -- Felipe. From dgorin at dc.uba.ar Wed Nov 11 08:24:06 2009 From: dgorin at dc.uba.ar (=?ISO-8859-1?Q?Daniel_Gor=EDn?=) Date: Wed Nov 11 08:00:01 2009 Subject: [Haskell-cafe] Problems with Language.Haskell.Interpreter and errors In-Reply-To: <1257928757.3900.8.camel@ios.cogsys.wiai.uni-bamberg.de> References: <1254225392.6118.80.camel@ios.cogsys.wiai.uni-bamberg.de> <799D986A-33A8-4C4F-B1AB-01C650EA1094@dc.uba.ar> <1254291628.6704.2.camel@ios.cogsys.wiai.uni-bamberg.de> <0919C693-2BE6-438C-9090-B6A92F7D9DEE@dc.uba.ar> <1257928757.3900.8.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <5DD22EC9-9893-464F-B9DF-10D0B6B2A49D@dc.uba.ar> On Nov 11, 2009, at 5:39 AM, Martin Hofmann wrote: > I still have problems and your code won't typecheck on my machine > printing the following error: > > [...] > > I assume we are using different versions of some packages. Could you > please send me the output of your 'ghc-pkg list'. > > Thanks, > > Martin > Sure. Global: Cabal-1.6.0.3, GLUT-2.1.1.2, HTTP-4000.0.6, HUnit-1.2.0.3, OpenGL-2.2.1.1, QuickCheck-1.2.0.0, array-0.2.0.0, base-3.0.3.1, base-4.1.0.0, bytestring-0.9.1.4, cgi-3001.1.7.1, containers-0.2.0.1, directory-1.0.0.3, (dph-base-0.3), (dph-par-0.3), (dph-prim-interface-0.3), (dph-prim-par-0.3), (dph-prim-seq-0.3), (dph-seq-0.3), editline-0.2.1.0, extensible-exceptions-0.1.1.0, fgl-5.4.2.2, filepath-1.1.0.2, (ghc-6.10.4), ghc-prim-0.1.0.0, haddock-2.4.2, haskell-src-1.0.1.3, haskell98-1.0.1.0, hpc-0.5.0.3, html-1.0.1.2, integer-0.1.0.1, mtl-1.1.0.2, network-2.2.1.2, network-2.2.1.4, old-locale-1.0.0.1, old-time-1.0.0.2, packedstring-0.1.0.1, parallel-1.1.0.1, parsec-2.1.0.1, pretty-1.0.1.0, process-1.0.1.1, random-1.0.0.1, regex-base-0.72.0.2, regex-compat-0.71.0.1, regex-posix-0.72.0.3, rts-1.0, stm-2.1.1.2, syb-0.1.0.1, template-haskell-2.3.0.1, time-1.1.2.4, time-1.1.4, unix-2.3.2.0, xhtml-3000.2.0.1, zlib-0.5.0.0 User: MonadCatchIO-mtl-0.2.0.0, ghc-mtl-1.0.1.0, ghc-paths-0.1.0.5, hint-0.3.2.0, utf8-string-0.3.5. Hope that helps Daniel From haskell at benmachine.co.uk Wed Nov 11 08:59:39 2009 From: haskell at benmachine.co.uk (Ben Millwood) Date: Wed Nov 11 08:35:27 2009 Subject: [Haskell-cafe] Help Haskell driving Medical Instruments In-Reply-To: <608498.76745.qm@web58803.mail.re1.yahoo.com> References: <608498.76745.qm@web58803.mail.re1.yahoo.com> Message-ID: On Tue, Nov 10, 2009 at 5:04 AM, Philippos Apolinarius wrote: > > foreign import ccall "rs232.h opencport" opencport :: CInt -> IO () > foreign import ccall "rs232.h closecport" closecport :: CInt -> CInt > [...] > > Originally, I had the following line (that did not work properly): > > foreign import ccall "rs232.h closecport" closecport :: IO () > I don't know why the latter line didn't work properly, but I'm pretty sure it's closer to the right answer than the former. If you don't have an IO type for your function, then Haskell is allowed to assume it is pure (has no side effects) and can then call it only when the result is needed, or multiple times if it likes, without affecting the meaning of the program. For a function that closes a handle this is clearly not the case. So I'm pretty sure your type signature needs to be in IO if you want to guarantee it is called at the right time; it might be worth elaborating on how the IO () version did not work, and how you used it. The way you are using it now would appear to work most of the time because the print statement will force the result to be evaluated, forcing the function to be called - but having a handle closed based on when an apparently irrelevant print statement runs or doesn't is obviously not ideal. From nicolas.pouillard at gmail.com Wed Nov 11 09:00:33 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Wed Nov 11 08:36:20 2009 Subject: [Haskell-cafe] (state) monad and CPS In-Reply-To: References: Message-ID: <1257947674-sup-3822@peray> Excerpts from jean-christophe mincke's message of Tue Nov 10 21:18:34 +0100 2009: > Hello, Hello, > I would like to get some advice about state monad (or any other monad I > guess) and CPS. Here is to remarks somewhat off topic: [...] > walk Empty acc k = k acc > walk (Leaf _) acc k = k (acc+1) > walk (Node (l, _, r)) acc k = let k1 acc = walk r acc k > in > walk l (acc+1) k1 Remember that by default laziness and accumulators does not fits well together. Here you are probably building a chain of thunks. Making acc a strict argument (using !acc) or using 'seq' (acc `seq` ...) will cure this. [...] > do acc <- get > put (acc+1) > ... Since this pattern occurs often 'modify' is a combination of get and put: do modify (+1) ... About your CPS question, you should have a look at the 'transformers' package, in particular the Control.Monad.Trans.Cont [1] module. [1]: http://hackage.haskell.org/packages/archive/transformers/0.1.4.0/doc/html/Control-Monad-Trans-Cont.html Best regards, -- Nicolas Pouillard http://nicolaspouillard.fr From mightybyte at gmail.com Wed Nov 11 09:22:29 2009 From: mightybyte at gmail.com (MightyByte) Date: Wed Nov 11 08:58:15 2009 Subject: [Haskell-cafe] Static Linking Problem In-Reply-To: <87tyx2m5l5.fsf@malde.org> References: <87tyx2m5l5.fsf@malde.org> Message-ID: On Tue, Nov 10, 2009 at 4:29 PM, Ketil Malde wrote: > MightyByte writes: > >> After a bit of googling, I came to the conclusion that I needed to >> compile it with "ghc --make -static -optl-static Foo.hs". ?Using only >> "-static" or "-optl-static" by themselves did not generate a >> statically linked binary. ?But when I compile with both those >> parameters I get a bunch of linker errors: > ?[..] >> (.text+0x59c): undefined reference to `pthread_mutex_lock' > > For some reason, GHC doesn't link with the pthreads library, so you need > to compile (link) with two options: -opt-static -optl-pthread Excellent, that appears to have solved my problem. It still gives me the warning: (.text+0x3068): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking But glibc is pretty standard, so I don't think this will be a problem for me. Thanks for the help. From martin.hofmann at uni-bamberg.de Wed Nov 11 09:25:23 2009 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Wed Nov 11 09:00:32 2009 Subject: [Haskell-cafe] Problems with Language.Haskell.Interpreter and errors In-Reply-To: <5DD22EC9-9893-464F-B9DF-10D0B6B2A49D@dc.uba.ar> References: <1254225392.6118.80.camel@ios.cogsys.wiai.uni-bamberg.de> <799D986A-33A8-4C4F-B1AB-01C650EA1094@dc.uba.ar> <1254291628.6704.2.camel@ios.cogsys.wiai.uni-bamberg.de> <0919C693-2BE6-438C-9090-B6A92F7D9DEE@dc.uba.ar> <1257928757.3900.8.camel@ios.cogsys.wiai.uni-bamberg.de> <5DD22EC9-9893-464F-B9DF-10D0B6B2A49D@dc.uba.ar> Message-ID: <1257949523.3900.19.camel@ios.cogsys.wiai.uni-bamberg.de> Thanks, using MonadCatchIO-mtl-0.2.0.0 and hint-0.3.2.0 did it. From mail at justinbogner.com Wed Nov 11 09:57:37 2009 From: mail at justinbogner.com (Justin Bogner) Date: Wed Nov 11 09:33:56 2009 Subject: [Haskell-cafe] Re: ANN: haskell-mode 2.6 References: <221b53ab0911011120o37e79d37gfaa0928f31e1d46c@mail.gmail.com> Message-ID: <87r5s5cdni.fsf@alpha.justinbogner.com> Svein Ove Aas writes: > Haskell-mode 2.6 has been released. The first hit for haskell-mode is http://www.haskell.org/haskell-mode/ This still points to Stefan's home page as the place to find it, which then points to http://projects.haskell.org/haskellmode-emacs/ , which is the right place. I don't know who has the right permissions, but can someone update http://www.haskell.org/haskell-mode/ to point to the right place? From Tillmann.Vogt at rwth-aachen.de Wed Nov 11 10:36:34 2009 From: Tillmann.Vogt at rwth-aachen.de (Tillmann Vogt) Date: Wed Nov 11 10:12:30 2009 Subject: [Haskell-cafe] looking for a good algorithm In-Reply-To: References: Message-ID: <4AFADA02.1010400@rwth-aachen.de> Hong Yang schrieb: > The question is more about algorithm than Haskell. But I am going to code in > Haskell which I am still learning. > > Suppose I have a large table, with hundreds of columns and thousands of > rows. But not every cell has a value (of String, or Int, or Double type). > > I want to shuffle the rows to maximize the number of columns whose first 100 > rows have at least one number, given a list of preferred column names since > there is no guarantee that every number column will have at least one number > in its first 100 rows after shuffling. > > Can someone provide a good algorithm for this problem? (I do not have any > background in algorithms.) You can assume I already know which columns are > of Int or Double type. I would say it depends on the distribution of values in the table. If there are rows with a lot of values and rows with few values, then I would first sort the rows after the number of cells with values. If you look at all the columns and the number of values for each row is unique then it would be perfectly solved. With a list of preferred columns and also a uniform distribution the problem might be hard (NP-complete?), but these hard problems can often be approximated, i.e with simulated annealing, which in short is switching two rows repeatedly as long as the result improves. > > This is not a homework. > Thanks, > > Hong > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From leimy2k at gmail.com Wed Nov 11 10:43:41 2009 From: leimy2k at gmail.com (David Leimbach) Date: Wed Nov 11 10:19:29 2009 Subject: [Haskell-cafe] Long running Haskell program Message-ID: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> As some of you may know, I've been writing commercial Haskell code for a little bit here (about a year and a half) and I've just recently had to write some code that was going to run have to run for a really long time before being restarted, possibly months or years if all other parts of the system cooperate as it's part of a server infrastructure management system. I recently ran into some serious space leak difficulties that would ultimately cause this program to crash some time after startup (my simulator is also written in Haskell, and runs a LOT faster than the real application ever could, this has enabled me to fast forward a bit the data growth issues and crash in minutes instead of days!) Anyway, rather than try to paste it all here with images and such I thought I'd stick it up on my blog so others could maybe benefit from the anecdote. It's difficult to disclose enough useful information as it is commercial code not under an open source license, but there's neat diagrams and stuff there so hopefully the colors are at least amusing :-) http://leimy9.blogspot.com/2009/11/long-running-haskell-applications.html Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/5a826508/attachment.html From shahn at cs.tu-berlin.de Wed Nov 11 11:21:30 2009 From: shahn at cs.tu-berlin.de (=?iso-8859-1?q?S=F6nke_Hahn?=) Date: Wed Nov 11 10:57:02 2009 Subject: [Haskell-cafe] Working with multiple projects In-Reply-To: <4AFA6689.8060501@gmail.com> References: <4AFA6689.8060501@gmail.com> Message-ID: <200911111721.30446.shahn@cs.tu-berlin.de> On Wednesday 11 November 2009 08:23:53 am Tony Morris wrote: > I have two projects that I intend to put on hackage soon. One depends > on the other. I have "cabaled" both. I am wondering how others work > with this kind of set up where changes are made to both libraries as > they work. > What i did in situations like this, is the following: If B depends on A: 1. Uninstall A (for not mistakenly link to an old version.) 2. Add the source directories of a local copy of A to the src-dirs in the cabal file of B. 3. remove the dependency of A in the cabal file of B. I know, that this is not very elegant, though. You end up changing your cabal file very often :( If you could tell cabal, which cabal file to use, the situation would be a little better, i think. S?nke From svein.ove at aas.no Wed Nov 11 11:44:57 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Wed Nov 11 11:20:44 2009 Subject: [Haskell-cafe] Static Linking Problem In-Reply-To: References: <87tyx2m5l5.fsf@malde.org> Message-ID: <221b53ab0911110844s73522191l19d8a649847a6a5a@mail.gmail.com> On Wed, Nov 11, 2009 at 3:22 PM, MightyByte wrote: > > (.text+0x3068): warning: Using 'getaddrinfo' in statically linked > applications requires at runtime the shared libraries from the glibc > version used for linking > > But glibc is pretty standard, so I don't think this will be a problem > for me. ?Thanks for the help. > You may have unexpected results. That warning occurs because some of glibc (namely, the getaddrinfo bit) is dynamically linked regardless of what you want; this is apparently to make NSS work, or something along those lines. However, if you then link the rest of glibc statically, you get dependencies between your program and the installed glibc, for internal, unstable APIs. (!) This is generally a Big No. Doing this means your program definitely won't be compatible with older versions of glibc, but it probably wouldn't be either way. However, in this case it also won't be compatible with *newer* versions of glibc. My recommendation would be to take glibc off the list of statically linked libraries. -- Svein Ove Aas From phi500ac at yahoo.ca Wed Nov 11 11:45:10 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Wed Nov 11 11:21:03 2009 Subject: [Haskell-cafe] Problem with JHC In-Reply-To: <20091111132318.GA16454@kira.casa> Message-ID: <493149.58235.qm@web58803.mail.re1.yahoo.com> > you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' > as the tree, right? Hi, Felipe. You are right. This means that I gave the correct input to the program. As you can see, I typed 'T AND [L 1, L 2]'. Therefore, JHC was expected to parse and print it. However, it failed to parse it. The program works perfectly well in GHC. Here is the GHC output: > philip@desktop:~/jhctut$ ghc tree.hs --make [1 of 1] Compiling Main???????????? ( tree.hs, tree.o ) Linking tree ... > philip@desktop:~/jhctut$ ./tree Give me a tree: T AND [L 1, L 2] T AND [L 1,L 2] --- On Wed, 11/11/09, Felipe Lessa wrote: From: Felipe Lessa Subject: Re: [Haskell-cafe] Problem with JHC To: haskell-cafe@haskell.org Received: Wednesday, November 11, 2009, 6:23 AM On Wed, Nov 11, 2009 at 04:32:05AM -0800, Philippos Apolinarius wrote: > data Op = AND | OR | NOT deriving (Show, Read) > data Tree= L Int | T Op [Tree] deriving (Show, Read)? Hmm, you see, > philip@desktop:~/jhctut$ ./jtree > Give me a tree: > T AND (L 1, L 2) > > jtree_code.c:2670: case fell off > Aborted you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' as the tree, right? -- Felipe. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe __________________________________________________________________ Make your browsing faster, safer, and easier with the new Internet Explorer? 8. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/560e673c/attachment.html From rmm-haskell at z.odi.ac Wed Nov 11 11:52:46 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Wed Nov 11 11:28:35 2009 Subject: [Haskell-cafe] Problem with JHC In-Reply-To: <493149.58235.qm@web58803.mail.re1.yahoo.com> References: <493149.58235.qm@web58803.mail.re1.yahoo.com> Message-ID: <0C5D7C59-21E3-459C-B9B0-0DEF32BA21EA@z.odi.ac> According to the paste you gave for the JHC test run: Here is what happens when I try to run it: philip@desktop:~/jhctut$ ./jtree Give me a tree: T AND (L 1, L 2) jtree_code.c:2670: case fell off Aborted You gave it parens not square brackets. -Ross On Nov 11, 2009, at 11:45 AM, Philippos Apolinarius wrote: > > you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' > > as the tree, right? > Hi, Felipe. > You are right. This means that I gave the correct input to the > program. As you can see, I typed 'T AND [L 1, L 2]'. Therefore, JHC > was expected to parse and print it. However, it failed to parse it. > The program works perfectly well in GHC. Here is the GHC output: > > > philip@desktop:~/jhctut$ ghc tree.hs --make > [1 of 1] Compiling Main ( tree.hs, tree.o ) > Linking tree ... > > philip@desktop:~/jhctut$ ./tree > Give me a tree: > T AND [L 1, L 2] > T AND [L 1,L 2] > > --- On Wed, 11/11/09, Felipe Lessa wrote: > > From: Felipe Lessa > Subject: Re: [Haskell-cafe] Problem with JHC > To: haskell-cafe@haskell.org > Received: Wednesday, November 11, 2009, 6:23 AM > > On Wed, Nov 11, 2009 at 04:32:05AM -0800, Philippos Apolinarius wrote: > > data Op = AND | OR | NOT deriving (Show, Read) > > data Tree= L Int | T Op [Tree] deriving (Show, Read) > > Hmm, you see, > > > philip@desktop:~/jhctut$ ./jtree > > Give me a tree: > > T AND (L 1, L 2) > > > > jtree_code.c:2670: case fell off > > Aborted > > you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' > as the tree, right? > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > Get the name you've always wanted ! @ymail.com or > @rocketmail.com._______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/5da1794a/attachment.html From ccshan at post.harvard.edu Wed Nov 11 11:42:27 2009 From: ccshan at post.harvard.edu (Chung-chieh Shan) Date: Wed Nov 11 11:36:38 2009 Subject: [Haskell-cafe] Re: looking for a good algorithm References: Message-ID: Hong Yang wrote in article in gmane.comp.lang.haskell.cafe: > I want to shuffle the rows to maximize the number of columns whose first 100 > rows have at least one number Sounds like the maximum coverage problem, which is said to be NP-hard. [citation needed] http://en.wikipedia.org/wiki/Maximum_coverage_problem -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig The answer to the ultimate question of life the universe and everything = 42 but usually it's not. From lazycat.manatee at gmail.com Wed Nov 11 11:20:59 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Wed Nov 11 11:44:18 2009 Subject: [Haskell-cafe] Re: Long running Haskell program References: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> Message-ID: <877htxyqvo.fsf@ubuntu.domain> David Leimbach writes: > As some of you may know, I've been writing commercial Haskell code for a little bit here (about a > year and a half) and I've just recently had to write some > code that was going to run have to run for a really long time before being restarted, possibly > months or years if all other parts of the system cooperate as > it's part of a server infrastructure management system. > > I recently ran into some serious space leak difficulties that would ultimately cause this program to > crash some time after startup (my simulator is also > written in Haskell, and runs a LOT faster than the real application ever could, this has enabled me > to fast forward a bit the data growth issues and crash > in minutes instead of days!) ? > > Anyway, rather than try to paste it all here with images and such I thought I'd stick it up on my > blog so others could maybe benefit from the anecdote. > ?It's difficult to disclose enough useful information as it is commercial code not under an open > source license, but there's neat diagrams and stuff there > so hopefully the colors are at least amusing :-) > > http://leimy9.blogspot.com/2009/11/long-running-haskell-applications.html Can you copy you blog at here? http://leimy9.blogspot.com/2009/11/long-running-haskell-applications.html is filter by GFW (http://en.wikipedia.org/wiki/Golden_Shield_Project) i can't see it. About crash free program, you can consider multi-process design, keep Simple and Stable core running in RootProcess, and Core module won't crash, and make unstable module running in ChildProcess, if you occur some un-catch exception from ChildProcess, just reboot those sub-module. I'm research some Haskell/Gtk+ program, sometimes un-catch exception is unavoidable, multi-process is good chose to avoid some exception crash all program. Cheers, -- Andy From bos at serpentine.com Wed Nov 11 12:51:58 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Wed Nov 11 12:27:48 2009 Subject: [Haskell-cafe] Long running Haskell program In-Reply-To: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> References: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> Message-ID: On Wed, Nov 11, 2009 at 7:43 AM, David Leimbach wrote: > > I recently ran into some serious space leak difficulties that would > ultimately cause this program to crash some time after startup (my simulator > is also written in Haskell, and runs a LOT faster than the real application > ever could, this has enabled me to fast forward a bit the data growth issues > and crash in minutes instead of days!) > It sounds to me like you were storing a Map in a StateT. Since the usual State and StateT monads don't force the evaluation of their payload, I'm not terribly surprised that such a leak should arise. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/497742f5/attachment.html From phi500ac at yahoo.ca Wed Nov 11 13:00:36 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Wed Nov 11 12:36:22 2009 Subject: [Haskell-cafe] Medical Instruments -> Jason In-Reply-To: <42784f260911101209nca238f3rea1decb75356ffb9@mail.gmail.com> Message-ID: <169680.94092.qm@web58803.mail.re1.yahoo.com> Hi, Jason. Thank you for your explanations. They were very useful. In the light of what you said, I modified the programs as shown below (commented lines failed to work). Forcing the C function to return a number, wrapping the returned number in IO,? and printing the number, I succeeded in bringing falures down to 1 case in 20 trials (average). By the way, I talked to doctors who work with capnograms, and they said that all Windows or Linux machines have problems in closing communication ports. However, it seems that capnographs are not turned off very often. I mean, when the doctor move the capnograph from one patient to another, s/he turns? off the instrument.? Therefore, this behavior does not create problems. However, what bothers me is that Clean always succeds in closeing the port. {-# LANGUAGE ForeignFunctionInterface #-} {- file: SER/IAL.hs -} module SER.IAL where ? ?import Control.Monad ?import Foreign ?import Foreign.C.Types ?import Foreign.C ?foreign import ccall "rs232.h opencport" opencport :: CInt -> IO () ?-- foreign import ccall "rs232.h closecport" closecport :: CInt -> CInt ?-- foreign import stdcall unsafe "rs232.h closecport" closecport :: IO () ?--? foreign import ccall unsafe "rs232.h closecport" c_closecport ::? CInt ?foreign import ccall unsafe "rs232.h closecport" c_closecport :: CInt -> CInt ?closecport :: Int -> IO Int ?closecport n= return (fromIntegral (c_closecport (fromIntegral n))) ?foreign import ccall "rs232.h rdrs232" c_sendmsg :: CInt -> CString -> CString ?sendMessage :: Int -> String -> IO String ?sendMessage? n msg = ?? withCString msg $ ????? \str -> peekCString (c_sendmsg (fromIntegral n) str) {- file: sensors.hs -} import Gui.Binding import Gui.Types import Gui.Constants import SER.IAL import Control.Monad import Data.Char main = do rv <- j_start ????????? frame <- j_frame "Sensors" ??? ? avg <- j_button frame "Sampling" ??? ? j_setpos avg 20 150 ??? ? j_setsize avg 90 30 ??? ? rb <- j_button frame "Read" ??? ? j_setpos rb 125 150 ??? ? j_setsize rb 90 30 ??? ? tb <- j_button frame "Acquisition" ??? ? j_setpos tb 230 150 ??? ? j_setsize tb 90 30 ??? ? fld <- j_textfield frame 40 ??? ? j_setpos fld 20 100 ??? ? menubar <- j_menubar frame ??? ? file <- j_menu menubar "File" ??? ? quitMI <- j_menuitem file "Quit" ????????? j_show frame ????????? opencport(3) ????????? waitForFrameAction frame fld rb tb avg quitMI ????????? r <- closecport 5 ????????? putStrLn (show r) ????????? return j_quit ??????? waitForFrameAction frame f rb tb avg q = ??? do obj <-? j_nextaction ?????? again <- if obj == event q then return False? ??????????????? else if obj == event rb then ?????????????????? (do msg <- sendMessage 1 "r" ?????????????????????? putStrLn msg ?????????????????????? return True) ??????????????? else if obj == event tb then ??? ??? ?? (do ??? ??? ???? tx <- sendMessage 1 "t" ??? ??? ???? let tp= filter (> ' ') tx ??? ??? ???? j_settext f tp ??? ??? ???? return True) ??? ??? else if obj == event avg then ??? ??? ?? (do ok <- sendMessage 1 "m" ??? ??? ?????? val <- j_gettext f 300 ??? ??? ?????? ns <- sendMessage 2 val ??? ??? ?????? putStrLn ((filter (> ' ') ok) ++ ns) ??? ??? ?????? return True) ??? ??? else ??? ??? ? (do ??? ??? ???? tx <- sendMessage 1 "t" ??? ??? ???? let tp= filter (> ' ') tx ??? ??? ???? rx <- sendMessage 1 "x" ??? ??? ???? let rd= filter (> ' ') rx ??? ??? ???? let x = hex2dec rd ??? ??? ???? let tt= (fromIntegral x)*209.1/1023.0 - 67.23 ??? ??? ???? j_settext f ((show tt)++" ==> "++tp) ??? ??? ???? return True) ?????? if not again ??? ? then return True ??? ? else waitForFrameAction frame f rb tb avg q hex2dec :: String -> Int hex2dec h= sum (zipWith (*) ??????????????????? (map (16^) [3,2,1,0]) ??????????????????? [digitToInt c | c <- h]) ??????????????????? convert d r s0= (fromIntegral (hex2dec d))*r/1024.0- s0 {- 1a43 67.23; 082b - 209.1 -} // file: serial.c #include "serial.h" #include #include /* Possible baudrates on a normal pc: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200 */ #define BAUD "baud=9600 data=8 parity=N stop=1" HANDLE Cport; char comports[16][10]={"\\\\.\\COM1",? "\\\\.\\COM2",? "\\\\.\\COM3",? "\\\\.\\COM4", ?????????????????????? "\\\\.\\COM5",? "\\\\.\\COM6",? "\\\\.\\COM7",? "\\\\.\\COM8", ?????????????????????? "\\\\.\\COM9",? "\\\\.\\COM10", "\\\\.\\COM11", "\\\\.\\COM12", ?????????????????????? "\\\\.\\COM13", "\\\\.\\COM14", "\\\\.\\COM15", "\\\\.\\COM16"}; int OpenComport(int comport_number) { ? if(comport_number>15) ? { ??? printf("illegal comport number\n"); ??? return(1); ? } ? Cport = CreateFileA(comports[comport_number], ????????????????????? GENERIC_READ|GENERIC_WRITE, ????????????????????? 0,????????????????????????? /* no share? */ ????????????????????? NULL,?????????????????????? /* no security */ ????????????????????? OPEN_EXISTING, ????????????????????? 0,????????????????????????? /* no threads */ ????????????????????? NULL);????????????????????? /* no templates */ ? if(Cport==INVALID_HANDLE_VALUE) ? { ??? printf("unable to open comport\n"); ??? return(1); ? } ? DCB port_settings; ? memset(&port_settings, 0, sizeof(port_settings));? /* clear the new struct? */ ? port_settings.DCBlength = sizeof(port_settings); ? if(!BuildCommDCBA(BAUD, &port_settings)) ? { ??? printf("unable to set comport dcb settings\n"); ??? CloseHandle(Cport); ??? return(1); ? } ? if(!SetCommState(Cport, &port_settings)) ? { ??? printf("unable to set comport cfg settings\n"); ??? CloseHandle(Cport); ??? return(1); ? } ? COMMTIMEOUTS Cptimeouts; ? Cptimeouts.ReadIntervalTimeout???????? = MAXDWORD; ? Cptimeouts.ReadTotalTimeoutMultiplier? = 10; ? Cptimeouts.ReadTotalTimeoutConstant??? = 10; ? Cptimeouts.WriteTotalTimeoutMultiplier = 10; ? Cptimeouts.WriteTotalTimeoutConstant?? = 10; ? if(!SetCommTimeouts(Cport, &Cptimeouts)) ? { ??? printf("unable to set comport time-out settings\n"); ??? CloseHandle(Cport); ??? return(1); ? } ? return(0); } int PollComport(unsigned char *buf, int size) { ? int n; ? if(size>4096)? size = 4096; /* added the void pointer cast, otherwise gcc will complain about */ /* "warning: dereferencing type-punned pointer will break strict aliasing rules" */ ? ReadFile(Cport, buf, size, (LPDWORD)((void *)&n), NULL); ? return(n); } int RdByte(unsigned char* m) { ? int n; ? ReadFile(Cport, m, 1, (LPDWORD)((void *)&n), NULL); ? return(n); } int SendByte(unsigned char byte) { ? int n; ? WriteFile(Cport, &byte, 1, (LPDWORD)((void *)&n), NULL); ? if(n<0)? return(1); ? return(0); } int SendBuf(unsigned char *buf, int size) { ? int n; ? if(WriteFile(Cport, buf, size, (LPDWORD)((void *)&n), NULL)) ? { ??? return(n); ? } ? return(-1); } int CloseComport(void) { ? CloseHandle(Cport); ? return(0); } int IsCTSEnabled(void) { ? int status; ? GetCommModemStatus(Cport, (LPDWORD)((void *)&status)); ? if(status&MS_CTS_ON) return(1); ? else return(0); } int cprintf(const char *text)? /* sends a string to serial port */ { ? while(*text != 0)?? SendByte(*(text++)); ? return(0); } int opencport(int p) { ?? OpenComport(p-1); ?? return 3; } int closecport(int n) { ?? CloseHandle(Cport); ?? printf("Bye\n"); ?? return n; } char* rdrs232(int n, char* msg) { ??? char *str; ??? char mm; ??? int i, j; ??? for (j=0; j0 && str[0]==0) { str[0]= ' ';} ??? return(str); } //file: serial.h #ifndef rs232_INCLUDED #define rs232_INCLUDED #ifdef __cplusplus extern "C" { #endif #include #include #ifdef __linux__ #include #include #include #include #include #include #include #else #include #endif int OpenComport(int); int PollComport(unsigned char *, int); int SendByte(unsigned char); int SendBuf(unsigned char *, int); int CloseComport(void); int cprintf(const char *); int IsCTSEnabled(void); char *topa(int n); int opencport(int p); int closecport(int n); char* rdrs232(int n, char* msg); #ifdef __cplusplus } /* extern "C" */ #endif #endif --- On Tue, 11/10/09, Jason Dusek wrote: From: Jason Dusek Subject: Re: [Haskell-cafe] Help Haskell driving Medical Instruments To: "Philippos Apolinarius" Cc: "Haskell Cafe" Received: Tuesday, November 10, 2009, 1:09 PM 2009/11/10 Philippos Apolinarius > I don't know how to mark the call unsafe. [...] I am running > the main program on Windows. ? Marking it unsafe is done by putting "unsafe" in the foreign ? import declaration. Even if it turns out not to fix the ? problem, it reduces the overhead of foreign calls (and is safe ? as long as they aren't going to call back into Haskell). ? Because your on Windows, you want to use "stdcall", as ? mentioned by Daniel Fischer. Thus the full declaration is: ? ? foreign import stdcall unsafe "rs232.h closecport" closecport :: IO () ? Let us know if this helps. > Here is the compilation script: > > ghc -fglasgow-exts serial.c? %1.hs -L./ -ljapi --make > erase *.hi > erase *.o > strip %1.exe ? I encourage you to look into Cabal soon :) -- Jason Dusek __________________________________________________________________ Make your browsing faster, safer, and easier with the new Internet Explorer? 8. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/7fa1ce53/attachment-0001.html From matthew.pocock at ncl.ac.uk Wed Nov 11 13:09:54 2009 From: matthew.pocock at ncl.ac.uk (Matthew Pocock) Date: Wed Nov 11 12:45:42 2009 Subject: [Haskell-cafe] Long running Haskell program In-Reply-To: References: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> Message-ID: Is there a state monad that is strict on the state but lazy on the computation? Of course, strictness in the state will force a portion of the computation to be run, but there may be significant portions of it which are not run. Would there be a way to write a state monad such that it is entirely lazy, but then to wrap either the computation or the state in an 'eager' strategy datatype which takes care of this in a more flexible manner? Thanks, Matthew 2009/11/11 Bryan O'Sullivan > On Wed, Nov 11, 2009 at 7:43 AM, David Leimbach wrote: > >> >> I recently ran into some serious space leak difficulties that would >> ultimately cause this program to crash some time after startup (my simulator >> is also written in Haskell, and runs a LOT faster than the real application >> ever could, this has enabled me to fast forward a bit the data growth issues >> and crash in minutes instead of days!) >> > > It sounds to me like you were storing a Map in a StateT. Since the usual > State and StateT monads don't force the evaluation of their payload, I'm not > terribly surprised that such a leak should arise. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/8f64bcdc/attachment.html From paolo.veronelli at gmail.com Wed Nov 11 13:25:14 2009 From: paolo.veronelli at gmail.com (Paolino) Date: Wed Nov 11 13:01:01 2009 Subject: [Haskell-cafe] Problem with JHC In-Reply-To: <0C5D7C59-21E3-459C-B9B0-0DEF32BA21EA@z.odi.ac> References: <493149.58235.qm@web58803.mail.re1.yahoo.com> <0C5D7C59-21E3-459C-B9B0-0DEF32BA21EA@z.odi.ac> Message-ID: FWIW, I just compiled JHC 0.7.2 with ghc 6.12 , doing a couple of corrections to make it compile, which I don't think they are related to this *bug*. Testing the given code, it aborts for every inputs I give it "L 1", " T AND [L 1,L 2]" included. I couldn't make it compile using function "reads" instead. paolino 2009/11/11 Ross Mellgren > According to the paste you gave for the JHC test run: > > Here is what happens when I try to run it: > > philip@desktop:~/jhctut$ ./jtree > Give me a tree: > T AND (L 1, L 2) > > jtree_code.c:2670: case fell off > Aborted > > You gave it parens not square brackets. > > -Ross > > On Nov 11, 2009, at 11:45 AM, Philippos Apolinarius wrote: > > > you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' > > as the tree, right? > Hi, Felipe. > You are right. This means that I gave the correct input to the program. As > you can see, I typed 'T AND [L 1, L 2]'. Therefore, JHC was expected to > parse and print it. However, it failed to parse it. The program works > perfectly well in GHC. Here is the GHC output: > > > philip@desktop:~/jhctut$ ghc tree.hs --make > [1 of 1] Compiling Main ( tree.hs, tree.o ) > Linking tree ... > > philip@desktop:~/jhctut$ ./tree > Give me a tree: > T AND [L 1, L 2] > T AND [L 1,L 2] > > --- On *Wed, 11/11/09, Felipe Lessa * wrote: > > > From: Felipe Lessa > Subject: Re: [Haskell-cafe] Problem with JHC > To: haskell-cafe@haskell.org > Received: Wednesday, November 11, 2009, 6:23 AM > > On Wed, Nov 11, 2009 at 04:32:05AM -0800, Philippos Apolinarius wrote: > > data Op = AND | OR | NOT deriving (Show, Read) > > data Tree= L Int | T Op [Tree] deriving (Show, Read) > > Hmm, you see, > > > philip@desktop:~/jhctut$ ./jtree > > Give me a tree: > > T AND (L 1, L 2) > > > > jtree_code.c:2670: case fell off > > Aborted > > you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' > as the tree, right? > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > ------------------------------ > Get the name you've always wanted ! *@ > ymail.com *or *@rocketmail.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 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/de89b7a0/attachment.html From dave at zednenem.com Wed Nov 11 13:29:07 2009 From: dave at zednenem.com (David Menendez) Date: Wed Nov 11 13:04:57 2009 Subject: [Haskell-cafe] Long running Haskell program In-Reply-To: References: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> Message-ID: <49a77b7a0911111029y19bbfb0ofca117642368906c@mail.gmail.com> On Wed, Nov 11, 2009 at 1:09 PM, Matthew Pocock wrote: > Is there a state monad that is strict on the state but lazy on the > computation? Of course, strictness in the state will force a portion of the > computation to be run, but there may be significant portions of it which are > not run. Would there be a way to write a state monad such that it is > entirely lazy, but then to wrap either the computation or the state in an > 'eager' strategy datatype which takes care of this in a more flexible > manner? I think replacing "put s" with "put $! s" should guarantee that the state is evaluated. If you're using get and put in many place in the code, you could try something along these lines: newtype SStateT s m a = S { unS :: StateT s m a } deriving (Monad, etc.) instance (Monad m) => MonadState s (SStateT s m) where get = S get put s = S (put $! s) -- Dave Menendez From paolo.veronelli at gmail.com Wed Nov 11 13:37:55 2009 From: paolo.veronelli at gmail.com (Paolino) Date: Wed Nov 11 13:13:42 2009 Subject: [Haskell-cafe] Long running Haskell program In-Reply-To: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> References: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> Message-ID: Hello leimy, the only simple solution I have found to avoid a leaking state of a server is doing a periodical rnf of it, this implying the NFData constraint on its datatype. The reader should leak only if you nest forever the "local" function. paolino 2009/11/11 David Leimbach > As some of you may know, I've been writing commercial Haskell code for a > little bit here (about a year and a half) and I've just recently had to > write some code that was going to run have to run for a really long time > before being restarted, possibly months or years if all other parts of the > system cooperate as it's part of a server infrastructure management system. > > I recently ran into some serious space leak difficulties that would > ultimately cause this program to crash some time after startup (my simulator > is also written in Haskell, and runs a LOT faster than the real application > ever could, this has enabled me to fast forward a bit the data growth issues > and crash in minutes instead of days!) > > Anyway, rather than try to paste it all here with images and such I thought > I'd stick it up on my blog so others could maybe benefit from the anecdote. > It's difficult to disclose enough useful information as it is commercial > code not under an open source license, but there's neat diagrams and stuff > there so hopefully the colors are at least amusing :-) > > http://leimy9.blogspot.com/2009/11/long-running-haskell-applications.html > > Dave > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/b3f1885e/attachment.html From lennart at augustsson.net Wed Nov 11 13:47:43 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Wed Nov 11 13:23:30 2009 Subject: [Haskell-cafe] Opinion about JHC In-Reply-To: <20091111083759.GH21564@sliver.repetae.net> References: <567296.97882.qm@web58802.mail.re1.yahoo.com> <20091111083759.GH21564@sliver.repetae.net> Message-ID: John, Do you use jhc when you develop jhc? I.e., does it compile itself. For me, this is the litmus test of when a compiler has become usable. I mean, if even the developers of a compiler don't use it themselves, why should anyone else? :) -- Lennart On Wed, Nov 11, 2009 at 3:37 AM, John Meacham wrote: > On Tue, Nov 10, 2009 at 07:41:54PM -0800, Philippos Apolinarius wrote: >> I discovered a Haskell compiler that generates very small and fast >> code. In fact, it beats Clean. It has the following properties: > > Excellent. that was my goal ;) > >> 1 --- One can cross-compile programs easily. For instance, here is how I generated code for Windows: >> >> jhc --cross -mwin32 genetic.hs -o genetic > > Yup. This was a major goal. compiling for iPhones and embedded arches is > just as easy assuming you have a gcc toolchain set up. (at least with > the hacked iPhone SDK.. I have never tried it with the official one) > >> >> 2 -- It seems to be quite complete. >> >> 3 -- However, it often compiles a file, but the program fails to run. >> >> I have the following questions about it: >> >> 1 -- How active is the team who is writing the JHC compiler? > > Hi, I am the main contributor, but others are welcome and several have > made signifigant contributions. Development tends to be spurty. A lot of > work will get done in a short amount of time, this generally corresponds > to when an external contributor gets involved and the back and forth > helps stimulate patches on my part to complement theirs. > > Although I have not been able to devote a lot of my time to jhc in the > past, hopefully this will change in the not to distant future and I will > be able to work on it full time. > > >> 2 -- Is it complete Haskell? The author claims that it is; it compiled >> all programs that I wrote, but that does not mean much, because my >> programs are quite simple. > > It does Haskell 98 and several extensions, which is pretty much what GHC > does. However, it does not implement the same set of extensions as GHC > so this causes issues as a lot of people use GHC extensions extensively. > > I plan on supporting all of Haskell' of course, and the popular GHC > extensions to help compatibility. Not all are implemented. > >> 3 -- Why the Haskell community almost never talks about JHC? > > Part of it is that I am not very good at advocacy. I don't always > post announcements on the main haskell lists figuring the interested > parties are on the jhc list already. I do try to make jhc good, fast, > and usable, I always hoped someone better at advocacy than me would join > the project :) In truth, I think the spurty nature of development also > affects this, the list will be quite for a long time with a flurry of > development lasting a few weeks occasionally inspiring some discussion > in the other groups. > > In any case, I am glad you liked what you found! please join the mailing > list for jhc if you are interested in its development or using it. > > ? ? ? ?John > > > > -- > John Meacham - ?repetae.net?john? - http://notanumber.net/ > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From donn at avvanta.com Wed Nov 11 14:12:24 2009 From: donn at avvanta.com (Donn Cave) Date: Wed Nov 11 13:48:11 2009 Subject: [Haskell-cafe] Opinion about JHC References: <567296.97882.qm@web58802.mail.re1.yahoo.com> <20091111083759.GH21564@sliver.repetae.net> Message-ID: <20091111191224.9067EF394A@mail.avvanta.com> Quoth Lennart Augustsson , > Do you use jhc when you develop jhc? I.e., does it compile itself. > For me, this is the litmus test of when a compiler has become usable. > I mean, if even the developers of a compiler don't use it themselves, > why should anyone else? :) Though that's exactly backwards for minority platforms, where the compilers that compile themselves tend to be no use whatever. Donn Cave, donn@avvanta.com From leimy2k at gmail.com Wed Nov 11 14:13:41 2009 From: leimy2k at gmail.com (David Leimbach) Date: Wed Nov 11 13:49:29 2009 Subject: [Haskell-cafe] Re: Long running Haskell program In-Reply-To: <877htxyqvo.fsf@ubuntu.domain> References: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> <877htxyqvo.fsf@ubuntu.domain> Message-ID: <3e1162e60911111113k5f482322mde53f52b610cd06a@mail.gmail.com> On Wed, Nov 11, 2009 at 8:20 AM, Andy Stewart wrote: > David Leimbach writes: > > > As some of you may know, I've been writing commercial Haskell code for a > little bit here (about a > > year and a half) and I've just recently had to write some > > code that was going to run have to run for a really long time before > being restarted, possibly > > months or years if all other parts of the system cooperate as > > it's part of a server infrastructure management system. > > > > I recently ran into some serious space leak difficulties that would > ultimately cause this program to > > crash some time after startup (my simulator is also > > written in Haskell, and runs a LOT faster than the real application ever > could, this has enabled me > > to fast forward a bit the data growth issues and crash > > in minutes instead of days!) > > > > Anyway, rather than try to paste it all here with images and such I > thought I'd stick it up on my > > blog so others could maybe benefit from the anecdote. > > It's difficult to disclose enough useful information as it is commercial > code not under an open > > source license, but there's neat diagrams and stuff there > > so hopefully the colors are at least amusing :-) > > > > > http://leimy9.blogspot.com/2009/11/long-running-haskell-applications.html > Can you copy you blog at here? > http://leimy9.blogspot.com/2009/11/long-running-haskell-applications.html > is filter by GFW (http://en.wikipedia.org/wiki/Golden_Shield_Project) i > can't see it. > > About crash free program, you can consider multi-process design, keep > Simple and Stable core running in RootProcess, and Core module won't > crash, and make unstable module running in ChildProcess, if you occur > some un-catch exception from ChildProcess, just reboot those sub-module. > > Believe it or not, this is a stack of Erlang <-> Haskell <-> C. It works via pipes and is a concurrent system of management. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/7c2e3155/attachment.html From leimy2k at gmail.com Wed Nov 11 14:17:11 2009 From: leimy2k at gmail.com (David Leimbach) Date: Wed Nov 11 13:52:59 2009 Subject: [Haskell-cafe] Long running Haskell program In-Reply-To: References: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> Message-ID: <3e1162e60911111117r7c2e26b3xd18e8d8e64f6299d@mail.gmail.com> On Wed, Nov 11, 2009 at 9:51 AM, Bryan O'Sullivan wrote: > On Wed, Nov 11, 2009 at 7:43 AM, David Leimbach wrote: > >> >> I recently ran into some serious space leak difficulties that would >> ultimately cause this program to crash some time after startup (my simulator >> is also written in Haskell, and runs a LOT faster than the real application >> ever could, this has enabled me to fast forward a bit the data growth issues >> and crash in minutes instead of days!) >> > > It sounds to me like you were storing a Map in a StateT. Since the usual > State and StateT monads don't force the evaluation of their payload, I'm not > terribly surprised that such a leak should arise. > That's exactly what was happening. The system was being far too lazy (by choices I made but didn't fully understand). By pulling the Map out of the state, and pushing it back into the state, as the definition of my looping, things got a lot better. I didn't see another *easy* way to force the state to be evaluated, except by doing IO on intermediate values. seq will only evaluate strictly if it's just underneath something else that's already been evaluated :-). The runtime doesn't look for "seq"s to force evaluation on. I figured I was better off just creating a dependency in the evaluation, near the outermost portion of the program (the loop) that would cause a strict evaluation, and so far I was right :-) Program behaves very well now, and responds much better too. Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/1546f18d/attachment.html From leimy2k at gmail.com Wed Nov 11 14:18:27 2009 From: leimy2k at gmail.com (David Leimbach) Date: Wed Nov 11 13:54:12 2009 Subject: [Haskell-cafe] Long running Haskell program In-Reply-To: <49a77b7a0911111029y19bbfb0ofca117642368906c@mail.gmail.com> References: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> <49a77b7a0911111029y19bbfb0ofca117642368906c@mail.gmail.com> Message-ID: <3e1162e60911111118i32d41cf8wa73885cfad156885@mail.gmail.com> On Wed, Nov 11, 2009 at 10:29 AM, David Menendez wrote: > On Wed, Nov 11, 2009 at 1:09 PM, Matthew Pocock > wrote: > > Is there a state monad that is strict on the state but lazy on the > > computation? Of course, strictness in the state will force a portion of > the > > computation to be run, but there may be significant portions of it which > are > > not run. Would there be a way to write a state monad such that it is > > entirely lazy, but then to wrap either the computation or the state in an > > 'eager' strategy datatype which takes care of this in a more flexible > > manner? > > I think replacing "put s" with "put $! s" should guarantee that the > state is evaluated. > > If you're using get and put in many place in the code, you could try > something along these lines: > > newtype SStateT s m a = S { unS :: StateT s m a } deriving (Monad, etc.) > > instance (Monad m) => MonadState s (SStateT s m) where > get = S get > put s = S (put $! s) > That's interesting, and once I have time to come back to this part of the project (I was behind schedule at this point!) I'll try something like that. > > -- > Dave Menendez > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/1d4f0948/attachment.html From dons at galois.com Wed Nov 11 14:19:38 2009 From: dons at galois.com (Don Stewart) Date: Wed Nov 11 13:55:30 2009 Subject: [Haskell-cafe] Long running Haskell program In-Reply-To: <3e1162e60911111117r7c2e26b3xd18e8d8e64f6299d@mail.gmail.com> References: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> <3e1162e60911111117r7c2e26b3xd18e8d8e64f6299d@mail.gmail.com> Message-ID: <20091111191938.GB23964@whirlpool.galois.com> leimy2k: > I figured I was better off just creating a dependency in the evaluation, near > the outermost portion of the program (the loop) that would cause a strict > evaluation, and so far I was right :-) > > Program behaves very well now, and responds much better too. Do you know if Control.Monad.State.Strict is enough to get the behaviour you need? -- Don From haskell at benmachine.co.uk Wed Nov 11 14:24:21 2009 From: haskell at benmachine.co.uk (Ben Millwood) Date: Wed Nov 11 14:00:10 2009 Subject: [Haskell-cafe] Medical Instruments -> Jason In-Reply-To: <169680.94092.qm@web58803.mail.re1.yahoo.com> References: <42784f260911101209nca238f3rea1decb75356ffb9@mail.gmail.com> <169680.94092.qm@web58803.mail.re1.yahoo.com> Message-ID: On Wed, Nov 11, 2009 at 6:00 PM, Philippos Apolinarius wrote: > > ?closecport :: Int -> IO Int > ?closecport n= return (fromIntegral (c_closecport (fromIntegral n))) > The return here doesn't do what you think it does - semantically, the value of c_closecport is still considered pure and assumed to be referentially transparent, so multiple calls to closecport are allowed to share the value returned, or delay the call until the value is unwrapped, call it multiple times for each use of the value, or anything else. You need to use IO *directly* in the foreign import declaration so that the compiler knows that the function calls can't be shared or inlined or generally messed about with: the IO tells it that order of execution with respect to your other IO actions is important. This one looks the most right: foreign import stdcall unsafe "rs232.h closecport" closecport :: IO () so I think you need to look closer about why it wasn't working for you, and where or how you were using it. From ndmitchell at gmail.com Wed Nov 11 14:25:39 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Nov 11 14:01:26 2009 Subject: [Haskell-cafe] Hoogle is great but ... In-Reply-To: <26046410.post@talk.nabble.com> References: <26046410.post@talk.nabble.com> Message-ID: <404396ef0911111125i4653ab57te732aeb8c46906dd@mail.gmail.com> Following up on this rather old thread, if you want to see a module which has lots of input/output example pairs, and properties, in the documentation then look at filepath (hoogle for takeExtension as an example). These properties are also automatically transformed in to test cases, so filepath has good documentation and good test coverage all in one, plus the documentation is actually checked for correctness. I think more libraries should do this - so I challenge someone to write the definitive "tests and assertions in code" package for Haskell. And it's nice to hear that Hoogle is great :-) Thanks, Neil 2009/10/25 zaxis : > > http://www.haskell.org/hoogle/ is VERY great for haskeller. However, i feel > hoogle should be improved by providing more examples as : > > isInfixOf :: Eq a => [a] -> [a] -> Bool > > The isInfixOf function takes two lists and returns True iff the first list > is contained, wholly and intact, anywhere within the second. > > Example: > > isInfixOf "Haskell" "I really like Haskell." -> True > isInfixOf "Ial" "I really like Haskell." -> False > > The Example code will be helpful for programmer to understand its > definition. > > Sincerely! > -- > View this message in context: http://www.nabble.com/Hoogle-is-great-but-...-tp26046410p26046410.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 > From lennart at augustsson.net Wed Nov 11 14:31:06 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Wed Nov 11 14:06:52 2009 Subject: [Haskell-cafe] Opinion about JHC In-Reply-To: <20091111191224.9067EF394A@mail.avvanta.com> References: <567296.97882.qm@web58802.mail.re1.yahoo.com> <20091111083759.GH21564@sliver.repetae.net> <20091111191224.9067EF394A@mail.avvanta.com> Message-ID: If by minority platform you mean platforms that are resource starved, like some embedded systems, then I would have to agree. -- Lennart On Wed, Nov 11, 2009 at 2:12 PM, Donn Cave wrote: > Quoth Lennart Augustsson , > >> Do you use jhc when you develop jhc? ?I.e., does it compile itself. >> For me, this is the litmus test of when a compiler has become usable. >> I mean, if even the developers of a compiler don't use it themselves, >> why should anyone else? :) > > Though that's exactly backwards for minority platforms, where the > compilers that compile themselves tend to be no use whatever. > > ? ? ? ?Donn Cave, donn@avvanta.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From leimy2k at gmail.com Wed Nov 11 14:33:45 2009 From: leimy2k at gmail.com (David Leimbach) Date: Wed Nov 11 14:09:30 2009 Subject: [Haskell-cafe] Long running Haskell program In-Reply-To: <20091111191938.GB23964@whirlpool.galois.com> References: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> <3e1162e60911111117r7c2e26b3xd18e8d8e64f6299d@mail.gmail.com> <20091111191938.GB23964@whirlpool.galois.com> Message-ID: <3e1162e60911111133o49070792m45f33628027b0a9e@mail.gmail.com> On Wed, Nov 11, 2009 at 11:19 AM, Don Stewart wrote: > leimy2k: > > I figured I was better off just creating a dependency in the evaluation, > near > > the outermost portion of the program (the loop) that would cause a strict > > evaluation, and so far I was right :-) > > > > Program behaves very well now, and responds much better too. > > Do you know if Control.Monad.State.Strict is enough to get the behaviour > you need? > > I'll give that a go. Most of my trouble figuring out the space leak has been around identifying what was really responsible for the problem. The functions that were listed as eating the space in -hc runs were not ultimately the ones causing the lack of strictness, in that they would have had to have been evaluated at a higher layer in a non-lazy way. So my take away from all of this is, when you have a space leak in haskell, start from the outer most evaluations inward, not the other way around!!! I think that would have saved me a ton of time. Dave > -- Don > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/4dd4bea6/attachment.html From donn at avvanta.com Wed Nov 11 14:44:08 2009 From: donn at avvanta.com (Donn Cave) Date: Wed Nov 11 14:19:53 2009 Subject: [Haskell-cafe] Opinion about JHC References: <567296.97882.qm@web58802.mail.re1.yahoo.com> <20091111083759.GH21564@sliver.repetae.net> <20091111191224.9067EF394A@mail.avvanta.com> Message-ID: <20091111194408.3F5A7276C48@mail.avvanta.com> Quoth Lennart Augustsson , > If by minority platform you mean platforms that are resource starved, > like some embedded systems, then I would have to agree. Like anything but the platform the compiler developer(s) use. If you used a platform like that, you would certainly have to agree. If you were a compiler developer for a language that supports like-platform porting the way GHC does, after trying to keep that working while developing the language I suspect you might also be tempted to agree. Donn Cave, donn@avvanta.com From leather at cs.uu.nl Wed Nov 11 15:24:43 2009 From: leather at cs.uu.nl (Sean Leather) Date: Wed Nov 11 15:00:49 2009 Subject: [Haskell-cafe] "Least common supertype"? Message-ID: <3c6288ab0911111224g2f7cce72rdfd957b7af32b6f2@mail.gmail.com> Is there a name for the following concept? Can you point me to any references on it? Suppose I have the following two functions ... > swap1 :: (Int, Char) -> (Char, Int) > swap2 :: (Char, Int) -> (Int, Char) ... and, for some reason, I think I can unify these into a single function. I think, hmm, given that the structure is that same, let's do a first pass: > swap? :: (a, b) -> (c, d) But then I go back to the input types to confirm that this will work, and, alas, it will not, because there are similarities that I missed. This is way too general. I need to ensure that what's an Int stays an Int and likewise for Char. > swap! :: (a, b) -> (b, a) And now I have found a type that is more general than swap1 and swap2 and yet not so general that the shared constraints are left out. This seems somewhat analogous to the least common multiple. Another example is the following: > showFloat :: Float -> String > showBool :: Bool -> String We could say the more general type is ... > show? :: a -> String ... but then we lose the implied constraint that we must know something about 'a' to produce a string. So, we add back such some such constraint: > show! :: (Show a) => a -> String Of course, with all of this, it may not be clear what to do about the definitions of the functions, but I'm curious if there's a name for the concept from a type perspective. Thanks, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/d88af364/attachment.html From ekirpichov at gmail.com Wed Nov 11 15:31:00 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Wed Nov 11 15:06:47 2009 Subject: [Haskell-cafe] "Least common supertype"? In-Reply-To: <3c6288ab0911111224g2f7cce72rdfd957b7af32b6f2@mail.gmail.com> References: <3c6288ab0911111224g2f7cce72rdfd957b7af32b6f2@mail.gmail.com> Message-ID: <5e0214850911111231w70f62809v511e962fd3d8c7db@mail.gmail.com> Is the name of the concept.... "Most general unifier" (MGU) ? (See: Hindley-Milner type inference) 2009/11/11 Sean Leather : > Is there a name for the following concept? Can you point me to any > references on it? > > Suppose I have the following two functions ... > >> swap1 :: (Int, Char) -> (Char, Int) >> swap2 :: (Char, Int) -> (Int, Char) > > ... and, for some reason, I think I can unify these into a single function. > I think, hmm, given that the structure is that same, let's do a first pass: > >> swap? :: (a, b) -> (c, d) > > But then I go back to the input types to confirm that this will work, and, > alas, it will not, because there are similarities that I missed. This is way > too general. I need to ensure that what's an Int stays an Int and likewise > for Char. > >> swap! :: (a, b) -> (b, a) > > And now I have found a type that is more general than swap1 and swap2 and > yet not so general that the shared constraints are left out. This seems > somewhat analogous to the least common multiple. > > Another example is the following: > >> showFloat :: Float -> String >> showBool :: Bool -> String > > We could say the more general type is ... > >> show? :: a -> String > > ... but then we lose the implied constraint that we must know something > about 'a' to produce a string. So, we add back such some such constraint: > >> show! :: (Show a) => a -> String > > Of course, with all of this, it may not be clear what to do about the > definitions of the functions, but I'm curious if there's a name for the > concept from a type perspective. > > Thanks, > Sean > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Eugene Kirpichov Web IR developer, market.yandex.ru From noteed at gmail.com Wed Nov 11 15:36:53 2009 From: noteed at gmail.com (minh thu) Date: Wed Nov 11 15:13:00 2009 Subject: [Haskell-cafe] "Least common supertype"? In-Reply-To: <5e0214850911111231w70f62809v511e962fd3d8c7db@mail.gmail.com> References: <3c6288ab0911111224g2f7cce72rdfd957b7af32b6f2@mail.gmail.com> <5e0214850911111231w70f62809v511e962fd3d8c7db@mail.gmail.com> Message-ID: <40a414c20911111236p1e76bf45h8acbaaa5fe5146c2@mail.gmail.com> Least Common Generalization. Cheers, Thu 2009/11/11 Eugene Kirpichov : > Is the name of the concept.... "Most general unifier" (MGU) ? (See: > Hindley-Milner type inference) > > 2009/11/11 Sean Leather : >> Is there a name for the following concept? Can you point me to any >> references on it? >> >> Suppose I have the following two functions ... >> >>> swap1 :: (Int, Char) -> (Char, Int) >>> swap2 :: (Char, Int) -> (Int, Char) >> >> ... and, for some reason, I think I can unify these into a single function. >> I think, hmm, given that the structure is that same, let's do a first pass: >> >>> swap? :: (a, b) -> (c, d) >> >> But then I go back to the input types to confirm that this will work, and, >> alas, it will not, because there are similarities that I missed. This is way >> too general. I need to ensure that what's an Int stays an Int and likewise >> for Char. >> >>> swap! :: (a, b) -> (b, a) >> >> And now I have found a type that is more general than swap1 and swap2 and >> yet not so general that the shared constraints are left out. This seems >> somewhat analogous to the least common multiple. >> >> Another example is the following: >> >>> showFloat :: Float -> String >>> showBool :: Bool -> String >> >> We could say the more general type is ... >> >>> show? :: a -> String >> >> ... but then we lose the implied constraint that we must know something >> about 'a' to produce a string. So, we add back such some such constraint: >> >>> show! :: (Show a) => a -> String >> >> Of course, with all of this, it may not be clear what to do about the >> definitions of the functions, but I'm curious if there's a name for the >> concept from a type perspective. >> >> Thanks, >> Sean >> >> _______________________________________________ >> 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 > From wei.hoo at gmail.com Wed Nov 11 15:39:01 2009 From: wei.hoo at gmail.com (Wei Hu) Date: Wed Nov 11 15:14:48 2009 Subject: [Haskell-cafe] Re: Long running Haskell program In-Reply-To: <877htxyqvo.fsf@ubuntu.domain> References: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> <877htxyqvo.fsf@ubuntu.domain> Message-ID: <71fd12e60911111239n29b0a658j24d008b3614a50bc@mail.gmail.com> I used to be a victim of GFW, so I can feel your pain. You may try to subscribe to http://leimy9.blogspot.com/feeds/posts/default in your Google Reader. In case that fails too, I've pasted the blog post below, with no images: I've been using Haskell in a serious way for about 2 years. Been using it in a professional sense about 1.5 years now in that, yes, I am one of the lucky ones that gets to use Haskell at work. The ride has been pretty smooth most of the time, as I've found that the type system especially helps me to rule out certain classes of bugs, easily test rather large chunks of programs as they're pure. The interpreter allows experimentation and iteration of ideas that can then be composed into the final compiled programs. All of this gives me a good deal of confidence that the code I'm writing is correct to some degree up front, something I've come to expect from functional programming languages over the years and greatly appreciate. However I've felt compelled to comment that things aren't always so smooth either. I spent the better part of a weekend and a Monday tracking down a space leak in a program that just was not allowed to leak space. I have a stack of a ReaderT StateT IO that I use to communicate with a device through a passthrough program that speaks CAN to a device for the purposes of creating a serial console connection where there is only a CAN bus. The Haskell program is responsible for the management of the data found at the other end o the serial connection and supports operations to the device through the serial channel via a simple text protocol while "forever" polling data on the serial endpoint. What I had done was the equivalent of pollerLoop :: Poller () pollerLoop = forever pollOnce Where Poller is my monad stack. pollOnce is defined as, pollOnce :: Poller () pollOnce = do checkCommandChannel -- see if there's a pending command to run executePoll Yes, this application is multi-threaded. I have a logger thread, a thread watching standard input of the program for queries and issuing commands to the endpoint. I have a thread per Poller, and the ability to poll devices simultaneously. The poller includes an implementation of my little "expect" syntax which was based on a naive implementation of hGetChar and checking for a desired result or timing out eventually. The really data inefficient version is a real screamer, beating the heck out of my Parsec or even ReadP version, but because of the way I wrote it, with a lot of reversing and prefix checking and substring slicing into temporary areas, it's not useful for large input blocks over a long time frame. Still it's so fast that it's appropriate for certain sections of code. I measured and verified this via space profiling to see the real runtime heap utilization (nice feature btw, I'd be dead without it right now I think). So what's the problem you're probably thinking? Well it turns out that since part of my state in StateT is a Data.Map, and that all my polling and parsing of expect-passing blocks caused updates to a Map, coupled with the language's default laziness caused a bit of a "bomb" of PAP (Partial APplications of functions). I had an ill-timed, project wise, discovery of a space leak. I tried sprinkling $! and seq all over the place, rewriting big chunks of code that used Text.Regex.Posix, to use Parsec and only got incremental improvements. The growth problem still existed, and would eventually exhaust memory. This was a real problem as this was an application that was not supposed to stop when the other conditions of the management system were ok. It could run for months or even years! I went through a whirlwind of emotions, and considered that perhaps I should be working a different job. Perhaps I could be a lion tamer? It turned out what I thought was a lion was really an anteater though... but that's literally a different story. It turns out that by looping not inside the monad, but over the execStateT/runReaderT expression I could pull all the state out, and then re-inject it into another execStateT/runReaderT each poll, which forced the strictness I needed on all state data, made the system respond faster, and best of all, not crash!!!! Diagrams below: This first one is the "before" picture. It shows the data growth by cost center in my code. As you can see things are getting worse almost linearly as I poll. This picture illustrates the result of pulling the state out of the Monad, and re-injecting it, forcing it to be evaluated. As you can see, I've got much more manageable memory utilization. This final one shows the new algorithm running with 2 threads, one spawned a few seconds into the run. You can see the initial burst of the fast but inefficient "expect" algorithm, followed by a much more regular memory utilization pattern. I'd like to thank all the folks on #haskell on FreeNode who gave me suggestions and hints to my vague problems regarding data growth and laziness vs strictness. Haskell's got a great user community and is probably one of the most helpful out there. One can learn a lot just asking questions of the right mentors as well as by reading haskell-cafe and the various blogs that are out there. I'm hoping that this anecdote is useful to someone. On Wed, Nov 11, 2009 at 11:20 AM, Andy Stewart wrote: > David Leimbach writes: > >> As some of you may know, I've been writing commercial Haskell code for a little bit here (about a >> year and a half) and I've just recently had to write some >> code that was going to run have to run for a really long time before being restarted, possibly >> months or years if all other parts of the system cooperate as >> it's part of a server infrastructure management system. >> >> I recently ran into some serious space leak difficulties that would ultimately cause this program to >> crash some time after startup (my simulator is also >> written in Haskell, and runs a LOT faster than the real application ever could, this has enabled me >> to fast forward a bit the data growth issues and crash >> in minutes instead of days!) >> >> Anyway, rather than try to paste it all here with images and such I thought I'd stick it up on my >> blog so others could maybe benefit from the anecdote. >> ?It's difficult to disclose enough useful information as it is commercial code not under an open >> source license, but there's neat diagrams and stuff there >> so hopefully the colors are at least amusing :-) >> >> http://leimy9.blogspot.com/2009/11/long-running-haskell-applications.html > Can you copy you blog at here? > http://leimy9.blogspot.com/2009/11/long-running-haskell-applications.html > is filter by GFW (http://en.wikipedia.org/wiki/Golden_Shield_Project) i > can't see it. > > About crash free program, you can consider multi-process design, keep > Simple and Stable core running in RootProcess, and Core module won't > crash, and make unstable module running in ChildProcess, if you occur > some un-catch exception from ChildProcess, just reboot those sub-module. > > I'm research some Haskell/Gtk+ program, sometimes > un-catch exception is unavoidable, multi-process is good chose to avoid > some exception crash all program. > > Cheers, > > ?-- Andy > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From noteed at gmail.com Wed Nov 11 15:42:56 2009 From: noteed at gmail.com (minh thu) Date: Wed Nov 11 15:19:02 2009 Subject: [Haskell-cafe] "Least common supertype"? In-Reply-To: <40a414c20911111236p1e76bf45h8acbaaa5fe5146c2@mail.gmail.com> References: <3c6288ab0911111224g2f7cce72rdfd957b7af32b6f2@mail.gmail.com> <5e0214850911111231w70f62809v511e962fd3d8c7db@mail.gmail.com> <40a414c20911111236p1e76bf45h8acbaaa5fe5146c2@mail.gmail.com> Message-ID: <40a414c20911111242j471b03bsd8aa0bc9cf055e3a@mail.gmail.com> For some reference, I found some definition for the lcg function in papers from [1]. In fact, I began to implement the type inference algorithm of System CT (the version of 1999, it has been revised since) and I have an implementation of lcg in that setting. I plan to upload the code to github; I can do it earlier than expected if you're interested. [1] http://homepages.dcc.ufmg.br/~camarao/ Cheers, Thu 2009/11/11 minh thu : > Least Common Generalization. > > Cheers, > Thu > > 2009/11/11 Eugene Kirpichov : >> Is the name of the concept.... "Most general unifier" (MGU) ? (See: >> Hindley-Milner type inference) >> >> 2009/11/11 Sean Leather : >>> Is there a name for the following concept? Can you point me to any >>> references on it? >>> >>> Suppose I have the following two functions ... >>> >>>> swap1 :: (Int, Char) -> (Char, Int) >>>> swap2 :: (Char, Int) -> (Int, Char) >>> >>> ... and, for some reason, I think I can unify these into a single function. >>> I think, hmm, given that the structure is that same, let's do a first pass: >>> >>>> swap? :: (a, b) -> (c, d) >>> >>> But then I go back to the input types to confirm that this will work, and, >>> alas, it will not, because there are similarities that I missed. This is way >>> too general. I need to ensure that what's an Int stays an Int and likewise >>> for Char. >>> >>>> swap! :: (a, b) -> (b, a) >>> >>> And now I have found a type that is more general than swap1 and swap2 and >>> yet not so general that the shared constraints are left out. This seems >>> somewhat analogous to the least common multiple. >>> >>> Another example is the following: >>> >>>> showFloat :: Float -> String >>>> showBool :: Bool -> String >>> >>> We could say the more general type is ... >>> >>>> show? :: a -> String >>> >>> ... but then we lose the implied constraint that we must know something >>> about 'a' to produce a string. So, we add back such some such constraint: >>> >>>> show! :: (Show a) => a -> String >>> >>> Of course, with all of this, it may not be clear what to do about the >>> definitions of the functions, but I'm curious if there's a name for the >>> concept from a type perspective. >>> >>> Thanks, >>> Sean >>> >>> _______________________________________________ >>> 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 >> > From nicolas.pouillard at gmail.com Wed Nov 11 15:53:26 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Wed Nov 11 15:29:12 2009 Subject: [Haskell-cafe] "Least common supertype"? In-Reply-To: <3c6288ab0911111224g2f7cce72rdfd957b7af32b6f2@mail.gmail.com> References: <3c6288ab0911111224g2f7cce72rdfd957b7af32b6f2@mail.gmail.com> Message-ID: <1257972614-sup-6074@peray> Excerpts from Sean Leather's message of Wed Nov 11 21:24:43 +0100 2009: > Is there a name for the following concept? Can you point me to any > references on it? > > Suppose I have the following two functions ... > > > swap1 :: (Int, Char) -> (Char, Int) > > swap2 :: (Char, Int) -> (Int, Char) > > ... and, for some reason, I think I can unify these into a single function. > I think, hmm, given that the structure is that same, let's do a first pass: > > > swap? :: (a, b) -> (c, d) > > But then I go back to the input types to confirm that this will work, and, > alas, it will not, because there are similarities that I missed. This is way > too general. I need to ensure that what's an Int stays an Int and likewise > for Char. > > > swap! :: (a, b) -> (b, a) In the literature this is also called anti-unification (anti-unifier). These techniques had been used for formalising some overloading systems. -- Nicolas Pouillard http://nicolaspouillard.fr From gcross at phys.washington.edu Wed Nov 11 16:14:56 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Wed Nov 11 15:50:57 2009 Subject: [Haskell-cafe] Sometimes pinned memory? Message-ID: Hey everyone! Do you have any suggestions for how I might allocate an aligned block of memory that I can pin while making foreign calls, but leave unpinned the rest of the time to potentially improve allocation and garbage collector performance? Or is this even a good idea? Thanks, Greg From dons at galois.com Wed Nov 11 16:18:49 2009 From: dons at galois.com (Don Stewart) Date: Wed Nov 11 15:54:37 2009 Subject: [Haskell-cafe] Sometimes pinned memory? In-Reply-To: References: Message-ID: <20091111211849.GJ23964@whirlpool.galois.com> gcross: > Hey everyone! Do you have any suggestions for how I might allocate an > aligned block of memory that I can pin while making foreign calls, but > leave unpinned the rest of the time to potentially improve allocation > and garbage collector performance? Or is this even a good idea? There's no pinned/unpinned memory. You have to pick one. * Use a ForeignPtr to allocate pinned memory (mallocForeignPtr) if you want it mostly poinned. Otherwise, you'll need to copy from unpinned to pinned. -- Don From phi500ac at yahoo.ca Wed Nov 11 16:26:03 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Wed Nov 11 16:01:48 2009 Subject: [Haskell-cafe] Problem with JHC In-Reply-To: <0C5D7C59-21E3-459C-B9B0-0DEF32BA21EA@z.odi.ac> Message-ID: <192721.36318.qm@web58804.mail.re1.yahoo.com> Hi, Ross. Ops, the paste is wrong, but the bug is real. I mean, if I try to run the program with the right input, the program aborts in the same place, with the same error message: philip@desktop:~/jhctut$ ./jtestarbo Give me a tree: T AND [L 1, L 2] jtestarbo_code.c:2670: case fell off Abortado In fact, it aborts in the same place for any input. This fact may help to discover where the trouble is: philip@desktop:~/jhctut$ ./jtestarbo Give me a tree: fdsfkldkl jtestarbo_code.c:2670: case fell off Abortado --- On Wed, 11/11/09, Ross Mellgren wrote: From: Ross Mellgren Subject: Re: [Haskell-cafe] Problem with JHC To: "Philippos Apolinarius" Cc: "Felipe Lessa" , haskell-cafe@haskell.org Received: Wednesday, November 11, 2009, 9:52 AM According to the paste you gave for the JHC test run: Here is what happens when I try to run it: philip@desktop:~/jhctut$ ./jtree Give me a tree: T AND (L 1, L 2) jtree_code.c:2670: case fell off Aborted You gave it parens not square brackets. -Ross On Nov 11, 2009, at 11:45 AM, Philippos Apolinarius wrote: > you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' > as the tree, right? Hi, Felipe. You are right. This means that I gave the correct input to the program. As you can see, I typed 'T AND [L 1, L 2]'. Therefore, JHC was expected to parse and print it. However, it failed to parse it. The program works perfectly well in GHC. Here is the GHC output: > philip@desktop:~/jhctut$ ghc tree.hs --make [1 of 1] Compiling Main???????????? ( tree.hs, tree.o ) Linking tree ... > philip@desktop:~/jhctut$ ./tree Give me a tree: T AND [L 1, L 2] T AND [L 1,L 2] --- On Wed, 11/11/09, Felipe Lessa wrote: From: Felipe Lessa Subject: Re: [Haskell-cafe] Problem with JHC To: haskell-cafe@haskell.org Received: Wednesday, November 11, 2009, 6:23 AM On Wed, Nov 11, 2009 at 04:32:05AM -0800, Philippos Apolinarius wrote: > data Op = AND | OR | NOT deriving (Show, Read) > data Tree= L Int | T Op [Tree] deriving (Show, Read)? Hmm, you see, > philip@desktop:~/jhctut$ ./jtree > Give me a tree: > T AND (L 1, L 2) > > jtree_code.c:2670: case fell off > Aborted you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' as the tree, right? -- Felipe. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe Get the name you've always wanted ! @ymail.com or @rocketmail.com._______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe __________________________________________________________________ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now http://ca.toolbar.yahoo.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/19c88f6b/attachment.html From bulat.ziganshin at gmail.com Wed Nov 11 16:31:16 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Nov 11 16:07:30 2009 Subject: [Haskell-cafe] Sometimes pinned memory? In-Reply-To: References: Message-ID: <1693152888.20091112003116@gmail.com> Hello Gregory, Thursday, November 12, 2009, 12:14:56 AM, you wrote: > Hey everyone! Do you have any suggestions for how I might allocate an > aligned block of memory that I can pin while making foreign calls, but > leave unpinned the rest of the time to potentially improve allocation > and garbage collector performance? Or is this even a good idea? if your call FFI function marked as unsafe, you may expect that memory block wouldn't moved across call. it's better to ask ghc gurus about details. just an example where memcpy used across non-pinned arrays: freezeSTUArray :: Ix i => STUArray s i e -> ST s (UArray i e) freezeSTUArray (STUArray l u n marr#) = ST $ \s1# -> case sizeofMutableByteArray# marr# of { n# -> case newByteArray# n# s1# of { (# s2#, marr'# #) -> case memcpy_freeze marr'# marr# (fromIntegral (I# n#)) of { IO m -> case unsafeCoerce# m s2# of { (# s3#, _ #) -> case unsafeFreezeByteArray# marr'# s3# of { (# s4#, arr# #) -> (# s4#, UArray l u n arr# #) }}}}} foreign import ccall unsafe "memcpy" memcpy_freeze :: MutableByteArray# s -> MutableByteArray# s -> CSize -> IO (Ptr a) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From gcross at phys.washington.edu Wed Nov 11 16:32:20 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Wed Nov 11 16:08:22 2009 Subject: [Haskell-cafe] Sometimes pinned memory? In-Reply-To: <20091111211849.GJ23964@whirlpool.galois.com> References: <20091111211849.GJ23964@whirlpool.galois.com> Message-ID: <242C75B1-1F07-40B4-9D0C-3162205D0296@phys.washington.edu> Thanks, Don. What made me think that this might be possible was the existence of Foreign.StablePtr, since that seems to take a Haskell expression and pin it down. Could this mechanism be harness to pin down arrays, or am I misunderstanding how it works? (Is StablePtr really just making a copy of the expression behind the scenes?) My motivation for this is that I will be sweeping back and forth along a data structure that is chain of memory blocks (essentially a pointed list), with ~ 10 to 1000 beads. At any given time I am only working with and updating one bead on the chain, so I am wondering if trying to use unpinned memory for the beads not in use would help by speeding up allocations and allowing the g.c. to rearrange their layout in memory. Each bead has a few memory chunks ranging from ~ 100 bytes to possibly up to tens of kilobytes, depending on a scaling parameter on my algorithm. Any thoughts? Cheers, Greg On Nov 11, 2009, at 1:18 PM, Don Stewart wrote: > gcross: >> Hey everyone! Do you have any suggestions for how I might allocate >> an >> aligned block of memory that I can pin while making foreign calls, >> but >> leave unpinned the rest of the time to potentially improve allocation >> and garbage collector performance? Or is this even a good idea? > > There's no pinned/unpinned memory. You have to pick one. > > * Use a ForeignPtr to allocate pinned memory (mallocForeignPtr) > > if you want it mostly poinned. Otherwise, you'll need to copy from > unpinned to pinned. > > > -- Don From dons at galois.com Wed Nov 11 16:35:19 2009 From: dons at galois.com (Don Stewart) Date: Wed Nov 11 16:11:05 2009 Subject: [Haskell-cafe] Sometimes pinned memory? In-Reply-To: <242C75B1-1F07-40B4-9D0C-3162205D0296@phys.washington.edu> References: <20091111211849.GJ23964@whirlpool.galois.com> <242C75B1-1F07-40B4-9D0C-3162205D0296@phys.washington.edu> Message-ID: <20091111213519.GM23964@whirlpool.galois.com> gcross: > Thanks, Don. What made me think that this might be possible was the > existence of Foreign.StablePtr, since that seems to take a Haskell > expression and pin it down. Could this mechanism be harness to pin down > arrays, or am I misunderstanding how it works? (Is StablePtr really just > making a copy of the expression behind the scenes?) That doesn't make the memory actually stable, it just keeps a dynamic association between a stable pointer and the actual memory address, so you can look up where a block of memory has moved to, keying only with a pointer-sized value. > My motivation for this is that I will be sweeping back and forth along a > data structure that is chain of memory blocks (essentially a pointed > list), with ~ 10 to 1000 beads. At any given time I am only working > with and updating one bead on the chain, so I am wondering if trying to > use unpinned memory for the beads not in use would help by speeding up > allocations and allowing the g.c. to rearrange their layout in memory. > Each bead has a few memory chunks ranging from ~ 100 bytes to possibly up > to tens of kilobytes, depending on a scaling parameter on my algorithm. If there are many small chunks, unpinned memory is better. Might be ok to copy into pinned memory for the foreign call. -- Don From phi500ac at yahoo.ca Wed Nov 11 16:36:05 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Wed Nov 11 16:11:51 2009 Subject: [Haskell-cafe] Opinion about JHC In-Reply-To: <20091111083759.GH21564@sliver.repetae.net> Message-ID: <683909.34243.qm@web58802.mail.re1.yahoo.com> Hi, John. I am sending you this second email because the first one has a worng paste.? However, if I use the right input, I gent the same error. In fact, it gives exactly the same error for any input, right or wrong.? {- file: tree.hs -} {- compile: jhc tree.hs -dc -o jtree } import System (getArgs) import System.IO import IO ? data Op = AND | OR | NOT deriving (Show, Read) ??? data Tree= L Int | T Op [Tree] deriving (Show, Read)? ? main= do ? putStrLn "Give me a tree:" ? s <- getLine ? let xx= read s ? putStrLn (show (xx::Tree)) ??? Here is what happens when I try to run it: philip@desktop:~/jhctut$ ./jtree Give me a tree: T AND [L 1, L 2] jtree_code.c:2670: case fell off Aborted It gives the same error for any input: philip@desktop:~/jhctut$ ./jtestarbo Give me a tree: fdsfkldkl jtestarbo_code.c:2670: case fell off Abortado It seems that the problem is in the Read class, since it works if I use the Show class only: import System (getArgs) import System.IO import IO ? data Op = AND | OR | NOT deriving (Show, Read) ??? data Tree= L Int | T Op [Tree] deriving (Show, Read)? ? main= do ? putStrLn "Give me a tree:" ? s <- getLine ? let xx= T AND [L 1, L 2] ? putStrLn (show (xx::Tree)) I hope you can fix it. --- On Wed, 11/11/09, John Meacham wrote: From: John Meacham Subject: Re: [Haskell-cafe] Opinion about JHC To: haskell-cafe@haskell.org Received: Wednesday, November 11, 2009, 1:37 AM On Tue, Nov 10, 2009 at 07:41:54PM -0800, Philippos Apolinarius wrote: > I discovered a Haskell compiler that generates very small and fast > code. In fact, it beats Clean. It has the following properties: Excellent. that was my goal ;) > 1 --- One can cross-compile programs easily. For instance, here is how I generated code for Windows: > > jhc --cross -mwin32 genetic.hs -o genetic Yup. This was a major goal. compiling for iPhones and embedded arches is just as easy assuming you have a gcc toolchain set up. (at least with the hacked iPhone SDK.. I have never tried it with the official one) > > 2 -- It seems to be quite complete. > > 3 -- However, it often compiles a file, but the program fails to run. > > I have the following questions about it: > > 1 -- How active is the team who is writing the JHC compiler? Hi, I am the main contributor, but others are welcome and several have made signifigant contributions. Development tends to be spurty. A lot of work will get done in a short amount of time, this generally corresponds to when an external contributor gets involved and the back and forth helps stimulate patches on my part to complement theirs. Although I have not been able to devote a lot of my time to jhc in the past, hopefully this will change in the not to distant future and I will be able to work on it full time. > 2 -- Is it complete Haskell? The author claims that it is; it compiled > all programs that I wrote, but that does not mean much, because my > programs are quite simple. It does Haskell 98 and several extensions, which is pretty much what GHC does. However, it does not implement the same set of extensions as GHC so this causes issues as a lot of people use GHC extensions extensively. I plan on supporting all of Haskell' of course, and the popular GHC extensions to help compatibility. Not all are implemented. > 3 -- Why the Haskell community almost never talks about JHC? Part of it is that I am not very good at advocacy. I don't always post announcements on the main haskell lists figuring the interested parties are on the jhc list already. I do try to make jhc good, fast, and usable, I always hoped someone better at advocacy than me would join the project :) In truth, I think the spurty nature of development also affects this, the list will be quite for a long time with a flurry of development lasting a few weeks occasionally inspiring some discussion in the other groups. In any case, I am glad you liked what you found! please join the mailing list for jhc if you are interested in its development or using it. ? ? ? ? John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe __________________________________________________________________ Ask a question on any topic and get answers from real people. Go to Yahoo! Answers and share what you know at http://ca.answers.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/f1b82dbd/attachment.html From lemming at henning-thielemann.de Wed Nov 11 16:39:54 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Nov 11 16:13:22 2009 Subject: [Haskell-cafe] Re: What's the deal with Clean? In-Reply-To: <5fdc56d70911080057j6e0c9b13k3e86a9d6bb913ee5@mail.gmail.com> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <1BFBEDAF-236D-4645-A0C2-8A7AB83FD213@swierstra.net> <5fdc56d70911080057j6e0c9b13k3e86a9d6bb913ee5@mail.gmail.com> Message-ID: <4AFB2F2A.9090701@henning-thielemann.de> Stephen Tetley schrieb: > Why speak nonsense when you can test it? > > // ---------------------------------------------------------------------------- > > module nonsense > > import StdEnv > > nonsense = map ((^) 2) > > Start = nonsense [1,2,3] > > // ---------------------------------------------------------------------------- > > .... Running gives: > > [2,4,8] I think they wanted square numbers, not powers of two. From lemming at henning-thielemann.de Wed Nov 11 16:57:15 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Nov 11 16:33:02 2009 Subject: [Haskell-cafe] a problem defining a monad instance In-Reply-To: <20091106180809.GA20150@pudlak.name> References: <20091106180809.GA20150@pudlak.name> Message-ID: On Fri, 6 Nov 2009, Petr Pudlak wrote: > Hi all, > > (This is a literate Haskell post.) > > I've encountered a small problem when trying to define a specialized > monad instance. Maybe someone will able to help me or to tell me that > it's impossible :-). > > To elaborate: I wanted to define a data type which is a little bit > similar to the [] monad. Instead of just having a list of possible > outcomes of a computation, I wanted to have a probability associated > with each possible outcome. http://hackage.haskell.org/package/probability > A natural way to define such a structure is to use a map from possible > values to numbers, let's say Floats: > >> module Distribution where >> >> import qualified Data.Map as M >> >> newtype Distrib a = Distrib { undistrib :: M.Map a Float } > > Defining functions to get a monad instance is not difficult. > "return" is just a singleton: > >> dreturn :: a -> Distrib a >> dreturn k = Distrib (M.singleton k 1) > > Composition is a little bit more difficult, but the functionality is > quite natural. (I welcome suggestions how to make the code nicer / more > readable.) However, the exact definition is not so important. > >> dcompose :: (Ord b) => Distrib a -> (a -> Distrib b) -> Distrib b >> dcompose (Distrib m) f = Distrib $ M.foldWithKey foldFn M.empty m >> where >> foldFn a prob umap = M.unionWith (\psum p -> psum + prob * p) umap (undistrib $ f a) > > The problem is the (Ord b) condition, which is required for the Map > functions. When I try to define the monad instance as This won't work and is the common problem of a Monad instance for Data.Set. http://www.randomhacks.net/articles/2007/03/15/data-set-monad-haskell-macros There is however an idea of how to solve this using existential quantification and type families: http://code.haskell.org/~thielema/category-constrained/src/Control/Constrained/Monad.hs From stephen.tetley at gmail.com Wed Nov 11 16:57:45 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Wed Nov 11 16:33:32 2009 Subject: [Haskell-cafe] Re: What's the deal with Clean? In-Reply-To: <4AFB2F2A.9090701@henning-thielemann.de> References: <7b501d5c0911031230r495dddc3jf112cfc3c64f66e4@mail.gmail.com> <1BFBEDAF-236D-4645-A0C2-8A7AB83FD213@swierstra.net> <5fdc56d70911080057j6e0c9b13k3e86a9d6bb913ee5@mail.gmail.com> <4AFB2F2A.9090701@henning-thielemann.de> Message-ID: <5fdc56d70911111357t6ffc32der2bc93d5be4433fe4@mail.gmail.com> Hi Henning I spotted that (and also that Clean doesn't have sections) after my blood pressure returned to normal. Best wishes Stephen >> >> [2,4,8] > > I think they wanted square numbers, not powers of two. > > From hyangfji at gmail.com Wed Nov 11 17:45:28 2009 From: hyangfji at gmail.com (Hong Yang) Date: Wed Nov 11 17:21:16 2009 Subject: [Haskell-cafe] looking for a good algorithm In-Reply-To: <4AFADA02.1010400@rwth-aachen.de> References: <4AFADA02.1010400@rwth-aachen.de> Message-ID: Thanks. I actually prototyped in Perl the SA method intuitively (though I do not know its name). But it is way slow. So I want to improve the speed by means of both algorithm and language. Hong On Wed, Nov 11, 2009 at 9:36 AM, Tillmann Vogt wrote: > Hong Yang schrieb: > > The question is more about algorithm than Haskell. But I am going to code >> in >> Haskell which I am still learning. >> >> Suppose I have a large table, with hundreds of columns and thousands of >> rows. But not every cell has a value (of String, or Int, or Double type). >> >> I want to shuffle the rows to maximize the number of columns whose first >> 100 >> rows have at least one number, given a list of preferred column names >> since >> there is no guarantee that every number column will have at least one >> number >> in its first 100 rows after shuffling. >> >> Can someone provide a good algorithm for this problem? (I do not have any >> background in algorithms.) You can assume I already know which columns are >> of Int or Double type. >> > > I would say it depends on the distribution of values in the table. If there > are rows with a lot of values and rows with few values, then I would first > sort the rows after the number of cells with values. If you look at all the > columns and the number of values for each row is unique then it would be > perfectly solved. With a list of preferred columns and also a uniform > distribution the problem might be hard (NP-complete?), but these hard > problems can often be approximated, i.e with simulated annealing, which in > short is switching two rows repeatedly as long as the result improves. > > > >> This is not a homework. >> Thanks, >> >> Hong >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/e1b6542e/attachment.html From hectorg87 at gmail.com Wed Nov 11 17:48:10 2009 From: hectorg87 at gmail.com (Hector Guilarte) Date: Wed Nov 11 17:25:13 2009 Subject: [Haskell-cafe] Tabla de calculo de dolares viajero CADIVI In-Reply-To: References: <5B72DF7006066246958A68F83D29AF1A301121@mail.iesa.edu.ve> Message-ID: <69630b260911111448tce51ef0r51c87f0719c6588a@mail.gmail.com> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/jpeg Size: 103427 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091111/ad4a9bdc/attachment-0001.jpe From thomas.dubuisson at gmail.com Wed Nov 11 17:50:21 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Wed Nov 11 17:26:14 2009 Subject: [Haskell-cafe] Problem with JHC In-Reply-To: <192721.36318.qm@web58804.mail.re1.yahoo.com> References: <0C5D7C59-21E3-459C-B9B0-0DEF32BA21EA@z.odi.ac> <192721.36318.qm@web58804.mail.re1.yahoo.com> Message-ID: <4c44d90b0911111450q2c9b7f82l8297ed44c9635015@mail.gmail.com> Like paolino, I did a couple tests and found: > data TreeX = Leaf Int | NotLeaf Int deriving (Show, Read) ??? [tommd@Mavlo Test]$ ./jtree ??? Give me a tree: ??? Leaf 5 ??? jtree_code.c:2572: case fell off ??? Aborted ??? [tommd@Mavlo Test]$ ./jtree ??? Give me a tree: ??? NotLeaf ??? jtree_code.c:2572: case fell off ??? Aborted So the read for that does not work... but surprisingly... > data TreeX = Leaf Int | NotLeaf deriving (Show, Read) Dropping the Int from the second constructor works (ignore the constructor names, they are just place-holders). ??? [tommd@Mavlo Test]$ ./jtree ??? Give me a tree: ??? Leaf 43 ??? Leaf 43 ??? [tommd@Mavlo Test]$ ./jtree ??? Give me a tree: ??? NotLeaf ??? NotLeaf --- OTHER TESTS --- 1) data TreeX = Leaf | NotLeaf 5 deriving (Show, Read) Another unfortunate bug is that reversing the constructors (having Leaf as a nullary constructor and NotLeaf taking an Int) causes compilation to fail (using jhc-0.7.2-0). 2) data TreeX = Leaf Int | NotLeaf Int | OoopsLeaf deriving (Show, Read) Works fine - notice it ends with a nullary constructor... Hypothesis 1: All working Read derivations have data declarations with a nullary constructor at the end. 3) data TreeX = Leaf Int | NotLeaf | OoopsLeaf Int deriving (Show, Read) Fails in with 'case fell off', so H1 seems good 4) data TreeX = Leaf Int | NotLeaf | OoopsLeaf deriving (Show, Read) Works. 5) data TreeX = Leaf | NotLeaf | OoopsLeaf Int deriving (Show, Read) Fails to compile. Hypothesis 2: All working Read derivations that don't cause compile issues have data declarations with non-nullary first constructors. Cheers, Thomas From ok at cs.otago.ac.nz Wed Nov 11 17:57:39 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Wed Nov 11 17:33:31 2009 Subject: [Haskell-cafe] "Least common supertype"? In-Reply-To: <3c6288ab0911111224g2f7cce72rdfd957b7af32b6f2@mail.gmail.com> References: <3c6288ab0911111224g2f7cce72rdfd957b7af32b6f2@mail.gmail.com> Message-ID: <54A1331D-E042-43D7-AAE4-335113AB30A1@cs.otago.ac.nz> On Nov 12, 2009, at 9:24 AM, Sean Leather wrote: > Is there a name for the following concept? [Generalising from (Int, Char) -> (Char, Int) (Char, Int) -> (Int, Char) to (x, y ) -> (y, x )] It's the "least specific generalisation", also known as anti- unification. (Because unification finds the most general specialisation.) As far as I know, it originated in this paper: Gordon D. Plotkin. A Note on Inductive Generalization. In B. Meltzer and D. Michie, editors, Machine Intelligence, volume 5, pages 153-163. Elsevier North-Holland, New York, 1970. More precisely, with the type constraints, it's sorted anti-unification. http://www.dfki.uni-kl.de/dfkidok/publications/TM/94/04/abstract.html might be worth a look. From caseyh at istar.ca Wed Nov 11 18:32:35 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Wed Nov 11 18:08:14 2009 Subject: [Haskell-cafe] looking for a good algorithm In-Reply-To: References: <4AFADA02.1010400@rwth-aachen.de> Message-ID: So, as I understand it, you have a very large sparse table, thousands of rows and hundreds of columns, of which each cell within a column of type String, Int, or Double can contain one of those types or nothing. Then you to want to shuffle the rows to maximize the number of columns whose first 100 rows have at least one number (Int or Double), given a list of preferred column names since there is no guarantee that every number column will have at least one number in its first 100 rows after shuffling. I'm wondering about hashing on the rows and hashing on the columns, then the column hash has the number of Int's or Double's (don't need the String's) in that column and the rows they are in. The row hash would have the number of Int's and Double's in that row and what column's they are in. Then; Then scan the row hash and sort into descending order, and by tagging those rows, not by actually moving them. Then I think your ready for simmulated annealing. -- Regards, Casey From z_axis at 163.com Wed Nov 11 19:24:16 2009 From: z_axis at 163.com (zaxis) Date: Wed Nov 11 19:00:00 2009 Subject: [Haskell-cafe] What does the `forall` mean ? Message-ID: <26311291.post@talk.nabble.com> import Text.ParserCombinators.Parsec data PermParser tok st a = Perm (Maybe a) [Branch tok st a] data Branch tok st a = forall b. Branch (PermParser tok st (b -> a)) (GenParser tok st b) I have hoogled the `forall` but i cannot find any appropriate answer! thanks! ----- fac n = foldr (*) 1 [1..n] -- View this message in context: http://old.nabble.com/What-does-the-%60forall%60-mean---tp26311291p26311291.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From jfredett at gmail.com Wed Nov 11 19:27:58 2009 From: jfredett at gmail.com (Joe Fredette) Date: Wed Nov 11 19:03:45 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <26311291.post@talk.nabble.com> References: <26311291.post@talk.nabble.com> Message-ID: <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> Forall means the same thing as it means in math, it means "for any type -- call it `b` -- then the type of the following it `Branch (PermParser tok st (b -> a)`" `tok`, `st` and `a` are all given by the declaration of the datatype itself. Hope that makes sense, /Joe On Nov 11, 2009, at 7:24 PM, zaxis wrote: > > import Text.ParserCombinators.Parsec > > data PermParser tok st a = Perm (Maybe a) [Branch tok st a] > data Branch tok st a = forall b. Branch (PermParser tok st (b -> > a)) > (GenParser tok st b) > > I have hoogled the `forall` but i cannot find any appropriate answer! > > thanks! > > ----- > fac n = foldr (*) 1 [1..n] > -- > View this message in context: http://old.nabble.com/What-does-the-%60forall%60-mean---tp26311291p26311291.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 From haskell at gimbo.org.uk Wed Nov 11 19:43:55 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Wed Nov 11 19:19:47 2009 Subject: [Haskell-cafe] ANNOUNCE: simple-observer-0.0.1, a simple implementation of the observer design pattern Message-ID: <4FC69D8D-88CD-4A7B-B793-7483876B0B05@gimbo.org.uk> Hi all, Further to earlier discussion on this topic, I've just released a first version of this package to hackage: http://hackage.haskell.org/package/simple-observer It is a fairly simple implementation of subject/observer which I've recently used to good effect in an GUI written using wxHaskell. Here's a blog post discussing it further and giving a simple example of use: http://gimbo.org.uk/blog/2009/11/12/simple-observers-in-haskell/ Many thanks for the earlier comments, even if they haven't resulted in any changes (yet?). Best regards, -Andy From qdunkan at gmail.com Wed Nov 11 20:02:17 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Wed Nov 11 19:38:03 2009 Subject: [Haskell-cafe] faster compiling for ghc Message-ID: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> Recently the "go" language was announced at golang.org. There's not a lot in there to make a haskeller envious, except one real big one: compilation speed. The go compiler is wonderfully speedy. Anyone have any tips for speeding up ghc? Not using -O2 helps a lot. I spend a lot of time linking (ghc api drags in huge amounts of ghc code) and I'm hoping the new dynamic linking stuff will speed that up. I suppose it should be possible to run the whole thing under the bytecode compiler, and this works fine for rerunning tests, I can just stay in ghci, make changes, :r and rerun, but it runs into trouble as soon as code wants to link in foreign C. I also recently discovered -fobject-code, which indeed starts compiling right away, cutting out the ghc startup overhead. However, it doesn't appear to help with the final link, so I wind up having to reinvoke ghc anyway. According to Rob Pike, the main reason for 6g's speed is that in a dependency tree where A depends on B depends on C, the interface for B will pull up all the info needed from C. So compiling A only needs to look at B. Would it help ghc at all if it did the same with hi files? I've heard that ghc does more cross module inlining than your typical imperative language, but with optimization off maybe we can ignore all that? I've seen various bits of noise about supporting parallel builds with --make and it seems to involve making the whole compiler re-entrant which is non-trivial. Would it be simpler to parallelize pure portions of the compilation, say with parallel strategies? Or just start one ghc per core and have a locking scheme so they don't step on each others files? From jason.dusek at gmail.com Wed Nov 11 20:26:13 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Nov 11 20:01:58 2009 Subject: [Haskell-cafe] Medical Instruments -> Jason In-Reply-To: <169680.94092.qm@web58803.mail.re1.yahoo.com> References: <42784f260911101209nca238f3rea1decb75356ffb9@mail.gmail.com> <169680.94092.qm@web58803.mail.re1.yahoo.com> Message-ID: <42784f260911111726u260c38dan7b03af357b9eb2c5@mail.gmail.com> First of all, I find it striking that you are using the declaration: ?foreign import ccall unsafe "rs232.h closecport" c_closecport :: CInt -> CInt and that it actually works. I would think the only workable declaration would be: ? foreign import stdcall unsafe "rs232.h closecport" closecport :: IO () You've tried the signature with `stdcall` and `IO ()` and it doesn't work at all? Likewise, your signature for `c_sendmsg` strikes me as perilous. It should result in a value in `IO`. However, let's ignore all that for now. I wonder, does the Haskell always call `closecport`? Maybe you could put in a print statement in the C to find out? -- Jason Dusek From dpiponi at gmail.com Wed Nov 11 20:41:01 2009 From: dpiponi at gmail.com (Dan Piponi) Date: Wed Nov 11 20:16:47 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <26311291.post@talk.nabble.com> References: <26311291.post@talk.nabble.com> Message-ID: <625b74080911111741n310f3610lf3be271e3021dc32@mail.gmail.com> On Wed, Nov 11, 2009 at 4:24 PM, zaxis wrote: > data Branch tok st a ? ? = forall b. Branch (PermParser tok st (b -> a)) > (GenParser tok st b) > > I have hoogled the `forall` but i cannot find any appropriate answer! That's an example of an existential type. What that line is saying is that for any type b (ie. for all b) that you could pick, the constructor called 'Branch' can take something of type 'PermParser tok st (b -> a)' and something of type 'GenParser tok st b' and make something of type 'Branch tok st a' out of it. The reason it's called an existential type is something like this: once you've constructed your thing of type 'Branch tok st a' you've lost the information about what the type b was. So all you know is that inside your thing is a pair of objects of type 'PermParser tok st (b -> a)' and 'GenParser tok st b' but you don't know what b is. All you know is that there exists some type 'b' that it was made of. To use these types with ghc you need to use the compilation flag -XExistentialQuantification. There's more to be found here: http://www.haskell.org/haskellwiki/Existential_type -- Dan From s.clover at gmail.com Wed Nov 11 22:00:04 2009 From: s.clover at gmail.com (sterl) Date: Wed Nov 11 21:30:57 2009 Subject: [Haskell-cafe] "Least common supertype"? In-Reply-To: <54A1331D-E042-43D7-AAE4-335113AB30A1@cs.otago.ac.nz> References: <3c6288ab0911111224g2f7cce72rdfd957b7af32b6f2@mail.gmail.com> <54A1331D-E042-43D7-AAE4-335113AB30A1@cs.otago.ac.nz> Message-ID: <4AFB7A34.6000903@gmail.com> Richard O'Keefe wrote: > On Nov 12, 2009, at 9:24 AM, Sean Leather wrote: >> Is there a name for the following concept? > [Generalising from > (Int, Char) -> (Char, Int) > (Char, Int) -> (Int, Char) > to (x, y ) -> (y, x )] > > It's the "least specific generalisation", also known as anti-unification. > (Because unification finds the most general specialisation.) > As far as I know, it originated in this paper: > Gordon D. Plotkin. A Note on Inductive Generalization. In B. Meltzer > and D. Michie, editors, Machine Intelligence, volume 5, pages 153-163. > Elsevier North-Holland, New York, 1970. IANTT (I am not a type theorist) but... If you're talking about supertypes and subtypes, then I think this can be classified as a "least upper bound". I.e. if there is a function that is used in both the first and second context provided, then one can infer that its constraints must satisfy both signatures. To then unify the signatures, construct a supertype which by definition both must satisfy. Eventually (when you know the constraints are fully saturated), you can then unify the supertype constraints by taking the least upper bound -- which, by contravariance, is the greatest lower bound of the input and the least upper bound of the output. The greatest lower bound of the inputs will enforce parametricity because the only common subtype of Int and Char is bottom. The least upper bound of the output is then trivial. --S From daniel.is.fischer at web.de Wed Nov 11 22:47:52 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Nov 11 22:25:04 2009 Subject: [Haskell-cafe] Package Woes Message-ID: <200911120447.52860.daniel.is.fischer@web.de> Sorry, slightly off-topic. I wanted to install LHC to compare that to GHC and JHC, but alas: dafis@linux-mkk1:~/Haskell/LHC/lhc-0.8> cabal install -fwith-libs -flhc-regress Resolving dependencies... Configuring libffi-0.1... cabal: The pkg-config package libffi is required but it could not be found. cabal: Error: some packages failed to install: lhc-0.8 depends on libffi-0.1 which failed to install. libffi-0.1 failed during the configure step. The exception was: exit: ExitFailure 1 Okay, so I installed libffi, but to no avail, still can't find libffi. The problem is apparently that libffi doesn't come with a .pc file, so pkg-config doesn't know about it. Does anybody know how to fix that? (openSuse 11.1, if that matters) From daniel.is.fischer at web.de Wed Nov 11 22:58:54 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Nov 11 22:36:05 2009 Subject: [Haskell-cafe] Problem with JHC In-Reply-To: <4c44d90b0911111450q2c9b7f82l8297ed44c9635015@mail.gmail.com> References: <0C5D7C59-21E3-459C-B9B0-0DEF32BA21EA@z.odi.ac> <192721.36318.qm@web58804.mail.re1.yahoo.com> <4c44d90b0911111450q2c9b7f82l8297ed44c9635015@mail.gmail.com> Message-ID: <200911120458.55000.daniel.is.fischer@web.de> Am Mittwoch 11 November 2009 23:50:21 schrieb Thomas DuBuisson: > Like paolino, I did a couple tests and found: > > > So the read for that does not work... but surprisingly... > > > data TreeX = Leaf Int | NotLeaf deriving (Show, Read) > > Dropping the Int from the second constructor works (ignore the > constructor names, they are just place-holders). > > > --- OTHER TESTS --- > 1) data TreeX = Leaf | NotLeaf 5 deriving (Show, Read) > Another unfortunate bug is that reversing the constructors (having > Leaf as a nullary constructor and NotLeaf taking an Int) causes > compilation to fail (using jhc-0.7.2-0). > > 2) data TreeX = Leaf Int | NotLeaf Int | OoopsLeaf deriving (Show, Read) > > Works fine - notice it ends with a nullary constructor... > Hypothesis 1: All working Read derivations have data declarations with > a nullary constructor at the end. Must be something like that, it also dies badly reading Either (but reading integers works): module Main where a, n :: Either Int Char a = Right 'a' n = Left 4 sa = "Right 'a'" sn = "Left 4" main :: IO () main = do putStrLn "Showing:" print (sa == show a) print (sn == show n) putStrLn "Reading:" print (read "123" :: Integer) print (a == read sa) print (n == read sn) results in $ ./veither Showing: True True Reading: 123 veither_code.c:3642: case fell off $ jhc --version jhc 0.7.2 (0.7.2-0) compiled by ghc-6.10 on a i386 running linux > > Cheers, > Thomas From jmillikin at gmail.com Wed Nov 11 23:57:43 2009 From: jmillikin at gmail.com (John Millikin) Date: Wed Nov 11 23:33:28 2009 Subject: [Haskell-cafe] ANNOUNCE: dbus-core 0.6 and dbus-client 0.2 Message-ID: <3283f7fe0911112057r7f18567bk536627046b6865ca@mail.gmail.com> This is the second public release of my D-Bus implementation. dbus-core is an implementation of the D-Bus protocol, and dbus-client is a set of wrappers and utility computations to simplify writing basic clients. Interesting changes to dbus-core ================================ * Performance improvements: sending and receiving large structures should now be significantly faster. My thanks and appreciation go to Bryan O'Sullivan, whose excellent Criterion library made benchmarking the serialisation code much easier than it had any right to be. * Better support for byte arrays: byte strings (strict and lazy) are now directly supported types, with special cases to avoid most conversion overhead. * Implemented the TCP/IP transport, though it's untested because I can't figure out how to make the server listen on a socket. If anybody cares about remote D-Bus, and this doesn't work, drop me a mail with your configuration and I'll find out why. * Added module to represent "match rules", required for full signal support. * Added module for name reservations -- this is really just moving the bulk of the code from dbus-client into dbus-core, where it belongs. * Fixed possible concurrency issue when receiving messages from a connection in multiple threads. This is still a really bad idea, and it will never work correctly, but at least now it won't corrupt the connection state. Interesting changes to dbus-client ================================== * Fixed dumb signature to mkClient (thanks, Max). Its purpose should now be more obvious. * Shifted around some of the method call APIs -- it's now possible to send method calls without a proxy. * Uses the new MatchRule work to fully support receiving signals. Documentation ============= PDFs of the source; these are the most useful and complete documentation currently available: https://dl.dropbox.com/u/1947532/dbus-core_0.6.pdf https://dl.dropbox.com/u/1947532/dbus-client_0.2.pdf An API listing is also available, good for a quick overview: https://dl.dropbox.com/u/1947532/dbus-core_0.6/index.html https://dl.dropbox.com/u/1947532/dbus-client_0.2/index.html Hackage is currently experiencing some dependency conflicts with the "bytestring" library[1], so it's not generating its own documentation. I'll keep the dropbox pages up until Hackage is in a more usable state. Downloads ========= Available from the usual places: http://hackage.haskell.org/packages/archive/dbus-core/0.6/dbus-core-0.6.tar.gz http://hackage.haskell.org/packages/archive/dbus-client/0.2/dbus-client-0.2.tar.gz [1] "binary" uses bytestring-0.9.1.4, "text" uses bytestring-0.9.1.5, kaboom From bulat.ziganshin at gmail.com Thu Nov 12 01:18:17 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Nov 12 00:57:56 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> Message-ID: <293882077.20091112091817@gmail.com> Hello Evan, Thursday, November 12, 2009, 4:02:17 AM, you wrote: > Recently the "go" language was announced at golang.org. There's not a > lot in there to make a haskeller envious, except one real big one: > compilation speed. The go compiler is wonderfully speedy. are you seen hugs, for example? i think that ghc is slow because it's written in haskell and compiled by itself hugs provides good interactive environment and good ghc compatibility, you can use conditional compilation to hide remaining differences. unfortunately, many haskell libs doesn't support hugs -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From wren at freegeek.org Thu Nov 12 02:17:41 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu Nov 12 01:53:30 2009 Subject: [Haskell-cafe] (state) monad and CPS In-Reply-To: <1257947674-sup-3822@peray> References: <1257947674-sup-3822@peray> Message-ID: <4AFBB695.4060605@freegeek.org> Nicolas Pouillard wrote: > Excerpts from jean-christophe mincke's message of Tue Nov 10 21:18:34 +0100 2009: >> do acc <- get >> put (acc+1) >> ... > > Since this pattern occurs often 'modify' is a combination of get and put: > > do modify (+1) > ... Though the caveat about laziness applies here as well. modify is famously lazy which can lead to space leaks and stack overflows. Better would be to define and use your own strict version: modify' f = get >>= \x -> put $! f x -- Live well, ~wren From dav.vire+haskell at gmail.com Thu Nov 12 02:22:41 2009 From: dav.vire+haskell at gmail.com (David Virebayre) Date: Thu Nov 12 01:58:26 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: <293882077.20091112091817@gmail.com> References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> <293882077.20091112091817@gmail.com> Message-ID: <4c88418c0911112322n6c4ed4bfp34a504ea68c624cf@mail.gmail.com> On Thu, Nov 12, 2009 at 7:18 AM, Bulat Ziganshin wrote: > > Hello Evan, > > Thursday, November 12, 2009, 4:02:17 AM, you wrote: > > > Recently the "go" language was announced at golang.org. ?There's not a > > lot in there to make a haskeller envious, except one real big one: > > compilation speed. ?The go compiler is wonderfully speedy. > > are you seen hugs, for example? i think that ghc is slow because it's > written in haskell and compiled by itself If I understood, Evan is interested in ideas to speed up compilation. As far as I know, hugs is an interpreter, not a compiler. From magicloud.magiclouds at gmail.com Thu Nov 12 02:32:22 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Thu Nov 12 02:08:08 2009 Subject: [Haskell-cafe] Problem about hidden package again. Message-ID: <3bd412d40911112332y48b72175lf2f3d7e0d04b6686@mail.gmail.com> Hi, Today, when I compiled gtk2hs, I got this: cairo/Graphics/Rendering/Cairo.hs.pp:264:0: Failed to load interface for `Data.Array.Base': it is a member of the hidden package `array-0.2.0.0' Use -v to see a list of the files searched for. As usual, I searched for the resolvement. No luck. And seems like this problem (not particularly to this package) is very common. I wonder how to resolve it? -- ??????? ??????? From permeakra at gmail.com Thu Nov 12 02:33:07 2009 From: permeakra at gmail.com (=?KOI8-R?B?5dfHxc7JyiDwxdLN0cvP1w==?=) Date: Thu Nov 12 02:08:54 2009 Subject: [Haskell-cafe] lambda-bot installation problem: gentoo trickery problem Message-ID: When I try cabal-install lambdabot (gentoo linux/amd64, ghc installed with portage), it runs fine until compiler tries to link readline package (some template haskell?). The problem caused by dirty trick, used in gentoo: the /usr/lib64/libreadline is a fake with script, redirecting ld to /lib64 . GHC is not redirected but simply fails with message "can't load .so/.DLL for: readline (/usr/lib64/libreadline.so: invalid ELF header)". So, the question is: is there any workaround? Copying library look like an option, but it is very, very dirty one. Is there a way to say ghc, which libreadline.so it should load? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091112/d4af3c58/attachment.html From wren at freegeek.org Thu Nov 12 02:36:01 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu Nov 12 02:11:47 2009 Subject: [Haskell-cafe] "Least common supertype"? In-Reply-To: <4AFB7A34.6000903@gmail.com> References: <3c6288ab0911111224g2f7cce72rdfd957b7af32b6f2@mail.gmail.com> <54A1331D-E042-43D7-AAE4-335113AB30A1@cs.otago.ac.nz> <4AFB7A34.6000903@gmail.com> Message-ID: <4AFBBAE1.9090206@freegeek.org> sterl wrote: > Richard O'Keefe wrote: >> On Nov 12, 2009, at 9:24 AM, Sean Leather wrote: >>> Is there a name for the following concept? >> [Generalising from >> (Int, Char) -> (Char, Int) >> (Char, Int) -> (Int, Char) >> to (x, y ) -> (y, x )] >> >> It's the "least specific generalisation", also known as anti-unification. >> (Because unification finds the most general specialisation.) >> As far as I know, it originated in this paper: >> Gordon D. Plotkin. A Note on Inductive Generalization. In B. Meltzer >> and D. Michie, editors, Machine Intelligence, volume 5, pages 153-163. >> Elsevier North-Holland, New York, 1970. > > IANTT (I am not a type theorist) but... > > If you're talking about supertypes and subtypes, then I think this can > be classified as a "least upper bound". It is a least upper bound, but only in a particular sense. The particular sense is (of course) anti-unification. To strike to the core of why it's not unification, if we try to unify Int and Char the answer is "no, those do not unify" because the type Int&Char is overconstrained (i.e. empty). This is exactly the behavior we want for HM type inference: type variables are allowed to be specialized down to (possibly ungrounded) terms, but if they specialize down too far then there's a type error, and there's no way to un-specialize terms back up because that would let us lose track of constraints on permissible types. Unification is a variety of intersection. Antiunification is the dual notion which is a variety of unioning. If we antiunify Int and Char, the answer will be Int|Char or whatever the closest analogue is (e.g. a free type variable) if the language doesn't allow indiscriminate unions. Depending on how we think of the sortal graph, we could also say unification returns the GLB whereas antiunification returns the LUB. (Antiunification shouldn't be confused with disunification, which is the negative of unification rather than the dual. Disunification says "these things are not allowed to be equal" so it's a sort of symmetric difference.) -- Live well, ~wren From z_axis at 163.com Thu Nov 12 02:37:39 2009 From: z_axis at 163.com (zaxis) Date: Thu Nov 12 02:13:23 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <625b74080911111741n310f3610lf3be271e3021dc32@mail.gmail.com> References: <26311291.post@talk.nabble.com> <625b74080911111741n310f3610lf3be271e3021dc32@mail.gmail.com> Message-ID: <26314602.post@talk.nabble.com> Without `forall`, the ghci will complain: "Not in scope: type variable `b' " It is clear now. thank you! Dan Piponi-2 wrote: > > On Wed, Nov 11, 2009 at 4:24 PM, zaxis wrote: >> data Branch tok st a ? ? = forall b. Branch (PermParser tok st (b -> a)) >> (GenParser tok st b) >> >> I have hoogled the `forall` but i cannot find any appropriate answer! > > That's an example of an existential type. What that line is saying is > that for any type b (ie. for all b) that you could pick, the > constructor called 'Branch' can take something of type 'PermParser tok > st (b -> a)' and something of type 'GenParser tok st b' and make > something of type 'Branch tok st a' out of it. > > The reason it's called an existential type is something like this: > once you've constructed your thing of type 'Branch tok st a' you've > lost the information about what the type b was. So all you know is > that inside your thing is a pair of objects of type 'PermParser tok st > (b -> a)' and 'GenParser tok st b' but you don't know what b is. All > you know is that there exists some type 'b' that it was made of. > > To use these types with ghc you need to use the compilation flag > -XExistentialQuantification. > > There's more to be found here: > http://www.haskell.org/haskellwiki/Existential_type > -- > Dan > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ----- fac n = foldr (*) 1 [1..n] -- View this message in context: http://old.nabble.com/What-does-the-%60forall%60-mean---tp26311291p26314602.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From bos at serpentine.com Thu Nov 12 02:44:59 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Thu Nov 12 02:20:44 2009 Subject: [Haskell-cafe] Wrestling the inliner beast Message-ID: I did a little bit of Data.Text benchmarking the other day, and I was shocked to find that decoding a UTF-8 stream proceeded at a sedate 3MB/sec. On investigation, the culprit was that I'd marked both the outer function and the inner (a loop) as INLINE. Because the inner loop was marked as INLINE, GHC wasn't inlining critically important leaf functions into it, so I was getting clobbered to death by boxing and unboxing. Leaving the outer function marked as INLINE, but taking the INLINE off the inner function, seems to cause *both* to get inlined as I originally hoped. This behaviour is all rather mysterious to me. The old "Secrets of the Inliner" paper is very much out of date now, but short of reading the source, I don't know where else to look to turn my voodoo folk intuition into something more solid. Is this all going to change in 6.12 anyway? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091112/7f0f366b/attachment.html From wren at freegeek.org Thu Nov 12 02:53:55 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu Nov 12 02:29:41 2009 Subject: [Haskell-cafe] "Least common supertype"? In-Reply-To: <4AFBBAE1.9090206@freegeek.org> References: <3c6288ab0911111224g2f7cce72rdfd957b7af32b6f2@mail.gmail.com> <54A1331D-E042-43D7-AAE4-335113AB30A1@cs.otago.ac.nz> <4AFB7A34.6000903@gmail.com> <4AFBBAE1.9090206@freegeek.org> Message-ID: <4AFBBF13.3070707@freegeek.org> wren ng thornton wrote: > sterl wrote: >> IANTT (I am not a type theorist) but... >> >> If you're talking about supertypes and subtypes, then I think this can >> be classified as a "least upper bound". > > It is a least upper bound, but only in a particular sense. The > particular sense is (of course) anti-unification. And part of the reason I say "only in a particular sense" is that it depends what graph we're talking about. There are many different varieties of relations we could draw among types. One is a parametric polymorphism relationship where some types are more polymorphic than and subsume other types. But we could also be discussing languages with a class hierarchy, or refinement types, or some other sense in which one type is "bigger" or "contains" another. Ideas like most general unifier and least specific generalization are just another relation on types. But they're particularly quirky because they take some subset of other type relations into account. Which is also to say that they may choose not to take certain other relations into account. A classic example here is the way Java generics ignore super-/subclass relations in the parameters. So the graph we draw of the MGU/LSG relation may not be coextensive with other graphs of "super" and "sub" types. Also, because of the properties of the function arrow there can be issues of contravariance to muddy the picture as well. Your intuition is on the right track, but it can be problematic to pin down in a way that adds meaningfully to the understanding of MGU/LSG. -- Live well, ~wren From dav.vire+haskell at gmail.com Thu Nov 12 02:57:17 2009 From: dav.vire+haskell at gmail.com (David Virebayre) Date: Thu Nov 12 02:33:01 2009 Subject: [Haskell-cafe] Static Linking Problem In-Reply-To: <221b53ab0911110844s73522191l19d8a649847a6a5a@mail.gmail.com> References: <87tyx2m5l5.fsf@malde.org> <221b53ab0911110844s73522191l19d8a649847a6a5a@mail.gmail.com> Message-ID: <4c88418c0911112357pe148a67y7d54b41930ba87b1@mail.gmail.com> On Wed, Nov 11, 2009 at 5:44 PM, Svein Ove Aas wrote: > My recommendation would be to take glibc off the list of statically > linked libraries. How do you do that ? David. From jeanchristophe.mincke at gmail.com Thu Nov 12 03:07:46 2009 From: jeanchristophe.mincke at gmail.com (jean-christophe mincke) Date: Thu Nov 12 02:43:31 2009 Subject: [Haskell-cafe] (state) monad and CPS In-Reply-To: <4AFBB695.4060605@freegeek.org> References: <1257947674-sup-3822@peray> <4AFBB695.4060605@freegeek.org> Message-ID: Hello, Thank everybody for the answers. I must admit that I did not really emphasize the goal behind my initial question. Which is better expressed this way: 'walk' is written is CPS and is tail recursive. Unless I am wrong , if the continuation monad is used, the recursive calls to 'walk' are no longer in tail position. So my initial question was rather: is it possible to use the state monad and keeping the code tail recursive? I do not master all the subtilities of lazy evaluation yet and perhaps tail recursivity does not have the same importance (or does not offer the same guarantees) in a lazy language as it does in a strict language. But I am facing a similar problem with workflows in F# (F#'s monads). Thank you Regards J-C On Thu, Nov 12, 2009 at 8:17 AM, wren ng thornton wrote: > Nicolas Pouillard wrote: > >> Excerpts from jean-christophe mincke's message of Tue Nov 10 21:18:34 >> +0100 2009: >> >>> do acc <- get >>> put (acc+1) >>> ... >>> >> >> Since this pattern occurs often 'modify' is a combination of get and put: >> >> do modify (+1) >> ... >> > > Though the caveat about laziness applies here as well. modify is famously > lazy which can lead to space leaks and stack overflows. Better would be to > define and use your own strict version: > > modify' f = get >>= \x -> put $! f x > > -- > Live well, > ~wren > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091112/04a01617/attachment.html From qdunkan at gmail.com Thu Nov 12 03:19:09 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Thu Nov 12 02:54:54 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: <4c88418c0911112322n6c4ed4bfp34a504ea68c624cf@mail.gmail.com> References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> <293882077.20091112091817@gmail.com> <4c88418c0911112322n6c4ed4bfp34a504ea68c624cf@mail.gmail.com> Message-ID: <2518b95d0911120019n528f8660ha05ec0d34536d5d2@mail.gmail.com> On Wed, Nov 11, 2009 at 11:22 PM, David Virebayre wrote: > On Thu, Nov 12, 2009 at 7:18 AM, Bulat Ziganshin > wrote: >> >> Hello Evan, >> >> Thursday, November 12, 2009, 4:02:17 AM, you wrote: >> >> > Recently the "go" language was announced at golang.org. ?There's not a >> > lot in there to make a haskeller envious, except one real big one: >> > compilation speed. ?The go compiler is wonderfully speedy. >> >> are you seen hugs, for example? i think that ghc is slow because it's >> written in haskell and compiled by itself > > If I understood, Evan is interested in ideas to speed up compilation. > As far as I know, hugs is an interpreter, not a compiler. Well, the bottom line is a faster "make a change, see it in action" cycle. As I mentioned, ghci's bytecode compiler is pretty good as long as I don't have to recompile the unchanged modules, but I've never been able to get it to work once I have C libraries to link in, it doesn't take the same flags as the real linker (and it's OS X so there's that funky framework stuff) and no matter how many libraries I try to put in manually it has some missing symbol. I should give hugs a try, but I suspect it may have the same problem. I also seem to recall it can't save and reload the bytecode for unchanged modules, which is going to be slow no matter how fast the actual compilation is. Hugs is also going to have trouble linking in the ghc api... though to load code at runtime it might be faster and smaller to link in hugs rather than the ghc api. From bulat.ziganshin at gmail.com Thu Nov 12 03:24:21 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Nov 12 03:08:01 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: <4c88418c0911112322n6c4ed4bfp34a504ea68c624cf@mail.gmail.com> References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> <293882077.20091112091817@gmail.com> <4c88418c0911112322n6c4ed4bfp34a504ea68c624cf@mail.gmail.com> Message-ID: <1932025586.20091112112421@gmail.com> Hello David, Thursday, November 12, 2009, 10:22:41 AM, you wrote: >> are you seen hugs, for example? i think that ghc is slow because it's >> written in haskell and compiled by itself > If I understood, Evan is interested in ideas to speed up compilation. > As far as I know, hugs is an interpreter, not a compiler. it's impossible to interpret haskell - how can you do type inference? hugs, like ghci, is bytecode interpreter. the difference is their implementation languages - haskell vs C -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From jfredett at gmail.com Thu Nov 12 04:00:04 2009 From: jfredett at gmail.com (Joe Fredette) Date: Thu Nov 12 03:35:51 2009 Subject: [Haskell-cafe] The weirdest error I've ever seen... Message-ID: <3A53E485-695C-4E33-A17A-A57DAF8C8424@gmail.com> Hiya Haskellers, So there I was, punching away at the keys, working on the Haskell Weekly News tools when the solution to one of my problems fell on me like a ton of lambdas. The solution and problem it solved are immaterial, but suffice to say it involved the combination of associated types and monad transformers, as well as some fancy deriving to end up with this code: ##### type Context = ReaderT Email type Match t = StateT t IO type ContextMatch t a = Context (Match t) a newtype FilterState t => Filter t a = Filter (ContextMatch t a) deriving (Functor, Monad, MonadReader Email, MonadState Bool, MonadIO) class FilterState t where data FState t deliver :: FState t -> IO () ##### Again, the fine details are unimportant, but the punchline is `Filter` is a Monad which houses not only results, but also an internal state which will be used in the delivery of emails in some yet-to-be- determined way. Naturally, I want to use `deriving` to turn this puppy into a monad over it's second argument. In fact, the whole thing kind- checks alright, but presents me with this, the titular 'weirdest error I've ever seen...' ##### [1 of 3] Compiling Network.HackMail.Email.ParseEmail ( Network/ HackMail/Email/ParseEmail.hs, interpreted ) [2 of 3] Compiling Network.HackMail.Email.Email ( Network/HackMail/ Email/Email.hs, interpreted ) [3 of 3] Compiling Network.HackMail.Filter.Filter ( Network/HackMail/ Filter/Filter.hs, interpreted ) *** Exception: No match in record selector Var.tcTyVarDetails ##### Now, there are three tickets open on the GHC trac, found for me by the ever-helpful `copumpkin` on #haskell -- because I didn't think to look -- they are numbers 3621, 3422 and 2714. But none of them are sufficiently close to my case for them to make sense to me, nor are the solutions presented suitable for entry into my feeble noggin. (Thats just a purty way of saying I'm not smart enough to understand what any of it means...) So I beseech my fellow Haskellers[1], What the heck did I do to anger the Var.tcTyVarDetail gods? My guess (given what I can glean from the Trac entries) is that the `deriving ... MonadState ...` needs changing in some specific-yet- cryptic way, but I've only got my gut to go on... For the Record, and in the event it matters... [jfredett@Erdos]$ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.10.4 [jfredett@Erdos]$ uname -a Linux Erdos 2.6.31-ARCH #1 SMP PREEMPT Fri Oct 23 11:12:58 CEST 2009 i686 Intel(R) Celeron(R) CPU 3.06GHz GenuineIntel GNU/Linux Thanks in advance for any help offered. /Joe [1] Bet you've never been beseeched before... From simonpj at microsoft.com Thu Nov 12 04:07:39 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Thu Nov 12 03:43:26 2009 Subject: [Haskell-cafe] The weirdest error I've ever seen... In-Reply-To: <3A53E485-695C-4E33-A17A-A57DAF8C8424@gmail.com> References: <3A53E485-695C-4E33-A17A-A57DAF8C8424@gmail.com> Message-ID: <59543203684B2244980D7E4057D5FBC1061C41FF@DB3EX14MBXC310.europe.corp.microsoft.com> | [1 of 3] Compiling Network.HackMail.Email.ParseEmail ( Network/ | HackMail/Email/ParseEmail.hs, interpreted ) | [2 of 3] Compiling Network.HackMail.Email.Email ( Network/HackMail/ | Email/Email.hs, interpreted ) | [3 of 3] Compiling Network.HackMail.Filter.Filter ( Network/HackMail/ | Filter/Filter.hs, interpreted ) | *** Exception: No match in record selector Var.tcTyVarDetails This is a bug in GHC without a doubt. It's possible that it's fixed in 6.12 -- can you try the release candidate? If it is not fixed, or if it's too hard for you to try, can you submit a Trac bug report please? (Include your code, and instructions for how to reproduce. Thanks Simon From magnus at therning.org Thu Nov 12 04:09:06 2009 From: magnus at therning.org (Magnus Therning) Date: Thu Nov 12 03:44:52 2009 Subject: [Haskell-cafe] Problem about hidden package again. In-Reply-To: <3bd412d40911112332y48b72175lf2f3d7e0d04b6686@mail.gmail.com> References: <3bd412d40911112332y48b72175lf2f3d7e0d04b6686@mail.gmail.com> Message-ID: On Thu, Nov 12, 2009 at 7:32 AM, Magicloud Magiclouds wrote: > Hi, > ?Today, when I compiled gtk2hs, I got this: > cairo/Graphics/Rendering/Cairo.hs.pp:264:0: > ? ?Failed to load interface for `Data.Array.Base': > ? ? ?it is a member of the hidden package `array-0.2.0.0' > ? ? ?Use -v to see a list of the files searched for. > ?As usual, I searched for the resolvement. No luck. And seems like > this problem (not particularly to this package) is very common. > ?I wonder how to resolve it? Is it compiled using Cabal? In that case you need to add array as a dependency. /m -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From magicloud.magiclouds at gmail.com Thu Nov 12 04:11:44 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Thu Nov 12 03:47:28 2009 Subject: [Haskell-cafe] Problem about hidden package again. In-Reply-To: References: <3bd412d40911112332y48b72175lf2f3d7e0d04b6686@mail.gmail.com> Message-ID: <3bd412d40911120111v35d7a361ub5c085f4e44bd3f7@mail.gmail.com> No, it is not. I used configure/make way. Well I just noticed that there is a "hide-all-package" options to ghc. I do not know why. Maybe the author went crazy. On Thu, Nov 12, 2009 at 5:09 PM, Magnus Therning wrote: > On Thu, Nov 12, 2009 at 7:32 AM, Magicloud Magiclouds > wrote: >> Hi, >> ?Today, when I compiled gtk2hs, I got this: >> cairo/Graphics/Rendering/Cairo.hs.pp:264:0: >> ? ?Failed to load interface for `Data.Array.Base': >> ? ? ?it is a member of the hidden package `array-0.2.0.0' >> ? ? ?Use -v to see a list of the files searched for. >> ?As usual, I searched for the resolvement. No luck. And seems like >> this problem (not particularly to this package) is very common. >> ?I wonder how to resolve it? > > Is it compiled using Cabal? ?In that case you need to add array as a dependency. > > /m > > -- > Magnus Therning ? ? ? ? ? ? ? ? ? ? ? ?(OpenPGP: 0xAB4DFBA4) > magnus?therning?org ? ? ? ? ?Jabber: magnus?therning?org > http://therning.org/magnus ? ? ? ? identi.ca|twitter: magthe > -- ??????? ??????? From svein.ove at aas.no Thu Nov 12 04:15:40 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Thu Nov 12 03:51:26 2009 Subject: [Haskell-cafe] Static Linking Problem In-Reply-To: <4c88418c0911112357pe148a67y7d54b41930ba87b1@mail.gmail.com> References: <87tyx2m5l5.fsf@malde.org> <221b53ab0911110844s73522191l19d8a649847a6a5a@mail.gmail.com> <4c88418c0911112357pe148a67y7d54b41930ba87b1@mail.gmail.com> Message-ID: <221b53ab0911120115i741b14a5o2ccd2d1233c77b38@mail.gmail.com> On Thu, Nov 12, 2009 at 8:57 AM, David Virebayre wrote: > On Wed, Nov 11, 2009 at 5:44 PM, Svein Ove Aas wrote: > >> My recommendation would be to take glibc off the list of statically >> linked libraries. > > How do you do that ? > By specifying the entire list manually, and not naming glibc. -- Svein Ove Aas From nicolas.pouillard at gmail.com Thu Nov 12 04:27:58 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Thu Nov 12 04:03:44 2009 Subject: [Haskell-cafe] (state) monad and CPS In-Reply-To: <4AFBB695.4060605@freegeek.org> References: <1257947674-sup-3822@peray> <4AFBB695.4060605@freegeek.org> Message-ID: <1258017845-sup-7812@peray> Excerpts from wren ng thornton's message of Thu Nov 12 08:17:41 +0100 2009: > Nicolas Pouillard wrote: > > Excerpts from jean-christophe mincke's message of Tue Nov 10 21:18:34 +0100 2009: > >> do acc <- get > >> put (acc+1) > >> ... > > > > Since this pattern occurs often 'modify' is a combination of get and put: > > > > do modify (+1) > > ... > > Though the caveat about laziness applies here as well. modify is > famously lazy which can lead to space leaks and stack overflows. Better > would be to define and use your own strict version: > > modify' f = get >>= \x -> put $! f x However if you want a strict state you should better use Control.Monad.State.Strict [1]. Finally I'm wondering if [1] is strict enough... [1]: http://www.haskell.org/ghc/docs/latest/html/libraries/mtl/Control-Monad-State-Strict.html -- Nicolas Pouillard http://nicolaspouillard.fr From magnus at therning.org Thu Nov 12 04:28:09 2009 From: magnus at therning.org (Magnus Therning) Date: Thu Nov 12 04:04:03 2009 Subject: [Haskell-cafe] Problem about hidden package again. In-Reply-To: <3bd412d40911120111v35d7a361ub5c085f4e44bd3f7@mail.gmail.com> References: <3bd412d40911112332y48b72175lf2f3d7e0d04b6686@mail.gmail.com> <3bd412d40911120111v35d7a361ub5c085f4e44bd3f7@mail.gmail.com> Message-ID: On Thu, Nov 12, 2009 at 9:11 AM, Magicloud Magiclouds wrote: > No, it is not. I used configure/make way. > Well I just noticed that there is a "hide-all-package" options to ghc. > I do not know why. Maybe the author went crazy. Chances are the auther DIDN'T go crazy :-) It's a common practice to hide all packages, and then only bring the ones needed into visibility. I doubt that Gtk2hs is completely self contained, so somewhere in there is the directives that makes the needed packages visible again. Just add array and you should be past this particular hurdle. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From wirtwolff at gmail.com Thu Nov 12 04:30:18 2009 From: wirtwolff at gmail.com (Wirt Wolff) Date: Thu Nov 12 04:06:10 2009 Subject: [Haskell-cafe] lambda-bot installation problem: gentoo trickery problem In-Reply-To: References: Message-ID: <1258017636-sup-149@chigamba> Excerpts from ??????? ????????'s message of Thu Nov 12 00:33:07 -0700 2009: > When I try cabal-install lambdabot (gentoo linux/amd64, ghc installed with > portage), it runs fine until compiler tries to link readline package (some > template haskell?). The problem caused by dirty trick, used in gentoo: the > /usr/lib64/libreadline is a fake with script, redirecting ld to /lib64 . GHC > is not redirected but simply fails with message "can't load .so/.DLL for: > readline (/usr/lib64/libreadline.so: invalid ELF header)". Yes, this is painful. There are discussions going on on ghc and on gentoo trackers for better ways to handle this. [1] [2] The problem is not gentoo specific though. Many other distros also use ld scripts, for example the same problem occurs using ubuntu. > So, the question is: is there any workaround? Copying library look like an > option, but it is very, very dirty one. Is there a way to say ghc, which > libreadline.so it should load? To build lambdabot, and in other similar situations I have renamed the ld script temporarily and symlinked to the appropriate real .so then after the build put things back as they were. There are cases when this isn't sufficient, for example when the problem lib is needed for ongoing development project. Others more knowledgable can speak to how they've handled that. [1] http://hackage.haskell.org/trac/ghc/ticket/2615 [2] http://bugs.gentoo.org/290974 -- wmw From d.kahlenberg at googlemail.com Thu Nov 12 04:46:33 2009 From: d.kahlenberg at googlemail.com (Daniel Kahlenberg) Date: Thu Nov 12 04:22:24 2009 Subject: [Haskell-cafe] Fwd: (Solved) cabal install with external gcc tool chain not the ghc-bundled one Message-ID: <4AFBD979.4030203@googlemail.com> to answer this question myself how the use of another gcc is specified with effect, I used the following options with the 'cabal install' call: --ghc-options="-pgmc e:/programme/ghc/mingw-gcc4/bin/gcc.exe -pgml e:/programme/ghc/mingw-gcc4/bin/gcc.exe" See http://www.haskell.org/ghc/docs/latest/html/users_guide/options-phases.html#replacing-phases (searched in the wrong direction, too many trees...). Slightly tuned, this should be the way to go in all similar cases. One thing I haven't considered yet is if the '--with-ld' and '--with-gcc' options (if curious too, see logs in my previous mail - Subject "[Haskell-cafe] caba install with external gcc toolchain not the ghc-bundled one") only effect what gets written into the setup-config/package.conf file or what other effects these have. Greets Daniel -------------- next part -------------- An embedded message was scrubbed... From: Daniel Kahlenberg Subject: [Haskell-cafe] caba install with external gcc toolchain not the ghc-bundled one Date: Wed, 11 Nov 2009 11:17:42 +0100 Size: 18058 Url: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091112/bca16446/Haskell-cafecabainstallwithexternalgcctoolchainnottheghc-bundledone.eml From apfelmus at quantentunnel.de Thu Nov 12 04:54:30 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Thu Nov 12 04:30:41 2009 Subject: [Haskell-cafe] Re: Long running Haskell program In-Reply-To: <49a77b7a0911111029y19bbfb0ofca117642368906c@mail.gmail.com> References: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> <49a77b7a0911111029y19bbfb0ofca117642368906c@mail.gmail.com> Message-ID: David Menendez wrote: > I think replacing "put s" with "put $! s" should guarantee that the > state is evaluated. > > If you're using get and put in many place in the code, you could try > something along these lines: > > newtype SStateT s m a = S { unS :: StateT s m a } deriving (Monad, etc.) > > instance (Monad m) => MonadState s (SStateT s m) where > get = S get > put s = S (put $! s) > Interestingly, this is different from Control.Monad.State.Strict . The latter never forces the state itself, just the pair constructor of the (result,state) pair. Here the different cases: evalLazy m = Control.Monad.State.Lazy.evalState m 0 evalStrict m = Control.Monad.State.Strict.evalState m 0 -- Pair constructor non-bottom GHCi> evalLazy $ put undefined () GHCi> evalStrict $ put undefined () -- Pair constructor bottom GHCi> evalLazy $ put $! undefined *** Exception: Prelude.undefined GHCi> evalStrict $ put $! undefined *** Exception: Prelude.undefined -- Last pair constructor non-bottom GHCi> evalLazy $ (put $! undefined) >> put 1 () -- Everything bottom GHCi> evalStrict $ (put $! undefined) >> put 1 *** Exception: Prelude.undefined Regards, apfelmus -- http://apfelmus.nfshost.com From matthew.pocock at ncl.ac.uk Thu Nov 12 05:00:46 2009 From: matthew.pocock at ncl.ac.uk (Matthew Pocock) Date: Thu Nov 12 04:36:30 2009 Subject: [Haskell-cafe] Re: Long running Haskell program In-Reply-To: References: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> <49a77b7a0911111029y19bbfb0ofca117642368906c@mail.gmail.com> Message-ID: 2009/11/12 Heinrich Apfelmus > Interestingly, this is different from Control.Monad.State.Strict . The > latter never forces the state itself, just the pair constructor of the > (result,state) pair. > > Yes. This bit me the first time I came across it. I think we need a Control. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091112/10d66742/attachment.html From mf-hcafe-15c311f0c at etc-network.de Wed Nov 11 12:21:16 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Thu Nov 12 04:37:03 2009 Subject: [Haskell-cafe] Fair diagonals (code golf) In-Reply-To: References: <4AF095D0.9030105@van.steenbergen.nl> <44F139D4-0B29-42A1-8D45-EF80333DB182@w3future.com> <4AF18DFA.7020602@gmail.com> Message-ID: <20091111172116.GL3717@yoyo> On Wed, Nov 04, 2009 at 07:01:50PM +0100, Sjoerd Visscher wrote: > To: Haskell Cafe > From: Sjoerd Visscher > Date: Wed, 4 Nov 2009 19:01:50 +0100 > Subject: Re: [Haskell-cafe] Fair diagonals (code golf) > > The code by Twan can be reduced to this: > > diagN = concat . foldr f [[[]]] > > f :: [a] -> [[[a]]] -> [[[a]]] > f xs ys = foldr (g ys) [] xs > > g :: [[[a]]] -> a -> [[[a]]] -> [[[a]]] > g ys x xs = merge (map (map (x:)) ys) ([] : xs) > > merge :: [[a]] -> [[a]] -> [[a]] > merge [] ys = ys > merge xs [] = xs > merge (x:xs) (y:ys) = (x++y) : merge xs ys > > But my feeling is that this can still be simplified further. Or at least > refactored so it is clear what actually is going on! i wrote another solution: diag2 xs ys = join . takeWhile (not . null) . map f $ [1..] where f i = zip xs' ys' where xs' = take i $ drop (i - length ys') xs ys' = reverse $ take i ys diag [] = [] diag [q] = [q] diag qs = foldr f (map (:[]) $ last qs) (init qs) where f q' = map (uncurry (++)) . diag2 (map (:[]) q') diag is the recursion step over the dimensions; diag2 is the base case with two dimensions. i can see that it's less efficient on (partially) finite inputs, since i keep dropping increasing prefixes of xs and ys in the local f in diag2), and there are probably other issues. but it was fun staring at this problem for a while. :) matthias From matthew.pocock at ncl.ac.uk Thu Nov 12 05:01:53 2009 From: matthew.pocock at ncl.ac.uk (Matthew Pocock) Date: Thu Nov 12 04:37:40 2009 Subject: [Haskell-cafe] Re: Long running Haskell program In-Reply-To: References: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> <49a77b7a0911111029y19bbfb0ofca117642368906c@mail.gmail.com> Message-ID: 2009/11/12 Heinrich Apfelmus > Interestingly, this is different from Control.Monad.State.Strict . The > latter never forces the state itself, just the pair constructor of the > (result,state) pair. > > Yes. This bit me the first time I came across it. I think we need a Control.Monad.State.StrictOnState with strict behaviour on the state value. I notice this same underlying issue is coming up in more than one thread on these lists. Matthew -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091112/f46fba84/attachment.html From apfelmus at quantentunnel.de Thu Nov 12 05:04:40 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Thu Nov 12 04:42:58 2009 Subject: [Haskell-cafe] Re: (state) monad and CPS In-Reply-To: References: <1257947674-sup-3822@peray> <4AFBB695.4060605@freegeek.org> Message-ID: jean-christophe mincke wrote: > I do not master all the subtilities of lazy evaluation yet and perhaps tail > recursivity does not have the same importance (or does not offer the same > guarantees) in a lazy language as it does in a strict language. Yep, that's the case. With lazy evaluation, tail recursion is less important. Also, code that looks tail recursive in a strict language will actually not be tail recursive in Haskell. A well-known example is the definition foldl and applied in the fashion of foldl (+) 0 [0..10] Regards, apfelmus -- http://apfelmus.nfshost.com From konstantin.vladimirov at gmail.com Thu Nov 12 05:12:35 2009 From: konstantin.vladimirov at gmail.com (Konstantin Vladimirov) Date: Thu Nov 12 04:48:19 2009 Subject: [Haskell-cafe] Resource compilation in GHC Message-ID: Hello. I'm writing an wxHaskell application. Everything is ok, but now I need a separate folder for icons, bitmaps, and so on, from where they are loaded at runtime. How can I compile resources, and link them into my executable to provide for users single .exe file with resource section inside it? -- With best regards, Konstantin From andrewcoppin at btinternet.com Thu Nov 12 05:36:32 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Nov 12 05:12:09 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <625b74080911111741n310f3610lf3be271e3021dc32@mail.gmail.com> References: <26311291.post@talk.nabble.com> <625b74080911111741n310f3610lf3be271e3021dc32@mail.gmail.com> Message-ID: <4AFBE530.2020603@btinternet.com> Dan Piponi wrote: > To use these types with ghc you need to use the compilation flag > -XExistentialQuantification. > Or, more portably, add {-# LANGUAGE ExistentialQuantification #-} at the top of the source file. It should now compile in any computer that supports this feature without any special command-line flags. > There's more to be found here: > http://www.haskell.org/haskellwiki/Existential_typ Amusingly, half of this article is still the text that I wrote. ;-) From andrewcoppin at btinternet.com Thu Nov 12 05:37:54 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Nov 12 05:13:31 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> References: <26311291.post@talk.nabble.com> <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> Message-ID: <4AFBE582.1030605@btinternet.com> Joe Fredette wrote: > Forall means the same thing as it means in math ...which not everybody already knows about. ;-) Even I am still not 100% sure how placing forall in different positions does different things. But usually it's not something I need to worry about. :-) From ekirpichov at gmail.com Thu Nov 12 05:44:00 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Thu Nov 12 05:19:44 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <4AFBE582.1030605@btinternet.com> References: <26311291.post@talk.nabble.com> <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> <4AFBE582.1030605@btinternet.com> Message-ID: <5e0214850911120244m30a2a285m4eeced410cf7d568@mail.gmail.com> 2009/11/12 Andrew Coppin : > Joe Fredette wrote: >> >> Forall means the same thing as it means in math > > ...which not everybody already knows about. ;-) > > Even I am still not 100% sure how placing forall in different positions does > different things. But usually it's not something I need to worry about. :-) To me it does not look like it does different things: everywhere it denotes universal polymorphism. What do you mean? I might be missing something. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From felipe.lessa at gmail.com Thu Nov 12 05:48:31 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Thu Nov 12 05:24:15 2009 Subject: [Haskell-cafe] Re: Long running Haskell program In-Reply-To: References: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> <49a77b7a0911111029y19bbfb0ofca117642368906c@mail.gmail.com> Message-ID: On Thu, Nov 12, 2009 at 8:01 AM, Matthew Pocock wrote: > Yes. This bit me the first time I came across it. I think we need a > Control.Monad.State.StrictOnState with strict behaviour on the state value. > I notice this same underlying issue is coming up in more than one thread on > these lists. This monad would indeed be useful, however it may be confusing as well. For example, if you are inserting elements in a Map using a lazy insert, seq'ing the map will only reduce it to WHNF (of course) and move the insertion down one level in the tree. IOW, I'd guess that OP's problem can't be solved just by seq'ing the map, he would have to use strict operations. There's a strict insertWith in Data.Map, but IIRC it's strict only on its combining operation, not on the insertion itself. Hmmm... maybe Control.Monad.State.RnfOnState? =P Cheers, -- Felipe. From nccb2 at kent.ac.uk Thu Nov 12 05:49:54 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Thu Nov 12 05:25:31 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <5e0214850911120244m30a2a285m4eeced410cf7d568@mail.gmail.com> References: <26311291.post@talk.nabble.com> <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> <4AFBE582.1030605@btinternet.com> <5e0214850911120244m30a2a285m4eeced410cf7d568@mail.gmail.com> Message-ID: <4AFBE852.9010804@kent.ac.uk> Eugene Kirpichov wrote: > 2009/11/12 Andrew Coppin : > >> Even I am still not 100% sure how placing forall in different positions does >> different things. But usually it's not something I need to worry about. :-) >> > > To me it does not look like it does different things: everywhere it > denotes universal polymorphism. What do you mean? I might be missing > something. > I think what he means is that this: foo :: forall a b. (a -> a) -> b -> b uses ScopedTypeVariables, and introduces the type-name a to be available in the where clause of myid. Whereas something like this: foo2 :: (forall a. a -> a) -> b -> b uses Rank2Types (I think?) to describe a function parameter that works for all types a. So although the general concept is the same, they use different Haskell extensions, and one is a significant extension to the type system while the other (ScopedTypeVariables) is just some more descriptive convenience. Thanks, Neil. From ekirpichov at gmail.com Thu Nov 12 05:50:49 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Thu Nov 12 05:26:32 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <4AFBE852.9010804@kent.ac.uk> References: <26311291.post@talk.nabble.com> <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> <4AFBE582.1030605@btinternet.com> <5e0214850911120244m30a2a285m4eeced410cf7d568@mail.gmail.com> <4AFBE852.9010804@kent.ac.uk> Message-ID: <5e0214850911120250h73dfc8b2s875b01d05bec8cc5@mail.gmail.com> 2009/11/12 Neil Brown : > Eugene Kirpichov wrote: >> >> 2009/11/12 Andrew Coppin : >> >>> >>> Even I am still not 100% sure how placing forall in different positions >>> does >>> different things. But usually it's not something I need to worry about. >>> :-) >>> >> >> To me it does not look like it does different things: everywhere it >> denotes universal polymorphism. What do you mean? I might be missing >> something. >> > > I think what he means is that this: > > foo :: forall a b. (a -> a) -> b -> b > > uses ScopedTypeVariables, and introduces the type-name a to be available in > the where clause of myid. ?Whereas something like this: > > foo2 :: (forall a. a -> a) -> b -> b > > uses Rank2Types (I think?) to describe a function parameter that works for > all types a. ?So although the general concept is the same, they use > different Haskell extensions, and one is a significant extension to the type > system while the other (ScopedTypeVariables) is just some more descriptive > convenience. > But that's not an issue of semantics of forall, just of which part of the rather broad and universal semantics is captured by which language extensions. > Thanks, > > Neil. > -- Eugene Kirpichov Web IR developer, market.yandex.ru From dav.vire+haskell at gmail.com Thu Nov 12 05:52:15 2009 From: dav.vire+haskell at gmail.com (David Virebayre) Date: Thu Nov 12 05:27:59 2009 Subject: [Haskell-cafe] Resource compilation in GHC In-Reply-To: References: Message-ID: <4c88418c0911120252l6a5736aci20ef8e7badb2dc60@mail.gmail.com> On Thu, Nov 12, 2009 at 11:12 AM, Konstantin Vladimirov wrote: > Hello. > I'm writing an wxHaskell application. Everything is ok, but now I need > a separate folder for icons, bitmaps, and so on, from where they are > loaded at runtime. How can I compile resources, and link them into my > executable to provide for users single .exe file with resource section > inside it? +1 ! I would also like to know how one can do it with gtk2hs. From ndmitchell at gmail.com Thu Nov 12 05:57:06 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Thu Nov 12 05:32:55 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: <293882077.20091112091817@gmail.com> References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> <293882077.20091112091817@gmail.com> Message-ID: <404396ef0911120257o315d7285r9a7f8dc218d2b6b5@mail.gmail.com> Hi, I'd really love a faster GHC! I spend hours every day waiting for GHC, so any improvements would be most welcome. I remember when developing Yhc on a really low powered computer, it had around 200 modules and loaded from scratch (with all the Prelude etc) in about 3 seconds on Hugs. ghc --make took about that long to start compiling the first file, and I think a complete compile was around 5 minutes. It's one of the main reasons I stuck with Hugs for so long. Running GHC in parallel with --make would be nice, but I find on Windows that the link time is the bottleneck for most projects. Thanks, Neil 2009/11/12 Bulat Ziganshin : > Hello Evan, > > Thursday, November 12, 2009, 4:02:17 AM, you wrote: > >> Recently the "go" language was announced at golang.org. ?There's not a >> lot in there to make a haskeller envious, except one real big one: >> compilation speed. ?The go compiler is wonderfully speedy. > > are you seen hugs, for example? i think that ghc is slow because it's > written in haskell and compiled by itself > > hugs provides good interactive environment and good ghc compatibility, > you can use conditional compilation to hide remaining differences. > unfortunately, many haskell libs doesn't support hugs > > -- > Best regards, > ?Bulat ? ? ? ? ? ? ? ? ? ? ? ? ? ?mailto:Bulat.Ziganshin@gmail.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bulat.ziganshin at gmail.com Thu Nov 12 06:16:36 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Nov 12 05:56:08 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: <404396ef0911120257o315d7285r9a7f8dc218d2b6b5@mail.gmail.com> References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> <293882077.20091112091817@gmail.com> <404396ef0911120257o315d7285r9a7f8dc218d2b6b5@mail.gmail.com> Message-ID: <97832057.20091112141636@gmail.com> Hello Neil, Thursday, November 12, 2009, 1:57:06 PM, you wrote: > I'd really love a faster GHC! there are few obvious ideas: 1) use Binary package for .hi files 2) allow to save/load bytecode 3) allow to run program directly from .hi files w/o linking 4) save mix of all .hi files as "program database" using mysql or so second one may be useful for hugs too. also, once i have asked you for CPP support in winhigs ;) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Thu Nov 12 06:19:37 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Nov 12 05:56:15 2009 Subject: [Haskell-cafe] Resource compilation in GHC In-Reply-To: References: Message-ID: <1256093647.20091112141937@gmail.com> Hello Konstantin, Thursday, November 12, 2009, 1:12:35 PM, you wrote: > I'm writing an wxHaskell application. Everything is ok, but now I need > a separate folder for icons, bitmaps, and so on, from where they are > loaded at runtime. How can I compile resources, and link them into my > executable to provide for users single .exe file with resource section > inside it? using win api, of course. look into SVN http://freearc.org:8080/freearc/trunk/ for example of how to add reources to executable (Unarc/makefile and compile.cmd). note that my program doesn't load anything from resources -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From magicloud.magiclouds at gmail.com Thu Nov 12 06:23:34 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Thu Nov 12 05:59:18 2009 Subject: [Haskell-cafe] Problem about hidden package again. In-Reply-To: References: <3bd412d40911112332y48b72175lf2f3d7e0d04b6686@mail.gmail.com> <3bd412d40911120111v35d7a361ub5c085f4e44bd3f7@mail.gmail.com> Message-ID: <3bd412d40911120323j9c894an6ce76cec89f5d3f1@mail.gmail.com> Just joking. But still, since gtk2hs still using the configure/make way, it is complex to add another option to the system. I tried to add array to build-depends of Cairo.cabal, no luck. On Thu, Nov 12, 2009 at 5:28 PM, Magnus Therning wrote: > On Thu, Nov 12, 2009 at 9:11 AM, Magicloud Magiclouds > wrote: >> No, it is not. I used configure/make way. >> Well I just noticed that there is a "hide-all-package" options to ghc. >> I do not know why. Maybe the author went crazy. > > Chances are the auther DIDN'T go crazy :-) > > It's a common practice to hide all packages, and then only bring the > ones needed into visibility. ?I doubt that Gtk2hs is completely self > contained, so somewhere in there is the directives that makes the > needed packages visible again. ?Just add array and you should be past > this particular hurdle. > > /M > > -- > Magnus Therning ? ? ? ? ? ? ? ? ? ? ? ?(OpenPGP: 0xAB4DFBA4) > magnus?therning?org ? ? ? ? ?Jabber: magnus?therning?org > http://therning.org/magnus ? ? ? ? identi.ca|twitter: magthe > -- ??????? ??????? From matthew.pocock at ncl.ac.uk Thu Nov 12 06:53:29 2009 From: matthew.pocock at ncl.ac.uk (Matthew Pocock) Date: Thu Nov 12 06:29:19 2009 Subject: [Haskell-cafe] Re: Long running Haskell program In-Reply-To: References: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> <49a77b7a0911111029y19bbfb0ofca117642368906c@mail.gmail.com> Message-ID: How about: instance (Monad m) => MonadState s (SStateT s m) where get = S get put s = S (put $ using s $ strategy m) where our state monad has a strategy field? Matthew -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091112/da44149f/attachment.html From xs at xaph.net Thu Nov 12 07:10:54 2009 From: xs at xaph.net (Rafal Kolanski) Date: Thu Nov 12 06:46:46 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: <1932025586.20091112112421@gmail.com> References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> <293882077.20091112091817@gmail.com> <4c88418c0911112322n6c4ed4bfp34a504ea68c624cf@mail.gmail.com> <1932025586.20091112112421@gmail.com> Message-ID: <4AFBFB4E.3080406@xaph.net> Bulat Ziganshin wrote: > it's impossible to interpret haskell - how can you do type inference? > hugs, like ghci, is bytecode interpreter. the difference is their > implementation languages - haskell vs C We use Standard ML for the Isabelle/HOL theorem prover, and it's interpreted, even has an interactive toplevel. It uses type inference, does it not? In fact, in a not-very-serious discussion at some point of what one could replace javascript with for a browser-embedded language, SML came up. What makes Haskell so different that it can't be interpreted in the SML style? Sincerely, Rafal Kolanski. From bugfact at gmail.com Thu Nov 12 07:26:21 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Nov 12 07:02:05 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: <4AFBFB4E.3080406@xaph.net> References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> <293882077.20091112091817@gmail.com> <4c88418c0911112322n6c4ed4bfp34a504ea68c624cf@mail.gmail.com> <1932025586.20091112112421@gmail.com> <4AFBFB4E.3080406@xaph.net> Message-ID: Regarding speeding up linking or compilation, IMO the real speedup you would get from incremental compilation & linking. It's okay if the initial compilation & linking take a long time, but the duration of next c&l iterations should only depend on the number of changes one does, not on the total project size. On Thu, Nov 12, 2009 at 1:10 PM, Rafal Kolanski wrote: > Bulat Ziganshin wrote: >> >> it's impossible to interpret haskell - how can you do type inference? >> hugs, like ghci, is bytecode interpreter. the difference is their >> implementation languages - haskell vs C > > We use Standard ML for the Isabelle/HOL theorem prover, and it's > interpreted, even has an interactive toplevel. It uses type inference, does > it not? In fact, in a not-very-serious discussion at some point of what one > could replace javascript with for a browser-embedded language, SML came up. > > What makes Haskell so different that it can't be interpreted in the SML > style? > > Sincerely, > > Rafal Kolanski. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bulat.ziganshin at gmail.com Thu Nov 12 07:25:27 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Nov 12 07:06:13 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: <4AFBFB4E.3080406@xaph.net> References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> <293882077.20091112091817@gmail.com> <4c88418c0911112322n6c4ed4bfp34a504ea68c624cf@mail.gmail.com> <1932025586.20091112112421@gmail.com> <4AFBFB4E.3080406@xaph.net> Message-ID: <1289311793.20091112152527@gmail.com> Hello Rafal, Thursday, November 12, 2009, 3:10:54 PM, you wrote: >> it's impossible to interpret haskell - how can you do type inference? >> hugs, like ghci, is bytecode interpreter. the difference is their >> implementation languages - haskell vs C > We use Standard ML for the Isabelle/HOL theorem prover, and it's > interpreted, even has an interactive toplevel. It uses type inference, > does it not? In fact, in a not-very-serious discussion at some point of > what one could replace javascript with for a browser-embedded language, > SML came up. ghc also has interactive toplevel. it compiles haskell down to bytecode, though. type inference is a part of compilation process, afaik, ocaml also generates bytecode. don't know about isabelle -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Thu Nov 12 07:39:09 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Nov 12 07:16:13 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> <293882077.20091112091817@gmail.com> <4c88418c0911112322n6c4ed4bfp34a504ea68c624cf@mail.gmail.com> <1932025586.20091112112421@gmail.com> <4AFBFB4E.3080406@xaph.net> Message-ID: <577938780.20091112153909@gmail.com> Hello Peter, Thursday, November 12, 2009, 3:26:21 PM, you wrote: incremental is just a word. what exactly we mean? ghc, like any other .obj-generating compiler, doesn't recompile unchanged source files (if their dependencies aren't changed too). otoh, (my old ghc 6.6) recompiles Main.hs if imported Sub.hs added new declaration (anyway unused in Main), so it may be improved some way > Regarding speeding up linking or compilation, IMO the real speedup you > would get from incremental compilation & linking. It's okay if the > initial compilation & linking take a long time, but the duration of > next c&l iterations should only depend on the number of changes one > does, not on the total project size. > On Thu, Nov 12, 2009 at 1:10 PM, Rafal Kolanski wrote: >> Bulat Ziganshin wrote: >>> >>> it's impossible to interpret haskell - how can you do type inference? >>> hugs, like ghci, is bytecode interpreter. the difference is their >>> implementation languages - haskell vs C >> >> We use Standard ML for the Isabelle/HOL theorem prover, and it's >> interpreted, even has an interactive toplevel. It uses type inference, does >> it not? In fact, in a not-very-serious discussion at some point of what one >> could replace javascript with for a browser-embedded language, SML came up. >> >> What makes Haskell so different that it can't be interpreted in the SML >> style? >> >> Sincerely, >> >> Rafal Kolanski. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From sebastian.sylvan at gmail.com Thu Nov 12 07:53:18 2009 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Thu Nov 12 07:29:03 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: <577938780.20091112153909@gmail.com> References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> <293882077.20091112091817@gmail.com> <4c88418c0911112322n6c4ed4bfp34a504ea68c624cf@mail.gmail.com> <1932025586.20091112112421@gmail.com> <4AFBFB4E.3080406@xaph.net> <577938780.20091112153909@gmail.com> Message-ID: <3d96ac180911120453h6ab7c8fbn3e6dcac3c82bd560@mail.gmail.com> On Thu, Nov 12, 2009 at 12:39 PM, Bulat Ziganshin wrote: > Hello Peter, > > Thursday, November 12, 2009, 3:26:21 PM, you wrote: > > incremental is just a word. what exactly we mean? Incremental linking means the general idea of reusing previous linking results, only patching it up with respect to changed obj files. So it's about reducing link times, not compile times. This has various consequences for executable size etc. so not something you'd want to do for release builds I think... Here's the documentation for VC's incremental linking option: http://msdn.microsoft.com/en-us/library/4khtbfyf(VS.80).aspx -- Sebastian Sylvan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091112/31e5f9f9/attachment.html From lazycat.manatee at gmail.com Thu Nov 12 07:32:20 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Thu Nov 12 07:44:01 2009 Subject: [Haskell-cafe] Re: Problem about hidden package again. References: <3bd412d40911112332y48b72175lf2f3d7e0d04b6686@mail.gmail.com> <3bd412d40911120111v35d7a361ub5c085f4e44bd3f7@mail.gmail.com> <3bd412d40911120323j9c894an6ce76cec89f5d3f1@mail.gmail.com> Message-ID: <877htvudnv.fsf@ubuntu.domain> Magicloud Magiclouds writes: > Just joking. But still, since gtk2hs still using the configure/make > way, it is complex to add another option to the system. I tried to add > array to build-depends of Cairo.cabal, no luck. Yes, it's not handy that gtk2hs can't use Cabal. But i think this is not easy when gtk2hs contain some many modules. -- Andy > > On Thu, Nov 12, 2009 at 5:28 PM, Magnus Therning wrote: >> On Thu, Nov 12, 2009 at 9:11 AM, Magicloud Magiclouds >> wrote: >>> No, it is not. I used configure/make way. >>> Well I just noticed that there is a "hide-all-package" options to ghc. >>> I do not know why. Maybe the author went crazy. >> >> Chances are the auther DIDN'T go crazy :-) >> >> It's a common practice to hide all packages, and then only bring the >> ones needed into visibility. ?I doubt that Gtk2hs is completely self >> contained, so somewhere in there is the directives that makes the >> needed packages visible again. ?Just add array and you should be past >> this particular hurdle. >> >> /M >> >> -- >> Magnus Therning ? ? ? ? ? ? ? ? ? ? ? ?(OpenPGP: 0xAB4DFBA4) >> magnus?therning?org ? ? ? ? ?Jabber: magnus?therning?org >> http://therning.org/magnus ? ? ? ? identi.ca|twitter: magthe >> From paolo.veronelli at gmail.com Thu Nov 12 08:18:40 2009 From: paolo.veronelli at gmail.com (Paolino) Date: Thu Nov 12 07:54:26 2009 Subject: [Haskell-cafe] Long running Haskell program In-Reply-To: References: <3e1162e60911110743u73291de0s60f54ed5211d867@mail.gmail.com> Message-ID: Also, a *service* should have a persistence periodical action which should evaluate (most part of) the state thunks in their values to be serialized. This work for the structure similarity of NFData and Show/Binary classes. When there is a not directly serializable part of the state , things can get complicate, but resolving the persistence issue for those parts should resolve also the space leak, I think. paolino 2009/11/11 Paolino > Hello leimy, the only simple solution I have found to avoid a leaking > state of a server is doing a periodical rnf of it, this implying the NFData > constraint on its datatype. > The reader should leak only if you nest forever the "local" function. > > paolino > > > > 2009/11/11 David Leimbach > >> As some of you may know, I've been writing commercial Haskell code for a >> little bit here (about a year and a half) and I've just recently had to >> write some code that was going to run have to run for a really long time >> before being restarted, possibly months or years if all other parts of the >> system cooperate as it's part of a server infrastructure management system. >> >> I recently ran into some serious space leak difficulties that would >> ultimately cause this program to crash some time after startup (my simulator >> is also written in Haskell, and runs a LOT faster than the real application >> ever could, this has enabled me to fast forward a bit the data growth issues >> and crash in minutes instead of days!) >> >> Anyway, rather than try to paste it all here with images and such I >> thought I'd stick it up on my blog so others could maybe benefit from the >> anecdote. It's difficult to disclose enough useful information as it is >> commercial code not under an open source license, but there's neat diagrams >> and stuff there so hopefully the colors are at least amusing :-) >> >> http://leimy9.blogspot.com/2009/11/long-running-haskell-applications.html >> >> Dave >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091112/e31b96f7/attachment.html From anakreon at csd.auth.gr Thu Nov 12 08:26:26 2009 From: anakreon at csd.auth.gr (Anakreon Mendis) Date: Thu Nov 12 08:05:49 2009 Subject: [Haskell-cafe] flow2dot Message-ID: <87ljib6fi5.fsf@mathind.csd.auth.gr> I've installed the flow2dot utility. It fails to produce a dot file from the sample provided by it's author. The output of the program is: .cabal/bin/flow2dot sample.flow flow2dot: Input: order a b c d a -> b: let's play "catch a ball"! b -> c: i'll pass it along c: what to do next? c -> a: lets throw it back again a: "not fair!" a -> c: find someone else! c -> d: ok, here you go: catch! d: zZzZzZzZzzz.... Error: "sample.flow" (line 1, column 1): unexpected "o" expecting "->", ":" or end of input From agocorona at gmail.com Thu Nov 12 08:39:06 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Thu Nov 12 08:14:50 2009 Subject: [Haskell-cafe] Re: socket error In-Reply-To: References: Message-ID: Now my program does not produce the error. A thread that was involved in the process failed with the effect of blocking the main thread that processed the socket input and produced the output. That ended up in this strange error after waiting half a second (more or less). instead of being catched by the error handler. as I expected. 2009/11/4 Kui Ma > > I am having the similar problem when running TCP server application on > windows XP. The server can only reads once from the handle of socket, then > any operation on the handle will cause error because it is already > finalized. It seems a platform issues but I have no idea about it. > ------------------------------ > Date: Tue, 3 Nov 2009 17:16:06 +0100 > From: agocorona@gmail.com > To: haskell-cafe@haskell.org > Subject: [Haskell-cafe] Re: socket error > > > I?m running windows, ghc 6.10.3 and 6.10.4 in two different machines. > > 2009/11/3 Alberto G. Corona > > : hPutBuf: illegal operation (handle is finalized) > > I?m a bit lost trying to find the source of this error. > I?m running an hack application (package hack). Basically it is a handler > of web requests. > hack can be used with different web servers: Hyena, simpleserver, > HappStack.... > all of them produce this error after a few interactions., Supposedly, it > happens within the socket module > since neither my module, nor hack, nor the hack simpleserver (package > hack-handler-simpleserver) call explicitly hPutBuf > > I tried to reproduce the error under linux, but my ubuntu installation is > too old and I?m in the process of reinstalling everything again. > > In the meantime, Any of you can give me any hint about the error? > > > > ------------------------------ > Windows Live: Keep your friends up to date with what you do online. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091112/a7d7b06a/attachment.html From jeremy.odonoghue at gmail.com Thu Nov 12 09:29:33 2009 From: jeremy.odonoghue at gmail.com (Jeremy O'Donoghue) Date: Thu Nov 12 09:05:16 2009 Subject: [Haskell-cafe] Cabal upload issue Message-ID: Hi all, I'm in the process of trying update the revisions of wx (part of wxHaskell) on hackage. I'm getting an error I find slightly surprising: "400 Error in upload The dependency 'build-depends: base' does not specify an upper bound on the version number. Each major release of the 'base' package changes the API in various ways and most packages will need some changes to compile with it. The recommended practise is to specify an upper bound on the version of the 'base' package. This ensures your package will continue to build when a new major version of the 'base' package is released. If you are not sure what upper bound to use then use the next major version. For example if you have tested your package with 'base' version 2 and 3 then use 'build-depends: base >= 2 && < 4'." In this case, we have the following in wx.cabal Library if flag(splitBase) build-depends: base >= 3, wxcore >= 0.12.1.1, stm else build-depends: base < 3, wxcore >= 0.12.1.1, stm Is this a bug, or am I doing something stupid? I should point out that this builds perfectly on my machine. Regards Jeremy From nccb2 at kent.ac.uk Thu Nov 12 09:35:31 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Thu Nov 12 09:11:05 2009 Subject: [Haskell-cafe] Cabal upload issue In-Reply-To: References: Message-ID: <4AFC1D33.1030902@kent.ac.uk> Jeremy O'Donoghue wrote: > Hi all, > > I'm in the process of trying update the revisions of wx (part of > wxHaskell) on hackage. > > I'm getting an error I find slightly surprising: > ... > Library > if flag(splitBase) > build-depends: base >= 3, wxcore >= 0.12.1.1, stm > Change this last line to base >= 3 && < 5 to get rid of the warning. I think the idea is that if base becomes version 5, it will likely break your code, so you should specify ahead of time that this library isn't currently designed to work with a version of base beyond 4. That way when someone installs your package in the future and you haven't tested with base 5, cabal will know to use base 4 for your library. Thanks, Neil. From duncan.coutts at googlemail.com Thu Nov 12 10:26:05 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Thu Nov 12 10:02:38 2009 Subject: [Haskell-cafe] Fwd: (Solved) cabal install with external gcc tool chain not the ghc-bundled one In-Reply-To: <4AFBD979.4030203@googlemail.com> References: <4AFBD979.4030203@googlemail.com> Message-ID: <1258039565.4680.9645.camel@localhost> On Thu, 2009-11-12 at 10:46 +0100, Daniel Kahlenberg wrote: > to answer this question myself how the use of another gcc is specified > with effect, I used the following options with the 'cabal install' call: > > --ghc-options="-pgmc e:/programme/ghc/mingw-gcc4/bin/gcc.exe -pgml > e:/programme/ghc/mingw-gcc4/bin/gcc.exe" > > See > http://www.haskell.org/ghc/docs/latest/html/users_guide/options-phases.html#replacing-phases > (searched in the wrong direction, too many trees...). Slightly tuned, > this should be the way to go in all similar cases. > > One thing I haven't considered yet is if the '--with-ld' and > '--with-gcc' options (if curious too, see logs in my previous mail - > Subject "[Haskell-cafe] caba install with external gcc toolchain not the > ghc-bundled one") only effect what gets written into the > setup-config/package.conf file or what other effects these have. Feel free to file a ticket about this. What makes me somewhat nervous is that the gcc you want to use for say .c files is not necessarily the same as the one ghc wants to use to compile .hc files or link stuff. This is particularly the case on Windows where ghc includes its own copy of gcc. Similarly on Solaris 10, ghc cannot use the /usr/bin/gcc because it's a hacked-up gcc that uses the Sun CC backend (which doesn't grok some of the crazy GNU C stuff that ghc uses). So it'd certainly be possible to have cabal's --with-gcc/ld override the ones that ghc uses by default, but the question is should it do so? I think it's worth asking the ghc hackers about this. Duncan From sam.martin at geomerics.com Thu Nov 12 12:37:16 2009 From: sam.martin at geomerics.com (Sam Martin) Date: Thu Nov 12 12:13:29 2009 Subject: [Haskell-cafe] Cabal upload issue In-Reply-To: <4AFC1D33.1030902@kent.ac.uk> References: <4AFC1D33.1030902@kent.ac.uk> Message-ID: <2E89FEDDC325014B986D1D77AB11E28B914FFA@THHS2EXBE1X.hostedservice2.net> Although it might be a pain in the arse to some degree, is there any reason why 'base' is considered special? As an example, I've come across a fair number of libraries/apps that (presumably) compile against a previous version of OpenGL, but not the current latest. Given it's impossible to test any package against libraries that don't yet exist, shouldn't the upper bound be required for all package dependencies? Just curious. :) ta, Sam -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Neil Brown Sent: 12 November 2009 14:36 To: Jeremy O'Donoghue Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Cabal upload issue Jeremy O'Donoghue wrote: > Hi all, > > I'm in the process of trying update the revisions of wx (part of > wxHaskell) on hackage. > > I'm getting an error I find slightly surprising: > ... > Library > if flag(splitBase) > build-depends: base >= 3, wxcore >= 0.12.1.1, stm > Change this last line to base >= 3 && < 5 to get rid of the warning. I think the idea is that if base becomes version 5, it will likely break your code, so you should specify ahead of time that this library isn't currently designed to work with a version of base beyond 4. That way when someone installs your package in the future and you haven't tested with base 5, cabal will know to use base 4 for your library. Thanks, Neil. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From jeremy.odonoghue at gmail.com Thu Nov 12 12:54:48 2009 From: jeremy.odonoghue at gmail.com (Jeremy O'Donoghue) Date: Thu Nov 12 12:30:34 2009 Subject: [Haskell-cafe] Cabal and autogenerated files Message-ID: Hi all, Another, probably simple, question regarding cabalization. Part of wxcore, the low level abstraction in wxHaskell, consists of haskell modules which are generated automatically by parsing C headers using another tool, wxdirect. When trying to create an sdist package, we run into the problem that because we export modules which are automatically generated, after a 'clean', they do not exist, so the sdist package generation fails. We have tried using 'extra-tmp-files' to list the modules which are autogenerated, but this isn't working. Is this because we are generating the autogen modules in an autogen directory, or is this approach likely to fail wherever we put the autogenerated files? Our use case seems a reasonable one, as it could reasonably exist for any project which relies on automatically generated code. Thanks for any suggestions. Jeremy From jfredett at gmail.com Thu Nov 12 12:58:40 2009 From: jfredett at gmail.com (Joe Fredette) Date: Thu Nov 12 12:34:25 2009 Subject: [Haskell-cafe] The weirdest error I've ever seen... In-Reply-To: <59543203684B2244980D7E4057D5FBC1061C41FF@DB3EX14MBXC310.europe.corp.microsoft.com> References: <3A53E485-695C-4E33-A17A-A57DAF8C8424@gmail.com> <59543203684B2244980D7E4057D5FBC1061C41FF@DB3EX14MBXC310.europe.corp.microsoft.com> Message-ID: Okay, so -- I feel totally awesome -- I never found a GHC bug before... and a Haskell Celebrity responded to my post! *swoons* :) Serious question now, There's a fair amount of definitely irrelevant code (like the definition of the `Email` type, etc), should I post that in the report too (assuming it doesn't work in 6.12 or I can't get 6.12 working to try it)? Thanks, /Joe On Nov 12, 2009, at 4:07 AM, Simon Peyton-Jones wrote: > | [1 of 3] Compiling Network.HackMail.Email.ParseEmail ( Network/ > | HackMail/Email/ParseEmail.hs, interpreted ) > | [2 of 3] Compiling Network.HackMail.Email.Email ( Network/HackMail/ > | Email/Email.hs, interpreted ) > | [3 of 3] Compiling Network.HackMail.Filter.Filter ( Network/ > HackMail/ > | Filter/Filter.hs, interpreted ) > | *** Exception: No match in record selector Var.tcTyVarDetails > > This is a bug in GHC without a doubt. > > It's possible that it's fixed in 6.12 -- can you try the release > candidate? If it is not fixed, or if it's too hard for you to try, > can you submit a Trac bug report please? (Include your code, and > instructions for how to reproduce. > > Thanks > > Simon From jfredett at gmail.com Thu Nov 12 13:12:03 2009 From: jfredett at gmail.com (Joe Fredette) Date: Thu Nov 12 12:47:50 2009 Subject: [Haskell-cafe] The weirdest error I've ever seen... In-Reply-To: References: <3A53E485-695C-4E33-A17A-A57DAF8C8424@gmail.com> <59543203684B2244980D7E4057D5FBC1061C41FF@DB3EX14MBXC310.europe.corp.microsoft.com> Message-ID: <27E743F3-305D-4586-9630-65769155EA46@gmail.com> Actually, I just solved the problem... I think... In my original code, I had the newtype: newtype FilterState t => Filter t a = Filter (ContextMatch t a) deriving (Functor, Monad, MonadReader Email, MonadState Bool, MonadIO) I was trying to confirm that it actually was the `deriving ... MonadState Bool ...` part that was causing the problem, and then I realized, it's not `MonadState Bool` I want, it's `MonadState t`. Upon changing that, everything compiles fine and ghc hums along happily. Should I still submit a bug report for a bad error message? /Joe On Nov 12, 2009, at 12:58 PM, Joe Fredette wrote: > Okay, so -- I feel totally awesome -- I never found a GHC bug > before... and a Haskell Celebrity responded to my post! *swoons* :) > > Serious question now, There's a fair amount of definitely irrelevant > code (like the definition of the `Email` type, etc), should I post > that in the report too (assuming it doesn't work in 6.12 or I can't > get 6.12 working to try it)? > > Thanks, > > /Joe > > On Nov 12, 2009, at 4:07 AM, Simon Peyton-Jones wrote: > >> | [1 of 3] Compiling Network.HackMail.Email.ParseEmail ( Network/ >> | HackMail/Email/ParseEmail.hs, interpreted ) >> | [2 of 3] Compiling Network.HackMail.Email.Email ( Network/HackMail/ >> | Email/Email.hs, interpreted ) >> | [3 of 3] Compiling Network.HackMail.Filter.Filter ( Network/ >> HackMail/ >> | Filter/Filter.hs, interpreted ) >> | *** Exception: No match in record selector Var.tcTyVarDetails >> >> This is a bug in GHC without a doubt. >> >> It's possible that it's fixed in 6.12 -- can you try the release >> candidate? If it is not fixed, or if it's too hard for you to try, >> can you submit a Trac bug report please? (Include your code, and >> instructions for how to reproduce. >> >> Thanks >> >> Simon > From ndmitchell at gmail.com Thu Nov 12 13:14:07 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Thu Nov 12 12:49:52 2009 Subject: [Haskell-cafe] The weirdest error I've ever seen... In-Reply-To: <27E743F3-305D-4586-9630-65769155EA46@gmail.com> References: <3A53E485-695C-4E33-A17A-A57DAF8C8424@gmail.com> <59543203684B2244980D7E4057D5FBC1061C41FF@DB3EX14MBXC310.europe.corp.microsoft.com> <27E743F3-305D-4586-9630-65769155EA46@gmail.com> Message-ID: <404396ef0911121014y142dbaa3qc7a7b72b201468f7@mail.gmail.com> Hi Joe, > Serious question now, There's a fair amount of definitely irrelevant code > (like the definition of the `Email` type, etc), should I post that in the > report too (assuming it doesn't work in 6.12 or I can't get 6.12 working to > try it)? http://hackage.haskell.org/trac/ghc/wiki/ReportABug - this is the reference. Do as many steps on this list as you want to, the more the easier it is for the GHC people, but they all take time: 1) Attach all the source code, enough to replicate the bug. 2) Download GHC 6.12 and check that it's still a bug there (if it's been fixed then it doesn't matter). 3) Start to boil down the test case by removing Email etc The important thing is to replicate the bug, but if you go further then it's less work for the GHC people. Don't try reducing the bug with GHC 6.10.4 though, because if it's a very subtle bug then you may stop it happening on other versions. > Upon changing that, everything compiles fine and ghc hums along happily. > > Should I still submit a bug report for a bad error message? Yes, you crashed the compiler - that's a bug, even if it was caused by invalid source code. Thanks, Neil On Thu, Nov 12, 2009 at 6:12 PM, Joe Fredette wrote: > Actually, I just solved the problem... I think... > > In my original code, I had the newtype: > > > ?newtype FilterState t => Filter t a = Filter (ContextMatch t a) > ? ? ?deriving (Functor, Monad, MonadReader Email, MonadState Bool, MonadIO) > > I was trying to confirm that it actually was the `deriving ... MonadState > Bool ...` part that was causing the problem, and then I realized, it's not > `MonadState Bool` I want, it's `MonadState t`. > > Upon changing that, everything compiles fine and ghc hums along happily. > > Should I still submit a bug report for a bad error message? > > /Joe > > On Nov 12, 2009, at 12:58 PM, Joe Fredette wrote: > >> Okay, so -- I feel totally awesome -- I never found a GHC bug before... >> and a Haskell Celebrity responded to my post! *swoons* :) >> >> Serious question now, There's a fair amount of definitely irrelevant code >> (like the definition of the `Email` type, etc), should I post that in the >> report too (assuming it doesn't work in 6.12 or I can't get 6.12 working to >> try it)? >> >> Thanks, >> >> /Joe >> >> On Nov 12, 2009, at 4:07 AM, Simon Peyton-Jones wrote: >> >>> | [1 of 3] Compiling Network.HackMail.Email.ParseEmail ( Network/ >>> | HackMail/Email/ParseEmail.hs, interpreted ) >>> | [2 of 3] Compiling Network.HackMail.Email.Email ( Network/HackMail/ >>> | Email/Email.hs, interpreted ) >>> | [3 of 3] Compiling Network.HackMail.Filter.Filter ( Network/HackMail/ >>> | Filter/Filter.hs, interpreted ) >>> | *** Exception: No match in record selector Var.tcTyVarDetails >>> >>> This is a bug in GHC without a doubt. >>> >>> It's possible that it's fixed in 6.12 -- can you try the release >>> candidate? ?If it is not fixed, or if it's too hard for you to try, can you >>> submit a Trac bug report please? (Include your code, and instructions for >>> how to reproduce. >>> >>> Thanks >>> >>> Simon >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From duncan.coutts at googlemail.com Thu Nov 12 13:16:18 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Thu Nov 12 12:52:04 2009 Subject: [Haskell-cafe] Cabal and autogenerated files In-Reply-To: References: Message-ID: <1258049778.4680.9994.camel@localhost> On Thu, 2009-11-12 at 17:54 +0000, Jeremy O'Donoghue wrote: > Hi all, > > Another, probably simple, question regarding cabalization. > > Part of wxcore, the low level abstraction in wxHaskell, consists of > haskell modules which are generated automatically by parsing C headers > using another tool, wxdirect. > > When trying to create an sdist package, we run into the problem that > because we export modules which are automatically generated, after a > 'clean', they do not exist, so the sdist package generation fails. So I take it that these modules are generated "from nothing" rather than something like happy/alex pre-processors where the .hs files are generated from .y/.x files. Cabal supports the latter fairly well and you can add custom pre-processors in this style. It doesn't really support generating modules out of thin-air in the build step (though it does this internally for the Paths_pkgname module). > We have tried using 'extra-tmp-files' to list the modules which are > autogenerated, but this isn't working. extra-tmp-files means rm these files too when cleaning. It's mostly redundant since the better thing to do is to keep all temp build files in the build directory. > Is this because we are generating the autogen modules in an autogen > directory, or is this approach likely to fail wherever we put the > autogenerated files? Our use case seems a reasonable one, as it could > reasonably exist for any project which relies on automatically > generated code. Tell me if I've misunderstood your problem. We'll have to think about how to get sdist to do the right thing for modules that have no ultimate corresponding source file. File a ticket with your description of your use case and what you'd like to be able to do. Duncan From duncan.coutts at googlemail.com Thu Nov 12 13:21:17 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Thu Nov 12 12:57:03 2009 Subject: [Haskell-cafe] Cabal upload issue In-Reply-To: <2E89FEDDC325014B986D1D77AB11E28B914FFA@THHS2EXBE1X.hostedservice2.net> References: <4AFC1D33.1030902@kent.ac.uk> <2E89FEDDC325014B986D1D77AB11E28B914FFA@THHS2EXBE1X.hostedservice2.net> Message-ID: <1258050077.4680.10009.camel@localhost> On Thu, 2009-11-12 at 17:37 +0000, Sam Martin wrote: > Although it might be a pain in the arse to some degree, is there any > reason why 'base' is considered special? > > As an example, I've come across a fair number of libraries/apps that > (presumably) compile against a previous version of OpenGL, but not the > current latest. The plan eventually is to do this for all packages that opt-in to following the PVP[1]. Base follows the PVP and it's a bit special since it's the single package that causes most breakage when new major versions come out. So we're dealing with part of the problem now as a special case and the rest of the problem later when we've got the appropriate infrastructure. > Given it's impossible to test any package against libraries that don't > yet exist, shouldn't the upper bound be required for all package > dependencies? True, however when you write that dependency you have no idea what that upper bound ought to be unless you know the package is following some kind of version policy. That's why we would only enforce it for packages that opt-in to the PVP. [1]: http://www.haskell.org/haskellwiki/Package_versioning_policy Duncan From jmillikin at gmail.com Thu Nov 12 13:56:23 2009 From: jmillikin at gmail.com (John Millikin) Date: Thu Nov 12 13:32:08 2009 Subject: [Haskell-cafe] Cabal and autogenerated files In-Reply-To: References: Message-ID: <3283f7fe0911121056s14ba4958o2727109476ecaa3f@mail.gmail.com> I've had some luck with two techniques for this: 1. Create "stub" files, associated with a custom preprocessor which knows how to parse them and generate a Haskell module. For example, you might have "Foo.wx-stub" contain: [headers] wx/foo.h wx/otherheader.h and then parse it into parameters for wxdirect. That allows Cabal to generate the appropriate files automatically. Downside: I've not figured out how to get proper dependency resolution for this, so occasionally a clean and rebuild is required. 2. Use a Makefile to generate the files, placing them in a subdirectory added to Cabal's search path. This works well for pretty much anything, since Make is a bit more mature than Cabal's build system, but having to remember the pre-processing step is annoying. On Thu, Nov 12, 2009 at 09:54, Jeremy O'Donoghue wrote: > Hi all, > > Another, probably simple, question regarding cabalization. > > Part of wxcore, the low level abstraction in wxHaskell, consists of > haskell modules which are generated automatically by parsing C headers > using another tool, wxdirect. > > When trying to create an sdist package, we run into the problem that > because we export modules which are automatically generated, after a > 'clean', they do not exist, so the sdist package generation fails. > > We have tried using 'extra-tmp-files' to list the modules which are > autogenerated, but this isn't working. > > Is this because we are generating the autogen modules in an autogen > directory, or is this approach likely to fail wherever we put the > autogenerated files? Our use case seems a reasonable one, as it could > reasonably exist for any project which relies on automatically > generated code. > > Thanks for any suggestions. > Jeremy > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From caseyh at istar.ca Thu Nov 12 14:42:18 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Thu Nov 12 14:17:50 2009 Subject: [Haskell-cafe] looking for a good algorithm Message-ID: To: Casey Hawthorne Subject: Re: [Haskell-cafe] looking for a good algorithm From: Casey Hawthorne Date: Thu, 12 Nov 2009 11:14:02 -0800 On third thought, convert the table to a 2D array of bits (or a 1D array of bits mapped to a 2D coordinate system). The bit is true for either an Int or Double. If space is a concern and one can tolerate a low rate of false positives, than a 2D Bloom Filter might be appropriate, or a 1D Bloom Filter with mapping to 2D coordinates. http://en.wikipedia.org/wiki/Bloom_filter Then on to simmulated annealing, possibly. Note: Donald Knuth's new fascicle is out: Volume 4 Fascicle 1, Bitwise Tricks & Techniques; Binary Decision Diagrams (2009), xiii+261pp. ISBN 0-321-58050-8 On Wed, 11 Nov 2009 15:32:35 -0800, you wrote: >So, as I understand it, you have a very large sparse table, thousands >of rows and hundreds of columns, of which each cell within a column of >type String, Int, or Double can contain one of those types or nothing. > >Then you to want to shuffle the rows to maximize the number of columns >whose first 100 rows have at least one number (Int or Double), given a >list of preferred column names since there is no guarantee that every >number column will have at least one number in its first 100 rows >after shuffling. > > >I'm wondering about hashing on the rows and hashing on the columns, >then the column hash has the number of Int's or Double's (don't need >the String's) in that column and the rows they are in. > >The row hash would have the number of Int's and Double's in that row >and what column's they are in. > >Then; > >Then scan the row hash and sort into descending order, and by tagging >those rows, not by actually moving them. > >Then I think your ready for simmulated annealing. -- Regards, Casey From ryani.spam at gmail.com Thu Nov 12 14:48:58 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Nov 12 14:24:47 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <5e0214850911120250h73dfc8b2s875b01d05bec8cc5@mail.gmail.com> References: <26311291.post@talk.nabble.com> <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> <4AFBE582.1030605@btinternet.com> <5e0214850911120244m30a2a285m4eeced410cf7d568@mail.gmail.com> <4AFBE852.9010804@kent.ac.uk> <5e0214850911120250h73dfc8b2s875b01d05bec8cc5@mail.gmail.com> Message-ID: <2f9b2d30911121148h22c03cd5w778b2c3bf17c70a5@mail.gmail.com> On Thu, Nov 12, 2009 at 2:50 AM, Eugene Kirpichov wrote: > But that's not an issue of semantics of forall, just of which part of > the rather broad and universal semantics is captured by which language > extensions. The forall for existential type quantification is wierd. > data Top = forall a. Any a -- existential > data Bottom = All (forall a. a) -- rank 2 I think it makes much more sense in GADT syntax: > data Top where > Any :: forall a. a -> Top > data Bottom where > All :: (forall a. a) -> Bottom where it's clear the forall is scoping the type of the constructor. -- ryan From andrewcoppin at btinternet.com Thu Nov 12 14:52:47 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Nov 12 14:28:23 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <5e0214850911120244m30a2a285m4eeced410cf7d568@mail.gmail.com> References: <26311291.post@talk.nabble.com> <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> <4AFBE582.1030605@btinternet.com> <5e0214850911120244m30a2a285m4eeced410cf7d568@mail.gmail.com> Message-ID: <4AFC678F.5090501@btinternet.com> Eugene Kirpichov wrote: > 2009/11/12 Andrew Coppin : > >> Joe Fredette wrote: >> >>> Forall means the same thing as it means in math >>> >> ...which not everybody already knows about. ;-) >> >> Even I am still not 100% sure how placing forall in different positions does >> different things. But usually it's not something I need to worry about. :-) >> > > To me it does not look like it does different things: everywhere it > denotes universal polymorphism. What do you mean? I might be missing > something. > I just meant it's not immediately clear how foo :: forall x. (x -> x -> y) is different from foo :: (forall x. x -> x) -> y It takes a bit of getting used to. From ekirpichov at gmail.com Thu Nov 12 14:57:38 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Thu Nov 12 14:33:22 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <2f9b2d30911121148h22c03cd5w778b2c3bf17c70a5@mail.gmail.com> References: <26311291.post@talk.nabble.com> <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> <4AFBE582.1030605@btinternet.com> <5e0214850911120244m30a2a285m4eeced410cf7d568@mail.gmail.com> <4AFBE852.9010804@kent.ac.uk> <5e0214850911120250h73dfc8b2s875b01d05bec8cc5@mail.gmail.com> <2f9b2d30911121148h22c03cd5w778b2c3bf17c70a5@mail.gmail.com> Message-ID: <5e0214850911121157q476df00cv8d063f82dd89bba9@mail.gmail.com> 2009/11/12 Ryan Ingram : > On Thu, Nov 12, 2009 at 2:50 AM, Eugene Kirpichov wrote: >> But that's not an issue of semantics of forall, just of which part of >> the rather broad and universal semantics is captured by which language >> extensions. > > The forall for existential type quantification is wierd. > >> data Top = forall a. Any a ? -- existential >> data Bottom = All (forall a. a) -- rank 2 > Hm, you're right. I didn't even remember you could define existential types without GADT syntax. I also find the GADT syntax much better for teaching people what an ADT is. > I think it makes much more sense in GADT syntax: > >> data Top where >> ? ?Any :: forall a. a -> Top >> data Bottom where >> ? ?All :: (forall a. a) -> Bottom > > where it's clear the forall is scoping the type of the constructor. > > ?-- ryan > -- Eugene Kirpichov Web IR developer, market.yandex.ru From gcross at phys.washington.edu Thu Nov 12 15:04:40 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Thu Nov 12 14:40:42 2009 Subject: [Haskell-cafe] Linker? Message-ID: Does anyone know here how GHC links in object files from other languages? I am getting a strange issue where it seems to be getting the calling convention on Fortran calls wrong. Specifically, on one computer (Gentoo Linux) I have with gcc and gfortran v4.4 and ghc compiled using gcc v4.3, I have no problems at all. On another computer (a Mac) I have with gcc 4.0 and gfortran 4.4 and a binary of ghc installed (as downloaded from haskell.org), I run into problems. Specifically, I noticed that the first parameter seems to get eaten when I declared a fortran routine as a function but not when I declare it as a subroutine. So I went ahead and converted the fortran routines into subroutines, but then I get another crash elsewhere in the code where a module calls a LAPACK routine for reasons unknown; I do not get this crash when running the same code path but called using a Python wrapper that uses gcc + gfortran + f2py rather than from my Haskell wrapper. I thought that this might be a problem with mixing gcc 4.0 and gfortran 4.4 (and ultimately I think this might still be the case), but when I tried writing small test cases using *only* gcc and gfortran and not ghc, everything worked just fine. Any thoughts? - Greg From caseyh at istar.ca Thu Nov 12 15:09:04 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Thu Nov 12 14:44:35 2009 Subject: [Haskell-cafe] Why can I run (runghc) some Haskell scripts but I cannot seem to compile them? Message-ID: Why can I run (runghc) some Haskell scripts but I cannot seem to compile them? e.g. http://www.haskell.org/all_about_monads/examples/example25.hs I've changed the import listing to the following: import IO import System import Monad import Data.Maybe import Data.List import Data.Char (toLower) import Control.Monad.State import Control.Monad.Writer -- Regards, Casey From caseyh at istar.ca Thu Nov 12 15:12:06 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Thu Nov 12 14:47:37 2009 Subject: [Haskell-cafe] Why can I run (runghc) some Haskell scripts but I cannot seem to compile them? Message-ID: Why can I run (runghc) some Haskell scripts but I cannot seem to compile them? e.g. http://www.haskell.org/all_about_monads/examples/example25.hs I've changed the import listing to the following: import IO import System import Monad import Data.Maybe import Data.List import Data.Char (toLower) import Control.Monad.State import Control.Monad.Writer The compiler errors are like the following: N-Queens.o:fake:(.text+0x2fe): undefined reference to `mtlzm1zi1zi0zi2_Controlzi MonadziStateziLazzy_zdf9_closure' N-Queens.o:fake:(.text+0x422): undefined reference to `mtlzm1zi1zi0zi2_Controlzi MonadziStateziLazzy_zdf7_closure' N-Queens.o:fake:(.text+0x66f6): undefined reference to `mtlzm1zi1zi0zi2_Controlz iMonadziWriterziLazzy_zdf1_closure' -- Regards, Casey From pumpkingod at gmail.com Thu Nov 12 15:13:47 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Thu Nov 12 14:49:29 2009 Subject: [Haskell-cafe] Why can I run (runghc) some Haskell scripts but I cannot seem to compile them? In-Reply-To: References: Message-ID: Did you try ghc --make? On Thu, Nov 12, 2009 at 3:12 PM, Casey Hawthorne wrote: > Why can I run (runghc) some Haskell scripts but I cannot seem to > compile them? > > e.g. http://www.haskell.org/all_about_monads/examples/example25.hs > > I've changed the import listing to the following: > > import IO > import System > import Monad > import Data.Maybe > import Data.List > import Data.Char (toLower) > import Control.Monad.State > import Control.Monad.Writer > > The compiler errors are like the following: > N-Queens.o:fake:(.text+0x2fe): undefined reference to > `mtlzm1zi1zi0zi2_Controlzi > MonadziStateziLazzy_zdf9_closure' > N-Queens.o:fake:(.text+0x422): undefined reference to > `mtlzm1zi1zi0zi2_Controlzi > MonadziStateziLazzy_zdf7_closure' > N-Queens.o:fake:(.text+0x66f6): undefined reference to > `mtlzm1zi1zi0zi2_Controlz > iMonadziWriterziLazzy_zdf1_closure' > > -- > Regards, > Casey > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From gour at gour-nitai.com Thu Nov 12 15:20:54 2009 From: gour at gour-nitai.com (Gour) Date: Thu Nov 12 14:57:01 2009 Subject: [Haskell-cafe] Re: Opinion about JHC References: <567296.97882.qm@web58802.mail.re1.yahoo.com> <20091111083759.GH21564@sliver.repetae.net> Message-ID: <20091112212054.7b0a9267@gaura-nitai.no-ip.org> On Wed, 11 Nov 2009 00:37:59 -0800 >>>>>> "John" == John Meacham wrote: Hi John, John> Yup. This was a major goal. compiling for iPhones and embedded John> arches is just as easy assuming you have a gcc toolchain set up. John> (at least with the hacked iPhone SDK.. I have never tried it with John> the official one) Is there any info whether it works on maemo platform? Sincerely, Gour -- Gour | Hlapicina, Croatia | GPG key: F96FF5F6 ---------------------------------------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091112/50a77572/signature.bin From mauricio.antunes at gmail.com Thu Nov 12 15:32:48 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Thu Nov 12 15:08:58 2009 Subject: [Haskell-cafe] Weird dependency failure log Message-ID: Hi, all, Hackage shows a log failure for 'bindings-gsl': Configuring bindings-gsl-0.1.1... cabal-setup: At least the following dependencies are missing: bindings-DSL ==1.0.* But here is, at version 1.0.1, no building problems: http://hackage.haskell.org/package/bindings-DSL There's one thing special about bindings-DSL. It's a package with a set of macros for hsc2hs, and contains no Haskell code. Maybe this revealed some hidden error in package dependency checking. Thanks, Maur?cio From caseyh at istar.ca Thu Nov 12 15:40:40 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Thu Nov 12 15:16:12 2009 Subject: [Haskell-cafe] Why can I run (runghc) some Haskell scripts but I cannot seem to compile them? In-Reply-To: References: Message-ID: Shazam! Thank you! On Thu, 12 Nov 2009 15:13:47 -0500, you wrote: >Did you try ghc --make? > >On Thu, Nov 12, 2009 at 3:12 PM, Casey Hawthorne wrote: >> Why can I run (runghc) some Haskell scripts but I cannot seem to >> compile them? >> >> e.g. http://www.haskell.org/all_about_monads/examples/example25.hs >> >> I've changed the import listing to the following: >> >> import IO >> import System >> import Monad >> import Data.Maybe >> import Data.List >> import Data.Char (toLower) >> import Control.Monad.State >> import Control.Monad.Writer >> >> The compiler errors are like the following: >> N-Queens.o:fake:(.text+0x2fe): undefined reference to >> `mtlzm1zi1zi0zi2_Controlzi >> MonadziStateziLazzy_zdf9_closure' >> N-Queens.o:fake:(.text+0x422): undefined reference to >> `mtlzm1zi1zi0zi2_Controlzi >> MonadziStateziLazzy_zdf7_closure' >> N-Queens.o:fake:(.text+0x66f6): undefined reference to >> `mtlzm1zi1zi0zi2_Controlz >> iMonadziWriterziLazzy_zdf1_closure' >> >> -- >> Regards, >> Casey >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> -- Regards, Casey From dav.vire+haskell at gmail.com Thu Nov 12 15:49:41 2009 From: dav.vire+haskell at gmail.com (David Virebayre) Date: Thu Nov 12 15:25:24 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <4AFC678F.5090501@btinternet.com> References: <26311291.post@talk.nabble.com> <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> <4AFBE582.1030605@btinternet.com> <5e0214850911120244m30a2a285m4eeced410cf7d568@mail.gmail.com> <4AFC678F.5090501@btinternet.com> Message-ID: <4c88418c0911121249j5351626he802a75939976cef@mail.gmail.com> On Thu, Nov 12, 2009 at 8:52 PM, Andrew Coppin wrote: > I just meant it's not immediately clear how > ?foo :: forall x. (x -> x -> y) > is different from > foo :: (forall x. x -> x) -> y > It takes a bit of getting used to. That still confuses me. From andrewcoppin at btinternet.com Thu Nov 12 15:51:22 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Nov 12 15:26:57 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <4c88418c0911121249j5351626he802a75939976cef@mail.gmail.com> References: <26311291.post@talk.nabble.com> <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> <4AFBE582.1030605@btinternet.com> <5e0214850911120244m30a2a285m4eeced410cf7d568@mail.gmail.com> <4AFC678F.5090501@btinternet.com> <4c88418c0911121249j5351626he802a75939976cef@mail.gmail.com> Message-ID: <4AFC754A.8020102@btinternet.com> David Virebayre wrote: > On Thu, Nov 12, 2009 at 8:52 PM, Andrew Coppin > wrote: > > >> I just meant it's not immediately clear how >> > > >> foo :: forall x. (x -> x -> y) >> > > >> is different from >> > > >> foo :: (forall x. x -> x) -> y >> > > >> It takes a bit of getting used to. >> > > That still confuses me. > The difference is when the x variable gets bound - but to comprehend that, you have to realise that x gets bound at some point, which is non-obvious... From ich at christoph-bauer.net Thu Nov 12 15:58:23 2009 From: ich at christoph-bauer.net (Christoph Bauer) Date: Thu Nov 12 15:44:59 2009 Subject: [Haskell-cafe] ANN: hesql Message-ID: <87zl6rfok0.fsf@christoph-bauer.net> Hello, sure, your program could use a database with HDBC. But I'll guess (since you love static typing so much) you dislike formulating queries in strings and to check the positions of your ?-placeholders and to convert your values with fromSql/toSql. Maybe you would prefer for your select query a list of tuples instead of a list of lists, because your beloved pattern matching needs always a dummy case. And here [1] is hesql... it's a preprocessor, which rewrites SQL-Queries as haskell functions. You put all your SQL-Queries (for example verifyLogin login' password' = select1' Accountid, Login, RealName, Email from Account where (password is null or password = md5(password')) and Lower(Login) = login' and not Locked; ) in a module (example/Account.hesql) and run $ hesql example/Account.hesql dbname=example which will write example/Account.hs, the real haskell module. It will generate code for a haskell function with the type: verifyLogin :: Stmts -> String -> String -> IO (Maybe (Int, String, String, String)) (Ok, this is not quite correct. Check the README.) And Of course my SQL-Parser is very incomplete. Hesql works only with postgresql, etc, etc. So, please send me patches :-) Don't expect too much. Christoph Bauer [1] on hackageDB From sschuldenzucker at uni-bonn.de Thu Nov 12 17:57:29 2009 From: sschuldenzucker at uni-bonn.de (Steffen Schuldenzucker) Date: Thu Nov 12 17:33:30 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <4AFC678F.5090501@btinternet.com> References: <26311291.post@talk.nabble.com> <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> <4AFBE582.1030605@btinternet.com> <5e0214850911120244m30a2a285m4eeced410cf7d568@mail.gmail.com> <4AFC678F.5090501@btinternet.com> Message-ID: <4AFC92D9.7080803@uni-bonn.de> Andrew Coppin wrote: > > I just meant it's not immediately clear how > > foo :: forall x. (x -> x -> y) > > is different from > > foo :: (forall x. x -> x) -> y Uhm, I guess you meant foo :: forall x. ((x -> x) -> y) VS. foo :: (forall x. x -> x) -> y , didn't you? From leather at cs.uu.nl Thu Nov 12 17:59:50 2009 From: leather at cs.uu.nl (Sean Leather) Date: Thu Nov 12 17:35:53 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <4AFC678F.5090501@btinternet.com> References: <26311291.post@talk.nabble.com> <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> <4AFBE582.1030605@btinternet.com> <5e0214850911120244m30a2a285m4eeced410cf7d568@mail.gmail.com> <4AFC678F.5090501@btinternet.com> Message-ID: <3c6288ab0911121459x6429d56fm6b83257ce3c157f6@mail.gmail.com> > I just meant it's not immediately clear how > > foo :: forall x. (x -> x -> y) > > is different from > > foo :: (forall x. x -> x) -> y > > It takes a bit of getting used to. Those are different functions all together, so perhaps you meant these. foo :: forall x y. (x -> x) -> y bar :: forall y. (forall x . x -> x) -> y While neither function is seemingly useful, the second says that the higher-order argument must be polymorphic. I see two options: bar id bar undefined The first has these and many more: foo (+1) foo show foo ($) ... Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091112/33cbec39/attachment.html From dastapov at gmail.com Thu Nov 12 18:21:40 2009 From: dastapov at gmail.com (Dmitry Astapov) Date: Thu Nov 12 17:57:46 2009 Subject: [Haskell-cafe] Re: flow2dot References: <87ljib6fi5.fsf@mathind.csd.auth.gr> Message-ID: Anakreon Mendis csd.auth.gr> writes: > > I've installed the flow2dot utility. It fails to produce a dot > file from the sample provided by it's author. The output of the program > is: [skip] Are you sure you are using version 0.7, since this is when "order" directive came into existence? From ok at cs.otago.ac.nz Thu Nov 12 19:58:46 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Thu Nov 12 19:34:33 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> Message-ID: <69332370-A05D-4A76-9626-64A729603F80@cs.otago.ac.nz> On Nov 12, 2009, at 2:02 PM, Evan Laforge wrote: > Recently the "go" language was announced at golang.org. It looks a lot like Limbo; does it have Limbo's dynamic loading? > > According to Rob Pike, the main reason for 6g's speed It's clear that 6g doesn't do as much optimisation as gccgo. It probably doesn't do as much optimisation as GHC. And it certainly doesn't have any kind of generics, let along type-level programming. I'd say the semantic distance between 'go' and x86 is quite a bit less than that between Haskell and x86. No laziness! From dagit at codersbase.com Thu Nov 12 20:25:06 2009 From: dagit at codersbase.com (Jason Dagit) Date: Thu Nov 12 20:00:48 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: <404396ef0911120257o315d7285r9a7f8dc218d2b6b5@mail.gmail.com> References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> <293882077.20091112091817@gmail.com> <404396ef0911120257o315d7285r9a7f8dc218d2b6b5@mail.gmail.com> Message-ID: On Thu, Nov 12, 2009 at 2:57 AM, Neil Mitchell wrote: > Hi, > > I'd really love a faster GHC! I spend hours every day waiting for GHC, > so any improvements would be most welcome. > Has anyone built a profiling enabled GHC to get data on where GHC spends time during compilation? > > I remember when developing Yhc on a really low powered computer, it > had around 200 modules and loaded from scratch (with all the Prelude > etc) in about 3 seconds on Hugs. ghc --make took about that long to > start compiling the first file, and I think a complete compile was > around 5 minutes. It's one of the main reasons I stuck with Hugs for > so long. > > Running GHC in parallel with --make would be nice, but I find on > Windows that the link time is the bottleneck for most projects. > Yes, when GHC calls GNU ld, it can be very costly. In my experience, on a linux virtual host I had to build my own GHC to disable split-obj because having it enabled caused ld to use about 1GB of memory. This is insane for a virtual host. I tried to solve it by adding swap that meant linking a trivial Setup.hs took about an hour. In conclusion, improving GNU ld could be a huge win for GHC, at least on linux. Does GHC on windows use GNU ld? Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091112/e98009d8/attachment.html From qdunkan at gmail.com Thu Nov 12 20:52:34 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Thu Nov 12 20:28:16 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> <293882077.20091112091817@gmail.com> <404396ef0911120257o315d7285r9a7f8dc218d2b6b5@mail.gmail.com> Message-ID: <2518b95d0911121752n6966c363see94223b213348fb@mail.gmail.com> >> Running GHC in parallel with --make would be nice, but I find on >> Windows that the link time is the bottleneck for most projects. > > Yes, when GHC calls GNU ld, it can be very costly. ?In my experience, on a This is also my experience. GNU ld is old and slow. I believe its generality also hurts it, there is a much faster linker called gold, but it's ELF-only. The reference to incremental linking was interesting, but AFAIK gnu and apple ld don't support that. > linux virtual host I had to build my own GHC to disable split-obj because > having it enabled caused ld to use about 1GB of memory. ?This is insane for > a virtual host. ?I tried to solve it by adding swap that meant linking a > trivial Setup.hs took about an hour. Oh, this is interesting. I recently stumbled across split-obj, and I gathered it's a special ghc hack to reduce binary size by putting functions in their own obj files (I guess ld is not smart enough to only link used code?). If it slows down links, would it be worthwhile to disable split-obj for normal builds, and turn it on with -O2 for a production build? > In conclusion, improving GNU ld could be a huge win for GHC, at least on > linux. ?Does GHC on windows use GNU ld? Improving GNU ld would be a huge win in a lot of places, and the fact that no one has done it (excepting gold of course) goes to show it's a lot easier said than done! On Thu, Nov 12, 2009 at 4:58 PM, Richard O'Keefe wrote: > > On Nov 12, 2009, at 2:02 PM, Evan Laforge wrote: > >> Recently the "go" language was announced at golang.org. > > It looks a lot like Limbo; does it have Limbo's dynamic loading? Nope, I don't think it's that similar to limbo actually, though it does have channels. It reminds me of haskell in some places, for example no implicit conversions, RTS multiplexed lightweight threads, and interfaces which are vaguely similar to typeclasses. The channels are a subset of TChans, its select {} is like a non-nesting orElse restricted to reading from channels. >> According to Rob Pike, the main reason for 6g's speed > > It's clear that 6g doesn't do as much optimisation as gccgo. > It probably doesn't do as much optimisation as GHC. > And it certainly doesn't have any kind of generics, let along > type-level programming. > I'd say the semantic distance between 'go' and x86 is quite a > bit less than that between Haskell and x86. ?No laziness! Indeed, the language is closer to the hardware and the type system is simpler. However, ghc can also be run without optimization. I think the main issue is that the designers had compilation speed as a feature from the beginning, and implemented some neat tricks to that end, which is why I mentioned how it pulls dependencies up to minimize file reading. Of course it could be that ghc already accomplishes the same end with --make by just keeping the interfaces in memory. Or file reading time is dwarfed by compiler cogitation. Of course a research language needs a flexible evolving compiler, maybe that's incompatible with a fast one. But fast builds are such a pleasure! From caseyh at istar.ca Thu Nov 12 21:15:35 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Thu Nov 12 20:51:06 2009 Subject: [Haskell-cafe] Pattern Matching Message-ID: <45gpf5duie29atpf90c5fetj600gfrhuk4@4ax.com> Why in a pattern match like score (1 3) = 7 can I not have sizeMax = 3 score (1 sizeMax) = 7 -- Regards, Casey From allbery at ece.cmu.edu Thu Nov 12 21:22:42 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Nov 12 20:58:36 2009 Subject: [Haskell-cafe] Pattern Matching In-Reply-To: <45gpf5duie29atpf90c5fetj600gfrhuk4@4ax.com> References: <45gpf5duie29atpf90c5fetj600gfrhuk4@4ax.com> Message-ID: <742A875A-8BF8-486C-912F-B1E12D22EB9B@ece.cmu.edu> On Nov 12, 2009, at 21:15 , Casey Hawthorne wrote: > Why in a pattern match like > > score (1 3) = 7 > > can I not have > > sizeMax = 3 > > score (1 sizeMax) = 7 Because it's a pattern, and when you introduce a symbol you are inviting the pattern match to bind what it matched to that name for use within the function. (Ordinary arguments are a trivial case of this.) Or, by example: > score (1 sizeMax) = (expression using sizeMax) The normal way to do what you want is guards: > score (1 x) | x == sizeMax = 7 -- you can pronounce the "|" as "such that" -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091112/735322ad/PGP.bin From haskell at colquitt.org Thu Nov 12 21:30:38 2009 From: haskell at colquitt.org (John Dorsey) Date: Thu Nov 12 21:06:23 2009 Subject: [Haskell-cafe] Pattern Matching In-Reply-To: <45gpf5duie29atpf90c5fetj600gfrhuk4@4ax.com> References: <45gpf5duie29atpf90c5fetj600gfrhuk4@4ax.com> Message-ID: <20091113023038.GE23495@colquitt.org> Casey, > Why in a pattern match like > > score (1 3) = 7 You probably mean > score 1 3 = 7 which applies the function 'score' to two arguments. With the parentheses, it looks like an application of '1' to the argument '3'. But to answer your actual question... > can I not have > > sizeMax = 3 > > score (1 sizeMax) = 7 When a variable name (such as 'sizeMax') appears in a pattern, it gets bound there. This is useful so you can refer to the variable on the right hand side, as in: successor x = x + 1 How would the compiler know whether to bind the variable (what actually happens), or match against the value represented by some earlier binding (what you're asking for)? What if the type of that second argument doesn't have a defined equality operation? There might be some reasonable way to do it, but I suspect it would be fragile and error-prone, at best. So it's always a new binding. It's easy enough to work around: score 1 x | x == sizeMax = 7 Regards, John From Braden.Shepherdson at gmail.com Thu Nov 12 22:44:22 2009 From: Braden.Shepherdson at gmail.com (Braden Shepherdson) Date: Thu Nov 12 22:19:53 2009 Subject: [Haskell-cafe] Re: Opinion about JHC In-Reply-To: <20091112212054.7b0a9267@gaura-nitai.no-ip.org> References: <567296.97882.qm@web58802.mail.re1.yahoo.com> <20091111083759.GH21564@sliver.repetae.net> <20091112212054.7b0a9267@gaura-nitai.no-ip.org> Message-ID: This worked for me, though that was quite a while ago. Presumably it still works. I don't remember doing any magic, just using the Maemo cross-compiler to build the output of jhc. The only annoying part was having to build with jhc outside the scratchbox environment and then build the C output inside the scratchbox. This is necessary because jhc is not self-hosting and I couldn't get GHC to build for Maemo. The attempts to build GHC (back in the 6.8.2 days -- supposed cross-platform bootstrapping works again in 6.12, maybe it'll work now) and the success with JHC are documented at [1]. Actually, I just looked and Dustin Weese succeeded where I had failed, and got an unregisterized 6.8 to bootstrap to Maemo. I've since learned ARM(v4) assembly for an embedded systems course, I might look into writing a properly registerized ARM back-end for GHC 6.12, now that the back-end overhaul is complete. That's definitely a Copious Free Time project, since I don't intend to be doing any ARM dev in Haskell or otherwise. Braden Shepherdson shepheb [1] http://hackage.haskell.org/trac/ghc/wiki/ArmLinuxGhc Gour wrote: > On Wed, 11 Nov 2009 00:37:59 -0800 >>>>>>> "John" == John Meacham wrote: > > Hi John, > > John> Yup. This was a major goal. compiling for iPhones and embedded > John> arches is just as easy assuming you have a gcc toolchain set up. > John> (at least with the hacked iPhone SDK.. I have never tried it with > John> the official one) > > Is there any info whether it works on maemo platform? > > > Sincerely, > Gour > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From stavenko at gmail.com Fri Nov 13 00:31:48 2009 From: stavenko at gmail.com (Vasiliy G. Stavenko) Date: Fri Nov 13 00:07:44 2009 Subject: [Haskell-cafe] C structures Message-ID: <1258090308.7336.100.camel@azazell-netbook> Hello everyone. What about passing complex c-types (structures) to c-functions. More detailed: I have an application in production which was written in Delphi. IT has ability to create pluggable modules to it. Interface realized by sending Win32Api messages to application. function in haskell Win32 Graphics.Win32.sendMessage :: HWND -> WyidowMessage-> WPARAM -> LPARAM -> IO RESULT Application wants to get different data in WPARAM and LPARAM. Such as window descriptor (HWND), string pointers and datastructer pointers. The latter i don't know how to create. I need anyones experience. From colin at colina.demon.co.uk Fri Nov 13 02:00:55 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Fri Nov 13 01:36:41 2009 Subject: [Haskell-cafe] ANN: hesql In-Reply-To: <87zl6rfok0.fsf@christoph-bauer.net> (Christoph Bauer's message of "Thu\, 12 Nov 2009 21\:58\:23 +0100") References: <87zl6rfok0.fsf@christoph-bauer.net> Message-ID: >>>>> "Christoph" == Christoph Bauer writes: Christoph> Hello, sure, your program could use a database with Christoph> HDBC. But I'll guess (since you love static typing so Christoph> much) you dislike formulating queries in strings and to Christoph> check the positions of your ?-placeholders and to Christoph> convert your values with fromSql/toSql. You guess right. That's why I use HaskellDB. Why would hesql be an improvement for me? It sounds like several steps backwards? -- Colin Adams Preston Lancashire From magnus at therning.org Fri Nov 13 02:07:54 2009 From: magnus at therning.org (Magnus Therning) Date: Fri Nov 13 01:43:44 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: <2518b95d0911121752n6966c363see94223b213348fb@mail.gmail.com> References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> <293882077.20091112091817@gmail.com> <404396ef0911120257o315d7285r9a7f8dc218d2b6b5@mail.gmail.com> <2518b95d0911121752n6966c363see94223b213348fb@mail.gmail.com> Message-ID: <4AFD05CA.5010006@therning.org> On 13/11/09 01:52, Evan Laforge wrote: >>> Running GHC in parallel with --make would be nice, but I find on >>> Windows that the link time is the bottleneck for most projects. >> >> Yes, when GHC calls GNU ld, it can be very costly. In my experience, on a > > This is also my experience. GNU ld is old and slow. I believe its > generality also hurts it, there is a much faster linker called gold, > but it's ELF-only. For someone like me, who only is interested in ELF on Linux, is there some way of getting GHC to use gold instead of ld? >> In conclusion, improving GNU ld could be a huge win for GHC, at least on >> linux. Does GHC on windows use GNU ld? > > Improving GNU ld would be a huge win in a lot of places, and the fact > that no one has done it (excepting gold of course) goes to show it's a > lot easier said than done! It could also mean that ld is good enough. Similar to how CVS was good enough for an awfully long time... ;-) /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091113/d67f7227/signature.bin From magnus at therning.org Fri Nov 13 02:12:07 2009 From: magnus at therning.org (Magnus Therning) Date: Fri Nov 13 01:47:52 2009 Subject: [Haskell-cafe] C structures In-Reply-To: <1258090308.7336.100.camel@azazell-netbook> References: <1258090308.7336.100.camel@azazell-netbook> Message-ID: <4AFD06C7.5050008@therning.org> On 13/11/09 05:31, Vasiliy G. Stavenko wrote: > Hello everyone. > > What about passing complex c-types (structures) to c-functions. > > More detailed: I have an application in production which was written in > Delphi. IT has ability to create pluggable modules to it. Interface > realized by sending Win32Api messages to application. > > function in haskell Win32 > Graphics.Win32.sendMessage :: HWND -> WyidowMessage-> WPARAM -> LPARAM > -> IO RESULT > > Application wants to get different data in WPARAM and LPARAM. Such as > window descriptor (HWND), string pointers and datastructer pointers. > The latter i don't know how to create. > > I need anyones experience. Possibly this old post of mine can help: http://therning.org/magnus/archives/315 /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091113/91b15030/signature.bin From gour at gour-nitai.com Fri Nov 13 02:27:46 2009 From: gour at gour-nitai.com (Gour) Date: Fri Nov 13 02:03:50 2009 Subject: [Haskell-cafe] Re: Opinion about JHC References: <567296.97882.qm@web58802.mail.re1.yahoo.com> <20091111083759.GH21564@sliver.repetae.net> <20091112212054.7b0a9267@gaura-nitai.no-ip.org> Message-ID: <20091113082746.6d1d362e@gaura-nitai.no-ip.org> On Thu, 12 Nov 2009 22:44:22 -0500 >>>>>> "Braden" == Braden Shepherdson >>>>>> wrote: Braden> This worked for me, though that was quite a while ago. Braden> Presumably it still works. I don't remember doing any magic, Braden> just using the Maemo cross-compiler to build the output of jhc. Thank you for the info. Braden> I've since learned ARM(v4) assembly for an embedded systems Braden> course, I might look into writing a properly registerized ARM Braden> back-end for GHC 6.12, now that the back-end overhaul is Braden> complete. It's no rush here, so having it in 6.12 would be cool. Braden> That's definitely a Copious Free Time project, since Braden> I don't intend to be doing any ARM dev in Haskell or otherwise. Well, I'm thinking about having 'light' version of desktop app running on something like N900, but it would involve gtk2hs as well, but that's another part of the story... Sincerely, Gour -- Gour | Hlapicina, Croatia | GPG key: F96FF5F6 ---------------------------------------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091113/a4c15544/signature.bin From ketil at malde.org Fri Nov 13 02:58:46 2009 From: ketil at malde.org (Ketil Malde) Date: Fri Nov 13 02:34:14 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: (Jason Dagit's message of "Thu, 12 Nov 2009 17:25:06 -0800") References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> <293882077.20091112091817@gmail.com> <404396ef0911120257o315d7285r9a7f8dc218d2b6b5@mail.gmail.com> Message-ID: <87aayqc0uh.fsf@malde.org> Jason Dagit writes: >> Running GHC in parallel with --make would be nice, but I find on >> Windows that the link time is the bottleneck for most projects. > Yes, when GHC calls GNU ld, it can be very costly. In my experience, I'll add mine: On my Ubuntu systems, linking is nearly instantaneous. On RedHat systems, it takes a noticeable amount of time - perhaps five to ten seconds. I'm not sure what the difference is caused by, I can try to investigate if it is of interest. -k -- If I haven't seen further, it is by standing in the footprints of giants From simonpj at microsoft.com Fri Nov 13 03:10:53 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Fri Nov 13 02:46:39 2009 Subject: [Haskell-cafe] The weirdest error I've ever seen... In-Reply-To: <27E743F3-305D-4586-9630-65769155EA46@gmail.com> References: <3A53E485-695C-4E33-A17A-A57DAF8C8424@gmail.com> <59543203684B2244980D7E4057D5FBC1061C41FF@DB3EX14MBXC310.europe.corp.microsoft.com> <27E743F3-305D-4586-9630-65769155EA46@gmail.com> Message-ID: <59543203684B2244980D7E4057D5FBC1061C5440@DB3EX14MBXC310.europe.corp.microsoft.com> It's not a bad error message -- it's a crash, and that should never happen. Ideally, boil down the program to something small that still exhibits the crash, and submit that. Perhaps just the newtype declaration alone, with supporting definitions for ContextMatch etc? Try removing unnecessary stuff, to get it as small as possible. Thanks Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On | Behalf Of Joe Fredette | Sent: 12 November 2009 18:12 | To: Joe Fredette | Cc: Simon Peyton-Jones; Haskell Caf? | Subject: Re: [Haskell-cafe] The weirdest error I've ever seen... | | Actually, I just solved the problem... I think... | | In my original code, I had the newtype: | | | newtype FilterState t => Filter t a = Filter (ContextMatch t a) | deriving (Functor, Monad, MonadReader Email, MonadState Bool, | MonadIO) | | I was trying to confirm that it actually was the `deriving ... | MonadState Bool ...` part that was causing the problem, and then I | realized, it's not `MonadState Bool` I want, it's `MonadState t`. | | Upon changing that, everything compiles fine and ghc hums along happily. | | Should I still submit a bug report for a bad error message? | | /Joe | | On Nov 12, 2009, at 12:58 PM, Joe Fredette wrote: | | > Okay, so -- I feel totally awesome -- I never found a GHC bug | > before... and a Haskell Celebrity responded to my post! *swoons* :) | > | > Serious question now, There's a fair amount of definitely irrelevant | > code (like the definition of the `Email` type, etc), should I post | > that in the report too (assuming it doesn't work in 6.12 or I can't | > get 6.12 working to try it)? | > | > Thanks, | > | > /Joe | > | > On Nov 12, 2009, at 4:07 AM, Simon Peyton-Jones wrote: | > | >> | [1 of 3] Compiling Network.HackMail.Email.ParseEmail ( Network/ | >> | HackMail/Email/ParseEmail.hs, interpreted ) | >> | [2 of 3] Compiling Network.HackMail.Email.Email ( Network/HackMail/ | >> | Email/Email.hs, interpreted ) | >> | [3 of 3] Compiling Network.HackMail.Filter.Filter ( Network/ | >> HackMail/ | >> | Filter/Filter.hs, interpreted ) | >> | *** Exception: No match in record selector Var.tcTyVarDetails | >> | >> This is a bug in GHC without a doubt. | >> | >> It's possible that it's fixed in 6.12 -- can you try the release | >> candidate? If it is not fixed, or if it's too hard for you to try, | >> can you submit a Trac bug report please? (Include your code, and | >> instructions for how to reproduce. | >> | >> Thanks | >> | >> Simon | > | | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe From dominic at steinitz.org Fri Nov 13 03:49:31 2009 From: dominic at steinitz.org (Dominic Steinitz) Date: Fri Nov 13 03:25:38 2009 Subject: [Haskell-cafe] haskell-src-exts Question Message-ID: I've been generating Haskell using haskell-src-exts but the prettyprinter isn't producing what I would expect. I would expect parse . prettyPrint == id i.e. the AST should be unchanged if you prettyprint it then parse it. Here's an example generated expression: App (App (Var (UnQual (Ident "pay"))) (Var (UnQual (Ident "tPD")))) (App (Var (UnQual (Ident "a"))) (InfixApp (App (Var (UnQual (Ident "length"))) (Var (UnQual (Ident "tOD")))) (QVarOp (UnQual (Symbol "+"))) (Lit (Int (-1))))) Here's what prettyPrint produces: pay tPD a length tOD + -1 Parsing it gives this (i.e. not the expression I first thought of): InfixApp (App (App (App (App (Var (UnQual (Ident "pay"))) (Var (UnQual (Ident "tPD")))) (Var (UnQual (Ident "a")))) (Var (UnQual (Ident "length")))) (Var (UnQual (Ident "tOD")))) (QVarOp (UnQual (Symbol "+"))) (NegApp (Lit (Int 1))) I would have expected the prettyprinter to produce this: pay tPD (a (length tOD + -1)) Do I have to write my own prettyprinter? Do I have to put in explicit parentheses? The latter seems unsatisfactory as my generated AST is unambiguous and bracketing ought to be part of the prettyprinter. The former would be quite a lot of code as there are many cases to consider. Dominic. From stavenko at gmail.com Fri Nov 13 04:00:18 2009 From: stavenko at gmail.com (Vasiliy G. Stavenko) Date: Fri Nov 13 03:36:19 2009 Subject: [Haskell-cafe] C structures In-Reply-To: <4AFD06C7.5050008@therning.org> References: <1258090308.7336.100.camel@azazell-netbook> <4AFD06C7.5050008@therning.org> Message-ID: <1258102818.7336.135.camel@azazell-netbook> > > > > I need anyones experience. > > Possibly this old post of mine can help: http://therning.org/magnus/archives/315 > Oh... WHile i was trying to repeat after you, it's become clear to me that this is not actually what I want. I want to create some structure, say data WM = WM {some_info :: Ptr CChar} create pointer for it type LPWM = Ptr WM and, when i need to convert it to something Int (or UINT) I found in Graphics.Win32 function castPtrToUINT :: Ptr a -> UINT So my question now is: would the structure defined in haskell as written in http://therning.org/magnus/archives/315, which pointer i will send to another C-function? be restored properly? Or maybe there's another function? which allows to do so? From andrewcoppin at btinternet.com Fri Nov 13 04:55:41 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Nov 13 04:31:15 2009 Subject: [Haskell-cafe] Pattern Matching In-Reply-To: <45gpf5duie29atpf90c5fetj600gfrhuk4@4ax.com> References: <45gpf5duie29atpf90c5fetj600gfrhuk4@4ax.com> Message-ID: <4AFD2D1D.9030101@btinternet.com> Casey Hawthorne wrote: > Why in a pattern match like > > score (1 3) = 7 > > can I not have > > sizeMax = 3 > > score (1 sizeMax) = 7 > If I had a dollar for every time I've written something like case msg of eVENT_QUIT -> ... eVENT_POST -> ... eVENT_RESIZE -> ... and spent an hour trying to figure out why the messages aren't being processed right... ;-) From colin at colina.demon.co.uk Fri Nov 13 05:00:00 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Fri Nov 13 04:35:43 2009 Subject: [Haskell-cafe] Pattern Matching In-Reply-To: <4AFD2D1D.9030101@btinternet.com> (Andrew Coppin's message of "Fri\, 13 Nov 2009 09\:55\:41 +0000") References: <45gpf5duie29atpf90c5fetj600gfrhuk4@4ax.com> <4AFD2D1D.9030101@btinternet.com> Message-ID: >>>>> "Andrew" == Andrew Coppin writes: Andrew> Casey Hawthorne wrote: >> Why in a pattern match like >> >> score (1 3) = 7 >> >> can I not have >> >> sizeMax = 3 >> >> score (1 sizeMax) = 7 >> If I had a dollar for every time I've written something like Andrew> case msg of eVENT_QUIT -> ... eVENT_POST -> ... Andrew> eVENT_RESIZE -> ... Andrew> and spent an hour trying to figure out why the messages Andrew> aren't being processed right... ;-) So why aren't they? -- Colin Adams Preston Lancashire From andrewcoppin at btinternet.com Fri Nov 13 05:05:15 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Nov 13 04:40:54 2009 Subject: [Haskell-cafe] Pattern Matching In-Reply-To: References: <45gpf5duie29atpf90c5fetj600gfrhuk4@4ax.com> <4AFD2D1D.9030101@btinternet.com> Message-ID: <4AFD2F5B.6030705@btinternet.com> Colin Paul Adams wrote: > If I had a dollar for every time I've written something like > > Andrew> case msg of eVENT_QUIT -> ... eVENT_POST -> ... > Andrew> eVENT_RESIZE -> ... > > Andrew> and spent an hour trying to figure out why the messages > Andrew> aren't being processed right... ;-) > > So why aren't they? > Because what I *should* have written is case msg of _ | msg == eVENT_QUIT -> ... | msg == eVENT_POST -> ... | msg == eVENT_RESIZE -> ... which is something quite different. (And, entertainingly, because the incorrect version is perfectly valid source code, no compiler errors or warnings...) From duncan.coutts at googlemail.com Fri Nov 13 05:19:14 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Fri Nov 13 04:54:57 2009 Subject: [Haskell-cafe] Resource compilation in GHC In-Reply-To: <4c88418c0911120252l6a5736aci20ef8e7badb2dc60@mail.gmail.com> References: <4c88418c0911120252l6a5736aci20ef8e7badb2dc60@mail.gmail.com> Message-ID: <1258107554.4680.11939.camel@localhost> On Thu, 2009-11-12 at 11:52 +0100, David Virebayre wrote: > On Thu, Nov 12, 2009 at 11:12 AM, Konstantin Vladimirov > wrote: > > Hello. > > > I'm writing an wxHaskell application. Everything is ok, but now I need > > a separate folder for icons, bitmaps, and so on, from where they are > > loaded at runtime. How can I compile resources, and link them into my > > executable to provide for users single .exe file with resource section > > inside it? > > +1 ! > > I would also like to know how one can do it with gtk2hs. I just keep them as separate data files and use Cabal to install them and to find them at runtime. http://haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#paths-module Duncan From duncan.coutts at googlemail.com Fri Nov 13 05:26:05 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Fri Nov 13 05:01:50 2009 Subject: [Haskell-cafe] Sometimes pinned memory? In-Reply-To: References: Message-ID: <1258107965.4680.11960.camel@localhost> On Wed, 2009-11-11 at 13:14 -0800, Gregory Crosswhite wrote: > Hey everyone! Do you have any suggestions for how I might allocate an > aligned block of memory that I can pin while making foreign calls, but > leave unpinned the rest of the time to potentially improve allocation > and garbage collector performance? Or is this even a good idea? GHC's memory management does not have any support for temporarily pinning a heap object. Heap objects must start out pinned or unpinned and that cannot be changed later (the current impl uses separate sections of the heap for pinned vs unpinned). As Don says, you can copy from an unpinned to a fresh pinned ByteArray#. If you're prepared to rely on internal properties of GHC's memory manager, then you can use the fact that currently ByteArray#s over a certain size are always pinned. This means that for small unpinned arrays you can just copy when it comes to a foreign call, and for larger ones you can rely on them being pinned. As I said though, this is not a portable technique. Duncan From malcolm.wallace at cs.york.ac.uk Fri Nov 13 05:31:35 2009 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Fri Nov 13 05:07:44 2009 Subject: [Haskell-cafe] Pattern Matching In-Reply-To: <4AFD2F5B.6030705@btinternet.com> References: <45gpf5duie29atpf90c5fetj600gfrhuk4@4ax.com> <4AFD2D1D.9030101@btinternet.com> <4AFD2F5B.6030705@btinternet.com> Message-ID: > (And, entertainingly, because the incorrect version is perfectly > valid source code, no compiler errors or warnings...) If you actually turn on compiler warnings (-Wall), I think you will see something like andrew.hs:10:10: Warning: This binding for `eVENT_QUIT' shadows the existing binding defined at EventLog.hs:43:0 In a case alternative and so forth, for every incorrect alternative. Regards, Malcolm From john at repetae.net Fri Nov 13 06:02:12 2009 From: john at repetae.net (John Meacham) Date: Fri Nov 13 05:37:54 2009 Subject: [Haskell-cafe] Problem with JHC In-Reply-To: References: <493149.58235.qm@web58803.mail.re1.yahoo.com> <0C5D7C59-21E3-459C-B9B0-0DEF32BA21EA@z.odi.ac> Message-ID: <20091113110212.GB23126@sliver.repetae.net> On Wed, Nov 11, 2009 at 07:25:14PM +0100, Paolino wrote: > FWIW, I just compiled JHC 0.7.2 with ghc 6.12 , doing a couple of > corrections to make it compile, which I don't think they are related to this > *bug*. Testing the given code, it aborts for every inputs I give it "L 1", > " T AND [L 1,L 2]" included. > I couldn't make it compile using function "reads" instead. I have not tested jhc with 6.12, it should compile with 6.8 and 6.10 seamlessly though, if you have found a way to get it to work with 6.12 and could post patches to the jhc list, that would be great though! John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From john at repetae.net Fri Nov 13 06:04:09 2009 From: john at repetae.net (John Meacham) Date: Fri Nov 13 05:39:50 2009 Subject: [Haskell-cafe] Problem with JHC In-Reply-To: <192721.36318.qm@web58804.mail.re1.yahoo.com> References: <0C5D7C59-21E3-459C-B9B0-0DEF32BA21EA@z.odi.ac> <192721.36318.qm@web58804.mail.re1.yahoo.com> Message-ID: <20091113110409.GC23126@sliver.repetae.net> On Wed, Nov 11, 2009 at 01:26:03PM -0800, Philippos Apolinarius wrote: > Ops, the paste is wrong, but the bug is real. I mean, if I try to run > the program with the right input, the program aborts in the same place, > with the same error message: > > philip@desktop:~/jhctut$ ./jtestarbo > > Give me a tree: > > T AND [L 1, L 2] > > jtestarbo_code.c:2670: case fell off Hmm... yes, a 'case fell off' error is always a bug in jhc one way or another. I will have to investigate your program and find out why that is happening. compiling with -fdebug can help find such errors, but clearly there is something wrong. John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From john at repetae.net Fri Nov 13 06:07:53 2009 From: john at repetae.net (John Meacham) Date: Fri Nov 13 05:43:34 2009 Subject: [Haskell-cafe] Re: Opinion about JHC In-Reply-To: <20091112212054.7b0a9267@gaura-nitai.no-ip.org> References: <567296.97882.qm@web58802.mail.re1.yahoo.com> <20091111083759.GH21564@sliver.repetae.net> <20091112212054.7b0a9267@gaura-nitai.no-ip.org> Message-ID: <20091113110753.GD23126@sliver.repetae.net> On Thu, Nov 12, 2009 at 09:20:54PM +0100, Gour wrote: > John> Yup. This was a major goal. compiling for iPhones and embedded > John> arches is just as easy assuming you have a gcc toolchain set up. > John> (at least with the hacked iPhone SDK.. I have never tried it with > John> the official one) > > Is there any info whether it works on maemo platform? Indeed, in fact it has worked for the maemo platform in the past I know because I tested with it once. I have not tested it in a long time, but now there is a cross compilation framework so it should be easier. there is a section in the manual on cross-compilation on how to set up new target platforms, basically all it involves is pointing jhc at the right gcc toolchain. John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From john at repetae.net Fri Nov 13 06:19:22 2009 From: john at repetae.net (John Meacham) Date: Fri Nov 13 05:55:03 2009 Subject: [Haskell-cafe] Re: Opinion about JHC In-Reply-To: References: <567296.97882.qm@web58802.mail.re1.yahoo.com> <20091111083759.GH21564@sliver.repetae.net> <20091112212054.7b0a9267@gaura-nitai.no-ip.org> Message-ID: <20091113111922.GE23126@sliver.repetae.net> On Thu, Nov 12, 2009 at 10:44:22PM -0500, Braden Shepherdson wrote: > The only annoying part was having to build with jhc outside the > scratchbox environment and then build the C output inside the > scratchbox. This is necessary because jhc is not self-hosting and I > couldn't get GHC to build for Maemo. Would you really want to have to run jhc _on_ your nokia 770 (or whatever) just to compile Haskell programs for it? The need for self-hosting in other compilers has always seemed like a deficiency in their design, a compiler is just a pure function from source code to output for a specified architecture. Said function is pure, it should not depend on what platform the compiler happens to be running on any more than any other pure function. Not that having jhc run on the nokia would be a bad thing, but it should not be required or provide any particular advantage for compiling programs for the nokia. jhc running on your N800 should be able to compile windows programs just as easily as jhc running on a windows machine itself or a linux box or a mac box. John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From john at repetae.net Fri Nov 13 06:26:44 2009 From: john at repetae.net (John Meacham) Date: Fri Nov 13 06:02:25 2009 Subject: [Haskell-cafe] Opinion about JHC In-Reply-To: References: <567296.97882.qm@web58802.mail.re1.yahoo.com> <20091111083759.GH21564@sliver.repetae.net> Message-ID: <20091113112644.GF23126@sliver.repetae.net> On Wed, Nov 11, 2009 at 01:47:43PM -0500, Lennart Augustsson wrote: > Do you use jhc when you develop jhc? I.e., does it compile itself. > For me, this is the litmus test of when a compiler has become usable. > I mean, if even the developers of a compiler don't use it themselves, > why should anyone else? :) Well, this touches on another issue, and that is that jhc is a native cross-compiler. It never behaves differently if compiled by another haskell compiler or is compiled on an alternate platform. There is never a need to 'bootstrap' it, once you have jhc running anywhere then it is as good as it would be if it is running everywhere. So to me, self-hosting has never been a big issue as it doesn't provide any direct "material" benefit. My time is better spent implementing more extensions or improving the back end. Of course, if jhc were to have a back-end that ghc didn't support that was a useful platform for jhc to run on, then it would be a different story. There would be a direct material benefit to having jhc being self-hosting so it would become a priority. John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From pirelo at googlemail.com Fri Nov 13 06:39:42 2009 From: pirelo at googlemail.com (Pablo Nogueira) Date: Fri Nov 13 06:15:24 2009 Subject: [Haskell-cafe] Final CFP: WFLP 2010. Deadlines extended: Abstract due Nov 18; Full paper due Nov 25 (LNCS) Message-ID: [Deadlines extended: Abstract due Nov 18; Full paper due Nov 25] ******************************************************************** Final Call For Papers 19th International Workshop on Functional and (Constraint) Logic Programming Madrid, Spain, January 17, 2010 http://babel.ls.fi.upm.es/events/wflp2010/ ********* colocated with Principles of Programming Languages POPL 2010 http://www.cse.psu.edu/popl/10/ ******************************************************************** IMPORTANT DATES Abstract Submission: November 18, 2009 **extended** Full Paper Submission: November 25, 2009 **extended** Acceptance Notification: December 20, 2009 Preliminary Proceedings: January 7, 2010 Workshop: January 17, 2010 SCOPE The aim of the Workshop on Functional and (Constraint) Logic Programming is to bring together researchers interested in functional programming and (constraint) logic programming with special emphasis on the integration of both paradigms and of other declarative programming extensions. It promotes the cross-fertilizing exchange of ideas and experiences among researchers and students from the different communities interested in the foundations, applications, and combinations of high-level declarative programming languages and related areas. The previous WFLP editions are: WFLP 2009 (Brasilia, Brazil), WFLP 2008 (Siena, Italy), WFLP 2007 (Paris, France), WFLP 2006 (Madrid, Spain), WCFLP 2005 (Tallinn, Estonia), WFLP 2004 (Aachen, Germany), WFLP 2003 (Valencia, Spain), WFLP 2002 (Grado, Italy), WFLP 2001 (Kiel, Germany), WFLP 2000 (Benicassim, Spain), WFLP'99 (Grenoble, France), WFLP'98 (Bad Honnef, Germany), WFLP'97 (Schwarzenberg, Germany), WFLP'96 (Marburg, Germany), WFLP'95 (Schwarzenberg, Germany), WFLP'94 (Schwarzenberg, Germany), WFLP'93 (Rattenberg, Germany), and WFLP'92 (Karlsruhe, Germany). LOCATION WFLP 2010 will be held on January 17, 2010 in Madrid, Spain, colocated with the 37th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL 2010). WFLP 2010 solicits papers in all areas of functional and (constraint) logic programming, including but not limited to: * Foundations: formal semantics, logic variables, binding and abstract syntax, rewriting and narrowing, unification, constraint solving, dynamics, type theory, meta-theory, effects, etc. * Language Design: security, services, modules, type systems, multi-paradigm languages, concurrency and distribution, objects, libraries, generic programming, interoperability, etc. * Implementation: abstract machines, parallelism, compile-time and run-time optimizations, foreign-language interfaces, memory management, multi-threading, exploiting parallel hardware, etc. * Transformation and Analysis: abstract interpretation, specialization, partial evaluation, program transformation, program calculation, program proof, meta-programming, generative programming, etc. * Software Development: algorithms, data structures, design patterns, components and composition, specification, proof assistants, verification and validation, model checking, debugging, testing, profiling, tracing, etc. * Paradigm Integration: integration of declarative programming with other paradigms or features such as imperative, object-oriented, aspect-oriented, concurrent, real-time programming, event-driven architectures, etc. * Applications: education, industry, commercial uses, domain-specific languages, visual/graphical user interfaces, embedded systems, WWW applications, XML processing, artificial intelligence, knowledge representation and machine learning, deductive databases, advanced programming environments and tools, etc. SUBMISSIONS and PROCEEDINGS Authors are invited to submit papers presenting original unpublished work. Papers must be at most 15 pages long. Exceptionally, authors may surpass the page limit by providing well-marked appendices intended as reviewing aids. Appendices will not appear in the final publication. Submission categories include regular research papers, system descriptions, and short papers describing on-going work (at most 8 pages). Submissions must be formatted in Lecture Notes in Computer Science (LNCS) style. This requirement needs not apply to appendices. Papers should be submitted in pdf format electronically via the web-based submission site http://www.easychair.org/conferences/?conf=wflp2010 Preliminary proceedings will be available at the workshop. Selected authors will be invited to submit a full version of their papers after the workshop. Contributions accepted for the post-workshop proceedings will be published in Springer's Lecture Notes in Computer Science series. INVITED SPEAKER Mariangiola Dezani (University of Torino, Italy) PROGRAM CHAIR Julio Marino (Universidad Politecnica de Madrid, Spain) PROGRAM COMMITTEE Maria Alpuente (Universidad Politecnica de Valencia, Spain) Sergio Antoy (Portland State University, USA) Bernd Brassel (CAU Kiel, Germany) Olaf Chitil (Univ. of Kent, UK) Rachid Echahed (CNRS-IMAG, France) Santiago Escobar (Universidad Politecnica de Valencia, Spain) Moreno Falaschi (Universita di Siena, Italy) Murdoch Gabbay (Heriot-Watt University, UK) Maria Garcia de la Banda (Monash University, Australia) Victor Gulias (Lambdastream SL, Spain) Michael Hanus (CAU Kiel, Germany) Herbert Kuchen (Univ. of Muenster, Germany) Francisco Lopez-Fraguas (Universidad Complutense de Madrid, Spain) James Lipton (Wesleyan University, USA) Mircea Marin (Univ. of Tsukuba, Japan) Juan Jose Moreno-Navarro (Ministry of Science & Innovation, Spain) Brigitte Pientka (McGill University, Canada) -------------- next part -------------- [Deadlines extended: Abstract due Nov 18; Full paper due Nov 25] ******************************************************************** Final Call For Papers 19th International Workshop on Functional and (Constraint) Logic Programming Madrid, Spain, January 17, 2010 http://babel.ls.fi.upm.es/events/wflp2010/ ********* colocated with Principles of Programming Languages POPL 2010 http://www.cse.psu.edu/popl/10/ ******************************************************************** IMPORTANT DATES Abstract Submission: November 18, 2009 **extended** Full Paper Submission: November 25, 2009 **extended** Acceptance Notification: December 20, 2009 Preliminary Proceedings: January 7, 2010 Workshop: January 17, 2010 SCOPE The aim of the Workshop on Functional and (Constraint) Logic Programming is to bring together researchers interested in functional programming and (constraint) logic programming with special emphasis on the integration of both paradigms and of other declarative programming extensions. It promotes the cross-fertilizing exchange of ideas and experiences among researchers and students from the different communities interested in the foundations, applications, and combinations of high-level declarative programming languages and related areas. The previous WFLP editions are: WFLP 2009 (Brasilia, Brazil), WFLP 2008 (Siena, Italy), WFLP 2007 (Paris, France), WFLP 2006 (Madrid, Spain), WCFLP 2005 (Tallinn, Estonia), WFLP 2004 (Aachen, Germany), WFLP 2003 (Valencia, Spain), WFLP 2002 (Grado, Italy), WFLP 2001 (Kiel, Germany), WFLP 2000 (Benicassim, Spain), WFLP'99 (Grenoble, France), WFLP'98 (Bad Honnef, Germany), WFLP'97 (Schwarzenberg, Germany), WFLP'96 (Marburg, Germany), WFLP'95 (Schwarzenberg, Germany), WFLP'94 (Schwarzenberg, Germany), WFLP'93 (Rattenberg, Germany), and WFLP'92 (Karlsruhe, Germany). LOCATION WFLP 2010 will be held on January 17, 2010 in Madrid, Spain, colocated with the 37th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL 2010). WFLP 2010 solicits papers in all areas of functional and (constraint) logic programming, including but not limited to: * Foundations: formal semantics, logic variables, binding and abstract syntax, rewriting and narrowing, unification, constraint solving, dynamics, type theory, meta-theory, effects, etc. * Language Design: security, services, modules, type systems, multi-paradigm languages, concurrency and distribution, objects, libraries, generic programming, interoperability, etc. * Implementation: abstract machines, parallelism, compile-time and run-time optimizations, foreign-language interfaces, memory management, multi-threading, exploiting parallel hardware, etc. * Transformation and Analysis: abstract interpretation, specialization, partial evaluation, program transformation, program calculation, program proof, meta-programming, generative programming, etc. * Software Development: algorithms, data structures, design patterns, components and composition, specification, proof assistants, verification and validation, model checking, debugging, testing, profiling, tracing, etc. * Paradigm Integration: integration of declarative programming with other paradigms or features such as imperative, object-oriented, aspect-oriented, concurrent, real-time programming, event-driven architectures, etc. * Applications: education, industry, commercial uses, domain-specific languages, visual/graphical user interfaces, embedded systems, WWW applications, XML processing, artificial intelligence, knowledge representation and machine learning, deductive databases, advanced programming environments and tools, etc. SUBMISSIONS and PROCEEDINGS Authors are invited to submit papers presenting original unpublished work. Papers must be at most 15 pages long. Exceptionally, authors may surpass the page limit by providing well-marked appendices intended as reviewing aids. Appendices will not appear in the final publication. Submission categories include regular research papers, system descriptions, and short papers describing on-going work (at most 8 pages). Submissions must be formatted in Lecture Notes in Computer Science (LNCS) style. This requirement needs not apply to appendices. Papers should be submitted in pdf format electronically via the web-based submission site http://www.easychair.org/conferences/?conf=wflp2010 Preliminary proceedings will be available at the workshop. Selected authors will be invited to submit a full version of their papers after the workshop. Contributions accepted for the post-workshop proceedings will be published in Springer's Lecture Notes in Computer Science series. INVITED SPEAKER Mariangiola Dezani (University of Torino, Italy) PROGRAM CHAIR Julio Marino (Universidad Politecnica de Madrid, Spain) PROGRAM COMMITTEE Maria Alpuente (Universidad Politecnica de Valencia, Spain) Sergio Antoy (Portland State University, USA) Bernd Brassel (CAU Kiel, Germany) Olaf Chitil (Univ. of Kent, UK) Rachid Echahed (CNRS-IMAG, France) Santiago Escobar (Universidad Politecnica de Valencia, Spain) Moreno Falaschi (Universita di Siena, Italy) Murdoch Gabbay (Heriot-Watt University, UK) Maria Garcia de la Banda (Monash University, Australia) Victor Gulias (Lambdastream SL, Spain) Michael Hanus (CAU Kiel, Germany) Herbert Kuchen (Univ. of Muenster, Germany) Francisco Lopez-Fraguas (Universidad Complutense de Madrid, Spain) James Lipton (Wesleyan University, USA) Mircea Marin (Univ. of Tsukuba, Japan) Juan Jose Moreno-Navarro (Ministry of Science & Innovation, Spain) Brigitte Pientka (McGill University, Canada) From daniel.is.fischer at web.de Fri Nov 13 07:02:53 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Nov 13 06:40:04 2009 Subject: [Haskell-cafe] Pattern Matching In-Reply-To: <4AFD2F5B.6030705@btinternet.com> References: <45gpf5duie29atpf90c5fetj600gfrhuk4@4ax.com> <4AFD2F5B.6030705@btinternet.com> Message-ID: <200911131302.53552.daniel.is.fischer@web.de> Am Freitag 13 November 2009 11:05:15 schrieb Andrew Coppin: > Colin Paul Adams wrote: > > If I had a dollar for every time I've written something like > > > > Andrew> case msg of eVENT_QUIT -> ... eVENT_POST -> ... > > Andrew> eVENT_RESIZE -> ... > > > > Andrew> and spent an hour trying to figure out why the messages > > Andrew> aren't being processed right... ;-) > > > > So why aren't they? > > Because what I *should* have written is > > case msg of > _ | msg == eVENT_QUIT -> ... > > | msg == eVENT_POST -> ... > | msg == eVENT_RESIZE -> ... > > which is something quite different. > > (And, entertainingly, because the incorrect version is perfectly valid > source code, no compiler errors or warnings...) It yells "overlapping patterns" -- you do pass -Wall, don't you? From ross at soi.city.ac.uk Fri Nov 13 07:48:42 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Fri Nov 13 07:24:25 2009 Subject: [Haskell-cafe] Weird dependency failure log In-Reply-To: References: Message-ID: <20091113124842.GA29430@soi.city.ac.uk> On Thu, Nov 12, 2009 at 06:32:48PM -0200, Maur??cio CA wrote: > There's one thing special about bindings-DSL. It's > a package with a set of macros for hsc2hs, and contains > no Haskell code. Maybe this revealed some hidden error > in package dependency checking. This is a package with no library and no executables. That's not supposed to work. From niklas.broberg at gmail.com Fri Nov 13 07:51:05 2009 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Fri Nov 13 07:26:47 2009 Subject: [Haskell-cafe] haskell-src-exts Question In-Reply-To: References: Message-ID: Hi Dominic, On Fri, Nov 13, 2009 at 9:49 AM, Dominic Steinitz wrote: > I would have expected the prettyprinter to produce this: > > pay tPD (a (length tOD + -1)) > > Do I have to write my own prettyprinter? Do I have to put in explicit > parentheses? The latter seems unsatisfactory as my generated AST is unambiguous > and bracketing ought to be part of the prettyprinter. The former would be quite > a lot of code as there are many cases to consider. I will start by admitting that the prettyprinter is something of the black sheep of HSE, simply because it's been completely inherited from haskell-src and I've hardly messed with at all (except for adding new cases of course). I'm not surprised that it doesn't (yet) work satisfactorily in all cases. Looking at your example, what you want is brackets to be inserted whenever the right subexpression in an application is non-atomic. That certainly seems reasonable to me. Would you file a ticket for it please? http://trac.haskell.org/haskell-src-exts :-) Cheers, /Niklas From mauricio.antunes at gmail.com Fri Nov 13 09:08:42 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Fri Nov 13 08:45:02 2009 Subject: [Haskell-cafe] Re: Weird dependency failure log In-Reply-To: <20091113124842.GA29430@soi.city.ac.uk> References: <20091113124842.GA29430@soi.city.ac.uk> Message-ID: >> There's one thing special about bindings-DSL. It's >> a package with a set of macros for hsc2hs, and contains >> no Haskell code. Maybe this revealed some hidden error >> in package dependency checking. > > This is a package with no library and no executables. > That's not supposed to work. It contains hsc2hs data all dependent packages use. Why shouldn't this be supposed to work? It does install needed files (two include files for hsc2hs), and they do stand for themselves to justify a package of its own. And other packages could also want to distribute just data. Say, a database of daytime saving dates to be used by a clock package. Thanks, Maur?cio From mlesniak at uni-kassel.de Fri Nov 13 09:15:00 2009 From: mlesniak at uni-kassel.de (Michael Lesniak) Date: Fri Nov 13 08:50:41 2009 Subject: [Haskell-cafe] Strange parallel behaviour with Ubuntu Karmic / GHC 6.10.4 Message-ID: <5f8b37690911130615w4439fcaav6c7b4be2ded1bbc2@mail.gmail.com> Hello, I'm currently developing some applications with explicit threading using forkIO and have strange behaviour on my freshly installed Ubuntu Karmic 9.10 (Kernel 2.6.31-14 SMP). Setup: Machine A: Quadcore, Ubuntu 9.04, Kernel 2.6.28-13 SMP Machine B: AMD Opteron 875, 8 cores, 2.6.18-164 SMP- (some redhat) Machine C: Dual-Core, Ubuntu 9.10, Kernel 2.6.31-14 SMP Compiler on all machines: ghc 6.10.4 (downloaded from GHCs official website) Program, Compilation, Execution A simple taskqueue with independent tasks and explicit parallelization (hence should deliver more or less perfect speedup). For one core wall-times around 16 are ok, for 2 a bit more than 8 seconds. Since I used the same sources and Makefiles on all machines all files were compiled with -threaded and started with +RTS -N2 -RTS. Testing: Machine A: Ok (meaning works and delivers the expected speedup) Machine B: Ok Machine C: Not ok (with -N2 wall times around 14-15 seconds) Looking at the core usage, for example with htop, I see that the second core is not really used on C. Executing OpenMP programs shows the expected speedup and usage of both cores, hence I do not think its a kind of general linux configuration problem. So, after all the testing I think its either the Linux Kernel or some other component of Ubuntu 9.10. But: Ubuntu is often used and I did not found any information regarding this problem. The simple solution of installing the old version of Ubuntu would probably help but should not be the way to go, should it? I'd be glad for any hints or comments, Michael -- Dipl.-Inf. Michael C. Lesniak University of Kassel Programming Languages / Methodologies Research Group Department of Computer Science and Electrical Engineering Wilhelmsh?her Allee 73 34121 Kassel Phone: +49-(0)561-804-6269 From michael.lesniak at gmail.com Fri Nov 13 09:30:14 2009 From: michael.lesniak at gmail.com (Michael Lesniak) Date: Fri Nov 13 09:05:54 2009 Subject: [Haskell-cafe] Strange parallel behaviour with Ubuntu Karmic / GHC 6.10.4 Message-ID: <5f8b37690911130630p74b72168k324206c4d8eca60b@mail.gmail.com> Hello, I'm currently developing some applications with explicit threading using forkIO and have strange behaviour on my freshly installed Ubuntu Karmic 9.10 (Kernel 2.6.31-14 SMP). Setup: Machine A: Quadcore, Ubuntu 9.04, Kernel 2.6.28-13 SMP Machine B: AMD Opteron 875, 8 cores, 2.6.18-164 SMP- (some redhat) Machine C: Dual-Core, Ubuntu 9.10, Kernel 2.6.31-14 SMP Compiler on all machines: ghc 6.10.4 (downloaded from GHCs official website) Program, Compilation, Execution A simple taskqueue with independent tasks and explicit parallelization (hence should deliver more or less perfect speedup). For one core wall-times around 16 are ok, for 2 a bit more than 8 seconds. Since I used the same sources and Makefiles on all machines all files were compiled with -threaded and started with +RTS -N2 -RTS. Testing: Machine A: Ok (meaning works and delivers the expected speedup) Machine B: Ok Machine C: Not ok (with -N2 wall times around 14-15 seconds) Looking at the core usage, for example with htop, I see that the second core is not really used on C. Executing OpenMP programs shows the expected speedup and usage of both cores, hence I do not think its a kind of general linux configuration problem. So, after all the testing I think its either the Linux Kernel or some other component of Ubuntu 9.10. But: Ubuntu is often used and I did not found any information regarding this problem. The simple solution of installing the old version of Ubuntu would probably help but should not be the way to go, should it? I'd be glad for any hints or comments, Michael -- Dipl.-Inf. Michael C. Lesniak University of Kassel Programming Languages / Methodologies Research Group Department of Computer Science and Electrical Engineering Wilhelmsh?her Allee 73 34121 Kassel Phone: +49-(0)561-804-6269 From jeremy.odonoghue at gmail.com Fri Nov 13 10:24:53 2009 From: jeremy.odonoghue at gmail.com (Jeremy O'Donoghue) Date: Fri Nov 13 10:00:33 2009 Subject: [Haskell-cafe] Cabal and autogenerated files In-Reply-To: <1258049778.4680.9994.camel@localhost> References: <1258049778.4680.9994.camel@localhost> Message-ID: <1258125893.17446.1345073725@webmail.messagingengine.com> On Thu, 12 Nov 2009 18:16 +0000, "Duncan Coutts" wrote: > On Thu, 2009-11-12 at 17:54 +0000, Jeremy O'Donoghue wrote: > > Hi all, > > > > Another, probably simple, question regarding cabalization. > > > > Part of wxcore, the low level abstraction in wxHaskell, consists of > > haskell modules which are generated automatically by parsing C headers > > using another tool, wxdirect. > > > > When trying to create an sdist package, we run into the problem that > > because we export modules which are automatically generated, after a > > 'clean', they do not exist, so the sdist package generation fails. > > So I take it that these modules are generated "from nothing" rather than > something like happy/alex pre-processors where the .hs files are > generated from .y/.x files. Cabal supports the latter fairly well and > you can add custom pre-processors in this style. It doesn't really > support generating modules out of thin-air in the build step (though it > does this internally for the Paths_pkgname module). They don't come from nothing as they are derived from a C header file and an Eiffel interface (for historical reasons). It sounds as though the custom preprocessor approach is closest to what we have/need. We have a custom config hook containing the following: myConfHook :: (Either GenericPackageDescription PackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo myConfHook (pkg0, pbi) flags = do createDirectoryIfMissing True wxcoreDirectory system $ "wxdirect -t --wxc " ++ sourceDirectory ++ " -o " ++ wxcoreDirectory ++ " " ++ wxcoreIncludeFile system $ "wxdirect -i --wxc " ++ sourceDirectory ++ " -o " ++ wxcoreDirectory ++ " " ++ wxcoreIncludeFile system $ "wxdirect -c --wxc " ++ sourceDirectory ++ " -o " ++ wxcoreDirectory ++ " " ++ wxcoreIncludeFile system $ "wxdirect -d --wxc " ++ sourceDirectory ++ " -o " ++ wxcoreDirectory ++ " " ++ intercalate " " eiffelFiles In this case, wxcoreDirectory resolves to "dist/build/autogen/Graphics/UI/WXCore". The calls to wxdirect generate a number of haskell files as output (currently in dist/build/autogen). Regards Jeremy -- Jeremy O'Donoghue jeremy.odonoghue@gmail.com From magicloud.magiclouds at gmail.com Fri Nov 13 11:14:56 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Fri Nov 13 10:50:36 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? Message-ID: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> Hi, I have looked the concept of monoid and something related, but still, I do not know why we use it? -- ??????? ??????? From RafaelGCPP.Linux at gmail.com Fri Nov 13 11:33:42 2009 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Fri Nov 13 11:09:23 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> Message-ID: <351ff25e0911130833k551ee56ag1dda6dfb5880081c@mail.gmail.com> Disclaimer: I don't really know all about category theory, so some definitions might not be absolutely correct. Monoid is the category of all types that have a empty value and an append operation. The best example is a list. instance Monoid [a] where mempty = [] mappend = (++) Why do I need it? Well, you can think of a function where you need to incrementally store data. Storing them to a Monoid, you can start with a list and then change to a Set, without changing the function itself, because it would be defined based on the Monoid operations. instance Ord a => Monoid (Set a) where mempty = empty mappend = union mconcat = unions Hope I have helped! Regards, Rafael On Fri, Nov 13, 2009 at 14:14, Magicloud Magiclouds < magicloud.magiclouds@gmail.com> wrote: > Hi, > I have looked the concept of monoid and something related, but > still, I do not know why we use it? > > -- > ??????? > ??????? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Rafael Gustavo da Cunha Pereira Pinto -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091113/7581ac7f/attachment.html From duncan.coutts at googlemail.com Fri Nov 13 11:42:03 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Fri Nov 13 11:17:46 2009 Subject: [Haskell-cafe] Re: Weird dependency failure log In-Reply-To: References: <20091113124842.GA29430@soi.city.ac.uk> Message-ID: <1258130523.4680.12718.camel@localhost> On Fri, 2009-11-13 at 12:08 -0200, Maur??cio CA wrote: > >> There's one thing special about bindings-DSL. It's > >> a package with a set of macros for hsc2hs, and contains > >> no Haskell code. Maybe this revealed some hidden error > >> in package dependency checking. > > > > This is a package with no library and no executables. > > That's not supposed to work. > > It contains hsc2hs data all dependent packages use. > > Why shouldn't this be supposed to work? It does install needed > files (two include files for hsc2hs), and they do stand for > themselves to justify a package of its own. Header files are associated with a library. If there is no library then nothing gets registered. This is by design. > And other packages could also want to distribute just data. Say, a > database of daytime saving dates to be used by a clock package. If it's not a library, nothing can depend on it. Duncan From stephen.tetley at gmail.com Fri Nov 13 11:48:25 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Fri Nov 13 11:24:06 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <351ff25e0911130833k551ee56ag1dda6dfb5880081c@mail.gmail.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <351ff25e0911130833k551ee56ag1dda6dfb5880081c@mail.gmail.com> Message-ID: <5fdc56d70911130848t6d983adm175c52a83e317b3a@mail.gmail.com> 2009/11/13 Rafael Gustavo da Cunha Pereira Pinto : > > Monoid is the category of all types that have a empty value and an append > operation. > Or more generally a neutral element and an associative operation: The multiplication monoid (1,*) 9*1*1*1 = 9 1 is neutral but you might be hard pressed to consider it _empty_. Best wishes Stephen From andrewcoppin at btinternet.com Fri Nov 13 11:52:34 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Nov 13 11:28:07 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <5fdc56d70911130848t6d983adm175c52a83e317b3a@mail.gmail.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <351ff25e0911130833k551ee56ag1dda6dfb5880081c@mail.gmail.com> <5fdc56d70911130848t6d983adm175c52a83e317b3a@mail.gmail.com> Message-ID: <4AFD8ED2.4050009@btinternet.com> Stephen Tetley wrote: > 2009/11/13 Rafael Gustavo da Cunha Pereira Pinto : > >> Monoid is the category of all types that have a empty value and an append >> operation. >> >> > > Or more generally a neutral element and an associative operation: > > The multiplication monoid (1,*) > > 9*1*1*1 = 9 > > 1 is neutral but you might be hard pressed to consider it _empty_. > This is the thing. If we had a class specifically for containers, that could be useful. If we had a class specifically for algebras, that could be useful. But a class that represents "any possible thing that can technically be considered a monoid" seems so absurdly general as to be almost useless. If you don't know what an operator *does*, being able to abstract over it isn't especially helpful... ...in my humble opinion. (Which, obviously, nobody else will agree with.) From ekirpichov at gmail.com Fri Nov 13 11:56:37 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Fri Nov 13 11:32:18 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> Message-ID: <5e0214850911130856i73ecb984t17eb7064ba7ca0cc@mail.gmail.com> There is an astonishing number of things in programming that are monoids: - Numbers, addition, 0 - Numbers, multiplication, 1 - Lists, concatenation, [] (including strings) - Sorted lists, merge with respect to a linear order, [] - Sets, union, {} - Maps, left-biased or right-biased union, {} - Maps K->V, union where Vs for same K get merged in some other monoid, {} - For any M: Subsets of M, intersection, M - Any lattice with an upper bound, minimum, upper bound; symmetrically for a lower-bounded set - If (S, *, u) is a monoid, then (A -> S, \f g x -> f x * g x, \x -> u) is a monoid - Product (a,b) and co-product (Either) of monoids - Parsers, alternation, a parser that always fails - etc. The benefits of calling something a monoid arise from using general-purpose structures operating on monoids: - Finger trees http://apfelmus.nfshost.com/monoid-fingertree.html - Aforementioned maps which merge values for a key in a given monoid - Aforementioned monoids lifted to functions - Monoidal folds (Data.Foldable) - ... 2009/11/13 Magicloud Magiclouds : > Hi, > I have looked the concept of monoid and something related, but > still, I do not know why we use it? > > -- > ??????? > ??????? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Eugene Kirpichov Web IR developer, market.yandex.ru From magnus at therning.org Fri Nov 13 12:00:12 2009 From: magnus at therning.org (Magnus Therning) Date: Fri Nov 13 11:35:53 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <4AFD8ED2.4050009@btinternet.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <351ff25e0911130833k551ee56ag1dda6dfb5880081c@mail.gmail.com> <5fdc56d70911130848t6d983adm175c52a83e317b3a@mail.gmail.com> <4AFD8ED2.4050009@btinternet.com> Message-ID: On Fri, Nov 13, 2009 at 4:52 PM, Andrew Coppin wrote: > Stephen Tetley wrote: >> >> 2009/11/13 Rafael Gustavo da Cunha Pereira Pinto >> : >> >>> >>> Monoid is the category of all types that have a empty value and an append >>> operation. >>> >>> >> >> Or more generally a neutral element and an associative operation: >> >> The multiplication monoid (1,*) >> >> 9*1*1*1 = 9 >> >> 1 is neutral but you might be hard pressed to consider it _empty_. >> > > This is the thing. If we had a class specifically for containers, that could > be useful. If we had a class specifically for algebras, that could be > useful. But a class that represents "any possible thing that can technically > be considered a monoid" seems so absurdly general as to be almost useless. > If you don't know what an operator *does*, being able to abstract over it > isn't especially helpful... > > ...in my humble opinion. (Which, obviously, nobody else will agree with.) But can't you say exactly the same about Monads? And at times it's useful to be able to switch between getting all results (List) and getting one (or none, Maybe), no? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From magicloud.magiclouds at gmail.com Fri Nov 13 12:09:35 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Fri Nov 13 11:45:16 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <351ff25e0911130833k551ee56ag1dda6dfb5880081c@mail.gmail.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <351ff25e0911130833k551ee56ag1dda6dfb5880081c@mail.gmail.com> Message-ID: <3bd412d40911130909n7beff82bk24ed6b55a8eeb3e@mail.gmail.com> Hum... simple like that. So you meant the Monoid just abstracts/represents the ability to build a stack, right? 2009/11/14 Rafael Gustavo da Cunha Pereira Pinto : > Disclaimer: I don't really know all about category theory, so some > definitions might not be absolutely correct. > > Monoid is the category of all types that have a empty value and an append > operation. > > The best example is a list. > > instance Monoid [a] where > > mempty = [] > mappend = (++) > > > > Why do I need it? Well, you can think of a function where you need to > incrementally store data. > > Storing them to a Monoid, you can start with a list and then change to a > Set, without changing the function itself, because it would be defined based > on the Monoid operations. > > instance Ord a => Monoid (Set a) where > > mempty = empty > mappend = union > > mconcat = unions > > Hope I have helped! > > Regards, > > Rafael > > > > On Fri, Nov 13, 2009 at 14:14, Magicloud Magiclouds > wrote: >> >> Hi, >> ?I have looked the concept of monoid and something related, but >> still, I do not know why we use it? >> >> -- >> ??????? >> ??????? >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > > -- > Rafael Gustavo da Cunha Pereira Pinto > > -- ??????? ??????? From andrewcoppin at btinternet.com Fri Nov 13 12:09:56 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Nov 13 11:45:30 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <351ff25e0911130833k551ee56ag1dda6dfb5880081c@mail.gmail.com> <5fdc56d70911130848t6d983adm175c52a83e317b3a@mail.gmail.com> <4AFD8ED2.4050009@btinternet.com> Message-ID: <4AFD92E4.1030104@btinternet.com> Magnus Therning wrote: > On Fri, Nov 13, 2009 at 4:52 PM, Andrew Coppin > wrote: > >> A class that represents "any possible thing that can technically >> be considered a monoid" seems so absurdly general as to be almost useless. >> If you don't know what an operator *does*, being able to abstract over it >> isn't especially helpful... >> > > But can't you say exactly the same about Monads? > I know nothing about how mathematicians use monads. However, Haskell uses them in one specific way: for controlling (not necessarily _sequencing_) statement execution. This is a fairly rigidly-defined notion. By contrast, Integer forms an infinite family of different monoids, yet it can have only a single Monoid instance... I notice that there's a an Alternative class, which is isomorphic to Monoid, but rather than being some arbitrary monoid, it's a monoid with a specific meaning. This, I would argue, is far more useful. From magicloud.magiclouds at gmail.com Fri Nov 13 12:11:27 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Fri Nov 13 11:47:08 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <5fdc56d70911130848t6d983adm175c52a83e317b3a@mail.gmail.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <351ff25e0911130833k551ee56ag1dda6dfb5880081c@mail.gmail.com> <5fdc56d70911130848t6d983adm175c52a83e317b3a@mail.gmail.com> Message-ID: <3bd412d40911130911v4f3ac0b9laebca79f5921491d@mail.gmail.com> That is OK. Since understand the basic concept of monoid (I mean the thing in actual math), the idea here is totally not hard for me. But the sample here does not show why (or how) we use it in programming, right? On Sat, Nov 14, 2009 at 12:48 AM, Stephen Tetley wrote: > 2009/11/13 Rafael Gustavo da Cunha Pereira Pinto : >> >> Monoid is the category of all types that have a empty value and an append >> operation. >> > > Or more generally a neutral element and an associative operation: > > The multiplication monoid (1,*) > > 9*1*1*1 = 9 > > 1 is neutral but you might be hard pressed to consider it _empty_. > > > Best wishes > > Stephen > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- ??????? ??????? From stephen.tetley at gmail.com Fri Nov 13 12:13:30 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Fri Nov 13 11:49:10 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <351ff25e0911130833k551ee56ag1dda6dfb5880081c@mail.gmail.com> <5fdc56d70911130848t6d983adm175c52a83e317b3a@mail.gmail.com> <4AFD8ED2.4050009@btinternet.com> Message-ID: <5fdc56d70911130913h15897632pf01ad224dbd04461@mail.gmail.com> 2009/11/13 Magnus Therning : > On Fri, Nov 13, 2009 at 4:52 PM, Andrew Coppin > wrote: >> >> This is the thing. If we had a class specifically for containers, that could >> be useful. If we had a class specifically for algebras, that could be >> useful. But a class that represents "any possible thing that can technically >> be considered a monoid" seems so absurdly general as to be almost useless. >> If you don't know what an operator *does*, being able to abstract over it >> isn't especially helpful... >> >> ...in my humble opinion. (Which, obviously, nobody else will agree with.) > > But can't you say exactly the same about Monads? There's a comment about monads for programming that goes along the lines of 'Monads are a just a structure (ADT?), but they happen to be a very good one." Does anyone know the original version (not my paraphrase) and who the originator was? Thanks Stephen From mauricio.antunes at gmail.com Fri Nov 13 12:15:40 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Fri Nov 13 11:51:45 2009 Subject: [Haskell-cafe] Re: Could someone teach me why we use Data.Monoid? In-Reply-To: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> Message-ID: > I have looked the concept of monoid and something related, but > still, I do not know why we use it? I don't know if it's a good example, but it's simple. This package I wrote uses reverse polish notation to write gtk2hs layout windows. http://hackage.haskell.org/package/gtk2hs-rpn Since the type for operators used in the stack is a Monoid instance, you can combine many of them to create new operators. I believe you can think of monoids as things you can sequence to make new ones of the same type, but someone with better knowledge please say if this is actually a misleading idea. Best, Maur?cio From RafaelGCPP.Linux at gmail.com Fri Nov 13 12:16:47 2009 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Fri Nov 13 11:52:32 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <4AFD8ED2.4050009@btinternet.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <351ff25e0911130833k551ee56ag1dda6dfb5880081c@mail.gmail.com> <5fdc56d70911130848t6d983adm175c52a83e317b3a@mail.gmail.com> <4AFD8ED2.4050009@btinternet.com> Message-ID: <351ff25e0911130916j375bf542u89502c04203d6680@mail.gmail.com> *"...in my humble opinion. (Which, obviously, nobody else will agree with.)" * I somewhat agree with your opinion!! What I miss the most is practical examples: 1) A function that uses a Monoid as a container 2) A function that uses Monoid as algebra and so on, for most of categories. I had a hard time understanding monads, not because I didn't understand the concept of a monad, but because practical uses are missing, except on Wadler's paper! Regards Rafael On Fri, Nov 13, 2009 at 14:52, Andrew Coppin wrote: > Stephen Tetley wrote: > >> 2009/11/13 Rafael Gustavo da Cunha Pereira Pinto < >> RafaelGCPP.Linux@gmail.com>: >> >> >>> Monoid is the category of all types that have a empty value and an append >>> operation. >>> >>> >>> >> >> Or more generally a neutral element and an associative operation: >> >> The multiplication monoid (1,*) >> >> 9*1*1*1 = 9 >> >> 1 is neutral but you might be hard pressed to consider it _empty_. >> >> > > This is the thing. If we had a class specifically for containers, that > could be useful. If we had a class specifically for algebras, that could be > useful. But a class that represents "any possible thing that can technically > be considered a monoid" seems so absurdly general as to be almost useless. > If you don't know what an operator *does*, being able to abstract over it > isn't especially helpful... > > ...in my humble opinion. (Which, obviously, nobody else will agree with.) > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Rafael Gustavo da Cunha Pereira Pinto -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091113/1227dc21/attachment.html From magicloud.magiclouds at gmail.com Fri Nov 13 12:17:02 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Fri Nov 13 11:52:45 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <5e0214850911130856i73ecb984t17eb7064ba7ca0cc@mail.gmail.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <5e0214850911130856i73ecb984t17eb7064ba7ca0cc@mail.gmail.com> Message-ID: <3bd412d40911130917o50a50786pcc513984a3a6da44@mail.gmail.com> I see. Then what is about Dual and Endo? Especially Endo, I completely confused.... 2009/11/14 Eugene Kirpichov : > There is an astonishing number of things in programming that are monoids: > ?- Numbers, addition, 0 > ?- Numbers, multiplication, 1 > ?- Lists, concatenation, [] (including strings) > ?- Sorted lists, merge with respect to a linear order, [] > ?- Sets, union, {} > ?- Maps, left-biased or right-biased union, {} > ?- Maps K->V, union where Vs for same K get merged in some other monoid, {} > ?- For any M: Subsets of M, intersection, M > ?- Any lattice with an upper bound, minimum, upper bound; > symmetrically for a lower-bounded set > ?- If (S, *, u) ?is a monoid, then (A -> S, \f g x -> f x * g x, \x -> > u) is a monoid > ?- Product (a,b) and co-product (Either) of monoids > ?- Parsers, alternation, a parser that always fails > ?- etc. > > The benefits of calling something a monoid arise from using > general-purpose structures operating on monoids: > ?- Finger trees http://apfelmus.nfshost.com/monoid-fingertree.html > ?- Aforementioned maps which merge values for a key in a given monoid > ?- Aforementioned monoids lifted to functions > ?- Monoidal folds (Data.Foldable) > ?- ... > > 2009/11/13 Magicloud Magiclouds : >> Hi, >> ?I have looked the concept of monoid and something related, but >> still, I do not know why we use it? >> >> -- >> ??????? >> ??????? >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru > -- ??????? ??????? From leimy2k at gmail.com Fri Nov 13 12:30:23 2009 From: leimy2k at gmail.com (David Leimbach) Date: Fri Nov 13 12:06:06 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <4AFD8ED2.4050009@btinternet.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <351ff25e0911130833k551ee56ag1dda6dfb5880081c@mail.gmail.com> <5fdc56d70911130848t6d983adm175c52a83e317b3a@mail.gmail.com> <4AFD8ED2.4050009@btinternet.com> Message-ID: <3e1162e60911130930l2fbafecfrf86f2da28d150a7c@mail.gmail.com> On Fri, Nov 13, 2009 at 8:52 AM, Andrew Coppin wrote: > Stephen Tetley wrote: > >> 2009/11/13 Rafael Gustavo da Cunha Pereira Pinto < >> RafaelGCPP.Linux@gmail.com>: >> >> >>> Monoid is the category of all types that have a empty value and an append >>> operation. >>> >>> >>> >> >> Or more generally a neutral element and an associative operation: >> >> The multiplication monoid (1,*) >> >> 9*1*1*1 = 9 >> >> 1 is neutral but you might be hard pressed to consider it _empty_. >> >> > > This is the thing. If we had a class specifically for containers, that > could be useful. If we had a class specifically for algebras, that could be > useful. But a class that represents "any possible thing that can technically > be considered a monoid" seems so absurdly general as to be almost useless. > If you don't know what an operator *does*, being able to abstract over it > isn't especially helpful... > > ...in my humble opinion. (Which, obviously, nobody else will agree with.) Well to your credit, many people wonder what it means for something to implement the Monoid interface, or even why the Monoid interface is useful. Programmers who don't know what Monoids are may not be aware of the varying alternatives of Monoid implementations. They're curious things to have, but are they useful? :-) Sum vs Product spells out two ways to use Ints in a Monoid context. But we could have done the same with the Functor implementation for lists via fmap now couldn't we? Is anyone really using Sum and Product where Functors get the job done? Practically speaking, I can explain to coworkers the concept of a Functor a lot easier than Monoids so I don't choose to use Monoids explicitly in my code. I do use MonadPlus though, especially with Maybe as it makes a nice short-circuit syntax around alternatives for potential Nothing results. So in a way I'm possibly shooting myself in the foot if I have to explain the code to someone who was expecting a case or an if expression. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091113/ba78b4dd/attachment.html From magicloud.magiclouds at gmail.com Fri Nov 13 12:31:32 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Fri Nov 13 12:07:17 2009 Subject: [Haskell-cafe] Re: Could someone teach me why we use Data.Monoid? In-Reply-To: References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> Message-ID: <3bd412d40911130931u5fb20a4auc0d779768b57c62d@mail.gmail.com> It is a great example, shows both howto and benefits. Thanks. 2009/11/14 Maur??cio CA : >> ?I have looked the concept of monoid and something related, but >> still, I do not know why we use it? > > I don't know if it's a good example, but it's simple. This > package I wrote uses reverse polish notation to write gtk2hs > layout windows. > > http://hackage.haskell.org/package/gtk2hs-rpn > > Since the type for operators used in the stack is a Monoid > instance, you can combine many of them to create new operators. > > I believe you can think of monoids as things you can sequence > to make new ones of the same type, but someone with better > knowledge please say if this is actually a misleading idea. > > Best, > Maur?cio > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- ??????? ??????? From ekmett at gmail.com Fri Nov 13 12:33:11 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Nov 13 12:08:50 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <3bd412d40911130911v4f3ac0b9laebca79f5921491d@mail.gmail.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <351ff25e0911130833k551ee56ag1dda6dfb5880081c@mail.gmail.com> <5fdc56d70911130848t6d983adm175c52a83e317b3a@mail.gmail.com> <3bd412d40911130911v4f3ac0b9laebca79f5921491d@mail.gmail.com> Message-ID: <7fb8f82f0911130933x2eb0f4f0o96f3b43fc4192135@mail.gmail.com> A monoid is just an associative binary operation with a unit. They appear all over the place. Why do we bother to talk about them in programming? Well, it turns out that there are a lot of ways you can take advantage of that fairly minimal amount of structure. For one, you could take any container worth of values that can be mapped into the monoid and apply the monoid to the elements the container in a left to right or right to left or arbitrary ordering, and by the magic of associativity you will get the same answer. Since you are free to reparenthesize you can even compute the result in parallel. Normally you have to distinguish between foldr and foldl. When the operation you are applying is monoidal, you just have fold (from Data.Foldable). And the container can choose the traversal that makes the most sense for it. One particularly interesting, if somewhat complex monoid is the 'fingertree' monoid, which lets you glue together fingertrees of values that have some other monoidal measure on them. This is actually a pretty tricky data structure to get right, but it can be written once and for all (and has been tucked in Data.FingerTree) and is parameterized on an arbitrary monoidal measure. I find uses for this structure all over the place. For instance, FingerTrees of ByteStrings make a great text buffer with fast splicing operations, while still allowing them to be sliced at arbitrary positions if you use a monoidal measure for the size. In my monoids package I have several other monoids of interest. For instance, if I am interested in reducing a container of values with a monoid, I can turn to data compression techniques to build a variation on the container that can be decompressed inside of the monoid. Lempel Ziv 78 describes a compression technique, that can be applied to improve the sharing of monoidal intermediate results. Viewing the world this way helps turn data compression techniques into efficiently reducible data structures. The fact that you can use associativity to reparenthesize for parallelism, the unit to avoid having to perfectly subdivide into an exact number of cores, and that you can feed the result into a fingertree lets you build structures that you can build initially in parallel, and update incrementally for a reduced cost. All for the low low price of using a little bit of mathematical formalism. I have a few posts on monoids and my monoids package on my blog at comonad.com, which may help you get your head around their use outside of the realm of pure mathematics. -Edward Kmett On Fri, Nov 13, 2009 at 12:11 PM, Magicloud Magiclouds < magicloud.magiclouds@gmail.com> wrote: > That is OK. Since understand the basic concept of monoid (I mean the > thing in actual math), the idea here is totally not hard for me. But > the sample here does not show why (or how) we use it in programming, > right? > > On Sat, Nov 14, 2009 at 12:48 AM, Stephen Tetley > wrote: > > 2009/11/13 Rafael Gustavo da Cunha Pereira Pinto < > RafaelGCPP.Linux@gmail.com>: > >> > >> Monoid is the category of all types that have a empty value and an > append > >> operation. > >> > > > > Or more generally a neutral element and an associative operation: > > > > The multiplication monoid (1,*) > > > > 9*1*1*1 = 9 > > > > 1 is neutral but you might be hard pressed to consider it _empty_. > > > > > > Best wishes > > > > Stephen > > _______________________________________________ > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091113/e049dbdd/attachment.html From ekirpichov at gmail.com Fri Nov 13 12:37:57 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Fri Nov 13 12:13:40 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <3bd412d40911130917o50a50786pcc513984a3a6da44@mail.gmail.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <5e0214850911130856i73ecb984t17eb7064ba7ca0cc@mail.gmail.com> <3bd412d40911130917o50a50786pcc513984a3a6da44@mail.gmail.com> Message-ID: <5e0214850911130937y3adb263am9103201eb4ec828@mail.gmail.com> For every monoid (M, *, u), the dual to it is the monoid (Dual M, \x y -> y * x, u) For every type A, there exists the A-endomorphism monoid (A->A, (.), id). Endo A is just a newtype for A -> A. More simply, dualization is flipping the binary operation, and the endo monoid is the monoid of functions a->a with composition. 2009/11/13 Magicloud Magiclouds : > I see. Then what is about Dual and Endo? Especially Endo, I completely > confused.... > > 2009/11/14 Eugene Kirpichov : >> There is an astonishing number of things in programming that are monoids: >> - Numbers, addition, 0 >> - Numbers, multiplication, 1 >> - Lists, concatenation, [] (including strings) >> - Sorted lists, merge with respect to a linear order, [] >> - Sets, union, {} >> - Maps, left-biased or right-biased union, {} >> - Maps K->V, union where Vs for same K get merged in some other monoid, {} >> - For any M: Subsets of M, intersection, M >> - Any lattice with an upper bound, minimum, upper bound; >> symmetrically for a lower-bounded set >> - If (S, *, u) is a monoid, then (A -> S, \f g x -> f x * g x, \x -> >> u) is a monoid >> - Product (a,b) and co-product (Either) of monoids >> - Parsers, alternation, a parser that always fails >> - etc. >> >> The benefits of calling something a monoid arise from using >> general-purpose structures operating on monoids: >> - Finger trees http://apfelmus.nfshost.com/monoid-fingertree.html >> - Aforementioned maps which merge values for a key in a given monoid >> - Aforementioned monoids lifted to functions >> - Monoidal folds (Data.Foldable) >> - ... >> >> 2009/11/13 Magicloud Magiclouds : >>> Hi, >>> I have looked the concept of monoid and something related, but >>> still, I do not know why we use it? >>> >>> -- >>> ??????? >>> ??????? >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> >> >> >> >> -- >> Eugene Kirpichov >> Web IR developer, market.yandex.ru >> > > > > -- > ??????? > ??????? > -- Eugene Kirpichov Web IR developer, market.yandex.ru From anton at appsolutions.com Fri Nov 13 12:46:31 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Fri Nov 13 12:22:15 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <4AFD8ED2.4050009@btinternet.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <351ff25e0911130833k551ee56ag1dda6dfb5880081c@mail.gmail.com> <5fdc56d70911130848t6d983adm175c52a83e317b3a@mail.gmail.com> <4AFD8ED2.4050009@btinternet.com> Message-ID: <4AFD9B77.6050904@appsolutions.com> Andrew Coppin wrote: > This is the thing. If we had a class specifically for containers, that > could be useful. If we had a class specifically for algebras, that could > be useful. But a class that represents "any possible thing that can > technically be considered a monoid" seems so absurdly general as to be > almost useless. You don't have to look any further than the Writer monad to find an example of how this kind of abstraction is useful. The Writer monad uses a monoid to accumulate results. The monoid provided to Writer could be container-like, like a list; it could be a record whose fields are updated with each operation; it could be a number whose value changes with each operation; etc. The point is that it's general: it can be any value that can be combined with another value of the same type, using some operation to do that combination. Sigfpe's article about monoids goes into more detail: http://blog.sigfpe.com/2009/01/haskell-monoids-and-their-uses.html > If you don't know what an operator *does*, being able to > abstract over it isn't especially helpful... The author of the Writer monad didn't know, and doesn't need to care, what the operator does. To him, being able to abstract over this unknown operator was not only helpful, but critical: without that, you'd need a different type of Writer for different types of accumulator. Indeed, we see that kind of thing regularly in lesser languages, where e.g. a logging class might require an instance of a container class to log to, so that if you want to do an accumulation that doesn't involve a container, you're out of luck. Or perhaps you get clever and implement a container class that actually wraps some non-container like value, so that "appending" to the container updates the value. Now you've reinvented monoids, and proved that the author of the logging class *did* need to be able to abstract over an unknown operator, but just didn't realize it. Anton From d at vidplace.com Fri Nov 13 12:48:13 2009 From: d at vidplace.com (David Place) Date: Fri Nov 13 12:23:58 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <20091113164723.98782324ADE@www.haskell.org> References: <20091113164723.98782324ADE@www.haskell.org> Message-ID: <59B81748-BEF7-47A6-918A-9E3DF77518DA@vidplace.com> Magicloud Magiclouds wrote: > Message: 26 > Date: Sat, 14 Nov 2009 01:11:27 +0800 > From: Magicloud Magiclouds > Subject: Re: [Haskell-cafe] Could someone teach me why we use > Data.Monoid? > To: Stephen Tetley > Cc: haskell-cafe > Message-ID: > <3bd412d40911130911v4f3ac0b9laebca79f5921491d@mail.gmail.com> > Content-Type: text/plain; charset=UTF-8 > > That is OK. Since understand the basic concept of monoid (I mean the > thing in actual math), the idea here is totally not hard for me. But > the sample here does not show why (or how) we use it in programming, > right? For an example of it's use, you might enjoy reading my article in the Monad.Reader "How to Refold a Map." > http://www.haskell.org/sitewiki/images/6/6a/TMR-Issue11.pdf Cheers, David From magicloud.magiclouds at gmail.com Fri Nov 13 12:48:17 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Fri Nov 13 12:24:00 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <5e0214850911130937y3adb263am9103201eb4ec828@mail.gmail.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <5e0214850911130856i73ecb984t17eb7064ba7ca0cc@mail.gmail.com> <3bd412d40911130917o50a50786pcc513984a3a6da44@mail.gmail.com> <5e0214850911130937y3adb263am9103201eb4ec828@mail.gmail.com> Message-ID: <3bd412d40911130948v3b56e1f8v89be8affbeb64cd2@mail.gmail.com> Thank you guys. I think I learned a lot. Pretty confusing and interesting. 2009/11/14 Eugene Kirpichov : > For every monoid (M, *, u), the dual to it is the monoid (Dual M, \x y > -> y * x, u) > For every type A, there exists the A-endomorphism monoid (A->A, (.), > id). Endo A is just a newtype for A -> A. > > More simply, dualization is flipping the binary operation, and the > endo monoid is the monoid of functions a->a with composition. > > 2009/11/13 Magicloud Magiclouds : >> I see. Then what is about Dual and Endo? Especially Endo, I completely >> confused.... >> >> 2009/11/14 Eugene Kirpichov : >>> There is an astonishing number of things in programming that are monoids: >>> ?- Numbers, addition, 0 >>> ?- Numbers, multiplication, 1 >>> ?- Lists, concatenation, [] (including strings) >>> ?- Sorted lists, merge with respect to a linear order, [] >>> ?- Sets, union, {} >>> ?- Maps, left-biased or right-biased union, {} >>> ?- Maps K->V, union where Vs for same K get merged in some other monoid, {} >>> ?- For any M: Subsets of M, intersection, M >>> ?- Any lattice with an upper bound, minimum, upper bound; >>> symmetrically for a lower-bounded set >>> ?- If (S, *, u) ?is a monoid, then (A -> S, \f g x -> f x * g x, \x -> >>> u) is a monoid >>> ?- Product (a,b) and co-product (Either) of monoids >>> ?- Parsers, alternation, a parser that always fails >>> ?- etc. >>> >>> The benefits of calling something a monoid arise from using >>> general-purpose structures operating on monoids: >>> ?- Finger trees http://apfelmus.nfshost.com/monoid-fingertree.html >>> ?- Aforementioned maps which merge values for a key in a given monoid >>> ?- Aforementioned monoids lifted to functions >>> ?- Monoidal folds (Data.Foldable) >>> ?- ... >>> >>> 2009/11/13 Magicloud Magiclouds : >>>> Hi, >>>> ?I have looked the concept of monoid and something related, but >>>> still, I do not know why we use it? >>>> >>>> -- >>>> ??????? >>>> ??????? >>>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >>>> >>> >>> >>> >>> -- >>> Eugene Kirpichov >>> Web IR developer, market.yandex.ru >>> >> >> >> >> -- >> ??????? >> ??????? >> > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru > -- ??????? ??????? From mauricio.antunes at gmail.com Fri Nov 13 12:53:22 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Fri Nov 13 12:29:30 2009 Subject: [Haskell-cafe] Re: Weird dependency failure log In-Reply-To: <1258130523.4680.12718.camel@localhost> References: <20091113124842.GA29430@soi.city.ac.uk> <1258130523.4680.12718.camel@localhost> Message-ID: >>> This is a package with no library and no executables. That's >>> not supposed to work. >> Why shouldn't this be supposed to work? It does install needed >> files (two include files for hsc2hs), and they do stand for >> themselves to justify a package of its own. > Header files are associated with a library. If there is no > library then nothing gets registered. This is by design. Doesn't Cabal option 'install-includes' contradicts that? > If it's not a library, nothing can depend on it. But please tell me then where my package fits. Many libraries I wrote and use depend heavily on it. Versioning in this package is extremely important, as a change in design for any macro would change all names in depending libraries. Thanks, Maur?cio From greg at gregorycollins.net Fri Nov 13 12:57:20 2009 From: greg at gregorycollins.net (Gregory Collins) Date: Fri Nov 13 12:33:00 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <3bd412d40911130917o50a50786pcc513984a3a6da44@mail.gmail.com> (Magicloud Magiclouds's message of "Sat, 14 Nov 2009 01:17:02 +0800") References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <5e0214850911130856i73ecb984t17eb7064ba7ca0cc@mail.gmail.com> <3bd412d40911130917o50a50786pcc513984a3a6da44@mail.gmail.com> Message-ID: <87pr7ms3y7.fsf@gregorycollins.net> Magicloud Magiclouds writes: > I see. Then what is about Dual and Endo? Especially Endo, I completely > confused.... It should help to look at the instances: > -- | The dual of a monoid, obtained by swapping the arguments of 'mappend'. > newtype Dual a = Dual { getDual :: a } > deriving (Eq, Ord, Read, Show, Bounded) > > instance Monoid a => Monoid (Dual a) where > mempty = Dual mempty > Dual x `mappend` Dual y = Dual (y `mappend` x) You can tag a monoidal value as being "Dual" and then invoking "mappend" will swap the argument order. Re: Endo: > -- | The monoid of endomorphisms under composition. > newtype Endo a = Endo { appEndo :: a -> a } > > instance Monoid (Endo a) where > mempty = Endo id > Endo f `mappend` Endo g = Endo (f . g) It's a way of labelling functions of type a -> a ("endomorphism") as being a monoid under composition (the "." operator). A short example: > GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > Prelude> import Data.Monoid > Prelude Data.Monoid> let f = ((+2) :: Double -> Double) > Prelude Data.Monoid> let g = ((/4) :: Double -> Double) > Prelude Data.Monoid> appEndo (Endo f `mappend` Endo g) 4 > 3.0 same as "(f . g) 4" == 4/4 + 2 > Prelude Data.Monoid> appEndo (getDual (Dual (Endo f) `mappend` Dual (Endo g))) 4 > 1.5 same as "(g . f) 4" == (4+2)/4. G. -- Gregory Collins From lemmih at gmail.com Fri Nov 13 12:58:22 2009 From: lemmih at gmail.com (Lemmih) Date: Fri Nov 13 12:34:02 2009 Subject: [Haskell-cafe] Package Woes In-Reply-To: <200911120447.52860.daniel.is.fischer@web.de> References: <200911120447.52860.daniel.is.fischer@web.de> Message-ID: On Thu, Nov 12, 2009 at 4:47 AM, Daniel Fischer wrote: > Sorry, slightly off-topic. > > I wanted to install LHC to compare that to GHC and JHC, but alas: > > dafis@linux-mkk1:~/Haskell/LHC/lhc-0.8> cabal install -fwith-libs -flhc-regress > Resolving dependencies... > Configuring libffi-0.1... > cabal: The pkg-config package libffi is required but it could not be found. > cabal: Error: some packages failed to install: > lhc-0.8 depends on libffi-0.1 which failed to install. > libffi-0.1 failed during the configure step. The exception was: > exit: ExitFailure 1 > > Okay, so I installed libffi, but to no avail, still can't find libffi. > The problem is apparently that libffi doesn't come with a .pc file, so pkg-config doesn't > know about it. We no longer use libffi and I've removed the dependency. However, you're most likely to hit further obstacles when it comes to building the base libraries for LHC. I recommend waiting for the next stable release. -- Cheers, Lemmih From stephen.tetley at gmail.com Fri Nov 13 13:10:06 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Fri Nov 13 12:45:47 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <59B81748-BEF7-47A6-918A-9E3DF77518DA@vidplace.com> References: <20091113164723.98782324ADE@www.haskell.org> <59B81748-BEF7-47A6-918A-9E3DF77518DA@vidplace.com> Message-ID: <5fdc56d70911131010q1152ac24uffd95ad7cf1045a9@mail.gmail.com> > Magicloud Magiclouds wrote: >> That is OK. Since understand the basic concept of monoid (I mean the >> thing in actual math), the idea here is totally not hard for me. But >> the sample here does not show why (or how) we use it in programming, >> right? Hi Magicloud Conal Elliott has an interesting paper about designing your programs in relation to the standard type classes:. http://conal.net/papers/type-class-morphisms/ Thinking about the data structures and functions in your program with regards the standard classes is very useful useful for clarifying your design. And certainly if you decide your data structure fits the Monoid interface then you will be presenting it to others who use your program in the 'standard vocabulary'. But even for Monoid which seemingly presents a simple interface (mempty, mappend) deciding whether the _container_ you have is naturally a monoid can be difficult. A personal example, I've been developing a drawing library for a couple of months and still can't decide whether a bounding box should be a monoid (mempty, append) or a groupoid (just append) where append in both cases is union. Even though I haven't resolved this problem, having the framework of monoid versus groupoid at least gives me the _terminology_ to consider the problem. Best wishes Stephen From daniel.is.fischer at web.de Fri Nov 13 13:37:26 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Nov 13 13:14:35 2009 Subject: [Haskell-cafe] Package Woes In-Reply-To: References: <200911120447.52860.daniel.is.fischer@web.de> Message-ID: <200911131937.26924.daniel.is.fischer@web.de> Am Freitag 13 November 2009 18:58:22 schrieb Lemmih: > We no longer use libffi and I've removed the dependency. > > However, you're most likely to hit further obstacles when it comes to > building the base libraries for LHC. I recommend waiting for the next > stable release. Is there already a timeline? From rwbarton at math.harvard.edu Fri Nov 13 13:38:31 2009 From: rwbarton at math.harvard.edu (Reid Barton) Date: Fri Nov 13 13:14:39 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <5e0214850911130937y3adb263am9103201eb4ec828@mail.gmail.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <5e0214850911130856i73ecb984t17eb7064ba7ca0cc@mail.gmail.com> <3bd412d40911130917o50a50786pcc513984a3a6da44@mail.gmail.com> <5e0214850911130937y3adb263am9103201eb4ec828@mail.gmail.com> Message-ID: <20091113183831.GA30386@rwbarton.mit.edu> On Fri, Nov 13, 2009 at 08:37:57PM +0300, Eugene Kirpichov wrote: > For every monoid (M, *, u), the dual to it is the monoid (Dual M, \x y > -> y * x, u) The entirely standard name for this is the opposite monoid. The only places I have seen the name "dual monoid" used to mean opposite monoid are in Data.Monoid and subsequently by some Haskellers. A very good reason not to use the name "dual monoid" is that the basic point of duality is contravariance. The prototypical example of duality is the dual V^* of a finite-dimensional vector space V, defined as the vector space of all linear maps from V to the ground field. If f : V -> W is a linear map, then we get an induced linear map f^* : W^* -> V^* by precomposing with f. Note that f^* "goes in the other direction"; the functor -^* is contravariant. Perhaps a more familiar example is from classical Boolean algebra. If P is a proposition, it's sensible to call not-P the dual of P, since an implication P -> Q yields an implication not-Q -> not-P. (This is closely related to the previous example, since not-P is the statement P -> false.) The notion of opposite monoids is not an example of duality. Given a monoid homomorphism f : M -> N, there is an induced opposite homomorphism f^op : M^op -> N^op, which is the same as f on elements. It goes the same direction as f; -^op is a covariant functor. If you're not convinced by these arguments, try googling for "opposite monoid" and "dual monoid" to see the standard usage for yourself. There is no standard meaning for the phrase "dual monoid", but I would venture that it is never used to mean "opposite monoid" in the mathematical literature. (Sorry for the rant.) Regards, Reid Barton From ekmett at gmail.com Fri Nov 13 13:43:35 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Nov 13 13:19:17 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <5fdc56d70911131010q1152ac24uffd95ad7cf1045a9@mail.gmail.com> References: <20091113164723.98782324ADE@www.haskell.org> <59B81748-BEF7-47A6-918A-9E3DF77518DA@vidplace.com> <5fdc56d70911131010q1152ac24uffd95ad7cf1045a9@mail.gmail.com> Message-ID: <7fb8f82f0911131043v3ae3066ftca1d8c676033c921@mail.gmail.com> On Fri, Nov 13, 2009 at 1:10 PM, Stephen Tetley wrote: > > Magicloud Magiclouds wrote: > > >> That is OK. Since understand the basic concept of monoid (I mean the > >> thing in actual math), the idea here is totally not hard for me. But > >> the sample here does not show why (or how) we use it in programming, > >> right? > > Hi Magicloud > > Conal Elliott has an interesting paper about designing your programs > in relation to the standard type classes:. > > http://conal.net/papers/type-class-morphisms/ > > Thinking about the data structures and functions in your program with > regards the standard classes is very useful useful for clarifying your > design. And certainly if you decide your data structure fits the > Monoid interface then you will be presenting it to others who use your > program in the 'standard vocabulary'. But even for Monoid which > seemingly presents a simple interface (mempty, mappend) deciding > whether the _container_ you have is naturally a monoid can be > difficult. > > A personal example, I've been developing a drawing library for a > couple of months and still can't decide whether a bounding box should > be a monoid (mempty, append) or a groupoid (just append) where append > in both cases is union. Even though I haven't resolved this problem, > having the framework of monoid versus groupoid at least gives me the > _terminology_ to consider the problem. > Watch out, in more common parlance, having just an binary operation is a magma, while having a category with full inverses yields a groupoid. I haven't seen many people use the older groupoid term for magmas, if only because they started to have naming conflicts with the category theory people, and Bourbaki's 'magma' was available and unambiguous. =) And of course magma is not to be confused with the notion of a semigroup, which is a binary associative operation, and is therefore much more similar to a monoid in that all it lacks is a unit. -Edward Kmett > > Best wishes > > Stephen > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091113/35a63908/attachment.html From stephen.tetley at gmail.com Fri Nov 13 14:44:00 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Fri Nov 13 14:19:41 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <7fb8f82f0911131043v3ae3066ftca1d8c676033c921@mail.gmail.com> References: <20091113164723.98782324ADE@www.haskell.org> <59B81748-BEF7-47A6-918A-9E3DF77518DA@vidplace.com> <5fdc56d70911131010q1152ac24uffd95ad7cf1045a9@mail.gmail.com> <7fb8f82f0911131043v3ae3066ftca1d8c676033c921@mail.gmail.com> Message-ID: <5fdc56d70911131144l4384bcbbsba240302adde70cb@mail.gmail.com> Hi Edward Many thanks. I've mostly used groupoid for 'string concatenation' on types that I don't consider to have useful empty (e.g PostScript paths, bars of music...), as string concatenation is associative it would have been better if I'd used semigroup in the first place (bounding box union certainly looks associative to me as well). Are magma and semigroup exclusive, i.e. in the presence of both a Magma class and a Semigroup class would it be correct that Magma represents only 'magma-op' where op isn't associative and Semigroup represents 'semigroup-op' where the op is associative? When I decided to use a Groupoid class, I was being a bit lazy-minded and felt it could represent a general binary op that _doesn't have to be_ associative but potentially could be. Thanks again Stephen 2009/11/13 Edward Kmett : > > > > > Watch out, in more common parlance, having just an binary operation is a > magma, while having a category with full inverses yields a groupoid. I > haven't seen many people use the older groupoid term for magmas, if only > because they started to have naming conflicts with the category theory > people, and Bourbaki's?'magma' was available and unambiguous.?=) > > And of course magma is not to be confused with the notion of a semigroup, > which is a binary associative operation, and is therefore much more similar > to a monoid in that all it lacks is a unit. > > -Edward Kmett > From max.rabkin at gmail.com Fri Nov 13 14:51:43 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Fri Nov 13 14:27:42 2009 Subject: [Haskell-cafe] Writing great documentation Message-ID: Haskellers, I have heard many complaints about the average quality on documentation. Therefore, I'd like to encourage you all to read Jacob Kaplan-Moss's series on writing great documentation: http://jacobian.org/writing/great-documentation/. The articles are themselves well-written and contain excellent advice (though I disagree somewhat with the comments on automatically-generated documentation: I find many libraries are excellently haddocumented). Jacob Kaplan-Moss is a developer on the Django project, which is well known for the quality of its documentation. One issue he brings up is having different types of documentation. My impression of many Haskell libraries (my own included) is that, while they may have good reference documentation, they lack tutorials and topic guides. Perhaps we could bring up some examples of Haskell projects with particularly good documentation, as examples to look up to. XMonad has very good overviews and guides for developers, and I like how each user-facing xmonad-contrib module gives a small snippet showing how to use it in ones own config. One area where I think it could be improved (and I plan to do some work on this when I have more free time) is in topical guides on things like "how to write your own layout". --Max From korpios at korpios.com Fri Nov 13 15:01:59 2009 From: korpios at korpios.com (Tom Tobin) Date: Fri Nov 13 14:37:39 2009 Subject: [Haskell-cafe] Writing great documentation In-Reply-To: References: Message-ID: On Fri, Nov 13, 2009 at 1:51 PM, Max Rabkin wrote: > I have heard many complaints about the average quality on > documentation. Therefore, I'd like to encourage you all to read Jacob > Kaplan-Moss's series on writing great documentation: > http://jacobian.org/writing/great-documentation/. The articles are > themselves well-written and contain excellent advice (though I > disagree somewhat with the comments on automatically-generated > documentation: I find many libraries are excellently haddocumented). > Jacob Kaplan-Moss is a developer on the Django project, which is well > known for the quality of its documentation. Some of the advice is decent, but some (e.g., "edit on paper", "avoid editing and writing simultaneously") I could never bring myself to do; the ability to continuously revise mid-stream is what keeps me *sane*, and the only reason I can write at all. (It probably helps ? or hurts? ? that I'm positively neurotic when it comes to grammar and usage.) From ndmitchell at gmail.com Fri Nov 13 15:08:42 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Fri Nov 13 14:44:27 2009 Subject: [Haskell-cafe] haskell-src-exts Question In-Reply-To: References: Message-ID: <404396ef0911131208k2063db80i4c966b403d53bafb@mail.gmail.com> Hi Niklas, >> Do I have to write my own prettyprinter? Do I have to put in explicit >> parentheses? The latter seems unsatisfactory as my generated AST is unambiguous >> and bracketing ought to be part of the prettyprinter. The former would be quite >> a lot of code as there are many cases to consider. > > Looking at your example, what you want is brackets to be inserted > whenever the right subexpression in an application is non-atomic. That > certainly seems reasonable to me. Would you file a ticket for it > please? http://trac.haskell.org/haskell-src-exts :-) I wanted that once, then I realised I was wrong :-) Should you insert brackets everywhere it's ambiguous? What about operators - you don't know the fixities, so can't tell if you should insert a bracket or not. I can't see any way for HSE to implement this feature correctly, and as such, it's really not a good feature to push down in to the pretty printer. In HLint I have a bracketing module, which has served me well. Please take any ideas you need from it - http://community.haskell.org/~ndm/darcs/hlint/src/HSE/Bracket.hs . In particular, given a fully bracketed expression, I can call transformBracket to transform the expression, not caring about brackets, in a way that guarantees the right brackets are put back. There is also needBracket and isAtom which are very useful. If you call descendBi (transformBracket Just) it will automatically bracket your term as much as is necessary. If you don't understand any of the ideas in Bracket then look at Uniplate (http://community.haskell.org/~ndm/uniplate) - it's where a lot of the ideas came from. If you're working with a HSE source tree without using Uniplate (or a competitor) then you're doing it wrong. Thanks, Neil From ndmitchell at gmail.com Fri Nov 13 15:08:44 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Fri Nov 13 14:44:31 2009 Subject: [Haskell-cafe] Opinion about JHC In-Reply-To: <20091113112644.GF23126@sliver.repetae.net> References: <567296.97882.qm@web58802.mail.re1.yahoo.com> <20091111083759.GH21564@sliver.repetae.net> <20091113112644.GF23126@sliver.repetae.net> Message-ID: <404396ef0911131208n4d97fd93xeff94ac5952d4ce@mail.gmail.com> Hi John, >> Do you use jhc when you develop jhc? ?I.e., does it compile itself. >> For me, this is the litmus test of when a compiler has become usable. >> I mean, if even the developers of a compiler don't use it themselves, >> why should anyone else? :) > > Well, this touches on another issue, and that is that jhc is a native > cross-compiler. It never behaves differently if compiled by another > haskell compiler or is compiled on an alternate platform. There is never > a need to 'bootstrap' it, once you have jhc running anywhere then it is > as good as it would be if it is running everywhere. So to me, > self-hosting has never been a big issue as it doesn't provide any direct > "material" benefit. My time is better spent implementing more extensions > or improving the back end. I think you might have missed Lennart's point. It's fair to say you do a lot of Haskell development work while writing a Haskell compiler. If you aren't using your compiler for your development work (in particular for your compiler) then anyone trying to use it is likely to bump in to problems. It's not that there are technical advantages of self-compilation, but it is a good statement of faith from the compiler author. Anyway, I think the Haskell community needs more compilers, so I wish you lots of luck with JHC! Thanks, Neil From haskell at gimbo.org.uk Fri Nov 13 15:26:19 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Fri Nov 13 15:02:05 2009 Subject: [Haskell-cafe] A small (?) problem with type families Message-ID: <1B22C0BD-EE31-4F3A-B166-D2E7C55A959B@gimbo.org.uk> Hi all, This email is literate Haskell. I'm trying to use type families to express some dependencies between type classes, and I'm running into trouble, I think because I'm producing chains of dependencies which the checker can't resolve... Here's a minimised version of the state I've got myself into. :-) > {-# LANGUAGE FlexibleContexts #-} > {-# LANGUAGE TypeFamilies #-} > module Families where First a type family where the type Y is functionally dependent on the type X, and we have a function from Y to (). > class X a where > type Y a > enact :: Y a -> () Now another type family, where the type Q is functionally dependent on the type P, _and_ it must also be an instance of the X class. > class (X (Q s)) => P s where > type Q s (Perhaps there's a better way to express that dependency?) Now a function which takes a value whose type is an instance of the Y depending on the Q depending on the P. (Phew!) The function just tries to call enact on that value. > bar :: P s => Y (Q s) -> () > bar w = enact w The error we get is: src/Families.lhs:35:16: Couldn't match expected type `Y a' against inferred type `Y (Q s)' In the first argument of `enact', namely `w' In the expression: enact w In the definition of `bar': bar w = enact w Presumably this way I'm chaining type dependencies is flawed. Any suggestions on how to improve it, and/or what to read to understand what I'm dealing with better? (So far I've read "Fun with type functions V2", but that's about it, and I admit I didn't grok it all.) Thanks! -Andy From dave at zednenem.com Fri Nov 13 15:36:59 2009 From: dave at zednenem.com (David Menendez) Date: Fri Nov 13 15:12:45 2009 Subject: [Haskell-cafe] A small (?) problem with type families In-Reply-To: <1B22C0BD-EE31-4F3A-B166-D2E7C55A959B@gimbo.org.uk> References: <1B22C0BD-EE31-4F3A-B166-D2E7C55A959B@gimbo.org.uk> Message-ID: <49a77b7a0911131236r1f54dea9o53e888f2363f5308@mail.gmail.com> On Fri, Nov 13, 2009 at 3:26 PM, Andy Gimblett wrote: > First a type family where the type Y is functionally dependent on > the type X, and we have a function from Y to (). > >> class X a where >> ? type Y a >> ? enact :: Y a -> () This is ambiguous. Type families are not injective (that is, Y a ~ Y b does not imply a ~ b), so there's no way for the compiler to figure out which instance of X is being used when it encounters enact. Given these instances, instance X Int where type Y Int = Bool enact _ = () instance X Char where type Y Char = Bool enact _ = undefined What is "enact False"? I recall seeing a discussion of this in the GHC documentation, but I can't seem to locate it. -- Dave Menendez From haskell at gimbo.org.uk Fri Nov 13 15:48:05 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Fri Nov 13 15:23:50 2009 Subject: [Haskell-cafe] A small (?) problem with type families In-Reply-To: <1B22C0BD-EE31-4F3A-B166-D2E7C55A959B@gimbo.org.uk> References: <1B22C0BD-EE31-4F3A-B166-D2E7C55A959B@gimbo.org.uk> Message-ID: Ack. I've just realised that P/Q is not a functional dependency. I need to use a multi-parameter type class there. So my question is probably completely pointless - sorry! Thanks anyway, -Andy On 13 Nov 2009, at 20:26, Andy Gimblett wrote: > Hi all, > > This email is literate Haskell. I'm trying to use type families to > express some dependencies between type classes, and I'm running into > trouble, I think because I'm producing chains of dependencies which > the checker can't resolve... Here's a minimised version of the state > I've got myself into. :-) > > > {-# LANGUAGE FlexibleContexts #-} > > {-# LANGUAGE TypeFamilies #-} > > > module Families where > > First a type family where the type Y is functionally dependent on > the type X, and we have a function from Y to (). > > > class X a where > > type Y a > > enact :: Y a -> () > > Now another type family, where the type Q is functionally dependent > on the type P, _and_ it must also be an instance of the X > class. > > > class (X (Q s)) => P s where > > type Q s > > (Perhaps there's a better way to express that dependency?) > > Now a function which takes a value whose type is an instance of the Y > depending on the Q depending on the P. (Phew!) The function just > tries to call enact on that value. > > > bar :: P s => Y (Q s) -> () > > bar w = enact w > > The error we get is: > > src/Families.lhs:35:16: > Couldn't match expected type `Y a' against inferred type `Y (Q s)' > In the first argument of `enact', namely `w' > In the expression: enact w > In the definition of `bar': bar w = enact w > > Presumably this way I'm chaining type dependencies is flawed. Any > suggestions on how to improve it, and/or what to read to understand > what I'm dealing with better? (So far I've read "Fun with type > functions V2", but that's about it, and I admit I didn't grok it all.) > > Thanks! > > -Andy > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From lennart at augustsson.net Fri Nov 13 15:55:51 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Fri Nov 13 15:31:31 2009 Subject: [Haskell-cafe] Opinion about JHC In-Reply-To: <404396ef0911131208n4d97fd93xeff94ac5952d4ce@mail.gmail.com> References: <567296.97882.qm@web58802.mail.re1.yahoo.com> <20091111083759.GH21564@sliver.repetae.net> <20091113112644.GF23126@sliver.repetae.net> <404396ef0911131208n4d97fd93xeff94ac5952d4ce@mail.gmail.com> Message-ID: Thanks Neil, That was indeed my point. Since a compiler is a substantial program I would have more confidence it a compiler that is self-hosting. Surely you must have tried? -- Lennart On Fri, Nov 13, 2009 at 8:08 PM, Neil Mitchell wrote: > Hi John, > >>> Do you use jhc when you develop jhc? ?I.e., does it compile itself. >>> For me, this is the litmus test of when a compiler has become usable. >>> I mean, if even the developers of a compiler don't use it themselves, >>> why should anyone else? :) >> >> Well, this touches on another issue, and that is that jhc is a native >> cross-compiler. It never behaves differently if compiled by another >> haskell compiler or is compiled on an alternate platform. There is never >> a need to 'bootstrap' it, once you have jhc running anywhere then it is >> as good as it would be if it is running everywhere. So to me, >> self-hosting has never been a big issue as it doesn't provide any direct >> "material" benefit. My time is better spent implementing more extensions >> or improving the back end. > > I think you might have missed Lennart's point. It's fair to say you do > a lot of Haskell development work while writing a Haskell compiler. If > you aren't using your compiler for your development work (in > particular for your compiler) then anyone trying to use it is likely > to bump in to problems. It's not that there are technical advantages > of self-compilation, but it is a good statement of faith from the > compiler author. > > Anyway, I think the Haskell community needs more compilers, so I wish > you lots of luck with JHC! > > Thanks, Neil > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From simon at joyful.com Fri Nov 13 15:58:52 2009 From: simon at joyful.com (Simon Michael) Date: Fri Nov 13 15:34:58 2009 Subject: [Haskell-cafe] Re: Writing great documentation In-Reply-To: References: Message-ID: Thanks for this topic and the link; I'm going to try to use it to improve the docs for hledger and my other projects. (And I agree, he's wrong about auto-generated docs.) I seem to remember admiring Parsec's documentation. Though, that reminds me.. A very common problem with online docs is fragmentation. Eg, often to learn haskell libraries the reader has to visit multiple sites, or multiple locations and formats from one site, and sort through multiple versions of the docs, to piece together a full picture. You may have the original outdated but most complete docs; the newer, less complete version hosted on haskell.org; the similar but different version pasted on the haskell wiki with discussion; the clarifying (or not) blog articles; the api docs on hackage corresponding to your installed software, etc. To avoid this, I think project leaders need to (a) maintain and clearly identify one canonical starting point for docs (I favour the hackage page for small projects, a dedicated site or a page on the wiki for larger ones); and (b) continually seek out, purge and delete out-dated/inconsistent/duplicated docs wherever they be hosted - get them off the net. From daniel.is.fischer at web.de Fri Nov 13 16:00:28 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Nov 13 15:37:35 2009 Subject: [Haskell-cafe] A small (?) problem with type families In-Reply-To: <49a77b7a0911131236r1f54dea9o53e888f2363f5308@mail.gmail.com> References: <1B22C0BD-EE31-4F3A-B166-D2E7C55A959B@gimbo.org.uk> <49a77b7a0911131236r1f54dea9o53e888f2363f5308@mail.gmail.com> Message-ID: <200911132200.29468.daniel.is.fischer@web.de> Am Freitag 13 November 2009 21:36:59 schrieb David Menendez: > On Fri, Nov 13, 2009 at 3:26 PM, Andy Gimblett wrote: > > First a type family where the type Y is functionally dependent on > > the type X, and we have a function from Y to (). > > > >> class X a where > >> ? type Y a > >> ? enact :: Y a -> () > > This is ambiguous. Type families are not injective (that is, Y a ~ Y b > does not imply a ~ b), so there's no way for the compiler to figure > out which instance of X is being used when it encounters enact. > > Given these instances, > > instance X Int where > type Y Int = Bool > enact _ = () > > instance X Char where > type Y Char = Bool > enact _ = undefined > > What is "enact False"? > > I recall seeing a discussion of this in the GHC documentation, but I > can't seem to locate it. Perhaps http://www.haskell.org/haskellwiki/GHC/Type_families#Frequently_asked_questions ? From nicolas.pouillard at gmail.com Fri Nov 13 16:07:34 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Fri Nov 13 15:43:14 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> <293882077.20091112091817@gmail.com> <404396ef0911120257o315d7285r9a7f8dc218d2b6b5@mail.gmail.com> Message-ID: <1258146052-sup-3500@peray> Excerpts from Jason Dagit's message of Fri Nov 13 02:25:06 +0100 2009: > On Thu, Nov 12, 2009 at 2:57 AM, Neil Mitchell wrote: > > > Hi, > > > > I'd really love a faster GHC! I spend hours every day waiting for GHC, > > so any improvements would be most welcome. > > > > Has anyone built a profiling enabled GHC to get data on where GHC spends > time during compilation? > > > > > I remember when developing Yhc on a really low powered computer, it > > had around 200 modules and loaded from scratch (with all the Prelude > > etc) in about 3 seconds on Hugs. ghc --make took about that long to > > start compiling the first file, and I think a complete compile was > > around 5 minutes. It's one of the main reasons I stuck with Hugs for > > so long. > > > > Running GHC in parallel with --make would be nice, but I find on > > Windows that the link time is the bottleneck for most projects. > > > > Yes, when GHC calls GNU ld, it can be very costly. In my experience, on a I confirm that I also had this experience on Arch Linux, GNU ld was allocating Gigs of memory, however this is very hard to reproduce. Actually I've wrapped /usr/bin/ld with a timeout :) -- Nicolas Pouillard http://nicolaspouillard.fr From duncan.coutts at googlemail.com Fri Nov 13 16:12:01 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Fri Nov 13 15:47:43 2009 Subject: [Haskell-cafe] Cabal and autogenerated files In-Reply-To: <1258125893.17446.1345073725@webmail.messagingengine.com> References: <1258049778.4680.9994.camel@localhost> <1258125893.17446.1345073725@webmail.messagingengine.com> Message-ID: <1258146721.4680.13490.camel@localhost> On Fri, 2009-11-13 at 15:24 +0000, Jeremy O'Donoghue wrote: > > So I take it that these modules are generated "from nothing" rather than > > something like happy/alex pre-processors where the .hs files are > > generated from .y/.x files. Cabal supports the latter fairly well and > > you can add custom pre-processors in this style. It doesn't really > > support generating modules out of thin-air in the build step (though it > > does this internally for the Paths_pkgname module). > > They don't come from nothing as they are derived from a C header file > and an Eiffel interface (for historical reasons). Ok, but not files in a 1:1 correspondence with the modules you generate. It's more like a bunch of files used to generate another bunch of files, with no simple naming convention to relate the two. > It sounds as though the custom preprocessor approach is closest to what > we have/need. Cabal's simple notion of preprocessor really only covers the case where you've got: Foo/Bar.hs generated from Foo/Bar.some-other-extension The pre-processors are registered by the extension and the Cabal pre-processing step decides what pre-processors to run by looking for files with known extensions. > We have a custom config hook containing the following: > > myConfHook :: (Either GenericPackageDescription PackageDescription, > HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo > myConfHook (pkg0, pbi) flags = do > createDirectoryIfMissing True wxcoreDirectory > system $ "wxdirect -t --wxc " ++ sourceDirectory ++ " -o " ++ > wxcoreDirectory ++ " " ++ wxcoreIncludeFile > system $ "wxdirect -i --wxc " ++ sourceDirectory ++ " -o " ++ > wxcoreDirectory ++ " " ++ wxcoreIncludeFile > system $ "wxdirect -c --wxc " ++ sourceDirectory ++ " -o " ++ > wxcoreDirectory ++ " " ++ wxcoreIncludeFile > system $ "wxdirect -d --wxc " ++ sourceDirectory ++ " -o " ++ > wxcoreDirectory ++ " " ++ intercalate " " eiffelFiles > > In this case, wxcoreDirectory resolves to > "dist/build/autogen/Graphics/UI/WXCore". > > The calls to wxdirect generate a number of haskell files as output > (currently in dist/build/autogen). > > Regards > Jeremy From haskell at gimbo.org.uk Fri Nov 13 16:13:11 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Fri Nov 13 15:49:04 2009 Subject: [Haskell-cafe] A small (?) problem with type families In-Reply-To: References: <1B22C0BD-EE31-4F3A-B166-D2E7C55A959B@gimbo.org.uk> Message-ID: <74D2942A-5E51-48EF-A420-95C1831F5A62@gimbo.org.uk> Hahaha, this is what I get for trying to think about Haskell on a Friday night. Now I think it _is_ a functional dependency after all. Who knows how long it will be before I change my mind again? :-) I shall think about this more carefully tomorrow... Thanks again, -Andy On 13 Nov 2009, at 20:48, Andy Gimblett wrote: > Ack. I've just realised that P/Q is not a functional dependency. I > need to use a multi-parameter type class there. So my question is > probably completely pointless - sorry! > > Thanks anyway, > > -Andy > > On 13 Nov 2009, at 20:26, Andy Gimblett wrote: > >> Hi all, >> >> This email is literate Haskell. I'm trying to use type families to >> express some dependencies between type classes, and I'm running into >> trouble, I think because I'm producing chains of dependencies which >> the checker can't resolve... Here's a minimised version of the state >> I've got myself into. :-) >> >> > {-# LANGUAGE FlexibleContexts #-} >> > {-# LANGUAGE TypeFamilies #-} >> >> > module Families where >> >> First a type family where the type Y is functionally dependent on >> the type X, and we have a function from Y to (). >> >> > class X a where >> > type Y a >> > enact :: Y a -> () >> >> Now another type family, where the type Q is functionally dependent >> on the type P, _and_ it must also be an instance of the X >> class. >> >> > class (X (Q s)) => P s where >> > type Q s >> >> (Perhaps there's a better way to express that dependency?) >> >> Now a function which takes a value whose type is an instance of the Y >> depending on the Q depending on the P. (Phew!) The function just >> tries to call enact on that value. >> >> > bar :: P s => Y (Q s) -> () >> > bar w = enact w >> >> The error we get is: >> >> src/Families.lhs:35:16: >> Couldn't match expected type `Y a' against inferred type `Y (Q s)' >> In the first argument of `enact', namely `w' >> In the expression: enact w >> In the definition of `bar': bar w = enact w >> >> Presumably this way I'm chaining type dependencies is flawed. Any >> suggestions on how to improve it, and/or what to read to understand >> what I'm dealing with better? (So far I've read "Fun with type >> functions V2", but that's about it, and I admit I didn't grok it >> all.) >> >> Thanks! >> >> -Andy >> >> _______________________________________________ >> 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 From max.rabkin at gmail.com Fri Nov 13 16:20:55 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Fri Nov 13 15:56:55 2009 Subject: [Haskell-cafe] Re: Writing great documentation In-Reply-To: References: Message-ID: On Fri, Nov 13, 2009 at 10:58 PM, Simon Michael wrote: > A very common problem with online docs is fragmentation. Absolutely! Is it possible to include non-haddock documentation in a cabal package. Is it possible to have it readable on Hackage? I think this would help with the fragmentation and versioning issues. One option is to have haddock-only modules for non-reference documentation (xmonad-contrib does this), and I think at the moment it is a good option, but it does have disadvantages. It may not be clear from the outline where documentation can be found, and it clutters up the module namespace. Perhaps we could add support for a Documentation-Modules field in cabal files, which would separate these modules in the outline, and not install them but only their documentation. --Max From duncan.coutts at googlemail.com Fri Nov 13 16:44:14 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Fri Nov 13 16:19:57 2009 Subject: [Haskell-cafe] haskell-src-exts Question In-Reply-To: <404396ef0911131208k2063db80i4c966b403d53bafb@mail.gmail.com> References: <404396ef0911131208k2063db80i4c966b403d53bafb@mail.gmail.com> Message-ID: <1258148654.4680.13597.camel@localhost> On Fri, 2009-11-13 at 20:08 +0000, Neil Mitchell wrote: > Hi Niklas, > > >> Do I have to write my own prettyprinter? Do I have to put in explicit > >> parentheses? The latter seems unsatisfactory as my generated AST is unambiguous > >> and bracketing ought to be part of the prettyprinter. The former would be quite > >> a lot of code as there are many cases to consider. > > > > Looking at your example, what you want is brackets to be inserted > > whenever the right subexpression in an application is non-atomic. That > > certainly seems reasonable to me. Would you file a ticket for it > > please? http://trac.haskell.org/haskell-src-exts :-) > > I wanted that once, then I realised I was wrong :-) Surely you do want this. It's the biggest problem with the original haskell-src package, that it cannot print out any useful Haskell code obtained from the parser, because it forgets all the brackets. > Should you insert brackets everywhere it's ambiguous? The minimal number that are necessary. The Show class manages to do this ok. > What about operators - you don't know the fixities, so can't tell if > you should insert a bracket or not. You can at least remember enough in the parser to print it out the same way. If we do not have fixity info available (eg because it's from some other module) we just keep the operators and expressions together in a list (such that they could be fully resolved if we applied fixity info) eg e1 %% e2 ?? e3 as (using made up AST names) (e1, [(Op "%%", e2), (Op "??", e3)]) We can then print it out the same way. We could also resolve the bracketing if we had fixity info and in that case we could print out the expression again with the minimal number of brackets necessary. I did it like this for an undergrad compiler, the round trip parsing and pretty printing works fine, as does getting from the plain syntax level to the fully resolved level by using fixity info. > I can't see any way for HSE to implement this feature correctly, and > as such, it's really not a good feature to push down in to the pretty > printer. It probably wants to be a combination of the parser, AST and pretty printer. Duncan From dave at zednenem.com Fri Nov 13 16:48:46 2009 From: dave at zednenem.com (David Menendez) Date: Fri Nov 13 16:24:26 2009 Subject: [Haskell-cafe] A small (?) problem with type families In-Reply-To: <200911132200.29468.daniel.is.fischer@web.de> References: <1B22C0BD-EE31-4F3A-B166-D2E7C55A959B@gimbo.org.uk> <49a77b7a0911131236r1f54dea9o53e888f2363f5308@mail.gmail.com> <200911132200.29468.daniel.is.fischer@web.de> Message-ID: <49a77b7a0911131348g7fdb3bdbm8f248866ea283224@mail.gmail.com> On Fri, Nov 13, 2009 at 4:00 PM, Daniel Fischer wrote: > Am Freitag 13 November 2009 21:36:59 schrieb David Menendez: >> >> I recall seeing a discussion of this in the GHC documentation, but I >> can't seem to locate it. > > Perhaps http://www.haskell.org/haskellwiki/GHC/Type_families#Frequently_asked_questions ? That's the one. I keep forgetting there's additional material on the wiki. -- Dave Menendez From duncan.coutts at googlemail.com Fri Nov 13 16:49:37 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Fri Nov 13 16:25:19 2009 Subject: [Haskell-cafe] Re: Weird dependency failure log In-Reply-To: References: <20091113124842.GA29430@soi.city.ac.uk> <1258130523.4680.12718.camel@localhost> Message-ID: <1258148977.4680.13615.camel@localhost> On Fri, 2009-11-13 at 15:53 -0200, Maur??cio CA wrote: > >>> This is a package with no library and no executables. That's > >>> not supposed to work. > > >> Why shouldn't this be supposed to work? It does install needed > >> files (two include files for hsc2hs), and they do stand for > >> themselves to justify a package of its own. > > > Header files are associated with a library. If there is no > > library then nothing gets registered. This is by design. > > Doesn't Cabal option 'install-includes' contradicts that? No. The install-includes field is part of a library or executable section in a .cabal file. It is not global to a package as a whole. > > If it's not a library, nothing can depend on it. > > But please tell me then where my package fits. I'm not sure I understand the question. Can you clarify what you mean. > Many libraries I wrote and use depend heavily on it. Versioning in > this package is extremely important, as a change in design for any > macro would change all names in depending libraries. I notice that you have changed the package to include a library. Duncan From magnus at therning.org Fri Nov 13 16:53:43 2009 From: magnus at therning.org (Magnus Therning) Date: Fri Nov 13 16:29:31 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <7fb8f82f0911131043v3ae3066ftca1d8c676033c921@mail.gmail.com> References: <20091113164723.98782324ADE@www.haskell.org> <59B81748-BEF7-47A6-918A-9E3DF77518DA@vidplace.com> <5fdc56d70911131010q1152ac24uffd95ad7cf1045a9@mail.gmail.com> <7fb8f82f0911131043v3ae3066ftca1d8c676033c921@mail.gmail.com> Message-ID: <4AFDD567.3040808@therning.org> On 13/11/09 18:43, Edward Kmett wrote: [..] > Watch out, in more common parlance, having just an binary operation is a > magma, while having a category with full inverses yields a groupoid. I > haven't seen many people use the older groupoid term for magmas, if only > because they started to have naming conflicts with the category theory > people, and Bourbaki's 'magma' was available and unambiguous. =) > > And of course magma is not to be confused with the notion of a > semigroup, which is a binary associative operation, and is therefore > much more similar to a monoid in that all it lacks is a unit. I suspect there'll be some bald (evil) haskeller out there filing a bug report right now for the type class Magma (with the alias LiquidHotMagma of course). Using it will require programming with just one hand though, since one pinkie must be between one's teeth. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091113/a1fa619a/signature.bin From magnus at therning.org Fri Nov 13 16:57:55 2009 From: magnus at therning.org (Magnus Therning) Date: Fri Nov 13 16:33:37 2009 Subject: [Haskell-cafe] Re: Writing great documentation In-Reply-To: References: Message-ID: <4AFDD663.9040403@therning.org> On 13/11/09 21:20, Max Rabkin wrote: > On Fri, Nov 13, 2009 at 10:58 PM, Simon Michael wrote: >> A very common problem with online docs is fragmentation. > > Absolutely! Is it possible to include non-haddock documentation in a > cabal package. Is it possible to have it readable on Hackage? I think > this would help with the fragmentation and versioning issues. > > One option is to have haddock-only modules for non-reference > documentation (xmonad-contrib does this), and I think at the moment it > is a good option, but it does have disadvantages. It may not be clear > from the outline where documentation can be found, and it clutters up > the module namespace. Perhaps we could add support for a > Documentation-Modules field in cabal files, which would separate these > modules in the outline, and not install them but only their > documentation. I feel the Haskell Wiki is a great place to keep non-reference docs. That's what I opted to do for dataenc, and will most likely do if I ever get around to putting other modules on hackage. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091113/b7ca8346/signature.bin From duncan.coutts at googlemail.com Fri Nov 13 17:20:45 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Fri Nov 13 16:56:28 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <351ff25e0911130916j375bf542u89502c04203d6680@mail.gmail.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <351ff25e0911130833k551ee56ag1dda6dfb5880081c@mail.gmail.com> <5fdc56d70911130848t6d983adm175c52a83e317b3a@mail.gmail.com> <4AFD8ED2.4050009@btinternet.com> <351ff25e0911130916j375bf542u89502c04203d6680@mail.gmail.com> Message-ID: <1258150845.4680.13718.camel@localhost> On Fri, 2009-11-13 at 15:16 -0200, Rafael Gustavo da Cunha Pereira Pinto wrote: > > "...in my humble opinion. (Which, obviously, nobody else will agree > with.)" > > I somewhat agree with your opinion!! > > What I miss the most is practical examples: > > 1) A function that uses a Monoid as a container > 2) A function that uses Monoid as algebra > > and so on, for most of categories. Here are two practical examples. Most aggregate statistic functions (think of all the aggregate functions in SQL, sum, average, stddev) are monoids. So you can write a generic "compute statistics" function for some dataset and then use it for any monoid statistic function that you come up with. Even better, your "compute statistics" function can take advantage of parallelism since the monoid operation is associative. Another practical example is config files and (equivalently) sets of command line flags. These things are records containing fields. But each field is a monoid (usually list or last) and this lets you make the whole record a monoid, point wise. This lets you do useful stuff like combining configuration from multiple sources (like a config file, defaults and command line) using just mappend. Now you could say, why make it a monoid, why not just provide a function `combineStats` or `combineConfig`. There are two reasons, one is that it provides documentation, it says "this thing is an instance of that well-known pattern". Secondly it sometimes lets you reuse generic functions (eg Data.Traversable). Duncan From duncan.coutts at googlemail.com Fri Nov 13 17:31:54 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Fri Nov 13 17:07:38 2009 Subject: [Haskell-cafe] Re: Writing great documentation In-Reply-To: References: Message-ID: <1258151514.4680.13765.camel@localhost> On Fri, 2009-11-13 at 23:20 +0200, Max Rabkin wrote: > On Fri, Nov 13, 2009 at 10:58 PM, Simon Michael wrote: > > A very common problem with online docs is fragmentation. > > Absolutely! Is it possible to include non-haddock documentation in a > cabal package. Is it possible to have it readable on Hackage? Not yet. Want to volunteer? http://hackage.haskell.org/trac/hackage/ticket/330 It's partly a matter of tasteful design and partly implementation. The same person/people do not need to do both bits. Thrashing out a detailed and workable design would get us most of the way there. > I think this would help with the fragmentation and versioning issues. Yes, I agree. > One option is to have haddock-only modules for non-reference > documentation (xmonad-contrib does this), and I think at the moment it > is a good option, but it does have disadvantages. It may not be clear > from the outline where documentation can be found, and it clutters up > the module namespace. Perhaps we could add support for a > Documentation-Modules field in cabal files, which would separate these > modules in the outline, and not install them but only their > documentation. I rather like the idea of using markdown (pandoc) for separate non-reference docs like man pages, tutorials, user guides etc rather than trying to make haddock do everything. Duncan From gour at gour-nitai.com Fri Nov 13 17:41:15 2009 From: gour at gour-nitai.com (Gour) Date: Fri Nov 13 17:17:18 2009 Subject: [Haskell-cafe] Re: Writing great documentation References: <1258151514.4680.13765.camel@localhost> Message-ID: <20091113234115.7b664407@gaura-nitai.no-ip.org> On Fri, 13 Nov 2009 22:31:54 +0000 >>>>>> "Duncan" == Duncan Coutts wrote: Duncan> I rather like the idea of using markdown (pandoc) for separate Duncan> non-reference docs like man pages, tutorials, user guides etc Duncan> rather than trying to make haddock do everything. I'd agree only with the exception to use rst/docutils/sphinx which produces nice html/pdf. (Yeah, I know it's not Haskell, but...) Sincerely, Gour -- Gour | Hlapicina, Croatia | GPG key: F96FF5F6 ---------------------------------------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091113/e295fc33/signature.bin From mauricio.antunes at gmail.com Fri Nov 13 17:47:08 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Fri Nov 13 17:23:12 2009 Subject: [Haskell-cafe] Re: Weird dependency failure log In-Reply-To: <1258148977.4680.13615.camel@localhost> References: <20091113124842.GA29430@soi.city.ac.uk> <1258130523.4680.12718.camel@localhost> <1258148977.4680.13615.camel@localhost> Message-ID: >> > Header files are associated with a library. >> > If there is no library then nothing gets >> > registered. This is by design. >> > If it's not a library, nothing can depend on >> > it. >> But please tell me then where my package fits. > I'm not sure I understand the question. Can you > clarify what you mean. Well, you said that if it's not a library, it can't have dependencies, and my package is not a library and does have dependencies. Maybe it should not be a package at all, but then I would not know a safe way to distribute it without breaking packages when something changes. I inserted a dummy module so that the package is accepted as a dependency. But I'm not sure this is appropriate. Thanks, Maur?cio From niklas.broberg at gmail.com Fri Nov 13 17:54:00 2009 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Fri Nov 13 17:29:39 2009 Subject: [Haskell-cafe] haskell-src-exts Question In-Reply-To: <1258148654.4680.13597.camel@localhost> References: <404396ef0911131208k2063db80i4c966b403d53bafb@mail.gmail.com> <1258148654.4680.13597.camel@localhost> Message-ID: > Surely you do want this. It's the biggest problem with the original > haskell-src package, that it cannot print out any useful Haskell code > obtained from the parser, because it forgets all the brackets. I should point out that haskell-src-exts already fixes this for code obtained from the parser, by making the parser and AST remember the brackets. Or as you put it: > It probably wants to be a combination of the parser, AST and pretty > printer. Yes indeed. But the problem at hand here is auto-generated AST code, where we cannot rely on the parser to do the right thing. There's help in the AST such that it's possible to explicitly insert brackets where needed, but I agree with Dominic that it shouldn't really be necessary in his case. Neil's point is well taken though - to do it correctly (or rather, minimally) for infix application, the pretty printer would need to be aware of the respective fixities involved. However, that doesn't mean we can't do better than what it is now, but be conservative about it. Only insert brackets where it's clear that brackets must be inserted, which would be the case for Dominic's example. If the argument to an application is non-atomic, it needs brackets, there's nothing ambiguous about that. Nothing can be said so categorically for infix applications, so there we should assume that the fixities are already done in the correct way, or that brackets are inserted manually where needed. Does that sound reasonable? Cheers, /Niklas From jason.dusek at gmail.com Fri Nov 13 18:00:36 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Nov 13 17:36:16 2009 Subject: [Haskell-cafe] FFI binding -- different behaviour under compilation and interpretation. Message-ID: <42784f260911131500m1640901bl2cedcb944ee2e831@mail.gmail.com> I'm binding to `wcwidth` to determine the column widths of various Unicode characters. I noticed a lot of -- in fact all -- Chinese characters were being given widths of `-1` when of course they should have width `2`. This only showed up when I compiled my program though -- within GHCi, it never happened. Below my signature is a parred down example that demoes the bug. It tries to get the width of only one Chinese character. You can see it like this: :; ghc --make DemoFailure.hs -o demo && demo [1 of 1] Compiling Main ( DemoFailure.hs, DemoFailure.o ) Linking demo ... 0x00005cff -1 ? :; chmod ug+x DemoFailure.hs && DemoFailure.hs 0x00005cff 2 ? Switching between safe/unsafe does not make any difference. This was run on a Macintosh. -- Jason Dusek #!/usr/bin/env runhaskell {- DemoFailure.hs -} {-# LANGUAGE ForeignFunctionInterface #-} import Foreign.C import Data.Char import Text.Printf import qualified System.IO.UTF8 as UTF8 main = do (sequence_ . fmap (UTF8.putStrLn . uncurry fmt)) widths where widths = [ (c, wcwidth c) | c <- ['\x5cff'] ] --widths = [ (c, wcwidth c) | c <- [minBound..maxBound] ] fmt c cols = printf "0x%08x %2d %s" (fromEnum c) cols rep where rep | ' ' == c = "\\SP" | isSpace c = '\\' : show (fromEnum c) | isPrint c = [c] | otherwise = (reverse . drop 1 . reverse . drop 1 . show) c wcwidth :: Char -> Int wcwidth = fromEnum . native . toEnum . fromEnum foreign import ccall unsafe "wchar.h wcwidth" native :: CWchar -> CInt From caseyh at istar.ca Fri Nov 13 18:08:24 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Fri Nov 13 17:43:48 2009 Subject: [Haskell-cafe] looking for a good algorithm In-Reply-To: References: Message-ID: Sorry, I forgot to ask an important question. Is the table stored in a dense format as in complete rows and complete columns or in a sparse table format? >The question is more about algorithm than Haskell. But I am going to code in Haskell which I am still learning. >Suppose I have a large table, with hundreds of columns and thousands of rows. But not every cell has a value (of String, or Int, or Double type). >I want to shuffle the rows to maximize the number of columns whose first 100 rows have at least one number, given a list of preferred column names since there is no guarantee that every number column will have at least one number in its first 100 rows after shuffling. >Can someone provide a good algorithm for this problem? (I do not have any background in algorithms.) You can assume I already know which columns are of Int or Double type. -- Regards, Casey From caseyh at istar.ca Fri Nov 13 18:12:11 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Fri Nov 13 17:47:35 2009 Subject: [Haskell-cafe] Pattern Matching In-Reply-To: <45gpf5duie29atpf90c5fetj600gfrhuk4@4ax.com> References: <45gpf5duie29atpf90c5fetj600gfrhuk4@4ax.com> Message-ID: Thank you to all who replied, very instructive. -- Regards, Casey From jeremy.odonoghue at gmail.com Fri Nov 13 18:55:19 2009 From: jeremy.odonoghue at gmail.com (Jeremy O'Donoghue) Date: Fri Nov 13 18:30:58 2009 Subject: [Haskell-cafe] ANN: wxHaskell 0.12.1.2 Message-ID: Hi all, On behalf of the wxHaskell maintainers, I am very pleased to announce the release of wxHaskell 0.12.1.2. The key feature of this release is that it is now possible to install wxHaskell entirely using cabal on all targets (with a minor proviso on Windows). The credit for this achievement is almost all down to new contributor Brian Lewis, who has worked very hard to make this work 'just right', and given me (at least) an object lesson in how to use Cabal. The small proviso for Windows machines is that wxWidgets should be built using MSys - none of the other compilers supported by wxWidgets is currently working, but we consider this a small price to pay for the convenience of getting a GUI straight from cabal. For Unix machines which have wxWidgets 2.8.x installed, you should now be able to install wxHaskell with a simple: cabal install wx For Windows machines, there are a few prerequisites: 1) You will need the Windows port of wx-config in your path. This can be downloaded from http://wxconfig.googlepages.com/ 2) You will need to compile wxWidgets using MSys. We have tested against MinGW 5.1.6 with g++ compiler, MinGW Make, MSYS-1.0.11, wxMSW-2.8.10, which are the latest versions, and can be downloaded from their respective websites. I used a completely clean install of the latest Haskell Platform to validate the procedure. Please note: all commands to be entered in an MSys shell. cd /c/path/to/wxWidgets-2.8.10/build/msw mingw32-make -f makefile.gcc BUILD=release MONOLITHIC=1 SHARED=1 UNICODE=1 set PATH=$PATH:/c/path/to/wx-config set WXWIN=/c/path/to/wxWidgets-2.8.10 set WXCFG=gcc_dll/mswu cabal install wx I will be updating the wxHaskell wiki to reflect these changes over the next day or so. Best Regards Jeremy O'Donoghue on behalf of the wxHaskell maintainers. From daniel.is.fischer at web.de Fri Nov 13 19:15:26 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Nov 13 18:52:31 2009 Subject: [Haskell-cafe] FFI binding -- different behaviour under compilation and interpretation. In-Reply-To: <42784f260911131500m1640901bl2cedcb944ee2e831@mail.gmail.com> References: <42784f260911131500m1640901bl2cedcb944ee2e831@mail.gmail.com> Message-ID: <200911140115.26995.daniel.is.fischer@web.de> Am Samstag 14 November 2009 00:00:36 schrieb Jason Dusek: > I'm binding to `wcwidth` to determine the column widths of > various Unicode characters. I noticed a lot of -- in fact all > -- Chinese characters were being given widths of `-1` when of > course they should have width `2`. This only showed up when I > compiled my program though -- within GHCi, it never happened. It seems that ghci calls setlocale(LC_ALL,"") or similar, while the compiled code doesn't. I've no idea why that would be, but dafis@linux-mkk1:~/Haskell/CafeTesting> cat locl.h void sloc(); dafis@linux-mkk1:~/Haskell/CafeTesting> cat locl.c #include #include "locl.h" void sloc(){ setlocale(LC_ALL,""); } main ? ? ? ? ? ? ? ? ? ? ? ? = ?do setloc ? (sequence_ . fmap (UTF8.putStrLn . uncurry fmt)) widths where... foreign import ccall unsafe "locl.h sloc" setloc :: IO () fixes it. From duncan.coutts at googlemail.com Fri Nov 13 19:46:05 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Fri Nov 13 19:21:48 2009 Subject: [Haskell-cafe] haskell-src-exts Question In-Reply-To: References: <404396ef0911131208k2063db80i4c966b403d53bafb@mail.gmail.com> <1258148654.4680.13597.camel@localhost> Message-ID: <1258159565.4680.14166.camel@localhost> On Fri, 2009-11-13 at 23:54 +0100, Niklas Broberg wrote: > > Surely you do want this. It's the biggest problem with the original > > haskell-src package, that it cannot print out any useful Haskell code > > obtained from the parser, because it forgets all the brackets. > > I should point out that haskell-src-exts already fixes this for code > obtained from the parser, by making the parser and AST remember the > brackets. Or as you put it: > > > It probably wants to be a combination of the parser, AST and pretty > > printer. > > Yes indeed. Ok, I misunderstood. > But the problem at hand here is auto-generated AST code, where we > cannot rely on the parser to do the right thing. There's help in the > AST such that it's possible to explicitly insert brackets where > needed, but I agree with Dominic that it shouldn't really be necessary > in his case. > Neil's point is well taken though - to do it correctly (or rather, > minimally) for infix application, the pretty printer would need to be > aware of the respective fixities involved. To do it minimally yes, but correctly? In the AST you've got InfixApp Exp QOp Exp so we know the tree structure, we just can't insert minimal brackets without knowing the fixity. > However, that doesn't mean we can't do better than what it is now, but > be conservative about it. Only insert brackets where it's clear that > brackets must be inserted, which would be the case for Dominic's > example. If the argument to an application is non-atomic, it needs > brackets, there's nothing ambiguous about that. Nothing can be said so > categorically for infix applications, so there we should assume that > the fixities are already done in the correct way, or that brackets are > inserted manually where needed. > > Does that sound reasonable? So to be clear, currently the printing behaviour is that no brackets are inserted for infix expressions which means the results are "wrong by default" (for ASTs constructed manually, not via the parser) but on the other hand this lets you insert the minimal (or pleasing) number of brackets. The suggestion is to move to a "safe/correct by default" where brackets are inserted to preserve the tree structure of infix expressions. The problem then becomes, what if we want to have the minimal (or pleasing not-quite-minimal) number of brackets. Right? If I've understood right, then yes I think making the pretty printing right by default is a good idea, and then for the users/applications where optimising for fewer brackets is important, it should be a little extra work to supply the necessary information. Perhaps like the ParseMode has fixities :: [Fixity], give the PPHsMode the same (partial) fixities environment. For operators not in the environment we fall back to using brackets all the time, but for known operators we can the use minimal bracketing. Another option I suppose would be to annotate the QOp used in InfixApp with a Maybe fixity. The parser would annotate these when it knows them from its fixities env in the ParseMode. For ASTs constructed manually the user would add them if they know or care. If not, they just get slightly more brackets than might strictly be necessary if the fixity were known. Duncan From ekmett at gmail.com Fri Nov 13 20:20:14 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Nov 13 19:55:56 2009 Subject: [Haskell-cafe] A small (?) problem with type families In-Reply-To: <49a77b7a0911131236r1f54dea9o53e888f2363f5308@mail.gmail.com> References: <1B22C0BD-EE31-4F3A-B166-D2E7C55A959B@gimbo.org.uk> <49a77b7a0911131236r1f54dea9o53e888f2363f5308@mail.gmail.com> Message-ID: <7fb8f82f0911131720t2bae63cdkd4bc9f4b79501e5e@mail.gmail.com> On Fri, Nov 13, 2009 at 3:36 PM, David Menendez wrote: > On Fri, Nov 13, 2009 at 3:26 PM, Andy Gimblett > wrote: > > First a type family where the type Y is functionally dependent on > > the type X, and we have a function from Y to (). > > > >> class X a where > >> type Y a > >> enact :: Y a -> () > > This is ambiguous. Type families are not injective (that is, Y a ~ Y b > does not imply a ~ b), so there's no way for the compiler to figure > out which instance of X is being used when it encounters enact. > Note: that if you need this injectivity you can use a data family instead. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091113/f6f137b5/attachment.html From jason.dusek at gmail.com Fri Nov 13 20:25:26 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Nov 13 20:01:05 2009 Subject: [Haskell-cafe] FFI binding -- different behaviour under compilation and interpretation. In-Reply-To: <200911140115.26995.daniel.is.fischer@web.de> References: <42784f260911131500m1640901bl2cedcb944ee2e831@mail.gmail.com> <200911140115.26995.daniel.is.fischer@web.de> Message-ID: <42784f260911131725q4485fb57tc7ac786e8677be7c@mail.gmail.com> Thank you very much! -- Jason Dusek From wren at freegeek.org Fri Nov 13 21:34:24 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri Nov 13 21:10:07 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <3bd412d40911130909n7beff82bk24ed6b55a8eeb3e@mail.gmail.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <351ff25e0911130833k551ee56ag1dda6dfb5880081c@mail.gmail.com> <3bd412d40911130909n7beff82bk24ed6b55a8eeb3e@mail.gmail.com> Message-ID: <4AFE1730.5040008@freegeek.org> Magicloud Magiclouds wrote: > Hum... simple like that. So you meant the Monoid just > abstracts/represents the ability to build a stack, right? The key idea behind monoids is that they define sequence. To get a handle on what that means, it helps to think first about the "free monoid". If we have some set S, then we can generate a monoid which describes sequences of elements drawn from S (the neutral element is the empty sequence, the operator is juxtaposition). The tricky thing is that we *really* mean sequences. That is, what we're abstracting over is the tree structure behind a sequence. So if we have a sequence like "abcd" we're abstracting over all the trees (a(b(cd))), (a((bc)d)), ((ab)(cd)),... including all the trees with neutral elements inserted anywhere: ((a)(b(cd))), the other ((a)(b(cd))), (a((b)(cd))),... The places where monoids are useful are exactly those places where we want to abstract over all those trees and consider them equal. By considering them equal, we know it's safe to pick any one of them arbitrarily so as to maximize performance, code legibility, or other factors. One use is when we realize the significance of distinguishing sequences from lists. Sequences have no tree structure because they abstract over all of them, whereas lists convert everything into a canonical right-branching structure. Difference-lists optimize lists by replacing them with a different structure that better represents the true equivalence between different ways of appending. Finger trees are another way of optimizing lists which is deeply connected to monoids. Another place that's helpful is if we want to fold over the sequence. We can parallelize any such fold because we know that the grouping and sequence of reductions are all equivalent. This is helpful for speeding up some computations, but it also lets us think about things like parallel parsing--- that is, actually building up the AST in parallel, working on the whole file at once rather than starting from the beginning and moving towards the end. Another place it's useful is when we have some sort of accumulator where we want to be able to accumulate groups of things as well as individual things. The prime example here is Duncan Coutts' example of supporting multiple config files (where commandline flags can be thought of as an additional config file). CSS is another example of this sort of accretion. Just to build on the config file example a bit more. What sorts of behavior do we expect from programs when some flag is specified more than once? The three most common strategies are: first one wins, last one wins, and take all of them as a list. All three of these are trivially monoids. Some of the stranger behaviors we find are also monoids. For example, some programs interpret more than one -v flag as incrementing the level of verbosity. This is just the free monoid generated by a singleton set, aka unary numbers, aka Peano integers. We could generalize this so that we accept multiple -v=N flags which increment the verbosity by N, in which case we get the (Int,0,+) monoid. Given all these different monoids, we can define the type signature of a config file as a mapping from flags to the monoids used to resolve them. And doing so is far and away the most elegant approach to config handling I've seen anywhere. So monoid == sequence. Similarly, commutative monoid == set. Stacks don't have a heck of a lot of equivalences, so I can't think of a nice algebraic structure that equates to them off-hand. (And the sequentiality of monads comes from being monoids on the category of endofunctors.) -- Live well, ~wren From phi500ac at yahoo.ca Fri Nov 13 22:51:36 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Fri Nov 13 22:27:14 2009 Subject: [Haskell-cafe] Problem with JHC In-Reply-To: <20091113110409.GC23126@sliver.repetae.net> Message-ID: <877995.32205.qm@web58805.mail.re1.yahoo.com> I will wait for your fixing the problem. I am sure that JHC will work flawlessly sooner or later, and I intend to use it in my projects. --- On Fri, 11/13/09, John Meacham wrote: From: John Meacham Subject: Re: [Haskell-cafe] Problem with JHC To: haskell-cafe@haskell.org Received: Friday, November 13, 2009, 4:04 AM On Wed, Nov 11, 2009 at 01:26:03PM -0800, Philippos Apolinarius wrote: > Ops, the paste is wrong, but the bug is real. I mean, if I try to run > the program with the right input, the program aborts in the same place, > with the same error message: > > philip@desktop:~/jhctut$ ./jtestarbo > > Give me a tree: > > T AND [L 1, L 2] > > jtestarbo_code.c:2670: case fell off Hmm... yes, a 'case fell off' error is always a bug in jhc one way or another. I will have to investigate your program and find out why that is happening. compiling with -fdebug can help find such errors, but clearly there is something wrong. ? ? ? ? John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe __________________________________________________________________ Make your browsing faster, safer, and easier with the new Internet Explorer? 8. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091113/f65377d0/attachment.html From wren at freegeek.org Fri Nov 13 22:53:56 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri Nov 13 22:29:38 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <5fdc56d70911131144l4384bcbbsba240302adde70cb@mail.gmail.com> References: <20091113164723.98782324ADE@www.haskell.org> <59B81748-BEF7-47A6-918A-9E3DF77518DA@vidplace.com> <5fdc56d70911131010q1152ac24uffd95ad7cf1045a9@mail.gmail.com> <7fb8f82f0911131043v3ae3066ftca1d8c676033c921@mail.gmail.com> <5fdc56d70911131144l4384bcbbsba240302adde70cb@mail.gmail.com> Message-ID: <4AFE29D4.5080400@freegeek.org> Stephen Tetley wrote: > Hi Edward > > Many thanks. > > I've mostly used groupoid for 'string concatenation' on types that I > don't consider to have useful empty (e.g PostScript paths, bars of > music...), as string concatenation is associative it would have been > better if I'd used semigroup in the first place (bounding box union > certainly looks associative to me as well). > > Are magma and semigroup exclusive, i.e. in the presence of both a > Magma class and a Semigroup class would it be correct that Magma > represents only 'magma-op' where op isn't associative and Semigroup > represents 'semigroup-op' where the op is associative? Magma = exists S : Set , exists _*_ : (S,S)->S Semigroup = exists (S,*) : Magma , forall a b c:S. a*(b*c) = (a*b)*c Monoid = exists (S,*,assoc) : Semigroup , exists e:S. forall a:S. e*a = a = a*e Group = exists (S,*,assoc,e) : Monoid , forall a:S. exists a':S. a'*a = e = a*a' Personally, I don't think magmas are worth a type class. They have no structure and obey no laws which aren't already encoded in the type of the binop. As such, I'd just pass the binop around. There are far too many magmas to warrant making them implicit arguments and trying to deduce which one to use based only on the type of the carrier IMO. But if we did have such a class, then yes the (Magma s) constraint would only imply the existence of a binary operator which s is closed under, whereas the (Semigroup s) constraint would add an additional implication that the binary operator is associative. And we should have Semigroup depend on Magma since every semigroup is a magma. Unfortunately, Haskell's type classes don't have any general mechanism for stating laws as part of the class definition nor providing proofs as part of the instance. > When I decided to use a Groupoid class, I was being a bit lazy-minded > and felt it could represent a general binary op that _doesn't have to > be_ associative but potentially could be. But groupoids do have to be associative (when defined). They're just like groups, except that the binop can be a partial function, and instead of a neutral element they have the weaker identity criterion (if a*b is defined then a*b*b' = a and a'*a*b = b). Groupoids don't make a lot of sense to me as "string concatenation"-like because of the inversion operator. Some types will support the idea of "negative letters" without supporting empty strings, but I can't think of any compelling examples off-hand. Then again, I deal with a lot of monoids which aren't groups and a lot of semirings which aren't rings, so I don't see a lot of inversion outside of the canonical examples. -- Live well, ~wren From john at repetae.net Fri Nov 13 23:10:17 2009 From: john at repetae.net (John Meacham) Date: Fri Nov 13 22:45:58 2009 Subject: [Haskell-cafe] Opinion about JHC In-Reply-To: <683909.34243.qm@web58802.mail.re1.yahoo.com> References: <20091111083759.GH21564@sliver.repetae.net> <683909.34243.qm@web58802.mail.re1.yahoo.com> Message-ID: <20091114041017.GA24020@sliver.repetae.net> Hi, I believe this bug has been fixed in the darcs version, at least, it is in my testing. The fix will be in 0.7.3, or you can try the version from the darcs repository directly. Thanks for the bug report! John On Wed, Nov 11, 2009 at 01:36:05PM -0800, Philippos Apolinarius wrote: > Hi, John. > I > am sending you this second email because the first one has a worng paste.? However, if I use the right input, I gent the same error. In fact, it gives exactly the same error for any input, right or wrong.? > > {- file: tree.hs -} > {- compile: jhc tree.hs -dc -o > jtree } > import System (getArgs) > > import System.IO > > import IO > > ? > data Op = AND | OR | NOT deriving (Show, Read) > > ??? > > data Tree= L Int | T Op [Tree] deriving (Show, Read)? > > ? > main= do > > ? putStrLn "Give me a tree:" > > ? s <- getLine > ? let xx= read s > ? putStrLn (show (xx::Tree)) > ??? > > Here is what happens when I try to run it: > > philip@desktop:~/jhctut$ ./jtree > Give me a tree: > T AND [L 1, L 2] > > jtree_code.c:2670: case fell off > Aborted > > It gives the same error for any input: > > philip@desktop:~/jhctut$ ./jtestarbo > Give me a tree: > fdsfkldkl > > jtestarbo_code.c:2670: case fell off > Abortado > > > It seems that the problem is in the Read class, since it works if I use the Show class only: > > import System (getArgs) > > import System.IO > > import IO > > ? > data Op = AND | OR | NOT deriving (Show, Read) > > ??? > > data Tree= L Int | T Op [Tree] deriving (Show, Read)? > > ? > main= do > > ? putStrLn "Give me a tree:" > > ? s <- > getLine > ? let xx= T AND [L 1, L 2] > ? putStrLn (show (xx::Tree)) > > I hope you can fix it. > > > > > > --- On Wed, 11/11/09, John Meacham wrote: > > From: John Meacham > Subject: Re: [Haskell-cafe] Opinion about JHC > To: haskell-cafe@haskell.org > Received: Wednesday, November 11, 2009, 1:37 AM > > On Tue, Nov 10, 2009 at 07:41:54PM -0800, Philippos Apolinarius wrote: > > I discovered a Haskell compiler that generates very small and fast > > code. In fact, it beats Clean. It has the following properties: > > Excellent. that was my goal ;) > > > 1 --- One can cross-compile programs easily. For instance, here is how I generated code for Windows: > > > > jhc --cross -mwin32 genetic.hs -o genetic > > Yup. This was a major goal. compiling for iPhones and embedded arches is > just as easy assuming you have a gcc toolchain set up. (at least with > the hacked iPhone SDK.. I have never tried it with the official one) > > > > > 2 -- It seems to be quite complete. > > > > 3 -- However, it often compiles a file, but the program fails to run. > > > > I have the following questions about it: > > > > 1 -- How active is the team who is writing the JHC compiler? > > Hi, I am the main contributor, but others are welcome and several have > made signifigant contributions. Development tends to be spurty. A lot of > work will get done in a short amount of time, this generally corresponds > to when an external contributor gets involved and the back and forth > helps stimulate patches on my part to complement theirs. > > Although I have not been able to devote a lot of my time to jhc in the > past, hopefully this will change in the not to distant future and I will > be able to work on it full time. > > > > 2 -- Is it complete Haskell? The author claims that it is; it compiled > > all programs that I wrote, but that does not mean much, because my > > programs are quite simple. > > It does Haskell 98 and several extensions, which is pretty much what GHC > does. However, it does not implement the same set of extensions as GHC > so this causes issues as a lot of people use GHC extensions extensively. > > I plan on supporting all of Haskell' of course, and the popular GHC > extensions to help compatibility. Not all are implemented. > > > 3 -- Why the Haskell community almost never talks about JHC? > > Part of it is that I am not very good at advocacy. I don't always > post announcements on the main haskell lists figuring the interested > parties are on the jhc list already. I do try to make jhc good, fast, > and usable, I always hoped someone better at advocacy than me would join > the project :) In truth, I think the spurty nature of development also > affects this, the list will be quite for a long time with a flurry of > development lasting a few weeks occasionally inspiring some discussion > in the other groups. > > In any case, I am glad you liked what you found! please join the mailing > list for jhc if you are interested in its development or using it. > > ? ? ? ? John > > > > -- > John Meacham - ?repetae.net?john? - http://notanumber.net/ > -- > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > __________________________________________________________________ > Ask a question on any topic and get answers from real people. Go to Yahoo! Answers and share what you know at http://ca.answers.yahoo.com -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From hyangfji at gmail.com Fri Nov 13 23:13:50 2009 From: hyangfji at gmail.com (Hong Yang) Date: Fri Nov 13 22:49:29 2009 Subject: [Haskell-cafe] looking for a good algorithm In-Reply-To: References: Message-ID: Hi Casey, Thanks very much for your zeal. The table is a csv file. Actually the number of rows can be sixty thousand. Hong On Fri, Nov 13, 2009 at 5:08 PM, Casey Hawthorne wrote: > Sorry, I forgot to ask an important question. > > Is the table stored > in a dense format as in complete rows and complete columns > or > in a sparse table format? > > > >The question is more about algorithm than Haskell. But I am going to code > in Haskell which I am still learning. > > >Suppose I have a large table, with hundreds of columns and thousands of > rows. But not every cell has a value (of String, or Int, or Double type). > > >I want to shuffle the rows to maximize the number of columns whose first > 100 rows have at least one number, given a list of preferred column names > since there is no guarantee that every number column will have at least one > number in its first 100 rows after shuffling. > > >Can someone provide a good algorithm for this problem? (I do not have any > background in algorithms.) You can assume I already know which columns are > of Int or Double type. > > -- > Regards, > Casey > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091113/ce9a98c8/attachment.html From john at repetae.net Fri Nov 13 23:24:49 2009 From: john at repetae.net (John Meacham) Date: Fri Nov 13 23:00:27 2009 Subject: [Haskell-cafe] Opinion about JHC In-Reply-To: References: <567296.97882.qm@web58802.mail.re1.yahoo.com> <20091111083759.GH21564@sliver.repetae.net> <20091113112644.GF23126@sliver.repetae.net> <404396ef0911131208n4d97fd93xeff94ac5952d4ce@mail.gmail.com> Message-ID: <20091114042449.GC24020@sliver.repetae.net> On Fri, Nov 13, 2009 at 08:55:51PM +0000, Lennart Augustsson wrote: > That was indeed my point. Since a compiler is a substantial program I > would have more confidence it a compiler that is self-hosting. > Surely you must have tried? No, there are extensions that I use in jhc's code base that jhc itself does not support yet (fundeps for instance). Although said extensions would be nice and are on the list of things to add to jhc, there are other tasks that are more important. I write a lot of code in Haskell, so getting jhc to compile in jhc isn't much more important than getting any of the other projects I work on to compile in it and I prioritize accordingly. I am all about variety in the tools I use. I never understood the desire to have it be self-hosting, I mean, sure it is a nice abstract goal, but there are things with concrete benefits that are more important to jhc right now. (of course, priorities change over time.) John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From jason.dusek at gmail.com Sat Nov 14 00:26:05 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Sat Nov 14 00:01:44 2009 Subject: [Haskell-cafe] FFI binding -- different behaviour under compilation and interpretation. In-Reply-To: <200911140115.26995.daniel.is.fischer@web.de> References: <42784f260911131500m1640901bl2cedcb944ee2e831@mail.gmail.com> <200911140115.26995.daniel.is.fischer@web.de> Message-ID: <42784f260911132126q2ede4017kb469454bd0ade94b@mail.gmail.com> There is a Cabal package for this already: http://hackage.haskell.org/package/setlocale A call to `setLocale LC_ALL (Just "")` in `main` fixes things. -- Jason Dusek 2009/11/13 Daniel Fischer : > Am Samstag 14 November 2009 00:00:36 schrieb Jason Dusek: >> ? I'm binding to `wcwidth` to determine the column widths of >> ? various Unicode characters. I noticed a lot of -- in fact all >> ? -- Chinese characters were being given widths of `-1` when of >> ? course they should have width `2`. This only showed up when I >> ? compiled my program though -- within GHCi, it never happened. > > It seems that ghci calls setlocale(LC_ALL,"") or similar, while the compiled code doesn't. > I've no idea why that would be, but > > dafis@linux-mkk1:~/Haskell/CafeTesting> cat locl.h > void sloc(); > dafis@linux-mkk1:~/Haskell/CafeTesting> cat locl.c > #include > #include "locl.h" > > void sloc(){ > ? ?setlocale(LC_ALL,""); > } > > > main ? ? ? ? ? ? ? ? ? ? ? ? = ?do > ?setloc > ? (sequence_ . fmap (UTF8.putStrLn . uncurry fmt)) widths > ? ?where... > > foreign import ccall unsafe "locl.h sloc" setloc :: IO () > > fixes it. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From Braden.Shepherdson at gmail.com Sat Nov 14 00:55:50 2009 From: Braden.Shepherdson at gmail.com (Braden Shepherdson) Date: Sat Nov 14 00:31:27 2009 Subject: [Haskell-cafe] Re: Opinion about JHC In-Reply-To: <20091113111922.GE23126@sliver.repetae.net> References: <567296.97882.qm@web58802.mail.re1.yahoo.com> <20091111083759.GH21564@sliver.repetae.net> <20091112212054.7b0a9267@gaura-nitai.no-ip.org> <20091113111922.GE23126@sliver.repetae.net> Message-ID: John Meacham wrote: > On Thu, Nov 12, 2009 at 10:44:22PM -0500, Braden Shepherdson wrote: >> The only annoying part was having to build with jhc outside the >> scratchbox environment and then build the C output inside the >> scratchbox. This is necessary because jhc is not self-hosting and I >> couldn't get GHC to build for Maemo. > > Would you really want to have to run jhc _on_ your nokia 770 (or > whatever) just to compile Haskell programs for it? The need for > self-hosting in other compilers has always seemed like a deficiency in > their design, a compiler is just a pure function from source code to > output for a specified architecture. Said function is pure, it should > not depend on what platform the compiler happens to be running on any > more than any other pure function. > > Not that having jhc run on the nokia would be a bad thing, but it should > not be required or provide any particular advantage for compiling > programs for the nokia. jhc running on your N800 should be able to > compile windows programs just as easily as jhc running on a windows > machine itself or a linux box or a mac box. > > John > It's not so much wanting to run it on the device (though that would be fun just for the hack value). I was just saying that it adds an annoying step to building using JHC, since you have to run JHC on the host, and then gcc inside the scratchbox. It's not a limitation, just makes it hard to write a working Makefile. I was just playing around with it, so that never mattered much. I suppose one could have two Makefiles in a proper project. Braden Shepherdson shepheb From jfredett at gmail.com Sat Nov 14 01:31:27 2009 From: jfredett at gmail.com (jfredett@gmail.com) Date: Sat Nov 14 01:07:10 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 139 - November 14, 2009 Message-ID: <4afe4ebf.9553f10a.3358.1fb0@mx.google.com> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20091114 Issue 139 - November 14, 2009 --------------------------------------------------------------------------- Welcome to issue 139 of HWN, a newsletter covering developments in the [1]Haskell community. Lots of good discussion this week about everything from Monoids to Memory Leaks, Parsers (for Token Streams) and pushing Haskell onto Medical devices! I could go on some long rant rife with really righteous alliteration or a touch of timely consonance, but instead I'll leave you all, my fellow Haskellers, to read your Haskell Weekly News! Announcements Two Open PhD positions at the Technical University Munich. Axel Simon [2]announced two PhD positions are open in Low-level and High-level analysis, see the post for details. (ED: Apologies for being so late in this announcment, it slipped under my radar! ) Final CFP: WFLP 2010. Deadlines extended: Abstract due Nov 18; Full paper due Nov 25 (LNCS). Pablo Nogueira [3]announced a deadline extension for the WLFP 2010 conference, abstracts are now due November 18, and full papers by the 25th. hesql. Christoph Bauer [4]announced hesql, a preprocessor for writing SQL statements in pure haskell. dbus-core 0.6 and dbus-client 0.2. John Millikin [5]announced the second release of his dbus libraries. Changes include performance improvments, better support for byte arrays, and TCP/IP transport (though this remains untested). simple-observer-0.0.1, a simple implementation of the observer design pattern. Andy Gimblett [6]announced an implementation of the Observer pattern in Haskell ICFP 2010: Call for papers. Wouter Swierstra [7]announced a call for papers for ICFP 2010. Calling all Haskellers in Huntsville, Alabama, or surrounding areas! Jake McArthur [8]announced the formation of a new Haskell User Group in Alabama. (ED: Apparently, Shae is the Johnny Appleseed for the Haskell Community, #haskell, BAHUG, now AHUG... when will it end? ) acme-dont. Gracjan Polak [9]announced the acme-dont package, providing a vital missed feature to our language -- a don't monad. See the post for all the revolutionary details. Discussion Could someone teach me why we use Data.Monoid? Magicloud Magiclouds [10]1fa7 gmane.comp.lang.haskell.cafe/66223 asked why we use monoids so much in Haskell. Least common supertype. Sean Leather [11]posed an interesting question about 'antiunification' -- finding a common supertype of two types which is 'most-constrained'. Long running Haskell program. David Leimbach [12]asked about managing memory leaks in long running programs. Parsec - separating Parsing from Lexing. Fernando Henrique Sanches [13]asked about using Parsec to parse a Token Stream. Help Haskell driving Medical Instruments. Philippos Apolinarius [14]talked about using Haskell to drive medical instruments. Blog noise [15]Haskell news from the [16]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Neil Brown: [17]The Observer Pattern using a Broadcast Channel. * Martijn van Steenbergen: [18]GADTs in Haskell 98. * Mikael Vejdemo Johansson (Syzygy-): [19][MATH198] Multiple lectures posted. * Andy Gill: [20]LAMBDA this week â ChalkBoard. * London Haskell Users Group: [21]Functional Programming Exchange. * Neil Brown: [22]The Observer Pattern using a Message-Passing Process. * Luke Plant: [23]Is static type checking a redundant testing mechanism?. * Twan van Laarhoven: [24]Four ways to fold an array. * Martin Sulzmann: [25]Tag-free Combinators for Binding-Time Polymorphic Program Generation. * Luke Palmer: [26]Collision Detection with Enneatrees. * Dan Piponi (sigfpe): [27]Memoizing Polymorphic Functions with High School Algebra and Quantifiers. * Luke Plant: [28]Haskell blog software. Quotes of the Week * c2.com: If you can program anything in HappS you actually already learned Haskell * Cale: Chew new Lasty ST Gum! It lasts until _|_! * danderson: [using unsafeFreeze for an ST action] that sounds like a way to shoot myself in the foot with high efficiency, given my knowledge of haskell. * BONUS: C++ is saner than something? imo C++ is like the guy that goes around shouting "I am napoleon!!!" * kmc:: (): worst monoid ever * DanWeston: Bottom has only one value, not two. Otherwise bottom would have been called buttocks. About the Haskell Weekly News New editions are posted to [29]the Haskell mailing list as well as to [30]the Haskell Sequence and [31]Planet Haskell. [32]RSS is also available, and headlines appear on [33]haskell.org. To help create new editions of this newsletter, please see the information on [34]how to contribute. Send stories to jfredett . at . gmail . dot . com. The darcs repository is available at darcs get [35]http://patch-tag.com/r/jfredett/HWN2/pullrepo HWN2 . References 1. http://haskell.org/ 2. http://www.mail-archive.com/haskell@haskell.org/msg22432.html 3. http://article.gmane.org/gmane.comp.lang.haskell.cafe/66215 4. http://article.gmane.org/gmane.comp.lang.haskell.cafe/66184 5. http://article.gmane.org/gmane.comp.lang.haskell.cafe/66110 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/66103 7. http://article.gmane.org/gmane.comp.lang.haskell.cafe/66021 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/66018 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/65958 10. http://thread.gmane.org/ 11. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/66080 12. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/66056 13. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/66012 14. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/65996 15. http://planet.haskell.org/ 16. http://haskell.org/haskellwiki/Blog_articles 17. http://chplib.wordpress.com/2009/11/12/the-observer-pattern-using-a-broadcast-channel/ 18. http://martijn.van.steenbergen.nl/journal/2009/11/12/gadts-in-haskell-98/ 19. http://blog.mikael.johanssons.org/archive/2009/11/math198-multiple-lectures-posted/ 20. http://www.ittc.ku.edu/csdlblog/?p=16 21. http://www.londonhug.net/2009/11/10/functional-programming-exchange/ 22. http://chplib.wordpress.com/2009/11/10/the-observer-pattern-using-a-message-passing-process/ 23. http://lukeplant.me.uk/blog/posts/is-static-type-checking-a-redundant-testing-mechanism/ 24. http://twan.home.fmf.nl/blog/haskell/four-ways-to-fold.details 25. http://sulzmann.blogspot.com/2009/11/tag-free-combinators-for-binding-time.html 26. http://lukepalmer.wordpress.com/2009/11/08/collision-detection-with-enneatrees/ 27. http://blog.sigfpe.com/2009/11/memoizing-polymorphic-functions-with.html 28. http://lukeplant.me.uk/blog/posts/haskell-blog-software/ 29. http://www.haskell.org/mailman/listinfo/haskell 30. http://sequence.complete.org/ 31. http://planet.haskell.org/ 32. http://sequence.complete.org/node/feed 33. http://haskell.org/ 34. http://haskell.org/haskellwiki/HWN 35. http://patch-tag.com/r/jfredett/HWN2/pullrepo%20HWN2 From gour at gour-nitai.com Sat Nov 14 01:41:17 2009 From: gour at gour-nitai.com (Gour) Date: Sat Nov 14 01:17:24 2009 Subject: [Haskell-cafe] Re: Opinion about JHC References: <567296.97882.qm@web58802.mail.re1.yahoo.com> <20091111083759.GH21564@sliver.repetae.net> <20091112212054.7b0a9267@gaura-nitai.no-ip.org> <20091113111922.GE23126@sliver.repetae.net> Message-ID: <20091114074117.732290bb@gaura-nitai.no-ip.org> On Fri, 13 Nov 2009 03:19:22 -0800 >>>>>> "John" == John Meacham wrote: John> Would you really want to have to run jhc _on_ your nokia 770 (or John> whatever) just to compile Haskell programs for it? No. I'd be satisfied with the ability to develop in Haskell for Maemo/Moblin and run apps on those platforms. Sincerely, Gour -- Gour | Hlapicina, Croatia | GPG key: F96FF5F6 ---------------------------------------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091114/bac2ac25/signature.bin From lemmih at gmail.com Sat Nov 14 02:03:05 2009 From: lemmih at gmail.com (Lemmih) Date: Sat Nov 14 01:38:44 2009 Subject: [Haskell-cafe] Package Woes In-Reply-To: <200911131937.26924.daniel.is.fischer@web.de> References: <200911120447.52860.daniel.is.fischer@web.de> <200911131937.26924.daniel.is.fischer@web.de> Message-ID: On Fri, Nov 13, 2009 at 7:37 PM, Daniel Fischer wrote: > Am Freitag 13 November 2009 18:58:22 schrieb Lemmih: >> We no longer use libffi and I've removed the dependency. >> >> However, you're most likely to hit further obstacles when it comes to >> building the base libraries for LHC. I recommend waiting for the next >> stable release. > > Is there already a timeline? Shortly after ghc-6.12 and cabal-1.8 are released. -- Cheers, Lemmih From mwassell at bigpond.net.au Sat Nov 14 02:21:59 2009 From: mwassell at bigpond.net.au (Mark Wassell) Date: Sat Nov 14 01:57:48 2009 Subject: [Haskell-cafe] Collection of sets containing no sets which are a subset of another in the collection Message-ID: <4AFE5A97.7040808@bigpond.net.au> Hi, I am looking for a data structure that will represent a collection of sets such that no element in the collection is a subset of another set. In other words, inserting an element that is already a subset of another element will return the original collection, and inserting an element that is a superset of any elements will result in a collection with the superset added and the subsets removed. What I have so far is the below but I am wondering if there has been any prior work on this (particularly using Haskell but also conceptual work). Inserting a set that is a subset is easy to handle, inserting a superset and remove subsets of it is a little tricker. Cheers Mark module SetTrie where -- -- A set of sets which does not contain elements which are subsets of any other element. -- ie insert a element which is a proper subset of another set returns the same set of sets -- insert a element which is a proper superset of one or more elements causes those elements to be removed -- (and the first element to be added) -- import Data.Set hiding (toList,singleton,map,insert) import Data.Map hiding (fromList,showTreeWith,toAscList,toList,singleton,map,insert) import qualified Data.Map as M (toList,fromList,lookup,insert) import qualified Data.Set as S (toList,fromList) -- Normally we would have a flag at a node to indicate a subset is there, but we -- don't store subsets. data SetTrie a = Leaf [a] | Node (Map a (SetTrie a)) deriving (Show,Eq) singleton :: Ord a => Set a -> SetTrie a singleton = Leaf . S.toList toList' :: Ord a => SetTrie a -> [[a]] toList' (Leaf xs) = [xs] toList' (Node m) = concatMap (\(x,y) -> map (x:) (toList' y)) $ M.toList m toList :: Ord a => SetTrie a -> [Set a] toList x = map S.fromList $ toList' x insert :: Ord a => SetTrie a -> Set a -> SetTrie a insert t s = insert' t $ toAscList s insert':: Ord a => SetTrie a -> [a] -> SetTrie a insert' (Leaf (y:ys)) (x:xs) = Node (M.fromList [(y,Leaf ys),(x,Leaf xs)]) insert' (Node m) (x:xs) = case M.lookup x m of Nothing -> case xs of [] -> Node $ M.insert x (Leaf xs) m _ -> Node $ M.insert x (Leaf xs) m Just t' -> case xs of [] -> Node m _ -> Node $ M.insert x (insert' t' xs) m -- removeSubsets :: -- terminate (Node m) = Node mTrue m -- terminate (Leaf (x:xs)) = Node True (M.fromList [(x,Leaf xs)]) s1 = fromList [1,2,3,5,2] s2 = fromList [2,3,5] t1 = Node (M.fromList [(1,Leaf [2]),(3,Leaf [5]),(2,Node (M.fromList [(4,Leaf [6])]))]) t2 = insert (singleton (S.fromList [1])) $ S.fromList [1,2,3] t3 = insert t1 $ S.fromList [2,4,7] t4 = insert t2 $ S.fromList [1] t5 = insert t3 $ S.fromList [2,5] t6 = insert t5 $ S.fromList [2,4] -- Now add a superset of everything t7 = insert (singleton (S.fromList [8])) $ S.fromList [1,2,3,4,5,6,7,8,9] Mark From max.rabkin at gmail.com Sat Nov 14 04:35:34 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Sat Nov 14 04:11:35 2009 Subject: [Haskell-cafe] Collection of sets containing no sets which are a subset of another in the collection In-Reply-To: <4AFE5A97.7040808@bigpond.net.au> References: <4AFE5A97.7040808@bigpond.net.au> Message-ID: On Sat, Nov 14, 2009 at 9:21 AM, Mark Wassell wrote: > Hi, > > I am looking for a data structure that will represent a collection of sets > such that no element in the collection is a subset of another set. In other > words, inserting an element that is already a subset of another element will > return the original collection, and inserting an element that is a superset > of any elements will result in a collection with the superset added and the > subsets removed. I *think* what you're describing is a Union-Find structure. A functional union-find structure is described in http://www.lri.fr/~filliatr/ftp/publis/puf-wml07.ps (the language used is OCaml, but if you have any difficulty translating it to Haskell I'm sure this list will offer its help). --Max From manlio_perillo at libero.it Sat Nov 14 05:31:20 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sat Nov 14 05:07:00 2009 Subject: [Haskell-cafe] Lexical Syntax and Unicode Message-ID: <4AFE86F8.4000301@libero.it> Hi. Reading the Haskell 98 Report (section 9.2), I have found a possible problem. The lexical syntax supports Unicode, however this is not true for the newline: newline -> return linefeed | return | linefeed | formfeed The Unicode standard adds two additional characters: U+2028 LINE SEPARATOR U+2029 PARAGRAPH SEPARATOR The Unicode Character Database, also defines two general categories: Zl = Separator, line Zp = Separator, paragraph The Zl category only contains the LINE SEPARATOR character and the Zp category only contains the PARAGRAPH SEPARATOR character. So, IMHO, the lexical syntax should be changed in : newline -> return linefeed | return | linefeed | formfeed | uniLine | uniPara uniLine -> any Unicode character defined as line separator uniPara -> any Unicode character defined as paragraph separator or, alternatively: uniLine -> LINE SEPARATOR uniPara -> PARAGRAPH SEPARATOR Manlio Perillo From lemming at henning-thielemann.de Sat Nov 14 05:36:54 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Nov 14 05:13:10 2009 Subject: [Haskell-cafe] Opinion about JHC In-Reply-To: <20091114042449.GC24020@sliver.repetae.net> References: <567296.97882.qm@web58802.mail.re1.yahoo.com> <20091111083759.GH21564@sliver.repetae.net> <20091113112644.GF23126@sliver.repetae.net> <404396ef0911131208n4d97fd93xeff94ac5952d4ce@mail.gmail.com> <20091114042449.GC24020@sliver.repetae.net> Message-ID: On Fri, 13 Nov 2009, John Meacham wrote: > On Fri, Nov 13, 2009 at 08:55:51PM +0000, Lennart Augustsson wrote: >> That was indeed my point. Since a compiler is a substantial program I >> would have more confidence it a compiler that is self-hosting. >> Surely you must have tried? > > No, there are extensions that I use in jhc's code base that jhc itself > does not support yet (fundeps for instance). Maybe you can skip fundeps and move to Type families immediately. > Although said extensions would be nice and are on the list of things to > add to jhc, there are other tasks that are more important. I write a lot > of code in Haskell, so getting jhc to compile in jhc isn't much more > important than getting any of the other projects I work on to compile in > it and I prioritize accordingly. I am all about variety in the tools I > use. I never understood the desire to have it be self-hosting, I mean, > sure it is a nice abstract goal, but there are things with concrete > benefits that are more important to jhc right now. (of course, > priorities change over time.) A JHC compiled JHC might be faster and noticeably smaller? My current jhc executable is 15 MB. From vasyl.pasternak at gmail.com Sat Nov 14 05:59:48 2009 From: vasyl.pasternak at gmail.com (Vasyl Pasternak) Date: Sat Nov 14 05:35:27 2009 Subject: [Haskell-cafe] Some thoughts about Hackage Message-ID: <8feb08f70911140259y363b14a0i7ea3beb770662eb7@mail.gmail.com> Hi, Yesterday Max complained about documentation for many Haskell modules. But I found another similar problem with Hackage. Before coding some Haskell program I try to find most appropriate libraries, which help me to do task more efficiently. But the problem, that there are to many libraries with similar functionality (for example - networking, web servers etc.). And to find the best solution is not so obvious. My idea is to improve Hackage to help everyone with package selecting. I propose the following: - add download counter for each package, it could show how popular the package is - allow registered users set the quality mark of the package (from 1 to 5) and show the average mark of each packet - add counter which shows how many packages depend on this package (direct/indirect) - create an aggregate package rank (a function on previous three values), similar to Google's PageRank, i. e. rank of the package is proportional to the package mark and weighted rank of dependent packages - allow comments on the package page, so anyone could tell its opinion or other useful info for this package. All messages should be delivered to the maintainer. This is useful, because it could speedup the feedback on the packages, and also could form large knowledge base on each package. Now everyone, who wants to read more about some package should use Google to extract info from HaskellWiki, Haskell-Cafe or hundreds of blog posts from different authors. What do you think ? Best regards, Vasyl Pasternak From ndmitchell at gmail.com Sat Nov 14 06:03:43 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sat Nov 14 05:39:21 2009 Subject: [Haskell-cafe] haskell-src-exts Question In-Reply-To: <1258159565.4680.14166.camel@localhost> References: <404396ef0911131208k2063db80i4c966b403d53bafb@mail.gmail.com> <1258148654.4680.13597.camel@localhost> <1258159565.4680.14166.camel@localhost> Message-ID: <404396ef0911140303g40c13bb3meb4adacd723709c7@mail.gmail.com> Hi Adding brackets that MUST have been there, by default, sounds like a great idea. The alternative is getting it wrong, so I think that's very safe. Adding brackets that MIGHT have been there is a lot less clear cut. One important consideration is that the fixities you parse/pretty-print with might be wrong, so it has to be sensitive to that. You have the options: * Always do it (but then you get way too many brackets, and in the case where you mis-guess the fixities, you break the code) * Do it based on a table of fixities (might work if the parser fixities match the pretty-printer fixities, but could go wrong) * Annotate operators with fixities (this seems really wrong, and suffers from incorrect guessed fixities very badly) * Never do it My preference would be: -- put in enough brackets based on a fixities ensureEnoughBrackets :: [Fixities] -> a -> a prettyPrint = show . ensureEnoughBrackets [] Always do the safe brackets, if people want to do a table-of-fixities approach they can easily do so. Also by putting this code in the pretty printer it's harder to reuse if you want to write a custom pretty print or similar - ensureEnoughBrackets may be independently useful. Thanks Neil > To do it minimally yes, but correctly? In the AST you've got > > InfixApp Exp QOp Exp > > so we know the tree structure, we just can't insert minimal brackets > without knowing the fixity. > >> However, that doesn't mean we can't do better than what it is now, but >> be conservative about it. Only insert brackets where it's clear that >> brackets must be inserted, which would be the case for Dominic's >> example. If the argument to an application is non-atomic, it needs >> brackets, there's nothing ambiguous about that. Nothing can be said so >> categorically for infix applications, so there we should assume that >> the fixities are already done in the correct way, or that brackets are >> inserted manually where needed. >> >> Does that sound reasonable? Yes - that seems perfectly sensible. > The suggestion is to move to a "safe/correct by default" where brackets > are inserted to preserve the tree structure of infix expressions. The > problem then becomes, what if we want to have the minimal (or pleasing > not-quite-minimal) number of brackets. > > Right? > > If I've understood right, then yes I think making the pretty printing > right by default is a good idea, and then for the users/applications > where optimising for fewer brackets is important, it should be a little > extra work to supply the necessary information. > > Perhaps like the ParseMode has fixities :: [Fixity], give the PPHsMode > the same (partial) fixities environment. For operators not in the > environment we fall back to using brackets all the time, but for known > operators we can the use minimal bracketing. > > Another option I suppose would be to annotate the QOp used in InfixApp > with a Maybe fixity. The parser would annotate these when it knows them > from its fixities env in the ParseMode. For ASTs constructed manually > the user would add them if they know or care. If not, they just get > slightly more brackets than might strictly be necessary if the fixity > were known. > > Duncan > > From andrewcoppin at btinternet.com Sat Nov 14 06:32:33 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Nov 14 06:08:10 2009 Subject: [Haskell-cafe] Some thoughts about Hackage In-Reply-To: <8feb08f70911140259y363b14a0i7ea3beb770662eb7@mail.gmail.com> References: <8feb08f70911140259y363b14a0i7ea3beb770662eb7@mail.gmail.com> Message-ID: <4AFE9551.6090200@btinternet.com> Vasyl Pasternak wrote: > Before coding some Haskell program I try to find most appropriate > libraries, which help me to do task more efficiently. But the problem, > that there are to many libraries with similar functionality (for > example - networking, web servers etc.). And to find the best solution > is not so obvious. > I agree. (Have you seen how many "binary" packages there are??) Some people seem to think having dozens of libraries for the same task is an "advantage" because it lets the libraries compete against each other and the best one will win. However, I don't think this is the case if it's too difficult to tell the libraries apart. > - allow comments on the package page, so anyone could tell its opinion > or other useful info for this package. > > What do you think ? > I think this last idea is the best. Adding a ranking is nice, but a comment lets people add highly relevant information like "this package is good, but doesn't work properly with Unicode" and so forth. Stuff somebody about to try using the package would *really* want to know. From felipe.lessa at gmail.com Sat Nov 14 06:45:42 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Nov 14 06:21:23 2009 Subject: [Haskell-cafe] Some thoughts about Hackage In-Reply-To: <4AFE9551.6090200@btinternet.com> References: <8feb08f70911140259y363b14a0i7ea3beb770662eb7@mail.gmail.com> <4AFE9551.6090200@btinternet.com> Message-ID: <20091114114542.GA1701@kira.casa> On Sat, Nov 14, 2009 at 11:32:33AM +0000, Andrew Coppin wrote: > Adding a ranking is nice, but a comment lets people add highly > relevant information like "this package is good, but doesn't work > properly with Unicode" and so forth. Stuff somebody about to try > using the package would *really* want to know. Probably adding markers to the comment area every time a new version is added is also a nice idea because a problem in the comment are may be corrected. The marker would serve as a visual aid that the comment may be outdated. -- Felipe. From jtod at dcs.gla.ac.uk Sat Nov 14 06:52:30 2009 From: jtod at dcs.gla.ac.uk (John O'Donnell) Date: Sat Nov 14 06:28:59 2009 Subject: [Haskell-cafe] Re: Writing great documentation[MESSAGE NOT SCANNED] In-Reply-To: <1258151514.4680.13765.camel@localhost> References: <1258151514.4680.13765.camel@localhost> Message-ID: <4AFE99FE.60005@dcs.gla.ac.uk> I agree with Duncan's comment: > I rather like the idea of using markdown (pandoc) for separate > non-reference docs like man pages, tutorials, user guides etc rather > than trying to make haddock do everything. > In one of my projects (Hydra and Sigma), I use pandoc for the bulk of the documentation, and integrate this with haddock documentation for the parts of the documentation that haddock can do (which is a small part of it). This is all coordinated by a (rather clunky) Setup.hs. The whole thing isn't very elegant, but it works robustly on both Linux and Windows. That's a big advantage of pandoc: you can install it with cabal and use it in your Setup, so it isn't necessary to do any shell scripting, which can cause portability problems. I'll attach the Setup.hs file. One of the central issues here is *where* the documentation files go. I don't like the existing situation, where haddock documentation goes into a standard place, and presumably other documentation goes somewhere else. It's surely better to have all the documentation for a package in one directory, with all the parts linked together. So my setup makes a directory, builds the haddock and pandoc pieces of the documentation, copies (or build) it all into the directory, and then the contents of this directory is listed under data-files in the cabal file. The result is that building the system produces a complete self-contained directory and the executable application is able to find its own documentation files. This is usful in a GUI program, for example, where it's nice to make the documentation availble under the Help menu. Something along these lines (with a cleaner design) would be generally useful. John O'Donnell On 11/13/2009 10:31 PM, Duncan Coutts wrote: > On Fri, 2009-11-13 at 23:20 +0200, Max Rabkin wrote: > >> On Fri, Nov 13, 2009 at 10:58 PM, Simon Michael wrote: >> >>> A very common problem with online docs is fragmentation. >>> >> Absolutely! Is it possible to include non-haddock documentation in a >> cabal package. Is it possible to have it readable on Hackage? >> > Not yet. > > Want to volunteer? > > http://hackage.haskell.org/trac/hackage/ticket/330 > > It's partly a matter of tasteful design and partly implementation. The > same person/people do not need to do both bits. Thrashing out a detailed > and workable design would get us most of the way there. > > >> I think this would help with the fragmentation and versioning issues. >> > Yes, I agree. > > >> One option is to have haddock-only modules for non-reference >> documentation (xmonad-contrib does this), and I think at the moment it >> is a good option, but it does have disadvantages. It may not be clear >> from the outline where documentation can be found, and it clutters up >> the module namespace. Perhaps we could add support for a >> Documentation-Modules field in cabal files, which would separate these >> modules in the outline, and not install them but only their >> documentation. >> > I rather like the idea of using markdown (pandoc) for separate > non-reference docs like man pages, tutorials, user guides etc rather > than trying to make haddock do everything. > > Duncan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- import Distribution.Simple import System.Directory import System.FilePath import Text.Pandoc import Text.Pandoc.Shared import qualified System.IO.UTF8 as U -- To do: main = defaultMainWithHooks hooks hooks :: UserHooks hooks = simpleUserHooks {postBuild = postBuildHook} ------------------------------------------------------------------------ {- Haddock creates its documentation in the form of a set of files in dist/doc/html/Hydra. These files have names matching *.html, *.gif, *.css, *.js, Hydra.haddock. After running haddock, we have: dist/doc/html/Hydra/(files created by Haddock) Hydra has much more extensive documentation, produced by pandoc from sources in doc. The top level file in this is index.html. To avoid conflicts between the primary Hydra documentation and the API documentation from haddock, the following steps are taken: 1. A list of files in dist/doc/html/Hydra/ is created, and named haddock_files 2. A directory dist/doc/html/Hydra/haddock is created 3. All the files in dist/doc/html/Hydra[haddock_files] are copied to dist/doc/html/Hydra/haddock 4. All the files in dist/doc/html/Hydra[haddock_files] are removed 5. Pandoc is run on the documentation source files, with the results placed in dist/doc/html/Hydra. These files contain relative pointers (URLs) into the haddock documentation. The result is a documentation directory in the same place Cabal expects to find it --- dist/doc/html/Hydra --- which contains the Hydra documentation as well as the API reference produced by haddock. -} ------------------------------------------------------------------------ {- The csslink string is html to be incorporated into the page; it loads the css style file. This is placed into the haddock directory, and given the name haddock.css, so the html files generated by haddock will find it. The files generated by pandoc also look there, so only one copy of the style file needs to be created. -} csslink :: String csslink = "" ------------------------------------------------------------------------ postBuildHook args flags packageDescription localBuildInfo = do putStrLn (take 72 (repeat '-')) putStrLn "running postBuildHook" createDirectoryIfMissing True (joinPath ["doc", "html"]) createDirectoryIfMissing True (joinPath ["doc", "html", "figures"]) putStrLn "Running pandoc..." runPandoc putStrLn "Pandoc finished" putStrLn (take 72 (repeat '-')) figure_files <- getDirectoryContents (joinPath ["doc", "src", "figures", "xfig"]) putStrLn ("Figure files: " ++ concat (map ((++"\n") . show) figure_files)) copy_files (joinPath ["doc", "src", "figures", "xfig"]) (joinPath ["doc", "html", "figures"]) figure_files copyFile (joinPath ["doc", "src", "style.css"]) (joinPath ["doc", "html", "style.css"]) copyFile "Sigma16.cabal" (joinPath ["doc","html", "Sigma16.cabal"]) -- copyFile -- (joinPath ["examples", "Add.asm.src.txt"]) -- (joinPath ["doc", "html", "Add.asm.src.txt"]) putStrLn (take 72 (repeat '-')) return () ------------------------------------------------------------------------ move_files src dest [] = return () move_files src dest (x:xs) = do putStrLn x if head x == '.' || x=="haddock" || x=="figures" then putStrLn ("Skipping file <" ++ x ++ ">") else do let srcpath = joinPath [src,x] let destpath = joinPath [dest,x] putStrLn ("Moving <" ++ srcpath ++ "> to <" ++ destpath ++ ">") renameFile srcpath destpath move_files src dest xs copy_files src dest [] = return () copy_files src dest (x:xs) = do putStrLn x let ext = takeExtension x let srcpath = joinPath [src,x] let destpath = joinPath [dest,x] putStrLn ("filepath = <" ++ x ++ "> extension = <" ++ ext ++ ">") if head x == '.' || ext/=".png" then putStrLn ("Skipping file <" ++ x ++ ">") else do putStrLn ("Copying <" ++ srcpath ++ "> to <" ++ destpath ++ ">") copyFile srcpath destpath copy_files src dest xs ------------------------------------------------------------------------ markdownToHtml :: WriterOptions -> String -> String markdownToHtml opts = (writeHtmlString opts) . readMarkdown defaultParserState mkHtml :: String -> String -> WriterOptions -> IO () mkHtml infilepath outfilepath opts = do inp <- U.readFile infilepath let outp = markdownToHtml opts inp writeFile outfilepath outp runPandoc = do putStrLn "Building index.html" mkHtml (joinPath ["doc", "src", "index.txt"]) (joinPath ["index.html"]) (defaultWriterOptions { writerStandalone = True , writerIncludeBefore = csslink }) mkHtml (joinPath ["doc", "src", "overview.txt"]) (joinPath ["doc", "html", "overview.html"]) (defaultWriterOptions { writerIncludeBefore = csslink , writerStandalone = True , writerTableOfContents = True }) mkHtml (joinPath ["doc", "src", "programming.txt"]) (joinPath ["doc", "html", "programming.html"]) (defaultWriterOptions { writerIncludeBefore = csslink , writerStandalone = True , writerTableOfContents = True , writerHTMLMathMethod = LaTeXMathML Nothing }) mkHtml (joinPath ["doc", "src", "architecture.txt"]) (joinPath ["doc", "html", "architecture.html"]) (defaultWriterOptions { writerIncludeBefore = csslink , writerStandalone = True , writerTableOfContents = True , writerHTMLMathMethod = LaTeXMathML Nothing }) mkHtml (joinPath ["doc", "src", "assembly.txt"]) (joinPath ["doc", "html", "assembly.html"]) (defaultWriterOptions { writerIncludeBefore = csslink , writerStandalone = True , writerTableOfContents = True , writerHTMLMathMethod = LaTeXMathML Nothing }) mkHtml (joinPath ["doc", "src", "linking.txt"]) (joinPath ["doc", "html", "linking.html"]) (defaultWriterOptions { writerIncludeBefore = csslink , writerStandalone = True , writerTableOfContents = True , writerHTMLMathMethod = LaTeXMathML Nothing }) mkHtml (joinPath ["doc", "src", "execution.txt"]) (joinPath ["doc", "html", "execution.html"]) (defaultWriterOptions { writerIncludeBefore = csslink , writerStandalone = True , writerTableOfContents = True , writerHTMLMathMethod = LaTeXMathML Nothing }) mkHtml (joinPath ["doc", "src", "tutorial.txt"]) (joinPath ["doc", "html", "tutorial.html"]) (defaultWriterOptions { writerIncludeBefore = csslink , writerStandalone = True , writerTableOfContents = True , writerHTMLMathMethod = LaTeXMathML Nothing }) mkHtml (joinPath ["doc", "src", "colophon.txt"]) (joinPath ["doc", "html", "colophon.html"]) (defaultWriterOptions { writerIncludeBefore = csslink , writerStandalone = True , writerTableOfContents = True , writerHTMLMathMethod = LaTeXMathML Nothing }) mkHtml "README" (joinPath ["doc", "html", "README.html"]) (defaultWriterOptions { writerIncludeBefore = csslink , writerStandalone = True , writerTableOfContents = True }) mkHtml "INSTALL" (joinPath ["doc", "html", "INSTALL.html"]) (defaultWriterOptions { writerIncludeBefore = csslink , writerStandalone = True , writerTableOfContents = True }) mkHtml "LICENSE" -- "dist/doc/html/Hydra/LICENSE.html" (joinPath ["doc", "html", "LICENSE.html"]) (defaultWriterOptions { writerIncludeBefore = csslink , writerStandalone = True , writerTableOfContents = True }) ------------------------------------------------------------------------ From stephen.tetley at gmail.com Sat Nov 14 07:21:58 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sat Nov 14 06:57:38 2009 Subject: [Haskell-cafe] Some thoughts about Hackage In-Reply-To: <20091114114542.GA1701@kira.casa> References: <8feb08f70911140259y363b14a0i7ea3beb770662eb7@mail.gmail.com> <4AFE9551.6090200@btinternet.com> <20091114114542.GA1701@kira.casa> Message-ID: <5fdc56d70911140421i72762d39p50a10b75a2e1aed6@mail.gmail.com> 2009/11/14 Felipe Lessa : > > Probably adding markers to the comment area every time a new > version is added is also a nice idea because a problem in the > comment are may be corrected. ?The marker would serve as a visual > aid that the comment may be outdated. It would be nice if you could see a changelog from a package's 'start' page on the Hackage website. Otherwise, don't Roel van Dijk's reverse dependencies give some of the information - i.e. the 'social proof' that a package is used and useful? http://www.haskell.org/pipermail/haskell-cafe/2009-October/067765.html http://bifunctor.homelinux.net/~roel/hackage/packages/hackage.html As Hackage already has Haddock docs and source-code view, you can easily scan a project to see if you like the code. Plus, the project's Hackage start page tracks versions so you can judge the maintained status of a project (some great packages 'just work' of course and haven't needed updating e.g. wl-pprint). As the Hackage server builds projects, you can tell to some degree that a project works or not (include the usual caveats for Windows and Mac users at this juncture)... Slighty of topic - how does a package author remove or at mark least deprecated their own package? Best wishes Stephen From gwern0 at gmail.com Sat Nov 14 09:05:54 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Sat Nov 14 08:41:32 2009 Subject: [Haskell-cafe] Some thoughts about Hackage In-Reply-To: <5fdc56d70911140421i72762d39p50a10b75a2e1aed6@mail.gmail.com> References: <8feb08f70911140259y363b14a0i7ea3beb770662eb7@mail.gmail.com> <4AFE9551.6090200@btinternet.com> <20091114114542.GA1701@kira.casa> <5fdc56d70911140421i72762d39p50a10b75a2e1aed6@mail.gmail.com> Message-ID: On Sat, Nov 14, 2009 at 7:21 AM, Stephen Tetley wrote: > 2009/11/14 Felipe Lessa : > >> >> Probably adding markers to the comment area every time a new >> version is added is also a nice idea because a problem in the >> comment are may be corrected. ?The marker would serve as a visual >> aid that the comment may be outdated. > > It would be nice if you could see a changelog from a package's 'start' > page on the Hackage website. http://hackage.haskell.org/trac/hackage/ticket/299 http://hackage.haskell.org/trac/hackage/ticket/244 -- gwern From gwern0 at gmail.com Sat Nov 14 09:13:48 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Sat Nov 14 08:49:26 2009 Subject: [Haskell-cafe] Collection of sets containing no sets which are a subset of another in the collection In-Reply-To: References: <4AFE5A97.7040808@bigpond.net.au> Message-ID: On Sat, Nov 14, 2009 at 4:35 AM, Max Rabkin wrote: > On Sat, Nov 14, 2009 at 9:21 AM, Mark Wassell wrote: >> Hi, >> >> I am looking for a data structure that will represent a collection of sets >> such that no element in the collection is a subset of another set. In other >> words, inserting an element that is already a subset of another element will >> return the original collection, and inserting an element that is a superset >> of any elements will result in a collection with the superset added and the >> subsets removed. > > I *think* what you're describing is a Union-Find structure. A > functional union-find structure is described in > http://www.lri.fr/~filliatr/ftp/publis/puf-wml07.ps (the language used > is OCaml, but if you have any difficulty translating it to Haskell I'm > sure this list will offer its help). > > --Max http://hackage.haskell.org/package/union-find ? -- gwern From anotheraddress at gmx.de Sat Nov 14 09:14:28 2009 From: anotheraddress at gmx.de (Daniel =?iso-8859-1?q?Sch=FCssler?=) Date: Sat Nov 14 08:50:10 2009 Subject: [Haskell-cafe] haskell-src-exts Question In-Reply-To: <404396ef0911131208k2063db80i4c966b403d53bafb@mail.gmail.com> References: <404396ef0911131208k2063db80i4c966b403d53bafb@mail.gmail.com> Message-ID: <200911141514.28759.anotheraddress@gmx.de> Hi, On Friday 13 November 2009 21:08:42 Neil Mitchell wrote: > In HLint I have a bracketing module, which has served me well. Please > take any ideas you need from it - > http://community.haskell.org/~ndm/darcs/hlint/src/HSE/Bracket.hs . In > particular, given a fully bracketed expression, I can call > transformBracket to transform the expression, not caring about > brackets, in a way that guarantees the right brackets are put back. > There is also needBracket and isAtom which are very useful. If you > call descendBi (transformBracket Just) it will automatically bracket > your term as much as is necessary. > Funny, I did the opposite approach the other day (not saying either is better :)); that is: parenthesize everything while building the AST (with a wrapper for App) and then: deparenthesize :: (Data a) => a -> a deparenthesize = everywhereBut isString (mkT goE `extT` goT) where isString x = typeOf x == typeOf (undefined :: String) goE (App (Paren (App e1 e2)) e3) = (App (App e1 e2) e3) goE (Paren (Paren e)) = Paren e goE (InfixApp e1 op'' (Paren (InfixApp e2 op' e3))) | op'' == op' , knownAssociative op'' = InfixApp e1 op'' (InfixApp e2 op' e3) goE (InfixApp (Paren (InfixApp e1 op'' e2)) op' e3) | op'' == op' , knownAssociative op'' = InfixApp (InfixApp e1 op'' e2) op' e3 goE x = x goT (TyApp (TyParen (TyApp t1 t2)) t3) = (TyApp (TyApp t1 t2) t3) -- add rule for function types too goT (TyParen (TyParen t)) = TyParen t goT x = x knownAssociative x = x `elem` [QVarOp (UnQual (Symbol "."))] Though the infix thing doesn't quite work; apparently they still get printed with parens even if there are no parens in the AST? Or the rule just didn't match for some reason... -- Greetings, Daniel From mauricio.antunes at gmail.com Sat Nov 14 10:47:04 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Sat Nov 14 10:23:05 2009 Subject: [Haskell-cafe] How much time until dependencies are rebuilt in hackage? Message-ID: Suppose package B depends on A. If a new version of A is uploaded to hackage, how much later package B will be rebuilt (either to show a problem with the new version or to solve a problem with a previous version of A)? Thanks, Maur?cio From markl at glyphic.com Sat Nov 14 11:55:25 2009 From: markl at glyphic.com (Mark Lentczner) Date: Sat Nov 14 11:31:03 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <3c6288ab0911121459x6429d56fm6b83257ce3c157f6@mail.gmail.com> References: <26311291.post@talk.nabble.com> <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> <4AFBE582.1030605@btinternet.com> <5e0214850911120244m30a2a285m4eeced410cf7d568@mail.gmail.com> <4AFC678F.5090501@btinternet.com> <3c6288ab0911121459x6429d56fm6b83257ce3c157f6@mail.gmail.com> Message-ID: <562F0F92-6DCA-4070-A20F-271F4BBDE9C7@glyphic.com> On Nov 12, 2009, at 2:59 PM, Sean Leather wrote: > foo :: forall x y. (x -> x) -> y > bar :: forall y. (forall x . x -> x) -> y > > While neither function is seemingly useful, the second says that the higher-order argument must be polymorphic. I see two options: AHA! This is the bit of insight I needed! My confusion over forall was I thought that I understood that all Haskell types were as if there was a forall for all free type variables in front of the expression. For example, I think the following are the same: fizz :: a -> String -> [a] fizz :: forall a. a -> String -> [a] So why would you need forall? The example Sean explained is that if you want to control the scope of the existential quantification. And you can only "push the scope inward", since the outer most scope basically "forall"s all the free type variables (after type inference, I suppose.) I also think I understand that the implicit 'forall' inherent in Haskell falls at different places in various constructs, which also had me confused. For example, while the above two function type declarations are equivalent, these two data declarations aren't: data Fizzle a = Fizzle (b -> (a, b)) a data Fizzle a = forall b. Fizzle (b -> (a, b)) a This would be because the implicit 'forall' is essentially to the left of the 'data Fizzle a' section. I'm guessing that the same holds true for type and newtype constructs. Have I got this all correct? Would I be correct in thinking: The difference between these two is that the type b can be "fixed" upon application of amy to the first two arguments (given context), whereas bob applied to two arguments MUST return a function that is applicable to every type. amy :: Int -> a -> b -> [Either a b] bob :: Int -> a -> (forall b. b) -> [Either a b] Thanks for helping me understand... - Mark From ndmitchell at gmail.com Sat Nov 14 11:57:07 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sat Nov 14 11:32:44 2009 Subject: [Haskell-cafe] haskell-src-exts Question In-Reply-To: <200911141514.28759.anotheraddress@gmx.de> References: <404396ef0911131208k2063db80i4c966b403d53bafb@mail.gmail.com> <200911141514.28759.anotheraddress@gmx.de> Message-ID: <404396ef0911140857m6e50b90cl1f6871872b9af3dc@mail.gmail.com> Hi Daniel, > Funny, I did the opposite approach the other day (not saying either is better > :)); that is: parenthesize everything while building the AST (with a wrapper > for App) and then: I have utilities in HLint for that too - but I don't want to remove users brackets automatically :-) Btw, if you use uniplate you might find your code goes faster, and is simpler: deparenthesize :: (Data a) => a -> a deparenthesize = transformBi goT . transformBi goT ? ?where (the rest exactly as before, but skipping isString) I always use Uniplate when working with HSE - they go great together (do import Data.Generics.PlateData, and you don't need any extra instances or anything) Thanks, Neil From caseyh at istar.ca Sat Nov 14 13:15:51 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Sat Nov 14 12:51:16 2009 Subject: [Haskell-cafe] Where is a good place to place code like this, so if I may be so bold, people can learn from it? Message-ID: <7pstf5t48mj65i73hs4u7fp3a4940bqpdd@4ax.com> Where is a good place to place code like this, so if I may be so bold, people can learn from it? {- Author Modifications: Casey Hawthorne Author Original: Jeff Newbern Maintainer: Casey Hawthorne Maintainer?: Jeff Newbern Time-stamp: Jeff Time-stamp: Casey License: GPL The N-queens puzzle is to place N queens on an N by N chess board so that no queen can attack another one. Compiler Flags: ghc -O2 -fvia-c --make N-Queens.hs Description http://www.haskell.org/all_about_monads/html/stacking.html#example Original Code http://www.haskell.org/all_about_monads/examples/example25.hs -} {- Description Example 25 - Using the StateT monad transformer with the List monad to achieve non-deterministic stateful computations, and the Writer monad to do logging Usage: Compile the code and run it with an argument between 1 and 8. It will print a solution to the N-queens puzzle along with a log of the number of choices it had at each step. The N-queens puzzle is to place N queens on a chess board so that no queen can attack another one. The original version always used an 8x8 board. Try: ./ex25 8 ./ex25 1 ./ex25 7 Added by Casey: - different board sizes -- up to a maximum 26x26 square board - updated imports list -} import IO import System import Monad import Data.Maybe import Data.List import Data.Char (toLower) import Control.Monad.State import Control.Monad.Writer -- describe Chess Units and positions type Rank = Int data File = A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | X | Y | Z deriving (Eq, Show, Ord, Enum) data Position = Pos {file::File, rank::Rank} deriving Eq instance Show Position where show (Pos f r) = (map toLower (show f)) ++ (show r) instance Ord Position where compare p1 p2 = case (rank p1) `compare` (rank p2) of LT -> GT GT -> LT _ -> (file p1) `compare` (file p2) data Kind = Pawn | Knight | Bishop | Rook | Queen | King deriving (Eq, Ord, Enum) instance Show Kind where show Pawn = "P" show Knight = "N" show Bishop = "B" show Rook = "R" show Queen = "Q" show King = "K" data Color = Black | White deriving (Eq, Ord, Enum) instance Show Color where show Black = "b" show White = "w" data Unit = Unit {color::Color, kind::Kind} deriving (Eq, Ord) instance Show Unit where show (Unit c k) = ((show c) ++ (show k)) data Board = Board {size::Int, psns::[(Unit,Position)]} -- newtype Board = Board [(Unit,Position)] -- newtype BoardMax = BoardMax Int instance Show Board where show (Board n ps) = let ordered = (sort . swap) ps ranks = map (showRank ordered) [n,(n-1)..1] board = intersperse (concat (take n (repeat "--+"))) ranks rlabels = intersperse " " (map (\n->(twoSpaces n)++" ") [n,(n-1)..1]) flabels = take (n*3) " a b c d e f g h i j k l m n o p q r s t u v w x y z" twoSpaces n | length (show n) == 2 = show n | otherwise = " " ++ (show n) in unlines $ zipWith (++) rlabels board ++ [flabels] where swap = map (\(a,b)->(b,a)) showRank ps r = let rnk = filter (\(p,_)->(rank p)==r) ps cs = map (showUnit rnk) (take n [A .. Z]) in concat (intersperse "|" cs) showUnit ps f = maybe " " (show . snd) (find (\(p,_)->(file p)==f) ps) data Diagonal = Ascending Position | Descending Position deriving (Eq, Show) -- define the diagonal according to its interesction with rank 1 or size of board) -- or with file a normalize :: Int -> Diagonal -> Diagonal normalize n d@(Ascending psn) | (rank psn) == 1 = d | (file psn) == A = d | otherwise = normalize n (Ascending (Pos (pred (file psn)) ((rank psn)-1))) normalize n d@(Descending psn) | (rank psn) == n = d | (file psn) == A = d | otherwise = normalize n (Descending (Pos (pred (file psn)) ((rank psn)+1))) -- get the diagonals corresponding to a location on the board getDiags :: Int -> Position -> (Diagonal,Diagonal) getDiags n p = (normalize n (Ascending p), normalize n (Descending p)) -- this is the type of our problem description data NQueensProblem = NQP {board::Board, ranks::[Rank], files::[File], asc::[Diagonal], desc::[Diagonal]} -- initial state = empty board, all ranks, files, and diagonals free initialState n = let fileA = map (\r->Pos A r) [1..n] rankMax = map (\f->Pos f n) (take n [A .. Z]) rank1 = map (\f->Pos f 1) (take n [A .. Z]) asc = map Ascending (nub (fileA ++ rank1)) desc = map Descending (nub (fileA ++ rankMax)) in NQP (Board n []) [1..n] (take n [A .. Z]) asc desc -- this is our combined monad type for this problem type NDS a = WriterT [String] (StateT NQueensProblem []) a -- Get the first solution to the problem, by evaluating the solver computation with -- an initial problem state and then returning the first solution in the result list, -- or Nothing if there was no solution. getSolution :: NDS a -> NQueensProblem -> Maybe (a,[String]) getSolution c i = listToMaybe (evalStateT (runWriterT c) i) -- add a Queen to the board in a specific position addQueen :: Position -> NDS () addQueen p = do (Board n b) <- gets board rs <- gets ranks fs <- gets files as <- gets asc ds <- gets desc let b' = (Unit Black Queen, p):b rs' = delete (rank p) rs fs' = delete (file p) fs (a,d) = getDiags n p as' = delete a as ds' = delete d ds tell ["Added Queen at " ++ (show p)] put (NQP (Board n b') rs' fs' as' ds') -- test if a position is in the set of allowed diagonals inDiags :: Int -> Position -> NDS Bool inDiags n p = do let (a,d) = getDiags n p as <- gets asc ds <- gets desc return $ (elem a as) && (elem d ds) -- add a Queen to the board in all allowed positions addQueens :: NDS () addQueens = do rs <- gets ranks fs <- gets files (Board n b) <- gets board allowed <- filterM (inDiags n) [Pos f r | f <- fs, r <- rs] tell [show (length allowed) ++ " possible choices"] msum (map addQueen allowed) -- Start with an empty chess board and add the requested number of queens, -- then get the board and print the solution along with the log main :: IO () main = do args <- getArgs let n = read (args!!0) cmds = replicate n addQueens sol = (`getSolution` (initialState n)) $ do sequence_ cmds gets board case sol of Just (b,l) -> do putStr $ show b -- show the solution putStr $ unlines l -- show the log Nothing -> putStrLn "No solution" -- END OF FILE -- Regards, Casey From jaco.van.iterson at gmail.com Sat Nov 14 13:20:27 2009 From: jaco.van.iterson at gmail.com (Jaco van Iterson) Date: Sat Nov 14 12:56:04 2009 Subject: [Haskell-cafe] Some help needed to start Haskell with Yi Message-ID: <6d2443150911141020o1d50f40by6530d0f4305c1ffb@mail.gmail.com> Hi there I'm new to Haskell and need some help to get started faster (busy busy busy). I like to adjust and extend an editor to my liking and I choose Yi. Only installation with 'cabal install yi' in a Cygwin shell under MS Windows XP ended in: Yi\Prelude.hs:182:9: Duplicate instance declarations: instance Category Accessor.T -- Defined at Yi\Prelude.hs:182:9-38 instance Category Accessor.T -- Defined in data-accessor-0.2.1:Data.Accessor.Private cabal.exe: Error: some packages failed to install: yi-0.6.1 failed during the building phase. The exception was: exit: ExitFailure 1 :( Seems easy to fix but I can't even find where on my drive I can find the source code. Where is the source? Cheers, Jaco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091114/ac2a2b25/attachment.html From bulat.ziganshin at gmail.com Sat Nov 14 13:42:01 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Nov 14 13:18:03 2009 Subject: [Haskell-cafe] Where is a good place to place code like this, so if I may be so bold, people can learn from it? In-Reply-To: <7pstf5t48mj65i73hs4u7fp3a4940bqpdd@4ax.com> References: <7pstf5t48mj65i73hs4u7fp3a4940bqpdd@4ax.com> Message-ID: <643773957.20091114214201@gmail.com> Hello Casey, Saturday, November 14, 2009, 9:15:51 PM, you wrote: > Where is a good place to place code like this, so if I may be so bold, > people can learn from it? the solution i've seen in 80's was: main = print (solutions 8 8) solutions n 0 = [[]] solutions n k = [(i,k):xs | xs <- solutions n (k-1), i <- [1..n], check i k xs] check i k xs = and [i1/=i && k1/=k && abs(i1-i)/=abs(k1-k) | (i1,k1) <- xs] -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From caseyh at istar.ca Sat Nov 14 13:53:38 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Sat Nov 14 13:29:04 2009 Subject: [Haskell-cafe] Where is a good place to place code like this, so if I may be so bold, people can learn from it? In-Reply-To: <643773957.20091114214201@gmail.com> References: <7pstf5t48mj65i73hs4u7fp3a4940bqpdd@4ax.com> <643773957.20091114214201@gmail.com> Message-ID: Hi Bulat: I believe Jeff's original idea was to show an example of a monad transformer stack and ASCII art output. On Sat, 14 Nov 2009 21:42:01 +0300, you wrote: >Hello Casey, > >Saturday, November 14, 2009, 9:15:51 PM, you wrote: > >> Where is a good place to place code like this, so if I may be so bold, >> people can learn from it? > >the solution i've seen in 80's was: > >main = print (solutions 8 8) > >solutions n 0 = [[]] >solutions n k = [(i,k):xs | xs <- solutions n (k-1), i <- [1..n], check i k xs] > >check i k xs = and [i1/=i && k1/=k && abs(i1-i)/=abs(k1-k) | (i1,k1) <- xs] -- Regards, Casey From Patrick.Browne at comp.dit.ie Sat Nov 14 14:07:25 2009 From: Patrick.Browne at comp.dit.ie (pbrowne) Date: Sat Nov 14 13:43:11 2009 Subject: [Haskell-cafe] Type-indexed expressions with fixpoint In-Reply-To: <20091110121227.1831A1727F@Adric.ern.nps.edu> References: <20091110121227.1831A1727F@Adric.ern.nps.edu> Message-ID: <4AFEFFED.1080007@comp.dit.ie> oleg@okmij.org wrote: > Brent Yorgey wrote: > > John Reynolds showed long ago that any higher-order language can be > encoded in first-order. We witness this every day: higher-order > language like Haskell is encoded in first-order language (machine > code). The trick is just to add a layer of interpretive overhead -- I > mean, a layer of interpretation. The closure conversion on type level > was shown in > http://okmij.org/ftp/Computation/lambda-calc.html#haskell-type-level > Brent, Do you have the reference for Reynolds higher-order to first-order encoding. Regards, Pat From felipe.lessa at gmail.com Sat Nov 14 14:30:40 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Nov 14 14:06:18 2009 Subject: [Haskell-cafe] Collection of sets containing no sets which are a subset of another in the collection In-Reply-To: References: <4AFE5A97.7040808@bigpond.net.au> Message-ID: <20091114193040.GA24850@kira.casa> On Sat, Nov 14, 2009 at 09:13:48AM -0500, Gwern Branwen wrote: > http://hackage.haskell.org/package/union-find ? This one is ephemeral, not persistant. -- Felipe. From felipe.lessa at gmail.com Sat Nov 14 14:31:13 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Nov 14 14:06:55 2009 Subject: [Haskell-cafe] How much time until dependencies are rebuilt in hackage? In-Reply-To: References: Message-ID: <20091114193113.GB24850@kira.casa> On Sat, Nov 14, 2009 at 01:47:04PM -0200, Maur??cio CA wrote: > Suppose package B depends on A. If a new > version of A is uploaded to hackage, how much > later package B will be rebuilt (either to show > a problem with the new version or to solve a > problem with a previous version of A)? I would guess "never", but don't quote me on that ;). -- Felipe. From jakewheatmail at googlemail.com Sat Nov 14 14:37:59 2009 From: jakewheatmail at googlemail.com (Jake Wheat) Date: Sat Nov 14 14:13:36 2009 Subject: [Haskell-cafe] ANN: hesql In-Reply-To: <87zl6rfok0.fsf@christoph-bauer.net> References: <87zl6rfok0.fsf@christoph-bauer.net> Message-ID: <4b5b53360911141137v2055f115yb314c395a4303f77@mail.gmail.com> Hello Christoph, I've been working on a SQL parser (http://hackage.haskell.org/package/hssqlppp) which might be useful for your project, although it might be a bit heavy weight (its feature scope getting more and more out of control...). Adding support for parsing ? placeholder statements is on my todo list, I could bump it up to the top if that would be useful to you. Also, have you checked out MetaHDBC (http://www.haskell.org/haskellwiki/MetaHDBC). I think it has similar goals to your project. 2009/11/13 Colin Paul Adams : > Why would hesql be an improvement for me? It sounds like several steps backwards? The last few paragraphs on this page http://lindstroem.wordpress.com/2008/09/18/metahdbc-paper-draft/ (comment dated November 4, 2008 at 9:31 pm, starting with 'Second, MetaHDBC is a thin layer above a DBMS, as compared to ...') give some reasons why an approach like this might sometimes be preferred to a haskelldb-like approach, different situations can recommend one or the other. Thanks, Jake Wheat From gwern0 at gmail.com Sat Nov 14 14:39:16 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Sat Nov 14 14:14:54 2009 Subject: [Haskell-cafe] Where is a good place to place code like this, so if I may be so bold, people can learn from it? In-Reply-To: <7pstf5t48mj65i73hs4u7fp3a4940bqpdd@4ax.com> References: <7pstf5t48mj65i73hs4u7fp3a4940bqpdd@4ax.com> Message-ID: On Sat, Nov 14, 2009 at 1:15 PM, Casey Hawthorne wrote: > Where is a good place to place code like this, so if I may be so bold, > people can learn from it? The Haskell wiki, I would suggest. If it were shorter and less Haskell-specific, then maybe also Rosetta Code (http://rosettacode.org/wiki/N-Queens#Haskell). -- gwern From pedagand at gmail.com Sat Nov 14 14:42:25 2009 From: pedagand at gmail.com (Pierre-Evariste Dagand) Date: Sat Nov 14 14:18:01 2009 Subject: [Haskell-cafe] Type-indexed expressions with fixpoint In-Reply-To: <4AFEFFED.1080007@comp.dit.ie> References: <20091110121227.1831A1727F@Adric.ern.nps.edu> <4AFEFFED.1080007@comp.dit.ie> Message-ID: <6cb897b30911141142t7f2717a8raee625afdbb80d24@mail.gmail.com> > Do you have the reference for Reynolds higher-order to first-order encoding. The reference discussed here is very likely to be: "Definitional Interpreters for Higher-Order Programming Languages" http://www.brics.dk/~hosc/local/HOSC-11-4-pp363-397.pdf You might also be interested in: "Higher-order functions considered unnecessary for higher-order programming", by Goguen http://portal.acm.org/citation.cfm?id=119842 This technique is called "defunctionalization", so you will probably find other references under that name. Regards, -- Pierre-Evariste DAGAND http://perso.eleves.bretagne.ens-cachan.fr/~dagand/ From paradoja at gmail.com Sat Nov 14 16:00:42 2009 From: paradoja at gmail.com (=?UTF-8?Q?Abby_Henr=C3=ADquez_Tejera?=) Date: Sat Nov 14 15:36:19 2009 Subject: [Haskell-cafe] Little errors in number calculations Message-ID: <82792530911141300v189555e2j7289317760190bd@mail.gmail.com> Hi. I've seen that in GHC sometimes there are little errors in some basic number calculations: *Prelude> 123.35503 * 10.0 1233.5502999999999 *Prelude> properFraction 123.35503 (123,0.3550299999999993) whereas in Hugs no such errors seem to occur (that I have found, at least): *Hugs> 123.35503 * 10.0 1233.5503 (but:) *Hugs> properFraction 123.35503 (123,0.355029999999999) I understand that error may (and will) happen in floating point, but it surprises me that they do so easily, and, above all, the difference between GHC and Hugs. Does someone know why does this difference occur? (Thanks in advance, by the way :) ). From bulat.ziganshin at gmail.com Sat Nov 14 16:07:00 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Nov 14 15:44:29 2009 Subject: [Haskell-cafe] Little errors in number calculations In-Reply-To: <82792530911141300v189555e2j7289317760190bd@mail.gmail.com> References: <82792530911141300v189555e2j7289317760190bd@mail.gmail.com> Message-ID: <393687763.20091115000700@gmail.com> Hello Abby, Sunday, November 15, 2009, 12:00:42 AM, you wrote: > I understand that error may (and will) happen in floating point, but > it surprises me that they do so easily, and, above all, the difference > between GHC and Hugs. Does someone know why does this difference > occur? compare: 0.355029999999999 0.3550299999999993 hugs just prints one less digit -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ross at soi.city.ac.uk Sat Nov 14 16:11:22 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Sat Nov 14 15:47:01 2009 Subject: [Haskell-cafe] Little errors in number calculations In-Reply-To: <82792530911141300v189555e2j7289317760190bd@mail.gmail.com> References: <82792530911141300v189555e2j7289317760190bd@mail.gmail.com> Message-ID: <20091114211122.GA18384@soi.city.ac.uk> On Sat, Nov 14, 2009 at 09:00:42PM +0000, Abby Henr?quez Tejera wrote: > I understand that error may (and will) happen in floating point, but > it surprises me that they do so easily, and, above all, the difference > between GHC and Hugs. Does someone know why does this difference > occur? The inaccuracy of floating point is the issue; it's just that Hugs sometimes prints things with less precision than required by the Haskell Report, and this can hide the errors. From mle+hs at mega-nerd.com Sat Nov 14 16:21:24 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Sat Nov 14 15:57:03 2009 Subject: [Haskell-cafe] Little errors in number calculations In-Reply-To: <82792530911141300v189555e2j7289317760190bd@mail.gmail.com> References: <82792530911141300v189555e2j7289317760190bd@mail.gmail.com> Message-ID: <20091115082124.a474727d.mle+hs@mega-nerd.com> Abby Henr?quez Tejera wrote: > I understand that error may (and will) happen in floating point, Yes, explained here: http://docs.sun.com/source/806-3568/ncg_goldberg.html > but > it surprises me that they do so easily, and, above all, the difference > between GHC and Hugs. Does someone know why does this difference > occur? It looks like the two implementations just print floating point numbers with differing amounts of precision (or rather number of digits). Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From manlio_perillo at libero.it Sat Nov 14 18:12:36 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sat Nov 14 17:48:14 2009 Subject: [Haskell-cafe] attoparsec and parsec Message-ID: <4AFF3964.7060303@libero.it> Hi. I'm writing a generic log parsing package, and I'm serching a parser combinators library. Parsing log files is a simple task, so I would like to use the more efficient solution. I have looked at attoparsec source code, and it seems very specialized for lazy bytestrings parsing, so I assume it is very efficient. How stable is the attoparsec package? How much more efficient is attoparsec than standard packages like parsec? By the way: there seem to be problems with generated documentation in http://hackage.haskell.org/package/attoparsec. Moreover, there is a similar package: http://hackage.haskell.org/package/bytestringparser what is the status of this package? It has the same API of attoparsec, but its older. However there is no indication that this package is deprecated in favor of attoparsec. Thanks Manlio Perillo From lennart at augustsson.net Sat Nov 14 20:14:34 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Sat Nov 14 19:50:10 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <562F0F92-6DCA-4070-A20F-271F4BBDE9C7@glyphic.com> References: <26311291.post@talk.nabble.com> <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> <4AFBE582.1030605@btinternet.com> <5e0214850911120244m30a2a285m4eeced410cf7d568@mail.gmail.com> <4AFC678F.5090501@btinternet.com> <3c6288ab0911121459x6429d56fm6b83257ce3c157f6@mail.gmail.com> <562F0F92-6DCA-4070-A20F-271F4BBDE9C7@glyphic.com> Message-ID: Of the two declarations > data Fizzle a = Fizzle (b -> (a, b)) a > data Fizzle a = forall b. Fizzle (b -> (a, b)) a only the second one is allowed (with some suitable extension). Personally I think the first one should be allowed as well, with the same meaning as the second one. Some people thought it was to error prone not to have any indication when an existential type is introduced, so instead we are now stuck with a somewhat confusing keyword. -- Lennart On Sat, Nov 14, 2009 at 4:55 PM, Mark Lentczner wrote: > On Nov 12, 2009, at 2:59 PM, Sean Leather wrote: >> ? foo :: forall x y. (x -> x) -> y >> ? bar :: forall y. (forall x . x -> x) -> y >> >> While neither function is seemingly useful, the second says that the higher-order argument must be polymorphic. I see two options: > > AHA! This is the bit of insight I needed! My confusion over forall was I thought that I understood that all Haskell types were as if there was a forall for all free type variables in front of the expression. For example, I think the following are the same: > > ? ? ? ?fizz :: a -> String -> [a] > ? ? ? ?fizz :: forall a. a -> String -> [a] > > So why would you need forall? The example Sean explained is that if you want to control the scope of the existential quantification. And you can only "push the scope inward", since the outer most scope basically "forall"s all the free type variables (after type inference, I suppose.) > > I also think I understand that the implicit 'forall' inherent in Haskell falls at different places in various constructs, which also had me confused. For example, while the above two function type declarations are equivalent, these two data declarations aren't: > > ? ? ? ?data Fizzle a = Fizzle (b -> (a, b)) a > ? ? ? ?data Fizzle a = forall b. Fizzle (b -> (a, b)) a > > This would be because the implicit 'forall' is essentially to the left of the 'data Fizzle a' section. I'm guessing that the same holds true for type and newtype constructs. > > Have I got this all correct? > > Would I be correct in thinking: The difference between these two is that the type b can be "fixed" upon application of amy to the first two arguments (given context), whereas bob applied to two arguments MUST return a function that is applicable to every type. > > ? ? ? ?amy :: Int -> a -> b -> [Either a b] > ? ? ? ?bob :: Int -> a -> (forall b. b) -> [Either a b] > > Thanks for helping me understand... > ? ? ? ?- Mark > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jason.dusek at gmail.com Sat Nov 14 20:16:45 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Sat Nov 14 19:52:22 2009 Subject: [Haskell-cafe] attoparsec and parsec In-Reply-To: <4AFF3964.7060303@libero.it> References: <4AFF3964.7060303@libero.it> Message-ID: <42784f260911141716if7fea35t5daef9b5acc81f@mail.gmail.com> To add to the confusion, I forked `bytestringparser` when I wrote the `json-b` package. The fork is here: http://hackage.haskell.org/package/bytestringparser-temporary/ I have added a number of things to original as well as fixing some problems with it. The reason I went with the older package is that the new one depended on stuff that wouldn't build on Hackage so I was like "whatever"; however, I now consider that it might have been better to work off the newer package. A subtle error, corrected in my version, seems yet to be present in the `attoparsec-0.7.2`, in an operator used internally to build up the result set. {-# LINE 132 "Data/Attoparsec/Internal.hs" #-} -- | Turn our split representation back into a normal lazy ByteString. (+:) :: SB.ByteString -> LB.ByteString -> LB.ByteString sb +: lb | SB.null sb = lb | otherwise = LB.Chunk sb lb Where this operator showed up in `bytestringparser`, I replaced `LB.Chunk` with the smart constructor, `LB.chunk`, to ensure that the "no empty chunks" invariant of lazy `ByteString`s was followed (I discovered this failing one evening when I was fleshing out the JSON parser). -- Jason Dusek From kapil at imsc.res.in Sat Nov 14 20:37:29 2009 From: kapil at imsc.res.in (Kapil Hari Paranjape) Date: Sat Nov 14 20:13:08 2009 Subject: [Haskell-cafe] Some help needed to start Haskell with Yi In-Reply-To: <6d2443150911141020o1d50f40by6530d0f4305c1ffb@mail.gmail.com> References: <6d2443150911141020o1d50f40by6530d0f4305c1ffb@mail.gmail.com> Message-ID: <20091115013729.GA5060@imsc.res.in> Hello, On Sat, 14 Nov 2009, Jaco van Iterson wrote: > Only installation with 'cabal install yi' in a Cygwin shell under MS Windows > XP ended in: > Yi\Prelude.hs:182:9: > Duplicate instance declarations: > instance Category Accessor.T -- Defined at Yi\Prelude.hs:182:9-38 > instance Category Accessor.T > -- Defined in data-accessor-0.2.1:Data.Accessor.Private > cabal.exe: Error: some packages failed to install: > yi-0.6.1 failed during the building phase. The exception was: > exit: ExitFailure 1 > > Seems easy to fix but I can't even find where on my drive I can find the > source code. > > Where is the source? You need to run 'cabal unpack yi' in a suitable directory. This will create a subdirectory containing the source. Enter that subdirectory, make the changes and then run 'cabal install' from that subdirectory. Regards, Kapil. -- From felipe.lessa at gmail.com Sat Nov 14 21:00:20 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Nov 14 20:35:58 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: References: <26311291.post@talk.nabble.com> <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> <4AFBE582.1030605@btinternet.com> <5e0214850911120244m30a2a285m4eeced410cf7d568@mail.gmail.com> <4AFC678F.5090501@btinternet.com> <3c6288ab0911121459x6429d56fm6b83257ce3c157f6@mail.gmail.com> <562F0F92-6DCA-4070-A20F-271F4BBDE9C7@glyphic.com> Message-ID: <20091115020019.GA15356@kira.casa> On Sun, Nov 15, 2009 at 01:14:34AM +0000, Lennart Augustsson wrote: > Of the two declarations > > data Fizzle a = Fizzle (b -> (a, b)) a > > data Fizzle a = forall b. Fizzle (b -> (a, b)) a > only the second one is allowed (with some suitable extension). > > Personally I think the first one should be allowed as well, with the > same meaning as the second one. > Some people thought it was to error prone not to have any indication > when an existential type is introduced, > so instead we are now stuck with a somewhat confusing keyword. I think you are able to say data Fizzle a where Fizzle :: (b -> (a,b)) -> a -> Fizzle a Cheers, -- Felipe. From mpm at alumni.caltech.edu Sun Nov 15 01:51:13 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Sun Nov 15 01:26:55 2009 Subject: [Haskell-cafe] help with musical data structures Message-ID: <1460.75.50.158.253.1258267873.squirrel@mail.alumni.caltech.edu> I'm pretty new to Haskell so I don't know what kind of data structure I should use for the following problem. Some kind of arrays, I guess. One data item, called OrientedPCSet ("oriented pitch class set," a musical term) will represent a set whose members are from the range of integers 0 to 11. This could probably be represented efficiently as some kind of bit field for fast comparison. Another item, PitchMatrix, will be a 2-d matrix of midi pitch numbers. This matrix will be constructed via a backtracking algortithm with an evaluation function at each step. It will probably be constructed by adding one number at a time, starting at the top of a column and working down, then moving to the next column. This matrix should probably be implemented as an array of some sort for fast lookup of the item row x, column y. It doesn't require update/modification to be as fast as lookup, and it won't get very large, so some sort of immutable array may work. Thanks, Mike From anotheraddress at gmx.de Sun Nov 15 01:51:35 2009 From: anotheraddress at gmx.de (Daniel =?gb2312?q?Sch=A8=B9ssler?=) Date: Sun Nov 15 01:27:17 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <5e0214850911130856i73ecb984t17eb7064ba7ca0cc@mail.gmail.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <5e0214850911130856i73ecb984t17eb7064ba7ca0cc@mail.gmail.com> Message-ID: <200911150751.35942.anotheraddress@gmx.de> Hi, > - Product (a,b) and co-product (Either) of monoids the coproduct of monoids is actually a bit tricky. It could be implemented like this: -- | -- Invariant 1: There are never two adjacent Lefts or two adjacent Rights -- Invariant 2: No elements (Left mempty) or (Right mempty) allowed newtype Coprod m1 m2 = C [Either m1 m2] instance (Eq m1, Eq m2, Monoid m1, Monoid m2) => Monoid (Coprod m1 m2) where mempty = C [] mappend (C x1) (C x2) = C (normalize (x1 ++ x2)) normalize [] = [] normalize (Left a0 : as) | a0 == mempty = normalize as normalize (Right a0 : as) | a0 == mempty = normalize as normalize [a] = [a] normalize (Left a0 : Left a1 : as) = Left (mappend a0 a1) : normalize as normalize (Right a0 : Right a1 : as) = Right (mappend a0 a1) : normalize as normalize (a0:as) = a0 : normalize as inl x = normalize [Left x] inr x = normalize [Right x] fold :: (Monoid m1, Monoid m2, Monoid n) => (m1 -> n) -> (m2 -> n) -> Coprod m1 m2 -> n fold k1 k2 = foldMap (either k1 k2) ------------------ Alternative version, possibly more efficient? Represent directly as fold: ------------------ newtype Coprod m1 m2 = C (forall n. Monoid n => (m1 -> n) -> (m2 -> n) -> n) instance Monoid (Coprod m1 m2) where mempty = C (\_ _ -> mempty) mappend (C x) (C x') = C (\k1 k2 -> mappend (x k1 k2) (x' k1 k2)) inl x = C (\k1 _ -> k1 x) inr x = C (\_ k2 -> k2 x) ------------------ Question: in the mappend of the second version, we have a choice: We could also, when possible, multiply on the *inside*, that is *before* applying k1/k2: ------------------- mappend (C x) (C x') = C (\k1 k2 -> x (\m1 -> x' (\m1' -> k1 (mappend m1 m1') (\m2' -> mappend (k1 m1) (k2 m2')) (\m2 -> x' (\m1' -> mappend (k2 m2) (k1 m1')) (\m2' -> k2 (mappend m2 m2'))) ------------------- Now I don't know what the efficiency implications of the two different versions are :) Apparently it depends on the relative costs of mappend in m1/m2 vs. n, and the cost of computing k1/k2? Greetings, Daniel From z_axis at 163.com Sun Nov 15 02:05:05 2009 From: z_axis at 163.com (zaxis) Date: Sun Nov 15 01:40:43 2009 Subject: [Haskell-cafe] Why can `env` be assigned value two times ? Message-ID: <26356073.post@talk.nabble.com> defineVar :: Env -> (Id, Val) -> IOThrowsError Val defineVar envRef (id, val) = do { env <- liftIO $ readIORef envRef; env <- return $ filter (\(_id, _) -> _id/=id) env; -- clear the current scope valRef <- liftIO $ newIORef val; liftIO $ writeIORef envRef $ ((id, valRef):env); return val; } In haskell, the variable canot change its value , right? If so, why can the `env` be assigned value twice? Sincerely! ----- fac n = foldr (*) 1 [1..n] -- View this message in context: http://old.nabble.com/Why-can-%60env%60-be-assigned-value-two-times---tp26356073p26356073.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From rmm-haskell at z.odi.ac Sun Nov 15 02:14:38 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Sun Nov 15 01:50:20 2009 Subject: [Haskell-cafe] Why can `env` be assigned value two times ? In-Reply-To: <26356073.post@talk.nabble.com> References: <26356073.post@talk.nabble.com> Message-ID: <6366AADA-810D-4E41-B1A1-CB474C7CF992@z.odi.ac> They're two different 'env's, which can be observed by desugaring the do-notation: do env <- liftIO (readIORef envRef) env <- return (filter (\(_id, _) -> _id /= id) env) ... Desugaring do-notation gets us: liftIO (readIORef envRev) >>= \ env -> return (filter (\(_id, _) -> _id /= id) env) >>= \ env -> ... Sometimes people use different names to make this obvious, e.g. do env <- liftIO $ readIORef envRef env' <- return (filter ... env) Also note that you're doing a pure operation here, so you don't need two bindings. You could instead do: do env <- filter (\(_id, _) -> _id /= id) <$> readIORev envRef ... (<$> is from the supremely useful Control.Applicative, and is equivalent to fmap from Functor, or liftM from Monad) or: do env <- liftIO $ readIORef envRef let env' = filter ... env Using let notation here makes it somewhat more obvious that that line doesn't have any side effects. -Ross On Nov 15, 2009, at 2:05 AM, zaxis wrote: > > defineVar :: Env -> (Id, Val) -> IOThrowsError Val > defineVar envRef (id, val) = do { > env <- liftIO $ readIORef envRef; > env <- return $ filter (\(_id, _) -> _id/=id) env; -- clear the current > scope > valRef <- liftIO $ newIORef val; > liftIO $ writeIORef envRef $ ((id, valRef):env); > return val; > } > > In haskell, the variable canot change its value , right? If so, why can the > `env` be assigned value twice? > > Sincerely! > > ----- > fac n = foldr (*) 1 [1..n] > -- > View this message in context: http://old.nabble.com/Why-can-%60env%60-be-assigned-value-two-times---tp26356073p26356073.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 From stephen.tetley at gmail.com Sun Nov 15 04:05:07 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sun Nov 15 03:40:42 2009 Subject: [Haskell-cafe] help with musical data structures In-Reply-To: <1460.75.50.158.253.1258267873.squirrel@mail.alumni.caltech.edu> References: <1460.75.50.158.253.1258267873.squirrel@mail.alumni.caltech.edu> Message-ID: <5fdc56d70911150105j1494af46i475e9d9e46578a8b@mail.gmail.com> Hello Mike A pitch class set represents Z12 numbers so I'd define a Z12 number type then store it in a list (if you have need a multiset - duplicates) or Data.Set (if you need uniqueness). Having a Z12 numeric type isn't the full story, some operations like finding prime form have easier algorithms if they are transitory - i.e. they go out of Z12 to the integers and back. You might want to look at Richard Bird's Sudoko solver for the other problem (slides and the code are a web search away) which takes a very elegant look at a matrix problem. Below is a Z12 modulo I made earlier - adding QuickCheck tests would have been wise (also I seem to remember there is a pitch class package on Hackage): -- Show instance is hand written to escape constructor noise -- It seemed useful to have mod12 as a shortcut - tastes may vary -- The Modulo12 coercion type class is a bit extraneous (fromInteger which suffice). -- I use it to allay coercion warnings in other modules module Z12 ( -- * Integers mod 12 Z12 -- * Integral coercion , Modulo12(..) , mod12 ) where -- Data types newtype Z12 = Z12 Int deriving (Eq,Ord) -------------------------------------------------------------------------------- class Modulo12 a where fromZ12 :: Z12 -> a toZ12 :: a -> Z12 instance Modulo12 Int where fromZ12 (Z12 i) = i toZ12 i = Z12 $ mod i 12 instance Modulo12 Integer where fromZ12 (Z12 i) = fromIntegral i toZ12 i = Z12 $ fromIntegral $ mod i 12 -------------------------------------------------------------------------------- instance Show Z12 where showsPrec p (Z12 i) = showsPrec p i -------------------------------------------------------------------------------- -- Num Instances liftUZ12 :: (Int -> Int) -> Z12 -> Z12 liftUZ12 op (Z12 a) = Z12 $ mod (op a) 12 liftBZ12 :: (Int -> Int -> Int) -> Z12 -> Z12 -> Z12 liftBZ12 op (Z12 a) (Z12 b) = Z12 $ mod (a `op` b) 12 instance Num Z12 where (+) = liftBZ12 (+) (-) = liftBZ12 (-) (*) = liftBZ12 (*) negate = liftUZ12 negate fromInteger i = Z12 $ (fromInteger i) `mod` 12 signum _ = error "Modular numbers are not signed" abs _ = error "Modular numbers are not signed" -------------------------------------------------------------------------------- mod12 :: Integral a => a -> a mod12 = (`mod` 12) From lemming at henning-thielemann.de Sun Nov 15 05:26:46 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Nov 15 05:02:24 2009 Subject: [Haskell-cafe] help with musical data structures In-Reply-To: <1460.75.50.158.253.1258267873.squirrel@mail.alumni.caltech.edu> References: <1460.75.50.158.253.1258267873.squirrel@mail.alumni.caltech.edu> Message-ID: On Sat, 14 Nov 2009, Michael Mossey wrote: > I'm pretty new to Haskell so I don't know what kind of data structure I > should use for the following problem. Some kind of arrays, I guess. > > One data item, called OrientedPCSet ("oriented pitch class set," a musical > term) will represent a set whose members are from the range of integers 0 > to 11. This could probably be represented efficiently as some kind of bit > field for fast comparison. In Haskore there is a type for pitch classes: http://hackage.haskell.org/packages/archive/haskore/0.1/doc/html/Haskore-Basic-Pitch.html but maybe it is not what you need, since it distinguishes between C sharp and D flat and so on. It has Ix and Ord instance and thus can be used for Array and Map, respectively. Both of them are of course not as efficient as a bitset in your case. To this end you might try http://hackage.haskell.org/packages/archive/EdisonCore/1.2.1.3/doc/html/Data-Edison-Coll-EnumSet.html > Another item, PitchMatrix, will be a 2-d matrix of midi pitch numbers. > This matrix will be constructed via a backtracking algortithm with an > evaluation function at each step. It will probably be constructed by > adding one number at a time, starting at the top of a column and working > down, then moving to the next column. This matrix should probably be > implemented as an array of some sort for fast lookup of the item row x, > column y. It doesn't require update/modification to be as fast as lookup, > and it won't get very large, so some sort of immutable array may work. A MIDI pitch type can be found in http://hackage.haskell.org/packages/archive/midi/0.1.4/doc/html/Sound-MIDI-Message-Channel-Voice.html#t%3APitch it also is in Ix class and thus you can define type PitchMatrix a = Array (Pitch, Pitch) a The Pitch pair means that you have a pair as array index, thus an two-dimensional array. Arrays provide the (//) operator for bundled updates. Sometimes it is possible to use the (//) operator or the array construction only once, because the order of filling the array is determined by data dependencies and laziness. E.g. there is an LU decomposition algorithm that does not need array element updates, only a clever order of filling the matrix: http://hackage.haskell.org/packages/archive/dsp/0.2.1/doc/html/Matrix-LU.html You may be also interested in the haskell-art mailing list in order to discuss musical experiments: http://lists.lurk.org/mailman/listinfo/haskell-art See also http://www.haskell.org/haskellwiki/Category:Music From stephen.tetley at gmail.com Sun Nov 15 05:58:35 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sun Nov 15 05:34:12 2009 Subject: [Haskell-cafe] help with musical data structures In-Reply-To: <5fdc56d70911150105j1494af46i475e9d9e46578a8b@mail.gmail.com> References: <1460.75.50.158.253.1258267873.squirrel@mail.alumni.caltech.edu> <5fdc56d70911150105j1494af46i475e9d9e46578a8b@mail.gmail.com> Message-ID: <5fdc56d70911150258w5459481bj3a1897d9a93ca080@mail.gmail.com> Postscript... Hi Mike I rather overlooked your efficiency concerns, however I wouldn't be so concerned. By the nature of what they represent I wouldn't expect pitch classes to grow to a size where a bit representation out weighs the convenience of a list or Data.Set. By the same reason - I'd only use an array for the pitch matrix if I felt an interface favouring index-lookup was most 'comfortable'. Best wishes Stephen From leather at cs.uu.nl Sun Nov 15 06:13:23 2009 From: leather at cs.uu.nl (Sean Leather) Date: Sun Nov 15 05:49:17 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <562F0F92-6DCA-4070-A20F-271F4BBDE9C7@glyphic.com> References: <26311291.post@talk.nabble.com> <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> <4AFBE582.1030605@btinternet.com> <5e0214850911120244m30a2a285m4eeced410cf7d568@mail.gmail.com> <4AFC678F.5090501@btinternet.com> <3c6288ab0911121459x6429d56fm6b83257ce3c157f6@mail.gmail.com> <562F0F92-6DCA-4070-A20F-271F4BBDE9C7@glyphic.com> Message-ID: <3c6288ab0911150313j1864c04exe046a88807a31469@mail.gmail.com> On Sat, Nov 14, 2009 at 17:55, Mark Lentczner wrote: > Would I be correct in thinking: The difference between these two is that > the type b can be "fixed" upon application of amy to the first two arguments > (given context), whereas bob applied to two arguments MUST return a function > that is applicable to every type. > > amy :: Int -> a -> b -> [Either a b] > bob :: Int -> a -> (forall b. b) -> [Either a b] Here are the same functions using fresh variables where necessary plus an additional function: amy :: forall a b. Int -> a -> b -> [Either a b] bob :: forall a b. Int -> a -> (forall c. c) -> [Either a b] cat :: forall a . Int -> a -> (forall b. b -> [Either a b]) First, note that the types of amy and cat are equivalent. Since function arrows are right-associative and since there are no conflicting variables b outside the scope of forall b, the quantification can easily be pushed to the outside as in amy. (I don't know if cat is what you meant to have for bob, so I thought I'd add it just in case.) As for bob, the only third argument it can take is bottom (undefined or error). And that argument has no effect on the types instantiated for a or b. (Using a fresh variable c helps make that more evident at a glance.) Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091115/05cf0d53/attachment.html From stephen.tetley at gmail.com Sun Nov 15 06:55:28 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sun Nov 15 06:31:03 2009 Subject: [Haskell-cafe] help with musical data structures In-Reply-To: References: <1460.75.50.158.253.1258267873.squirrel@mail.alumni.caltech.edu> Message-ID: <5fdc56d70911150355i454adb59j70847743210f55c8@mail.gmail.com> 2009/11/15 Henning Thielemann : > In Haskore there is a type for pitch classes: > > http://hackage.haskell.org/packages/archive/haskore/0.1/doc/html/Haskore-Basic-Pitch.html > ?but maybe it is not what you need, since it distinguishes between C sharp > and D flat and so on. Hi Henning The enharmonic doublings and existing Ord instance make Haskore's PitchClass a tricky proposition for representing the Serialist's view of pitch classes. An integer (or Z12) represent would be simpler. To get pitch names I would recover them with a post-processing step, spelling pitches with respect to a "scale" (here a SpellingMap): > spell :: SpellingMap -> Pitch -> Pitch The spell function returns the note in the scale (SpellingMap) if present, otherwise it returns the original to be printed with an accidental. I have my own pitch representation, but a SpellingMap for Haskore would be > type SpellingMap = Data.Map PitchClass PitchClass Scales here are functions that generate SpellingMaps rather than objects themselves. The modes and major and minor scales have easy generation as they are someways rotational over the circle of fifths (I've have implemented a useful algorithm for this but can't readily describe it[1]). Hijaz and klezmer fans need to construct their spelling maps by hand. Best wishes Stephen [1] Code exists here - vis dependencies and scant documentation that stop it being useful: http://code.google.com/p/copperbox/source/browse/trunk/bala/Mullein/src/Mullein/Pitch.hs From alexey.skladnoy at gmail.com Sun Nov 15 07:00:34 2009 From: alexey.skladnoy at gmail.com (Alexey Khudyakov) Date: Sun Nov 15 06:36:09 2009 Subject: [Haskell-cafe] poor perfomance of indexU in uvector package Message-ID: <8425cc0e0911150400i38b5935cs16a54cf5e72bc84f@mail.gmail.com> Hello This post meant to be literate haskell. I found that perfomace of indexU is very poor and it is not fast O(1) operation which is very surprising. Here is some benchmarcking I've done. Everything compiled with -O2 Code below converts square 2D array to list of 1D arrays. Summation of array contents is done in force evaluation > import Control.Monad > import Control.Monad.ST > import Data.Array.Vector > import System > > arr :: Int -> UArr Double > arr n = toU $ map fromIntegral [1 .. n*n] > This is fastest function. It slice arrays along another direction and used mainly as upper bound of speed > sliceY :: Int -> UArr Double -> [UArr Double] > sliceY n a = map (\i -> sliceU a (i*n) n) [0 .. n-1] > Naive implementation using lists and index lookup. 2.15 second for 200*200 array > sliceXlist :: Int -> UArr Double -> [UArr Double] > sliceXlist n a = map mkSlice [0 .. n-1] > where > mkSlice x = toU $ map (\y -> indexU a (x + y*n)) [0 .. n-1] Similar implementation in ST monad and it uses indexU too. 2.14 seconds for 200*200 array > sliceXst :: Int -> UArr Double -> [UArr Double] > sliceXst n a = map mkSlice [0 .. n-1] > where > mkSlice x = runST $ do arr <- newMU n > forM_ [0 .. n-1] $ \y -> writeMU arr y (indexU a (y*n + x)) > unsafeFreezeAllMU arr This implementation avoids use of indexU by copying entire 2D array into mutable array and using it for lookup. Surprisingly it outperform previsious implementations for sufficiently big n 1.19 seconds for 200*200 array > sliceXcopy :: Int -> UArr Double -> [UArr Double] > sliceXcopy n a = map mkSlice [0 .. n-1] > where > mkSlice x = runST $ do arr <- newMU n > cp <- newMU (n*n) > copyMU cp 0 a > forM_ [0 .. n-1] $ \y -> writeMU arr y =<< readMU cp (y*n + x) > unsafeFreezeAllMU arr This is another implementation with lists which convert whole array to list and picks appropriate element it. It is fastest implementation so far. 0.039 seconds for 200*200 array > sliceXlistfast :: Int -> UArr Double -> [UArr Double] > sliceXlistfast n a = map mkSlice [0 .. n-1] > where > takeEvery n [] = [] > takeEvery n (x:xs) = x : takeEvery n (drop (n-1) xs) > mkSlice x = toU $ takeEvery n . drop x $ fromU a > > > ---------------------------------------------------------------- > main :: IO () > main = do > [str,a] <- getArgs > let n = read str > case a of > "y" -> print $ sum $ map sumU (sliceY n (arr n)) > "list" -> print $ sum $ map sumU (sliceXlist n (arr n)) > "lf" -> print $ sum $ map sumU (sliceXlistfast n (arr n)) > "st" -> print $ sum $ map sumU (sliceXst n (arr n)) > "copy" -> print $ sum $ map sumU (sliceXcopy n (arr n)) From nicolas.pouillard at gmail.com Sun Nov 15 07:05:08 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Sun Nov 15 06:40:42 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <200911150751.35942.anotheraddress@gmx.de> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <5e0214850911130856i73ecb984t17eb7064ba7ca0cc@mail.gmail.com> <200911150751.35942.anotheraddress@gmx.de> Message-ID: <1258286496-sup-1347@peray> Excerpts from Daniel Sch?ssler's message of Sun Nov 15 07:51:35 +0100 2009: > Hi, Hi, > -- Invariant 1: There are never two adjacent Lefts or two adjacent Rights [...] > normalize (Left a0 : Left a1 : as) = Left (mappend a0 a1) : normalize as > normalize (Right a0 : Right a1 : as) = Right (mappend a0 a1) : normalize as If you want to preserve your invariant, I think you should do : normalize (Left a0 : Left a1 : as) = normalize (Left (mappend a0 a1) : as) normalize (Right a0 : Right a1 : as) = normalize (Right (mappend a0 a1) : as) However, maybe it is correct if you only call normalize on (xs ++ ys) where xs and ys are already normalized so that you have only one point where you can break this invariant. Regards, -- Nicolas Pouillard http://nicolaspouillard.fr From manlio_perillo at libero.it Sun Nov 15 08:19:37 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Nov 15 07:55:16 2009 Subject: [Haskell-cafe] attoparsec and parsec In-Reply-To: <42784f260911141716if7fea35t5daef9b5acc81f@mail.gmail.com> References: <4AFF3964.7060303@libero.it> <42784f260911141716if7fea35t5daef9b5acc81f@mail.gmail.com> Message-ID: <4AFFFFE9.7020306@libero.it> Jason Dusek ha scritto: > To add to the confusion, I forked `bytestringparser` when I > wrote the `json-b` package. The fork is here: > > http://hackage.haskell.org/package/bytestringparser-temporary/ > > I have added a number of things to original as well as fixing > some problems with it. > > The reason I went with the older package is that the new one > depended on stuff that wouldn't build on Hackage I installed attoparsec yesterday without problems. > so I was like > "whatever"; however, I now consider that it might have been > better to work off the newer package. > > A subtle error, corrected in my version, seems yet to be > present in the `attoparsec-0.7.2`, in an operator used > internally to build up the result set. > > {-# LINE 132 "Data/Attoparsec/Internal.hs" #-} > -- | Turn our split representation back into a normal lazy ByteString. > (+:) :: SB.ByteString -> LB.ByteString -> LB.ByteString > sb +: lb | SB.null sb = lb > | otherwise = LB.Chunk sb lb > > Where this operator showed up in `bytestringparser`, I > replaced `LB.Chunk` with the smart constructor, `LB.chunk`, to > ensure that the "no empty chunks" invariant of lazy > `ByteString`s was followed (I discovered this failing one > evening when I was fleshing out the JSON parser). > Did you try to contact the author/maintainer? This test can be added to the test suite. Thanks Manlio From anotheraddress at gmx.de Sun Nov 15 09:10:38 2009 From: anotheraddress at gmx.de (Daniel =?utf-8?q?Sch=C3=BCssler?=) Date: Sun Nov 15 08:46:14 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <1258286496-sup-1347@peray> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <200911150751.35942.anotheraddress@gmx.de> <1258286496-sup-1347@peray> Message-ID: <200911151510.38621.anotheraddress@gmx.de> On Sunday 15 November 2009 13:05:08 Nicolas Pouillard wrote: > Excerpts from Daniel Sch?ssler's message of Sun Nov 15 07:51:35 +0100 2009: > > Hi, > > Hi, Hi, > > > -- Invariant 1: There are never two adjacent Lefts or two adjacent Rights > > [...] > > > normalize (Left a0 : Left a1 : as) = Left (mappend a0 a1) : normalize as > > normalize (Right a0 : Right a1 : as) = Right (mappend a0 a1) : normalize > > as > > If you want to preserve your invariant, I think you should do : > > normalize (Left a0 : Left a1 : as) = normalize (Left (mappend a0 a1) : > as) normalize (Right a0 : Right a1 : as) = normalize (Right (mappend a0 > a1) : as) > > However, maybe it is correct if you only call normalize on (xs ++ ys) where > xs and ys are already normalized so that you have only one point where you > can break this invariant. > > Regards, > You are right :) If `normalize' is meant to normalize arbitrary lists, we'd have to use your version. If OTOH we just want to normalize xs ++ ys, we shouldn't iterate over the whole list; it'd be better to use Data.Sequence and just consider the middle, as you said (I was thinking of free groups, where there can be more collapse, but in that case we'd need the analogue your version too). Greetings, Daniel From mpm at alumni.caltech.edu Sun Nov 15 09:20:21 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Sun Nov 15 08:55:57 2009 Subject: [Haskell-cafe] help with musical data structures In-Reply-To: <5fdc56d70911150258w5459481bj3a1897d9a93ca080@mail.gmail.com> References: <1460.75.50.158.253.1258267873.squirrel@mail.alumni.caltech.edu> <5fdc56d70911150105j1494af46i475e9d9e46578a8b@mail.gmail.com> <5fdc56d70911150258w5459481bj3a1897d9a93ca080@mail.gmail.com> Message-ID: <4B000E25.5000807@alumni.caltech.edu> Hi Stephen, I will need a function that computes prime (normal?) form, of course, and it is just begging to be memoized. I wonder if that is possible with Data.Set, or whether it would be much faster using the bit vector representation? Thanks, Mike Stephen Tetley wrote: > Postscript... > > Hi Mike > > I rather overlooked your efficiency concerns, however I wouldn't be so > concerned. By the nature of what they represent I wouldn't expect > pitch classes to grow to a size where a bit representation out weighs > the convenience of a list or Data.Set. > > By the same reason - I'd only use an array for the pitch matrix if I > felt an interface favouring index-lookup was most 'comfortable'. > > > > Best wishes > > Stephen > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From felipe.lessa at gmail.com Sun Nov 15 09:50:48 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sun Nov 15 09:26:24 2009 Subject: [Haskell-cafe] poor perfomance of indexU in uvector package In-Reply-To: <8425cc0e0911150400i38b5935cs16a54cf5e72bc84f@mail.gmail.com> References: <8425cc0e0911150400i38b5935cs16a54cf5e72bc84f@mail.gmail.com> Message-ID: <20091115145048.GA20940@kira.casa> On Sun, Nov 15, 2009 at 03:00:34PM +0300, Alexey Khudyakov wrote: > Naive implementation using lists and index lookup. > 2.15 second for 200*200 array > > sliceXlist :: Int -> UArr Double -> [UArr Double] > > sliceXlist n a = map mkSlice [0 .. n-1] > > where > > mkSlice x = toU $ map (\y -> indexU a (x + y*n)) [0 .. n-1] Have you tried something like mkSlice x = mapU (\y -> indexU a (x + y*n)) $ enumFromToU 0 (n-1) I guess it should be a lot faster :). Also, I would recomend using criterion. Another implementation you may try is a' = mapU (\(i :*: x) -> (i `mod` n) :*: x) (indexedU a) mkSlice j = fstU $ filterU (\(i :*: x) -> i == j) a' HTH, -- Felipe. From colin at colina.demon.co.uk Sun Nov 15 10:15:43 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sun Nov 15 09:51:22 2009 Subject: [Haskell-cafe] Trouble installing HDBC 2.1.1 with ghc 6.10.4 Message-ID: I'm seeing messages such as: Database/HDBC/SqlValue.hs:610:32: No instance for (Typeable Day) .... Is this connected with the in-and-out status of the time library in the GHC 6.10.x series? Is there a work-around? -- Colin Adams Preston Lancashire From alexey.skladnoy at gmail.com Sun Nov 15 10:16:03 2009 From: alexey.skladnoy at gmail.com (Alexey Khudyakov) Date: Sun Nov 15 09:51:39 2009 Subject: [Haskell-cafe] poor perfomance of indexU in uvector package In-Reply-To: <20091115145048.GA20940@kira.casa> References: <8425cc0e0911150400i38b5935cs16a54cf5e72bc84f@mail.gmail.com> <20091115145048.GA20940@kira.casa> Message-ID: <8425cc0e0911150716l795f2bady2eff26c1af5a8c15@mail.gmail.com> On Sun, Nov 15, 2009 at 5:50 PM, Felipe Lessa wrote: > On Sun, Nov 15, 2009 at 03:00:34PM +0300, Alexey Khudyakov wrote: >> Naive implementation using lists and index lookup. >> 2.15 second for 200*200 array >> > sliceXlist :: Int -> UArr Double -> [UArr Double] >> > sliceXlist n a = map mkSlice [0 .. n-1] >> > where >> > mkSlice x = toU $ map (\y -> indexU a (x + y*n)) [0 .. n-1] > > Have you tried something like > > mkSlice x = mapU (\y -> indexU a (x + y*n)) $ enumFromToU 0 (n-1) > > I guess it should be a lot faster :). No it doesn't. There is no significant difference between two variant above. I think any program which uses indexU will be slowed to crawl. Seems like a bug for me. > Another implementation you may try is > > a' = mapU (\(i :*: x) -> (i `mod` n) :*: x) (indexedU a) > mkSlice j = fstU $ filterU (\(i :*: x) -> i == j) a' > This one is fastest so far > Also, I would recomend using criterion. I tried to do so.. But it depends on gtk2hs and it is too difficult to install From nonowarn at gmail.com Sun Nov 15 10:37:34 2009 From: nonowarn at gmail.com (Yusaku Hashimoto) Date: Sun Nov 15 10:13:08 2009 Subject: [Haskell-cafe] poor perfomance of indexU in uvector package In-Reply-To: <8425cc0e0911150716l795f2bady2eff26c1af5a8c15@mail.gmail.com> References: <8425cc0e0911150400i38b5935cs16a54cf5e72bc84f@mail.gmail.com> <20091115145048.GA20940@kira.casa> <8425cc0e0911150716l795f2bady2eff26c1af5a8c15@mail.gmail.com> Message-ID: >> Also, I would recomend using criterion. > > I tried to do so.. But it depends on gtk2hs and it is too difficult > to install You can install with the flag to skip gtk2hs installation. i.e. Try `cabal install criterion -f-chart` -~nwn From stephen.tetley at gmail.com Sun Nov 15 11:40:10 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sun Nov 15 11:15:46 2009 Subject: [Haskell-cafe] help with musical data structures In-Reply-To: <4B000E25.5000807@alumni.caltech.edu> References: <1460.75.50.158.253.1258267873.squirrel@mail.alumni.caltech.edu> <5fdc56d70911150105j1494af46i475e9d9e46578a8b@mail.gmail.com> <5fdc56d70911150258w5459481bj3a1897d9a93ca080@mail.gmail.com> <4B000E25.5000807@alumni.caltech.edu> Message-ID: <5fdc56d70911150840h756bc033ucce17a4ebccdaf8b@mail.gmail.com> Hi Mike Try it and time it of course - there are a couple of libraries to help memo-izing on Hackage. Never having used them, but looking at the docs neither data-memocombinators or MemoTrie would seem to be straightforward for Data.Set, so a Word32 or some other number that is an instance of Bits would be a better choice. My completely unfounded intuition is what you would gain by memoization you would loose by packing and unpacking the bit representation to something that can be read, printed or whatever else you need to do with it. The only algorithm I've transcribed for finding prime form is the one detailed by Paul Nelson here: http://composertools.com/Theory/PCSets.pdf This one goes out of Z12 at step 2 but if you were using a 24bit bit vector (e.g. Word32) it would still cope. Best wishes Stephen 2009/11/15 Michael Mossey : > Hi Stephen, > > I will need a function that computes prime (normal?) form, of course, and it > is just begging to be memoized. I wonder if that is possible with Data.Set, > or whether it would be much faster using the bit vector representation? > > Thanks, > Mike > > From dons at galois.com Sun Nov 15 12:59:49 2009 From: dons at galois.com (Don Stewart) Date: Sun Nov 15 12:35:25 2009 Subject: [Haskell-cafe] poor perfomance of indexU in uvector package In-Reply-To: <8425cc0e0911150400i38b5935cs16a54cf5e72bc84f@mail.gmail.com> References: <8425cc0e0911150400i38b5935cs16a54cf5e72bc84f@mail.gmail.com> Message-ID: <20091115175949.GE21777@whirlpool.galois.com> alexey.skladnoy: > Hello > > This post meant to be literate haskell. > > I found that perfomace of indexU is very poor and it is not fast O(1) > operation which is very surprising. Here is some benchmarcking I've > done. Everything compiled with -O2 > You're using the streamed version when its not fusing. Use the non-streaming direct implementation exported from Data.Array.Vector.UArr This is really an API bug, but I've not had time to sanitize the use. From ekirpichov at gmail.com Sun Nov 15 13:04:28 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sun Nov 15 12:40:02 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <200911151510.38621.anotheraddress@gmx.de> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <200911150751.35942.anotheraddress@gmx.de> <1258286496-sup-1347@peray> <200911151510.38621.anotheraddress@gmx.de> Message-ID: <5e0214850911151004i69dcfb5cp232d671d04ab0733@mail.gmail.com> Hey, I've found terrific slides about monoids! http://comonad.com/reader/wp-content/uploads/2009/08/IntroductionToMonoids.pdf Edward Kmett, you rock! There's more http://comonad.com/reader/2009/iteratees-parsec-and-monoid/ - but the second part was too hard for me to read it fully without special motivation. 2009/11/15 Daniel Sch?ssler : > On Sunday 15 November 2009 13:05:08 Nicolas Pouillard wrote: >> Excerpts from Daniel Sch?ssler's message of Sun Nov 15 07:51:35 +0100 2009: >> > Hi, >> >> Hi, > > Hi, > >> >> > -- Invariant 1: There are never two adjacent Lefts or two adjacent Rights >> >> [...] >> >> > normalize (Left a0 : Left a1 : as) = Left (mappend a0 a1) : normalize as >> > normalize (Right a0 : Right a1 : as) = Right (mappend a0 a1) : normalize >> > as >> >> If you want to preserve your invariant, I think you should do : >> >> normalize (Left ?a0 : Left ?a1 : as) = normalize (Left ?(mappend a0 a1) : >> ?as) normalize (Right a0 : Right a1 : as) = normalize (Right (mappend a0 >> ?a1) : as) >> >> However, maybe it is correct if you only call normalize on (xs ++ ys) where >> xs and ys are already normalized so that you have only one point where you >> ?can break this invariant. >> >> Regards, >> > > You are right :) If `normalize' is meant to normalize arbitrary lists, we'd > have to use your version. If OTOH we just want to normalize xs ++ ys, we > shouldn't iterate over the whole list; it'd be better to use Data.Sequence and > just consider the middle, as you said (I was thinking of free groups, where > there can be more collapse, but in that case we'd need the analogue your > version too). > > > Greetings, > Daniel > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From felipe.lessa at gmail.com Sun Nov 15 13:05:43 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sun Nov 15 12:41:18 2009 Subject: [Haskell-cafe] poor perfomance of indexU in uvector package In-Reply-To: <8425cc0e0911150716l795f2bady2eff26c1af5a8c15@mail.gmail.com> References: <8425cc0e0911150400i38b5935cs16a54cf5e72bc84f@mail.gmail.com> <20091115145048.GA20940@kira.casa> <8425cc0e0911150716l795f2bady2eff26c1af5a8c15@mail.gmail.com> Message-ID: <20091115180543.GA30379@kira.casa> On Sun, Nov 15, 2009 at 06:16:03PM +0300, Alexey Khudyakov wrote: > > Another implementation you may try is > > > > a' = mapU (\(i :*: x) -> (i `mod` n) :*: x) (indexedU a) > > mkSlice j = fstU $ filterU (\(i :*: x) -> i == j) a' > > > > This one is fastest so far Nice! Just for the record, of course I meant 'sndU' :). Thanks god Haskell is statically typed and that error should be caught rather easily. -- Felipe. From thomas.dubuisson at gmail.com Sun Nov 15 13:11:11 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Sun Nov 15 12:46:44 2009 Subject: [Haskell-cafe] poor perfomance of indexU in uvector package In-Reply-To: <8425cc0e0911150400i38b5935cs16a54cf5e72bc84f@mail.gmail.com> References: <8425cc0e0911150400i38b5935cs16a54cf5e72bc84f@mail.gmail.com> Message-ID: <4c44d90b0911151011j1c0fa7c4t95559d52ede3eba1@mail.gmail.com> The documentation explicitly says indexU is O(n) - no need for so much testing to rediscover that fact. When I needed a contiguous block of values in UArr, I just relied on sliceU to acquire the block and performed a foldU. Thomas On Sun, Nov 15, 2009 at 4:00 AM, Alexey Khudyakov wrote: > Hello > > This post meant to be literate haskell. > > I found that perfomace of indexU is very poor and it is not fast O(1) > operation which is very surprising. Here is some benchmarcking I've > done. Everything compiled with -O2 > > Code below converts square 2D array to list of 1D arrays. Summation of > array contents is done in force evaluation > >> import Control.Monad >> import Control.Monad.ST >> import Data.Array.Vector >> import System >> >> arr :: Int -> UArr Double >> arr n = toU $ map fromIntegral [1 .. n*n] >> > > This is fastest function. It slice arrays along another direction and used > mainly as upper bound of speed >> sliceY :: Int -> ?UArr Double -> [UArr Double] >> sliceY n a = map (\i -> sliceU a (i*n) n) [0 .. n-1] >> > > Naive implementation using lists and index lookup. > ?2.15 second for 200*200 array >> sliceXlist :: Int -> UArr Double -> [UArr Double] >> sliceXlist n a = map mkSlice [0 .. n-1] >> ? ? where >> ? ? ? mkSlice x = toU $ map (\y -> indexU a (x + y*n)) [0 .. n-1] > > Similar implementation in ST monad and it uses indexU too. > ?2.14 seconds for 200*200 array >> sliceXst :: Int -> ? UArr Double -> [UArr Double] >> sliceXst n a = map mkSlice [0 .. n-1] >> ? ? where >> ? ? ? mkSlice x = runST $ do arr <- newMU n >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?forM_ [0 .. n-1] $ \y -> writeMU arr y (indexU a (y*n + x)) >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsafeFreezeAllMU arr > > This implementation avoids use of indexU by copying entire > 2D array into mutable array and using it for lookup. Surprisingly > it outperform previsious implementations for sufficiently big n > ?1.19 seconds for 200*200 array >> sliceXcopy :: Int -> ?UArr Double -> [UArr Double] >> sliceXcopy n a = map mkSlice [0 .. n-1] >> ? ? where >> ? ? ? mkSlice x = runST $ do arr <- newMU n >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?cp ?<- newMU (n*n) >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?copyMU cp 0 a >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?forM_ [0 .. n-1] $ \y -> writeMU arr y =<< readMU cp (y*n + x) >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsafeFreezeAllMU arr > > This is another ?implementation with lists which convert whole > array to list and picks appropriate element it. It is fastest implementation > so far. > 0.039 seconds for 200*200 array >> sliceXlistfast :: Int -> UArr Double -> [UArr Double] >> sliceXlistfast n a = map mkSlice [0 .. n-1] >> ? ? where >> ? ? ? takeEvery n [] ? ? = [] >> ? ? ? takeEvery n (x:xs) = x : takeEvery n (drop (n-1) xs) >> ? ? ? mkSlice x = toU $ takeEvery n . drop x $ fromU a >> > > >> >> ---------------------------------------------------------------- >> main :: IO () >> main = do >> ? [str,a] <- getArgs >> ? let n = read str >> ? case a of >> ? ? ? "y" ? ?-> print $ sum $ map sumU (sliceY ? ? n (arr n)) >> ? ? ? "list" -> print $ sum $ map sumU (sliceXlist n (arr n)) >> ? ? ? "lf" ? -> print $ sum $ map sumU (sliceXlistfast n (arr n)) >> ? ? ? "st" ? -> print $ sum $ map sumU (sliceXst ? n (arr n)) >> ? ? ? "copy" -> print $ sum $ map sumU (sliceXcopy n (arr n)) > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dpiponi at gmail.com Sun Nov 15 13:32:43 2009 From: dpiponi at gmail.com (Dan Piponi) Date: Sun Nov 15 13:08:16 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <200911150751.35942.anotheraddress@gmx.de> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <5e0214850911130856i73ecb984t17eb7064ba7ca0cc@mail.gmail.com> <200911150751.35942.anotheraddress@gmx.de> Message-ID: <625b74080911151032j41a24e1dsa8e6d63660335508@mail.gmail.com> 2009/11/14 Daniel Sch?ssler : >> ?- Product (a,b) and co-product (Either) of monoids > the coproduct of monoids is actually a bit tricky. Funny, I was just thinking about that. I was pondering the article at LTU on Lawvere theories: http://lambda-the-ultimate.org/node/3235 Essentially the idea is this: monads correspond to algebraic theories and monad transformers are ways to combine algebraic theories. But Lawvere theories provide another way to describe algebraic theories, and hence the things that monads can help with: like side effects, state and non-determinism. The advantage of Lawvere theories is there is some nice mathematics for how to combine them, something that's lacking from monads. So I just worked through a simple example: combining the Writer monad with itself. As Lawvere theories there are two ways to combine them: the product and the sum. The product corresponds, I think, to the usual monad transformer. This gives the Writer monad corresponding to the product of monoids. But the sum gives the Writer monad for the coproduct of monoids. (I think this is correct, but I'm not 100% sure I totally get Lawvere theories yet.) If you think about it, it's a very natural thing to do. If you think of the Writer monad as being useful to make logs then the coproduct allows you to interleave two different kinds of logs keeping the relative order of the entries. The usual monad transformer keeps two separate logs and so loses the relative ordering information. So it's actually something you might frequently want in real world code. But I can't imagine a monad transformer for Writer that would give the coproduct when combined with another Writer, so I don't think it could be implemented as such. -- Dan From haberg at math.su.se Sun Nov 15 13:52:09 2009 From: haberg at math.su.se (Hans Aberg) Date: Sun Nov 15 13:28:19 2009 Subject: [Haskell-cafe] help with musical data structures In-Reply-To: <5fdc56d70911150355i454adb59j70847743210f55c8@mail.gmail.com> References: <1460.75.50.158.253.1258267873.squirrel@mail.alumni.caltech.edu> <5fdc56d70911150355i454adb59j70847743210f55c8@mail.gmail.com> Message-ID: <324AF94B-DEA8-40FE-8F21-27C8A8A61415@math.su.se> On 15 Nov 2009, at 12:55, Stephen Tetley wrote: >> http://hackage.haskell.org/packages/archive/haskore/0.1/doc/html/Haskore-Basic-Pitch.html >> but maybe it is not what you need, since it distinguishes between >> C sharp >> and D flat and so on. > The enharmonic doublings and existing Ord instance make Haskore's > PitchClass a tricky proposition for representing the Serialist's view > of pitch classes. An integer (or Z12) represent would be simpler. A Z12 representation is really only suitable for serial music, which in effect uses 12 scale degrees per octave. > To get pitch names I would recover them with a post-processing step, > spelling pitches with respect to a "scale" (here a SpellingMap): > >> spell :: SpellingMap -> Pitch -> Pitch > > The spell function returns the note in the scale (SpellingMap) if > present, otherwise it returns the original to be printed with an > accidental. > > I have my own pitch representation, but a SpellingMap for Haskore > would be > >> type SpellingMap = Data.Map PitchClass PitchClass > > Scales here are functions that generate SpellingMaps rather than > objects themselves. > The modes and major and minor scales have easy generation as they are > someways rotational over the circle of fifths (I've have implemented a > useful algorithm for this but can't readily describe it[1]). Hijaz and > klezmer fans need to construct their spelling maps by hand. The pitch and notation systems that Western music uses can be described as generated by a minor second m and major second M. Sharps and flats alter with the interval M - m. If departing from two independent intervals, like a perfect fifth and the octave, then m and M can be computed. - I have written some code for ChucK which does that and makes them playable on the (typing) keyboard in a two- dimensional layout. The pitch system, which I call a "diatonic pitch system", is then the set of combinations p m + q M, where p, q are integers (relative a tuning frequency). The sum d = p + q acts a scale degree of the pitch system. Sharps and flats do not alter this scale degree. Typical common 7 note scales have adjacent scale degrees. This is also true for scales like hijaz. The note name can then be computed as follows: First one needs (p, q) values representing the note names a b c d e f g having scale degrees 0, ..., 6, plus a value for the octave. If given an arbitrary combination (p, q), first reduce its octave, and then compute its scale degree; subtract the (p, q) value of the note name with the same scale degree. There results a note with p + q = 0, i.e., p = - q. If q > 0, it is is the number of sharps, if p > 0 it is the number of flats. This method can be generalized. It is not necessary to have 7 notes per diapason, and the diapason need not be the octave. By adding neutral seconds, one can describe more general pitch systems (one is enough for Arab, Persian and Turkish scales). Hans From lennart at augustsson.net Sun Nov 15 14:05:35 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Sun Nov 15 13:41:10 2009 Subject: [Haskell-cafe] Little errors in number calculations In-Reply-To: <82792530911141300v189555e2j7289317760190bd@mail.gmail.com> References: <82792530911141300v189555e2j7289317760190bd@mail.gmail.com> Message-ID: Hugs is wrong, as you can easily see by evaluating let x = 123.35503 * 10.0 in x == read (show x) With ghc it comes out as True and with Hugs as False. -- Lennart On Sat, Nov 14, 2009 at 9:00 PM, Abby Henr?quez Tejera wrote: > Hi. > > I've seen that in GHC sometimes there are little errors in some basic > number calculations: > > *Prelude> 123.35503 * 10.0 > 1233.5502999999999 > > *Prelude> properFraction 123.35503 > (123,0.3550299999999993) > > whereas in Hugs no such errors seem to occur (that I have found, at > least): > > *Hugs> 123.35503 * 10.0 > 1233.5503 > > (but:) > > *Hugs> properFraction 123.35503 > (123,0.355029999999999) > > I understand that error may (and will) happen in floating point, but > it surprises me that they do so easily, and, above all, the difference > between GHC and Hugs. Does someone know why does this difference > occur? > > (Thanks in advance, by the way :) ). > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ck_kashyap at yahoo.com Sun Nov 15 14:21:36 2009 From: ck_kashyap at yahoo.com (CK Kashyap) Date: Sun Nov 15 13:57:11 2009 Subject: [Haskell-cafe] DSL in Haskell Message-ID: <34696.21589.qm@web112513.mail.gq1.yahoo.com> Hi All, I was reading a Ruby book and in that it was mentioned that its capability to dynamically query and modify classes makes it suitable for implementing DSL's ... I am referring to Ruby's reflection and methods like "method_missing" here. It can allow things like not having to define constants for all possible unicode code points etc...For example, first use of U0123 could bring such a constant definition into existence etc I see multiple search hits when I look for Haskell and DSL - can someone please point me to a good primer or explain to me how equivalent of above mentioned features in Ruby can be done in Haskell ... or the Haskell alternative for it. Regards, Kashyap -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091115/31a63e67/attachment.html From dons at galois.com Sun Nov 15 14:27:54 2009 From: dons at galois.com (Don Stewart) Date: Sun Nov 15 14:03:30 2009 Subject: [Haskell-cafe] DSL in Haskell In-Reply-To: <34696.21589.qm@web112513.mail.gq1.yahoo.com> References: <34696.21589.qm@web112513.mail.gq1.yahoo.com> Message-ID: <20091115192754.GB21944@whirlpool.galois.com> ck_kashyap: > Hi All, > I was reading a Ruby book and in that it was mentioned that its capability to > dynamically query and modify classes makes it suitable for implementing DSL's > ... I am referring to Ruby's reflection and methods like "method_missing" here. > It can allow things like not having to define constants for all possible > unicode code points etc...For example, first use of U0123 could bring such a > constant definition into existence etc > > I see multiple search hits when I look for Haskell and DSL - can someone please > point me to a good primer or explain to me how equivalent of above mentioned > features in Ruby can be done in Haskell ... or the Haskell alternative for it. The Haskell equivalent would be overloading, primarily via type classes. See Lennart Augusston's BASIC for an example of this in the extreme: http://augustss.blogspot.com/2009/02/more-basic-not-that-anybody-should-care.html That's BASIC syntax, in Haskell, relying on overloading numbers, strings etc. And all statically typed. For a survey of some of the more recent EDSLs in Haskell, see this brief overview, http://www.galois.com/~dons/papers/stewart-2009-edsls.pdf -- Don From caseyh at istar.ca Sun Nov 15 14:47:00 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Sun Nov 15 14:22:25 2009 Subject: [Haskell-cafe] I'm also missing examples of library function and Hackage usage. Haskell Wiki? Message-ID: I'm also missing examples of library function and Hackage usage. Where does one put up code on the Haskell Wiki? :) -- Regards, Casey From mpm at alumni.caltech.edu Sun Nov 15 15:54:11 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Sun Nov 15 15:29:49 2009 Subject: [Haskell-cafe] O(n) algorithm for determining subset Message-ID: <26690.208.57.251.240.1258318451.squirrel@mail.alumni.caltech.edu> Can someone tell me if this is correct. I'm guessing that if I represent two sets of integers by Word32 (where ith bit set means i is in the set), then an algorithm to determine if x is a subset of y would go something like (y - x) == (y `exclusiveOr` x) From ketil at malde.org Sun Nov 15 16:03:26 2009 From: ketil at malde.org (Ketil Malde) Date: Sun Nov 15 15:38:42 2009 Subject: [Haskell-cafe] Some thoughts about Hackage In-Reply-To: <8feb08f70911140259y363b14a0i7ea3beb770662eb7@mail.gmail.com> (Vasyl Pasternak's message of "Sat, 14 Nov 2009 12:59:48 +0200") References: <8feb08f70911140259y363b14a0i7ea3beb770662eb7@mail.gmail.com> Message-ID: <878we7xzz5.fsf@malde.org> I completely agree that some way of measuring the potential usefulness of packages would be great. To some extent, you can get a measure of the popularity of various packages in Debian (and probably other Linux distributions have similar systems). E.g. http://qa.debian.org/popcon.php?package=ghc6 Not too many libraries yet, though. -k -- If I haven't seen further, it is by standing in the footprints of giants From ekirpichov at gmail.com Sun Nov 15 16:03:54 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sun Nov 15 15:39:29 2009 Subject: [Haskell-cafe] O(n) algorithm for determining subset In-Reply-To: <26690.208.57.251.240.1258318451.squirrel@mail.alumni.caltech.edu> References: <26690.208.57.251.240.1258318451.squirrel@mail.alumni.caltech.edu> Message-ID: <5e0214850911151303w686111d8ja20d3cb76c553c5f@mail.gmail.com> It's simpler: "x&~y == 0" 2009/11/15 Michael Mossey : > Can someone tell me if this is correct. I'm guessing that if I represent > two sets of integers by Word32 (where ith bit set means i is in the set), > then an algorithm to determine if x is a subset of y would go something > like > > > ?(y - x) == (y `exclusiveOr` x) > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From nccb2 at kent.ac.uk Sun Nov 15 16:49:11 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Sun Nov 15 16:24:41 2009 Subject: [Haskell-cafe] Strange parallel behaviour with Ubuntu Karmic / GHC 6.10.4 In-Reply-To: <5f8b37690911130615w4439fcaav6c7b4be2ded1bbc2@mail.gmail.com> References: <5f8b37690911130615w4439fcaav6c7b4be2ded1bbc2@mail.gmail.com> Message-ID: <4B007757.1040408@kent.ac.uk> Michael Lesniak wrote: > Hello, > > I'm currently developing some applications with explicit threading > using forkIO and have strange behaviour on my freshly installed Ubuntu > Karmic 9.10 (Kernel 2.6.31-14 SMP). > > Setup: > Machine A: Quadcore, Ubuntu 9.04, Kernel 2.6.28-13 SMP > Machine B: AMD Opteron 875, 8 cores, 2.6.18-164 SMP- (some redhat) > Machine C: Dual-Core, Ubuntu 9.10, Kernel 2.6.31-14 SMP > Compiler on all machines: ghc 6.10.4 (downloaded from GHCs official website) > Hi, I have a dual-core Ubuntu 9.10 machine (running whatever GHC comes with the distro -- 6.10.x), so if you put your test code somewhere that I can get at, I can run it and see if I get the same effect. Thanks, Neil. From mlesniak at uni-kassel.de Sun Nov 15 18:48:02 2009 From: mlesniak at uni-kassel.de (Michael Lesniak) Date: Sun Nov 15 18:23:35 2009 Subject: [Haskell-cafe] Strange parallel behaviour with Ubuntu Karmic / GHC 6.10.4 In-Reply-To: <4B007757.1040408@kent.ac.uk> References: <5f8b37690911130615w4439fcaav6c7b4be2ded1bbc2@mail.gmail.com> <4B007757.1040408@kent.ac.uk> Message-ID: <5f8b37690911151548r541f2a86k98534499d8ddf56a@mail.gmail.com> Hello, I've written a smaller example which reproduces the unusual behaviour. Should I open a GHC-Ticket, too? -- A small working example which describes the problems (I have) with GHC -- 6.10.4, Ubuntu Karmic 9.10, explicit threading and core usage. -- -- See http://www.haskell.org/pipermail/haskell-cafe/2009-November/069144.html -- for the general description of the problem. -- -- For comparsion: -- Compilation on both machines with -- -- ghc --make -O2 -threaded Example.hs -o e -Wall -- -- -- 1. Machine B: (Quadcore, Ubuntu 9.04) -- a. With 1 thread: -- time e +RTS -N1 -RTS 16 -- e +RTS -N1 -RTS 16 11,00s user 5,00s system 100% cpu 16,004 total -- -- b. With 2 threads: -- time e +RTS -N2 -RTS 16 -- e +RTS -N2 -RTS 16 11,44s user 4,58s system 197% cpu 8,102 total -- -- -- 2. Machine C: (Dualcore, Ubuntu 9.10) -- a. With 1 thread: -- time e +RTS -N1 -RTS 16 -- -- real 0m16.414s -- user 0m11.360s -- sys 0m4.650s -- -- b. With 2 threads: -- time e +RTS -N2 -RTS 16 -- -- real 0m18.484s -- user 0m14.320s -- sys 0m5.940s -- ------------------------------------------------------------------------------- module Main where import GHC.Conc import Control.Concurrent import Control.Monad import System.Posix.Clock import System.Environment ------------------------------------------------------------------------------- main :: IO () main = do -- Configuration args <- getArgs let threads = numCapabilities -- number of threads determined by -N<...> taskDur = 1.0 -- seconds each task takes taskNum = (read . head) args -- Number of tasks is 1st parameter -- Generate a channel for the tasks to do and fill it with uniform and -- independent tasks. The other channel receives a message for each task -- which is finished. queue <- newChan finished <- newChan writeList2Chan queue (replicate taskNum taskDur) -- Fork threads replicateM_ threads (forkIO (thread queue finished)) -- Wait until the queue is empty replicateM_ taskNum (readChan finished) ------------------------------------------------------------------------------- thread :: Chan Double -> Chan Int -> IO () thread queue finished = forever $ do task <- readChan queue workFor task writeChan finished 1 ------------------------------------------------------------------------------- -- | Generates work for @s@ seconds. workFor :: Double -> IO () workFor s = do now <- getTime ThreadCPUTime repeat (time2Double now + s) where repeat fs = do now <- nSqrt 10000 `pseq` getTime ThreadCPUTime let f = time2Double now unless (f >= fs) $ repeat fs time2Double t = fromIntegral (sec t) + (fromIntegral (nsec t) / 1000000000) -- Calculates the sqrt of 2^1000. The parameter n is to ensure -- that GHC does not optimize it away. -- (In fact, I'm not sure this is needed...) nSqrt n = let sqs = map (\_ -> iterate sqrt (2^1000) !! 50) [1..n] in foldr seq 1 sqs From allbery at ece.cmu.edu Sun Nov 15 19:04:49 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Nov 15 18:40:35 2009 Subject: [Haskell-cafe] Why can `env` be assigned value two times ? In-Reply-To: <26356073.post@talk.nabble.com> References: <26356073.post@talk.nabble.com> Message-ID: On Nov 15, 2009, at 02:05 , zaxis wrote: > defineVar :: Env -> (Id, Val) -> IOThrowsError Val > defineVar envRef (id, val) = do { > env <- liftIO $ readIORef envRef; > env <- return $ filter (\(_id, _) -> _id/=id) env; -- clear the > current > scope > valRef <- liftIO $ newIORef val; > liftIO $ writeIORef envRef $ ((id, valRef):env); > return val; > } > > In haskell, the variable canot change its value , right? If so, why > can the > `env` be assigned value twice? Because they're not really the same variable; they're separate lambda bindings. If you translate the "do" syntax to the underlying "bind" syntax, you get something like: > defineVar envRef (id,val) = > liftIO (readIORef envRef) >>= > \env -> return (filter (\(_id,_) -> _id /= id) env) >>= > \env -> liftIO (newIORef val) >> > liftIO (writeIORef envRef ((id,valRef):env)) >> > return val So you're shadowing (hiding) the original "env" when you reuse the name. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091115/db2c070e/PGP.bin From gue.schmidt at web.de Sun Nov 15 19:33:41 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Sun Nov 15 19:09:38 2009 Subject: [Haskell-cafe] slightly off-topic Message-ID: -------------- next part -------------- A non-text attachment was scrubbed... Name: grandma.jpeg Type: image/jpeg Size: 100250 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091115/cbfe48d8/grandma-0001.jpeg From markl at glyphic.com Mon Nov 16 01:33:12 2009 From: markl at glyphic.com (Mark Lentczner) Date: Mon Nov 16 01:08:45 2009 Subject: [Haskell-cafe] Coercing numeric and string constants Message-ID: I'm looking for a good way to handle a library interface that accepts both strings and numbers in particular argument positions: Start with the following definitions. I've defined ResourceTree as a class here since the details don't matter. > data Segment = Key String | Index Int > deriving (Eq, Show) > > type Path = [Segment] > > class ResourceTree a where > lookupPath :: Path -> a -> Maybe String What I'm after is to make the following code, representative of intended client usage to work: > examples :: (ResourceTree a) => a -> [Maybe String] > examples r = [ > r `at` "status", > r `at` 7, > r `at` "part" ./ "sku", > r `at` "items" ./ 2, > r `at` 7 ./ "name", > r `at` 7 ./ 9 > ] The first way I thought to do this was with type classes: > class Segmentable a where { toSegment :: a -> Segment } > instance Segmentable Segment where { toSegment = id } > instance Segmentable String where { toSegment = Key } > instance Segmentable Int where { toSegment = Index } > > class Pathable a where { toPath :: a -> Path } > instance Pathable Path where { toPath = id } > instance Pathable String where { toPath s = [ Key s ] } > instance Pathable Int where { toPath i = [ Index i ] } > > (./) :: (Segmentable a, Pathable b) => a -> b -> Path > a ./ b = toSegment a : toPath b > infixr 4 ./ > > at :: (ResourceTree a, Pathable b) => a -> b -> Maybe String > a `at` b = lookupPath (toPath b) a > infix 2 `at` This works great for all uses in the client code where the type of the numeric arguments are known or otherwise forced to be Int. However, when used with numeric constants (as in the function example above), it fails due to the way that numeric constants are defined in Haskell. For example, the constant 9 in example results in this error: Ambiguous type variable `t4' in the constraints: `Pathable t4' arising from a use of `./' at Test.hs:48:15-20 `Num t4' arising from the literal `9' at Test.hs:48:20 Probable fix: add a type signature that fixes these type variable(s) I suppose that even though there is only one type that is both an instance of Num and of Pathable (Int), that can't be deduced with certainty. In the client code, one could fix this by typing the constants thus: > r `at` (7::Int) ./ (9::Int) But to me that makes a hash out of the concise syntax I was trying to achieve. Also, this code requires both FlexibleInstances and TypeSynonymInstances pragmas (though the later requirement could be worked around.), though I'm lead to understand that those are common enough. I think also that, these are only needed in the library, not the client code. The other way I thought to do this is by making Path and Segment instances of Num and IsString: > instance Num Segment where { fromInteger = Index . fromInteger } > instance IsString Segment where { fromString = Key . fromString } > instance Num Path where { fromInteger i = [ Index $ fromInteger i ] } > instance IsString Path where { fromString s = [ Key $ fromString s ] } > > (./) :: Segment -> Path -> Path > a ./ b = a : b > infixr 4 ./ > > at :: (ResourceTree a) => a -> Path -> Maybe String > a `at` b = lookupPath b a > infix 2 `at` This works but has two downsides: 1) Segment and Path are poor instances of Num, eliciting errors for missing methods and resulting in run-time errors should any client code accidentally use them as such. 2) It requires the OverloadedStrings pragma in every client module. Any comments on these two approaches would be appreciated, How to improve them? Which is the lesser of two evils? On the other hand, I realize that many may object that intended interface isn't very Haskell like. The data object I need to represent (ResourceTree) comes from external input and really does have the strange "paths of strings or integers" construction, I can't change that. And it is expected that much client code will use constant paths to access and manipulate various parts of such objects, hence the desire for a concise operator set that works with constants. Given that there are actually several operations on ResourceTree involving paths (where the operation requires the whole Path as a single value), any thoughts on a more Haskell like construction? Thanks, - MtnViewMark Mark Lentczner http://www.ozonehouse.com/mark/ mark@glyphic.com From jason.dusek at gmail.com Mon Nov 16 01:50:20 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Mon Nov 16 01:25:52 2009 Subject: [Haskell-cafe] attoparsec and parsec In-Reply-To: <4AFFFFE9.7020306@libero.it> References: <4AFF3964.7060303@libero.it> <42784f260911141716if7fea35t5daef9b5acc81f@mail.gmail.com> <4AFFFFE9.7020306@libero.it> Message-ID: <42784f260911152250j41b2fc7h61d44ab975ca9a3f@mail.gmail.com> 2009/11/15 Manlio Perillo : > I installed attoparsec yesterday without problems. Great; but any package you make with it will also fail to build on Hackage and we won't have browsable docs and so on.... > Did you try to contact the author/maintainer? Yes, I did. However, I was quite keen on releasing my JSON parser in a timely manner; the maintainer was (very reasonably) not on my schedule and I'm not sure my patch was ever applied. -- Jason Dusek From z_axis at 163.com Mon Nov 16 02:06:25 2009 From: z_axis at 163.com (zaxis) Date: Mon Nov 16 01:41:57 2009 Subject: [Haskell-cafe] Why can `env` be assigned value two times ? In-Reply-To: <26356073.post@talk.nabble.com> References: <26356073.post@talk.nabble.com> Message-ID: <26367496.post@talk.nabble.com> thanks for all your answers ! zaxis wrote: > > defineVar :: Env -> (Id, Val) -> IOThrowsError Val > defineVar envRef (id, val) = do { > env <- liftIO $ readIORef envRef; > env <- return $ filter (\(_id, _) -> _id/=id) env; -- clear the > current scope > valRef <- liftIO $ newIORef val; > liftIO $ writeIORef envRef $ ((id, valRef):env); > return val; > } > > In haskell, the variable canot change its value , right? If so, why can > the `env` be assigned value twice? > > Sincerely! > ----- fac n = foldr (*) 1 [1..n] -- View this message in context: http://old.nabble.com/Why-can-%60env%60-be-assigned-value-two-times---tp26356073p26367496.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From z_axis at 163.com Mon Nov 16 02:09:26 2009 From: z_axis at 163.com (zaxis) Date: Mon Nov 16 01:44:59 2009 Subject: [Haskell-cafe] About xmonad Message-ID: <26367498.post@talk.nabble.com> %uname -a Linux myarch 2.6.31-ARCH #1 SMP PREEMPT Tue Nov 10 19:48:17 CET 2009 i686 AMD Athlon(tm) 64 X2 Dual Core Processor 3600+ AuthenticAMD GNU/Linux %xmonad --version xmonad 0.9 In firefox, the `save as` dialog doesnot appear when i want to choose picture to save by right clicking the mouse. %cat ~/.xmonad/xmonad.hs import XMonad import XMonad.Hooks.ManageDocks import XMonad.Hooks.EwmhDesktops import XMonad.Hooks.DynamicLog import XMonad.Hooks.ManageHelpers import XMonad.Util.Run(spawnPipe) import XMonad.Layout.TwoPane import XMonad.Layout.WindowNavigation import qualified XMonad.StackSet as W import qualified Data.Map as M main = do xmonad $ defaultConfig { borderWidth = 1 , focusedBorderColor = "#ff6666" , normalBorderColor = "#2222aa" , manageHook = manageHook defaultConfig <+> myManageHook , workspaces = map show [1 .. 10 :: Int] , terminal = "roxterm" , modMask = mod4Mask , focusFollowsMouse = True , startupHook = myStartupHook , logHook = myLogHook , layoutHook = windowNavigation $ avoidStruts $ (Mirror tall ||| tall ||| Full) --, layoutHook = ewmhDesktopsLayout $ windowNavigation $ avoidStruts $ (Mirror tall ||| tall ||| Full) , keys = \c -> myKeys c `M.union` keys defaultConfig c --, mouseBindings = \c -> myMouse c `M.union` mouseBindings defaultConfig c } where tall = Tall 1 (3/100) (1/2) myStartupHook :: X () myStartupHook = do { spawn "fcitx"; spawn "roxterm"; spawn "lxpanel"; spawn "/home/sw2wolf/bin/kvm.sh"; } myLogHook :: X () myLogHook = ewmhDesktopsLogHook myManageHook :: ManageHook myManageHook = composeAll . concat $ [ [ className =? c --> doFloat | c <- myCFloats] ,[ resource =? r --> doFloat | r <- myRFloats] ,[ title =? t --> doFloat | t <- myTFloats] ,[ className =? c --> doIgnore | c <- ignores] ,[ className =? "Audacious" --> doShift "3" ] ,[ className =? "Firefox" --> doF W.swapDown] ,[(role =? "gimp-toolbox" <||> role =? "gimp-image-window") --> (ask >>= doF . W.sink)]] where myCFloats = ["Thunderbird-bin", "GQview", "MPlayer", "Gimp","Vncviewer","Xmessage"] myRFloats = ["Dialog", "Download", "Places"] myTFloats = ["Firefox Preferences", "Element Properties"] ignores = ["trayer"] role = stringProperty "WM_WINDOW_ROLE" myKeys (XConfig {modMask = modm}) = M.fromList $ -- Apps and tools [ ((modm, xK_F2), spawn "gmrun") , ((modm, xK_f), spawn "/home/firefox/firefox") , ((modm, xK_t), spawn "thunderbird") --, ((modm, xK_p), spawn "exe=`dmenu_path | dmenu -b` && eval \"exec $exe\"") , ((modm, xK_F11), spawn "sudo shutdown -r now") , ((modm, xK_F12), spawn "sudo shutdown -h now") , ((modm .|. controlMask, xK_Print), spawn "sleep 0.2; scrot -s") , ((modm, xK_Print), spawn "scrot '/tmp/%Y-%m-%d_%H:%M:%S_$wx$h_scrot.png' -e 'mv $f ~'") , ((modm, xK_c), kill) -- Window Navigation , ((modm, xK_Right), sendMessage $ Go R) , ((modm, xK_Left ), sendMessage $ Go L) , ((modm, xK_Up ), sendMessage $ Go U) , ((modm, xK_Down ), sendMessage $ Go D) -- swap... , ((modm .|. controlMask, xK_Right), sendMessage $ Swap R) , ((modm .|. controlMask, xK_Left ), sendMessage $ Swap L) , ((modm .|. controlMask, xK_Up ), sendMessage $ Swap U) , ((modm .|. controlMask, xK_Down ), sendMessage $ Swap D) ] ----- fac n = foldr (*) 1 [1..n] -- View this message in context: http://old.nabble.com/About-xmonad-tp26367498p26367498.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From wren at freegeek.org Mon Nov 16 02:56:05 2009 From: wren at freegeek.org (wren ng thornton) Date: Mon Nov 16 02:31:40 2009 Subject: [Haskell-cafe] What does the `forall` mean ? In-Reply-To: <562F0F92-6DCA-4070-A20F-271F4BBDE9C7@glyphic.com> References: <26311291.post@talk.nabble.com> <644F37FA-2902-46DD-A6FF-2C232B8A9E25@gmail.com> <4AFBE582.1030605@btinternet.com> <5e0214850911120244m30a2a285m4eeced410cf7d568@mail.gmail.com> <4AFC678F.5090501@btinternet.com> <3c6288ab0911121459x6429d56fm6b83257ce3c157f6@mail.gmail.com> <562F0F92-6DCA-4070-A20F-271F4BBDE9C7@glyphic.com> Message-ID: <4B010595.7000307@freegeek.org> Mark Lentczner wrote: > I also think I understand that the implicit 'forall' inherent in Haskell falls at different places in various constructs, which also had me confused. For example, while the above two function type declarations are equivalent, these two data declarations aren't: > > data Fizzle a = Fizzle (b -> (a, b)) a > data Fizzle a = forall b. Fizzle (b -> (a, b)) a They shouldn't. For data declarations there's the mix up that Lennart Augustsson brought up, but that's more of an issue with the implicit forall not being added in the first case. Basically, the implicit forall is always added at the front. So if I have some type T, then that's implicitly (forall a b c... . T). It's like constructing well-formed formulae in predicate calculus except that we're never allowed to have free variables, just like we can't have free variables in a well-formed expression of the lambda calculus. Since Hindley--Milner type inference can only deal with Rank-1 polymorphism we know all the quantifiers must be at the front, and since we know everything must be quantified we can just leave the quantifiers implicit. In GHC we can have Rank-N quantification but we need to give the signatures to tell the compiler we're using them. The reason I said "basically" is because Haskell also has some constructs which give type variables a larger scope than just the signature for a single function. Many of these (data, type, newtype, class) introduce a different kind of quantifier. The new quantifier is frequently written with iota and basically means that the variable is bound in the environment. Of course now that means we have to think about passing around an environment instead of just checking each signature in isolation. (There are other reasons why the compiler would have an environment for things, but now the user has to think about them too.) -- Live well, ~wren From wren at freegeek.org Mon Nov 16 03:13:55 2009 From: wren at freegeek.org (wren ng thornton) Date: Mon Nov 16 02:49:29 2009 Subject: [Haskell-cafe] help with musical data structures In-Reply-To: <5fdc56d70911150105j1494af46i475e9d9e46578a8b@mail.gmail.com> References: <1460.75.50.158.253.1258267873.squirrel@mail.alumni.caltech.edu> <5fdc56d70911150105j1494af46i475e9d9e46578a8b@mail.gmail.com> Message-ID: <4B0109C3.3060503@freegeek.org> Stephen Tetley wrote: > Hello Mike > > A pitch class set represents Z12 numbers so I'd define a Z12 number > type then store it in a list (if you have need a multiset - > duplicates) or Data.Set (if you need uniqueness). If you want an efficient implementation for *sets* of Z12 numbers I'd recommend using bit arithmetic. Pick some Word type with at least 12 bits and use bit0 to represent including 0 in the set, bit1 to represent including 1, bit2 for 2, etc. This can be generalized for any Zn provided n is a suitably small number. Z16 may be a good place to start if you want wider applicability, though you'd want to wrap that with error checking code in order to exclude 12..15. import Data.Word import Data.Bits newtype Z16 = Z16 Word16 z16_0 = 1 `shiftL` 0 z16_1 = 1 `shiftL` 1 z16_2 = 1 `shiftL` 2 ... union = (.|.) intersection = (.&.) ... But I don't know whether you need to deal more with sets or with the elements therein, so that might reduce the efficiency of this approach. -- Live well, ~wren From colin at colina.demon.co.uk Mon Nov 16 03:59:10 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Mon Nov 16 03:34:42 2009 Subject: [Haskell-cafe] Logistic regression Message-ID: Is there any free code anywhere for performing logistic regression? I can't see anything on hackage. -- Colin Adams Preston Lancashire From nccb2 at kent.ac.uk Mon Nov 16 04:38:29 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Mon Nov 16 04:13:41 2009 Subject: [Haskell-cafe] Strange parallel behaviour with Ubuntu Karmic / GHC 6.10.4 In-Reply-To: <5f8b37690911151548r541f2a86k98534499d8ddf56a@mail.gmail.com> References: <5f8b37690911130615w4439fcaav6c7b4be2ded1bbc2@mail.gmail.com> <4B007757.1040408@kent.ac.uk> <5f8b37690911151548r541f2a86k98534499d8ddf56a@mail.gmail.com> Message-ID: <4B011D95.6010600@kent.ac.uk> Michael Lesniak wrote: > Hello, > > I've written a smaller example which reproduces the unusual behaviour. > Should I open a GHC-Ticket, too? > Hi, I get these results: $ time ./Temp +RTS -N1 -RTS 16 real 0m16.010s user 0m10.869s sys 0m5.144s $ time ./Temp +RTS -N2 -RTS 16 real 0m12.794s user 0m13.341s sys 0m7.136s Looking at top, the second version used ~160% CPU time (i.e. it was using both cores fairly well). So I don't think I get the same bad behaviour as you. Those sys times look high by the way -- I guess it's all the calls to getTime? I wonder if that number might be causing the problem; can you replicate it with lower sys times? Thanks, Neil. From mlesniak at uni-kassel.de Mon Nov 16 04:59:45 2009 From: mlesniak at uni-kassel.de (Michael Lesniak) Date: Mon Nov 16 04:35:17 2009 Subject: [Haskell-cafe] Strange parallel behaviour with Ubuntu Karmic / GHC 6.10.4 In-Reply-To: <4B011D95.6010600@kent.ac.uk> References: <5f8b37690911130615w4439fcaav6c7b4be2ded1bbc2@mail.gmail.com> <4B007757.1040408@kent.ac.uk> <5f8b37690911151548r541f2a86k98534499d8ddf56a@mail.gmail.com> <4B011D95.6010600@kent.ac.uk> Message-ID: <5f8b37690911160159t4d8c92ddya89adebe0957d27f@mail.gmail.com> Hello, > getTime? ?I wonder if that number might be causing the problem; can you > replicate it with lower sys times? That was it! Thanks Neil! When I'm using some number crunching without getTime it works (with more or less the expected speedup and usage of two cores) on my Ubuntu 9.10, too. Out of curiosity, the question is still open: Why does the old example (using getTime) work so much better on an older version of Ubuntu/RedHat and not on the new ones? Kind regards, Michael -- Dipl.-Inf. Michael C. Lesniak University of Kassel Programming Languages / Methodologies Research Group Department of Computer Science and Electrical Engineering Wilhelmsh?her Allee 73 34121 Kassel Phone: +49-(0)561-804-6269 From deniz.a.m.dogan at gmail.com Mon Nov 16 05:24:57 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Mon Nov 16 05:00:49 2009 Subject: [Haskell-cafe] About xmonad In-Reply-To: <26367498.post@talk.nabble.com> References: <26367498.post@talk.nabble.com> Message-ID: <7b501d5c0911160224s3df84bdan413d90bb70070b4@mail.gmail.com> 2009/11/16 zaxis : > > %uname -a > Linux myarch 2.6.31-ARCH #1 SMP PREEMPT Tue Nov 10 19:48:17 CET 2009 i686 > AMD Athlon(tm) 64 X2 Dual Core Processor 3600+ AuthenticAMD GNU/Linux > > %xmonad --version > xmonad 0.9 > > In firefox, the `save as` dialog doesnot appear when i want to choose > picture to save by right clicking the mouse. > > %cat ~/.xmonad/xmonad.hs > import XMonad > > import XMonad.Hooks.ManageDocks > import XMonad.Hooks.EwmhDesktops > import XMonad.Hooks.DynamicLog > import XMonad.Hooks.ManageHelpers > > import XMonad.Util.Run(spawnPipe) > > import XMonad.Layout.TwoPane > import XMonad.Layout.WindowNavigation > > import qualified XMonad.StackSet as W > import qualified Data.Map as M > > main = do > ? ?xmonad $ defaultConfig > ? ? ? ? ? ?{ borderWidth ? ? ? ?= 1 > ? ? ? ? ? ?, focusedBorderColor ? ? = "#ff6666" > ? ? ? ? ? ?, normalBorderColor ? ? = "#2222aa" > ? ? ? ? ? ?, manageHook ? ? ? = manageHook defaultConfig <+> myManageHook > ? ? ? ? ? ?, workspaces ? ? ? = map show [1 .. 10 :: Int] > ? ? ? ? ? ?, terminal ? ? ? ?= "roxterm" > ? ? ? ? ? ?, modMask ? ? ? ? ?= mod4Mask > ? ? ? ? ? ?, focusFollowsMouse ?= True > ? ? ? ? ? ?, startupHook ? ? ?= myStartupHook > ? ? ? ? ? ?, logHook = myLogHook > ? ? ? ? ? ?, layoutHook ? ? ?= windowNavigation $ avoidStruts $ (Mirror > tall ||| tall ||| Full) > ? ? ? ? ? ?--, layoutHook ? ?= ewmhDesktopsLayout $ windowNavigation $ > avoidStruts $ (Mirror tall ||| tall ||| Full) > ? ? ? ? ? ?, keys ? ? ? ? ? ? = \c -> myKeys c `M.union` keys defaultConfig > c > ? ? ? ? ? ?--, mouseBindings = \c -> myMouse c `M.union` mouseBindings > defaultConfig c > ? ? ? ? ? ?} > ? ?where > ? ? ? ?tall ? ? = Tall 1 (3/100) (1/2) > > ? ? ? ?myStartupHook :: X () > ? ? ? ?myStartupHook = do { > ? ? ? ? ? ?spawn "fcitx"; > ? ? ? ? ? ?spawn "roxterm"; > ? ? ? ? ? ?spawn "lxpanel"; > ? ? ? ? ? ?spawn "/home/sw2wolf/bin/kvm.sh"; > ? ? ? ?} > ? ? ? ?myLogHook :: X () > ? ? ? ?myLogHook = ewmhDesktopsLogHook > > ? ? ? ?myManageHook :: ManageHook > ? ? ? ?myManageHook = composeAll . concat $ > ? ? ? ? ? ? ? ? ? ? ? ?[ [ className =? c --> doFloat | c <- myCFloats] > ? ? ? ? ? ? ? ? ? ? ? ? ,[ resource ?=? r --> doFloat | r <- myRFloats] > ? ? ? ? ? ? ? ? ? ? ? ? ,[ title ? ? =? t --> doFloat | t <- myTFloats] > ? ? ? ? ? ? ? ? ? ? ? ? ,[ className =? c --> doIgnore | c <- ignores] > ? ? ? ? ? ? ? ? ? ? ? ? ,[ className =? "Audacious" --> doShift "3" ] > ? ? ? ? ? ? ? ? ? ? ? ? ,[ className =? "Firefox" --> doF W.swapDown] > ? ? ? ? ? ? ? ? ? ? ? ? ,[(role =? "gimp-toolbox" <||> role =? > "gimp-image-window") --> (ask >>= doF . W.sink)]] > ? ? ? ? ? ? ? ? ? ?where myCFloats = ["Thunderbird-bin", "GQview", > "MPlayer", "Gimp","Vncviewer","Xmessage"] > ? ? ? ? ? ? ? ? ? ? ? ? ?myRFloats = ["Dialog", "Download", "Places"] > ? ? ? ? ? ? ? ? ? ? ? ? ?myTFloats ?= ["Firefox Preferences", "Element > Properties"] > ? ? ? ? ? ? ? ? ? ? ? ? ?ignores = ["trayer"] > ? ? ? ? ? ? ? ? ? ? ? ? ?role = stringProperty "WM_WINDOW_ROLE" > > ? ? ? ?myKeys (XConfig {modMask = modm}) = M.fromList $ > ? ? ? ? ? ?-- Apps and tools > ? ? ? ? ? ?[ ((modm, xK_F2), spawn "gmrun") > ? ? ? ? ? ?, ((modm, xK_f), spawn "/home/firefox/firefox") > ? ? ? ? ? ?, ((modm, xK_t), spawn "thunderbird") > ? ? ? ? ? ?--, ((modm, xK_p), spawn "exe=`dmenu_path | dmenu -b` && eval > \"exec $exe\"") > ? ? ? ? ? ?, ((modm, xK_F11), spawn "sudo shutdown -r now") > ? ? ? ? ? ?, ((modm, xK_F12), spawn "sudo shutdown -h now") > ? ? ? ? ? ?, ((modm .|. controlMask, xK_Print), spawn "sleep 0.2; scrot > -s") > ? ? ? ? ? ?, ((modm, xK_Print), spawn "scrot > '/tmp/%Y-%m-%d_%H:%M:%S_$wx$h_scrot.png' -e 'mv $f ~'") > ? ? ? ? ? ?, ((modm, xK_c), kill) > ? ? ? ? ? ?-- Window Navigation > ? ? ? ? ? ?, ((modm, xK_Right), sendMessage $ Go R) > ? ? ? ? ? ?, ((modm, xK_Left ), sendMessage $ Go L) > ? ? ? ? ? ?, ((modm, xK_Up ? ), sendMessage $ Go U) > ? ? ? ? ? ?, ((modm, xK_Down ), sendMessage $ Go D) > ? ? ? ? ? ?-- swap... > ? ? ? ? ? ?, ((modm .|. controlMask, xK_Right), sendMessage $ Swap R) > ? ? ? ? ? ?, ((modm .|. controlMask, xK_Left ), sendMessage $ Swap L) > ? ? ? ? ? ?, ((modm .|. controlMask, xK_Up ? ), sendMessage $ Swap U) > ? ? ? ? ? ?, ((modm .|. controlMask, xK_Down ), sendMessage $ Swap D) > ? ? ? ? ? ?] > > ----- > fac n = foldr (*) 1 [1..n] > -- > View this message in context: http://old.nabble.com/About-xmonad-tp26367498p26367498.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 > You should try asking on the xmonad mailing list: http://www.haskell.org/mailman/listinfo/xmonad -- Deniz Dogan From nccb2 at kent.ac.uk Mon Nov 16 05:33:25 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Mon Nov 16 05:08:33 2009 Subject: [Haskell-cafe] Strange parallel behaviour with Ubuntu Karmic / GHC 6.10.4 In-Reply-To: <5f8b37690911160159t4d8c92ddya89adebe0957d27f@mail.gmail.com> References: <5f8b37690911130615w4439fcaav6c7b4be2ded1bbc2@mail.gmail.com> <4B007757.1040408@kent.ac.uk> <5f8b37690911151548r541f2a86k98534499d8ddf56a@mail.gmail.com> <4B011D95.6010600@kent.ac.uk> <5f8b37690911160159t4d8c92ddya89adebe0957d27f@mail.gmail.com> Message-ID: <4B012A75.7030600@kent.ac.uk> Michael Lesniak wrote: > Hello, > > >> getTime? I wonder if that number might be causing the problem; can you >> replicate it with lower sys times? >> > That was it! Thanks Neil! > > When I'm using some number crunching without getTime it works (with > more or less the expected speedup and usage of two cores) on my Ubuntu > 9.10, too. > > Out of curiosity, the question is still open: Why does the old example > (using getTime) work so much better on an older version of > Ubuntu/RedHat and not on the new ones? > > Your kernels were: Setup: Machine A: Quadcore, Ubuntu 9.04, Kernel 2.6.28-13 SMP Machine B: AMD Opteron 875, 8 cores, 2.6.18-164 SMP- (some redhat) Machine C: Dual-Core, Ubuntu 9.10, Kernel 2.6.31-14 SMP Looking at the implementation of getTime ThreadCPUTime in the clock package, it calls clock_gettime(CLOCK_THREAD_CPUTIME_ID,..). According to this page (http://www.h-online.com/open/news/item/Kernel-Log-What-s-new-in-2-6-29-Part-8-Faster-start-up-and-other-behind-the-scenes-changes-740591.html), the changes in 2.6.29 (changes which only your Ubuntu 9.10 machine has) included a patch (http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c742b31c03f37c5c499178f09f57381aa6c70131) which altered the implementation of that function. Perhaps on some multi-processor machines the new implementation effectively serialises the code? I know there used to be issues of whether some of the timers were synchronised across processors/cores (to stop them appearing to go backwards), so maybe something with the timers and their synchronisations effectively stops your program running in parallel. If it helps, my machine is: "Intel(R) Core(TM)2 Duo CPU E8400 @ 3.00GHz" according to /proc/cpuinfo. Thanks, Neil. From sebf at informatik.uni-kiel.de Mon Nov 16 06:03:04 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Mon Nov 16 05:38:41 2009 Subject: [Haskell-cafe] haskell-src-exts Question In-Reply-To: References: <404396ef0911131208k2063db80i4c966b403d53bafb@mail.gmail.com> <1258148654.4680.13597.camel@localhost> Message-ID: Hello, On Nov 13, 2009, at 11:54 PM, Niklas Broberg wrote: > But the problem at hand here is auto-generated AST code, where we > cannot rely on the parser to do the right thing. There's help in the > AST such that it's possible to explicitly insert brackets where > needed, but I agree with Dominic that it shouldn't really be necessary > in his case. Neil's point is well taken though - to do it correctly > (or rather, minimally) for infix application, the pretty printer would > need to be aware of the respective fixities involved. If I was planning to write a Haskell program that generates Haskell code, should I use HSE? Or is it more for generating nice looking code than correct code? Is there an alternative package that is more suitable for generating code that is meant to be executed rather than being looked at? > However, that doesn't mean we can't do better than what it is now, but > be conservative about it. Only insert brackets where it's clear that > brackets must be inserted, which would be the case for Dominic's > example. If the argument to an application is non-atomic, it needs > brackets, there's nothing ambiguous about that. Nothing can be said so > categorically for infix applications, so there we should assume that > the fixities are already done in the correct way, or that brackets are > inserted manually where needed. > > Does that sound reasonable? Personnaly, I would prefer Duncans approach to produce correct output by default and require additional fixity information if the output should contain fewer parens. (The reason for my preference is that I think it is quite annoying to insert parens manually into auto generated infix applications only to get correct output.) In order to help reducing the amount of annoying parentheses in printed code, would it be sufficient - at least for the common case - to do something along the lines of prettyPrint = prettyPrintWithFixities preludeFixities and provide make `prettyPrint`, `prettyPrintWithFixities`, and `preludeFixities` public? Cheers, Sebastian -- Underestimating the novelty of the future is a time-honored tradition. (D.G.) From lazycat.manatee at gmail.com Mon Nov 16 04:16:27 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Mon Nov 16 05:44:13 2009 Subject: [Haskell-cafe] How to update SSH key in code.haskell.org Message-ID: <87ws1qn82c.fsf@ubuntu.domain> Hi all. I'm a developer of gtk2hs project at code.haskell.org But i found i lost my SSH key when i update new system, and i can't push patch to gtk2hs. I have send mail to support@community.haskell.org for this problem, but i'm not sure that's the right place. So how to update SSH key with my account (AndyStewart) ? Thanks, -- Andy From z_axis at 163.com Mon Nov 16 06:09:18 2009 From: z_axis at 163.com (zaxis) Date: Mon Nov 16 05:44:50 2009 Subject: [Haskell-cafe] About xmonad In-Reply-To: <7b501d5c0911160224s3df84bdan413d90bb70070b4@mail.gmail.com> References: <26367498.post@talk.nabble.com> <7b501d5c0911160224s3df84bdan413d90bb70070b4@mail.gmail.com> Message-ID: <26370168.post@talk.nabble.com> I have subscribed to xmonad maillist but i never received any email ! Deniz Dogan-3 wrote: > > 2009/11/16 zaxis : >> >> %uname -a >> Linux myarch 2.6.31-ARCH #1 SMP PREEMPT Tue Nov 10 19:48:17 CET 2009 i686 >> AMD Athlon(tm) 64 X2 Dual Core Processor 3600+ AuthenticAMD GNU/Linux >> >> %xmonad --version >> xmonad 0.9 >> >> In firefox, the `save as` dialog doesnot appear when i want to choose >> picture to save by right clicking the mouse. >> >> %cat ~/.xmonad/xmonad.hs >> import XMonad >> >> import XMonad.Hooks.ManageDocks >> import XMonad.Hooks.EwmhDesktops >> import XMonad.Hooks.DynamicLog >> import XMonad.Hooks.ManageHelpers >> >> import XMonad.Util.Run(spawnPipe) >> >> import XMonad.Layout.TwoPane >> import XMonad.Layout.WindowNavigation >> >> import qualified XMonad.StackSet as W >> import qualified Data.Map as M >> >> main = do >> ? ?xmonad $ defaultConfig >> ? ? ? ? ? ?{ borderWidth ? ? ? ?= 1 >> ? ? ? ? ? ?, focusedBorderColor ? ? = "#ff6666" >> ? ? ? ? ? ?, normalBorderColor ? ? = "#2222aa" >> ? ? ? ? ? ?, manageHook ? ? ? = manageHook defaultConfig <+> myManageHook >> ? ? ? ? ? ?, workspaces ? ? ? = map show [1 .. 10 :: Int] >> ? ? ? ? ? ?, terminal ? ? ? ?= "roxterm" >> ? ? ? ? ? ?, modMask ? ? ? ? ?= mod4Mask >> ? ? ? ? ? ?, focusFollowsMouse ?= True >> ? ? ? ? ? ?, startupHook ? ? ?= myStartupHook >> ? ? ? ? ? ?, logHook = myLogHook >> ? ? ? ? ? ?, layoutHook ? ? ?= windowNavigation $ avoidStruts $ (Mirror >> tall ||| tall ||| Full) >> ? ? ? ? ? ?--, layoutHook ? ?= ewmhDesktopsLayout $ windowNavigation $ >> avoidStruts $ (Mirror tall ||| tall ||| Full) >> ? ? ? ? ? ?, keys ? ? ? ? ? ? = \c -> myKeys c `M.union` keys >> defaultConfig >> c >> ? ? ? ? ? ?--, mouseBindings = \c -> myMouse c `M.union` mouseBindings >> defaultConfig c >> ? ? ? ? ? ?} >> ? ?where >> ? ? ? ?tall ? ? = Tall 1 (3/100) (1/2) >> >> ? ? ? ?myStartupHook :: X () >> ? ? ? ?myStartupHook = do { >> ? ? ? ? ? ?spawn "fcitx"; >> ? ? ? ? ? ?spawn "roxterm"; >> ? ? ? ? ? ?spawn "lxpanel"; >> ? ? ? ? ? ?spawn "/home/sw2wolf/bin/kvm.sh"; >> ? ? ? ?} >> ? ? ? ?myLogHook :: X () >> ? ? ? ?myLogHook = ewmhDesktopsLogHook >> >> ? ? ? ?myManageHook :: ManageHook >> ? ? ? ?myManageHook = composeAll . concat $ >> ? ? ? ? ? ? ? ? ? ? ? ?[ [ className =? c --> doFloat | c <- myCFloats] >> ? ? ? ? ? ? ? ? ? ? ? ? ,[ resource ?=? r --> doFloat | r <- myRFloats] >> ? ? ? ? ? ? ? ? ? ? ? ? ,[ title ? ? =? t --> doFloat | t <- myTFloats] >> ? ? ? ? ? ? ? ? ? ? ? ? ,[ className =? c --> doIgnore | c <- ignores] >> ? ? ? ? ? ? ? ? ? ? ? ? ,[ className =? "Audacious" --> doShift "3" ] >> ? ? ? ? ? ? ? ? ? ? ? ? ,[ className =? "Firefox" --> doF W.swapDown] >> ? ? ? ? ? ? ? ? ? ? ? ? ,[(role =? "gimp-toolbox" <||> role =? >> "gimp-image-window") --> (ask >>= doF . W.sink)]] >> ? ? ? ? ? ? ? ? ? ?where myCFloats = ["Thunderbird-bin", "GQview", >> "MPlayer", "Gimp","Vncviewer","Xmessage"] >> ? ? ? ? ? ? ? ? ? ? ? ? ?myRFloats = ["Dialog", "Download", "Places"] >> ? ? ? ? ? ? ? ? ? ? ? ? ?myTFloats ?= ["Firefox Preferences", "Element >> Properties"] >> ? ? ? ? ? ? ? ? ? ? ? ? ?ignores = ["trayer"] >> ? ? ? ? ? ? ? ? ? ? ? ? ?role = stringProperty "WM_WINDOW_ROLE" >> >> ? ? ? ?myKeys (XConfig {modMask = modm}) = M.fromList $ >> ? ? ? ? ? ?-- Apps and tools >> ? ? ? ? ? ?[ ((modm, xK_F2), spawn "gmrun") >> ? ? ? ? ? ?, ((modm, xK_f), spawn "/home/firefox/firefox") >> ? ? ? ? ? ?, ((modm, xK_t), spawn "thunderbird") >> ? ? ? ? ? ?--, ((modm, xK_p), spawn "exe=`dmenu_path | dmenu -b` && eval >> \"exec $exe\"") >> ? ? ? ? ? ?, ((modm, xK_F11), spawn "sudo shutdown -r now") >> ? ? ? ? ? ?, ((modm, xK_F12), spawn "sudo shutdown -h now") >> ? ? ? ? ? ?, ((modm .|. controlMask, xK_Print), spawn "sleep 0.2; scrot >> -s") >> ? ? ? ? ? ?, ((modm, xK_Print), spawn "scrot >> '/tmp/%Y-%m-%d_%H:%M:%S_$wx$h_scrot.png' -e 'mv $f ~'") >> ? ? ? ? ? ?, ((modm, xK_c), kill) >> ? ? ? ? ? ?-- Window Navigation >> ? ? ? ? ? ?, ((modm, xK_Right), sendMessage $ Go R) >> ? ? ? ? ? ?, ((modm, xK_Left ), sendMessage $ Go L) >> ? ? ? ? ? ?, ((modm, xK_Up ? ), sendMessage $ Go U) >> ? ? ? ? ? ?, ((modm, xK_Down ), sendMessage $ Go D) >> ? ? ? ? ? ?-- swap... >> ? ? ? ? ? ?, ((modm .|. controlMask, xK_Right), sendMessage $ Swap R) >> ? ? ? ? ? ?, ((modm .|. controlMask, xK_Left ), sendMessage $ Swap L) >> ? ? ? ? ? ?, ((modm .|. controlMask, xK_Up ? ), sendMessage $ Swap U) >> ? ? ? ? ? ?, ((modm .|. controlMask, xK_Down ), sendMessage $ Swap D) >> ? ? ? ? ? ?] >> >> ----- >> fac n = foldr (*) 1 [1..n] >> -- >> View this message in context: >> http://old.nabble.com/About-xmonad-tp26367498p26367498.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 >> > > You should try asking on the xmonad mailing list: > http://www.haskell.org/mailman/listinfo/xmonad > > -- > Deniz Dogan > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ----- fac n = foldr (*) 1 [1..n] -- View this message in context: http://old.nabble.com/About-xmonad-tp26367498p26370168.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ck_kashyap at yahoo.com Mon Nov 16 06:16:33 2009 From: ck_kashyap at yahoo.com (CK Kashyap) Date: Mon Nov 16 05:52:04 2009 Subject: [Haskell-cafe] DSL in Haskell In-Reply-To: <20091115192754.GB21944@whirlpool.galois.com> References: <34696.21589.qm@web112513.mail.gq1.yahoo.com> <20091115192754.GB21944@whirlpool.galois.com> Message-ID: <98677.98249.qm@web112508.mail.gq1.yahoo.com> Thanks Don, I read the PDF. I was not able to figure out how to get the BASIC module. Wanted to see a reference implementation. The DSL I want to start with is a music generation DSL ... It should generate a wave file with music data as input -> for example the input could contain C3 D3 E3 ... -> should output a wave file with those notes ... some kind of mnemonics for tempo will also be there. Later I'd like to incorporate parallel sequence generation -> where I could get chord effect etc ... I had done a rudimentary implementation in C a while back -> http://kashyap-1978.tripod.com/Escapades/Goodies/Construct_WAV.html I'd appreciate it very much if you could give me some pointers on getting started. Regards, Kashyap ________________________________ From: Don Stewart To: CK Kashyap Cc: haskell-cafe@haskell.org Sent: Mon, November 16, 2009 12:57:54 AM Subject: Re: [Haskell-cafe] DSL in Haskell ck_kashyap: > Hi All, > I was reading a Ruby book and in that it was mentioned that its capability to > dynamically query and modify classes makes it suitable for implementing DSL's > ... I am referring to Ruby's reflection and methods like "method_missing" here. > It can allow things like not having to define constants for all possible > unicode code points etc...For example, first use of U0123 could bring such a > constant definition into existence etc > > I see multiple search hits when I look for Haskell and DSL - can someone please > point me to a good primer or explain to me how equivalent of above mentioned > features in Ruby can be done in Haskell ... or the Haskell alternative for it. The Haskell equivalent would be overloading, primarily via type classes. See Lennart Augusston's BASIC for an example of this in the extreme: http://augustss.blogspot.com/2009/02/more-basic-not-that-anybody-should-care.html That's BASIC syntax, in Haskell, relying on overloading numbers, strings etc. And all statically typed. For a survey of some of the more recent EDSLs in Haskell, see this brief overview, http://www.galois.com/~dons/papers/stewart-2009-edsls.pdf -- Don -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091116/f6a3d05c/attachment.html From mauricio.antunes at gmail.com Mon Nov 16 06:17:37 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Mon Nov 16 05:53:33 2009 Subject: [Haskell-cafe] ANN: bindings-SDL 1.0.2, the domain specific language for FFI description Message-ID: Hi, This package is to be used with hsc2hs. (hsc2hs is called automatically if you use Cabal.) It's a self-contained set of macros used to create a Haskell wrap for a C interface. They follow the idea that it's better to have a C-like wrap code first and then write Haskell-like code on top of that than going directly from C to Haskell style. Hackage link: http://hackage.haskell.org/package/bindings-DSL Wiki documentation: http://bitbucket.org/mauricio/bindings-dsl The fancy 'domain specific language' comes from 'binding-SDL' macros hability to describe a C interface. Instead of writing Haskell or preprocessor code, you can use 'bindings-DSL' macros to describe the interface you want to wrap without knowledge of how that description translates to preprocessor or Haskell code. Suppose, for instance, you have the following C struct: struct example_struct{ int n; struct example_struct *p; } It will be described like this: #starttype struct example_struct #field n , CInt #field p , Ptr #stoptype and this gives you a Haskell data type (automatically named C'example_struct) with the same fields and Storable instantiation. Here is a bigger example, with structs, macros, functions and global variables. Suppose you want to wrap this: http://git.savannah.gnu.org/cgit/gsl.git/tree/multimin/gsl_multimin.h Then this is how your 'bindings-DSL' code will look like: http://bitbucket.org/mauricio/bindings-gsl/src/tip/src/Bindings/Gsl/MultidimensionalMinimization.hsc That code translates to these Haskell declarations: http://hackage.haskell.org/packages/archive/bindings-gsl/0.1.1.6/doc/html/Bindings-Gsl-MultidimensionalMinimization.html 'bindings-DSL' came from previous 'bindings-common' package. It started as an effort to have many Haskell interfaces to good libraries available on Hackage, and came to be a language to support writing such interfaces easily and reliably. Hope it's usefull to you. Best, Maur?cio From Alistair.Bayley at invesco.com Mon Nov 16 06:35:25 2009 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Mon Nov 16 06:10:58 2009 Subject: [Haskell-cafe] Opinion about JHC In-Reply-To: <20091114042449.GC24020@sliver.repetae.net> References: <567296.97882.qm@web58802.mail.re1.yahoo.com><20091111083759.GH21564@sliver.repetae.net><20091113112644.GF23126@sliver.repetae.net><404396ef0911131208n4d97fd93xeff94ac5952d4ce@mail.gmail.com> <20091114042449.GC24020@sliver.repetae.net> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA91102643A@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of John Meacham > > On Fri, Nov 13, 2009 at 08:55:51PM +0000, Lennart Augustsson wrote: > > That was indeed my point. Since a compiler is a > substantial program I > > would have more confidence it a compiler that is self-hosting. > > Surely you must have tried? > > [...] I never understood the desire to have it be self-hosting [...] I think you did, once. Quoting from here (from section "The story of jhc"): http://repetae.net/computer/jhc/jhc.shtml "Writing a compiler is also doubly efficient to begin with, since if you self-compile improvements not only give you a better optimizer, but also speed up your self-compiled compiler." I was looking forward to the day jhc became self-hosting. Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From alexey.skladnoy at gmail.com Mon Nov 16 06:46:57 2009 From: alexey.skladnoy at gmail.com (Alexey Khudyakov) Date: Mon Nov 16 06:22:29 2009 Subject: [Haskell-cafe] poor perfomance of indexU in uvector package In-Reply-To: <20091115175949.GE21777@whirlpool.galois.com> References: <8425cc0e0911150400i38b5935cs16a54cf5e72bc84f@mail.gmail.com> <20091115175949.GE21777@whirlpool.galois.com> Message-ID: <8425cc0e0911160346q747c92a3hb9918c13ebec3ff3@mail.gmail.com> On Sun, Nov 15, 2009 at 8:59 PM, Don Stewart wrote: > alexey.skladnoy: >> I found that perfomace of indexU is very poor and it is not fast O(1) >> operation which is very surprising. Here is some benchmarcking I've >> done. Everything compiled with -O2 > > You're using the streamed version when its not fusing. Use the > non-streaming direct implementation exported from Data.Array.Vector.UArr > > This is really an API bug, but I've not had time to sanitize the use. > Probably this should be stated more explicitly in documentation. This is _very_ unexpected and confusing behaviour. Also I don't quite understand nature of bug. Is this missing export or wrong function is exported. And is streamed version of idexU useful and in which way? On Sun, Nov 15, 2009 at 9:11 PM, Thomas DuBuisson wrote: > The documentation explicitly says indexU is O(n) - no need for so much > testing to rediscover that fact. When I needed a contiguous block of > values in UArr, I just relied on sliceU to acquire the block and > performed a foldU. > Problems begin when you need non-contiguous block. Easiest way to so is indexing. From rl at cse.unsw.edu.au Mon Nov 16 07:23:47 2009 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Mon Nov 16 06:59:24 2009 Subject: [Haskell-cafe] poor perfomance of indexU in uvector package In-Reply-To: <8425cc0e0911160346q747c92a3hb9918c13ebec3ff3@mail.gmail.com> References: <8425cc0e0911150400i38b5935cs16a54cf5e72bc84f@mail.gmail.com> <20091115175949.GE21777@whirlpool.galois.com> <8425cc0e0911160346q747c92a3hb9918c13ebec3ff3@mail.gmail.com> Message-ID: <93610DC5-A56F-431A-8ECE-4262268217B4@cse.unsw.edu.au> On 16/11/2009, at 22:46, Alexey Khudyakov wrote: > Problems begin when you need non-contiguous block. Easiest way to so > is indexing. FWIW, this operation is called backpermute and is probably exported as bpermute in uvector. Roman From dominic at steinitz.org Mon Nov 16 09:17:51 2009 From: dominic at steinitz.org (Dominic Steinitz) Date: Mon Nov 16 08:57:44 2009 Subject: [Haskell-cafe] Re: haskell-src-exts Question References: Message-ID: Niklas Broberg gmail.com> writes: > please? http://trac.haskell.org/haskell-src-exts Niklas, I'd love to raise a bug for it but unfortunately I can't log on to trac. I don't understand why but none of my colleagues can log on either. It's been a long standing issue. I presume it's to do with our proxy but we can log on to lots of other sites. Perhaps you could cut and paste the email I sent? Dominic. From dominic at steinitz.org Mon Nov 16 09:27:23 2009 From: dominic at steinitz.org (Dominic Steinitz) Date: Mon Nov 16 09:03:34 2009 Subject: [Haskell-cafe] Re: haskell-src-exts Question References: Message-ID: Dominic Steinitz steinitz.org> writes: > > Niklas Broberg gmail.com> writes: > > please? http://trac.haskell.org/haskell-src-exts > > Niklas, I'd love to raise a bug for it but unfortunately I can't log on to Good news. Although I couldn't logon as guest, I've created an account and can logon as that. I'll create the ticket now. From gue.schmidt at web.de Mon Nov 16 09:32:57 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Nov 16 09:09:05 2009 Subject: [Haskell-cafe] who wrote the Relational_Algebra page Message-ID: on the Haskell wiki? http://www.haskell.org/haskellwiki/Relational_algebra G?nther From Alistair.Bayley at invesco.com Mon Nov 16 09:38:58 2009 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Mon Nov 16 09:14:44 2009 Subject: [Haskell-cafe] who wrote the Relational_Algebra page In-Reply-To: References: Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA91102643B@GBLONXMB02.corp.amvescap.net> > on the Haskell wiki? > > http://www.haskell.org/haskellwiki/Relational_algebra > > G?nther According to the page history, the userid is EndreyMark. Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From gwern0 at gmail.com Mon Nov 16 09:44:24 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Mon Nov 16 09:26:08 2009 Subject: [Haskell-cafe] who wrote the Relational_Algebra page In-Reply-To: References: Message-ID: 2009/11/16 G?nther Schmidt : > on the Haskell wiki? > > http://www.haskell.org/haskellwiki/Relational_algebra > > G?nther http://www.haskell.org/haskellwiki/?title=Relational_algebra&action=history ? -- gwern From gue.schmidt at web.de Mon Nov 16 10:06:50 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Nov 16 09:42:22 2009 Subject: [Haskell-cafe] who wrote the Relational_Algebra page In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA91102643B@GBLONXMB02.corp.amvescap.net> References: <125EACD0CAE4D24ABDB4D148C4593DA91102643B@GBLONXMB02.corp.amvescap.net> Message-ID: Hi Alistair, thanks, do you happen to know his email address? I try to get in touch with him because this particular subject is of great importance to me and he seems to have done quite a lot of research already. G?nther Am 16.11.2009, 15:38 Uhr, schrieb Bayley, Alistair : >> on the Haskell wiki? >> >> http://www.haskell.org/haskellwiki/Relational_algebra >> >> G?nther > > According to the page history, the userid is EndreyMark. > > Alistair > ***************************************************************** > Confidentiality Note: The information contained in this message, > and any attachments, may contain confidential and/or privileged > material. It is intended solely for the person(s) or entity to > which it is addressed. Any review, retransmission, dissemination, > or taking of any action in reliance upon this information by > persons or entities other than the intended recipient(s) is > prohibited. If you received this in error, please contact the > sender and delete the material from any computer. > ***************************************************************** > From jgoerzen at complete.org Mon Nov 16 10:44:30 2009 From: jgoerzen at complete.org (John Goerzen) Date: Mon Nov 16 10:20:04 2009 Subject: [Haskell-cafe] Trouble installing HDBC 2.1.1 with ghc 6.10.4 In-Reply-To: References: Message-ID: <4B01735E.1070904@complete.org> Colin Paul Adams wrote: > Is this connected with the in-and-out status of the time library in > the GHC 6.10.x series? > > Is there a work-around? Using the current HDBC (2.2.1) would fix it for you. -- John From gwern0 at gmail.com Mon Nov 16 10:55:45 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Mon Nov 16 10:31:22 2009 Subject: [Haskell-cafe] who wrote the Relational_Algebra page In-Reply-To: References: <125EACD0CAE4D24ABDB4D148C4593DA91102643B@GBLONXMB02.corp.amvescap.net> Message-ID: 2009/11/16 G?nther Schmidt : > Hi Alistair, > > > thanks, do you happen to know his email address? > I try to get in touch with him because this particular subject is of great > importance to me and he seems to have done quite a lot of research already. > > G?nther Most Haskell wiki users (and Wikipedia users for that matter) provide an email address while signing up. This then allows other users to email them; you go to his user page and you'll notice an 'email' link up top with the other links like User talk or Contributions. -- gwern From duncan at well-typed.com Mon Nov 16 11:20:42 2009 From: duncan at well-typed.com (Duncan Coutts) Date: Mon Nov 16 10:56:16 2009 Subject: [Haskell-cafe] ANNOUNCE: New Industrial Haskell Group membership options Message-ID: <1258388442.4896.3546.camel@localhost> The Industrial Haskell Group (IHG) is an organisation to support the needs of commercial users of the Haskell programming language. The second round of the IHG's collaborative development scheme will be running for 6 months from January. We are now inviting additional companies to take part. This scheme is ideal for companies that make significant use of Haskell and wish to fund specific projects. Additionally, there are new associate and academic membership options. These enable companies and academic groups to support the general health of the Haskell development platform, but with a lower financial commitment. For more details on all of the above, please see http://industry.haskell.org/ If your company or group is interested in joining then please e-mail info@industry.haskell.org -- Duncan Coutts, Haskell Consultant Well-Typed LLP, http://www.well-typed.com/ From marlowsd at gmail.com Mon Nov 16 11:29:46 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Mon Nov 16 11:05:23 2009 Subject: [Haskell-cafe] Announcing the GHC Bug Sweep Message-ID: <4B017DFA.2060207@gmail.com> Help us weed the GHC ticket database, and get a warm fuzzy feeling from contributing to Haskell core technology! There are currently ~750 tickets against GHC. Many of them have not been looked at in months or years. Often when I go through old tickets I find easy targets: bugs that have already been fixed, duplicates, bugs that are not reproducible and the submitter has gone away. So the idea we have is this: do an incremental sweep of the whole database, starting from the oldest tickets. Check each one, and try to make some progress on it. If we get enough momentum going we can make sure every ticket gets looked at every few months at the least. This is a game for the whole family! We don't care how much progress you make on each ticket, just as long as someone has taken a look and moved the ticket forward in some way. For example, you might check for duplicates, update the metadata, ask for more information from the submitter, try to reproduce the bug against the latest version of GHC. To claim a ticket all you have to do is remove it from the list on the wiki. Full instructions are here http://hackage.haskell.org/trac/ghc/wiki/BugSweep including a list of suggestions for ways to make progress on a ticket. Cheers! Simon & the GHC team From tzz at lifelogs.com Mon Nov 16 11:27:40 2009 From: tzz at lifelogs.com (Ted Zlatanov) Date: Mon Nov 16 11:20:36 2009 Subject: [Haskell-cafe] inversion lists (was: O(n) algorithm for determining subset) References: <26690.208.57.251.240.1258318451.squirrel@mail.alumni.caltech.edu> <5e0214850911151303w686111d8ja20d3cb76c553c5f@mail.gmail.com> Message-ID: <87r5ryigeb.fsf_-_@lifelogs.com> On Mon, 16 Nov 2009 00:03:54 +0300 Eugene Kirpichov wrote: EK> 2009/11/15 Michael Mossey : >> Can someone tell me if this is correct. I'm guessing that if I represent >> two sets of integers by Word32 (where ith bit set means i is in the set), >> then an algorithm to determine if x is a subset of y would go something >> like >> >> >> ?(y - x) == (y `exclusiveOr` x) EK> It's simpler: "x&~y == 0" Depending on the OP data set the simple bit vector may be a good strategy, but I wonder if an inversion list would be better? Do you expect long runs of adjacent numbers and gaps? Inversion lists tend to encode those much more efficiently than bit vectors. I'm just now learning Haskell so I don't know enough to show an implementation but inversion lists are very simple conceptually. If your set is (2,3,4,5,8,9,10) the inversion list would be (2,6,8,11). It's easy to generate it from a set of Ord elements. I'd be curious to see an implementation of the above and other set operations with inversion lists, in fact, so I can learn from it. I couldn't find any implementation online for Haskell. Thanks Ted From spoon at killersmurf.com Mon Nov 16 12:19:30 2009 From: spoon at killersmurf.com (Johnny Morrice) Date: Mon Nov 16 11:55:02 2009 Subject: [Haskell-cafe] Typefuck: Brainfuck in the type system Message-ID: <1258391970.13924.24.camel@utensil> Greetings list, I was um well, drinking beer and thought it would be amusing to write a brainfuck interpreter which runs within the GHC type checker so I did, using type families. I haven't decided whether or not to put it on hackage (it is rather silly after all) but I have a link to a cabalized package and instructions on how to work it in an entry on my blog, here: http://killersmurf.blogspot.com/2009/11/typefuck.html Enjoy the ridiculousness. Johnny From jfredett at gmail.com Mon Nov 16 12:23:56 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Nov 16 11:59:31 2009 Subject: [Haskell-cafe] Typefuck: Brainfuck in the type system In-Reply-To: <1258391970.13924.24.camel@utensil> References: <1258391970.13924.24.camel@utensil> Message-ID: Awesome, however, I don't know what the policy is for such -- interesting -- names on Hackage. Normally I believe the response to "Should I put it on Hackage" is a resounding, immediate "Absolutely." In this case, perhaps a small name change to avoid any possibility of offense? /Joe On Nov 16, 2009, at 12:19 PM, Johnny Morrice wrote: > Greetings list, > > I was um well, drinking beer and thought it would be amusing to > write a > brainfuck interpreter which runs within the GHC type checker so I did, > using type families. > > I haven't decided whether or not to put it on hackage (it is rather > silly after all) but I have a link to a cabalized package and > instructions on how to work it in an entry on my blog, here: > http://killersmurf.blogspot.com/2009/11/typefuck.html > > Enjoy the ridiculousness. > > Johnny > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From gwern0 at gmail.com Mon Nov 16 12:26:42 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Mon Nov 16 12:02:15 2009 Subject: [Haskell-cafe] Typefuck: Brainfuck in the type system In-Reply-To: References: <1258391970.13924.24.camel@utensil> Message-ID: On Mon, Nov 16, 2009 at 12:23 PM, Joe Fredette wrote: > Awesome, however, I don't know what the policy is for such -- interesting -- > names on Hackage. Normally I believe the response to "Should I put it on > Hackage" is a resounding, immediate "Absolutely." In this case, perhaps a > small name change to avoid any possibility of offense? > > /Joe Too late: http://hackage.haskell.org/package/brainfuck http://hackage.haskell.org/package/loli -- gwern From jfredett at gmail.com Mon Nov 16 12:28:40 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Nov 16 12:04:16 2009 Subject: [Haskell-cafe] Typefuck: Brainfuck in the type system In-Reply-To: References: <1258391970.13924.24.camel@utensil> Message-ID: Well then, send it up to the great Hackage machine! If the f-bombs are allowed... I think my package names are about to get alot less SFW... On Nov 16, 2009, at 12:26 PM, Gwern Branwen wrote: > On Mon, Nov 16, 2009 at 12:23 PM, Joe Fredette > wrote: >> Awesome, however, I don't know what the policy is for such -- >> interesting -- >> names on Hackage. Normally I believe the response to "Should I put >> it on >> Hackage" is a resounding, immediate "Absolutely." In this case, >> perhaps a >> small name change to avoid any possibility of offense? >> >> /Joe > > Too late: > http://hackage.haskell.org/package/brainfuck > http://hackage.haskell.org/package/loli > > -- > gwern From jgbailey at gmail.com Mon Nov 16 12:29:45 2009 From: jgbailey at gmail.com (Justin Bailey) Date: Mon Nov 16 12:05:36 2009 Subject: [Haskell-cafe] DSL in Haskell In-Reply-To: <98677.98249.qm@web112508.mail.gq1.yahoo.com> References: <34696.21589.qm@web112513.mail.gq1.yahoo.com> <20091115192754.GB21944@whirlpool.galois.com> <98677.98249.qm@web112508.mail.gq1.yahoo.com> Message-ID: You can find teh BASIC module on hackage: http://hackage.haskell.org/package/BASIC Download .tar.gz file and you can see the source. On Mon, Nov 16, 2009 at 3:16 AM, CK Kashyap wrote: > Thanks Don, > > I read the PDF. I was not able to figure out how to get the BASIC module. > Wanted to see a reference implementation. > > The DSL I want to start with is a music generation DSL ... It should > generate a wave file > with music data as input -> for example the input could contain > C3 D3 E3 ... -> should output a wave file with those notes ... some kind of > mnemonics for tempo will also be there. > Later I'd like to incorporate parallel sequence generation -> where I could > get chord effect etc ... > I had done a rudimentary implementation in C a while back -> > http://kashyap-1978.tripod.com/Escapades/Goodies/Construct_WAV.html > > I'd appreciate it very much if you could give me some pointers on getting > started. > > Regards, > Kashyap > ________________________________ > From: Don Stewart > To: CK Kashyap > Cc: haskell-cafe@haskell.org > Sent: Mon, November 16, 2009 12:57:54 AM > Subject: Re: [Haskell-cafe] DSL in Haskell > > ck_kashyap: >> Hi All, >> I was reading a Ruby book and in that it was mentioned that its capability >> to >> dynamically query and modify classes makes it suitable for implementing >> DSL's >> ... I am referring to Ruby's reflection and methods like "method_missing" >> here. >> It can allow things like not having to define constants for all possible >> unicode code points etc...For example, first use of U0123 could bring such >> a >> constant definition into existence etc >> >> I see multiple search hits when I look for Haskell and DSL - can someone >> please >> point me to a good primer or explain to me how equivalent of above >> mentioned >> features in Ruby can be done in Haskell ... or the Haskell alternative for >> it. > > The Haskell equivalent would be overloading, primarily via type classes. > > See Lennart Augusston's BASIC for an example of this in the extreme: > > > http://augustss.blogspot.com/2009/02/more-basic-not-that-anybody-should-care.html > > That's BASIC syntax, in Haskell, relying on overloading numbers, strings > etc. And all statically typed. > > For a survey of some of the more recent EDSLs in Haskell, see this brief > overview, > > ? ? http://www.galois.com/~dons/papers/stewart-2009-edsls.pdf > > -- Don > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From lemming at henning-thielemann.de Mon Nov 16 12:32:19 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Nov 16 12:08:26 2009 Subject: [Haskell-cafe] unboxed arrays restricted to simple types (Int, Float, ..) In-Reply-To: <78dc001e0911110449r2002f8c7t3a6d4e19a7888329@mail.gmail.com> References: <4AFAA6D4.1070707@rwth-aachen.de> <78dc001e0911110449r2002f8c7t3a6d4e19a7888329@mail.gmail.com> Message-ID: On Wed, 11 Nov 2009, Tom Nielsen wrote: > There's a couple of things going on here: > > -If you use storablevector and storable-tuple, or uvector, you can > store tuples of things. So your stupidArrayElement could be mimicked > by (Int, Int). Btw. there is Data.Array.Storable. Maybe I should just add a conversion from StorableArray to StorableVector and back. From dmehrtash at gmail.com Mon Nov 16 12:49:07 2009 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Mon Nov 16 12:24:38 2009 Subject: [Haskell-cafe] DSL in Haskell In-Reply-To: <98677.98249.qm@web112508.mail.gq1.yahoo.com> References: <34696.21589.qm@web112513.mail.gq1.yahoo.com> <20091115192754.GB21944@whirlpool.galois.com> <98677.98249.qm@web112508.mail.gq1.yahoo.com> Message-ID: Have you seen the Haskell School of Expression book by Paul Hudak? The book is available on line, Ch 9 and 10 talks about music. http://plucky.cs.yale.edu/cs431/HaskoreSoeV-0.7.pdf Daryoush On Mon, Nov 16, 2009 at 3:16 AM, CK Kashyap wrote: > Thanks Don, > > I read the PDF. I was not able to figure out how to get the BASIC module. > Wanted to see a reference implementation. > > The DSL I want to start with is a music generation DSL ... It should > generate a wave file > with music data as input -> for example the input could contain > C3 D3 E3 ... -> should output a wave file with those notes ... some kind of > mnemonics for tempo will also be there. > Later I'd like to incorporate parallel sequence generation -> where I could > get chord effect etc ... > I had done a rudimentary implementation in C a while back -> > http://kashyap-1978.tripod.com/Escapades/Goodies/Construct_WAV.html > > I'd appreciate it very much if you could give me some pointers on getting > started. > > Regards, > Kashyap > ------------------------------ > *From:* Don Stewart > *To:* CK Kashyap > *Cc:* haskell-cafe@haskell.org > *Sent:* Mon, November 16, 2009 12:57:54 AM > *Subject:* Re: [Haskell-cafe] DSL in Haskell > > ck_kashyap: > > Hi All, > > I was reading a Ruby book and in that it was mentioned that its > capability to > > dynamically query and modify classes makes it suitable for implementing > DSL's > > ... I am referring to Ruby's reflection and methods like "method_missing" > here. > > It can allow things like not having to define constants for all possible > > unicode code points etc...For example, first use of U0123 could bring > such a > > constant definition into existence etc > > > > I see multiple search hits when I look for Haskell and DSL - can someone > please > > point me to a good primer or explain to me how equivalent of above > mentioned > > features in Ruby can be done in Haskell ... or the Haskell alternative > for it. > > The Haskell equivalent would be overloading, primarily via type classes. > > See Lennart Augusston's BASIC for an example of this in the extreme: > > > http://augustss.blogspot.com/2009/02/more-basic-not-that-anybody-should-care.html > > That's BASIC syntax, in Haskell, relying on overloading numbers, strings > etc. And all statically typed. > > For a survey of some of the more recent EDSLs in Haskell, see this brief > overview, > > http://www.galois.com/~dons/papers/stewart-2009-edsls.pdf > > -- Don > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091116/78df72cb/attachment.html From lennart at augustsson.net Mon Nov 16 13:15:44 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Mon Nov 16 12:51:17 2009 Subject: [Haskell-cafe] Coercing numeric and string constants In-Reply-To: References: Message-ID: Try with -XExtendedDefaulingRules. On Mon, Nov 16, 2009 at 6:33 AM, Mark Lentczner wrote: > I'm looking for a good way to handle a library interface that accepts both strings and numbers in particular argument positions: > > Start with the following definitions. I've defined ResourceTree as a class here since the details don't matter. > >> data Segment = Key String | Index Int >> ? ? deriving (Eq, Show) >> >> type Path = [Segment] >> >> class ResourceTree a where >> ? ? lookupPath :: Path -> a -> Maybe String > > What I'm after is to make the following code, representative of intended client usage to work: > >> examples :: (ResourceTree a) => a -> [Maybe String] >> examples r = [ >> ? ? ? ? r `at` "status", >> ? ? ? ? r `at` 7, >> ? ? ? ? r `at` "part" ./ "sku", >> ? ? ? ? r `at` "items" ./ 2, >> ? ? ? ? r `at` 7 ./ "name", >> ? ? ? ? r `at` 7 ./ 9 >> ? ? ] > > The first way I thought to do this was with type classes: > >> class ? ?Segmentable a ? ? ? where { toSegment :: a -> Segment } >> instance Segmentable Segment where { toSegment = id } >> instance Segmentable String ?where { toSegment = Key } >> instance Segmentable Int ? ? where { toSegment = Index } >> >> class ? ?Pathable a ? ? ?where { toPath :: a -> Path } >> instance Pathable Path ? where { toPath = id } >> instance Pathable String where { toPath s = [ Key s ] } >> instance Pathable Int ? ?where { toPath i = [ Index i ] } >> >> (./) :: (Segmentable a, Pathable b) => a -> b -> Path >> a ./ b = toSegment a : toPath ?b >> infixr 4 ./ >> >> at :: (ResourceTree a, Pathable b) => a -> b -> Maybe String >> a `at` b = lookupPath (toPath b) a >> infix 2 `at` > > This works great for all uses in the client code where the type of the numeric arguments are known or otherwise forced to be Int. However, when used with numeric constants (as in the function example above), it fails due to the way that numeric constants are defined in Haskell. For example, the constant 9 in example results in this error: > > ? ?Ambiguous type variable `t4' in the constraints: > ? ? ?`Pathable t4' arising from a use of `./' at Test.hs:48:15-20 > ? ? ?`Num t4' arising from the literal `9' at Test.hs:48:20 > ? ?Probable fix: add a type signature that fixes these type variable(s) > > I suppose that even though there is only one type that is both an instance of Num and of Pathable (Int), that can't be deduced with certainty. > > In the client code, one could fix this by typing the constants thus: > >> r `at` (7::Int) ./ (9::Int) > > But to me that makes a hash out of the concise syntax I was trying to achieve. > > Also, this code requires both FlexibleInstances and TypeSynonymInstances pragmas (though the later requirement could be worked around.), though I'm lead to understand that those are common enough. I think also that, these are only needed in the library, not the client code. > > The other way I thought to do this is by making Path and Segment instances of Num and IsString: > >> instance Num ? ? ?Segment where { fromInteger = Index . fromInteger } >> instance IsString Segment where { fromString ?= Key . fromString } >> instance Num ? ? ?Path ? ?where { fromInteger i = [ Index $ fromInteger i ] } >> instance IsString Path ? ?where { fromString ?s = [ Key $ fromString s ] } >> >> (./) :: Segment -> Path -> Path >> a ./ b = ?a : b >> infixr 4 ./ >> >> at :: (ResourceTree a) => a -> Path -> Maybe String >> a `at` b = lookupPath b a >> infix 2 `at` > > This works but has two downsides: 1) Segment and Path are poor instances of Num, eliciting errors for missing methods and resulting in run-time errors should any client code accidentally use them as such. 2) It requires the OverloadedStrings pragma in every client module. > > Any comments on these two approaches would be appreciated, How to improve them? Which is the lesser of two evils? > > On the other hand, I realize that many may object that intended interface isn't very Haskell like. The data object I need to represent (ResourceTree) comes from external input and really does have the strange "paths of strings or integers" construction, I can't change that. And it is expected that much client code will use constant paths to access and manipulate various parts of such objects, hence the desire for a concise operator set that works with constants. Given that there are actually several operations on ResourceTree involving paths (where the operation requires the whole Path as a single value), any thoughts on a more Haskell like construction? > > Thanks, > ? ? ? ?- MtnViewMark > > > Mark Lentczner > http://www.ozonehouse.com/mark/ > mark@glyphic.com > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ck_kashyap at yahoo.com Mon Nov 16 13:35:14 2009 From: ck_kashyap at yahoo.com (CK Kashyap) Date: Mon Nov 16 13:13:18 2009 Subject: [Haskell-cafe] DSL in Haskell In-Reply-To: References: <34696.21589.qm@web112513.mail.gq1.yahoo.com> <20091115192754.GB21944@whirlpool.galois.com> <98677.98249.qm@web112508.mail.gq1.yahoo.com> Message-ID: <544194.35386.qm@web112502.mail.gq1.yahoo.com> Thank you very very much Daryoush ... I had not seen the book ... Looks pretty interesting, I saw it mentioning Midi though ... Thank you Justin for the location of the BASIC module. Regards, Kashyap ________________________________ From: Daryoush Mehrtash To: CK Kashyap Cc: Don Stewart ; haskell-cafe@haskell.org Sent: Mon, November 16, 2009 11:19:07 PM Subject: Re: [Haskell-cafe] DSL in Haskell Have you seen the Haskell School of Expression book by Paul Hudak? The book is available on line, Ch 9 and 10 talks about music. http://plucky.cs.yale.edu/cs431/HaskoreSoeV-0.7.pdf Daryoush On Mon, Nov 16, 2009 at 3:16 AM, CK Kashyap wrote: Thanks Don, > >I read the PDF. I was not able to figure out how to get the BASIC module. Wanted to see a reference implementation. > >The DSL I want to start with is a music generation DSL ... It should generate a wave file >with music data as input -> for example the input could contain >C3 D3 E3 ... -> should output a wave file with those notes ... some kind of mnemonics for tempo will also be there. >>Later I'd like to incorporate parallel sequence generation -> where I could get chord effect etc ... >I had done a rudimentary implementation in C a while back -> >http://kashyap-1978.tripod.com/Escapades/Goodies/Construct_WAV.html > >I'd appreciate > it very much if you could give me some pointers on getting started. > > >Regards, >Kashyap > > ________________________________ From: Don Stewart >To: CK Kashyap >Cc: haskell-cafe@haskell.org >Sent: Mon, November 16, 2009 12:57:54 AM >Subject: Re: [Haskell-cafe] DSL in Haskell > > >>ck_kashyap: >> Hi All, >> I was reading a Ruby book and in that it was mentioned that its capability to >> dynamically query and modify classes makes it suitable for implementing DSL's >> ... I am referring to Ruby's reflection and methods like "method_missing" here. >>> It can allow things like not having to define constants for all possible >> unicode code points etc...For example, first use of U0123 could bring such a >> constant definition into existence etc >> >>> I see multiple search hits when I look for Haskell and DSL - can someone please >> point me to a good primer or explain to me how equivalent of above mentioned >> features in Ruby can be done in Haskell ... or the Haskell alternative for it. > >The Haskell equivalent would be overloading, primarily via type classes. > >See Lennart Augusston's BASIC for an example of this in the extreme: > > http://augustss.blogspot.com/2009/02/more-basic-not-that-anybody-should-care.html > >That's BASIC syntax, in Haskell, relying on overloading numbers, strings >etc. And all statically typed. > >For a survey of some of the more recent EDSLs in Haskell, see this brief >overview, > > http://www.galois.com/%7Edons/papers/stewart-2009-edsls.pdf > >-- Don > > >_______________________________________________ >>Haskell-Cafe mailing list >Haskell-Cafe@haskell.org >http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091116/7d4d8a28/attachment.html From ekmett at gmail.com Mon Nov 16 14:15:40 2009 From: ekmett at gmail.com (Edward Kmett) Date: Mon Nov 16 13:51:11 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <5e0214850911151004i69dcfb5cp232d671d04ab0733@mail.gmail.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> <200911150751.35942.anotheraddress@gmx.de> <1258286496-sup-1347@peray> <200911151510.38621.anotheraddress@gmx.de> <5e0214850911151004i69dcfb5cp232d671d04ab0733@mail.gmail.com> Message-ID: <7fb8f82f0911161115m385361bcj7f1cf88cafe57d15@mail.gmail.com> 2009/11/15 Eugene Kirpichov > Hey, I've found terrific slides about monoids! > > http://comonad.com/reader/wp-content/uploads/2009/08/IntroductionToMonoids.pdf > Edward Kmett, you rock! > Glad you enjoyed the slides. =) > There's more http://comonad.com/reader/2009/iteratees-parsec-and-monoid/ > - but the second part was too hard for me to read it fully without > special motivation. > The iteratees, parsec and monoids talk was mostly to solve a technical problem of my own. The result is a way to build parallel parsers that works quite well for most practical programming language grammars, but requires you to think about parsing a bit sideways and requires a lot of machinery from other areas to make work. In essence I rely on the fact that in programming languages we typically have a point at which we can resume parsing, or at least lexing, in a context-free manner by locating global invariants of the grammar. These invariants are typically already present and are used to provide error productions in real world compiler grammars, so that the compiler can try to resume parsing. It is a hack, but it is a reasonably efficient hack. =) To make it work, I have to borrow a lot of machinery from other areas. Iteratees give me a resumable parser, giving that access to its input history lets it backtrack, which lets me bolt them onto parsec, so you can write parsers the way you are used to, at least for the tokens in your language, and then you add a layer on top to deal with the token-stream, which is now available to be reduced monoidally rather than just sequentially. What I was looking for was a good understanding of what invariants would it make sense to design a language to have so that it could be efficiently parsed in parallel and incrementally reparsed as the user types without having to rescan the whole source file. -Edward Kmett -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091116/0b51a469/attachment.html From michael at snoyman.com Mon Nov 16 14:39:14 2009 From: michael at snoyman.com (Michael Snoyman) Date: Mon Nov 16 14:14:48 2009 Subject: [Haskell-cafe] ANNOUNCE: control-monad-failure and safe-failure Message-ID: <29bf512f0911161139y181eeb4w53ad59ab133c4731@mail.gmail.com> Folks, We are extremely happy to announce the control-monad-failure and safe-failure packages for error handling. control-monad-failure provides a basic notion of failure which does not commit to any concrete representation. It is just a version of the MonadError class without the annoying bits. > class MonadFailure e m where failure :: e -> m a Instances are provided for several concrete representations of failure handling: Maybe, Either, ErrorT, Control.Exception.Throw, and []. safe-failure is a fork of Neil Mitchell's Safe package providing MonadFailure versions of several partial functions in the Prelude, which instead of failing with a runtime error fail with Failure. > head :: MonadFailure HeadFailure m => [a] -> m a This is a joint release from the authors of the attempt and the control-monad-exception packages, and accompanying releases of those packages have been made making them adopt the MonadFailure interface. We have also created a wiki page explaining our reasons for following this path in: http://www.haskellwiki.org/Failure Thanks, Jose Iborra, Nicolas Pouillard and Michael Snoyman -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091116/344767b8/attachment.html From ekirpichov at gmail.com Mon Nov 16 14:40:54 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Mon Nov 16 14:16:31 2009 Subject: [Haskell-cafe] ANNOUNCE: control-monad-failure and safe-failure In-Reply-To: <29bf512f0911161139y181eeb4w53ad59ab133c4731@mail.gmail.com> References: <29bf512f0911161139y181eeb4w53ad59ab133c4731@mail.gmail.com> Message-ID: <5e0214850911161140k4aad8b2ewf32b89518eaf8354@mail.gmail.com> Correction: the correct link is http://www.haskell.org/haskellwiki/Failure 2009/11/16 Michael Snoyman : > Folks, > > We are extremely happy to announce the control-monad-failure and > safe-failure packages for error handling. > > control-monad-failure provides a basic notion of failure which does not > commit to any concrete representation. > It is just a version of the MonadError class without the annoying bits. > >> class MonadFailure e m where failure :: e -> m a > > Instances are provided for several concrete representations of failure > handling: Maybe, Either, ErrorT, Control.Exception.Throw, and []. > > safe-failure is a fork of Neil Mitchell's Safe package providing > MonadFailure versions of several partial functions > in the Prelude, which instead of failing with a runtime error fail with > Failure. > >> head :: MonadFailure HeadFailure m => [a] -> m a > > This is a joint release from the authors of the attempt and the > control-monad-exception packages, > and accompanying releases of those packages have been made making them adopt > the MonadFailure interface. > We have also created a wiki page explaining our reasons for following this > path in: > > ?http://www.haskellwiki.org/Failure > > > Thanks, > Jose Iborra, Nicolas Pouillard and Michael Snoyman > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Eugene Kirpichov Web IR developer, market.yandex.ru From gcross at phys.washington.edu Mon Nov 16 14:45:52 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Mon Nov 16 14:21:34 2009 Subject: [Haskell-cafe] Could someone teach me why we use Data.Monoid? In-Reply-To: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> References: <3bd412d40911130814y3c449479s83af2e34cdc6b23a@mail.gmail.com> Message-ID: <3093C303-6B29-4D00-B6F1-FA6D6F14354C@phys.washington.edu> In my own opinion, the reason why we use the concept of a monoid or a monad is in order to build libraries around the concepts. For example, the "do" construct could have been designed just for doing IO, but because it works for *any* monad you can also use the same syntax sugar to conveniently work with a calculation *) that manipulates a mutable state (State) *) that has an environment (Reader) *) that writes out a log (Writer) Likewise, the nice thing about monoid is that it lets us generalize libraries. So for example, the Writer monad could have just been designed to work by concatenating strings or lists since this is what one might typically think of for a "log". But because it is designed to work with an arbitrary *monoid*, you could use it to keep track of a running total as well, since numbers under addition is also a monoid. So the way I figure it, the important thing is to understand just enough of these patterns (monads, monoids) that you can recognize them when they come up in your own work so that you can be aware of what pre-existing libraries and/or syntax sugar you can leverage to work with them. Cheers, Greg On Nov 13, 2009, at 8:14 AM, Magicloud Magiclouds wrote: > Hi, > I have looked the concept of monoid and something related, but > still, I do not know why we use it? > > -- > ??????? > ??????? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From gue.schmidt at web.de Mon Nov 16 15:15:44 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Nov 16 14:51:45 2009 Subject: [Haskell-cafe] Howto start a bigger project Message-ID: Hi all, I'm stuck with a problem where I need serious help from other haskellers, in particular those that participate here on this list. It's a rather big project and I will need to set it up in an organized way, something with a blog, web page or other means. I tried to solve it by myself while asking the occasional question here but that turned out to be ineefective. The problem as such is certainly of interest for just about any programmer who is using Haskell for real world programming too. In short, to get started I'd appreciate some tips how to set this up. G?nther From seanmcl at gmail.com Mon Nov 16 15:27:55 2009 From: seanmcl at gmail.com (Sean McLaughlin) Date: Mon Nov 16 15:03:45 2009 Subject: [Haskell-cafe] ghci + user prelude Message-ID: <6579f8680911161227k599f6188k694187b2f19782af@mail.gmail.com> Hello, If there's a file called Prelude.hs in a directory, and ghci is started from that directory, ghci dies. -- Prelude.hs module A.Prelude where $ ghci GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. : module `Prelude' is not loaded Is there a way around this? I often like to have a modified Prelude file in a subdirectory of my project, and this behavior keeps me from being able to start ghci there. Thanks! Sean From michael at snoyman.com Mon Nov 16 15:28:30 2009 From: michael at snoyman.com (Michael Snoyman) Date: Mon Nov 16 15:04:04 2009 Subject: [Haskell-cafe] ANNOUNCE: attempt Message-ID: <29bf512f0911161228v3a392249n7d7b54af659e334a@mail.gmail.com> We'd like to announce the second release (version 0.0.1) of the attempt package, for handling of failures. This release has been made to work with the new control-monad-failure package[1] in an effort to standardize failure handling. Notable changes to this release: * The MonadAttempt class was fully redundant with MonadFailure, and has thus been removed. * WrapFailure class has been moved to control-monad-failure (with minor modifications). * Data.Attempt.Helper (safe versions of some functions) has been moved to safe-failure[2]. * Full support for the monadloc package[3] to get monadic stack traces. As usual, this release is available on hackage[4]. API stability cannot be guaranteed with this release as well, but we're getting much closer to hitting the mark. All the best, Michael Snoyman, Nicolas Pouillard 1. http://hackage.haskell.org/package/control-monad-failure 2. http://hackage.haskell.org/package/safe-failure 3. http://hackage.haskell.org/package/monadloc 4. http://hackage.haskell.org/package/attempt -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091116/78e23ad9/attachment.html From lrpalmer at gmail.com Mon Nov 16 15:29:41 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Nov 16 15:05:11 2009 Subject: [Haskell-cafe] Howto start a bigger project In-Reply-To: References: Message-ID: <7ca3f0160911161229u12320332l62981ea711af9005@mail.gmail.com> Ummm..... what is it? 2009/11/16 G?nther Schmidt : > Hi all, > > I'm stuck with a problem where I need serious help from other haskellers, in > particular those that participate here on this list. It's a rather big > project and I will need to set it up in an organized way, something with a > blog, web page or other means. > > I tried to solve it by myself while asking the occasional question here but > that turned out to be ineefective. The problem as such is certainly of > interest for just about any programmer who is using Haskell for real world > programming too. > > In short, to get started I'd appreciate some tips how to set this up. > > G?nther > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From caseyh at istar.ca Mon Nov 16 15:30:51 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Mon Nov 16 15:06:14 2009 Subject: [Haskell-cafe] Howto start a bigger project In-Reply-To: References: Message-ID: What is this big project about? Why not use www.sourceforge.net? On Mon, 16 Nov 2009 21:15:44 +0100, you wrote: >Hi all, > >I'm stuck with a problem where I need serious help from other haskellers, >in particular those that participate here on this list. It's a rather big >project and I will need to set it up in an organized way, something with a >blog, web page or other means. > >I tried to solve it by myself while asking the occasional question here >but that turned out to be ineefective. The problem as such is certainly of >interest for just about any programmer who is using Haskell for real world >programming too. > >In short, to get started I'd appreciate some tips how to set this up. > >G?nther > -- Regards, Casey From bulat.ziganshin at gmail.com Mon Nov 16 15:43:49 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Nov 16 15:19:31 2009 Subject: [Haskell-cafe] Howto start a bigger project In-Reply-To: References: Message-ID: <1145102339.20091116234349@gmail.com> Hello Casey, Monday, November 16, 2009, 11:30:51 PM, you wrote: > Why not use www.sourceforge.net? i strongly recommend http://code.google.com or http://codeplex.com SF is slow and olf-fashioned -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ezyang at MIT.EDU Mon Nov 16 15:46:58 2009 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Mon Nov 16 15:22:48 2009 Subject: [Haskell-cafe] ghci + user prelude In-Reply-To: <6579f8680911161227k599f6188k694187b2f19782af@mail.gmail.com> References: <6579f8680911161227k599f6188k694187b2f19782af@mail.gmail.com> Message-ID: <1258404357-sup-7094@ezyang> Excerpts from Sean McLaughlin's message of Mon Nov 16 15:27:55 -0500 2009: > Is there a way around this? I often like to have a modified Prelude > file in a subdirectory of my project, and this behavior keeps me from > being able to start ghci there. http://www.haskell.org/haskellwiki/No_import_of_Prelude Cheers, Edward From ezyang at MIT.EDU Mon Nov 16 15:48:36 2009 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Mon Nov 16 15:24:16 2009 Subject: [Haskell-cafe] ANNOUNCE: control-monad-failure and safe-failure In-Reply-To: <29bf512f0911161139y181eeb4w53ad59ab133c4731@mail.gmail.com> References: <29bf512f0911161139y181eeb4w53ad59ab133c4731@mail.gmail.com> Message-ID: <1258404461-sup-1666@ezyang> Excerpts from Michael Snoyman's message of Mon Nov 16 14:39:14 -0500 2009: > control-monad-failure provides a basic notion of failure which does not > commit to any concrete representation. > It is just a version of the MonadError class without the annoying bits. Excellent! I've used MonadError in the past and it has been a little... warty; looking forward to using control-monad-failure for future projects. Cheers, Edward From michael at snoyman.com Mon Nov 16 15:51:33 2009 From: michael at snoyman.com (Michael Snoyman) Date: Mon Nov 16 15:27:05 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: attempt In-Reply-To: <29bf512f0911161228v3a392249n7d7b54af659e334a@mail.gmail.com> References: <29bf512f0911161228v3a392249n7d7b54af659e334a@mail.gmail.com> Message-ID: <29bf512f0911161251uea6239yf550a0c530720222@mail.gmail.com> Correction: that's version 0.0.2 that was just release. On Mon, Nov 16, 2009 at 10:28 PM, Michael Snoyman wrote: > We'd like to announce the second release (version 0.0.1) of the attempt > package, for handling of failures. This release has been made to work with > the new control-monad-failure package[1] in an effort to standardize failure > handling. > > Notable changes to this release: > * The MonadAttempt class was fully redundant with MonadFailure, and has > thus been removed. > * WrapFailure class has been moved to control-monad-failure (with minor > modifications). > * Data.Attempt.Helper (safe versions of some functions) has been moved to > safe-failure[2]. > * Full support for the monadloc package[3] to get monadic stack traces. > > As usual, this release is available on hackage[4]. API stability cannot be > guaranteed with this release as well, but we're getting much closer to > hitting the mark. > > All the best, > Michael Snoyman, Nicolas Pouillard > > 1. http://hackage.haskell.org/package/control-monad-failure > 2. http://hackage.haskell.org/package/safe-failure > 3. http://hackage.haskell.org/package/monadloc > 4. http://hackage.haskell.org/package/attempt > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091116/a9fe4b6b/attachment.html From korpios at korpios.com Mon Nov 16 15:55:58 2009 From: korpios at korpios.com (Tom Tobin) Date: Mon Nov 16 15:31:30 2009 Subject: [Haskell-cafe] Howto start a bigger project In-Reply-To: <1145102339.20091116234349@gmail.com> References: <1145102339.20091116234349@gmail.com> Message-ID: On Mon, Nov 16, 2009 at 2:43 PM, Bulat Ziganshin wrote: > Hello Casey, > > Monday, November 16, 2009, 11:30:51 PM, you wrote: > >> Why not use www.sourceforge.net? > > i strongly recommend http://code.google.com or http://codeplex.com > SF is slow and olf-fashioned If you like distributed version control: git: GitHub, http://github.com/ (my favorite, since I'm a git addict) mercurial: BitBucket, http://bitbucket.org/ (or Google Code, these days) darcs: Patch-Tag, http://patch-tag.com/ bazaar: Launchpad, https://launchpad.net/ From gue.schmidt at web.de Mon Nov 16 15:56:09 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Nov 16 15:31:41 2009 Subject: [Haskell-cafe] Howto start a bigger project In-Reply-To: <7ca3f0160911161229u12320332l62981ea711af9005@mail.gmail.com> References: <7ca3f0160911161229u12320332l62981ea711af9005@mail.gmail.com> Message-ID: Hi Luke, creating an EDSL for abstract terms in Relational Algebra, which can then be either compiled to SQL or evaluated to in-memory code. The closest thing I've seen and used so far is HaskellDB, but it immediately compiles to SQL, while I want to leave that part flexible. G?nther Am 16.11.2009, 21:29 Uhr, schrieb Luke Palmer : > Ummm..... what is it? > > 2009/11/16 G?nther Schmidt : >> Hi all, >> >> I'm stuck with a problem where I need serious help from other >> haskellers, in >> particular those that participate here on this list. It's a rather big >> project and I will need to set it up in an organized way, something >> with a >> blog, web page or other means. >> >> I tried to solve it by myself while asking the occasional question here >> but >> that turned out to be ineefective. The problem as such is certainly of >> interest for just about any programmer who is using Haskell for real >> world >> programming too. >> >> In short, to get started I'd appreciate some tips how to set this up. >> >> G?nther >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> From andrewcoppin at btinternet.com Mon Nov 16 16:37:45 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Nov 16 16:13:12 2009 Subject: [Haskell-cafe] Howto start a bigger project In-Reply-To: References: Message-ID: <4B01C629.1030102@btinternet.com> G?nther Schmidt wrote: > Hi all, > > I'm stuck with a problem where I need serious help from other > haskellers, in particular those that participate here on this list. > It's a rather big project and I will need to set it up in an organized > way, something with a blog, web page or other means. > > I tried to solve it by myself while asking the occasional question > here but that turned out to be ineefective. The problem as such is > certainly of interest for just about any programmer who is using > Haskell for real world programming too. > > In short, to get started I'd appreciate some tips how to set this up. In my experience, getting people interested in helping is usually a far bigger problem. YMMV. From hjgtuyl at chello.nl Mon Nov 16 17:05:43 2009 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Mon Nov 16 16:41:16 2009 Subject: [Haskell-cafe] DSL in Haskell In-Reply-To: References: <34696.21589.qm@web112513.mail.gq1.yahoo.com> <20091115192754.GB21944@whirlpool.galois.com> <98677.98249.qm@web112508.mail.gq1.yahoo.com> Message-ID: The most recent version of this book is http://plucky.cs.yale.edu/cs431/HaskoreSoeV-0.12.pdf (See http://plucky.cs.yale.edu/cs431/reading.htm ) Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html -- On Mon, 16 Nov 2009 18:49:07 +0100, Daryoush Mehrtash wrote: > Have you seen the Haskell School of Expression book by Paul Hudak? > > The book is available on line, Ch 9 and 10 talks about music. > > http://plucky.cs.yale.edu/cs431/HaskoreSoeV-0.7.pdf > > Daryoush > > > > On Mon, Nov 16, 2009 at 3:16 AM, CK Kashyap wrote: > >> Thanks Don, >> >> I read the PDF. I was not able to figure out how to get the BASIC >> module. >> Wanted to see a reference implementation. >> >> The DSL I want to start with is a music generation DSL ... It should >> generate a wave file >> with music data as input -> for example the input could contain >> C3 D3 E3 ... -> should output a wave file with those notes ... some >> kind of >> mnemonics for tempo will also be there. >> Later I'd like to incorporate parallel sequence generation -> where I >> could >> get chord effect etc ... >> I had done a rudimentary implementation in C a while back -> >> http://kashyap-1978.tripod.com/Escapades/Goodies/Construct_WAV.html >> >> I'd appreciate it very much if you could give me some pointers on >> getting >> started. >> >> Regards, >> Kashyap >> ------------------------------ >> *From:* Don Stewart >> *To:* CK Kashyap >> *Cc:* haskell-cafe@haskell.org >> *Sent:* Mon, November 16, 2009 12:57:54 AM >> *Subject:* Re: [Haskell-cafe] DSL in Haskell >> >> ck_kashyap: >> > Hi All, >> > I was reading a Ruby book and in that it was mentioned that its >> capability to >> > dynamically query and modify classes makes it suitable for >> implementing >> DSL's >> > ... I am referring to Ruby's reflection and methods like >> "method_missing" >> here. >> > It can allow things like not having to define constants for all >> possible >> > unicode code points etc...For example, first use of U0123 could bring >> such a >> > constant definition into existence etc >> > >> > I see multiple search hits when I look for Haskell and DSL - can >> someone >> please >> > point me to a good primer or explain to me how equivalent of above >> mentioned >> > features in Ruby can be done in Haskell ... or the Haskell alternative >> for it. >> >> The Haskell equivalent would be overloading, primarily via type classes. >> >> See Lennart Augusston's BASIC for an example of this in the extreme: >> >> >> http://augustss.blogspot.com/2009/02/more-basic-not-that-anybody-should-care.html >> >> That's BASIC syntax, in Haskell, relying on overloading numbers, strings >> etc. And all statically typed. >> >> For a survey of some of the more recent EDSLs in Haskell, see this brief >> overview, >> >> http://www.galois.com/~dons/papers/stewart-2009-edsls.pdf >> >> -- Don >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> -- From roma at ro-che.info Mon Nov 16 17:16:28 2009 From: roma at ro-che.info (Roman Cheplyaka) Date: Mon Nov 16 16:52:39 2009 Subject: [Haskell-cafe] Announcing the GHC Bug Sweep In-Reply-To: <4B017DFA.2060207@gmail.com> References: <4B017DFA.2060207@gmail.com> Message-ID: <20091116221628.GA24597@flit> Cool, I'm in! (Also inspired by [1]this post by Erik de Castro Lopo) It would be nice to keep track of participants somewhere, so that each of us knows he's not alone :) 1. http://www.mega-nerd.com/erikd/Blog/CodeHacking/DDC/hacking_ddc.html * Simon Marlow [2009-11-16 16:29:46+0000] > Help us weed the GHC ticket database, and get a warm fuzzy feeling from > contributing to Haskell core technology! > > There are currently ~750 tickets against GHC. Many of them have not been > looked at in months or years. Often when I go through old tickets I find > easy targets: bugs that have already been fixed, duplicates, bugs that are > not reproducible and the submitter has gone away. > > So the idea we have is this: do an incremental sweep of the whole > database, starting from the oldest tickets. Check each one, and try to > make some progress on it. If we get enough momentum going we can make > sure every ticket gets looked at every few months at the least. > > This is a game for the whole family! We don't care how much progress you > make on each ticket, just as long as someone has taken a look and moved > the ticket forward in some way. For example, you might check for > duplicates, update the metadata, ask for more information from the > submitter, try to reproduce the bug against the latest version of GHC. > > To claim a ticket all you have to do is remove it from the list on the > wiki. Full instructions are here > > http://hackage.haskell.org/trac/ghc/wiki/BugSweep > > including a list of suggestions for ways to make progress on a ticket. -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From mlesniak at uni-kassel.de Mon Nov 16 17:32:04 2009 From: mlesniak at uni-kassel.de (Michael Lesniak) Date: Mon Nov 16 17:07:35 2009 Subject: [Haskell-cafe] Announcing the GHC Bug Sweep In-Reply-To: <20091116221628.GA24597@flit> References: <4B017DFA.2060207@gmail.com> <20091116221628.GA24597@flit> Message-ID: <5f8b37690911161432g30454862rf428f172f618e5b3@mail.gmail.com> Hello, I'm also interested and find Roman's idea about a wiki-page for tracking motivating. >> So the idea we have is this: do an incremental sweep of the whole >> database, starting from the oldest tickets. ?Check each one, and try to >> make some progress on it. ?If we get enough momentum going we can make >> sure every ticket gets looked at every few months at the least. What I'd really like to see is a kind of categorization according to the topic, difficulty etc.... I think determing these things could be quite difficult for a GHC newbie (e.g. me). Any plans to do this? Kind regards, Michael -- Dipl.-Inf. Michael C. Lesniak University of Kassel Programming Languages / Methodologies Research Group Department of Computer Science and Electrical Engineering Wilhelmsh?her Allee 73 34121 Kassel Phone: +49-(0)561-804-6269 From spoon at killersmurf.com Mon Nov 16 17:36:41 2009 From: spoon at killersmurf.com (Johnny Morrice) Date: Mon Nov 16 17:12:12 2009 Subject: [Haskell-cafe] Typefuck: Brainfuck in the type system In-Reply-To: References: <1258391970.13924.24.camel@utensil> Message-ID: <1258411001.11382.21.camel@utensil> My personal opinion is that such f-bombs really have no place on what is a font of software dissemination. My point of view is a fallacy however. Consider a new, viable programming language which has a syntax based entirely on GG-Allin lyrics. Obviously this would disgust a decent programmer (aren't we all decent :) One would be pressed to prove that this new language has no scientific value only in order to avoid his disgusting poetry, which could be difficult (and perhaps pointless, which would be worse than difficult) But I think I am fuzzing out beyond what the point of this originally was... yes - this discussion reminds me of both Wadler's law and the phenomenon of Cargo Cults, as according to the Wiki Wiki web (see http://c2.com/cgi/wiki?CargoCult) -- what I mean by this is that however it might be labelled on a software archive, such a program is surely and deeply ****ed. Johnny On Mon, 2009-11-16 at 12:28 -0500, Joe Fredette wrote: > Well then, send it up to the great Hackage machine! If the f-bombs are > allowed... > > I think my package names are about to get alot less SFW... > > > > On Nov 16, 2009, at 12:26 PM, Gwern Branwen wrote: > > > On Mon, Nov 16, 2009 at 12:23 PM, Joe Fredette > > wrote: > >> Awesome, however, I don't know what the policy is for such -- > >> interesting -- > >> names on Hackage. Normally I believe the response to "Should I put > >> it on > >> Hackage" is a resounding, immediate "Absolutely." In this case, > >> perhaps a > >> small name change to avoid any possibility of offense? > >> > >> /Joe > > > > Too late: > > http://hackage.haskell.org/package/brainfuck > > http://hackage.haskell.org/package/loli > > > > -- > > gwern > From gue.schmidt at web.de Mon Nov 16 18:25:18 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Nov 16 18:01:13 2009 Subject: [Haskell-cafe] Re: Howto start a bigger project References: Message-ID: Hi all, I don't think the *project* is ready for sourceforge or similar yet. I was thinking more about something bloggish first, where I could state some thoughts first and where people could then comment or otherwise contribute. I reckon it will be some time until the project needs a code repository, I'd need something first where I can sketch the whole thing and collect ideas. G?nther From korpios at korpios.com Mon Nov 16 18:28:22 2009 From: korpios at korpios.com (Tom Tobin) Date: Mon Nov 16 18:03:58 2009 Subject: [Haskell-cafe] Re: Howto start a bigger project In-Reply-To: References: Message-ID: 2009/11/16 G?nther Schmidt : > Hi all, > > I don't think the *project* is ready for sourceforge or similar yet. I was > thinking more about something bloggish first, where I could state some > thoughts first and where people could then comment or otherwise contribute. > > I reckon it will be some time until the project needs a code repository, I'd > need something first where I can sketch the whole thing and collect ideas. If you don't have a repository that people can grab and play with, it's going to be hard to attract interest. Even if the code is awful or totally broken, at least it's something your prospective audience can grab and play with. A blog without code won't do much, IMHO. From gcross at phys.washington.edu Mon Nov 16 18:50:03 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Mon Nov 16 18:25:33 2009 Subject: [Haskell-cafe] Re: Howto start a bigger project In-Reply-To: References: Message-ID: <254C9C9B-26D2-4A7D-AE7E-FD2CF9EEA10C@phys.washington.edu> If all you are looking for is a place to chat about and garner feedback on your ideas for a new Haskell library, then why don't you just tell *us* what's on your mind? :-) I mean, we've just spent 37 posts talking about monoids in the last 48 hours, so we aren't exactly an unopinionated and reticent crowd. :-) - Greg On Nov 16, 2009, at 3:25 PM, G?nther Schmidt wrote: > Hi all, > > I don't think the *project* is ready for sourceforge or similar yet. > I was thinking more about something bloggish first, where I could > state some thoughts first and where people could then comment or > otherwise contribute. > > I reckon it will be some time until the project needs a code > repository, I'd need something first where I can sketch the whole > thing and collect ideas. > > G?nther > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From james at neurogami.com Mon Nov 16 18:58:37 2009 From: james at neurogami.com (James Britt) Date: Mon Nov 16 18:34:24 2009 Subject: [Haskell-cafe] Howto start a bigger project In-Reply-To: References: Message-ID: <4B01E72D.3010002@neurogami.com> G?nther Schmidt wrote: > Hi all, > > I'm stuck with a problem where I need serious help from other > haskellers, in particular those that participate here on this list. It's > a rather big project and I will need to set it up in an organized way, > something with a blog, web page or other means. > > I tried to solve it by myself while asking the occasional question here > but that turned out to be ineefective. The problem as such is certainly > of interest for just about any programmer who is using Haskell for real > world programming too. > > In short, to get started I'd appreciate some tips how to set this up. Create a project on github.com. It makes it dead easy for people to try out code and submit patches. Do enough work so that the code is useful, even if the implementation is crap. In fact, a crappy implementation may be a good thing; it makes it easier for people to find something to contribute. And then they feel a part of the project. Version 0.0.1 has to work right out of the box, be easy to install, be stupid obvious to use, and have non-zero value. Promises mean nothing. So, in practice, you need to start a really small project that could maybe become big but doesn't have to in order to be valuable right now. I've ended up as a committer on more than a few projects because the code solved a real problem in a simple and good enough way that I did not feel the need to go roll my own. And when I encountered a bug or wanted a feature, it was easy to contribute. But, key to all this, is getting people to feel they have a vested interest in the project succeeding, and that can be tricky. James -- Neurogami - Smart application development http://www.neurogami.com james@neurogami.com From greenspan.levi at googlemail.com Mon Nov 16 19:02:19 2009 From: greenspan.levi at googlemail.com (Levi Greenspan) Date: Mon Nov 16 18:37:52 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? Message-ID: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> What's the status of the TDNR proposal [1]? Personally I think it is a very good idea and I'd like to see it in Haskell'/GHC rather sooner than later. Working around the limitations of the current record system is one of my biggest pain points in Haskell and TDNR would be a major improvement. Thus I wonder if someone is actively working on this proposal? Thanks, Levi. ---------------- [1] http://hackage.haskell.org/trac/haskell-prime/wiki/TypeDirectedNameResolution From seanmcl at gmail.com Mon Nov 16 19:06:06 2009 From: seanmcl at gmail.com (Sean McLaughlin) Date: Mon Nov 16 18:41:56 2009 Subject: [Haskell-cafe] ghci + user prelude In-Reply-To: <1258404357-sup-7094@ezyang> References: <6579f8680911161227k599f6188k694187b2f19782af@mail.gmail.com> <1258404357-sup-7094@ezyang> Message-ID: <6579f8680911161606u7447356fkae637674b29666b1@mail.gmail.com> Hi. I'm aware of this option, and use it frequently to override the default prelude, but it doesn't help this problem: $ ghci -XNoImplicitPrelude GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. : module `Prelude' is not loaded On Mon, Nov 16, 2009 at 3:46 PM, Edward Z. Yang wrote: > Excerpts from Sean McLaughlin's message of Mon Nov 16 15:27:55 -0500 2009: >> Is there a way around this? ?I often like to have a modified Prelude >> file in a subdirectory of my project, and this behavior keeps me from >> being able to start ghci there. > > http://www.haskell.org/haskellwiki/No_import_of_Prelude > > Cheers, > Edward > From gue.schmidt at web.de Mon Nov 16 19:42:54 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Nov 16 19:18:25 2009 Subject: [Haskell-cafe] Re: Howto start a bigger project In-Reply-To: <254C9C9B-26D2-4A7D-AE7E-FD2CF9EEA10C@phys.washington.edu> References: <254C9C9B-26D2-4A7D-AE7E-FD2CF9EEA10C@phys.washington.edu> Message-ID: Hi Greg, you folks sure aren't, but I'm so bloody disorganized, I'll never it right this way. G?nther Am 17.11.2009, 00:50 Uhr, schrieb Gregory Crosswhite : > If all you are looking for is a place to chat about and garner feedback > on your ideas for a new Haskell library, then why don't you just tell > *us* what's on your mind? :-) > > I mean, we've just spent 37 posts talking about monoids in the last 48 > hours, so we aren't exactly an unopinionated and reticent crowd. :-) > > - Greg > > On Nov 16, 2009, at 3:25 PM, G?nther Schmidt wrote: > >> Hi all, >> >> I don't think the *project* is ready for sourceforge or similar yet. I >> was thinking more about something bloggish first, where I could state >> some thoughts first and where people could then comment or otherwise >> contribute. >> >> I reckon it will be some time until the project needs a code >> repository, I'd need something first where I can sketch the whole thing >> and collect ideas. >> >> G?nther >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > From caseyh at istar.ca Mon Nov 16 19:46:08 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Mon Nov 16 19:21:32 2009 Subject: [Haskell-cafe] Howto start a bigger project In-Reply-To: <1145102339.20091116234349@gmail.com> References: <1145102339.20091116234349@gmail.com> Message-ID: <1gs3g5tp2t7cb463e1l9qj12shgc9oiv5j@4ax.com> On Mon, 16 Nov 2009 23:43:49 +0300, you wrote: >Hello Casey, > >Monday, November 16, 2009, 11:30:51 PM, you wrote: > >> Why not use www.sourceforge.net? > >i strongly recommend http://code.google.com or http://codeplex.com >SF is slow and olf-fashioned Just because a Scandinavian started it, doesn't mean its ___-fashioned, somehow! :) -- Regards, Casey From duncan.coutts at googlemail.com Mon Nov 16 19:46:52 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Mon Nov 16 19:22:24 2009 Subject: [Haskell-cafe] creating documentation links failed with cabal install --haddock-options=--hyperlink-source. is this a bug? In-Reply-To: <910ddf450910310845v2785163andb3a1a016711361c@mail.gmail.com> References: <910ddf450910310845v2785163andb3a1a016711361c@mail.gmail.com> Message-ID: <1258418812.4896.5129.camel@localhost> On Sat, 2009-10-31 at 10:45 -0500, Thomas Hartman wrote: > cabal haddock -?hyperlink-source > > installs documentation with links to source code, which also be on by defualt. > > cabal install ?haddock-options=?hyperlink source > > does not install hyperlinked source. This is an instance of the lack of the feature described in this ticket: http://hackage.haskell.org/trac/hackage/ticket/517 BTW, you're getting confused between flags for the "cabal haddock" command and the "haddock" command. The --hyperlink-source flag is for the "cabal haddock" command. The haddock tool has no such flag (or anything equivalent) so using --haddock-options= will not help. Duncan From duncan.coutts at googlemail.com Mon Nov 16 19:49:03 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Mon Nov 16 19:24:35 2009 Subject: [Haskell-cafe] C headers in cabal dependencies In-Reply-To: References: Message-ID: <1258418943.4896.5137.camel@localhost> On Wed, 2009-10-28 at 17:34 -0200, Maur??cio CA wrote: > Hi, > > I've been using 'install-includes' in a package. I sometimes make > small changes to those include files, and I've seen that cabal > doesn't consider then dependencies, i.e., doesn't rebuild .hsc > files depending on then. > > I'm not sure if this is an error, as parsing hsc2hs input may > not be cabal task. Anyway, I would like to suggest that files in > install-includes be considered dependencies and that files under > 'includes' be also included when processing '.hsc' files. This is an instance of the long standing lack of module/file dependency tracking in Cabal: http://hackage.haskell.org/trac/hackage/ticket/15 Duncan From duncan.coutts at googlemail.com Mon Nov 16 19:51:10 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Mon Nov 16 19:26:43 2009 Subject: [Haskell-cafe] How much time until dependencies are rebuilt in hackage? In-Reply-To: <20091114193113.GB24850@kira.casa> References: <20091114193113.GB24850@kira.casa> Message-ID: <1258419070.4896.5145.camel@localhost> On Sat, 2009-11-14 at 17:31 -0200, Felipe Lessa wrote: > On Sat, Nov 14, 2009 at 01:47:04PM -0200, Maur??cio CA wrote: > > Suppose package B depends on A. If a new > > version of A is uploaded to hackage, how much > > later package B will be rebuilt (either to show > > a problem with the new version or to solve a > > problem with a previous version of A)? > > I would guess "never", but don't quote me on that ;). That's the correct answer! People who think this is a bad state of affairs can help out with the new server implementation (code.haskell.org/hackage-server). Duncan From gue.schmidt at web.de Mon Nov 16 19:54:22 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Nov 16 19:30:24 2009 Subject: [Haskell-cafe] Re: Howto start a bigger project References: <4B01E72D.3010002@neurogami.com> Message-ID: Hi James, it's still very very far away from even a single line of code. I'd need a medium to lay this out first and discuss the idea. I'd normaly use this list, but I think it's a bit too volatile a medium for that. Most of the time I'm unable to find the threads I was interested in ever again, or with a great deal of pain. The *project* at this stage is academic / R & D in nature. G?nther Am 17.11.2009, 00:58 Uhr, schrieb James Britt : > G?nther Schmidt wrote: > > Hi all, > > > > I'm stuck with a problem where I need serious help from other > > haskellers, in particular those that participate here on this list. > It's > > a rather big project and I will need to set it up in an organized way, > > something with a blog, web page or other means. > > > > I tried to solve it by myself while asking the occasional question > here > > but that turned out to be ineefective. The problem as such is > certainly > > of interest for just about any programmer who is using Haskell for > real > > world programming too. > > > > In short, to get started I'd appreciate some tips how to set this up. > > Create a project on github.com. It makes it dead easy for people to try > out code and submit patches. > > Do enough work so that the code is useful, even if the implementation is > crap. > > In fact, a crappy implementation may be a good thing; it makes it easier > for people to find something to contribute. And then they feel a part > of the project. > > Version 0.0.1 has to work right out of the box, be easy to install, be > stupid obvious to use, and have non-zero value. Promises mean nothing. > > So, in practice, you need to start a really small project that could > maybe become big but doesn't have to in order to be valuable right now. > > I've ended up as a committer on more than a few projects because the > code solved a real problem in a simple and good enough way that I did > not feel the need to go roll my own. And when I encountered a bug or > wanted a feature, it was easy to contribute. > > But, key to all this, is getting people to feel they have a vested > interest in the project succeeding, and that can be tricky. > > > James > From stian at gressugle.com Mon Nov 16 20:14:49 2009 From: stian at gressugle.com (Stian H. Johannesen) Date: Mon Nov 16 19:50:24 2009 Subject: [Haskell-cafe] Re: Howto start a bigger project In-Reply-To: References: <4B01E72D.3010002@neurogami.com> Message-ID: <4B01F909.3000504@gressugle.com> Why not just create a wiki? - S On 17.11.2009 01:54, G?nther Schmidt wrote: > Hi James, > > it's still very very far away from even a single line of code. I'd > need a medium to lay this out first and discuss the idea. I'd normaly > use this list, but I think it's a bit too volatile a medium for that. > Most of the time I'm unable to find the threads I was interested in > ever again, or with a great deal of pain. > > The *project* at this stage is academic / R & D in nature. > > G?nther > > > Am 17.11.2009, 00:58 Uhr, schrieb James Britt : > >> G?nther Schmidt wrote: >> > Hi all, >> > >> > I'm stuck with a problem where I need serious help from other >> > haskellers, in particular those that participate here on this list. >> It's >> > a rather big project and I will need to set it up in an organized way, >> > something with a blog, web page or other means. >> > >> > I tried to solve it by myself while asking the occasional question >> here >> > but that turned out to be ineefective. The problem as such is >> certainly >> > of interest for just about any programmer who is using Haskell for >> real >> > world programming too. >> > >> > In short, to get started I'd appreciate some tips how to set this up. >> >> Create a project on github.com. It makes it dead easy for people to >> try out code and submit patches. >> >> Do enough work so that the code is useful, even if the implementation >> is crap. >> >> In fact, a crappy implementation may be a good thing; it makes it >> easier for people to find something to contribute. And then they >> feel a part of the project. >> >> Version 0.0.1 has to work right out of the box, be easy to install, >> be stupid obvious to use, and have non-zero value. Promises mean >> nothing. >> >> So, in practice, you need to start a really small project that could >> maybe become big but doesn't have to in order to be valuable right now. >> >> I've ended up as a committer on more than a few projects because the >> code solved a real problem in a simple and good enough way that I >> did not feel the need to go roll my own. And when I encountered a >> bug or wanted a feature, it was easy to contribute. >> >> But, key to all this, is getting people to feel they have a vested >> interest in the project succeeding, and that can be tricky. >> >> >> James >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jmillikin at gmail.com Mon Nov 16 21:38:42 2009 From: jmillikin at gmail.com (John Millikin) Date: Mon Nov 16 21:14:12 2009 Subject: [Haskell-cafe] ANNOUNCE: gnome-keyring 0.1 (bindings to libgnome-keyring) Message-ID: <3283f7fe0911161838s2c6d0485l4dc08f494f505a8d@mail.gmail.com> The GNOME Keyring is a service for securely storing per-user secret information, such as passwords and encryption keys, on the GNOME desktop. This library is a binding to the libgnome-keyring C library. The API is still a bit too slave-ish to the original for my taste, some modules will be changing/merging in the next version. The innards are an absolute horror -- don't look too close if you're one of those people who faint at rampant unsafe casting. That said, it works surprisingly well for a first-release FFI binding -- mostly due to the excellent design of libgnome-keyring and c2hs. So if any Linux/BSD/OpenSolaris/etc users have needed secure password storage in Haskell, please try it out and let me know if you encounter any problems. Download: http://hackage.haskell.org/package/gnome-keyring/ API docs (copy of original library docs): https://dl.dropbox.com/u/1947532/gnome-keyring_0.1/index.html From jason.dusek at gmail.com Mon Nov 16 21:54:07 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Mon Nov 16 21:29:35 2009 Subject: [Haskell-cafe] ANN: wcwidth-0.0.1 Message-ID: <42784f260911161854s2cf3d41aj54d8c29facf3190c@mail.gmail.com> A small package with bindings to a function in that assigns a column width to Unicode characters. http://hackage.haskell.org/package/wcwidth-0.0.1 This is the function that tells your terminal to make Chinese characters two columns wide while making the letter 'a' but one column wide. In addition, a little utility is provided that constructs a table of widths by character and a listing of character ranges with the same width. On different systems, `wcwidth` may assign different widths to the same character for some obscure characters. -- Jason Dusek From tphyahoo at gmail.com Mon Nov 16 23:19:52 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Mon Nov 16 22:55:21 2009 Subject: [Haskell-cafe] Howto start a bigger project In-Reply-To: References: Message-ID: <910ddf450911162019t4d1c79e3tb9fe39dedfcf9cf9@mail.gmail.com> How about patch-tag? It's built with haskell (happstack), and one of its founding goals is to promote the use of haskell in real world so you're sure to be surrounded by like minded people. And wikis are about to go live so you could help beta test that feature too :) thomas. Am 16. November 2009 12:15 schrieb G?nther Schmidt : > Hi all, > > I'm stuck with a problem where I need serious help from other haskellers, > in particular those that participate here on this list. It's a rather big > project and I will need to set it up in an organized way, something with a > blog, web page or other means. > > I tried to solve it by myself while asking the occasional question here but > that turned out to be ineefective. The problem as such is certainly of > interest for just about any programmer who is using Haskell for real world > programming too. > > In short, to get started I'd appreciate some tips how to set this up. > > G?nther > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091116/62660a58/attachment.html From noel.kalman at googlemail.com Tue Nov 17 01:47:14 2009 From: noel.kalman at googlemail.com (Kalman Noel) Date: Tue Nov 17 01:22:34 2009 Subject: [Haskell-cafe] ANNOUNCE: control-monad-failure and safe-failure In-Reply-To: References: Message-ID: <4B0246F2.2090002@googlemail.com> Michael Snoyman schrieb: > control-monad-failure provides a basic notion of failure which does not > commit to any concrete representation. > It is just a version of the MonadError class without the annoying bits. > >> class MonadFailure e m where failure :: e -> m a Why is it called "MonadFailure" (specifically, what's the "Monad" bit doing there)? From nicolas.pouillard at gmail.com Tue Nov 17 04:46:16 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Tue Nov 17 04:21:47 2009 Subject: [Haskell-cafe] ANNOUNCE: control-monad-failure and safe-failure In-Reply-To: <4B0246F2.2090002@googlemail.com> References: <4B0246F2.2090002@googlemail.com> Message-ID: <1258451060-sup-8619@peray> Excerpts from Kalman Noel's message of Tue Nov 17 07:47:14 +0100 2009: > Michael Snoyman schrieb: > > control-monad-failure provides a basic notion of failure which does not > > commit to any concrete representation. > > It is just a version of the MonadError class without the annoying bits. > > > >> class MonadFailure e m where failure :: e -> m a > > Why is it called "MonadFailure" (specifically, what's the "Monad" bit doing > there)? Because of 'Monad m' being a superclass of 'MonadFailure e m'. Here is the class: class Monad m => MonadFailure e m where ??failure :: e -> m a -- Nicolas Pouillard http://nicolaspouillard.fr From marlowsd at gmail.com Tue Nov 17 06:00:21 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Tue Nov 17 05:36:04 2009 Subject: [Haskell-cafe] ANNOUNCE: deepseq-1.0.0.0 Message-ID: <4B028245.1080201@gmail.com> I've just uploaded deepseq-1.0.0.0 to Hackage http://hackage.haskell.org/package/deepseq This provides a DeepSeq class with a deepseq method, equivalent to the existing NFData/rnf in the parallel package. I'll be using this in a newly revamped parallel package, which I hope to upload shortly. Cheers, Simon From vandijk.roel at gmail.com Tue Nov 17 06:04:37 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Tue Nov 17 05:40:06 2009 Subject: [Haskell-cafe] ANNOUNCE: deepseq-1.0.0.0 In-Reply-To: <4B028245.1080201@gmail.com> References: <4B028245.1080201@gmail.com> Message-ID: On Tue, Nov 17, 2009 at 12:00 PM, Simon Marlow wrote: > I've just uploaded deepseq-1.0.0.0 to Hackage This is great! I often use rnf to fully evaluate some expression where I didn't need parallelism at all. Time to update some packages. Thank you, Roel From jpm at cs.uu.nl Tue Nov 17 06:16:57 2009 From: jpm at cs.uu.nl (=?ISO-8859-1?Q?Jos=E9_Pedro_Magalh=E3es?=) Date: Tue Nov 17 05:52:49 2009 Subject: [Haskell-cafe] ANNOUNCE: deepseq-1.0.0.0 In-Reply-To: References: <4B028245.1080201@gmail.com> Message-ID: <52f14b210911170316t3257d84el97494704fc213d29@mail.gmail.com> Hello, The release of the regular library for generic programming on Hackage [1] also contains a form of deep seq [2]. This means that you don't even have to write the definition of 'deepseq', you can just use 'gdseq' (assuming you have used Template Haskell to derive the generic representations for your types). Cheers, Pedro [1] http://hackage.haskell.org/package/regular [2] http://hackage.haskell.org/packages/archive/regular/0.2.1/doc/html/Generics-Regular-Functions-Seq.html#t%3ASeq On Tue, Nov 17, 2009 at 12:04, Roel van Dijk wrote: > On Tue, Nov 17, 2009 at 12:00 PM, Simon Marlow wrote: >> I've just uploaded deepseq-1.0.0.0 to Hackage > > This is great! I often use rnf to fully evaluate some expression where > I didn't need parallelism at all. Time to update some packages. > > Thank you, > Roel > _______________________________________________ > Libraries mailing list > Libraries@haskell.org > http://www.haskell.org/mailman/listinfo/libraries > From noel.kalman at googlemail.com Tue Nov 17 06:55:54 2009 From: noel.kalman at googlemail.com (Kalman Noel) Date: Tue Nov 17 06:31:07 2009 Subject: [Haskell-cafe] ANNOUNCE: control-monad-failure and safe-failure In-Reply-To: <1258451060-sup-8619@peray> References: <4B0246F2.2090002@googlemail.com> <1258451060-sup-8619@peray> Message-ID: <4B028F4A.3090105@googlemail.com> Nicolas Pouillard schrieb: >>>> class MonadFailure e m where failure :: e -> m a >> Why is it called "MonadFailure" (specifically, what's the "Monad" bit doing >> there)? > > Because of 'Monad m' being a superclass of 'MonadFailure e m'. > > Here is the class: > class Monad m => MonadFailure e m where > failure :: e -> m a Oh ok; I misguidedly took the line at the top to be the class definition. I'd still be interested if such a simple Failure class could be meaningful or useful for mere, say, Applicatives. From nicolas.pouillard at gmail.com Tue Nov 17 07:18:07 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Tue Nov 17 06:53:35 2009 Subject: [Haskell-cafe] ANNOUNCE: control-monad-failure and safe-failure In-Reply-To: <4B028F4A.3090105@googlemail.com> References: <4B0246F2.2090002@googlemail.com> <1258451060-sup-8619@peray> <4B028F4A.3090105@googlemail.com> Message-ID: <1258460245-sup-6638@peray> Excerpts from Kalman Noel's message of Tue Nov 17 12:55:54 +0100 2009: > Nicolas Pouillard schrieb: > >>>> class MonadFailure e m where failure :: e -> m a > >> Why is it called "MonadFailure" (specifically, what's the "Monad" bit doing > >> there)? > > > > Because of 'Monad m' being a superclass of 'MonadFailure e m'. > > > > Here is the class: > > class Monad m => MonadFailure e m where > > failure :: e -> m a > > Oh ok; I misguidedly took the line at the top to be the class definition. I'd > still be interested if such a simple Failure class could be meaningful or > useful for mere, say, Applicatives. I think it is meaningful. -- Nicolas Pouillard http://nicolaspouillard.fr From simonpj at microsoft.com Tue Nov 17 07:18:11 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Tue Nov 17 06:53:44 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> Message-ID: <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> | What's the status of the TDNR proposal [1]? Personally I think it is a | very good idea and I'd like to see it in Haskell'/GHC rather sooner | than later. Working around the limitations of the current record | system is one of my biggest pain points in Haskell and TDNR would be a | major improvement. Thus I wonder if someone is actively working on | this proposal? It's stalled. As far as I know, there's been very little discussion about it. It's not a trivial thing to implement, and it treads on delicate territory (how "." is treated). So I'd need to be convinced there was a strong constituency who really wanted it before adding it. I've added an informal straw poll to the bottom of [1] to allow you to express an opinion. Also I'm not very happy with the "stacking operations" part, and I'd like a better idea. Simon From matthijs at stdin.nl Tue Nov 17 07:22:38 2009 From: matthijs at stdin.nl (Matthijs Kooijman) Date: Tue Nov 17 06:58:08 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> Message-ID: <20091117122238.GQ3418@katherina.student.utwente.nl> > I've added an informal straw poll to the bottom of [1] to allow you to express an opinion. [1]: ? -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091117/bfb97352/attachment.bin From nicolas.pouillard at gmail.com Tue Nov 17 07:25:14 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Tue Nov 17 07:00:42 2009 Subject: [Haskell-cafe] ANNOUNCE: deepseq-1.0.0.0 In-Reply-To: <4B028245.1080201@gmail.com> References: <4B028245.1080201@gmail.com> Message-ID: <1258460604-sup-9104@peray> Excerpts from Simon Marlow's message of Tue Nov 17 12:00:21 +0100 2009: > I've just uploaded deepseq-1.0.0.0 to Hackage Great! I'm wondering what is the need/purpose for DeepSeqIntegral and DeepSeqOrd? -- Nicolas Pouillard http://nicolaspouillard.fr From simonpj at microsoft.com Tue Nov 17 07:29:05 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Tue Nov 17 07:04:36 2009 Subject: FW: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? Message-ID: <59543203684B2244980D7E4057D5FBC1084F9638@DB3EX14MBXC310.europe.corp.microsoft.com> [Resending, this time with link; sorry] | What's the status of the TDNR proposal [1]? Personally I think it is a | very good idea and I'd like to see it in Haskell'/GHC rather sooner | than later. Working around the limitations of the current record | system is one of my biggest pain points in Haskell and TDNR would be a | major improvement. Thus I wonder if someone is actively working on | this proposal? It's stalled. As far as I know, there's been very little discussion about it. It's not a trivial thing to implement, and it treads on delicate territory (how "." is treated). So I'd need to be convinced there was a strong constituency who really wanted it before adding it. I've added an informal straw poll to the bottom of [1] to allow you to express an opinion. Also I'm not very happy with the "stacking operations" part, and I'd like a better idea. Simon [1] http://hackage.haskell.org/trac/haskell-prime/wiki/TypeDirectedNameResolution From nccb2 at kent.ac.uk Tue Nov 17 07:33:00 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Tue Nov 17 07:08:10 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> Message-ID: <4B0297FC.3000702@kent.ac.uk> Simon Peyton-Jones wrote: > | What's the status of the TDNR proposal [1]? > > It's stalled. As far as I know, there's been very little discussion about it. It's not a trivial thing to implement, and it treads on delicate territory (how "." is treated). Having skimmed the page, it seems like the re-use of "." is one of the major difficulties of the proposal. Would it be possible to use "->"? It has been used for accessing members in C and C++, so it is not too unusual a choice. It is already special in Haskell so it wouldn't break anyone's code -- but do its other uses (case statements and lambdas) mean that it would cause problems in the grammar if re-used for TDNR? Neil. From magnus at therning.org Tue Nov 17 07:41:40 2009 From: magnus at therning.org (Magnus Therning) Date: Tue Nov 17 07:17:09 2009 Subject: [Haskell-cafe] ANNOUNCE: gnome-keyring 0.1 (bindings to libgnome-keyring) In-Reply-To: <3283f7fe0911161838s2c6d0485l4dc08f494f505a8d@mail.gmail.com> References: <3283f7fe0911161838s2c6d0485l4dc08f494f505a8d@mail.gmail.com> Message-ID: Excellent. It seems that my sit-back-and-wait approach is slowly resulting in all the libraries required to rewrite my old (Python) password storage tool are being put into place :-) /M On Tue, Nov 17, 2009 at 2:38 AM, John Millikin wrote: > The GNOME Keyring is a service for securely storing per-user secret > information, such as passwords and encryption keys, on the GNOME > desktop. This library is a binding to the libgnome-keyring C library. > > The API is still a bit too slave-ish to the original for my taste, > some modules will be changing/merging in the next version. The innards > are an absolute horror -- don't look too close if you're one of those > people who faint at rampant unsafe casting. > > That said, it works surprisingly well for a first-release FFI binding > -- mostly due to the excellent design of libgnome-keyring and c2hs. > > So if any Linux/BSD/OpenSolaris/etc users have needed secure password > storage in Haskell, please try it out and let me know if you encounter > any problems. > Download: http://hackage.haskell.org/package/gnome-keyring/ > API docs (copy of original library docs): > https://dl.dropbox.com/u/1947532/gnome-keyring_0.1/index.html > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From duncan.coutts at googlemail.com Tue Nov 17 09:00:58 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Tue Nov 17 08:36:28 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: deepseq-1.0.0.0 In-Reply-To: <4B028245.1080201@gmail.com> References: <4B028245.1080201@gmail.com> Message-ID: <1258466458.4896.7785.camel@localhost> On Tue, 2009-11-17 at 11:00 +0000, Simon Marlow wrote: > I've just uploaded deepseq-1.0.0.0 to Hackage > > http://hackage.haskell.org/package/deepseq > > This provides a DeepSeq class with a deepseq method, equivalent to the > existing NFData/rnf in the parallel package. I'll be using this in a > newly revamped parallel package, which I hope to upload shortly. Yay, you get to be the first person to try out the new platform package proposal process! http://trac.haskell.org/haskell-platform/wiki/AddingPackages (because it's a new dependency of a platform package) Duncan From paradoja at gmail.com Tue Nov 17 09:29:03 2009 From: paradoja at gmail.com (=?UTF-8?Q?Abby_Henr=C3=ADquez_Tejera?=) Date: Tue Nov 17 09:04:31 2009 Subject: [Haskell-cafe] Little errors in number calculations In-Reply-To: References: <82792530911141300v189555e2j7289317760190bd@mail.gmail.com> Message-ID: <82792530911170629l65c21acat9c53f06babdf8d3c@mail.gmail.com> It's curious that Hugs "lies"... Thanks for the answers :) . 2009/11/15 Lennart Augustsson : > Hugs is wrong, as you can easily see by evaluating > ? let x = 123.35503 * 10.0 in x == read (show x) > With ghc it comes out as True and with Hugs as False. > > ?-- Lennart > > On Sat, Nov 14, 2009 at 9:00 PM, Abby Henr?quez Tejera > wrote: >> Hi. >> >> I've seen that in GHC sometimes there are little errors in some basic >> number calculations: >> >> *Prelude> 123.35503 * 10.0 >> 1233.5502999999999 >> >> *Prelude> properFraction 123.35503 >> (123,0.3550299999999993) >> >> whereas in Hugs no such errors seem to occur (that I have found, at >> least): >> >> *Hugs> 123.35503 * 10.0 >> 1233.5503 >> >> (but:) >> >> *Hugs> properFraction 123.35503 >> (123,0.355029999999999) >> >> I understand that error may (and will) happen in floating point, but >> it surprises me that they do so easily, and, above all, the difference >> between GHC and Hugs. Does someone know why does this difference >> occur? >> >> (Thanks in advance, by the way :) ). >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From greenspan.levi at googlemail.com Tue Nov 17 09:36:52 2009 From: greenspan.levi at googlemail.com (Levi Greenspan) Date: Tue Nov 17 09:12:23 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> Message-ID: <3e62d4360911170636m6329e590n9bb5756711b8e8bf@mail.gmail.com> On Tue, Nov 17, 2009 at 1:18 PM, Simon Peyton-Jones wrote: > | What's the status of the TDNR proposal [1]? Personally I think it is a > | very good idea and I'd like to see it in Haskell'/GHC rather sooner > | than later. Working around the limitations of the current record > | system is one of my biggest pain points in Haskell and TDNR would be a > | major improvement. Thus I wonder if someone is actively working on > | this proposal? > > It's stalled. ?As far as I know, there's been very little discussion about it. ?It's not a trivial thing to implement, and it treads on delicate territory (how "." is treated). ?So I'd need to be convinced there was a strong constituency who really wanted it before adding it. Well, implementing certain protocols (e.g. based on JSON, like Bayeux [1]) in a type-safe way requires lots of records and many of these records have similar selectors, e.g. channel. Currently one can only have a nice interface to such a protocol by using type classes and creating lots of instance declarations, which is a lot of boilerplate to be written. This would be much easier with TDNR, than with module-scoped record selectors. Also the hack to use different modules is further complicated by the fact that at least GHC insists on having each module in a separate file. As pointed out by others one may choose a different string instead of "." like "->" if this makes the implementation of TDNR feasible. But some mechanism to have some sort of scoped record selectors or TDNR is needed in my opinion. Many thanks, Levi -------- [1] http://svn.cometd.org/trunk/bayeux/bayeux.html > > I've added an informal straw poll to the bottom of [1] to allow you to express an opinion. > > Also I'm not very happy with the "stacking operations" part, and I'd like a better idea. > > Simon > > From greenspan.levi at googlemail.com Tue Nov 17 10:24:42 2009 From: greenspan.levi at googlemail.com (Levi Greenspan) Date: Tue Nov 17 10:00:10 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> Message-ID: <3e62d4360911170724k4e26a4ffg2231d41badc9668b@mail.gmail.com> On Tue, Nov 17, 2009 at 1:18 PM, Simon Peyton-Jones wrote: > I've added an informal straw poll to the bottom of [1] to allow you to express an opinion. Forgive my ignorance, but I can not find a way to edit the wiki page. What am I doing wrong? Cheers, Levi From daniel.is.fischer at web.de Tue Nov 17 10:52:17 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Nov 17 10:29:11 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <3e62d4360911170636m6329e590n9bb5756711b8e8bf@mail.gmail.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> <3e62d4360911170636m6329e590n9bb5756711b8e8bf@mail.gmail.com> Message-ID: <200911171652.18136.daniel.is.fischer@web.de> Am Dienstag 17 November 2009 15:36:52 schrieb Levi Greenspan: > As pointed out by others one may choose a different string instead of > "." like "->" ?if this makes the implementation of TDNR feasible. Or, if both of these strings would make the implementation awkward, one can choose a different but similar, "~>", "-->" (to annoy bad syntax highlighters 8-)), which is neither special in Haskell syntax nor a prominent operator from a library. I wouldn't lay much stress on using the same notation as other languages. After all, we have (/=) instead of (!=) and it works. > But some mechanism to have some sort of scoped record selectors or TDNR is > needed in my opinion. I haven't needed the feature yet, but I think it would be A Good Thing? to have it. From leather at cs.uu.nl Tue Nov 17 11:14:16 2009 From: leather at cs.uu.nl (Sean Leather) Date: Tue Nov 17 10:50:05 2009 Subject: [Haskell-cafe] How to show record syntax? Message-ID: <3c6288ab0911170814n1bbb3e08n6f139064796f32c8@mail.gmail.com> A while back, I was working on the Show function for EMGM [1] and verifying its output vs. that of GHC's when I discovered (I thought) a minor difference between what was necessary and what GHC did for record syntax. Labeled construction and update, according to the Report [2], have higher precedence than function application. This means that I can do the following > module Main where > data A = A {x :: Int} deriving Show > main = print $ Just A {x = 5} without putting parentheses around A {x = 5}. If I run this in GHCi, *Main> main Just (A {x = 5}) I see that the derived show in GHC adds parentheses around the record value. This led to an issue report [3] which developed a few responses. Some don't like the grammar as defined, because, at a glance, it appears too much like function application. Others noted that Hugs does not add the parentheses and wanted to see consistency between compilers. In the spirit of the GHC Bug Sweep [4] and finding resolution, I put the question to the wider community. How should we show record syntax? Should we try to ensure consistency between the compilers? Should we try to print as few parentheses as possible? Should we write a Haskell' proposal to "fix" the grammar and make Just A {x=5} illegal? What do you think? [1] http://hackage.haskell.org/packages/archive/emgm/0.3.1/doc/html/Generics-EMGM-Functions-Show.html [2] http://www.haskell.org/onlinereport/exps.html#sect3 [3] http://hackage.haskell.org/trac/ghc/ticket/2530 [4] http://hackage.haskell.org/trac/ghc/wiki/BugSweep Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091117/450a2dce/attachment.html From bos at serpentine.com Tue Nov 17 11:36:47 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Tue Nov 17 11:12:16 2009 Subject: [Haskell-cafe] ANNOUNCE: deepseq-1.0.0.0 In-Reply-To: <4B028245.1080201@gmail.com> References: <4B028245.1080201@gmail.com> Message-ID: On Tue, Nov 17, 2009 at 3:00 AM, Simon Marlow wrote: > I've just uploaded deepseq-1.0.0.0 to Hackage > > http://hackage.haskell.org/package/deepseq > > This provides a DeepSeq class with a deepseq method, equivalent to the > existing NFData/rnf in the parallel package. > > If it's equivalent, what are the relevant differences? Why would I choose DeepSeq over NFData or vice versa? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091117/580f4fdf/attachment.html From lrpalmer at gmail.com Tue Nov 17 12:08:10 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Nov 17 11:43:38 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> Message-ID: <7ca3f0160911170908x6085255bvcae15b05fd8178c0@mail.gmail.com> On Tue, Nov 17, 2009 at 5:18 AM, Simon Peyton-Jones wrote: > | What's the status of the TDNR proposal [1]? Personally I think it is a > | very good idea and I'd like to see it in Haskell'/GHC rather sooner > | than later. Working around the limitations of the current record > | system is one of my biggest pain points in Haskell and TDNR would be a > | major improvement. Thus I wonder if someone is actively working on > | this proposal? > > It's stalled. ?As far as I know, there's been very little discussion about it. ?It's not a trivial thing to implement, and it treads on delicate territory (how "." is treated). ?So I'd need to be convinced there was a strong constituency who really wanted it before adding it. > > I've added an informal straw poll to the bottom of [1] to allow you to express an opinion. And how I love expressing my opinion :-P. I would if only I could figure out how to edit the page! Am I being dense? (Yes, I am logged in) Luke > Also I'm not very happy with the "stacking operations" part, and I'd like a better idea. > > Simon > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From duncan.coutts at googlemail.com Tue Nov 17 12:46:07 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Tue Nov 17 12:21:42 2009 Subject: [Haskell-cafe] How to show record syntax? In-Reply-To: <3c6288ab0911170814n1bbb3e08n6f139064796f32c8@mail.gmail.com> References: <3c6288ab0911170814n1bbb3e08n6f139064796f32c8@mail.gmail.com> Message-ID: <1258479967.4896.8727.camel@localhost> On Tue, 2009-11-17 at 17:14 +0100, Sean Leather wrote: > > module Main where > > data A = A {x :: Int} deriving Show > > main = print $ Just A {x = 5} > This led to an issue report [3] which developed a few responses. Some > don't like the grammar as defined, because, at a glance, it appears > too much like function application. Others noted that Hugs does not > add the parentheses and wanted to see consistency between compilers. > > In the spirit of the GHC Bug Sweep [4] and finding resolution, I put > the question to the wider community. How should we show record syntax? > Should we try to ensure consistency between the compilers? Should we > try to print as few parentheses as possible? Should we write a > Haskell' proposal to "fix" the grammar and make Just A {x=5} illegal? > What do you think? If you want my opinion, I think consistency between the compilers is probably a good thing. I do not have a very strong opinion on whether the derived Show instances should use the extra brackets here or not. Just pick one. The Show output is not readable in the first place so it does not really matter. However I am opposed to "fixing" the grammar to add lots of unnecessary brackets and to make my programs uglier. Using records for the named function argument idiom is rather nice and should be encouraged not discouraged by making the syntax for it worse. bigChunkyCallWithLotsOfArgs defaultArgs { someArg = 3, someOtherArg = 4, } Lovely! bigChunkyCallWithLotsOfArgs (defaultArgs { someArg = 3, someOtherArg = 4, }) Bleugh! Duncan From simonpj at microsoft.com Tue Nov 17 13:01:51 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Tue Nov 17 12:37:26 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <7ca3f0160911170908x6085255bvcae15b05fd8178c0@mail.gmail.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> <7ca3f0160911170908x6085255bvcae15b05fd8178c0@mail.gmail.com> Message-ID: <59543203684B2244980D7E4057D5FBC1084FAE72@DB3EX14MBXC310.europe.corp.microsoft.com> Sigh. Apologies. Turns out that [1] is not publicly editable. So I've created a HaskellWiki page [2] and cross-linked them. [2] http://haskell.org/haskellwiki/TypeDirectedNameResolution You should be able to edit that! Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On | Behalf Of Luke Palmer | Sent: 17 November 2009 17:08 | To: Simon Peyton-Jones | Cc: Levi Greenspan; Haskell Cafe | Subject: Re: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? | | On Tue, Nov 17, 2009 at 5:18 AM, Simon Peyton-Jones | wrote: | > | What's the status of the TDNR proposal [1]? Personally I think it is a | > | very good idea and I'd like to see it in Haskell'/GHC rather sooner | > | than later. Working around the limitations of the current record | > | system is one of my biggest pain points in Haskell and TDNR would be a | > | major improvement. Thus I wonder if someone is actively working on | > | this proposal? | > | > It's stalled. ?As far as I know, there's been very little discussion about it. | ?It's not a trivial thing to implement, and it treads on delicate territory (how "." | is treated). ?So I'd need to be convinced there was a strong constituency who really | wanted it before adding it. | > | > I've added an informal straw poll to the bottom of [1] to allow you to express an | opinion. | | And how I love expressing my opinion :-P. I would if only I could | figure out how to edit the page! Am I being dense? (Yes, I am logged | in) | | Luke | | > Also I'm not very happy with the "stacking operations" part, and I'd like a better | idea. | > | > Simon | > | > | > _______________________________________________ | > 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 From allbery at ece.cmu.edu Tue Nov 17 13:42:52 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Nov 17 13:18:35 2009 Subject: [Haskell-cafe] ANNOUNCE: deepseq-1.0.0.0 In-Reply-To: References: <4B028245.1080201@gmail.com> Message-ID: <09552E18-4CAF-4C90-83E6-468631B90F31@ece.cmu.edu> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20091117/b0f21666/PGP.bin From nowgate at yahoo.com Tue Nov 17 14:16:50 2009 From: nowgate at yahoo.com (michael rice) Date: Tue Nov 17 13:52:18 2009 Subject: [Haskell-cafe] Simple hash table creation Message-ID: <563306.28011.qm@web31102.mail.mud.yahoo.com> I'm trying to create a hash table. Yeah, I know, don't use hash tables, but I need to create something I'm familiar with, not something I've never worked with before. What's wrong with this code? Michael ==================== import Prelude hiding (lookup) import Data.HashTable data MyHashTable = HashTable String Int dummy:: String -> Int dummy s = 7 ht = MyHashTable.new (==) dummy ==================== [michael@localhost ~]$ ghci hash1 GHCi, version 6.10.3: http://www.haskell.org/ghc/? :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. [1 of 1] Compiling Main???????????? ( hash1.hs, interpreted ) hash1.hs:9:5: Not in scope: `MyHashTable.new' Failed, modules loaded: none. Prelude> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091117/70b4f674/attachment.html From doug at cs.dartmouth.edu Tue Nov 17 14:20:38 2009 From: doug at cs.dartmouth.edu (Doug McIlroy) Date: Tue Nov 17 13:56:05 2009 Subject: [Haskell-cafe] omitting params in function bindings Message-ID: <200911171920.nAHJKcqE017428@tecumseh.cs.dartmouth.edu> Is there a deep reason (beyond saving a sentence or two in the language definition) for requiring all patterns in a function binding to have the same explicit arity? For example, in dropWhile0 :: Num a => [a] -> [a] dropWhile0 (0:xs) = dropWhile0 xs dropWhile0 xs = xs why shouldn't the last line be replaceable by dropWhile0 = id From bulat.ziganshin at gmail.com Tue Nov 17 14:27:49 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Nov 17 14:05:24 2009 Subject: [Haskell-cafe] Simple hash table creation In-Reply-To: <563306.28011.qm@web31102.mail.mud.yahoo.com> References: <563306.28011.qm@web31102.mail.mud.yahoo.com> Message-ID: <1778632758.20091117222749@gmail.com> Hello michael, Tuesday, November 17, 2009, 10:16:50 PM, you wrote: > I'm trying to create a hash table. Yeah, I know, don't use hash > tables, but I need to create something I'm familiar with, not > something I've never worked with before. What's wrong with this code? > ht = MyHashTable.new (==) dummy MyHashTable should be a name of module. seems that you try to use your OOP instinct here :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From daniel.is.fischer at web.de Tue Nov 17 14:36:46 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Nov 17 14:13:38 2009 Subject: [Haskell-cafe] Simple hash table creation In-Reply-To: <563306.28011.qm@web31102.mail.mud.yahoo.com> References: <563306.28011.qm@web31102.mail.mud.yahoo.com> Message-ID: <200911172036.46610.daniel.is.fischer@web.de> Am Dienstag 17 November 2009 20:16:50 schrieb michael rice: > I'm trying to create a hash table. Yeah, I know, don't use hash tables, but > I need to create something I'm familiar with, not something I've never > worked with before. What's wrong with this code? > > Michael > > ==================== > > import Prelude hiding (lookup) > import Data.HashTable > > data MyHashTable = HashTable String Int > > dummy:: String -> Int > dummy s = 7 > > ht = MyHashTable.new (==) dummy > > ==================== MyHashTable.new is parsed as a qualified function, 'new' from the module MyHashTable. But there's no module MyHashTable imported, hence there's no function 'new' from that module in scope. > > [michael@localhost ~]$ ghci hash1 > GHCi, version 6.10.3: http://www.haskell.org/ghc/? :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > [1 of 1] Compiling Main???????????? ( hash1.hs, interpreted ) > > hash1.hs:9:5: Not in scope: `MyHashTable.new' > Failed, modules loaded: none. > Prelude> If we look at the type of Data.HashTable.new: new :: (key -> key -> Bool) -> (key -> GHC.Int.Int32) -> IO (HashTable key val) we see that new (==) dummy (or Data.HashTable.new (==) dummy, but we don't need to qualify new) has type IO (HashTable String val), so is an IO-action returning a hashtable. What you probably wanted was type MyHashTable = HashTable String Int -- not data MyHashTable ht <- new (==) dummy :: IO MyHashTable then ht is a hashtable of type MyHashTable. From daniel.is.fischer at web.de Tue Nov 17 14:45:10 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Nov 17 14:22:04 2009 Subject: [Haskell-cafe] Simple hash table creation In-Reply-To: <200911172036.46610.daniel.is.fischer@web.de> References: <563306.28011.qm@web31102.mail.mud.yahoo.com> <200911172036.46610.daniel.is.fischer@web.de> Message-ID: <200911172045.10701.daniel.is.fischer@web.de> Am Dienstag 17 November 2009 20:36:46 schrieb Daniel Fischer: > What you probably wanted was > > type MyHashTable = HashTable String Int -- not data MyHashTable > Just in case it's not clear: > ht <- new (==) dummy :: IO MyHashTable only works at the prompt or in an IO do-block, not at the top level of the module. > > then ht is a hashtable of type MyHashTable. From nowgate at yahoo.com Tue Nov 17 14:54:33 2009 From: nowgate at yahoo.com (michael rice) Date: Tue Nov 17 14:30:01 2009 Subject: [Haskell-cafe] Simple hash table creation In-Reply-To: <200911172036.46610.daniel.is.fischer@web.de> Message-ID: <880525.81341.qm@web31107.mail.mud.yahoo.com> Thanks all, Got it! type rather than data and <- rather than = (should have remembered this from monad stuff). Also, don't need the qualification. Onward and upward. Thanks, Michael --- On Tue, 11/17/09, Daniel Fischer wrote: From: Daniel Fischer Subject: Re: [Haskell-cafe] Simple hash table creation To: haskell-cafe@haskell.org Date: Tuesday, November 17, 2009, 2:36 PM Am Dienstag 17 November 2009 20:16:50 schrieb michael rice: > I'm trying to create a hash table. Yeah, I know, don't use hash tables, but > I need to create something I'm familiar with, not something I've never > worked with before. What's wrong with this code? > > Michael > > ==================== > > import Prelude hiding (lookup) > import Data.HashTable > > data MyHashTable = HashTable String Int > > dummy:: String -> Int > dummy s = 7 > > ht = MyHashTable.new (==) dummy > > ==================== MyHashTable.new is parsed as a qualified function, 'new' from the module MyHashTable. But there's no module MyHashTable imported, hence there's no function 'new' from that module in scope. > > [michael@localhost ~]$ ghci hash1 > GHCi, version 6.10.3: http://www.haskell.org/ghc/? :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > [1 of 1] Compiling Main???????????? ( hash1.hs, interpreted ) > > hash1.hs:9:5: Not in scope: `MyHashTable.new' > Failed, modules loaded: none. > Prelude> If we look at the type of Data.HashTable.new: new ::? (key -> key -> Bool)? -> (key -> GHC.Int.Int32)? -> IO (HashTable key val) we see that new (==) dummy (or Data.HashTable.new (==) dummy, but we don't need to qualify new) has type IO (HashTable String val), so is an IO-action returning a hashtable. What you probably wanted was type MyHashTable = HashTable String Int -- not data MyHashTable ht <- new (==) dummy :: IO MyHashTable then ht is a hashtable of type MyHashTable. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091117/718dd4ba/attachment.html From nowgate at yahoo.com Tue Nov 17 15:09:26 2009 From: nowgate at yahoo.com (michael rice) Date: Tue Nov 17 14:44:55 2009 Subject: [Haskell-cafe] Simple hash table creation In-Reply-To: <200911172045.10701.daniel.is.fischer@web.de> Message-ID: <287224.54364.qm@web31102.mail.mud.yahoo.com> Hi Daniel, Thanks for the IO monad reminder. What is GHC.Int.Int32? Can't find it on Hoogle. Michael ================== *Main> ht <- new (==) dummy :: IO MyHashTable :1:15: ??? Couldn't match expected type `GHC.Int.Int32' ?????????? against inferred type `Int' ??? In the second argument of `new', namely `dummy' ??? In a stmt of a 'do' expression: ??????? ht <- new (==) dummy :: IO MyHashTable *Main> :t dummy dummy :: String -> Int *Main> --- On Tue, 11/17/09, Daniel Fischer wrote: From: Daniel Fischer Subject: Re: [Haskell-cafe] Simple hash table creation To: haskell-cafe@haskell.org Date: Tuesday, November 17, 2009, 2:45 PM Am Dienstag 17 November 2009 20:36:46 schrieb Daniel Fischer: > What you probably wanted was > > type MyHashTable = HashTable String Int -- not data MyHashTable > Just in case it's not clear: > ht <- new (==) dummy :: IO MyHashTable only works at the prompt or in an IO do-block, not at the top level of the module. > > then ht is a hashtable of type MyHashTable. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091117/2f9ad958/attachment-0001.html From gcross at phys.washington.edu Tue Nov 17 15:23:14 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Tue Nov 17 14:58:43 2009 Subject: [Haskell-cafe] Simple hash table creation In-Reply-To: <563306.28011.qm@web31102.mail.mud.yahoo.com> References: <563306.28011.qm@web31102.mail.mud.yahoo.com> Message-ID: You don't need to create a new type for a String -> Int hashtable, you already get it for free because HashTable is a parameterized type. Also, although you are apparently trying to make life simpler for yourself using a HashTable, you are actually making like more complicated because the Data.HashTable implementation can only be worked with inside the IO monad. So what you'd need is something like: ==================== import Prelude hiding (lookup) import Data.HashTable dummy s = 7 main = do ht <- new (==) dummy insert ht "Foo" 12 value <- lookup ht "Foo" putStrLn . show $ value ==================== Note that I didn't have to label any of the types; Haskell is smart enough to mostly infer all of them automatically. The main reason to include types is if there is some ambiguity. So for example, if you actually wanted to map Strings to Floats, then you would need to explicitly tell it somewhere that the values it is storing are floats. You could do this by either pinning down explicitly the HashTable type: ==================== import Prelude hiding (lookup) import Data.HashTable dummy s = 7 main = do ht <- new (==) dummy :: IO (HashTable String Float) insert ht "Foo" 12 value <- lookup ht "Foo" putStrLn . show $ value ==================== Or just by pinning down the type of a value that you insert into it: ==================== import Prelude hiding (lookup) import Data.HashTable dummy s = 7 main = do ht <- new (==) dummy insert ht "Foo" (12 :: Float) value <- lookup ht "Foo" putStrLn . show $ value ==================== Again, the downside though is that you can't work with HashTable outside of the IO monad. If what you want is just a map from strings to values, then you probably are better off using Data.Map: ==================== import Prelude hiding (lookup) import Data.Map my_map = empty :: Map String Int my_map_after_adding_key = insert "Foo" 12 my_map value_associated_with_Foo = lookup "Foo" my_map_after_adding_key main = putStrLn . show $ value_associated_with_Foo ==================== Cheers, Greg On Nov 17, 2009, at 11:16 AM, michael rice wrote: > I'm trying to create a hash table. Yeah, I know, don't use hash > tables, but I need to create something I'm familiar with, not > something I've never worked with before. What's wrong with this code? > > Michael > > ==================== > > import Prelude hiding (lookup) > import Data.HashTable > > data MyHashTable = HashTable String Int > > dummy:: String -> Int > dummy s = 7 > > ht = MyHashTable.new (==) dummy > > ==================== > > [michael@localhost ~]$ ghci hash1 > GHCi, version 6.10.3: http://www.haskell.org/ghc/ :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > [1 of 1] Compiling Main ( hash1.hs, interpreted ) > > hash1.hs:9:5: Not in scope: `MyHashTable.new' > Failed, modules loaded: none. > Prelude> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091117/4f93a41a/attachment.html From daniel.is.fischer at web.de Tue Nov 17 15:21:18 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Nov 17 15:02:29 2009 Subject: [Haskell-cafe] Simple hash table creation In-Reply-To: <287224.54364.qm@web31102.mail.mud.yahoo.com> References: <287224.54364.qm@web31102.mail.mud.yahoo.com> Message-ID: <200911172121.18401.daniel.is.fischer@web.de> Am Dienstag 17 November 2009 21:09:26 schrieb michael rice: > What is GHC.Int.Int32? Can't find it on Hoogle. Int32 is the guaranteed-to-be-32-bits integer type, it's defined in the module GHC.Int, typically it's imported via Data.Int (because, naturally, using GHC's own modules isn't portable). Due to the way ghci's :type command works, such types are printed qualified. The hash function must have a return type of fixed and specified width, or porting the app between 32-bit and 64-bit platforms could have enormous performance impact, so it can't be plain Int. From ezyang at MIT.EDU Tue Nov 17 15:33:17 2009 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Tue Nov 17 15:08:47 2009 Subject: [Haskell-cafe] ghci + user prelude In-Reply-To: <6579f8680911161606u7447356fkae637674b29666b1@mail.gmail.com> References: <6579f8680911161227k599f6188k694187b2f19782af@mail.gmail.com> <1258404357-sup-7094@ezyang> <6579f8680911161606u7447356fkae637674b29666b1@mail.gmail.com> Message-ID: <1258489958-sup-2769@ezyang> Excerpts from Sean McLaughlin's message of Mon Nov 16 19:06:06 -0500 2009: > Hi. I'm aware of this option, and use it frequently to override the > default prelude, but it doesn't help this problem: I suppose this is the appropriate quote from the GHC manual: """ GHC normally imports Prelude.hi files for you. If you'd rather it didn't, then give it a -XNoImplicitPrelude option. The idea is that you can then import a Prelude of your own. (But don't call it Prelude; the Haskell module namespace is flat, and you must not conflict with any Prelude module.)""" Cheers, Edward From gcross at phys.washington.edu Tue Nov 17 15:30:15 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Tue Nov 17 15:09:24 2009 Subject: [Haskell-cafe] Simple hash table creation In-Reply-To: <287224.54364.qm@web31102.mail.mud.yahoo.com> References: <287224.54364.qm@web31102.mail.mud.yahoo.com> Message-ID: <28204A71-EA11-4119-B25E-75A0FA8AC4E1@phys.washington.edu> Look in Data.Int for a list of the Int types. Basically you generally only use Int unless you are working at a lower- level which has an explicit requirement for the number of bits. In this case, HashTable has such a requirement, so you have two choices: you can either change the type annotation on dummy: import Data.Int dummy:: String -> Int32 dummy s = 7 or you can just leave it off entirely, and GHC will automatically infer the correct type (without you needing to import Data.Int): dummy s = 7 On Nov 17, 2009, at 12:09 PM, michael rice wrote: > Hi Daniel, > > Thanks for the IO monad reminder. > > What is GHC.Int.Int32? Can't find it on Hoogle. > > Michael > > ================== > > *Main> ht <- new (==) dummy :: IO MyHashTable > > :1:15: > Couldn't match expected type `GHC.Int.Int32' > against inferred type `Int' > In the second argument of `new', namely `dummy' > In a stmt of a 'do' expression: > ht <- new (==) dummy :: IO MyHashTable > *Main> :t dummy > dummy :: String -> Int > *Main> > > > > --- On Tue, 11/17/09, Daniel Fischer wrote: > > From: Daniel Fischer > Subject: Re: [Haskell-cafe] Simple hash table creation > To: haskell-cafe@haskell.org > Date: Tuesday, November 17, 2009, 2:45 PM > > Am Dienstag 17 November 2009 20:36:46 schrieb Daniel Fischer: > > What you probably wanted was > > > > type MyHashTable = HashTable String Int -- not data MyHashTable > > > > Just in case it's not clear: > > > ht <- new (==) dummy :: IO MyHashTable > > only works at the prompt or in an IO do-block, not at the top level > of the module. > > > > > then ht is a hashtable of type MyHashTable. > > > _______________________________________________ > 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091117/3aead5d8/attachment.html From bulat.ziganshin at gmail.com Tue Nov 17 15:55:02 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Nov 17 15:32:38 2009 Subject: [Haskell-cafe] Simple hash table creation In-Reply-To: <200911172121.18401.daniel.is.fischer@web.de> References: <287224.54364.qm@web31102.mail.mud.yahoo.com> <200911172121.18401.daniel.is.fischer@web.de> Message-ID: <160187144.20091117235502@gmail.com> Hello Daniel, Tuesday, November 17, 2009, 11:21:18 PM, you wrote: > The hash function must have a return type of fixed and specified width, or porting the app > between 32-bit and 64-bit platforms could have enormous performance impact, so it can't be > plain Int. i think that the problem with use of Int instead of Int32 here would be different results with incorrect comparison functions, nothing more -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From nowgate at yahoo.com Tue Nov 17 16:00:58 2009 From: nowgate at yahoo.com (michael rice) Date: Tue Nov 17 15:36:27 2009 Subject: [Haskell-cafe] Simple hash table creation In-Reply-To: <28204A71-EA11-4119-B25E-75A0FA8AC4E1@phys.washington.edu> Message-ID: <710561.21804.qm@web31107.mail.mud.yahoo.com> Hi Gregory, I was wondering about that, because of the following: [1 of 1] Compiling Main???????????? ( hash1.hs, interpreted ) Ok, modules loaded: Main. *Main> ht <- new (==) dummy :: IO MyHashTable *Main> dummy "mike" 7 *Main> dummy "michael" 7 *Main> insert ht "mike" 1 *Main> toList ht [("mike",1)] *Main> insert ht "michael" 2 *Main> toList ht [("michael",2),("mike",1)] *Main> insert ht "miguel" 3 *Main> toList ht [("miguel",3),("michael",2),("mike",1)] *Main> :t dummy "miguel" dummy "miguel" :: Int32 *Main> It seems my dummy function is being ignored. I figured I would only be able to store a single value with a hash function that always returns 7. Why ask for a hash function and not use it? Also, it's said that it is good programming practice? to include type information in function definitions, so I always try to do that, even though it usually leads to my code being rejected. I need to step back and use the :t? and module functions defs to figure out what types are returned and required as arguments, instead of trying to puzzle it out myself. Like juggling, there's a lot of balls in the air w/Haskell, lots of things to remember, but it's the most intriguing computer language I've looked at in a long time. Thanks for your input. Michael --- On Tue, 11/17/09, Gregory Crosswhite wrote: From: Gregory Crosswhite Subject: Re: [Haskell-cafe] Simple hash table creation To: "michael rice" Cc: haskell-cafe@haskell.org, "Daniel Fischer" Date: Tuesday, November 17, 2009, 3:30 PM Look in Data.Int for a list of the Int types. Basically you generally only use Int unless you are working at a lower-level which has an explicit requirement for the number of bits. ?In this case, HashTable has such a requirement, so you have two choices: ?you can either change the type annotation on dummy: import Data.Int dummy:: String -> Int32 dummy s = 7 or you can just leave it off entirely, and GHC will automatically infer the correct type (without you needing to import Data.Int): dummy s = 7 On Nov 17, 2009, at 12:09 PM, michael rice wrote: Hi Daniel, Thanks for the IO monad reminder. What is GHC.Int.Int32? Can't find it on Hoogle. Michael ================== *Main> ht <- new (==) dummy :: IO MyHashTable :1:15: ??? Couldn't match expected type `GHC.Int.Int32' ?????????? against inferred type `Int' ??? In the second argument of `new', namely `dummy' ??? In a stmt of a 'do' expression: ??????? ht <- new (==) dummy :: IO MyHashTable *Main> :t dummy dummy :: String -> Int *Main> --- On Tue, 11/17/09, Daniel Fischer wrote: From: Daniel Fischer Subject: Re: [Haskell-cafe] Simple hash table creation To: haskell-cafe@haskell.org Date: Tuesday, November 17, 2009, 2:45 PM Am Dienstag 17 November 2009 20:36:46 schrieb Daniel Fischer: > What you probably wanted was > > type MyHashTable = HashTable String Int -- not data MyHashTable > Just in case it's not clear: > ht <- new (==) dummy :: IO MyHashTable only works at the prompt or in an IO do-block, not at the top level of the module. > > then ht is a hashtable of type MyHashTable. _______________________________________________ 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091117/19e33fad/attachment.html From brad.larsen at gmail.com Tue Nov 17 16:17:06 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Tue Nov 17 15:52:34 2009 Subject: [Haskell-cafe] Simple hash table creation In-Reply-To: <710561.21804.qm@web31107.mail.mud.yahoo.com> References: <28204A71-EA11-4119-B25E-75A0FA8AC4E1@phys.washington.edu> <710561.21804.qm@web31107.mail.mud.yahoo.com> Message-ID: On Tue, Nov 17, 2009 at 4:00 PM, michael rice wrote: > > Hi Gregory, > > I was wondering about that, because of the following: > > [1 of 1] Compiling Main???????????? ( hash1.hs, interpreted ) > Ok, modules loaded: Main. > *Main> ht <- new (==) dummy :: IO MyHashTable > *Main> dummy "mike" > 7 > *Main> dummy "michael" > 7 > *Main> insert ht "mike" 1 > *Main> toList ht > [("mike",1)] > *Main> insert ht "michael" 2 > *Main> toList ht > [("michael",2),("mike",1)] > *Main> insert ht "miguel" 3 > *Main> toList ht > [("miguel",3),("michael",2),("mike",1)] > *Main> :t dummy "miguel" > dummy "miguel" :: Int32 > *Main> > > It seems my dummy function is being ignored. I figured I would only be able to store a single value with a hash function that always returns 7. Why ask for a hash function and not use it? [...] Most hash tables deal with collisions, i.e. the case when two keys stored in the table hash to the same value. In the case of your 'dummy' hash function, which always returns 7, every key hashes to the same value, hence collisions galore. One way to deal with collisions is to hash a key to a bucket (i.e. list) of items, then walk down the list looking for the given key. In such an implementation (and I believe for hash tables in general), the quality of the hash function greatly affects the performance of the hash table operations. I am not sure what implementation Data.HashTable uses. However, I believe Data.HashTable is not all that good: for multi-million element tables from Int to Int, Data.IntMap runs many times faster than Data.HashTable. I have no wish to start a flame war here (this topic has in the past), but the state of affairs regarding hash tables in Haskell is not good. Sincerely, Brad From nowgate at yahoo.com Tue Nov 17 16:22:18 2009 From: nowgate at yahoo.com (michael rice) Date: Tue Nov 17 15:57:47 2009 Subject: [Haskell-cafe] Simple hash table creation In-Reply-To: Message-ID: <464198.66877.qm@web31106.mail.mud.yahoo.com> So, what you're telling me is, my dummy hash function IS being used, and because of collisions the other values are placed in different locations? Michael --- On Tue, 11/17/09, Brad Larsen wrote: From: Brad Larsen Subject: Re: [Haskell-cafe] Simple hash table creation To: "michael rice" Cc: "Gregory Crosswhite" , haskell-cafe@haskell.org Date: Tuesday, November 17, 2009, 4:17 PM On Tue, Nov 17, 2009 at 4:00 PM, michael rice wrote: > > Hi Gregory, > > I was wondering about that, because of the following: > > [1 of 1] Compiling Main???????????? ( hash1.hs, interpreted ) > Ok, modules loaded: Main. > *Main> ht <- new (==) dummy :: IO MyHashTable > *Main> dummy "mike" > 7 > *Main> dummy "michael" > 7 > *Main> insert ht "mike" 1 > *Main> toList ht > [("mike",1)] > *Main> insert ht "michael" 2 > *Main> toList ht > [("michael",2),("mike",1)] > *Main> insert ht "miguel" 3 > *Main> toList ht > [("miguel",3),("michael",2),("mike",1)] > *Main> :t dummy "miguel" > dummy "miguel" :: Int32 > *Main> > > It seems my dummy function is being ignored. I figured I would only be able to store a single value with a hash function that always returns 7. Why ask for a hash function and not use it? [...] Most hash tables deal with collisions, i.e. the case when two keys stored in the table hash to the same value.? In the case of your 'dummy' hash function, which always returns 7, every key hashes to the same value, hence collisions galore. One way to deal with collisions is to hash a key to a bucket (i.e. list) of items, then walk down the list looking for the given key.? In such an implementation (and I believe for hash tables in general), the quality of the hash function greatly affects the performance of the hash table operations. I am not sure what implementation Data.HashTable uses.? However, I believe Data.HashTable is not all that good:? for multi-million element tables from Int to Int, Data.IntMap runs many times faster than Data.HashTable.? I have no wish to start a flame war here (this topic has in the past), but the state of affairs regarding hash tables in Haskell is not good. Sincerely, Brad -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091117/3b4a217e/attachment.html From brad.larsen at gmail.com Tue Nov 17 16:36:12 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Tue Nov 17 16:11:39 2009 Subject: [Haskell-cafe] Simple hash table creation In-Reply-To: <464198.66877.qm@web31106.mail.mud.yahoo.com> References: <464198.66877.qm@web31106.mail.mud.yahoo.com> Message-ID: On Tue, Nov 17, 2009 at 4:22 PM, michael rice wrote: > > So, what you're telling me is, my dummy hash function IS being used, and because of collisions the other values are placed in different locations? > > Michael [...] If Data.HashTable is implemented using separate chaining, then all the key/value pairs would be hashed to the same bucket (hash value 7). If a different scheme is used, then hash collisions would be resolved in a different way, e.g., through linear probing. Regardless of the collision resolution scheme used, excessive hash collisions are bad, and are what can cause the worst-case time complexity of hash table operations (in most implementations) to be O(n). The Wikipedia page on hash tables isn't bad: . Sincerely, Brad From bulat.ziganshin at gmail.com Tue Nov 17 16:38:16 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Nov 17 16:13:47 2009 Subject: [Haskell-cafe] Simple hash table creation In-Reply-To: <710561.21804.qm@web31107.mail.mud.yahoo.com> References: <28204A71-EA11-4119-B25E-75A0FA8AC4E1@phys.washington.edu> <710561.21804.qm@web31107.mail.mud.yahoo.com> Message-ID: <874412426.20091118003816@gmail.com> Hello michael, Wednesday, November 18, 2009, 12:00:58 AM, you wrote: *Main>> toList ht > [("miguel",3),("michael",2),("mike",1)] > > It seems my dummy function is being ignored. i wonder why you think so? your ht has all 3 pairs you ever inserted inside, they all are inside the same bucket since hash function returns the same value for them ... hmm, i guess that you expect something like low-level hashtable from other languages - i.e. it should have just one slot for all values hashed to 7 and save here last value it works other way - it has just one slot for all your values but it stores here LIST of your pairs. so nothing is lost. if you want to save only the last value, replace (==) to (\a b -> dummy a==dummy b) the whole story is that hash function used to select slot, and then key part of pair is compared using (==) with keys of all values in the slot. it will replace existing pair if key1==key2, otherwise added to list so, hashing allows to quickly find pair by its key, but it still full map as far as you pass a usual (==) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From nowgate at yahoo.com Tue Nov 17 17:28:26 2009 From: nowgate at yahoo.com (michael rice) Date: Tue Nov 17 17:03:53 2009 Subject: [Haskell-cafe] Simple hash table creation In-Reply-To: <874412426.20091118003816@gmail.com> Message-ID: <853202.24840.qm@web31102.mail.mud.yahoo.com> Hi Bulat, I was just looking for a simple hashing function. I was going to use the length function but a constant int is even simpler.? I'm supposing that had I used the length function "mike" and "fred" would end up in the same bucket. This is the first time I've tried to do anything in Haskell with data structures other than lists, so I needed to see how things work. Thanks, everyone, for the help. Michael --- On Tue, 11/17/09, Bulat Ziganshin wrote: From: Bulat Ziganshin Subject: Re[2]: [Haskell-cafe] Simple hash table creation To: "michael rice" Cc: "Gregory Crosswhite" , haskell-cafe@haskell.org Date: Tuesday, November 17, 2009, 4:38 PM Hello michael, Wednesday, November 18, 2009, 12:00:58 AM, you wrote: *Main>> toList ht > [("miguel",3),("michael",2),("mike",1)] > > It seems my dummy function is being ignored. i wonder why you think so? your ht has all 3 pairs you ever inserted inside, they all are inside the same bucket since hash function returns the same value for them ... hmm, i guess that you expect something like low-level hashtable from other languages - i.e. it should have just one slot for all values hashed to 7 and save here last value it works other way - it has just one slot for all your values but it stores here LIST of your pairs. so nothing is lost. if you want to save only the last value, replace (==) to (\a b -> dummy a==dummy b) the whole story is that hash function used to select slot, and then key part of pair is compared using (==) with keys of all values in the slot. it will replace existing pair if key1==key2, otherwise added to list so, hashing allows to quickly find pair by its key, but it still full map as far as you pass a usual (==) -- Best regards, Bulat? ? ? ? ? ? ? ? ? ? ? ? ? ? mailto:Bulat.Ziganshin@gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091117/b5137322/attachment.html From ezra.lalonde at gmail.com Tue Nov 17 18:31:19 2009 From: ezra.lalonde at gmail.com (Ezra Lalonde) Date: Tue Nov 17 18:06:48 2009 Subject: Re[Haskell-cafe] cursive to foldr In-Reply-To: <26368900.post@talk.nabble.com> References: <26368900.post@talk.nabble.com> Message-ID: <26399795.post@talk.nabble.com> Using the same basic structure you did, and foldr, I think below is the simplest method: ==================== import Data.Maybe searchList :: (a -> Bool) -> [a] -> Maybe [a] searchList p xs = foldr (\x acc -> if p x then Just (x: fromMaybe [] acc) else acc) Nothing xs ==================== ghci> searchList (=='o') "A quick brown fox" Just "oo" ghci> searchList (==' ') "A quick brown fox" Just " " ghci> searchList (=='z') "A quick brown fox" Nothing >From maybe gets rid of the Maybe, so that our recursive call works: ghci> fromMaybe [] (Just [1..3]) [1,2,3] That's why we got the error below when we tried without fromMaybe; on subsequent applications of foldr, the type would have to change. ==================== :1:51: Couldn't match expected type `[a]' against inferred type `Maybe [a]' In the expression: if p x then Just (x : acc) else acc In the first argument of `foldr', namely `(\ x acc -> if p x then Just (x : acc) else acc)' In the expression: foldr (\ x acc -> if p x then Just (x : acc) else acc) Nothing xs ==================== I have a feeling that using fromMaybe is not the best way, but it gets the job done for now. On that note; if somebody with some more experience would chime in, that'd be awesome. ;) Ezra dima.neg wrote: > > How can I do this using foldr? > > searchList p [] = Nothing > searchList p (x:xs) > | p x = Just (x:filter p xs) > | otherwise = searchList p xs > > > I try this: > searchList p xs = foldr (\x acc -> if p x then Just (x:acc) else acc) > Nothing xs > but don't work. > > Thanks > -- View this message in context: http://old.nabble.com/Recursive-to-foldr-tp26368900p26399795.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From rohan.drape at gmail.com Tue Nov 17 19:01:57 2009 From: rohan.drape at gmail.com (Rohan Drape) Date: Tue Nov 17 18:50:33 2009 Subject: [Haskell-cafe] Re: help with musical data structures References: <1460.75.50.158.253.1258267873.squirrel@mail.alumni.caltech.edu> <5fdc56d70911150105j1494af46i475e9d9e46578a8b@mail.gmail.com> <5fdc56d70911150258w5459481bj3a1897d9a93ca080@mail.gmail.com> <4B000E25.5000807@alumni.caltech.edu> Message-ID: On 2009-11-15, Michael Mossey wrote: > I will need a function that computes prime (normal?) > form, of course, and it is just begging to be > memoized. there are some prime form algorithms at http://hackage.haskell.org/packages/archive/hmt/0.1/doc/html/Music-Theory-Prime.html completely naive and un-optimised, but this has never been an issue in my experience. bests rohan From flippa at flippac.org Tue Nov 17 20:31:29 2009 From: flippa at flippac.org (Philippa Cowderoy) Date: Tue Nov 17 20:06:55 2009 Subject: [Haskell-cafe] GHCi's :t misbehaving Message-ID: <4B034E71.60808@flippac.org> I have some mildly complicated parsing code, that uses parsec to return a computation (in a state monad) that handles operator precedence - so I can handle scoped precedence/fixities, much like in Haskell. I just spent a while bolting on some new features. More time than I'd like, I'd left it alone for a while and it took a bit of time getting my head around it again enough to be okay doing folds on parse results and the like. Enough so that I've been leaning on the type checker to tell me when I've messed up! So, I have something that loads into ghci okay now. I go to check the type of one of the functions using :t and get this error: :1:0: Ambiguous type variable `m' in the constraint: `Monad m' arising from a use of `constructor' at :1:0-10 Probable fix: add a type signature that fixes these type variable(s) Now I'm not about the supply the type signature, that's what I asked it for! And it ought to typecheck okay, given that the code loaded in the first place. I'm about to turn in for the night, but I'm wondering what's going on here. Anyone? -- flippa@flippac.org From lrpalmer at gmail.com Tue Nov 17 21:30:59 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Nov 17 21:06:26 2009 Subject: [Haskell-cafe] GHCi's :t misbehaving In-Reply-To: <4B034E71.60808@flippac.org> References: <4B034E71.60808@flippac.org> Message-ID: <7ca3f0160911171830g30d58925ye37db5a88eae1145@mail.gmail.com> It's very hard to tell what is going on without more details. If you *at least* give the ghci session, and possibly the whole code (while it might be too much to read, it is not to much to load and try ourselves). This looks like a monomorphism restriction, which shouldn't happen when you are using :t. So that's why more info is necessary. Luke On Tue, Nov 17, 2009 at 6:31 PM, Philippa Cowderoy wrote: > I have some mildly complicated parsing code, that uses parsec to return a > computation (in a state monad) that handles operator precedence - so I can > handle scoped precedence/fixities, much like in Haskell. I just spent a > while bolting on some new features. More time than I'd like, I'd left it > alone for a while and it took a bit of time getting my head around it again > enough to be okay doing folds on parse results and the like. Enough so that > I've been leaning on the type checker to tell me when I've messed up! > > So, I have something that loads into ghci okay now. I go to check the type > of one of the functions using :t and get this error: > :1:0: > ? Ambiguous type variable `m' in the constraint: > ? ? `Monad m' > ? ? ? arising from a use of `constructor' at :1:0-10 > ? Probable fix: add a type signature that fixes these type variable(s) > > Now I'm not about the supply the type signature, that's what I asked it for! > And it ought to typecheck okay, given that the code loaded in the first > place. I'm about to turn in for the night, but I'm wondering what's going on > here. Anyone? > > -- > flippa@flippac.org > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dave at zednenem.com Tue Nov 17 21:39:45 2009 From: dave at zednenem.com (David Menendez) Date: Tue Nov 17 21:15:22 2009 Subject: Re[Haskell-cafe] cursive to foldr In-Reply-To: <26399795.post@talk.nabble.com> References: <26368900.post@talk.nabble.com> <26399795.post@talk.nabble.com> Message-ID: <49a77b7a0911171839r467bc6bct5b4dbe4ae6b082ec@mail.gmail.com> On Tue, Nov 17, 2009 at 6:31 PM, Ezra Lalonde wrote: > > Using the same basic structure you did, and foldr, I think below is the > simplest method: > > ==================== > import Data.Maybe > > searchList :: (a -> Bool) -> [a] -> Maybe [a] > searchList p xs = foldr (\x acc -> if p x then Just (x: fromMaybe [] acc) > else acc) Nothing xs > ==================== This might be considered simpler: searchList p = foldr (\x -> if p x then Just . maybe [x] (x:) else id) Nothing The real problem with searchList is that it's strict and can't be made lazy. Because it returns Nothing when nothing matches the predicate, it has to traverse the entire list before returning anything. Instead, I would recommend filter, which can be used as-is or defined in terms of foldr. filter p = foldr (\x -> if p x then (x:) else id) [] Compare the behavior of "searchList even [0..]" and "filter even [0..]". -- Dave Menendez From lrpalmer at gmail.com Tue Nov 17 22:01:36 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Nov 17 21:37:04 2009 Subject: Re[Haskell-cafe] cursive to foldr In-Reply-To: <49a77b7a0911171839r467bc6bct5b4dbe4ae6b082ec@mail.gmail.com> References: <26368900.post@talk.nabble.com> <26399795.post@talk.nabble.com> <49a77b7a0911171839r467bc6bct5b4dbe4ae6b082ec@mail.gmail.com> Message-ID: <7ca3f0160911171901j196bd7b6v5513db9cec19ac6c@mail.gmail.com> On Tue, Nov 17, 2009 at 7:39 PM, David Menendez wrote: > On Tue, Nov 17, 2009 at 6:31 PM, Ezra Lalonde wrote: >> >> Using the same basic structure you did, and foldr, I think below is the >> simplest method: >> >> ==================== >> import Data.Maybe >> >> searchList :: (a -> Bool) -> [a] -> Maybe [a] >> searchList p xs = foldr (\x acc -> if p x then Just (x: fromMaybe [] acc) >> else acc) Nothing xs >> ==================== > > This might be considered simpler: > > searchList p = foldr (\x -> if p x then Just . maybe [x] (x:) else id) Nothing > > The real problem with searchList is that it's strict and can't be made > lazy. Because it returns Nothing when nothing matches the predicate, > it has to traverse the entire list before returning anything. Instead, > I would recommend filter, which can be used as-is or defined in terms > of foldr. > > filter p = foldr (\x -> if p x then (x:) else id) [] > > Compare the behavior of "searchList even [0..]" and "filter even [0..]". ...? filter even [0..] --> [0,2,4,6,8,...] searchList even [0...] --> Just [0,2,4,6,8,...] searchList gives Nothing in exactly those cases that filter gives []. They give _|_ in exactly the same situations. searchList could well be defined as: searchList p xs = if null ys then Nothing else Just ys where ys = filter p xs null is strict, so searchList is just as strict as filter. Luke From wren at freegeek.org Tue Nov 17 22:06:57 2009 From: wren at freegeek.org (wren ng thornton) Date: Tue Nov 17 21:42:26 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <4B0297FC.3000702@kent.ac.uk> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> <4B0297FC.3000702@kent.ac.uk> Message-ID: <4B0364D1.4000402@freegeek.org> Neil Brown wrote: > Having skimmed the page, it seems like the re-use of "." is one of the > major difficulties of the proposal. Would it be possible to use "->"? > It has been used for accessing members in C and C++, so it is not too > unusual a choice. It's also the one that Perl went with. > It is already special in Haskell so it wouldn't break > anyone's code -- but do its other uses (case statements and lambdas) > mean that it would cause problems in the grammar if re-used for TDNR? Given the other uses of -> in Haskell, I'm hesitant to suggest it either. I seem to recall # is the option used by OCaml and a few other functional-OO languages. So far as I know -XMagicHash is the only thing that would conflict with that name so it seems far less invasive than . or ->. Another option would be to use @ which is currently forbidden in expressions, though that might cause issues with System F/Core. -- Live well, ~wren From malcolm.wallace at cs.york.ac.uk Tue Nov 17 22:33:48 2009 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Tue Nov 17 22:10:09 2009 Subject: [Haskell-cafe] omitting params in function bindings In-Reply-To: <200911171920.nAHJKcqE017428@tecumseh.cs.dartmouth.edu> References: <200911171920.nAHJKcqE017428@tecumseh.cs.dartmouth.edu> Message-ID: Doug McIlroy wrote: > Is there a deep reason (beyond saving a sentence > or two in the language definition) for requiring > all patterns in a function binding to have the > same explicit arity? Perhaps it is more likely that a clause omitting an argument is a mistake by the programmer, than that it was an intentional eta- conversion. Regards, Malcolm From heringtonlacey at mindspring.com Tue Nov 17 22:48:19 2009 From: heringtonlacey at mindspring.com (Dean Herington) Date: Tue Nov 17 22:23:56 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: deepseq-1.0.0.0 In-Reply-To: <4B028245.1080201@gmail.com> References: <4B028245.1080201@gmail.com> Message-ID: At 11:00 AM +0000 11/17/09, Simon Marlow wrote: >I've just uploaded deepseq-1.0.0.0 to Hackage > > http://hackage.haskell.org/package/deepseq > >This provides a DeepSeq class with a deepseq method, equivalent to >the existing NFData/rnf in the parallel package. I'll be using this >in a newly revamped parallel package, which I hope to upload shortly. > >Cheers, > Simon The documentation claim that "The default implementation of 'deepseq' is simply 'seq'" is not exactly right, as `deepseq` and `seq` have different signatures. Which raises the more interesting question: Why did you choose a different signature? And, would a version of `seq` with the same signature as `deepseq` be useful? Dean From lrpalmer at gmail.com Tue Nov 17 23:06:20 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Nov 17 22:41:48 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: deepseq-1.0.0.0 In-Reply-To: References: <4B028245.1080201@gmail.com> Message-ID: <7ca3f0160911172006i74a6e810t8e85d2c093191af3@mail.gmail.com> On Tue, Nov 17, 2009 at 8:48 PM, Dean Herington wrote: > The documentation claim that "The default implementation of 'deepseq' is > simply 'seq'" is not exactly right, as `deepseq` and `seq` have different > signatures. ?Which raises the more interesting question: Why did you choose > a different signature? ?And, would a version of `seq` with the same > signature as `deepseq` be useful? The situation is analogous to, say, "null" having this signature: null :: [a] -> Bool Instead of this one: null :: [a] -> b -> b -> b Or the recent famous debate about returning Maybe a vs. Monad m => m a for failure. If we have seq' :: a -> (), then we have seq = m . seq' where m () = id And of course we can go the other way too. So it is a question of taste. deepseq is simpler by at least two standards: it is not polymorphic and it has only one argument. There are exactly two values of both () and forall b. b -> b, but that fact is more obvious of the former (IMO). I think it is the right choice. Luke From malcolm.wallace at cs.york.ac.uk Tue Nov 17 23:05:34 2009 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Tue Nov 17 22:42:13 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: deepseq-1.0.0.0 In-Reply-To: References: <4B028245.1080201@gmail.com> Message-ID: <4EAD957A-8BDC-4BFD-85D9-39B74D638556@cs.york.ac.uk> > The documentation claim that "The default implementation of > 'deepseq' is simply 'seq'" is not exactly right, as `deepseq` and > `seq` have different signatures. Yes indeed. In order to use deepseq, it looks like I also need some way to force the () return value, e.g. let res = deepseq (my big computation) in res `seq` use res or let res = deepseq (my big computation) in case res of () -> use res I suppose the advantage of this approach is to ensure that the user must let-bind the forced value to a name. A beginner might write (my big computation) `seq` use (my big computation) without realising that it fails to do what they desire. Regards, Malcolm From rl at cse.unsw.edu.au Tue Nov 17 23:59:51 2009 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Tue Nov 17 23:35:24 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> Message-ID: Simon, have you given any thought to how this interacts with type system extensions, in particular with GADTs and type families? The proposal relies on being able to "find the type" of a term but it's not entirely clear to me what that means. Here is an example: foo :: F Int -> Int foo :: Int -> Int bar1 :: Int -> Int bar1 = foo bar2 :: Int ~ F Int => Int -> Int bar2 = foo IIUC, bar1 is ok but bar2 isn't. Do we realy want to have such a strong dependency between name lookup and type inference? Can name lookup be specified properly without also having to specify the entire inference algorithm? Another example: suppose we have data T a where TInt :: T Int TBool :: T Bool foo :: T Int -> u foo :: T Bool -> u bar :: T a -> u bar x = case x of TInt -> foo x TBool -> foo x Here, (foo x) calls different functions in the two alternatives, right? To be honest, that's not something I'd like to see in Haskell. Roman From dave at zednenem.com Wed Nov 18 00:01:38 2009 From: dave at zednenem.com (David Menendez) Date: Tue Nov 17 23:37:05 2009 Subject: Re[Haskell-cafe] cursive to foldr In-Reply-To: <7ca3f0160911171901j196bd7b6v5513db9cec19ac6c@mail.gmail.com> References: <26368900.post@talk.nabble.com> <26399795.post@talk.nabble.com> <49a77b7a0911171839r467bc6bct5b4dbe4ae6b082ec@mail.gmail.com> <7ca3f0160911171901j196bd7b6v5513db9cec19ac6c@mail.gmail.com> Message-ID: <49a77b7a0911172101p1a30af67teef55ba6795b3510@mail.gmail.com> On Tue, Nov 17, 2009 at 10:01 PM, Luke Palmer wrote: > filter even [0..] ? ?--> ? ?[0,2,4,6,8,...] > searchList even [0...] ? --> ? Just [0,2,4,6,8,...] > > searchList gives Nothing in exactly those cases that filter gives []. > They give _|_ in exactly the same situations. ?searchList could well > be defined as: > > searchList p xs = if null ys then Nothing else Just ys > ? ?where ys = filter p xs > > null is strict, so searchList is just as strict as filter. You're right. I was thinking of traverse with an exception monad. To make up for it, I'll note that with the recently (re)proposed mfilter, you can define searchList as: searchList p = mfilter (not . null) . Just . filter p -- Dave Menendez From ekmett at gmail.com Wed Nov 18 01:00:34 2009 From: ekmett at gmail.com (Edward Kmett) Date: Wed Nov 18 00:36:01 2009 Subject: [Haskell-cafe] omitting params in function bindings In-Reply-To: <200911171920.nAHJKcqE017428@tecumseh.cs.dartmouth.edu> References: <200911171920.nAHJKcqE017428@tecumseh.cs.dartmouth.edu> Message-ID: <7fb8f82f0911172200n7654cc92h17bf65636010aff@mail.gmail.com> There is the property that once you 'move across the = to the right', the pattern matcher isn't allowed to backtrack and try other patterns any more, which might introduce some funny business. Though, I can't -- at the moment -- come up with a way that it would break anything. -Edward Kmett On Tue, Nov 17, 2009 at 2:20 PM, Doug McIlroy wrote: > Is there a deep reason (beyond saving a sentence > or two in the language definition) for requiring > all patterns in a function binding to have the > same explicit arity? > > For example, in > dropWhile0 :: Num a => [a] -> [a] > dropWhile0 (0:xs) = dropWhile0 xs > dropWhile0 xs = xs > why shouldn't the last line be replaceable by > dropWhile0 = id > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091118/990909e7/attachment.html From aeyakovenko at gmail.com Wed Nov 18 01:21:07 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Wed Nov 18 00:56:34 2009 Subject: [Haskell-cafe] hipmunkplayground on windows Message-ID: Anyone else seeing a bunch of linker errors when trying to install HipmunkPlayground? this is what i see: C:\Program Files\Haskell\OpenGL-2.2.3.0\ghc-6.10.4/libHSOpenGL-2.2.3.0.a(RenderMode.o):fake:(.text+0x5be): more undefined references to `glRenderMode' follow C:\Program Files\Haskell\OpenGL-2.2.3.0\ghc-6.10.4/libHSOpenGL-2.2.3.0.a(Environments.o):fake:(.text+0x1c25): undefined reference to `glGetTexEnvfv' C:\Program Files\Haskell\OpenGL-2.2.3.0\ghc-6.10.4/libHSOpenGL-2.2.3.0.a(Environments.o):fake:(.text+0x5779): undefined reference to `glTexEnvi' C:\Program Files\Haskell\OpenGL-2.2.3.0\ghc-6.10.4/libHSOpenGL-2.2.3.0.a(Environments.o):fake:(.text+0x58f5): undefined reference to `glGetTexEnviv' C:\Program Files\Haskell\OpenGL-2.2.3.0\ghc-6.10.4/libHSOpenGL-2.2.3.0.a(Environments.o):fake:(.text+0x5aba): undefined reference to `glTexEnvf' C:\Program Files\Haskell\OpenGL-2.2.3.0\ghc-6.10.4/libHSOpenGL-2.2.3.0.a(Environments.o):fake:(.text+0x5c7d): undefined reference to `glGetTexEnvfv' C:\Program Files\Haskell\OpenGL-2.2.3.0\ghc-6.10.4/libHSOpenGL-2.2.3.0.a(Environments.o):fake:(.text+0x6d51): undefined reference to `glTexEnvfv' C:\Program Files\Haskell\OpenGL-2.2.3.0\ghc-6.10.4/libHSOpenGL-2.2.3.0.a(Queries.o):fake:(.text+0x339): undefined reference to `glGetTexLevelParameteriv' collect2: ld returned 1 exit status cabal.exe: Error: some packages failed to install: HipmunkPlayground-5.0.0 failed during the building phase. The exception was: exit: ExitFailure 1 From felipe.lessa at gmail.com Wed Nov 18 02:56:26 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Wed Nov 18 02:31:59 2009 Subject: [Haskell-cafe] hipmunkplayground on windows In-Reply-To: References: Message-ID: <20091118075625.GB14947@kira.casa> On Tue, Nov 17, 2009 at 10:21:07PM -0800, Anatoly Yakovenko wrote: > Anyone else seeing a bunch of linker errors when trying to install > HipmunkPlayground? Hmmm, no, I've never seen those errors before. Are you able to compile any OpenGL programs at all? You may try, for example, installing the game 'bloxorz'[1]. [1] http://hackage.haskell.org/package/bloxorz Cheers, -- Felipe. From daniel.is.fischer at web.de Wed Nov 18 03:47:31 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Nov 18 03:24:25 2009 Subject: [Haskell-cafe] hipmunkplayground on windows In-Reply-To: <20091118075625.GB14947@kira.casa> References: <20091118075625.GB14947@kira.casa> Message-ID: <200911180947.32804.daniel.is.fischer@web.de> Am Mittwoch 18 November 2009 08:56:26 schrieb Felipe Lessa: > On Tue, Nov 17, 2009 at 10:21:07PM -0800, Anatoly Yakovenko wrote: > > Anyone else seeing a bunch of linker errors when trying to install > > HipmunkPlayground? > > Hmmm, no, I've never seen those errors before. Are you able to > compile any OpenGL programs at all? You may try, for example, > installing the game 'bloxorz'[1]. > > [1] http://hackage.haskell.org/package/bloxorz I don't think that'll work: Quaternion.hs:34:26: Couldn't match expected type `GLfloat' against inferred type `Float' In the expression: (r00 :: GLfloat) In the second argument of `newMatrix', namely `[(r00 :: GLfloat), r01, r02, r03, ....]' In the expression: newMatrix ColumnMajor [(r00 :: GLfloat), r01, r02, r03, ....] cabal: Error: some packages failed to install: bloxorz-0.1 failed during the building phase. The exception was: exit: ExitFailure 1 > > Cheers, > > -- > Felipe. From marlowsd at gmail.com Wed Nov 18 03:53:31 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Wed Nov 18 03:29:08 2009 Subject: [Haskell-cafe] ANNOUNCE: deepseq-1.0.0.0 In-Reply-To: <09552E18-4CAF-4C90-83E6-468631B90F31@ece.cmu.edu> References: <4B028245.1080201@gmail.com> <09552E18-4CAF-4C90-83E6-468631B90F31@ece.cmu.edu> Message-ID: <4B03B60B.6010104@gmail.com> On 17/11/2009 18:42, Brandon S. Allbery KF8NH wrote: > On Nov 17, 2009, at 11:36 , Bryan O'Sullivan wrote: >> On Tue, Nov 17, 2009 at 3:00 AM, Simon Marlow > > wrote: >> >> I've just uploaded deepseq-1.0.0.0 to Hackage >> >> http://hackage.haskell.org/package/deepseq >> >> This provides a DeepSeq class with a deepseq method, equivalent to >> the existing NFData/rnf in the parallel package. >> >> >> >> If it's equivalent, what are the relevant differences? Why would I >> choose DeepSeq over NFData or vice versa? > > Considering that he said he's going to be using it in parallel, the > difference is merely that it's usable *without* parallel. It's about > dependencies, not functionality. Yes, that's exactly it. No new functionality relative to NFData, just moving it to a more appropriate place. Cheers, Simon From marlowsd at gmail.com Wed Nov 18 03:55:28 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Wed Nov 18 03:31:02 2009 Subject: [Haskell-cafe] ANNOUNCE: deepseq-1.0.0.0 In-Reply-To: <1258460604-sup-9104@peray> References: <4B028245.1080201@gmail.com> <1258460604-sup-9104@peray> Message-ID: <4B03B680.3060108@gmail.com> On 17/11/2009 12:25, Nicolas Pouillard wrote: > Excerpts from Simon Marlow's message of Tue Nov 17 12:00:21 +0100 2009: >> I've just uploaded deepseq-1.0.0.0 to Hackage > > Great! > > I'm wondering what is the need/purpose for DeepSeqIntegral and DeepSeqOrd? I don't actually know, they were previously NFDataIntegral and NFDataOrd respectively. Unless anyone can think of a reason to want these, I'll remove them. Cheers, Simon From marlowsd at gmail.com Wed Nov 18 04:17:31 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Wed Nov 18 03:53:05 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: deepseq-1.0.0.0 In-Reply-To: References: <4B028245.1080201@gmail.com> Message-ID: <4B03BBAB.2090006@gmail.com> On 18/11/2009 03:48, Dean Herington wrote: > At 11:00 AM +0000 11/17/09, Simon Marlow wrote: >> I've just uploaded deepseq-1.0.0.0 to Hackage >> >> http://hackage.haskell.org/package/deepseq >> >> This provides a DeepSeq class with a deepseq method, equivalent to the >> existing NFData/rnf in the parallel package. I'll be using this in a >> newly revamped parallel package, which I hope to upload shortly. >> >> Cheers, >> Simon > > The documentation claim that "The default implementation of 'deepseq' is > simply 'seq'" is not exactly right, as `deepseq` and `seq` have > different signatures. Which raises the more interesting question: Why > did you choose a different signature? And, would a version of `seq` with > the same signature as `deepseq` be useful? So the main difference is that with the current formulation of deepseq, you need to explicitly force the result in order to use it, either with a pattern match, another seq, or a pseq. If we used (a -> b -> b) then the top-level forcing is "built-in". Let's look at an example instance; here (1) is the current deepseq, (2) is deepseq :: a -> b -> b instance (DeepSeq a, DeepSeq b) => DeepSeq (a,b) where -- (1) deepseq (a,b) = deepseq a `seq` deepseq b -- (2) deepseq (a,b) = deepseq a . deepseq b They're both fairly similar. Most instances follow this pattern, with seq being replaced by (.). You could argue that (a -> b -> b) is "doing more" than (a -> ()), because it has a kind of built-in continuation (Luke's point). I buy that, although (a -> ()) has a strange-looking unit type in the result and you have to use it in conjunction with seq. (1) generates slightly better code with GHC, because it compiles seq directly into a case expression, whereas (.) involves a thunk. If deepseq is inlined all the way down, then it would turn into the same thing either way. I don't feel terribly strongly, but I have a slight preference for the current version. Cheers, Simon From bulat.ziganshin at gmail.com Wed Nov 18 04:36:39 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Nov 18 04:12:24 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: deepseq-1.0.0.0 In-Reply-To: <4B03BBAB.2090006@gmail.com> References: <4B028245.1080201@gmail.com> <4B03BBAB.2090006@gmail.com> Message-ID: <1174878203.20091118123639@gmail.com> Hello Simon, Wednesday, November 18, 2009, 12:17:31 PM, you wrote: > You could argue that (a -> b -> b) is "doing more" than (a -> ()), if i correctly understand, we have two versions: 1) easier to use 2) more efficient and one of them may be defined via another? how about providing both versions, with simpler name for simpler version? -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From apfelmus at quantentunnel.de Wed Nov 18 04:45:41 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Wed Nov 18 04:21:41 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: deepseq-1.0.0.0 In-Reply-To: <4B028245.1080201@gmail.com> References: <4B028245.1080201@gmail.com> Message-ID: Simon Marlow wrote: > I've just uploaded deepseq-1.0.0.0 to Hackage > > http://hackage.haskell.org/package/deepseq > > This provides a DeepSeq class with a deepseq method, equivalent to the > existing NFData/rnf in the parallel package. I'll be using this in a > newly revamped parallel package, which I hope to upload shortly. Any reason for the name change? I liked "normal form" being part of NFData and rnf . Regards, apfelmus -- http://apfelmus.nfshost.com From simonpj at microsoft.com Wed Nov 18 05:10:38 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Wed Nov 18 04:46:07 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> Message-ID: <59543203684B2244980D7E4057D5FBC1084FB67D@DB3EX14MBXC310.europe.corp.microsoft.com> | Simon, have you given any thought to how this interacts with type system | extensions, in particular with GADTs and type families? The proposal relies | on being able to "find the type" of a term but it's not entirely clear to me | what that means. Here is an example: | | foo :: F Int -> Int | foo :: Int -> Int | | bar1 :: Int -> Int | bar1 = foo | | bar2 :: Int ~ F Int => Int -> Int | bar2 = foo | | IIUC, bar1 is ok but bar2 isn't. Do we realy want to have such a strong | dependency between name lookup and type inference? Can name lookup be | specified properly without also having to specify the entire inference | algorithm? Yes I think it can, although you are right to point out that I said nothing about type inference. One minor thing is that you've misunderstood the proposal a bit. It ONLY springs into action when there's a dot. So you'd have to write bar1 x = x.foo bar2 x = x.foo OK so now it works rather like type functions. Suppose, the types with which foo was in scope were foo :: Int -> Int foo :: Bool -> Char Now imagine that we had a weird kind of type function type instance TDNR_foo Int = Int -> Int type instance TDNR_foo Bool = Bool -> Char Each 'foo' gives a type instance for TDNR_foo, mapping the type of the first argument to the type of that foo. So when we see (x.foo) we produce the following constraints TDNR_foo tx ~ tx -> tr where x:tx and the result type is tr. Then we can solve at our leisure. We can't make progress until we know 'tx', but when we do we can choose which foo is used. Of course, there'd be some modest built-in machinery rather than a forest of Now you rightly ask what if foo :: F Int -> Int Now under my "type function" analogy, we'd get type instance TDNR_foo (F Int) = F Int -> Int and now we may be in trouble because type functions can't have a type function call in an argument pattern. I hadn't thought of that. The obvious thing to do is to *refrain* from adding a "type instance" for such a 'foo'. But that would be a bit odd, because it would silently mean that some 'foo's (the ones whose first argument involved type functions) just didn't participate in TDNR at all. But we can hardly emit a warning message for every function with a type function in the first argument! I suppose that if you use x.foo, we could warn if any in-scope foo's have this property, saying "you might have meant one of these, but I can't even consider them". GADTs, on the other hand, are no problem. | Another example: suppose we have | | data T a where | TInt :: T Int | TBool :: T Bool | | foo :: T Int -> u | foo :: T Bool -> u | | bar :: T a -> u | bar x = case x of | TInt -> foo x | TBool -> foo x | | Here, (foo x) calls different functions in the two alternatives, right? To be | honest, that's not something I'd like to see in Haskell. You mean x.foo and x.foo, right? Then yes, certainly. Of course that's already true of type classes: data T a where T1 :: Show a => T a T2 :: Sow a => T a bar :: a -> T a -> String bar x y = case y of T1 -> show x T2 -> show x Then I get different show's. Simon From simonpj at microsoft.com Wed Nov 18 05:10:39 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Wed Nov 18 04:46:18 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <4B0364D1.4000402@freegeek.org> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> <4B0297FC.3000702@kent.ac.uk> <4B0364D1.4000402@freegeek.org> Message-ID: <59543203684B2244980D7E4057D5FBC1084FB686@DB3EX14MBXC310.europe.corp.microsoft.com> It's always tempting to spend a lot of time on syntax, but in this case it may be justified. Syntactic brevity is a good part of the point of TDNR. And I'm on a train which is a good time to argue about syntax. Personally I think there are strong advantages to ".": * For record selectors, currently written (x r), writing r.x is exactly right * For these unary operators, r.x really does mean (abstractly) "select the x field from r" * And that is the way that "." is used for modules: "M.x" means "select the x function from module M" * You can think of qualified names for modules in the same way "Control.Monad" means pick the Monad module from the Control group. * It culturally fits with the way "." is used on OO languages What is the disadvantage? Well, Haskell already uses "." for composition. But * "." is already special. If you write M.x you mean a qualified name, not the composition of data constructor M with function x I merely propose to make it even special-er! I'll keep quiet about syntax now. Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe- | bounces@haskell.org] On Behalf Of wren ng thornton | Sent: 18 November 2009 03:07 | To: Haskell Cafe | Subject: Re: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? | | Neil Brown wrote: | > Having skimmed the page, it seems like the re-use of "." is one of the | > major difficulties of the proposal. Would it be possible to use "->"? | > It has been used for accessing members in C and C++, so it is not too | > unusual a choice. | | It's also the one that Perl went with. | | | > It is already special in Haskell so it wouldn't break | > anyone's code -- but do its other uses (case statements and lambdas) | > mean that it would cause problems in the grammar if re-used for TDNR? | | Given the other uses of -> in Haskell, I'm hesitant to suggest it | either. I seem to recall # is the option used by OCaml and a few other | functional-OO languages. So far as I know -XMagicHash is the only thing | that would conflict with that name so it seems far less invasive than . | or ->. Another option would be to use @ which is currently forbidden in | expressions, though that might cause issues with System F/Core. | | -- | Live well, | ~wren | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe From rl at cse.unsw.edu.au Wed Nov 18 05:58:42 2009 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Wed Nov 18 05:34:15 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <59543203684B2244980D7E4057D5FBC1084FB67D@DB3EX14MBXC310.europe.corp.microsoft.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> <59543203684B2244980D7E4057D5FBC1084FB67D@DB3EX14MBXC310.europe.corp.microsoft.com> Message-ID: <7668DC2C-2397-47F8-B458-F6C4B1CFD7D8@cse.unsw.edu.au> On 18/11/2009, at 21:10, Simon Peyton-Jones wrote: > Yes I think it can, although you are right to point out that I said nothing about type inference. One minor thing is that you've misunderstood the proposal a bit. It ONLY springs into action when there's a dot. So you'd have to write > bar1 x = x.foo > bar2 x = x.foo Yes, that's what I meant to write, silly me. I promise to pay more attention next time. > OK so now it works rather like type functions. Suppose, the types with which foo was in scope were > foo :: Int -> Int > foo :: Bool -> Char > > Now imagine that we had a weird kind of type function > > type instance TDNR_foo Int = Int -> Int > type instance TDNR_foo Bool = Bool -> Char > > Each 'foo' gives a type instance for TDNR_foo, mapping the type of the first argument to the type of that foo. Hmm... GHC doesn't allow this: type instance TDNR_foo () = forall a. () -> a -> a IIUC this restriction is necessary to guarantee termination. Given your analogy, wouldn't this proposal run into similar problems? > | Another example: suppose we have > | > | data T a where > | TInt :: T Int > | TBool :: T Bool > | > | foo :: T Int -> u > | foo :: T Bool -> u > | > | bar :: T a -> u > | bar x = case x of > | TInt -> foo x > | TBool -> foo x > | > | Here, (foo x) calls different functions in the two alternatives, right? To be > | honest, that's not something I'd like to see in Haskell. > > You mean x.foo and x.foo, right? Then yes, certainly. > > Of course that's already true of type classes: > > data T a where > T1 :: Show a => T a > T2 :: Sow a => T a > > bar :: a -> T a -> String > bar x y = case y of > T1 -> show x > T2 -> show x > > Then I get different show's. How so? Surely you'll get the same Show instance in both cases unless you have conflicting instances in your program? Roman From icfp.publicity at googlemail.com Wed Nov 18 06:14:41 2009 From: icfp.publicity at googlemail.com (Wouter Swierstra) Date: Wed Nov 18 05:50:09 2009 Subject: [Haskell-cafe] ICFP '10: Second call for workshop proposals Message-ID: <53ff55480911180314t2a7b2dcdw93974b6affe3a471@mail.gmail.com> CALL FOR WORKSHOP AND CO-LOCATED EVENT PROPOSALS ICFP 2010 15th ACM SIGPLAN International Conference on Functional Programming September 27 - 29, 2010 Baltimore, Maryland http://www.icfpconference.org/icfp2010 The 15th ACM SIGPLAN International Conference on Functional Programming will be held in Baltimore, Maryland on September 27-29, 2010. ICFP provides a forum for researchers and developers to hear about the latest work on the design, implementations, principles, and uses of functional programming. Proposals are invited for workshops (and other co-located events, such as tutorials) to be affiliated with ICFP 2010 and sponsored by SIGPLAN. These events should be more informal and focused than ICFP itself, include sessions that enable interaction among the attendees, and be fairly low-cost. The preference is for one-day events, but other schedules can also be considered. ---------------------------------------------------------------------- Submission details Deadline for submission: November 20, 2009 Notification of acceptance: December 18, 2009 Prospective organizers of workshops or other co-located events are invited to submit a completed workshop proposal form in plain text format to the ICFP 2010 workshop co-chairs (Derek Dreyer and Chris Stone), via email to icfp10-workshops at mpi-sws.org by November 20, 2009. (For proposals of co-located events other than workshops, please fill in the workshop proposal form and just leave blank any sections that do not apply.) Please note that this is a firm deadline. Organizers will be notified if their event proposal is accepted by December 18, 2009, and if successful, depending on the event, they will be asked to produce a final report after the event has taken place that is suitable for publication in SIGPLAN Notices. The proposal form is available at: http://www.icfpconference.org/icfp2010/icfp10-workshops-form.txt Further information about SIGPLAN sponsorship is available at: http://acm.org/sigplan/sigplan_workshop_proposal.htm ---------------------------------------------------------------------- Selection committee The proposals will be evaluated by a committee comprising the following members of the ICFP 2010 organizing committee, together with the members of the SIGPLAN executive committee. Workshop Co-Chair: Derek Dreyer (MPI-SWS) Workshop Co-Chair: Chris Stone (Harvey Mudd College) General Chair: Paul Hudak (Yale University) Program Chair: Stephanie Weirich (University of Pennsylvania) ---------------------------------------------------------------------- Further information Any queries should be addressed to the workshop co-chairs (Derek Dreyer and Chris Stone), via email to icfp10-workshops at mpi-sws.org. From phi500ac at yahoo.ca Wed Nov 18 06:54:38 2009 From: phi500ac at yahoo.ca (Philippos Apolinarius) Date: Wed Nov 18 06:30:03 2009 Subject: [Haskell-cafe] Haskell as an alternative to Java Message-ID: <49986.17415.qm@web58807.mail.re1.yahoo.com> I wonder whether the Haskell community tryed to reproduce the study Lisp as an alternative to Java,? by Ron Garret / Erann Gat. However, since that study was reproduced in almost every other language (with a fair amount of cheating going on, I believe :-), I am sure that there is a Haskell version (without cheating, I am sure :-). Here is a paper about the original study: http://www.flownet.com/gat/papers/lisp-java.pdf Here is Norvig's solution to the original problem: http://www.norvig.com/java-lisp.html Could someone send me a link to a Haskell solution, with comments? I have seen a solution in Clean, but since it was a homework in the college where I study, I am quite sure that my fellow students have just translated Norvig's solution to Clean. Therefore, it would be great if one could send me a link to a Clean solution too. __________________________________________________________________ Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail. Click on Options in Mail and switch to New Mail today or register for free at http://mail.yahoo.ca -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091118/4d4c0b8f/attachment.html From marlowsd at gmail.com Wed Nov 18 06:55:11 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Wed Nov 18 06:30:52 2009 Subject: [Haskell-cafe] Re: Announcing the GHC Bug Sweep In-Reply-To: <4B017DFA.2060207@gmail.com> References: <4B017DFA.2060207@gmail.com> Message-ID: <4B03E09F.9030406@gmail.com> On 16/11/2009 16:29, Simon Marlow wrote: > Help us weed the GHC ticket database, and get a warm fuzzy feeling from > contributing to Haskell core technology! > > There are currently ~750 tickets against GHC. Many of them have not been > looked at in months or years. Often when I go through old tickets I find > easy targets: bugs that have already been fixed, duplicates, bugs that > are not reproducible and the submitter has gone away. > > So the idea we have is this: do an incremental sweep of the whole > database, starting from the oldest tickets. Check each one, and try to > make some progress on it. If we get enough momentum going we can make > sure every ticket gets looked at every few months at the least. > > This is a game for the whole family! We don't care how much progress you > make on each ticket, just as long as someone has taken a look and moved > the ticket forward in some way. For example, you might check for > duplicates, update the metadata, ask for more information from the > submitter, try to reproduce the bug against the latest version of GHC. > > To claim a ticket all you have to do is remove it from the list on the > wiki. Full instructions are here > > http://hackage.haskell.org/trac/ghc/wiki/BugSweep > > including a list of suggestions for ways to make progress on a ticket. Thanks to all those who have helped out so far. The bug database now has fewer bugs than a couple of days ago (we're now at 738). It's not much, but we're heading in the right direction. Cheers, Simon From marlowsd at gmail.com Wed Nov 18 06:59:37 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Wed Nov 18 06:35:09 2009 Subject: [Haskell-cafe] Re: Announcing the GHC Bug Sweep In-Reply-To: <5f8b37690911161432g30454862rf428f172f618e5b3@mail.gmail.com> References: <4B017DFA.2060207@gmail.com> <20091116221628.GA24597@flit> <5f8b37690911161432g30454862rf428f172f618e5b3@mail.gmail.com> Message-ID: <4B03E1A9.9010706@gmail.com> On 16/11/2009 22:32, Michael Lesniak wrote: > Hello, > > I'm also interested and find Roman's idea about a wiki-page for > tracking motivating. > >>> So the idea we have is this: do an incremental sweep of the whole >>> database, starting from the oldest tickets. Check each one, and try to >>> make some progress on it. If we get enough momentum going we can make >>> sure every ticket gets looked at every few months at the least. > What I'd really like to see is a kind of categorization according to > the topic, difficulty etc.... I think determing these things could be > quite difficult for a GHC newbie (e.g. me). Any plans to do this? If you go to the "Custom Query" section of Trac, you can do these kinds of searches. The field "Component" is for the part of the system that the ticket applies to (e.g. compiler, run-time system, build system etc.), and "Difficulty" is a rough idea of how much work is involved. Obviously the difficulty varies a lot depending on who is doing the work, which is why I say it's a rough idea. These fields aren't always set correctly, which is one of the things that we hope to improve with the bug sweep. Cheers, Simon From haskell at benmachine.co.uk Wed Nov 18 07:43:30 2009 From: haskell at benmachine.co.uk (Ben Millwood) Date: Wed Nov 18 07:18:58 2009 Subject: Re[Haskell-cafe] cursive to foldr In-Reply-To: <49a77b7a0911172101p1a30af67teef55ba6795b3510@mail.gmail.com> References: <26368900.post@talk.nabble.com> <26399795.post@talk.nabble.com> <49a77b7a0911171839r467bc6bct5b4dbe4ae6b082ec@mail.gmail.com> <7ca3f0160911171901j196bd7b6v5513db9cec19ac6c@mail.gmail.com> <49a77b7a0911172101p1a30af67teef55ba6795b3510@mail.gmail.com> Message-ID: It looks quite neat to use the Maybe monoid here: > import Data.Monoid > searchList p = foldr (\x -> if p x then mappend (Just [x]) else id) Nothing but it seems that the Maybe Monoid instance keeps this strict. I fiddled with this a bit, and came up with the following: > instance (Monoid m) => Monoid (Maybe m) where > mempty = Nothing -- as usual > mappend (Just x) y = Just $ mappend x (fromMaybe mempty y) > mappend Nothing y = y which results in the expected behaviour (it's unsatisfyingly asymmetric, since it should (but can't) produce a Just if the second argument is Just without pattern-matching on the first, but there is only so much one can do without involving scary things like unamb). I'd be interested in what people thought of the relative merits of this alternative Monoid instance, but perhaps that would be a subject for a different thread. From gabor at mac.com Wed Nov 18 08:03:59 2009 From: gabor at mac.com (Gabor Greif) Date: Wed Nov 18 07:39:28 2009 Subject: [Haskell-cafe] pthread_kill missing? Message-ID: <4B03F0BF.1070808@mac.com> Hi all, I'd like to send a signal from the main thread to a forkOS-ed thread in GHC. The former should use raiseSignal and the second should sit in awaitSignal. I figured that the posix functionality in the unix-2.3 library does not cover this case. I would have expected that blocking/sending/receiving signals would utilize the pthread_* routines. This does not seem to be the case. Any idea when these will be available? Thanks in advance, cheers, Gabor PS: I guess some of you will say, "use condition variables". But that won't answer my question :-) From svein.ove at aas.no Wed Nov 18 08:15:44 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Wed Nov 18 07:51:11 2009 Subject: [Haskell-cafe] pthread_kill missing? In-Reply-To: <4B03F0BF.1070808@mac.com> References: <4B03F0BF.1070808@mac.com> Message-ID: <221b53ab0911180515u1420ec0fu6cd02b28bc393b22@mail.gmail.com> On Wed, Nov 18, 2009 at 2:03 PM, Gabor Greif wrote: > PS: I guess some of you will say, "use condition variables". > But that won't answer my question :-) > Actually, I was going to say "use throwTo". Is there som reason you have to use the POSIX routines directly instead of using native haskell exceptions? -- Svein Ove Aas From flippa at flippac.org Wed Nov 18 08:17:21 2009 From: flippa at flippac.org (Philippa Cowderoy) Date: Wed Nov 18 07:52:58 2009 Subject: [Haskell-cafe] GHCi's :t misbehaving In-Reply-To: <7ca3f0160911171830g30d58925ye37db5a88eae1145@mail.gmail.com> References: <4B034E71.60808@flippac.org> <7ca3f0160911171830g30d58925ye37db5a88eae1145@mail.gmail.com> Message-ID: <4B03F3E1.6080605@flippac.org> Luke Palmer wrote: > It's very hard to tell what is going on without more details. If you > *at least* give the ghci session, and possibly the whole code (while > it might be too much to read, it is not to much to load and try > ourselves). > > This looks like a monomorphism restriction, which shouldn't happen > when you are using :t. So that's why more info is necessary. > I was using GHC 6.10.3 because I'd not felt like building my own gtk2hs on windows - it looks like it's fixed in 6.10.4, there was a remaining type error that 6.10.3 wasn't flagging up. -- flippa@flippac.org From marlowsd at gmail.com Wed Nov 18 09:21:54 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Wed Nov 18 08:57:29 2009 Subject: [Haskell-cafe] ANNOUNCE: parallel-2.0.0.0 Message-ID: <4B040302.4070202@gmail.com> I've just uploaded parallel-2.0.0.0 to Hackage. If you're using Strategies at all, I'd advise updating to this version of the parallel package. It's not completely API compatible, but if you're just using the supplied Strategies such as parList, the changes should be relatively minor. The Haddock docs include a full description of the changes, reproduced below. Haddock docs are also here, until Hackage catches up: http://www.haskell.org/~simonmar/parallel/index.html The Strategy-using programs I've tried so far go faster. Enjoy! Cheers, Simon --------------------------------------------------------------------- Version 1.x The original Strategies design is described in and the code was written by Phil Trinder, Hans-Wolfgang Loidl, Kevin Hammond et al. Version 2.x Later, during work on the shared-memory implementation of parallelism in GHC, we discovered that the original formulation of Strategies had some problems, in particular it lead to space leaks and difficulties expressing speculative parallelism. Details are in the paper \"Runtime Support for Multicore Haskell\" . This module has been rewritten in version 2. The main change is to the 'Strategy a' type synonym, which was previously @a -> Done@ and is now @a -> a@. This change helps to fix the space leak described in \"Runtime Support for Multicore Haskell\". The problem is that the runtime will currently retain the memory referenced by all sparks, until they are evaluated. Hence, we must arrange to evaluate all the sparks eventually, just in case they aren't evaluated in parallel, so that they don't cause a space leak. This is why we must return a \"new\" value after applying a 'Strategy', so that the application can evaluate each spark created by the 'Strategy'. The simple rule is this: you /must/ use the result of applying a 'Strategy' if the strategy creates parallel sparks, and you should probably discard the the original value. If you don't do this, currently it may result in a space leak. In the future (GHC 6.14), it will probably result in lost parallelism instead, as we plan to change GHC so that unreferenced sparks are discarded rather than retained (we can't make this change until most code is switched over to this new version of Strategies, because code using the old verison of Strategies would be broken by the change in policy). The other changes in version 2.x are: * Strategies can now be defined using a convenient Applicative type Eval. e.g. parList s = unEval $ traverse (Par . s) * 'parList' has been generalised to 'parTraverse', which works on any 'Traversable' type. * 'parList' and 'parBuffer' have versions specialised to 'rwhnf', and there are transformation rules that automatically translate e.g. @parList rwnhf@ into a call to the optimised version. * 'NFData' is deprecated; please use the @DeepSeq@ class in the @deepseq@ package instead. Note that since the 'Strategy' type changed, 'rnf' is no longer a 'Strategy': use 'rdeepseq' instead. From simonpj at microsoft.com Wed Nov 18 09:38:12 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Wed Nov 18 09:13:43 2009 Subject: [Haskell-cafe] GHCi's :t misbehaving In-Reply-To: <4B034E71.60808@flippac.org> References: <4B034E71.60808@flippac.org> Message-ID: <59543203684B2244980D7E4057D5FBC1084FC22C@DB3EX14MBXC310.europe.corp.microsoft.com> Are you wanting the type of a variable? You probably want :i What is the actual type of the variable? Or is it an expression? Without more info it's hard to help. You should be able to make a repo case without all the supporting code by defining thing1 :: thing1 = error "urk" and so on for other variables. Then :t Simon S | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On | Behalf Of Philippa Cowderoy | Sent: 18 November 2009 01:31 | To: Haskell cafe | Subject: [Haskell-cafe] GHCi's :t misbehaving | | I have some mildly complicated parsing code, that uses parsec to return | a computation (in a state monad) that handles operator precedence - so I | can handle scoped precedence/fixities, much like in Haskell. I just | spent a while bolting on some new features. More time than I'd like, I'd | left it alone for a while and it took a bit of time getting my head | around it again enough to be okay doing folds on parse results and the | like. Enough so that I've been leaning on the type checker to tell me | when I've messed up! | | So, I have something that loads into ghci okay now. I go to check the | type of one of the functions using :t and get this error: | :1:0: | Ambiguous type variable `m' in the constraint: | `Monad m' | arising from a use of `constructor' at :1:0-10 | Probable fix: add a type signature that fixes these type variable(s) | | Now I'm not about the supply the type signature, that's what I asked it | for! And it ought to typecheck okay, given that the code loaded in the | first place. I'm about to turn in for the night, but I'm wondering | what's going on here. Anyone? | | -- | flippa@flippac.org | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe From duncan.coutts at googlemail.com Wed Nov 18 09:39:10 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Wed Nov 18 09:14:41 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: deepseq-1.0.0.0 In-Reply-To: <4B03BBAB.2090006@gmail.com> References: <4B028245.1080201@gmail.com> <4B03BBAB.2090006@gmail.com> Message-ID: <1258555150.4896.13804.camel@localhost> On Wed, 2009-11-18 at 09:17 +0000, Simon Marlow wrote: > So the main difference is that with the current formulation of deepseq, > you need to explicitly force the result in order to use it, either with > a pattern match, another seq, or a pseq. If we used (a -> b -> b) then > the top-level forcing is "built-in". > > Let's look at an example instance; here (1) is the current deepseq, (2) > is deepseq :: a -> b -> b > > instance (DeepSeq a, DeepSeq b) => DeepSeq (a,b) where > -- (1) deepseq (a,b) = deepseq a `seq` deepseq b > -- (2) deepseq (a,b) = deepseq a . deepseq b > > They're both fairly similar. Most instances follow this pattern, with > seq being replaced by (.). > > You could argue that (a -> b -> b) is "doing more" than (a -> ()), > because it has a kind of built-in continuation (Luke's point). I buy > that, although (a -> ()) has a strange-looking unit type in the result > and you have to use it in conjunction with seq. I think the most important thing is to make the public interface that people use most frequently simple and easy to remember. Thus I suggest the primary function people use should be deepseq :: DeepSeq a => a -> b -> b because then all that users have to remember is: "deepseq --- like seq but more so!" That's it. Users already know how to use seq, so now they know how to use deepseq too. > (1) generates slightly better code with GHC, because it compiles seq > directly into a case expression, whereas (.) involves a thunk. If > deepseq is inlined all the way down, then it would turn into the same > thing either way. > > I don't feel terribly strongly, but I have a slight preference for the > current version. If it so happens that it is more convenient or faster to make the class and instances use the (a -> ()) style then that is fine. We can give the class method a different name. Presumably people have to write Deepseq instances much less frequently than they use deepseq. Duncan From simonpj at microsoft.com Wed Nov 18 09:43:08 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Wed Nov 18 09:18:37 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <7668DC2C-2397-47F8-B458-F6C4B1CFD7D8@cse.unsw.edu.au> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> <59543203684B2244980D7E4057D5FBC1084FB67D@DB3EX14MBXC310.europe.corp.microsoft.com> <7668DC2C-2397-47F8-B458-F6C4B1CFD7D8@cse.unsw.edu.au> Message-ID: <59543203684B2244980D7E4057D5FBC1084FC248@DB3EX14MBXC310.europe.corp.microsoft.com> | > Each 'foo' gives a type instance for TDNR_foo, mapping the type of the first | argument to the type of that foo. | | Hmm... GHC doesn't allow this: | | type instance TDNR_foo () = forall a. () -> a -> a | | IIUC this restriction is necessary to guarantee termination. Given your analogy, | wouldn't this proposal run into similar problems? Maybe so. Of course I don't propose to *really* make a type function; just a new form of constraint. I am not sure of the details. But I'm disinclined to work it through unless there's a solid consensus in favour of doing something, and I do not yet sense such a consensus. My nose tells me that the typing questions will not be a blocker. | > Of course that's already true of type classes: | > | > data T a where | > T1 :: Show a => T a | > T2 :: Show a => T a | > | > bar :: a -> T a -> String | > bar x y = case y of | > T1 -> show x | > T2 -> show x | > | > Then I get different show's. | | How so? Surely you'll get the same Show instance in both cases unless you have | conflicting instances in your program? T1 and T2 both bind a local (Show a) dictionary. I suppose you could argue that they must be the same, yes. But anyway, the original TDNR thing is perfectly well defined. It might occasionally be surprising. But that doesn't stop the OO folk from loving it. S From manlio_perillo at libero.it Wed Nov 18 10:28:53 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Wed Nov 18 10:04:25 2009 Subject: [Haskell-cafe] surrogate code points in a Char Message-ID: <4B0412B5.4050200@libero.it> Hi. The Unicode Standard (version 4.0, section 3.9, D31 - pag 76) says: """Because surrogate code points are not included in the set of Unicode scalar values, UTF-32 code units in the range 0000D800 .. 0000DFFF are ill-formed""" However GHC does not reject this code units: Prelude> print '\x0000D800' '\55296' Is this a correct behaviour? Note that Python, too (2.5.4, UCS4 build, Linux Debian), accept these code units. Thanks Manlio From csaba.hruska at gmail.com Wed Nov 18 10:29:43 2009 From: csaba.hruska at gmail.com (Csaba Hruska) Date: Wed Nov 18 10:05:08 2009 Subject: [Haskell-cafe] ANN: LambdaCube engine and Bullet physics binding Message-ID: <8914b92d0911180729u783ae1c8t44900a1d0f8dd674@mail.gmail.com> Hi everyone, I'm pleased to announce the first pre-beta-candidate-release of the LambdaCube 3D engine [1] and the bindings for the Bullet physics library [2]. The packages are just a cabal-install away. You should be able to install lambdacube-engine and lambdacube-examples right away. In order to get the physics engine running, please check the instructions on the wiki. After compiling bullet, you can try the lambdacube-bullet package as well, which shows how to combine the two. It can't be stressed enough that this project is in a very early stage, and everything is bound to change and improve a lot. I just made this publicly available in order to attract contributions, so if you have anything to share, be it bugfixes, code improvements or more and prettier examples, feel free to join in! Cheers, Csaba [1] http://haskell.org/haskellwiki/LambdaCubeEngine [2] http://haskell.org/haskellwiki/Bullet -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091118/2b101330/attachment.html From greenspan.levi at googlemail.com Wed Nov 18 10:41:02 2009 From: greenspan.levi at googlemail.com (levi) Date: Wed Nov 18 10:16:26 2009 Subject: [Haskell-cafe] Re: Status of TypeDirectedNameResolution proposal? In-Reply-To: <59543203684B2244980D7E4057D5FBC1084FC248@DB3EX14MBXC310.europe.corp.microsoft.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> <59543203684B2244980D7E4057D5FBC1084FB67D@DB3EX14MBXC310.europe.corp.microsoft.com> <7668DC2C-2397-47F8-B458-F6C4B1CFD7D8@cse.unsw.edu.au> <59543203684B2244980D7E4057D5FBC1084FC248@DB3EX14MBXC310.europe.corp.microsoft.com> Message-ID: On Nov 18, 3:43?pm, Simon Peyton-Jones wrote: > But anyway, the original TDNR thing is perfectly well defined. It might occasionally be surprising. ?But that doesn't stop the OO folk from loving it. Not only OO folks but I think anybody who works with many records having similar selectors. In the past I had hopes for Daan Leijen's "Extensible records with scoped labels" [1] to have some impact on Haskell's record system but that didn't happen. Module-scoped selectors + the fact that you need one file per module are just not very convenient. Type classes only lead to more boilerplate in this area. If I compare for instance: data D1 = D1 { d1_p :: Int } data D2 = D2 { d2_p :: Int } class P a where p :: a -> Int withP :: a -> Int -> a instance P D1 where p = d1_p withP p x = p { d1_p = x } instance P D2 where p = d2_p withP p x = p { d2_p = x } with the TDNR solution: data D1 = D1 { p :: Int } data D2 = D2 { p :: Int } I have a clear preference. I think the important issue is not so much that one can access p with OO-like notation, but that the scope of p is effectively restricted. And very often one is not done with just one type class but instead one writes many for the different record fields. It was nice to see that DDC also has something similar to TDNR [2]. I would be happy if someone corrects me and points out an easy solution for this problem, but I fail to see one. Cheers, Levi --- [1] http://legacy.cs.uu.nl/daan/pubs.html#scopedlabels [2] http://www.haskell.org/haskellwiki/DDC/FieldProjections From gue.schmidt at web.de Wed Nov 18 12:14:58 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Wed Nov 18 11:50:48 2009 Subject: [Haskell-cafe] Wiki software? Message-ID: Hi, I'm finally about to organize myself, somewhat. And am going to use a wiki for it. Does there a good one exist that's written in Haskell? G?nther From tanimoto at arizona.edu Wed Nov 18 12:17:07 2009 From: tanimoto at arizona.edu (Paulo Tanimoto) Date: Wed Nov 18 11:52:51 2009 Subject: [Haskell-cafe] Wiki software? In-Reply-To: References: Message-ID: 2009/11/18 G?nther Schmidt : > Hi, > > I'm finally about to organize myself, somewhat. > > And am going to use a wiki for it. Does there a good one exist that's > written in Haskell? > > G?nther > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/gitit From deniz.a.m.dogan at gmail.com Wed Nov 18 12:17:51 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Wed Nov 18 11:53:37 2009 Subject: [Haskell-cafe] Wiki software? In-Reply-To: References: Message-ID: <7b501d5c0911180917m54a70d8dj9e1193a6e07d221@mail.gmail.com> 2009/11/18 G?nther Schmidt : > Hi, > > I'm finally about to organize myself, somewhat. > > And am going to use a wiki for it. Does there a good one exist that's > written in Haskell? > > G?nther > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > Not what you were looking for, but org-mode in Emacs is great for "organizing stuff". -- Deniz Dogan From ekmett at gmail.com Wed Nov 18 12:39:23 2009 From: ekmett at gmail.com (Edward Kmett) Date: Wed Nov 18 12:14:58 2009 Subject: [Haskell-cafe] surrogate code points in a Char In-Reply-To: <4B0412B5.4050200@libero.it> References: <4B0412B5.4050200@libero.it> Message-ID: <7fb8f82f0911180939u74ab2bf4xf7614af622ff4c69@mail.gmail.com> Enforcing a gap in the middle of the range of Char would be exceedingly awkward to propagate through all of the libraries. Off the top of my head: 1.) Functions like succ and pred which currently work on Char as an enumeration would have to jump over the gap, to be truly anal retentive about the mapping 2.) The toEnum and fromEnum would need to make the gap vanish as well, ruining the ability to treat toEnum/fromEnum as chr/ord 3.) Every application would take a performance hit 4.) What to do in the presence of an encoding error is even more uncertain. All you can do is throw an exception that can only be caught in IO. A couple of less defensible considerations: 5.) It would break alternative encodings like utf-8b which use the invalid code points in the surrogate pair range to encode ill-formed bytes in the input stream to allow 'cut and paste'-safe round tripping of utf-8b->Char->utf-8b even in the presence of invalid binary data/codepoints. 6.) Not all data is properly encoded. Consider, Unicode data you get back from Oracle, which isn't really encoded in UTF-8, but is instead CESU-8, which encodes codepoints in the higher plane as a surrogate pair, then utf-8 encodes the surrogate pair. So, I suppose the answer would be it is functioning as designed, because the current behavior is the least bad option. =) -Edward Kmett On Wed, Nov 18, 2009 at 10:28 AM, Manlio Perillo wrote: > Hi. > > The Unicode Standard (version 4.0, section 3.9, D31 - pag 76) says: > > """Because surrogate code points are not included in the set of Unicode > scalar values, UTF-32 code units in the range 0000D800 .. 0000DFFF are > ill-formed""" > > However GHC does not reject this code units: > > Prelude> print '\x0000D800' > '\55296' > > > Is this a correct behaviour? > Note that Python, too (2.5.4, UCS4 build, Linux Debian), accept these > code units. > > > > Thanks Manlio > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091118/14bad1bb/attachment.html From gue.schmidt at web.de Wed Nov 18 12:58:10 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Wed Nov 18 12:33:37 2009 Subject: [Haskell-cafe] Wiki software? In-Reply-To: <7b501d5c0911180917m54a70d8dj9e1193a6e07d221@mail.gmail.com> References: <7b501d5c0911180917m54a70d8dj9e1193a6e07d221@mail.gmail.com> Message-ID: Hi Deniz, you're probably right, but I'm looking for a web-based solution so I could access it from different machines / desktops. I'm doing work in about half a dozen different VMs. G?nther Am 18.11.2009, 18:17 Uhr, schrieb Deniz Dogan : > 2009/11/18 G?nther Schmidt : >> Hi, >> >> I'm finally about to organize myself, somewhat. >> >> And am going to use a wiki for it. Does there a good one exist that's >> written in Haskell? >> >> G?nther >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > Not what you were looking for, but org-mode in Emacs is great for > "organizing stuff". > From jv at informatik.uni-bonn.de Wed Nov 18 13:05:12 2009 From: jv at informatik.uni-bonn.de (=?ISO-8859-15?Q?Janis_Voigtl=E4nder?=) Date: Wed Nov 18 12:40:39 2009 Subject: [Haskell-cafe] Call for Participation - PEPM'10 (co-located with POPL'10) Message-ID: <4B043758.9050408@informatik.uni-bonn.de> =============================================================== CALL FOR PARTICIPATION ACM SIGPLAN 2010 Workshop on Partial Evaluation and Program Manipulation (PEPM'10) Madrid, January 18-19, 2010 (Affiliated with POPL'10) http://www.program-transformation.org/PEPM10 =============================================================== Abstracts of all papers and presentations are available from the above web site. INVITED TALKS: * Lennart Augustsson (Standard Chartered Bank, UK) Title: O, Partial Evaluator, Where Art Thou? * Jeremy Siek (University of Colorado at Boulder, USA) Title: General Purpose Languages Should be Metalanguages. SPECIAL FEATURE: * Andy Gill, Garrin Kimmell and Kevin Matlage. Capturing Functions and Catching Satellites. CONTRIBUTED TALKS: * Nabil el Boustani and Jurriaan Hage. Corrective Hints for Type Incorrect Generic Java Programs. * Johannes Rudolph and Peter Thiemann. Mnemonics: Type-safe Bytecode Generation at Run Time. * Elvira Albert, Miguel Gomez-Zamalloa and German Puebla. PET: A Partial Evaluation-based Test Case Generation Tool for Java Bytecode. * Martin Hofmann. Igor2 - an Analytical Inductive Functional Programming System. * Jos? Pedro Magalh?es, Stefan Holdermans, Johan Jeuring and Andres L?h. Optimizing Generics Is Easy! * Michele Baggi, Mar?a Alpuente, Demis Ballis and Moreno Falaschi. A Fold/Unfold Transformation Framework for Rewrite Theories extended to CCT. * Hugh Anderson and Siau-Cheng KHOO. Regular Approximation and Bounded Domains for Size-Change Termination. * ?velyne Contejean, Pierre Courtieu, Julien Forest, Andrei Paskevich, Olivier Pons and Xavier Urbain. A3PAT, an Approach for Certified Automated Termination Proofs. * Fritz Henglein. Optimizing Relational Algebra Operations Using Generic Equivalence Discriminators and Lazy Products. * Adrian Riesco and Juan Rodriguez-Hortala. Programming with Singular and Plural Non-deterministic Functions. * Martin Hofmann and Emanuel Kitzelmann. I/O Guided Detection of List Catamorphisms. * Andrew Moss and Dan Page. Bridging the Gap Between Symbolic and Efficient AES Implementations. * Christopher Brown and Simon Thompson. Clone Detection and Elimination for Haskell. * Stefan Holdermans and Jurriaan Hage. Making Stricterness More Relevant. * Arun Lakhotia, Davidson Boccardo, Anshuman Singh and Aleardo Manacero J?nior. Context-Sensitive Analysis of Obfuscated x86 Executables. * Xin Li and Mizuhito Ogawa. Conditional Weighted Pushdown Systems and Applications. * Ivan Lazar Miljenovic. The SourceGraph Program. * Florian Haftmann. From Higher-Order Logic to Haskell: There and Back Again. IMPORTANT DATES: * Early registration deadline: December 22, 2009 * Hotel registration deadline: December 28, 2009 From lrpalmer at gmail.com Wed Nov 18 14:18:26 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Nov 18 13:53:51 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> Message-ID: <7ca3f0160911181118q155a58b8q2d94de0ea38da4d1@mail.gmail.com> You know, another solution to the records problem, which is not quite as convenient but much simpler (and has other applications) is to allow local modules. module Foo where module Bar where data Bar = Bar { x :: Int, y :: Int } module Baz where data Baz = Baz { x :: Int, y :: Int } f a b = Bar.x a + Baz.y b On Tue, Nov 17, 2009 at 5:18 AM, Simon Peyton-Jones wrote: > | What's the status of the TDNR proposal [1]? Personally I think it is a > | very good idea and I'd like to see it in Haskell'/GHC rather sooner > | than later. Working around the limitations of the current record > | system is one of my biggest pain points in Haskell and TDNR would be a > | major improvement. Thus I wonder if someone is actively working on > | this proposal? > > It's stalled. ?As far as I know, there's been very little discussion about it. ?It's not a trivial thing to implement, and it treads on delicate territory (how "." is treated). ?So I'd need to be convinced there was a strong constituency who really wanted it before adding it. > > I've added an informal straw poll to the bottom of [1] to allow you to express an opinion. > > Also I'm not very happy with the "stacking operations" part, and I'd like a better idea. > > Simon > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From greenspan.levi at googlemail.com Wed Nov 18 15:10:52 2009 From: greenspan.levi at googlemail.com (levi) Date: Wed Nov 18 14:46:15 2009 Subject: [Haskell-cafe] Re: Status of TypeDirectedNameResolution proposal? In-Reply-To: <7ca3f0160911181118q155a58b8q2d94de0ea38da4d1@mail.gmail.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> <7ca3f0160911181118q155a58b8q2d94de0ea38da4d1@mail.gmail.com> Message-ID: <3171c0b3-6645-43ce-8902-f85db6a03ec1@m16g2000yqc.googlegroups.com> On Nov 18, 8:18?pm, Luke Palmer wrote: > You know, another solution to the records problem, which is not quite > as convenient but much simpler (and has other applications) is to > allow local modules. > > module Foo where > ? module Bar where > ? ? data Bar = Bar { x :: Int, y :: Int } > ? module Baz where > ? ? data Baz = Baz { x :: Int, y :: Int } > > ? f a b = Bar.x a + Baz.y b +1 Independent of TDNR I would welcome this. Maybe Ticket 2551 ("Allow multiple modules per source file") [1] should be reconsidered. Cheers, Levi --- [1] http://hackage.haskell.org/trac/ghc/ticket/2551 From robgreayer at gmail.com Wed Nov 18 15:49:36 2009 From: robgreayer at gmail.com (Robert Greayer) Date: Wed Nov 18 15:25:01 2009 Subject: [Haskell-cafe] Re: Status of TypeDirectedNameResolution proposal? In-Reply-To: <3171c0b3-6645-43ce-8902-f85db6a03ec1@m16g2000yqc.googlegroups.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> <7ca3f0160911181118q155a58b8q2d94de0ea38da4d1@mail.gmail.com> <3171c0b3-6645-43ce-8902-f85db6a03ec1@m16g2000yqc.googlegroups.com> Message-ID: <4ec472cb0911181249m374f7acdid6e7869806e87245@mail.gmail.com> On Wed, Nov 18, 2009 at 3:10 PM, levi wrote: > On Nov 18, 8:18 pm, Luke Palmer wrote: > > You know, another solution to the records problem, which is not quite > > as convenient but much simpler (and has other applications) is to > > allow local modules. > > > > module Foo where > > module Bar where > > data Bar = Bar { x :: Int, y :: Int } > > module Baz where > > data Baz = Baz { x :: Int, y :: Int } > > > > f a b = Bar.x a + Baz.y b > > +1 > > Independent of TDNR I would welcome this. Maybe Ticket 2551 ("Allow > multiple modules per source file") [1] should be reconsidered. > Although ticket 2551 is not exactly what Luke is suggesting (which would be an extension to the language, whereas, if I'm not mistaken, 2551 is just a change to where GHC can find modules, not nesting of modules). -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091118/d7cde550/attachment.html From qdunkan at gmail.com Wed Nov 18 15:53:17 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Wed Nov 18 15:28:43 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <7ca3f0160911181118q155a58b8q2d94de0ea38da4d1@mail.gmail.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> <7ca3f0160911181118q155a58b8q2d94de0ea38da4d1@mail.gmail.com> Message-ID: <2518b95d0911181253x76ded18av66be5bd62c4654aa@mail.gmail.com> The proposal has this sentence, apparently in reference to using qualified imports: "This is sufficient, but it is just sufficiently inconvenient that people don't use it much." Does this mean qualified imports? I use them exclusively, and I'd love it if everyone else used them too. Anyway, a few concerns about TDNR as prosposed: One thing I'd really like that this would provide is shorter record selection. "b.color" is a lot nicer than "Button.btn_color b". Or would it? It seems like under a TDNR scheme to be able to write "b.color" I'd have to either import "color" explicitly or go over to the unqualified import world. I don't really want to do the latter, but I also wouldn't want to maintain explicit import lists. Also, as far as I can see this doesn't provide is nice record update syntax. If I can write "b.color" I want to be able to write "b2 = b.color := red"! I think this will also lead to either lots of name shadowing warnings or more trouble picking variable names. The short perspicuous names this allows are also the most convenient for local variables. I don't want to suddenly not be able to use a 'color' variable name because some record has a 'color' field. A record system (and OO languages) would have no trouble with 'let color = b.color' but as far as I can see TDNR would have a problem. So as far as records, TDNR doesn't seem too satisfactory. I'm also worried about the use of dot with regards to a possible future record system. If we're already using dot for TDNR it's seems like it would be even harder for a record system to use it. I'm not saying this very well, but it seems like both proposals solve overlapping problems: TDNR provides convenient "method" calls and convenient field access as a side-effect, a record system would provide convenient field access and some form of subtyping. I think records are more interesting and I worry that TDNR would lessen motivation to implement records or make them more tricky to implement. From ekmett at gmail.com Wed Nov 18 16:12:34 2009 From: ekmett at gmail.com (Edward Kmett) Date: Wed Nov 18 15:48:00 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <2518b95d0911181253x76ded18av66be5bd62c4654aa@mail.gmail.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> <7ca3f0160911181118q155a58b8q2d94de0ea38da4d1@mail.gmail.com> <2518b95d0911181253x76ded18av66be5bd62c4654aa@mail.gmail.com> Message-ID: <7fb8f82f0911181312m415daa44u625911abef683179@mail.gmail.com> On Wed, Nov 18, 2009 at 3:53 PM, Evan Laforge wrote: > The proposal has this sentence, apparently in reference to using > qualified imports: "This is sufficient, but it is just sufficiently > inconvenient that people don't use it much." Does this mean qualified > imports? I use them exclusively, and I'd love it if everyone else > used them too. > A possibly irrelevant aside: Qualified imports are some times problematic when you need to work with classes from the module. You can't define a member of two instances from different two modules that define classes with conflicting member names. This can lead to situations where you have no option but to have orphan instances. module Bar where class Foo a where foo :: a module Baz where class Quux a where foo :: a module Quaffle where import qualified Bar import qualified Baz instance Bar.Foo Int where Bar.foo = 1 -- ^- syntax error. instance Baz.Quux Int where Baz.foo = 2 I suppose this could possibly be fixed if something deep in the parser allowed a QName there. -Edward Kmett > Anyway, a few concerns about TDNR as prosposed: > > One thing I'd really like that this would provide is shorter record > selection. "b.color" is a lot nicer than "Button.btn_color b". Or > would it? It seems like under a TDNR scheme to be able to write > "b.color" I'd have to either import "color" explicitly or go over to > the unqualified import world. I don't really want to do the latter, > but I also wouldn't want to maintain explicit import lists. Also, as > far as I can see this doesn't provide is nice record update syntax. > If I can write "b.color" I want to be able to write "b2 = b.color := > red"! > > I think this will also lead to either lots of name shadowing warnings > or more trouble picking variable names. The short perspicuous names > this allows are also the most convenient for local variables. I don't > want to suddenly not be able to use a 'color' variable name because > some record has a 'color' field. A record system (and OO languages) > would have no trouble with 'let color = b.color' but as far as I can > see TDNR would have a problem. > > So as far as records, TDNR doesn't seem too satisfactory. > > I'm also worried about the use of dot with regards to a possible > future record system. If we're already using dot for TDNR it's seems > like it would be even harder for a record system to use it. I'm not > saying this very well, but it seems like both proposals solve > overlapping problems: TDNR provides convenient "method" calls and > convenient field access as a side-effect, a record system would > provide convenient field access and some form of subtyping. I think > records are more interesting and I worry that TDNR would lessen > motivation to implement records or make them more tricky to implement. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091118/7675436b/attachment.html From doaitse at swierstra.net Wed Nov 18 16:22:02 2009 From: doaitse at swierstra.net (S. Doaitse Swierstra) Date: Wed Nov 18 15:57:28 2009 Subject: [Haskell-cafe] Wiki software? In-Reply-To: References: Message-ID: <8D9547D2-6458-40E5-804C-5293C10C5BE4@swierstra.net> How about: http://hackage.haskell.org/package/orchid a simple, but nice wiki produced by one of our students Sebastiaan Visser, Doaitse Swierstra On 18 nov 2009, at 18:14, G?nther Schmidt wrote: > Hi, > > I'm finally about to organize myself, somewhat. > > And am going to use a wiki for it. Does there a good one exist > that's written in Haskell? > > G?nther > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From dave at zednenem.com Wed Nov 18 16:29:57 2009 From: dave at zednenem.com (David Menendez) Date: Wed Nov 18 16:05:23 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <7fb8f82f0911181312m415daa44u625911abef683179@mail.gmail.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> <7ca3f0160911181118q155a58b8q2d94de0ea38da4d1@mail.gmail.com> <2518b95d0911181253x76ded18av66be5bd62c4654aa@mail.gmail.com> <7fb8f82f0911181312m415daa44u625911abef683179@mail.gmail.com> Message-ID: <49a77b7a0911181329u6d01370ft8e45fc070fc3fd8e@mail.gmail.com> On Wed, Nov 18, 2009 at 4:12 PM, Edward Kmett wrote: > > Qualified imports are some times problematic when you need to work with > classes from the module. You can't define a member of two instances from > different two modules that define classes with conflicting member names. > This can lead to situations where you have no option but to have orphan > instances. > > module Bar where > class Foo a where > ?? foo :: a > > module Baz where > class Quux a where > ? foo :: a > > module Quaffle where > import qualified Bar > import qualified Baz > > instance Bar.Foo Int where > ? Bar.foo = 1 > -- ^- syntax error. > > instance Baz.Quux Int where > ? Baz.foo = 2 > > I suppose this could possibly be fixed if something deep in the parser > allowed a QName there. Try Quaffle without the qualifications. > module Quaffle where > import qualified Bar > import qualified Baz > > instance Bar.Foo Int where > foo = 1 > > instance Baz.Quux Int where > foo = 2 -- Dave Menendez From ekmett at gmail.com Wed Nov 18 16:33:17 2009 From: ekmett at gmail.com (Edward Kmett) Date: Wed Nov 18 16:08:42 2009 Subject: Re[Haskell-cafe] cursive to foldr In-Reply-To: References: <26368900.post@talk.nabble.com> <26399795.post@talk.nabble.com> <49a77b7a0911171839r467bc6bct5b4dbe4ae6b082ec@mail.gmail.com> <7ca3f0160911171901j196bd7b6v5513db9cec19ac6c@mail.gmail.com> <49a77b7a0911172101p1a30af67teef55ba6795b3510@mail.gmail.com> Message-ID: <7fb8f82f0911181333h4102e2elbacb5da06974c5b7@mail.gmail.com> On Wed, Nov 18, 2009 at 7:43 AM, Ben Millwood wrote: > It looks quite neat to use the Maybe monoid here: > > > import Data.Monoid > > searchList p = foldr (\x -> if p x then mappend (Just [x]) else id) > Nothing > > but it seems that the Maybe Monoid instance keeps this strict. I > fiddled with this a bit, and came up with the following: > > > instance (Monoid m) => Monoid (Maybe m) where > > mempty = Nothing -- as usual > > mappend (Just x) y = Just $ mappend x (fromMaybe mempty y) > > mappend Nothing y = y > The existing Monoid instance for 'Maybe a' lifts what is logically a Semigroup into a Monoid by extending the domain of the operation with a unit (Nothing). Alas, This is annoyingly not the same behavior as the MonadPlus behavior for Maybe, unlike all of the other cases where MonadPlus and Monoid happen to exist in a manner in which they coincide, and since there is no Semigroup class, it lies and claims that it transforms Monoid m => Monoid (Maybe m). Your version uses mempty from the underlying monoid, so it would break any code that relied on the existing 'lifted Semigroup' interpretation of the Maybe Monoid, which safely operate lift Semigroups-that-claim-to-be-Monoids where mempty = undefined -Edward Kmett -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091118/6076f691/attachment.html From ekmett at gmail.com Wed Nov 18 16:35:56 2009 From: ekmett at gmail.com (Edward Kmett) Date: Wed Nov 18 16:11:20 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <49a77b7a0911181329u6d01370ft8e45fc070fc3fd8e@mail.gmail.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> <7ca3f0160911181118q155a58b8q2d94de0ea38da4d1@mail.gmail.com> <2518b95d0911181253x76ded18av66be5bd62c4654aa@mail.gmail.com> <7fb8f82f0911181312m415daa44u625911abef683179@mail.gmail.com> <49a77b7a0911181329u6d01370ft8e45fc070fc3fd8e@mail.gmail.com> Message-ID: <7fb8f82f0911181335r1ef3c7bbs45993aa7b0d62369@mail.gmail.com> Thanks! Learn something new every day. =) -Edward Kmett On Wed, Nov 18, 2009 at 4:29 PM, David Menendez wrote: > On Wed, Nov 18, 2009 at 4:12 PM, Edward Kmett wrote: > > > > Qualified imports are some times problematic when you need to work with > > classes from the module. You can't define a member of two instances from > > different two modules that define classes with conflicting member names. > > This can lead to situations where you have no option but to have orphan > > instances. > > > > module Bar where > > class Foo a where > > foo :: a > > > > module Baz where > > class Quux a where > > foo :: a > > > > module Quaffle where > > import qualified Bar > > import qualified Baz > > > > instance Bar.Foo Int where > > Bar.foo = 1 > > -- ^- syntax error. > > > > instance Baz.Quux Int where > > Baz.foo = 2 > > > > I suppose this could possibly be fixed if something deep in the parser > > allowed a QName there. > > Try Quaffle without the qualifications. > > > module Quaffle where > > import qualified Bar > > import qualified Baz > > > > instance Bar.Foo Int where > > foo = 1 > > > > instance Baz.Quux Int where > > foo = 2 > > > -- > Dave Menendez > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091118/a193a690/attachment.html From ekmett at gmail.com Wed Nov 18 17:09:09 2009 From: ekmett at gmail.com (Edward Kmett) Date: Wed Nov 18 16:44:34 2009 Subject: [Haskell-cafe] ANNOUNCE: parallel-2.0.0.0 In-Reply-To: <4B040302.4070202@gmail.com> References: <4B040302.4070202@gmail.com> Message-ID: <7fb8f82f0911181409r1495483s5be5ba39e189643b@mail.gmail.com> I love the new Eval Applicative! Out of idle curiosity, can parListN be generalized to parTraverseN similar to how parList was generalized to parTraverse? Similarly, parListChunk? -Edward Kmett On Wed, Nov 18, 2009 at 9:21 AM, Simon Marlow wrote: > I've just uploaded parallel-2.0.0.0 to Hackage. If you're using Strategies > at all, I'd advise updating to this version of the parallel package. It's > not completely API compatible, but if you're just using the supplied > Strategies such as parList, the changes should be relatively minor. > > The Haddock docs include a full description of the changes, reproduced > below. Haddock docs are also here, until Hackage catches up: > > http://www.haskell.org/~simonmar/parallel/index.html > > The Strategy-using programs I've tried so far go faster. Enjoy! > > Cheers, > Simon > > --------------------------------------------------------------------- > > Version 1.x > > The original Strategies design is described in > > > > > and the code was written by > Phil Trinder, Hans-Wolfgang Loidl, Kevin Hammond et al. > > Version 2.x > > Later, during work on the shared-memory implementation of > parallelism in GHC, we discovered that the original formulation of > Strategies had some problems, in particular it lead to space leaks > and difficulties expressing speculative parallelism. Details are in > the paper \"Runtime Support for Multicore Haskell\" < > http://www.haskell.org/~simonmar/papers/multicore-ghc.pdf > >. > > This module has been rewritten in version 2. The main change is to > the 'Strategy a' type synonym, which was previously @a -> Done@ and > is now @a -> a@. This change helps to fix the space leak described > in \"Runtime Support for Multicore Haskell\". The problem is that > the runtime will currently retain the memory referenced by all > sparks, until they are evaluated. Hence, we must arrange to > evaluate all the sparks eventually, just in case they aren't > evaluated in parallel, so that they don't cause a space leak. This > is why we must return a \"new\" value after applying a 'Strategy', > so that the application can evaluate each spark created by the > 'Strategy'. > > The simple rule is this: you /must/ use the result of applying > a 'Strategy' if the strategy creates parallel sparks, and you > should probably discard the the original value. If you don't > do this, currently it may result in a space leak. In the > future (GHC 6.14), it will probably result in lost parallelism > instead, as we plan to change GHC so that unreferenced sparks > are discarded rather than retained (we can't make this change > until most code is switched over to this new version of > Strategies, because code using the old verison of Strategies > would be broken by the change in policy). > > The other changes in version 2.x are: > > * Strategies can now be defined using a convenient Applicative > type Eval. e.g. parList s = unEval $ traverse (Par . s) > > * 'parList' has been generalised to 'parTraverse', which works on > any 'Traversable' type. > > * 'parList' and 'parBuffer' have versions specialised to 'rwhnf', > and there are transformation rules that automatically translate > e.g. @parList rwnhf@ into a call to the optimised version. > > * 'NFData' is deprecated; please use the @DeepSeq@ class in the @deepseq@ > package instead. Note that since the 'Strategy' type changed, 'rnf' > is no longer a 'Strategy': use 'rdeepseq' instead. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091118/0a85a32a/attachment.html From gabor at mac.com Wed Nov 18 18:12:11 2009 From: gabor at mac.com (Gabor Greif) Date: Wed Nov 18 17:47:20 2009 Subject: [Haskell-cafe] pthread_kill missing? In-Reply-To: <221b53ab0911180515u1420ec0fu6cd02b28bc393b22@mail.gmail.com> References: <4B03F0BF.1070808@mac.com> <221b53ab0911180515u1420ec0fu6cd02b28bc393b22@mail.gmail.com> Message-ID: Am 18.11.2009 um 14:15 schrieb Svein Ove Aas: > On Wed, Nov 18, 2009 at 2:03 PM, Gabor Greif wrote: >> PS: I guess some of you will say, "use condition variables". >> But that won't answer my question :-) >> > Actually, I was going to say "use throwTo". > > Is there som reason you have to use the POSIX routines directly > instead of using native haskell exceptions? Because I'd like to eventually send signals from outside (e.g. a shell) too. This is in fact a stripped-down version of a real program written in C mainly to demonstrate how much easier it is to get the same functionality in Haskell. How much work would it be to add the pthread signal blocking/sending facility to the unix library? Cheers, Gabor > > > -- > Svein Ove Aas > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From caseyh at istar.ca Wed Nov 18 18:22:53 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Wed Nov 18 17:58:21 2009 Subject: [Haskell-cafe] If you haven't bought any of Knuth's fascicles yet, this is definitely the one to get. Bitwise Tricks & Techniques Message-ID: If you haven't bought any of Knuth's fascicles yet, this is definitely the one to get. "The Art of Computer Programming: Volume 4 Bitwise Tricks & Techniques Binary Decision Diagrams" Fascicle 1 Donald E. Knuth 2009 Describes basic "broadword" operations and an important class of data structures that can make computer programs run dozens - even thousands - of times faster. I started a Haskell program using bitwise operations and then discarded them thinking them to low level. I think one of the dangers of Haskell, is that I get carried away with medium and high level abstractions and think "everything" MUST be done that way. :) -- Regards, Casey From mightybyte at gmail.com Wed Nov 18 18:30:31 2009 From: mightybyte at gmail.com (MightyByte) Date: Wed Nov 18 18:05:58 2009 Subject: [Haskell-cafe] If you haven't bought any of Knuth's fascicles yet, this is definitely the one to get. Bitwise Tricks & Techniques In-Reply-To: References: Message-ID: I can't compare it with Knuth's fascicle, but the FXT book (linked to from http://www.jjj.de/fxt/) has a whole chapter on bit wizardry and is another excellent resource along these lines. On Wed, Nov 18, 2009 at 6:22 PM, Casey Hawthorne wrote: > If you haven't bought any of Knuth's fascicles yet, this is definitely > the one to get. > > "The Art of Computer Programming: Volume 4 > Bitwise Tricks & Techniques > Binary Decision Diagrams" > Fascicle 1 > Donald E. Knuth > 2009 > > Describes basic "broadword" operations and an important class of data > structures that can make computer programs run dozens - even thousands > - of times faster. > > I started a Haskell program using bitwise operations and then > discarded them thinking them to low level. > > I think one of the dangers of Haskell, is that I get carried away with > medium and high level abstractions and think "everything" MUST be done > that way. > > :) > -- > Regards, > Casey > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From caseyh at istar.ca Wed Nov 18 18:35:39 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Wed Nov 18 18:11:06 2009 Subject: [Haskell-cafe] If you haven't bought any of Knuth's fascicles yet, this is definitely the one to get. Bitwise Tricks & Techniques In-Reply-To: References: Message-ID: <7519g5lavdu2576368im5svtgc75nr1s0h@4ax.com> Thank you for the URL. On Wed, 18 Nov 2009 18:30:31 -0500, you wrote: >I can't compare it with Knuth's fascicle, but the FXT book (linked to >from http://www.jjj.de/fxt/) has a whole chapter on bit wizardry and >is another excellent resource along these lines. > >On Wed, Nov 18, 2009 at 6:22 PM, Casey Hawthorne wrote: >> If you haven't bought any of Knuth's fascicles yet, this is definitely >> the one to get. >> >> "The Art of Computer Programming: Volume 4 >> Bitwise Tricks & Techniques >> Binary Decision Diagrams" >> Fascicle 1 >> Donald E. Knuth >> 2009 >> >> Describes basic "broadword" operations and an important class of data >> structures that can make computer programs run dozens - even thousands >> - of times faster. >> >> I started a Haskell program using bitwise operations and then >> discarded them thinking them to low level. >> >> I think one of the dangers of Haskell, is that I get carried away with >> medium and high level abstractions and think "everything" MUST be done >> that way. >> >> :) >> -- >> Regards, >> Casey >> _______________________________________________ >> 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 -- Regards, Casey From twanvl at gmail.com Wed Nov 18 18:59:25 2009 From: twanvl at gmail.com (Twan van Laarhoven) Date: Wed Nov 18 18:34:43 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> Message-ID: <4B048A5D.3020702@gmail.com> Levi Greenspan wrote: > What's the status of the TDNR proposal [1]? Personally I think it is a > very good idea and I'd like to see it in Haskell'/GHC rather sooner > than later. Working around the limitations of the current record > system is one of my biggest pain points in Haskell and TDNR would be a > major improvement. Thus I wonder if someone is actively working on > this proposal? The TDNR proposal really tries to do two separate things: 1. Record syntax for function application. The proposal is to tread "x.f" or a variation thereof the same as "(f x)" 2. Type directed name lookup. The proposal is to look up overloaded names based on the type of the first function argument. Why can't these be considered separately? Is there a good reason for not using TDNR in normal function applications? The only argument I can think of (compared to the record syntax) is that it would be a bigger change. Twan From lemming at henning-thielemann.de Wed Nov 18 19:07:37 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Nov 18 18:42:10 2009 Subject: [Haskell-cafe] Some help needed to start Haskell with Yi In-Reply-To: <20091115013729.GA5060@imsc.res.in> References: <6d2443150911141020o1d50f40by6530d0f4305c1ffb@mail.gmail.com> <20091115013729.GA5060@imsc.res.in> Message-ID: <4B048C49.3090804@henning-thielemann.de> Kapil Hari Paranjape schrieb: > Hello, > > On Sat, 14 Nov 2009, Jaco van Iterson wrote: >> Only installation with 'cabal install yi' in a Cygwin shell under MS Windows >> XP ended in: >> Yi\Prelude.hs:182:9: >> Duplicate instance declarations: >> instance Category Accessor.T -- Defined at Yi\Prelude.hs:182:9-38 >> instance Category Accessor.T >> -- Defined in data-accessor-0.2.1:Data.Accessor.Private >> cabal.exe: Error: some packages failed to install: >> yi-0.6.1 failed during the building phase. The exception was: >> exit: ExitFailure 1 >> >> Seems easy to fix but I can't even find where on my drive I can find the >> source code. >> >> Where is the source? Seems to be that the author defined an orphan instance - something one should never do! From lemming at henning-thielemann.de Wed Nov 18 19:13:23 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Nov 18 18:46:37 2009 Subject: [Haskell-cafe] inversion lists In-Reply-To: <87r5ryigeb.fsf_-_@lifelogs.com> References: <26690.208.57.251.240.1258318451.squirrel@mail.alumni.caltech.edu> <5e0214850911151303w686111d8ja20d3cb76c553c5f@mail.gmail.com> <87r5ryigeb.fsf_-_@lifelogs.com> Message-ID: <4B048DA3.2060501@henning-thielemann.de> Ted Zlatanov schrieb: > On Mon, 16 Nov 2009 00:03:54 +0300 Eugene Kirpichov wrote: > > EK> 2009/11/15 Michael Mossey : >>> Can someone tell me if this is correct. I'm guessing that if I represent >>> two sets of integers by Word32 (where ith bit set means i is in the set), >>> then an algorithm to determine if x is a subset of y would go something >>> like >>> >>> >>> (y - x) == (y `exclusiveOr` x) > > EK> It's simpler: "x&~y == 0" > > Depending on the OP data set the simple bit vector may be a good > strategy, but I wonder if an inversion list would be better? Do you > expect long runs of adjacent numbers and gaps? Inversion lists tend to > encode those much more efficiently than bit vectors. > > I'm just now learning Haskell so I don't know enough to show an > implementation but inversion lists are very simple conceptually. If > your set is (2,3,4,5,8,9,10) the inversion list would be (2,6,8,11). > It's easy to generate it from a set of Ord elements. Is "inversion list" = "Gray code" ? From tomi at nomi.cz Wed Nov 18 19:24:33 2009 From: tomi at nomi.cz (=?iso-8859-2?Q?Tom=E1=B9_Janou=B9ek?=) Date: Wed Nov 18 19:00:21 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: parallel-2.0.0.0 In-Reply-To: <4B040302.4070202@gmail.com> References: <4B040302.4070202@gmail.com> Message-ID: <20091119002433.GA15007@nomi.cz> Hello, On Wed, Nov 18, 2009 at 02:21:54PM +0000, Simon Marlow wrote: > [...] > is now @a -> a@. This change helps to fix the space leak described > in \"Runtime Support for Multicore Haskell\". The problem is that > the runtime will currently retain the memory referenced by all > sparks, until they are evaluated. Hence, we must arrange to > evaluate all the sparks eventually, just in case they aren't > evaluated in parallel, so that they don't cause a space leak. This > [...] I tried to understand the implications of this, read the relevant sections in the paper, and put together a little piece of code: > sparkN 0 f = f > sparkN !n f = (n + 42) `par` sparkN (n-1) f > > main = sparkN 100000000 $ do > performGC > getLine I compiled that with GHC 6.10.4 and expected to get a huge space leak, which didn't happen. What am I doing wrong? Thanks in advance for any tips. Regards, -- Tom?? Janou?ek, a.k.a. Liskni_si, http://work.lisk.in/ From daniel.is.fischer at web.de Wed Nov 18 20:15:47 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Nov 18 19:53:46 2009 Subject: [Haskell-cafe] Some help needed to start Haskell with Yi In-Reply-To: <4B048C49.3090804@henning-thielemann.de> References: <6d2443150911141020o1d50f40by6530d0f4305c1ffb@mail.gmail.com> <20091115013729.GA5060@imsc.res.in> <4B048C49.3090804@henning-thielemann.de> Message-ID: <200911190215.48602.daniel.is.fischer@web.de> Am Donnerstag 19 November 2009 01:07:37 schrieb Henning Thielemann: > Kapil Hari Paranjape schrieb: > > Hello, > > > > On Sat, 14 Nov 2009, Jaco van Iterson wrote: > >> Only installation with 'cabal install yi' in a Cygwin shell under MS > >> Windows XP ended in: > >> Yi\Prelude.hs:182:9: > >> Duplicate instance declarations: > >> instance Category Accessor.T -- Defined at Yi\Prelude.hs:182:9-38 > >> instance Category Accessor.T > >> -- Defined in data-accessor-0.2.1:Data.Accessor.Private > >> cabal.exe: Error: some packages failed to install: > >> yi-0.6.1 failed during the building phase. The exception was: > >> exit: ExitFailure 1 > >> > >> Seems easy to fix but I can't even find where on my drive I can find the > >> source code. > >> > >> Where is the source? > > Seems to be that the author defined an orphan instance - something one > should never do! So what do you do if you need an instance ClassX TypeY but the author of the package that defines TypeY hasn't provided one? You can define an orphan instance or duplicate packageY but with the instance. Both are bad. Providing an orphan instance until packageY has one seems the lesser evil to me. Are there any good options? From robgreayer at gmail.com Wed Nov 18 20:54:04 2009 From: robgreayer at gmail.com (Robert Greayer) Date: Wed Nov 18 20:29:28 2009 Subject: [Haskell-cafe] Some help needed to start Haskell with Yi In-Reply-To: <4ec472cb0911181752n2512da09na451caff3b4b6426@mail.gmail.com> References: <6d2443150911141020o1d50f40by6530d0f4305c1ffb@mail.gmail.com> <20091115013729.GA5060@imsc.res.in> <4B048C49.3090804@henning-thielemann.de> <200911190215.48602.daniel.is.fischer@web.de> <4ec472cb0911181752n2512da09na451caff3b4b6426@mail.gmail.com> Message-ID: <4ec472cb0911181754s96a6313i4dcc67c91802594@mail.gmail.com> On Wed, Nov 18, 2009 at 8:15 PM, Daniel Fischer wrote: > >> Am Donnerstag 19 November 2009 01:07:37 schrieb Henning Thielemann: >> > Kapil Hari Paranjape schrieb: >> > > Hello, >> > > >> > > On Sat, 14 Nov 2009, Jaco van Iterson wrote: >> > >> Only installation with 'cabal install yi' in a Cygwin shell under MS >> > >> Windows XP ended in: >> > >> Yi\Prelude.hs:182:9: >> > >> Duplicate instance declarations: >> > >> instance Category Accessor.T -- Defined at >> Yi\Prelude.hs:182:9-38 >> > >> instance Category Accessor.T >> > >> -- Defined in data-accessor-0.2.1:Data.Accessor.Private >> > >> cabal.exe: Error: some packages failed to install: >> > >> yi-0.6.1 failed during the building phase. The exception was: >> > >> exit: ExitFailure 1 >> > >> >> > >> Seems easy to fix but I can't even find where on my drive I can find >> the >> > >> source code. >> > >> >> > >> Where is the source? >> > >> > Seems to be that the author defined an orphan instance - something one >> > should never do! >> >> So what do you do if you need an instance ClassX TypeY but the author of >> the package that >> defines TypeY hasn't provided one? >> >> You can define an orphan instance or duplicate packageY but with the >> instance. Both are >> bad. Providing an orphan instance until packageY has one seems the lesser >> evil to me. >> Are there any good options? > > Whether it qualifies as 'good' or not, I'm not sure, but I think the standard recommendation is to newtype-wrap the type you want to make an orphan instance of, and make the instance on that (new) type. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091118/9182bb77/attachment.html From lemming at henning-thielemann.de Wed Nov 18 21:03:09 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Nov 18 20:36:00 2009 Subject: [Haskell-cafe] Some help needed to start Haskell with Yi In-Reply-To: <200911190215.48602.daniel.is.fischer@web.de> References: <6d2443150911141020o1d50f40by6530d0f4305c1ffb@mail.gmail.com> <20091115013729.GA5060@imsc.res.in> <4B048C49.3090804@henning-thielemann.de> <200911190215.48602.daniel.is.fischer@web.de> Message-ID: <4B04A75D.4090701@henning-thielemann.de> Daniel Fischer schrieb: > Am Donnerstag 19 November 2009 01:07:37 schrieb Henning Thielemann: > >> Seems to be that the author defined an orphan instance - something one >> should never do! > > So what do you do if you need an instance ClassX TypeY but the author of the package that > defines TypeY hasn't provided one? The author (me) has added the instance after it became aware to him (me) ... > You can define an orphan instance or duplicate packageY but with the instance. Both are > bad. Providing an orphan instance until packageY has one seems the lesser evil to me. > Are there any good options? A separate package for that orphan instance would be the best solution. From daniel.is.fischer at web.de Wed Nov 18 21:29:39 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Nov 18 21:06:28 2009 Subject: [Haskell-cafe] Some help needed to start Haskell with Yi In-Reply-To: <4B04A75D.4090701@henning-thielemann.de> References: <6d2443150911141020o1d50f40by6530d0f4305c1ffb@mail.gmail.com> <200911190215.48602.daniel.is.fischer@web.de> <4B04A75D.4090701@henning-thielemann.de> Message-ID: <200911190329.39888.daniel.is.fischer@web.de> Am Donnerstag 19 November 2009 03:03:09 schrieb Henning Thielemann: > Daniel Fischer schrieb: > > Am Donnerstag 19 November 2009 01:07:37 schrieb Henning Thielemann: > >> Seems to be that the author defined an orphan instance - something one > >> should never do! > > > > So what do you do if you need an instance ClassX TypeY but the author of > > the package that defines TypeY hasn't provided one? > > The author (me) has added the instance after it became aware to him (me) > ... Of course :) > > > You can define an orphan instance or duplicate packageY but with the > > instance. Both are bad. Providing an orphan instance until packageY has > > one seems the lesser evil to me. Are there any good options? > > A separate package for that orphan instance would be the best solution. I'm not sure that's really better. With a separate package, you'd have dependencies packageY, orphanInstance. When a new version of packageY with the instance is uploaded, things break in the same way. The fix is easy either way, delete the dependency orphanInstance or delete the orphan instance, but with a separate package, that stays around polluting hackage - or is there now a way to remove packages from hackage swiftly? Perhaps the very best method is to contact the author/maintainer of packageY and say you need the instance. From tzz at lifelogs.com Wed Nov 18 21:57:56 2009 From: tzz at lifelogs.com (Ted Zlatanov) Date: Wed Nov 18 21:32:59 2009 Subject: [Haskell-cafe] Re: inversion lists References: <26690.208.57.251.240.1258318451.squirrel@mail.alumni.caltech.edu> <5e0214850911151303w686111d8ja20d3cb76c553c5f@mail.gmail.com> <87r5ryigeb.fsf_-_@lifelogs.com> <4B048DA3.2060501@henning-thielemann.de> Message-ID: <87bpiz6x1n.fsf@lifelogs.com> On Thu, 19 Nov 2009 01:13:23 +0100 Henning Thielemann wrote: HT> Ted Zlatanov schrieb: >> On Mon, 16 Nov 2009 00:03:54 +0300 Eugene Kirpichov wrote: >> EK> 2009/11/15 Michael Mossey : >>>> Can someone tell me if this is correct. I'm guessing that if I represent >>>> two sets of integers by Word32 (where ith bit set means i is in the set), >>>> then an algorithm to determine if x is a subset of y would go something >>>> like >>>> >>>> >>>> (y - x) == (y `exclusiveOr` x) >> EK> It's simpler: "x&~y == 0" >> >> Depending on the OP data set the simple bit vector may be a good >> strategy, but I wonder if an inversion list would be better? Do you >> expect long runs of adjacent numbers and gaps? Inversion lists tend to >> encode those much more efficiently than bit vectors. >> >> I'm just now learning Haskell so I don't know enough to show an >> implementation but inversion lists are very simple conceptually. If >> your set is (2,3,4,5,8,9,10) the inversion list would be (2,6,8,11). >> It's easy to generate it from a set of Ord elements. HT> Is "inversion list" = "Gray code" ? No. An inversion list contains the boundaries of all the continuous intervals in the input. In other words, any time you see input of [n,n+1, n+2...n+k,n+m...] where m > k+1 your inversion list gets the entries n and n+k+1. As I said I'm just starting to learn Haskell so I can't give a proper implementation: isSuccessor:: (Num a) => a -> a -> Bool isSuccessor x y = x+1 == y inversion :: (Num a) => [a] -> [a] inversion [] = [] inversion (x:xs) = x:(inversion . dropWhile isSuccessor xs) The above is obviously broken, but the idea is to drop successive elements. I don't know how to do that in a predicate for dropWhile so I may need a different function from Data.List or elsewhere. Ted From daniel.is.fischer at web.de Wed Nov 18 22:54:13 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Nov 18 22:31:02 2009 Subject: [Haskell-cafe] Re: inversion lists In-Reply-To: <87bpiz6x1n.fsf@lifelogs.com> References: <26690.208.57.251.240.1258318451.squirrel@mail.alumni.caltech.edu> <4B048DA3.2060501@henning-thielemann.de> <87bpiz6x1n.fsf@lifelogs.com> Message-ID: <200911190454.13312.daniel.is.fischer@web.de> Am Donnerstag 19 November 2009 03:57:56 schrieb Ted Zlatanov: > On Thu, 19 Nov 2009 01:13:23 +0100 Henning Thielemann > wrote: > > HT> Ted Zlatanov schrieb: > >> On Mon, 16 Nov 2009 00:03:54 +0300 Eugene Kirpichov > >> wrote: > > EK> 2009/11/15 Michael Mossey : > >>>> Can someone tell me if this is correct. I'm guessing that if I > >>>> represent two sets of integers by Word32 (where ith bit set means i is > >>>> in the set), then an algorithm to determine if x is a subset of y > >>>> would go something like > >>>> > >>>> > >>>> (y - x) == (y `exclusiveOr` x) > > EK> It's simpler: "x&~y == 0" > > >> Depending on the OP data set the simple bit vector may be a good > >> strategy, but I wonder if an inversion list would be better? Do you > >> expect long runs of adjacent numbers and gaps? Inversion lists tend to > >> encode those much more efficiently than bit vectors. > >> > >> I'm just now learning Haskell so I don't know enough to show an > >> implementation but inversion lists are very simple conceptually. If > >> your set is (2,3,4,5,8,9,10) the inversion list would be (2,6,8,11). > >> It's easy to generate it from a set of Ord elements. > > HT> Is "inversion list" = "Gray code" ? > > No. An inversion list contains the boundaries of all the continuous > intervals in the input. In other words, any time you see input of > [n,n+1, n+2...n+k,n+m...] where m > k+1 your inversion list gets the > entries n and n+k+1. > > As I said I'm just starting to learn Haskell so I can't give a proper > implementation: > > isSuccessor:: (Num a) => a -> a -> Bool > isSuccessor x y = x+1 == y > > inversion :: (Num a) => [a] -> [a] > inversion [] = [] > inversion (x:xs) = x:(inversion . dropWhile isSuccessor xs) > > The above is obviously broken, but the idea is to drop successive > elements. I don't know how to do that in a predicate for dropWhile so I > may need a different function from Data.List or elsewhere. > > Ted > like: h :: Num a => a -> [a] -> [a] h x (y:ys) | x+1 == y = x:ys h x zs = x:(x+1):zs invlist = foldr h [] ghci> invlist [2,3,4,5,8,9,10] [2,6,8,11] ghci> invlist [4] [4,5] ghci> invlist [1,2,3,4,7,8,9,13,14,15,20,22] [1,5,7,10,13,16,20,21,22,23] ? From john at repetae.net Thu Nov 19 00:13:59 2009 From: john at repetae.net (John Meacham) Date: Wed Nov 18 23:49:23 2009 Subject: [Haskell-cafe] faster compiling for ghc In-Reply-To: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> References: <2518b95d0911111702i37456425sbf2a23305f35e64e@mail.gmail.com> Message-ID: <20091119051359.GC24358@sliver.repetae.net> A good trick is to use NOINLINE and restricted module exports to ensure changes in one module don't cause others to be recompiled. A common idiom is something like. module TypeAnalysis(typeAnalyze) where where the module is a fairly large complicated beast, but it just has the single entry point of typeAnalyze, by putting a {-# NOINLINE typeAnalyze #-} in there, you can be sure that changes to the module don't cause other modules to be recompiled in general. John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From s.clover at gmail.com Thu Nov 19 00:26:18 2009 From: s.clover at gmail.com (sterl) Date: Thu Nov 19 00:01:50 2009 Subject: [Haskell-cafe] pthread_kill missing? In-Reply-To: References: <4B03F0BF.1070808@mac.com> <221b53ab0911180515u1420ec0fu6cd02b28bc393b22@mail.gmail.com> Message-ID: <4B04D6FA.3020802@gmail.com> Gabor Greif wrote: > Because I'd like to eventually send signals from outside (e.g. a shell) > too. This is in fact a stripped-down version of a real program written > in C > mainly to demonstrate how much easier it is to get the same functionality > in Haskell. Much easier then to install a signal handler the usual way? This signal handler can in turn use standard asynchronous exceptions to send signals on to the appropriate forkIOed threads... Of course this is a different mechanism, but it feels much more idiomatic vis a vis haskell concurrency and the GHC runtime. --S From gcross at phys.washington.edu Thu Nov 19 01:28:47 2009 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Thu Nov 19 01:05:11 2009 Subject: [Haskell-cafe] Cabal + gfortran? Message-ID: <6AF661D7-68E2-4E33-9235-D25C7B8D3CB5@phys.washington.edu> Hi, I want to set up a build that compiles fortran sources in addition to the Haskell, and which maybe also eventually checks for the existence of a library or two (specifically, LAPACK and BLAS). Does anyone here have a suggestion for where I should be looking to figure out how to do this, such as a package which uses such a setup that would provide an example? Thanks, Greg From aruiz at um.es Thu Nov 19 03:25:07 2009 From: aruiz at um.es (Alberto Ruiz) Date: Thu Nov 19 03:00:31 2009 Subject: [Haskell-cafe] Cabal + gfortran? In-Reply-To: <6AF661D7-68E2-4E33-9235-D25C7B8D3CB5@phys.washington.edu> References: <6AF661D7-68E2-4E33-9235-D25C7B8D3CB5@phys.washington.edu> Message-ID: <4B0500E3.60207@um.es> Hi Gregory, The package hmatrix [1] checks for LAPACK and BLAS (and GSL) using a simple script [2] (but it does not compile fortran sources, only a few C helper functions). [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hmatrix [2] http://perception.inf.um.es/cgi-bin/darcsweb.cgi?r=hmatrix;a=headblob;f=/configure.hs Gregory Crosswhite wrote: > Hi, > > I want to set up a build that compiles fortran sources in addition to > the Haskell, and which maybe also eventually checks for the existence of > a library or two (specifically, LAPACK and BLAS). Does anyone here have > a suggestion for where I should be looking to figure out how to do this, > such as a package which uses such a setup that would provide an example? > > Thanks, > Greg > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From stephen.tetley at gmail.com Thu Nov 19 03:45:03 2009 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Thu Nov 19 03:20:26 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <4B048A5D.3020702@gmail.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <4B048A5D.3020702@gmail.com> Message-ID: <5fdc56d70911190045i3b7401f4mc71dd3c6b4af2d30@mail.gmail.com> 2009/11/18 Twan van Laarhoven : > > The TDNR proposal really tries to do two separate things: > > ?1. Record syntax for function application. > ? ?The proposal is to tread "x.f" or a variation thereof the same as "(f x)" > > ?2. Type directed name lookup. > ? ?The proposal is to look up overloaded names based on the type of the > first function argument. > > Why can't these be considered separately? Is there a good reason for not > using TDNR in normal function applications? The only argument I can think of > (compared to the record syntax) is that it would be a bigger change. Hi Twan Using the T combinator renamed to (#) for "x.f" was idiomatic Haskell a decade ago, vis: 'Client-side Web Scripting with HaskellScript" Erik Meijer, Daan Leijen and James Hook (PADL 1999) 'Modelling HTML in Haskell' Peter Thiemann (PADL 2000) Quoting Erik Meijer et al.: To reflect the influence of the OO style, we will use the postfix function application object # method = method object to mimic the object.method notation. For your first point, I'd vote for adding (#) to Data.Function... Best wishes Stephen From simonpj at microsoft.com Thu Nov 19 03:57:00 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Thu Nov 19 03:32:26 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <2518b95d0911181253x76ded18av66be5bd62c4654aa@mail.gmail.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <59543203684B2244980D7E4057D5FBC1084F95B6@DB3EX14MBXC310.europe.corp.microsoft.com> <7ca3f0160911181118q155a58b8q2d94de0ea38da4d1@mail.gmail.com> <2518b95d0911181253x76ded18av66be5bd62c4654aa@mail.gmail.com> Message-ID: <59543203684B2244980D7E4057D5FBC1084FC9FE@DB3EX14MBXC310.europe.corp.microsoft.com> | The proposal has this sentence, apparently in reference to using | qualified imports: "This is sufficient, but it is just sufficiently | inconvenient that people don't use it much." Does this mean qualified | imports? I clarified. | One thing I'd really like that this would provide is shorter record | selection. "b.color" is a lot nicer than "Button.btn_color b". Or | would it? It seems like under a TDNR scheme to be able to write | "b.color" I'd have to either import "color" explicitly or go over to | the unqualified import world. Good qn. I added a subsection "Qualified imports" to discuss. | I don't really want to do the latter, | but I also wouldn't want to maintain explicit import lists. Also, as | far as I can see this doesn't provide is nice record update syntax. | If I can write "b.color" I want to be able to write "b2 = b.color := | red"! Yes, well see "Record syntax". Might be doable. | I think this will also lead to either lots of name shadowing warnings | or more trouble picking variable names. The short perspicuous names | this allows are also the most convenient for local variables. I don't | want to suddenly not be able to use a 'color' variable name because | some record has a 'color' field. A record system (and OO languages) | would have no trouble with 'let color = b.color' but as far as I can | see TDNR would have a problem. Good point. I added a subsection "Top-level disambiguation only" | So as far as records, TDNR doesn't seem too satisfactory. I think these points are all addressable, more or less as OO languages do, as mentioned above. Thanks for the suggestions Simon From nicolas.pouillard at gmail.com Thu Nov 19 04:27:54 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Thu Nov 19 04:03:18 2009 Subject: [Haskell-cafe] Status of TypeDirectedNameResolution proposal? In-Reply-To: <4B048A5D.3020702@gmail.com> References: <3e62d4360911161602i4d8b0b13p7ddbc40d0dce64d3@mail.gmail.com> <4B048A5D.3020702@gmail.com> Message-ID: <1258622813-sup-6449@peray> Excerpts from Twan van Laarhoven's message of Thu Nov 19 00:59:25 +0100 2009: > Levi Greenspan wrote: > > What's the status of the TDNR proposal [1]? Personally I think it is a > > very good idea and I'd like to see it in Haskell'/GHC rather sooner > > than later. Working around the limitations of the current record > > system is one of my biggest pain points in Haskell and TDNR would be a > > major improvement. Thus I wonder if someone is actively working on > > this proposal? > > The TDNR proposal really tries to do two separate things: > > 1. Record syntax for function application. > The proposal is to tread "x.f" or a variation thereof the same as "(f x)" It is more like "(ModuleToGuess.f x)" than "(f x)". -- Nicolas Pouillard http://nicolaspouillard.fr From Alistair.Bayley at invesco.com Thu Nov 19 04:57:03 2009 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Thu Nov 19 04:32:27 2009 Subject: [Haskell-cafe] Wiki software? In-Reply-To: <8D9547D2-6458-40E5-804C-5293C10C5BE4@swierstra.net> References: <8D9547D2-6458-40E5-804C-5293C10C5BE4@swierstra.net> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA91102645F@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of S. > Doaitse Swierstra > > How about: > > http://hackage.haskell.org/package/orchid > > a simple, but nice wiki produced by one of our students Sebastiaan > Visser, You can see it in action here: http://funct.org/wiki/ http://funct.org/wiki/#Building%20a%20Wiki%20in%20Haskell.html Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From frodo at theshire.org Thu Nov 19 05:47:56 2009 From: frodo at theshire.org (Cristiano Paris) Date: Thu Nov 19 05:23:39 2009 Subject: [Haskell-cafe] Typefuck: Brainfuck in the type system In-Reply-To: References: <1258391970.13924.24.camel@utensil> Message-ID: On Mon, Nov 16, 2009 at 6:26 PM, Gwern Branwen wrote: > ... > Too late: > ... > http://hackage.haskell.org/package/loli What's the point with loli? Cristiano From marlowsd at gmail.com Thu Nov 19 06:24:03 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Thu Nov 19 05:59:31 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: deepseq-1.0.0.0 In-Reply-To: <4EAD957A-8BDC-4BFD-85D9-39B74D638556@cs.york.ac.uk> References: <4B028245.1080201@gmail.com> <4EAD957A-8BDC-4BFD-85D9-39B74D638556@cs.york.ac.uk> Message-ID: <4B052AD3.4040801@gmail.com> On 18/11/2009 04:05, Malcolm Wallace wrote: >> The documentation claim that "The default implementation of 'deepseq' >> is simply 'seq'" is not exactly right, as `deepseq` and `seq` have >> different signatures. > > Yes indeed. In order to use deepseq, it looks like I also need some way > to force the () return value, e.g. > > let res = deepseq (