From wren at freegeek.org Wed Apr 1 00:12:58 2009 From: wren at freegeek.org (wren ng thornton) Date: Wed Apr 1 00:00:13 2009 Subject: [Haskell-cafe] about the Godel Numbering for untyped lambda calculus In-Reply-To: References: Message-ID: <49D2E9CA.7070509@freegeek.org> John Tromp wrote: >> I am reading the book "The lambda calculus: Its syntax and Semantics" in the >> chapter about Godel Numbering but I am confused in some points. >> >> We know for Church Numerals, we have Cn = \fx.f^n(x) for some n>=0, >> i.e. C0= \fx.x and C >> 1 = \fx.fx. >> >> >From the above definition, I could guess the purpose of this kind of >> encoding is trying to encode numeral via terms. >> >> How about the Godel Numbering? From definition we know people say #M is the >> godel number of M and we also have [M] = C#M to enjoy the second fixed point >> theorem : for all F there exists X s.t. F[X] = X. >> >> What the mapping function # is standing for? How could I use it? What the #M >> will be? How to make use of the Godel Numbering? >> >> Thank you very much! > > My Wikipedia page on Binary Lambda Calculus. > > http://en.wikipedia.org/wiki/Binary_lambda_calculus > > shows a simple encoding of lc terms as bitstrings, which in > turn are in 1-1 correspondence with the natural numbers. > > It also shows how to represent bitstrings as lambda terms, > and gives an interpreter that extracts any closed term M > from its encoding #M. > > It also give several examples of how all that is applicable > to program size complexity. Also don't forget Jot[1] [1] http://barker.linguistics.fas.nyu.edu/Stuff/Iota/ -- Live well, ~wren From jnf at arcor.de Wed Apr 1 01:30:31 2009 From: jnf at arcor.de (jutaro) Date: Wed Apr 1 01:17:43 2009 Subject: [Haskell-cafe] Announcement: Beta of Leksah IDE available In-Reply-To: <1238538058.6785.11.camel@jutaro-laptop> References: <1238538058.6785.11.camel@jutaro-laptop> Message-ID: <22820084.post@talk.nabble.com> I know its 1. of April, but when I wrote that I started with Leksah June 1997 it was no intentional joke, it was just late at night. I started June 2007. J?rgen jutaro wrote: > > I'm proud to announce release 0.4.4 of Leksah, the Haskell IDE written > in Haskell. > Leksahs current features include: > * On the fly error reporting with location of compilation errors > * Completion > * Import helper for constructing the import statements > * Module browser with navigation to definition > * Search for identifiers with information about types and comments > * Project management support based on Cabal with a visual editor > * Haskell customised editor with "source candy" > * Configuration with session support, keymaps and flexible panes > For further information: leksah.org > > Please don't compare what we have reached to IDE's like VisualStudio, > Eclipse or NetBeans. I started Leksah June 1997 and work on it in my > spare time for fun. I started the project for various reasons. One was > to contribute to make Haskell successful in industry, because I suffer > from the use of inappropriate programming languages like C, C++, C# or > Java in my daily job. Another was to contribute to open source, which > I'm using privately almost exclusively. The first alpha version of > Leksah was published February 2008. Since the beginning of this year > Hamish Mackenzie joined the project and merged his Funa project with > Leksah, which gave a real boost. > > I thank the people who have encouraged and helped me with their > comments, enthusiasm and support. I learned as well that the IDE issue > is a controversial theme in the community. I learned that "IDEs are big > evil nasty things", that "if you need an IDE, something is wrong with > your language", that it is scientifically proved, that "real cool > hackers will always use Emacs or vi". Most stupid I found the recurring > comment: "Every few years there is someone who starts a Haskell IDE > project and then gives up after a few years.". That will be true for > Leksah as well, if it will not be accepted and supported by the > community. The current state of Leksah is a proof of concept, that an > IDE for Haskell is not a difficult thing to do if the community supports > it and that it will in my view be of great help and will contribute > tremendously to spread Haskell. > > So I please the members of the community to pause for a moment and try > out Leksah with a benevolent attitude. > > J?rgen Nicklisch-Franken > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/Announcement%3A-Beta-of-Leksah-IDE-available-tp22816032p22820084.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From dave at zednenem.com Wed Apr 1 01:54:44 2009 From: dave at zednenem.com (David Menendez) Date: Wed Apr 1 01:41:56 2009 Subject: [Haskell-cafe] Re: Looking for practical examples of Zippers In-Reply-To: <49D2E30C.4060000@freegeek.org> References: <20090330193532.GB4181@whirlpool.galois.com> <49D2E30C.4060000@freegeek.org> Message-ID: <49a77b7a0903312254ka4c521br936e2fdc77baaf55@mail.gmail.com> On Tue, Mar 31, 2009 at 11:44 PM, wren ng thornton wrote: > Another tricky thing for this particular example is answering the question > of what you want to call the "focus". Usually zippered datastructures are > functors, so given F X we can pick one X to be the focus and then unzip the > F around it. The functor part isn't important. You can make a zipper from any recursive structure. data Expr = Var String | Lit Int | App Expr Expr | Abs String Expr data ExprCtx = AppC1 Expr | AppC2 Expr | AbsC String data ExprZ = ExprZ { ctx :: [ExprCtx], focus :: Expr } In general, if I have a type T and functors F and F' such that T is isomorphic to F T and F' is the derivative of F, then ([F' T], T) is a zipper for T. -- Dave Menendez From dave at zednenem.com Wed Apr 1 02:02:51 2009 From: dave at zednenem.com (David Menendez) Date: Wed Apr 1 01:50:02 2009 Subject: [Haskell-cafe] Re: Looking for practical examples of Zippers In-Reply-To: References: <20090330193532.GB4181@whirlpool.galois.com> Message-ID: <49a77b7a0903312302y53d3fc91hb9857ebc53fb9955@mail.gmail.com> On Mon, Mar 30, 2009 at 3:46 PM, G??nther Schmidt wrote: > Thanks Don, > > I followed some examples but have not yet seen anything that would show me > how, for instance, turn a nested Map like > > Map Int (Map Int (Map String Double) > > into a "zipped" version. > > That is presuming of course that this use is feasible at all. Are you asking about the technique for navigating recursive structures, or did you mean something having to do with the isomorphism between "Map Int (Map Int (Map String Double))" and "Map (Int,Int,String) Double"? For the latter, the term you want is "generalized trie". -- Dave Menendez From DekuDekuplex at Yahoo.com Wed Apr 1 02:29:57 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Wed Apr 1 02:17:22 2009 Subject: [Haskell-cafe] Re: Announcement: Beta of Leksah IDE available References: <1238538058.6785.11.camel@jutaro-laptop> Message-ID: Your logo, a lowercase lambda merged with an inverted version of the same sharing a single spine, loosely resembles an uppercase 'H', and could possibly serve as a Haskell logo. It is simple, can represent simultaneously both "lambda" and "Haskell," and can easily be enlarged or reduced without loss of legibility. Why didn't you submit it in the Haskell Logo Competition? The next time this competition comes around, if you don't mind, please submit this logo as an entry! -- 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 alistair at abayley.org Wed Apr 1 02:46:29 2009 From: alistair at abayley.org (Alistair Bayley) Date: Wed Apr 1 02:33:40 2009 Subject: [Haskell-cafe] ANNOUNCE: vacuum-cairo: a cairo frontend to vacuumfor live Haskell data visualization In-Reply-To: References: <20090331054038.GA5648@whirlpool.galois.com> <49D1D9E0.8010700@bigpond.net.au> <16442B752A06A74AB4D9F9A5FF076E4B01ABA9AD@ELON17P32001A.csfb.cs-group.com> Message-ID: <79d7c4980903312346h6341bf3cy46d6cd854ae9d4c9@mail.gmail.com> 2009/3/31 Peter Verswyvelen : > Maybe GHCi has a bug when it comes to DLL lookup. > I had an application that worked fine when compiled with GHC, but failed > with GHCi (libglew.dll not found) > I used procmon?to monitor which files the GHC* processes searched, and it > seemed that the compiled version looked for libglew32.dll, while GHCi was > looking for libglew.dll > Since this only happened with our own wrapper project, I thought we made a > mistake, but maybe?you could also use procmon to figure out what GHCi is > doing, it might be a bug. ghci has a custom linker which behaves differently from gnu ld, which is what ghc uses. I don't recall the exact details (if I ever knew them), just that it differs. So something that works with ghc won't necessarily do so with ghci. Alistair From oleg at okmij.org Wed Apr 1 02:59:46 2009 From: oleg at okmij.org (oleg@okmij.org) Date: Wed Apr 1 02:49:53 2009 Subject: [Haskell-cafe] Zippers from any traversable [Was: Looking for practical examples of Zippers] Message-ID: <20090401065946.AC6B7AF97@Adric.metnet.fnmoc.navy.mil> wren ng thornton wrote: > > how, for instance, turn a nested Map like > > > > Map Int (Map Int (Map String Double) > > > > into a "zipped" version. > You can't. Or rather, you can't unless you have access to the > implementation of the datastructure itself; and Data.Map doesn't provide > enough details to do it. Actually Data.Map does provide enough details: Data.Map is a member of Traversable and anything that supports Traversable (at the very least, provides something like mapM) can be turned into a Zipper. Generically. We do not need to know any details of a data structure (or if it is a data structure: the collection may well be ephemeral, whose elements are computed on the fly). Please see the enclosed code; the code defines a function tmod to interactively traverse the collection, displaying the elements one by one and offering to modify the current element, or quit the traversal. The enclosed code implements the zipper that can only move forward. Chung-chieh Shan has well described how to turn any one-directional zipper into bi-directional. Again generically. http://conway.rutgers.edu/~ccshan/wiki/blog/posts/WalkZip3/ Although the enclosed code demonstrates the possibility of turning a Data.Map into a Zipper, one may wonder about the merits of that endeavour. Data.Map is a very rich data structure, with efficient means to focus on any given element and replace it (e.g., elemAt, replaceAt) and to incrementally deconstruct the map (deleteMax, deleteMin, minView, etc). Triple-nested maps can be processed just as effectively. The case for a tree of maps (which is essentially a file system) is described in http://okmij.org/ftp/Computation/Continuations.html#zipper-fs module ZT where import qualified Data.Traversable as T import Control.Monad.Cont import qualified Data.Map as M -- In the variant Z a k, a is the current, focused value -- evaluate (k Nothing) to move forward -- evaluate (k v) to replace the current value with v and move forward. data Zipper t a = ZDone (t a) | Z a (Maybe a -> Zipper t a) make_zipper :: T.Traversable t => t a -> Zipper t a make_zipper t = reset $ T.mapM f t >>= return . ZDone where f a = shift (\k -> return $ Z a (k . maybe a id)) zip_up :: Zipper t a -> t a zip_up (ZDone t) = t zip_up (Z _ k) = zip_up $ k Nothing reset :: Cont r r -> r reset m = runCont m id shift :: ((a -> r) -> Cont r r) -> Cont r a shift e = Cont (\k -> reset (e k)) -- Tests -- sample collections tmap = M.fromList [ (v,product [1..v]) | v <- [1..10] ] -- extract a few sample elements from the collection trav t = let (Z a1 k1) = make_zipper t (Z a2 k2) = k1 Nothing (Z a3 k3) = k2 Nothing (Z a4 k4) = k3 Nothing in [a1,a3,a4] travm = trav tmap -- Traverse and possibly modify elements of a collection tmod t = loop (make_zipper t) where loop (ZDone t) = putStrLn $ "Done\n: " ++ show t loop (Z a k) = do putStrLn $ "Current element: " ++ show a ask k ask k = do putStrLn "Enter Return, q or the replacement value: " getLine >>= check k check k "" = loop $ k Nothing check k "\r" = loop $ k Nothing check k ('q':_) = loop . ZDone . zip_up $ k Nothing check k s | [(n,_)] <- reads s = loop $ k (Just n) -- replace check k _ = putStrLn "Repeat" >> ask k testm = tmod tmap From Malcolm.Wallace at cs.york.ac.uk Wed Apr 1 04:58:36 2009 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Wed Apr 1 04:50:45 2009 Subject: [Haskell-cafe] Is there a way to see the equation reduction? In-Reply-To: References: <4d8ad03a0903311849o4763af08nbe3491f835e51b88@mail.gmail.com> Message-ID: <20090401095836.2a1c59f6.Malcolm.Wallace@cs.york.ac.uk> Daryoush Mehrtash wrote: > But I am more interested in seeing the expansion and reduction that > the execution encounters as it lazily evaluates the function. Have you tried GHood? http://www.cs.kent.ac.uk/people/staff/cr3/toolbox/haskell/GHood/ It is a bit like the recently-released Vacuum visualiser for data structures, except that it also animates the reduction sequence. (Have a look at some of the online examples - you can view the reduction steps right there in your web browser.) Regards, Malcolm From duncan.coutts at worc.ox.ac.uk Wed Apr 1 05:12:44 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Apr 1 04:59:48 2009 Subject: [Haskell-cafe] QuesoGLC / cabal extra-libraries not used? In-Reply-To: References: Message-ID: <1238577164.25888.1378.camel@localhost> On Wed, 2009-04-01 at 00:32 +0200, Peter Verswyvelen wrote: > I'm busy writing my first library for Hackage - a wrapper for > QuesoGLC, yet another OpenGL font renderer using Freetype2. So if > someone else is already doing this, stop doing so :-) > > > I've succesfully build the libquesoglc.a library from C source, and > can build my Haskell tutorial file using > > > ghc --make -lquesoglc Tutorial1.hs > > > > But I can't drop the -lquesoglc, then I get linker errors. > > > However I did specify extra-libraries: quesoglc in the cabal file, and > the package file got configured, build and installed > > > So I must be doing something wrong, but can't figure out what. You're not doing something like building the Tutorial1.hs from the top of the build tree of your package? If so it'll be picking up the local .hs files and ignoring the built and registered version of the package. You can check, use something like: ghc --make Tutorial1.hs -i \ -hide-all-packages -package base -package QuesoGLC So that you know it must only be looking at the installed QuesoGLC package. Duncan From maarten.hazewinkel at gmail.com Wed Apr 1 05:27:04 2009 From: maarten.hazewinkel at gmail.com (Maarten Hazewinkel) Date: Wed Apr 1 05:14:17 2009 Subject: [Haskell-cafe] Re: [Haskell] Marketing Haskell In-Reply-To: <87d4bwpzjj.fsf@malde.org> References: <87d4bwpzjj.fsf@malde.org> Message-ID: <63EC6697-3158-446A-9147-10B6450291A4@mac.com> That's not you usual Koala face. Must be a special Simon^H^H^H^H^HHaskell-Koala species. -------------- next part -------------- A non-text attachment was scrubbed... Name: haskell-mascot.jpg Type: image/jpeg Size: 5042 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090401/09db74c8/haskell-mascot.jpg -------------- next part -------------- On 1 Apr 2009, at 10:07, Simon Peyton-Jones wrote: > > Dear Haskell enthusiasts, > > Now that the logo issue finally has been settled, it is time to select > the proper Haskell mascot. As you are no doubt aware, Microsoft's > involvement in Haskell means that we have moved from avoiding success > at all cost to actively marketing the language, and any language > striving for success is entirely dependent on a cute and distinctive > mascot. Where would Perl be today without its camel? > > Since the recent logo discussion has demonstrated once and for all the > futility of attempting a democratic process in the Haskell community - > to be quite honest, the elected logo looks like an error message > from an IBM > mainframe - I have decided to decide on a mascot myself. > > So I hereby declare the official Haskell mascot to be the koala, in > the form of the image attached below. Please ensure that this image > accompanies any material published on the web or on paper. > > Simon > > _______________________________________________ > Haskell mailing list > Haskell@haskell.org > http://www.haskell.org/mailman/listinfo/haskell Maarten Hazewinkel maarten.hazewinkel@gmail.com Tel: 06-53 692 432 (+31-653 692 432 from outside the Netherlands) From sebf at informatik.uni-kiel.de Wed Apr 1 05:40:39 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Wed Apr 1 05:27:54 2009 Subject: [Haskell-cafe] ANNOUNCE: vacuum-cairo: a cairo frontend to vacuum for live Haskell data visualization In-Reply-To: <6CB400D3-136E-4952-BDC0-149385036F01@ece.cmu.edu> References: <20090331054038.GA5648@whirlpool.galois.com> <702553FB-753D-438F-BD2C-63C1BE4E15F3@ece.cmu.edu> <6CB400D3-136E-4952-BDC0-149385036F01@ece.cmu.edu> Message-ID: On Apr 1, 2009, at 4:02 AM, Brandon S. Allbery KF8NH wrote: > Yes, if the libsvg-cairo library is found when you run configure for > gtk2hs, it will be built. The version of libsvg-cairo that I have installed from MacPorts does not seem to work together with the native GTK+ framework for Macs. Reconfiguring gtk2hs still tells me: * The following packages will be built: ... * svgcairo : no ... Although the installer for the native GTK+ framework does not mention svg-cairo, it seems to be included: $ ls /Library/Frameworks/Cairo.framework/Resources/dev/lib/pkgconfig/ cairo-svg.pc /Library/Frameworks/Cairo.framework/Resources/dev/lib/pkgconfig/cairo- svg.pc Or am I misinterpreting the existence of this file? Trying to force gtk2hs to build svgcairo with --enable-svg complains: "librsvg requirement not met". Installing librsvg from MacPorts failed, but I guess it wouldn't have worked together with the native GTK+ anyway. Cheers, Sebastian From bugfact at gmail.com Wed Apr 1 06:04:51 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 1 05:52:04 2009 Subject: [Haskell-cafe] QuesoGLC / cabal extra-libraries not used? In-Reply-To: <1238577164.25888.1378.camel@localhost> References: <1238577164.25888.1378.camel@localhost> Message-ID: Yes, that's it. So I better more all the tutorials and demos into an Examples folder. Thanks Duncan, that should fix it, I'll test it tonight. On Wed, Apr 1, 2009 at 11:12 AM, Duncan Coutts wrote: > On Wed, 2009-04-01 at 00:32 +0200, Peter Verswyvelen wrote: > > I'm busy writing my first library for Hackage - a wrapper for > > QuesoGLC, yet another OpenGL font renderer using Freetype2. So if > > someone else is already doing this, stop doing so :-) > > > > > > I've succesfully build the libquesoglc.a library from C source, and > > can build my Haskell tutorial file using > > > > > > ghc --make -lquesoglc Tutorial1.hs > > > > > > > > But I can't drop the -lquesoglc, then I get linker errors. > > > > > > However I did specify extra-libraries: quesoglc in the cabal file, and > > the package file got configured, build and installed > > > > > > So I must be doing something wrong, but can't figure out what. > > You're not doing something like building the Tutorial1.hs from the top > of the build tree of your package? If so it'll be picking up the > local .hs files and ignoring the built and registered version of the > package. > > You can check, use something like: > > ghc --make Tutorial1.hs -i \ > -hide-all-packages -package base -package QuesoGLC > > So that you know it must only be looking at the installed QuesoGLC > package. > > Duncan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090401/ecee27ce/attachment.htm From bugfact at gmail.com Wed Apr 1 06:06:06 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 1 05:53:18 2009 Subject: [Haskell-cafe] ANNOUNCE: vacuum-cairo: a cairo frontend to vacuumfor live Haskell data visualization In-Reply-To: <79d7c4980903312346h6341bf3cy46d6cd854ae9d4c9@mail.gmail.com> References: <20090331054038.GA5648@whirlpool.galois.com> <49D1D9E0.8010700@bigpond.net.au> <16442B752A06A74AB4D9F9A5FF076E4B01ABA9AD@ELON17P32001A.csfb.cs-group.com> <79d7c4980903312346h6341bf3cy46d6cd854ae9d4c9@mail.gmail.com> Message-ID: On Wed, Apr 1, 2009 at 8:46 AM, Alistair Bayley wrote: > ghci has a custom linker which behaves differently from gnu ld, which > is what ghc uses. I don't recall the exact details (if I ever knew > them), just that it differs. So something that works with ghc won't > necessarily do so with ghci. Right. And should this be considered as a bug or a feature? If it is a feature, then we should be able to specify different libraries for GHCi in the cabal file no? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090401/9eb9f13e/attachment.htm From wss at cs.nott.ac.uk Wed Apr 1 06:12:22 2009 From: wss at cs.nott.ac.uk (Wouter Swierstra) Date: Wed Apr 1 05:59:33 2009 Subject: [Haskell-cafe] Parsing with Proof In-Reply-To: <22814576.post@talk.nabble.com> References: <22814576.post@talk.nabble.com> Message-ID: <96232696-E63A-48EB-A5FC-6E4AE0E72BFA@cs.nott.ac.uk> > I am wondering about how to give a correctness prove of a simple > parsing > algorithm. I tried to think of a simple example but even in this > case I > don't know how. I'm not sure I understand your question, but I'm guessing you're looking for general techniques for the formal verification of combinator-based parsers. Here's a quick brain dump of related work that might help you get started. Nils Anders Danielsson wrote a verified regexp matcher in Agda a while ago. http://www.cs.chalmers.se/~ulfn/darcs/Agda2/examples/AIM6/RegExp/ Although this isn't quite parsing, the ideas are relatively simple so it's a good place to start. (Bob Harper has a theoretical pearl on the topic, which might be worth checking out to get some inspiration). More recently, Nils Anders has extended this to parser combinators together with Ulf Norell: http://www.cs.nott.ac.uk/~nad/publications/danielsson-norell-parser-combinators.pdf Alternatively, you could explore how to implement similar ideas in Coq. I'm a big Program fan and recently used it to verify some simple programs in the state monad. I've just submitted a paper about this: http://www.cse.chalmers.se/~wouter/Publications/HoareStateMonad.pdf I'd imagine you might be able to take a similar approach to applicative (or monadic) parser combinators. Doaitse Swierstra recently wrote a good overview tutorial about parser combinators in general that is certainly worth checking out: http://www.cs.uu.nl/research/techreps/repo/CS-2008/2008-044.pdf Hope this helps, Wouter From manlio_perillo at libero.it Wed Apr 1 06:16:10 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Wed Apr 1 06:03:53 2009 Subject: [Haskell-cafe] uvector package appendU: memory leak? In-Reply-To: <49D2DDE4.6010201@freegeek.org> References: <49CFC944.4050805@libero.it><20090329193408.GB32044@whirlpool.galois.com><49CFD455.8070601@libero.it><20090329201500.GC32044@whirlpool.galois.com><49CFF240.7090700@libero.it><694810ED728D46F3AFED546B0049A230@cr3lt> <49D0F430.5000006@libero.it> <49D206BB.9040001@libero.it> <49D2DDE4.6010201@freegeek.org> Message-ID: <49D33EEA.8080500@libero.it> wren ng thornton ha scritto: > Manlio Perillo wrote: >> Since ratings for each customers are parsed "at the same time", using >> a plain list would consume a lot of memory, since stream fusion can >> only be executed at the end of the parsing. >> >> On the other hand, when I want to group ratings by movies, stream >> fusion seems to work fine. >> > [...] > > For the problem as you've discussed it, I'd suggest a different > approach: You can't fit all the data into memory at once, so you > shouldn't try to. You should write one program that takes in the > per-movie grouping of data and produces a per-user file as output. Well, creating 480189 files in a directory is not a very nice thing to do to a normal file system. I should arrange files in directory, but then this starts to become too complex. The solution I'm using now just works. It takes about 950 MB of memory and 35 minutes, but it's not a big problem since: 1) Once loaded, I can serialize the data in binary format 2) I think that the program can be parallelized, parsing subsets of the files in N threads, and then merging the maps. Using this method, should optimize array copying. The problem is that unionWith seems to be lazy, and there is no no strict variant; I'm not sure. > Then > have your second program read in the reorganized data and do fusion et al. > > This reduces the problem to just writing the PerMovie -> PerUser > program. Since you still can't fit all the data into memory, that means > you can't hope to write the per-user file in one go. The data *do* fit into memory, fortunately. > [...] > > Best of luck. > Thanks Manlio From marlowsd at gmail.com Wed Apr 1 06:21:13 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Wed Apr 1 06:08:31 2009 Subject: [Haskell-cafe] Re: Building/Prerequisites->Linux->glibc-devel libedit-devel ? In-Reply-To: <694519c50903091742rc64b185w420bf941a1f55894@mail.gmail.com> References: <22376307.post@talk.nabble.com> <694519c50903091742rc64b185w420bf941a1f55894@mail.gmail.com> Message-ID: <49D34019.7070904@gmail.com> Antoine Latter wrote: > On Mon, Mar 9, 2009 at 7:14 PM, Windoze wrote: >> Greetings, >> >> am considering learning how to do a build for my slackware-based distro. >> >> The doc sited below say's it requires: >> >> glibc-devel >> libedit-devel >> ncurses-devel >> gmp-devel >> .etc. >> >> Must I used the dev versions, or will it work with the lastest, stable >> release versions of same? >> > > By "dev version" the instructions mean "be sure to install the C > header files." In Debian-like distros, such packages have the "-dev" > suffix. I'm in the process of updating these instructions. I'd be grateful if people could take a look and fix any errors, and also add other Linux distros: http://hackage.haskell.org/trac/ghc/wiki/Building/Preparation/Linux Cheers, Simon From patai_gergely at fastmail.fm Wed Apr 1 06:44:35 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Wed Apr 1 06:31:45 2009 Subject: [Haskell-cafe] ZipList monad, anyone? Message-ID: <1238582675.10366.1308390907@webmail.messagingengine.com> Does ZipList have any useful monad instance? The thought came up while thinking about higher order dataflows and an ArrowApply interface for Yampa. As a ZipList can be thought of as a function with a discrete domain, I figured its monadic form could be analogous to the reader monad, hence: instance Monad ZipList where return = ZipList . repeat ZipList xs >>= f = ZipList $ zipWith ((!!) . getZipList . f) xs [0..] Correct me if I'm wrong, but it seems to me that f always returning an infinite list is a sufficient condition for the monad laws to hold. However, this is painfully inefficient. I assume that bringing FRP-like switching and some clever data structure (which optimises stateless streams for starters) into the picture can potentially lead to constant-time access at least in the case of sequential sampling. Is there any recent work going in this direction? Gergely -- http://www.fastmail.fm - One of many happy users: http://www.fastmail.fm/docs/quotes.html From claus.reinke at talk21.com Wed Apr 1 07:07:07 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Wed Apr 1 06:54:24 2009 Subject: [Haskell-cafe] Is there a way to see the equation reduction? References: <4d8ad03a0903311849o4763af08nbe3491f835e51b88@mail.gmail.com> <20090401095836.2a1c59f6.Malcolm.Wallace@cs.york.ac.uk> Message-ID: >> But I am more interested in seeing the expansion and reduction that >> the execution encounters as it lazily evaluates the function. > > Have you tried GHood? examples: > http://www.cs.kent.ac.uk/people/staff/cr3/toolbox/haskell/GHood/ package: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/GHood > It is a bit like the recently-released Vacuum visualiser for data > structures, except that it also animates the reduction sequence. > (Have a look at some of the online examples - you can view the reduction > steps right there in your web browser.) Ahem. While I do recommend GHood for getting animated visual insights into what your program is doing, *GHood does not animate reductions* for instance, the steps of 'id id id ()' reducing will not be visible as such, though by observing the first 'id', you would be able to see all the 'id's being applied to their parameters and yielding their results (and you could add further probes) *GHood animates observations* - when the usage contexts starts looking through an observe probe for the data behind the probe (demand goes in) - when the data behind a probe has been reduced to produce a further level of WHNF (data goes out) Non-strict evaluation means that things won't be reduced unless that is forced by observation but, nevertheless, the two are not the same, they complement each other. Also, GHood/Hood do not observe sharing or when data is freed, which might be relevant for the example. On the positive side, observations can be targetted, so one can put small probes into large projects, and observations are very relevant for (relative) strictness issues. It would be nice if an animation visualizer could be built on top of Vacuum, just as GHood was built on top of Hood. Of course, I'd really like to be able to follow reductions textually as well, in a combination of editor/ide/GHCi. It was shown long ago that this needn't be in conflict with efficient implementation, such as compiled graph reduction (as I might have mentioned before;-). I doubt that the ancient code still installs properly, but the old pages or pi-RED/KiR are still there(*), so anyone building a new Haskell implementation could look at user's guide and papers for inspiration, but it would be difficult to add after the fact to an implementation as complex as GHC. Claus (*) http://www.informatik.uni-kiel.de/~base/ From sfvisser at cs.uu.nl Wed Apr 1 07:23:17 2009 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Wed Apr 1 07:10:29 2009 Subject: [Haskell-cafe] [ANN] salvia-0.1, salvia-extras-0.1 In-Reply-To: <856033f20903281426y32e25a7aw9d75694245a9a8fe@mail.gmail.com> References: <363AAAFB-C97C-4EDF-865B-F42D9CED7857@cs.uu.nl> <856033f20903281426y32e25a7aw9d75694245a9a8fe@mail.gmail.com> Message-ID: There is now. Not much new in Orchid itself, but builds against the updated Salvia. Because of the use of keep-alive the performance of orchid should be a lot better now (at some places). -- Sebastiaan On Mar 28, 2009, at 10:26 PM, Paul L wrote: > Thanks for the massive update! Is there a new version of Orchid > coming along? > > On 3/22/09, Sebastiaan Visser wrote: >> Hi all, >> >> I am pleased to announce a new version of Salvia, the lightweight >> Haskell Web Server Framework with modular support for serving static >> files, directories indices, default error responses, connection >> counting and logging, HEAD and PUT requests, keep-alives, custom >> banner printing, default handler environments for parsing request and >> printing responses, dispatching based on request methods, URI, paths >> and filename extension, URI rewriting and redirection, virtual >> hosting, cookie, session and user management and more... >> >> Changes since previous version: >> >> - Some more advanced, non-fundamental handlers have been moved to >> their own package salvia-extras. This helps pruning the >> dependencies a >> bit. >> - The package now has some default handler environments that simplify >> setting up a server application. >> - The server now has support for keep-alive, significantly increasing >> the performance. >> - The library functions are now almost fully documented instead of >> no- >> documentation-at-all in the previous versions. >> - Salvia now also works on windows (I heard). >> - Lots of code cleanups throughout the code. >> - Lots of minor bug fixes. >> >> To install: use cabal. >> >> Thanks to the people that helped me with suggestions and bug-reports! >> >> -- >> Sebastiaan. >> > -- > Regards, > Paul Liu From lrpalmer at gmail.com Wed Apr 1 07:45:58 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Apr 1 07:33:08 2009 Subject: [Haskell-cafe] ZipList monad, anyone? In-Reply-To: <1238582675.10366.1308390907@webmail.messagingengine.com> References: <1238582675.10366.1308390907@webmail.messagingengine.com> Message-ID: <7ca3f0160904010445x4c4ac154n5e8d06669618810d@mail.gmail.com> 2009/4/1 Patai Gergely > Does ZipList have any useful monad instance? The thought came up while > thinking about higher order dataflows and an ArrowApply interface for > Yampa. As a ZipList can be thought of as a function with a discrete > domain, I figured its monadic form could be analogous to the reader > monad, hence: > > instance Monad ZipList where > return = ZipList . repeat > ZipList xs >>= f = ZipList $ zipWith ((!!) . getZipList . f) xs > [0..] > > Correct me if I'm wrong, but it seems to me that f always returning an > infinite list is a sufficient condition for the monad laws to hold. > However, this is painfully inefficient. I assume that bringing FRP-like > switching and some clever data structure (which optimises stateless > streams for starters) into the picture can potentially lead to > constant-time access at least in the case of sequential sampling. Is > there any recent work going in this direction? Having spent several months on this exact problem, I'll say that I consider it pretty unlikely. To give you an idea of the frustration involved, the end of that time was no longer spent trying to implement it, but rather trying to characterize a mathematical reason that it was impossible (to no avail). A clever data structure might give you logarithmic or even amortized constant time access in sequential cases, but you probably will not have good garbage collection properties (all data will remain for all time). I don't mean to be a buzzkill without giving any concrete evidence. I've (intentionally) distanced myself from these problems for a few months, so explaining is difficult. Stick with Applicative for this type of thing. Monad will drive you insane :-) Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090401/0212ac1e/attachment.htm From claus.reinke at talk21.com Wed Apr 1 08:34:21 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Wed Apr 1 08:21:48 2009 Subject: [Haskell-cafe] Looking for practical examples of Zippers References: Message-ID: >my quest for data structures continues. Lately I came across "Zippers". >Can anybody point be to some useful examples? Once upon a time, there was a hardware implementation of a lambda calculus based functional language (mostly, I was told, to show that it could be done:-). The program representation was a string of symbols (graph reduction came later; implementation of graph reduction on stock hardware came much later) in a constructor syntax (think fully applied data constructors in Haskell, each constructor annotated with its arity). The problem: if you were to do beta-reductions somewhere in the middle of such a string, you'd have to make space or fill gaps, to adjust for the differing lengths of redex and reduced, not to mention the issue of finding and identifying the redices in the first place. Working in hardware, you couldn't quite ignore those details. The solution: use a hardware zipper representation, consisting of a system of 3 main stacks (there were auxiliary stacks to handle things like substitution), often likened to a railway shunting yard: output|_|input c o n t r o l To traverse a program expression: - the program starts on the input stack, in pre-order form (the constructors before their arguments). - take a constructor from the front of the input stack, put it on the control stack, initialising a counter for the arguments. - while there are still arguments left, recursively traverse them from input to output stack, decrementing the constructor count. - after all parameters of the constructor on top of the control stack have been traversed to the output stack, move the constructor to the output stack - the program ends up on the output stack, in post-order form (the constructors after their arguments, though still on top of them, stack-wise). That way, all sub-expressions would, at some point of the traversal, appear on the top of the three stacks, so if there was a redex on top (application constructor on control, function on one stack, argument on the other stack), the processor could replace the redex by a reduced expression without having to make room or fill gaps, or look anywhere but at the top of the stacks. There was even a special graphical notation, to specify the elaborate mix of control- and data-flow going on, but at the heart of it all was that traversal scheme over a shunting yard of stacks, based on a zipper in hardware. Claus From voigt at tcs.inf.tu-dresden.de Wed Apr 1 09:08:49 2009 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Wed Apr 1 08:56:00 2009 Subject: [Haskell-cafe] Call for Contributions - Haskell Communities and Activities Report, May 2009 edition Message-ID: <49D36761.8000001@tcs.inf.tu-dresden.de> Dear Haskellers, so much has happened in the Haskell world in the past months. Therefore, I would very much like to collect contributions for the 16th edition of the ================================================================ Haskell Communities & Activities Report http://www.haskell.org/communities/ Submission deadline: 1 May 2009 (please send your contributions to hcar at haskell.org, in plain text or LaTeX format) ================================================================ This is the short story: * If you are working on any project that is in some way related to Haskell, please write a short entry and submit it. Even if the project is very small or unfinished or you think it is not important enough -- please reconsider and submit an entry anyway! * If you are interested in any project related to Haskell that has not previously been mentioned in the HC&A Report, please tell me, so that I can contact the project leaders and ask them to submit an entry. * Feel free to pass on this call for contributions to others that might be interested. More detailed information: The Haskell Communities & Activities Report is a bi-annual overview of the state of Haskell as well as Haskell-related projects over the last, and possibly the upcoming six months. If you have only recently been exposed to Haskell, it might be a good idea to browse the November 2008 edition -- you will find interesting topics described as well as several starting points and links that may provide answers to many questions. Contributions will be collected until the submission deadline. They will then be compiled into a coherent report that is published online as soon as it is ready. As always, this is a great opportunity to update your webpages, make new releases, announce or even start new projects, or to talk about developments you want every Haskeller to know about! Looking forward to your contributions, Janis (current editor) FAQ: Q: What format should I write in? A: The required format is a LaTeX source file, adhering to the template that is available at: http://haskell.org/communities/05-2009/template.tex There is also a LaTeX style file at http://haskell.org/communities/05-2009/hcar.sty that you can use to preview your entry. If you do not know LaTeX, then use plain text. If you modify an old entry that you have written for an earlier edition of the report, you should receive your old entry as a template soon (provided I have your valid email address). Please modify that template, rather than using your own version of the old entry as a template. Q: Can I include images? A: Yes, you are even encouraged to do so. Please use .jpg format, then. Q: How much should I write? A: Authors are asked to limit entries to about one column of text. This corresponds to approximately one page, or 40 lines of text, with the above style and template. A general introduction is helpful. Apart from that, you should focus on recent or upcoming developments. Pointers to online content can be given for more comprehensive or ``historic'' overviews of a project. Images do not count towards the length limit, so you may want to use this opportunity to pep entries up. There is no minimum length of an entry! The report aims at being as complete as possible, so please consider writing an entry, even if it is only a few lines long. Q: Which topics are relevant? A: All topics which are related to Haskell in some way are relevant. We usually had reports from users of Haskell (private, academic, or commercial), from authors or contributors to projects related to Haskell, from people working on the Haskell language, libraries, on language extensions or variants. We also like reports over distributions of Haskell software, Haskell infrastructure, books and tutorials on Haskell. Reports on past and upcoming events related to Haskell are also relevant. Finally, there might be new topics we do not even think about. As a rule of thumb: if in doubt, then it probably is relevant and has a place in the HCAR. You can also ask the editor. Q: Is unfinished work relevant? Are ideas for projects relevant? A: Yes! You can use the HCAR to talk about projects you are currently working on. You can use it to look for other developers that might help you. You can use it to write ``wishlist'' items for libraries and language features you would like to see implemented. Q: If I do not update my entry, but want to keep it in the report, what should I do? A: Tell the editor that there are no changes. The old entry will be reused in this case, but it might be dropped if it is older than a year, to give more room and more attention to projects that change a lot. Do not resend complete entries if you have not changed them. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From gleb.alexeev at gmail.com Wed Apr 1 10:02:52 2009 From: gleb.alexeev at gmail.com (Gleb Alexeyev) Date: Wed Apr 1 09:49:46 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: vacuum-cairo: a cairo frontend to vacuum for live Haskell data visualization In-Reply-To: <20090331054038.GA5648@whirlpool.galois.com> References: <20090331054038.GA5648@whirlpool.galois.com> Message-ID: Don Stewart wrote: > I am pleased to announce the release of vacuum-cairo, a Haskell library > for interactive rendering and display of values on the GHC heap using > Matt Morrow's vacuum library. Awesome stuff, kudos to you and Matt Morrow! I thought it'd be fun to visualize data structures in three dimensions. Attached is quick and dirty hack based on your code and Ubigraph server (http://ubietylab.net/ubigraph/). The demo video (apologies for poor quality): http://www.youtube.com/watch?v=3mMH1cHWB6c If someone finds it fun enough, I'll cabalize it and upload to Hackage. -------------- next part -------------- A non-text attachment was scrubbed... Name: Ubigraph.hs Type: text/x-haskell Size: 1375 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090401/35f6c5bb/Ubigraph.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: VacuumUbigraph.hs Type: text/x-haskell Size: 2054 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090401/35f6c5bb/VacuumUbigraph.bin From icfp.publicity at googlemail.com Wed Apr 1 11:32:59 2009 From: icfp.publicity at googlemail.com (Matthew Fluet (ICFP Publicity Chair)) Date: Wed Apr 1 11:20:12 2009 Subject: [Haskell-cafe] DEFUN09: Call for Talks & Tutorials (co-located w/ ICFP09) Message-ID: <53ff55480904010832x36925651k6e4d884dc1acafc5@mail.gmail.com> Call for Talks and Tutorials ACM SIGPLAN 2009 Developer Tracks on Functional Programming http://www.defun2009.info/ Edinburgh, Scotland, September 3 and 5, 2009 The workshop will be held in conjunction with ICFP 2009 http://www.cs.nott.ac.uk/~gmh/icfp09.html Important dates Proposal Deadline: June 5, 2009, 0:00 UTC Notification: June 19, 2009 DEFUN 2009 invites functional programmers and researchers who know how to solve problems with functional progamming to give talks and lead tutorials at the The ICFP Developer Tracks. We want to know about your favorite programming techniques, powerful libraries, and engineering approaches you've used that the world should know about and apply to other projects. We want to know how to be productive using functional programming, write better code, and avoid common pitfalls. We invite proposals for presentations in the following categories. Lightning talks 5- to 10-minute talks that introduce exciting and promising research or techniques that may be in progress or not yet ready for widespread use, but that offer a glimpse into the near future of real world functional programming. Examples: * Clustered high performance computing in a functional language * Making advanced type systems more accessible to working programmers * How and why we're infiltrating category theory info industry How-to talks 45-minute "how-to" talks that provide specific information on how to solve specific problems using functional programming. These talks focus on concrete examples, but provide useful information for developers working on different projects or in different contexts. Examples: * "How I use Haskell for oilfield simulations." * "How I replaced /sbin/init by a Scheme program." * "How I hooked up my home appliances to an Erlang control system." * "How I got an SML program to drive my BMW." General language tutorials Half-day general language tutorials for specific functional languages, given by recognized experts for the respective languages. Technology tutorials Half-day tutorials on techniques, technologies, or solving specific problems in functional programming. Examples: * How to make the best use of specific FP programming techniques * How to inject FP into a development team used to more conventional technologies * How to connect FP to existing libraries / frameworks / platforms * How to deliver high-performance systems with FP * How to deliver high-reliability systems with FP Remember that your audience will include computing professionals who are not academics and who may not already be experts on functional programming. Presenters of tutorials will receive free registration to CUFP 2009. Submission guidelines Submit a proposal of 150 words or less for either a 45-minute talk with a short Q&A session at the end, or a 300-word-or-less proposal for a 3-hour tutorial, where you present your material, but also give participants a chance to practice it on their own laptops. Some advice: * Give it a simple and straightforward title or name; avoid fancy titles or puns that would make it harder for attendees to figure out what you'll be talking about. * Clearly identify the level of the talk: What knowledge should people have when they come to the presentation or tutorial? * Explain why people will want to attend: o Is the language or library useful for a wide range of attendees? o Is the pitfall you're identifying common enough that a wide range of attendees is likely to encounter it? * Explain what benefits attendees are expected to take home to their own projects. * For a tutorial, explain how you want to structure the time, and what you expect to have attendees to do on their laptops. List what software you'll expect attendees to have installed prior to coming. Submit your proposal in plain text electronically to defun-2009-submissions@serpentine.com by the beginning of Friday, June 5 2009, Universal Coordinated Time. Organizers * Yaron Minsky (Jane Street Capital) * Ulf Wiger (Erlang Training and Consulting) * Mike Sperber - co-chair (DeinProgramm) * Bryan O'Sullivan - co-chair (Linden Lab) From dave at zednenem.com Wed Apr 1 11:42:37 2009 From: dave at zednenem.com (David Menendez) Date: Wed Apr 1 11:29:48 2009 Subject: [Haskell-cafe] ZipList monad, anyone? In-Reply-To: <7ca3f0160904010445x4c4ac154n5e8d06669618810d@mail.gmail.com> References: <1238582675.10366.1308390907@webmail.messagingengine.com> <7ca3f0160904010445x4c4ac154n5e8d06669618810d@mail.gmail.com> Message-ID: <49a77b7a0904010842w41801cccm21326537e290912f@mail.gmail.com> 2009/4/1 Luke Palmer : > 2009/4/1 Patai Gergely >> >> Does ZipList have any useful monad instance? The thought came up while >> thinking about higher order dataflows and an ArrowApply interface for >> Yampa. As a ZipList can be thought of as a function with a discrete >> domain, I figured its monadic form could be analogous to the reader >> monad, hence: >> >> instance Monad ZipList where >> ? ?return = ZipList . repeat >> ? ?ZipList xs >>= f = ZipList $ zipWith ((!!) . getZipList . f) xs >> ? ?[0..] >> >> Correct me if I'm wrong, but it seems to me that f always returning an >> infinite list is a sufficient condition for the monad laws to hold. Yes, although you should use an actual infinite list type if you're depending on that. In fact, the Stream package provides an infinite list type with Applicative and Monad instances. >> However, this is painfully inefficient. I assume that bringing FRP-like >> switching and some clever data structure (which optimises stateless >> streams for starters) into the picture can potentially lead to >> constant-time access at least in the case of sequential sampling. Is >> there any recent work going in this direction? > > Having spent several months on this exact problem, I'll say that I consider > it pretty unlikely. ?To give you an idea of the frustration involved, the > end of that time was no longer spent trying to implement it, but rather > trying to characterize a mathematical reason that it was impossible (to no > avail). The problem is that there is no sequential access to optimize. If you break (>>=) into fmap and join, you can see that join has to get the diagonal. Each inner list is accessed once. Really, you're better off just using Nat -> a. The primary advantage to using a list over a function is avoiding recomputation, but nothing is getting recomputed here. -- Dave Menendez From dan.doel at gmail.com Wed Apr 1 11:42:56 2009 From: dan.doel at gmail.com (Dan Doel) Date: Wed Apr 1 11:30:11 2009 Subject: [Haskell-cafe] ZipList monad, anyone? In-Reply-To: <1238582675.10366.1308390907@webmail.messagingengine.com> References: <1238582675.10366.1308390907@webmail.messagingengine.com> Message-ID: <200904011142.57428.dan.doel@gmail.com> On Wednesday 01 April 2009 6:44:35 am Patai Gergely wrote: > Does ZipList have any useful monad instance? The thought came up while > thinking about higher order dataflows and an ArrowApply interface for > Yampa. As a ZipList can be thought of as a function with a discrete > domain, I figured its monadic form could be analogous to the reader > monad, hence: > > instance Monad ZipList where > return = ZipList . repeat > ZipList xs >>= f = ZipList $ zipWith ((!!) . getZipList . f) xs > [0..] > > Correct me if I'm wrong, but it seems to me that f always returning an > infinite list is a sufficient condition for the monad laws to hold. It is. However, the ZipList type does not restrict one from writing functions that don't return infinite lists. For instance, if we consider just join, with the above definition: join [[1,2],[3]] = [1, _|_] Which, I think, is fairly undesirable. You can try to avoid bottoms like so: diag ((x:_):xs) = x : diag (map (drop 1) xs) diag ([]:xs) = diag xs diag [] = [] but this version breaks associativity: diag . diag $ [[[1],[3,4]],[[],[7,8]]] = [1,8] diag . map diag $ [[[1],[3,4]],[[],[7,8]]] = [1] So, you seem to have a choice between breaking monad laws or inserting bottom placeholders to avoid breaking them. This monad works fine for size enforced vectors (including if the size is infinite, a.k.a. streams, which seems to be what you're actually talking about in the first place, so my reply above may be irrelevant), but I'm skeptical that one could make something that works appropriately for unrestricted lists. -- Dan From vanenkj at gmail.com Wed Apr 1 11:45:08 2009 From: vanenkj at gmail.com (John Van Enk) Date: Wed Apr 1 11:32:18 2009 Subject: [Haskell-cafe] Re: [Haskell] Marketing Haskell In-Reply-To: <63EC6697-3158-446A-9147-10B6450291A4@mac.com> References: <87d4bwpzjj.fsf@malde.org> <63EC6697-3158-446A-9147-10B6450291A4@mac.com> Message-ID: My dreams, they will be forever haunted. 2009/4/1 Maarten Hazewinkel > That's not you usual Koala face. > Must be a special Simon^H^H^H^H^HHaskell-Koala species. > > > > On 1 Apr 2009, at 10:07, Simon Peyton-Jones wrote: > > >> Dear Haskell enthusiasts, >> >> Now that the logo issue finally has been settled, it is time to select >> the proper Haskell mascot. As you are no doubt aware, Microsoft's >> involvement in Haskell means that we have moved from avoiding success >> at all cost to actively marketing the language, and any language >> striving for success is entirely dependent on a cute and distinctive >> mascot. Where would Perl be today without its camel? >> >> Since the recent logo discussion has demonstrated once and for all the >> futility of attempting a democratic process in the Haskell community - >> to be quite honest, the elected logo looks like an error message from an >> IBM >> mainframe - I have decided to decide on a mascot myself. >> >> So I hereby declare the official Haskell mascot to be the koala, in >> the form of the image attached below. Please ensure that this image >> accompanies any material published on the web or on paper. >> >> Simon >> >> _______________________________________________ >> Haskell mailing list >> Haskell@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell >> > > > Maarten Hazewinkel > maarten.hazewinkel@gmail.com > Tel: 06-53 692 432 (+31-653 692 432 from outside the Netherlands) > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090401/0283ad8f/attachment.htm From bugfact at gmail.com Wed Apr 1 12:43:56 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 1 12:31:07 2009 Subject: [Haskell-cafe] Reverting to any old version using Darcs Message-ID: Rumor goes that this is very difficult to do with Darcs. Is this correct? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090401/f8366218/attachment.htm From moonpatio at gmail.com Wed Apr 1 12:54:16 2009 From: moonpatio at gmail.com (Matt Morrow) Date: Wed Apr 1 12:41:27 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: vacuum-cairo: a cairo frontend to vacuum for live Haskell data visualization In-Reply-To: References: <20090331054038.GA5648@whirlpool.galois.com> Message-ID: <1bc51a990904010954m1253c08eld5a5e14882f31449@mail.gmail.com> Holy crap! That looks amazing. I think you should most definitely upload it. 2009/4/1 Gleb Alexeyev > Don Stewart wrote: > >> I am pleased to announce the release of vacuum-cairo, a Haskell library >> for interactive rendering and display of values on the GHC heap using >> Matt Morrow's vacuum library. >> > > Awesome stuff, kudos to you and Matt Morrow! > > I thought it'd be fun to visualize data structures in three dimensions. > Attached is quick and dirty hack based on your code and Ubigraph server ( > http://ubietylab.net/ubigraph/). > > The demo video (apologies for poor quality): > http://www.youtube.com/watch?v=3mMH1cHWB6c > > If someone finds it fun enough, I'll cabalize it and upload to Hackage. > > _______________________________________________ > 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/20090401/95bdcb45/attachment.htm From gwern0 at gmail.com Wed Apr 1 12:57:12 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Wed Apr 1 12:44:22 2009 Subject: [Haskell-cafe] Reverting to any old version using Darcs In-Reply-To: References: Message-ID: 2009/4/1 Peter Verswyvelen : > Rumor goes that this is very difficult to do with Darcs. Is this correct? I've always found it straightforward. Perhaps you should read the manual http://darcs.net/manual/node8.html#SECTION00890000000000000000 and try it out for yourself. -- gwern From jnf at arcor.de Wed Apr 1 12:59:32 2009 From: jnf at arcor.de (jutaro) Date: Wed Apr 1 12:46:42 2009 Subject: [Haskell-cafe] Announcement: Beta of Leksah IDE available In-Reply-To: References: <1238538058.6785.11.camel@jutaro-laptop> Message-ID: <22831078.post@talk.nabble.com> Hi Benjamin, Nice that you like the logo. The idea to turn the lambda around came from the name of the project. But actually I'm feeling totally incapable of graphics design and the icons coming with leksah are an example of bitty plagiarism. So I will definitely not participate in any Logo competition, but feel free to use the idea. By the way, if you have any inclination for this, may you like to help with the graphic design of the leksah a bit? E.g. We have this little symbols representing data, newtype, variable, class ... They all look awful. J?rgen Nicklisch-Franken Benjamin L.Russell wrote: > > Your logo, a lowercase lambda merged with an inverted version of the > same sharing a single spine, loosely resembles an uppercase 'H', and > could possibly serve as a Haskell logo. It is simple, can represent > simultaneously both "lambda" and "Haskell," and can easily be enlarged > or reduced without loss of legibility. Why didn't you submit it in > the Haskell Logo Competition? > > The next time this competition comes around, if you don't mind, please > submit this logo as an entry! > > -- 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 > > -- View this message in context: http://www.nabble.com/Announcement%3A-Beta-of-Leksah-IDE-available-tp22816032p22831078.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From dons at galois.com Wed Apr 1 13:14:36 2009 From: dons at galois.com (Don Stewart) Date: Wed Apr 1 13:03:17 2009 Subject: [Haskell-cafe] Reverting to any old version using Darcs In-Reply-To: References: Message-ID: <20090401171436.GA12860@whirlpool.galois.com> bugfact: > Rumor goes that this is very difficult to do with Darcs. Is this correct? darcs unpull -- Don From dons at galois.com Wed Apr 1 13:15:30 2009 From: dons at galois.com (Don Stewart) Date: Wed Apr 1 13:03:42 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: vacuum-cairo: a cairo frontend to vacuum for live Haskell data visualization In-Reply-To: <1bc51a990904010954m1253c08eld5a5e14882f31449@mail.gmail.com> References: <20090331054038.GA5648@whirlpool.galois.com> <1bc51a990904010954m1253c08eld5a5e14882f31449@mail.gmail.com> Message-ID: <20090401171530.GB12860@whirlpool.galois.com> Please upload!! moonpatio: > Holy crap! That looks amazing. I think you should most definitely upload it. > > 2009/4/1 Gleb Alexeyev > > Don Stewart wrote: > > I am pleased to announce the release of vacuum-cairo, a Haskell library > for interactive rendering and display of values on the GHC heap using > Matt Morrow's vacuum library. > > > Awesome stuff, kudos to you and Matt Morrow! > > I thought it'd be fun to visualize data structures in three dimensions. > Attached is quick and dirty hack based on your code and Ubigraph server ( > http://ubietylab.net/ubigraph/). > > The demo video (apologies for poor quality): http://www.youtube.com/watch?v > =3mMH1cHWB6c > > If someone finds it fun enough, I'll cabalize it and upload to Hackage. > > _______________________________________________ > 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 jnf at arcor.de Wed Apr 1 13:17:17 2009 From: jnf at arcor.de (jutaro) Date: Wed Apr 1 13:04:28 2009 Subject: [Haskell-cafe] Announcement: Beta of Leksah IDE available In-Reply-To: <20090401011918.0a3af602@solaris> References: <1238538058.6785.11.camel@jutaro-laptop> <20090401011918.0a3af602@solaris> Message-ID: <22831401.post@talk.nabble.com> Thanks Achim, maybe you are right with Plugins. In the moment I'm more focused on adding additional features. But wish the day, that so many want to add features that a plugin system will be essential, we have it. With the GUI arrangement like splitting etc. leksah is quite flexible, but it doesn't support drag and drop, so maybe I'm the only one who knows how to use it. Well our capacity is limited, and no high priority on drag and drop and such thinks. J?rgen Achim Schneider wrote: > > J__rgen Nicklisch-Franken wrote: > >> So I please the members of the community to pause for a moment and try >> out Leksah with a benevolent attitude. >> > I did (the previous version, tbh), and couldn't find anything to > seriously bicker about... a few problems regarding metadata generation, > but that was dealt with as soon as I RTFM'ed. Ah, yes, you shouldn't be > able to close the toolbar by pressing on one of its buttons that > incidentally looks just like the one to close a file. > > Completition already rocks, the interface is nicely configurable > (although I resorted to editing config and session files instead of > using gui commands[1]), project management worked out fine (after I > figured out that I had to manually configure leksah to pass --user to > cabal), all in all it's an impressive piece of code that radiates later > uberness instead of lacking features. Last, but not least, it's _fast_, > _waaaaaaaaay_ more zappy than eclipse. As far as basic IDE features are > concerned, it's also complete. > > > The one thing that keeps me from switching to it, right now, is the > editor not being a vi. While gtksourceview might be, in theory, > a usable editor, my muscle memory tells me otherwise. It'd be like > switching to autoconf for C development instead of just copying over my > beloved OMakefile. > > > Providing refactoring support would make it irresistible... maybe it's > time to add a plugin layer, so that things like vacuum or a wrapper > around hp2ps can register themselves with leksah, without giving up > their identity as stand-alone projects. Plugability is the one feature > that made eclipse big, and it won't hurt leksah, either. > > > [1] I utterly failed to figure out how to do stuff[2], seriously. > Eclipse has a really nice drag&drop interface with visual feedback > to rearrange stuff, but I'm not the kind of guy who drops a program > for lacking such bells&whistles. > [2] "Stuff" being rearranging divisions such that it's first split > horizontally, the console/type view etc. taking up the bottom part > and the upper part being split vertically into source view/module > browser. I just can't stand wrapped lines on the console. Somehow, > I think it should be the default arrangement. > > -- > (c) this sig last receiving data processing entity. Inspect headers > for copyright history. All rights reserved. Copying, hiring, renting, > performance and/or quoting of this signature prohibited. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/Announcement%3A-Beta-of-Leksah-IDE-available-tp22816032p22831401.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ndmitchell at gmail.com Wed Apr 1 13:47:17 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Apr 1 13:34:26 2009 Subject: [Haskell-cafe] Announcement: Beta of Leksah IDE available In-Reply-To: <22831401.post@talk.nabble.com> References: <1238538058.6785.11.camel@jutaro-laptop> <20090401011918.0a3af602@solaris> <22831401.post@talk.nabble.com> Message-ID: <404396ef0904011047n45f36662yf6fc728097c60f28@mail.gmail.com> Hi Just tried it out, a few notes: * Very easy install - if only gtk2hs could be installed with cabal it would have been perfect. * Select the package you have installed. I didn't have a clue what to do here. Do you mean where I keep my Haskell programs? Or where GHC installs them? Can't you figure it out - its a confusing dialog which looks redundant. * Turning off "To Candy" was an essential first step for me! I can perhaps see <- as candy, but replacing $ with diamond is just confusing. * I opened a .cabal file, and expected to see the files in the source in a Window somewhere. I didn't. * The UI feels a little clunky, this could be the Gtk feel of the app (which in time I'd get over), or the choice of UI (the left-pane is quite large). Anything you could do to simplify/streamline the UI would be great. All in all looks quite neat. This is definitely going somewhere, and looks like it will be quite good by the end. Thanks Neil On Wed, Apr 1, 2009 at 6:17 PM, jutaro wrote: > > Thanks Achim, > maybe you are right with Plugins. In the moment I'm more focused on adding > additional features. But wish the day, that so many want to add features > that a plugin system will be essential, we have it. > > With the GUI arrangement like splitting etc. leksah is quite flexible, but > it doesn't support drag and drop, so maybe I'm the only one who knows how to > use it. Well our capacity is limited, and no high priority on drag and drop > and such thinks. > > J?rgen > > > > Achim Schneider wrote: >> >> J__rgen Nicklisch-Franken wrote: >> >>> So I please the members of the community to pause for a moment and try >>> out Leksah with a benevolent attitude. >>> >> I did (the previous version, tbh), and couldn't find anything to >> seriously bicker about... a few problems regarding metadata generation, >> but that was dealt with as soon as I RTFM'ed. Ah, yes, you shouldn't be >> able to close the toolbar by pressing on one of its buttons that >> incidentally looks just like the one to close a file. >> >> Completition already rocks, the interface is nicely configurable >> (although I resorted to editing config and session files instead of >> using gui commands[1]), project management worked out fine (after I >> figured out that I had to manually configure leksah to pass --user to >> cabal), all in all it's an impressive piece of code that radiates later >> uberness instead of lacking features. Last, but not least, it's _fast_, >> _waaaaaaaaay_ more zappy than eclipse. As far as basic IDE features are >> concerned, it's also complete. >> >> >> The one thing that keeps me from switching to it, right now, is the >> editor not being a vi. While gtksourceview might be, in theory, >> a usable editor, my muscle memory tells me otherwise. It'd be like >> switching to autoconf for C development instead of just copying over my >> beloved OMakefile. >> >> >> Providing refactoring support would make it irresistible... maybe it's >> time to add a plugin layer, so that things like vacuum or a wrapper >> around hp2ps can register themselves with leksah, without giving up >> their identity as stand-alone projects. Plugability is the one feature >> that made eclipse big, and it won't hurt leksah, either. >> >> >> [1] I utterly failed to figure out how to do stuff[2], seriously. >> ? ? Eclipse has a really nice drag&drop interface with visual feedback >> ? ? to rearrange stuff, but I'm not the kind of guy who drops a program >> ? ? for lacking such bells&whistles. >> [2] "Stuff" being rearranging divisions such that it's first split >> ? ? horizontally, the console/type view etc. taking up the bottom part >> ? ? and the upper part being split vertically into source view/module >> ? ? browser. I just can't stand wrapped lines on the console. Somehow, >> ? ? I think it should be the default arrangement. >> >> -- >> (c) this sig last receiving data processing entity. Inspect headers >> for copyright history. All rights reserved. Copying, hiring, renting, >> performance and/or quoting of this signature prohibited. >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > -- > View this message in context: http://www.nabble.com/Announcement%3A-Beta-of-Leksah-IDE-available-tp22816032p22831401.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 ddvlad at anaconda.cs.pub.ro Wed Apr 1 14:16:04 2009 From: ddvlad at anaconda.cs.pub.ro (Vlad Dogaru) Date: Wed Apr 1 14:03:20 2009 Subject: [Haskell-cafe] [SoC] XML Schema Implementation In-Reply-To: <1238451364.30017.45.camel@localhost> References: <1238451364.30017.45.camel@localhost> Message-ID: <1238609764.28274.10.camel@localhost> On Tue, 2009-03-31 at 01:16 +0300, Vlad Dogaru wrote: > Hello everyone, > > I am writing to judge interest in a Summer of Code proposition: an XML > Schema[1] implementation, described as a possbile application here[2]. > As both a tool and an inspiration, I intend to use HaXML[3]. > [snip] Thank you to everyone who has contributed their experience and opinions. This has hopefully helped me understand what would benefit the community most in the direction of XSD. Vlad From jefferson.r.heard at gmail.com Wed Apr 1 14:50:41 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Wed Apr 1 14:37:58 2009 Subject: [Haskell-cafe] Announcement: Beta of Leksah IDE available In-Reply-To: <404396ef0904011047n45f36662yf6fc728097c60f28@mail.gmail.com> References: <1238538058.6785.11.camel@jutaro-laptop> <20090401011918.0a3af602@solaris> <22831401.post@talk.nabble.com> <404396ef0904011047n45f36662yf6fc728097c60f28@mail.gmail.com> Message-ID: <4165d3a70904011150h55f7ddepf70c86eed416843d@mail.gmail.com> I have one problem so far (and one segfault), but I like the IDE a lot. When I create a new package inside one of my current source directories, it adds all the modules in that directory to *both* the exposed and additional unexposed modules list, resulting in a net zero modules in the package. Is this a known problem? Am I missing something? I can't see how to add or remove modules from either of these lists. -- Jeff On Wed, Apr 1, 2009 at 1:47 PM, Neil Mitchell wrote: > Hi > > Just tried it out, a few notes: > > * Very easy install - if only gtk2hs could be installed with cabal it > would have been perfect. > > * Select the package you have installed. I didn't have a clue what to > do here. Do you mean where I keep my Haskell programs? Or where GHC > installs them? Can't you figure it out - its a confusing dialog which > looks redundant. > > * Turning off "To Candy" was an essential first step for me! I can > perhaps see <- as candy, but replacing $ with diamond is just > confusing. > > * I opened a .cabal file, and expected to see the files in the source > in a Window somewhere. I didn't. > > * The UI feels a little clunky, this could be the Gtk feel of the app > (which in time I'd get over), or the choice of UI (the left-pane is > quite large). Anything you could do to simplify/streamline the UI > would be great. > > All in all looks quite neat. This is definitely going somewhere, and > looks like it will be quite good by the end. > > Thanks > > Neil > > > > On Wed, Apr 1, 2009 at 6:17 PM, jutaro wrote: >> >> Thanks Achim, >> maybe you are right with Plugins. In the moment I'm more focused on adding >> additional features. But wish the day, that so many want to add features >> that a plugin system will be essential, we have it. >> >> With the GUI arrangement like splitting etc. leksah is quite flexible, but >> it doesn't support drag and drop, so maybe I'm the only one who knows how to >> use it. Well our capacity is limited, and no high priority on drag and drop >> and such thinks. >> >> J?rgen >> >> >> >> Achim Schneider wrote: >>> >>> J__rgen Nicklisch-Franken wrote: >>> >>>> So I please the members of the community to pause for a moment and try >>>> out Leksah with a benevolent attitude. >>>> >>> I did (the previous version, tbh), and couldn't find anything to >>> seriously bicker about... a few problems regarding metadata generation, >>> but that was dealt with as soon as I RTFM'ed. Ah, yes, you shouldn't be >>> able to close the toolbar by pressing on one of its buttons that >>> incidentally looks just like the one to close a file. >>> >>> Completition already rocks, the interface is nicely configurable >>> (although I resorted to editing config and session files instead of >>> using gui commands[1]), project management worked out fine (after I >>> figured out that I had to manually configure leksah to pass --user to >>> cabal), all in all it's an impressive piece of code that radiates later >>> uberness instead of lacking features. Last, but not least, it's _fast_, >>> _waaaaaaaaay_ more zappy than eclipse. As far as basic IDE features are >>> concerned, it's also complete. >>> >>> >>> The one thing that keeps me from switching to it, right now, is the >>> editor not being a vi. While gtksourceview might be, in theory, >>> a usable editor, my muscle memory tells me otherwise. It'd be like >>> switching to autoconf for C development instead of just copying over my >>> beloved OMakefile. >>> >>> >>> Providing refactoring support would make it irresistible... maybe it's >>> time to add a plugin layer, so that things like vacuum or a wrapper >>> around hp2ps can register themselves with leksah, without giving up >>> their identity as stand-alone projects. Plugability is the one feature >>> that made eclipse big, and it won't hurt leksah, either. >>> >>> >>> [1] I utterly failed to figure out how to do stuff[2], seriously. >>> ? ? Eclipse has a really nice drag&drop interface with visual feedback >>> ? ? to rearrange stuff, but I'm not the kind of guy who drops a program >>> ? ? for lacking such bells&whistles. >>> [2] "Stuff" being rearranging divisions such that it's first split >>> ? ? horizontally, the console/type view etc. taking up the bottom part >>> ? ? and the upper part being split vertically into source view/module >>> ? ? browser. I just can't stand wrapped lines on the console. Somehow, >>> ? ? I think it should be the default arrangement. >>> >>> -- >>> (c) this sig last receiving data processing entity. Inspect headers >>> for copyright history. All rights reserved. Copying, hiring, renting, >>> performance and/or quoting of this signature prohibited. >>> >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> >> >> -- >> View this message in context: http://www.nabble.com/Announcement%3A-Beta-of-Leksah-IDE-available-tp22816032p22831401.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 > From ketil at malde.org Wed Apr 1 15:57:05 2009 From: ketil at malde.org (Ketil Malde) Date: Wed Apr 1 15:43:11 2009 Subject: [Haskell-cafe] Reverting to any old version using Darcs In-Reply-To: <20090401171436.GA12860@whirlpool.galois.com> (Don Stewart's message of "Wed\, 1 Apr 2009 10\:14\:36 -0700") References: <20090401171436.GA12860@whirlpool.galois.com> Message-ID: <873acsxi3y.fsf@malde.org> Don Stewart writes: >> Rumor goes that this is very difficult to do with Darcs. Is this correct? > darcs unpull Or just cd to a different directory, and darcs get -t ? -k -- If I haven't seen further, it is by standing in the footprints of giants From jnf at arcor.de Wed Apr 1 16:01:50 2009 From: jnf at arcor.de (jutaro) Date: Wed Apr 1 15:48:59 2009 Subject: [Haskell-cafe] Announcement: Beta of Leksah IDE available In-Reply-To: <404396ef0904011047n45f36662yf6fc728097c60f28@mail.gmail.com> References: <1238538058.6785.11.camel@jutaro-laptop> <20090401011918.0a3af602@solaris> <22831401.post@talk.nabble.com> <404396ef0904011047n45f36662yf6fc728097c60f28@mail.gmail.com> Message-ID: <22834510.post@talk.nabble.com> Hi Neil, Neil Mitchell wrote: > > Hi > > Just tried it out, a few notes: > > * Very easy install - if only gtk2hs could be installed with cabal it > would have been perfect. > > * Select the package you have installed. I didn't have a clue what to > do here. Do you mean where I keep my Haskell programs? Or where GHC > installs them? Can't you figure it out - its a confusing dialog which > looks redundant. > I guess you mean the dialog which should help leksah to find sources for installed packages. It needs this so you can go to all the definitions in the base packages ... This is very handy if it works. Look to the manual for details. Neil Mitchell wrote: > > * Turning off "To Candy" was an essential first step for me! I can > perhaps see <- as candy, but replacing $ with diamond is just > confusing. > Yeah, I've should have taken this out. But just edit the candy file to your taste. Neil Mitchell wrote: > > > * I opened a .cabal file, and expected to see the files in the source > in a Window somewhere. I didn't. > Yes, thats a bit of a problem. As 1. the project has to be compiled. and 2. metadata has to be collected. Then it appears in the modules window. Neil Mitchell wrote: > > * The UI feels a little clunky, this could be the Gtk feel of the app > (which in time I'd get over), or the choice of UI (the left-pane is > quite large). Anything you could do to simplify/streamline the UI > would be great. > You can do some adjustments on your own. On MS Windows we have some problems though. Neil Mitchell wrote: > > > All in all looks quite neat. This is definitely going somewhere, and > looks like it will be quite good by the end. > Thanks J?rgen Neil Mitchell wrote: > > Thanks > Neil > > > > On Wed, Apr 1, 2009 at 6:17 PM, jutaro wrote: >> >> Thanks Achim, >> maybe you are right with Plugins. In the moment I'm more focused on >> adding >> additional features. But wish the day, that so many want to add features >> that a plugin system will be essential, we have it. >> >> With the GUI arrangement like splitting etc. leksah is quite flexible, >> but >> it doesn't support drag and drop, so maybe I'm the only one who knows how >> to >> use it. Well our capacity is limited, and no high priority on drag and >> drop >> and such thinks. >> >> J?rgen >> >> >> >> Achim Schneider wrote: >>> >>> J__rgen Nicklisch-Franken wrote: >>> >>>> So I please the members of the community to pause for a moment and try >>>> out Leksah with a benevolent attitude. >>>> >>> I did (the previous version, tbh), and couldn't find anything to >>> seriously bicker about... a few problems regarding metadata generation, >>> but that was dealt with as soon as I RTFM'ed. Ah, yes, you shouldn't be >>> able to close the toolbar by pressing on one of its buttons that >>> incidentally looks just like the one to close a file. >>> >>> Completition already rocks, the interface is nicely configurable >>> (although I resorted to editing config and session files instead of >>> using gui commands[1]), project management worked out fine (after I >>> figured out that I had to manually configure leksah to pass --user to >>> cabal), all in all it's an impressive piece of code that radiates later >>> uberness instead of lacking features. Last, but not least, it's _fast_, >>> _waaaaaaaaay_ more zappy than eclipse. As far as basic IDE features are >>> concerned, it's also complete. >>> >>> >>> The one thing that keeps me from switching to it, right now, is the >>> editor not being a vi. While gtksourceview might be, in theory, >>> a usable editor, my muscle memory tells me otherwise. It'd be like >>> switching to autoconf for C development instead of just copying over my >>> beloved OMakefile. >>> >>> >>> Providing refactoring support would make it irresistible... maybe it's >>> time to add a plugin layer, so that things like vacuum or a wrapper >>> around hp2ps can register themselves with leksah, without giving up >>> their identity as stand-alone projects. Plugability is the one feature >>> that made eclipse big, and it won't hurt leksah, either. >>> >>> >>> [1] I utterly failed to figure out how to do stuff[2], seriously. >>> ? ? Eclipse has a really nice drag&drop interface with visual feedback >>> ? ? to rearrange stuff, but I'm not the kind of guy who drops a program >>> ? ? for lacking such bells&whistles. >>> [2] "Stuff" being rearranging divisions such that it's first split >>> ? ? horizontally, the console/type view etc. taking up the bottom part >>> ? ? and the upper part being split vertically into source view/module >>> ? ? browser. I just can't stand wrapped lines on the console. Somehow, >>> ? ? I think it should be the default arrangement. >>> >>> -- >>> (c) this sig last receiving data processing entity. Inspect headers >>> for copyright history. All rights reserved. Copying, hiring, renting, >>> performance and/or quoting of this signature prohibited. >>> >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> >> >> -- >> View this message in context: >> http://www.nabble.com/Announcement%3A-Beta-of-Leksah-IDE-available-tp22816032p22831401.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://www.nabble.com/Announcement%3A-Beta-of-Leksah-IDE-available-tp22816032p22834510.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From jnf at arcor.de Wed Apr 1 16:11:54 2009 From: jnf at arcor.de (jutaro) Date: Wed Apr 1 15:59:04 2009 Subject: [Haskell-cafe] Announcement: Beta of Leksah IDE available In-Reply-To: <4165d3a70904011150h55f7ddepf70c86eed416843d@mail.gmail.com> References: <1238538058.6785.11.camel@jutaro-laptop> <20090401011918.0a3af602@solaris> <22831401.post@talk.nabble.com> <404396ef0904011047n45f36662yf6fc728097c60f28@mail.gmail.com> <4165d3a70904011150h55f7ddepf70c86eed416843d@mail.gmail.com> Message-ID: <22834684.post@talk.nabble.com> Hi Jeff, I just tried it out and it didn't work for me too. So I've released it to early I guess. One problem I see is that the background build is even active when no project is open. So it always ask you to open a file, and you can't cancel this. This can be avoided by unselecting the symbol in the toolbar that looks like a recycle sign. Switch it on again, if you're ready with a project. I will fix this in the next release. However, in the visual cabal editor, can't you select and unselect modules in a checkbox at the side? J?rgen I have one problem so far (and one segfault), but I like the IDE a lot. When I create a new package inside one of my current source directories, it adds all the modules in that directory to *both* the exposed and additional unexposed modules list, resulting in a net zero modules in the package. Is this a known problem? Am I missing something? I can't see how to add or remove modules from either of these lists. -- Jeff -- View this message in context: http://www.nabble.com/Announcement%3A-Beta-of-Leksah-IDE-available-tp22816032p22834684.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From david.waern at gmail.com Wed Apr 1 16:13:54 2009 From: david.waern at gmail.com (David Waern) Date: Wed Apr 1 16:01:04 2009 Subject: [Haskell-cafe] Announcement: Beta of Leksah IDE available In-Reply-To: <22834510.post@talk.nabble.com> References: <1238538058.6785.11.camel@jutaro-laptop> <20090401011918.0a3af602@solaris> <22831401.post@talk.nabble.com> <404396ef0904011047n45f36662yf6fc728097c60f28@mail.gmail.com> <22834510.post@talk.nabble.com> Message-ID: 2009/4/1 jutaro : > I guess you mean the dialog which should help leksah to find sources > for installed packages. It needs this so you can go to all the definitions > in the base packages ... This is very handy if it works. Look to the manual > for details. Maybe could add support to Cabal for installing sources? Should be very useful to have in general. David From dons at galois.com Wed Apr 1 16:13:53 2009 From: dons at galois.com (Don Stewart) Date: Wed Apr 1 16:02:04 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: vacuum-cairo: a cairo frontend to vacuum for live Haskell data visualization In-Reply-To: References: <20090331054038.GA5648@whirlpool.galois.com> Message-ID: <20090401201353.GJ12860@whirlpool.galois.com> Did you use hubigraph? http://ooxo.org/hubigraph/ This cabalized project doesn't appear to be on hackage! gleb.alexeev: > Don Stewart wrote: >> I am pleased to announce the release of vacuum-cairo, a Haskell library >> for interactive rendering and display of values on the GHC heap using >> Matt Morrow's vacuum library. > > Awesome stuff, kudos to you and Matt Morrow! > > I thought it'd be fun to visualize data structures in three dimensions. > Attached is quick and dirty hack based on your code and Ubigraph server > (http://ubietylab.net/ubigraph/). > > The demo video (apologies for poor quality): > http://www.youtube.com/watch?v=3mMH1cHWB6c > > If someone finds it fun enough, I'll cabalize it and upload to Hackage. > module Ubigraph where > > import Network.XmlRpc.Client > > type Url = String > type VertexId = Int > type EdgeId = Int > > defaultServer = "http://127.0.0.1:20738/RPC2" > > void :: IO Int -> IO () > void m = m >> return () > > clear :: Url -> IO () > clear url = void (remote url "ubigraph.clear") > > newVertex :: Url -> IO VertexId > newVertex url = remote url "ubigraph.new_vertex" > > newEdge :: Url -> VertexId -> VertexId -> IO EdgeId > newEdge url = remote url "ubigraph.new_edge" > > removeVertex :: Url -> VertexId -> IO () > removeVertex url vid = void (remote url "ubigraph.remove_vertex" vid) > > removeEgde :: Url -> EdgeId -> IO () > removeEgde url eid= void (remote url "ubigraph.remove_edge" eid) > > > zeroOnSuccess :: IO Int -> IO Bool > zeroOnSuccess = fmap (==0) > > newVertexWithId :: Url -> VertexId -> IO Bool > newVertexWithId url vid = zeroOnSuccess (remote url "ubigraph.new_vertex_w_id" vid) > > newEdgeWithId :: Url -> EdgeId -> VertexId -> VertexId -> IO Bool > newEdgeWithId url eid x y = zeroOnSuccess (remote url "ubigraph.new_edge_w_id" eid x y) > > setVertexAttribute :: Url -> VertexId -> String -> String -> IO Bool > setVertexAttribute url vid attr val = zeroOnSuccess (remote url "ubigraph.set_vertex_attribute" vid attr val) > > setEdgeAttribute :: Url -> VertexId -> String -> String -> IO Bool > setEdgeAttribute url eid attr val = zeroOnSuccess (remote url "ubigraph.set_edge_attribute" eid attr val) > module VacuumUbigraph where > > import GHC.Vacuum > import Data.Char > import Text.Printf > import Data.List > > import qualified Data.IntMap as IntMap > import qualified Data.IntSet as IntSet > > import qualified Ubigraph as U > > nodeStyle n = > case nodeName n of > ":" -> ("(:)", "cube", "#0000ff") > > -- atomic stuff is special > k | k `elem` ["S#" ,"I#" ,"W#" > ,"I8#" ,"I16#" ,"I32#" ,"I64#" > ,"W8#" ,"W16#" ,"W32#" ,"W64#"] -> (showLit n, "sphere", "#00ff00") > -- chars > "C#" -> (show . chr . fromIntegral . head . nodeLits $ n, "sphere", "#00ff00") > "D#" -> ("Double", "sphere", "#009900") > "F#" -> ("Float", "sphere", "#009900") > > -- bytestrings > "PS" -> (printf "ByteString[%d,%d]" (nodeLits n !! 1) (nodeLits n !! 2), "cube", "#ff0000") > "Chunk" -> (printf "Chunk[%d,%d]" (nodeLits n !! 1) (nodeLits n !! 2), "cube", "#ff0000") > > -- otherwise just the constructor and local fields > c | z > 0 -> > (c ++ show (take (fromIntegral z) $ nodeLits n), "cube", "#990000") > | otherwise -> (c, "cube", "#990000") > where z = itabLits (nodeInfo n) > where > showLit n = show (head $ nodeLits n) > > view a = do > U.clear srv > mapM_ renderNode nodes > mapM_ renderEdge edges > where > g = vacuum a > alist = toAdjList g > nodes = nub $ map fst alist ++ concatMap snd alist > edges = concatMap (\(n, ns) -> map ((,) n) ns) alist > > style nid = maybe ("...", "cube", "#ff0000") nodeStyle (IntMap.lookup nid g) > > renderNode nid = do > U.newVertexWithId srv nid > let (label, shape, color) = style nid > U.setVertexAttribute srv nid "label" label > U.setVertexAttribute srv nid "shape" shape > U.setVertexAttribute srv nid "color" color > > renderEdge (a, b) = do > e <- U.newEdge srv a b > U.setEdgeAttribute srv e "stroke" "dotted" > U.setEdgeAttribute srv e "arrow" "true" > > srv = U.defaultServer > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From gwern0 at gmail.com Wed Apr 1 16:21:08 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Wed Apr 1 16:08:19 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: vacuum-cairo: a cairo frontend to vacuum for live Haskell data visualization In-Reply-To: <20090401201353.GJ12860@whirlpool.galois.com> References: <20090331054038.GA5648@whirlpool.galois.com> <20090401201353.GJ12860@whirlpool.galois.com> Message-ID: On Wed, Apr 1, 2009 at 4:13 PM, Don Stewart wrote: > Did you use hubigraph? > > ? ?http://ooxo.org/hubigraph/ > > This cabalized project doesn't appear to be on hackage! The same author also has http://ooxo.org/dtwitzen/ and http://github.com/smly/sys35tools/tree/master -- gwern From lemming at henning-thielemann.de Wed Apr 1 16:24:56 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Apr 1 16:12:11 2009 Subject: [Haskell-cafe] Re: Announcement: Beta of Leksah IDE available In-Reply-To: References: <1238538058.6785.11.camel@jutaro-laptop> Message-ID: On Wed, 1 Apr 2009, Benjamin L.Russell wrote: > Your logo, a lowercase lambda merged with an inverted version of the > same sharing a single spine, loosely resembles an uppercase 'H', and > could possibly serve as a Haskell logo. It is simple, can represent > simultaneously both "lambda" and "Haskell," and can easily be enlarged > or reduced without loss of legibility. Why didn't you submit it in > the Haskell Logo Competition? Because it is already the Leksah logo? :-) From bugfact at gmail.com Wed Apr 1 16:30:04 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 1 16:17:14 2009 Subject: [Haskell-cafe] Reverting to any old version using Darcs In-Reply-To: <873acsxi3y.fsf@malde.org> References: <20090401171436.GA12860@whirlpool.galois.com> <873acsxi3y.fsf@malde.org> Message-ID: Okay, thanks. So the rumors about this must be incorrect? On Wed, Apr 1, 2009 at 9:57 PM, Ketil Malde wrote: > Don Stewart writes: > > >> Rumor goes that this is very difficult to do with Darcs. Is this > correct? > > > darcs unpull > > Or just cd to a different directory, and darcs get -t ? > > -k > -- > If I haven't seen further, it is by standing in the footprints of giants > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090401/c771a7a9/attachment.htm From dons at galois.com Wed Apr 1 16:29:53 2009 From: dons at galois.com (Don Stewart) Date: Wed Apr 1 16:18:33 2009 Subject: [Haskell-cafe] Reverting to any old version using Darcs In-Reply-To: References: <20090401171436.GA12860@whirlpool.galois.com> <873acsxi3y.fsf@malde.org> Message-ID: <20090401202953.GK12860@whirlpool.galois.com> Yes. It would be fairly easy to check this in the docs, too :) bugfact: > Okay, thanks. So the rumors about this must be incorrect? > > On Wed, Apr 1, 2009 at 9:57 PM, Ketil Malde wrote: > > Don Stewart writes: > > >> Rumor goes that this is very difficult to do with Darcs. Is this > correct? > > > darcs unpull > > Or just cd to a different directory, and darcs get -t ? > > -k > -- > If I haven't seen further, it is by standing in the footprints of giants > > From simon at joyful.com Wed Apr 1 16:56:04 2009 From: simon at joyful.com (Simon Michael) Date: Wed Apr 1 16:47:13 2009 Subject: [Haskell-cafe] Re: Reverting to any old version using Darcs In-Reply-To: References: <20090401171436.GA12860@whirlpool.galois.com> <873acsxi3y.fsf@malde.org> Message-ID: <49D3D4E4.2030301@joyful.com> Peter Verswyvelen wrote: > Okay, thanks. So the rumors about this must be incorrect? That's one rumor I've never heard. Do drop by #darcs as well, we love solving easy problems. :) From dons at galois.com Wed Apr 1 17:11:32 2009 From: dons at galois.com (Don Stewart) Date: Wed Apr 1 16:59:52 2009 Subject: [Haskell-cafe] ANN: cmonad 0.1.1 In-Reply-To: <9FEB7608-558F-40CF-BE90-9CC1EA5B72EA@cs.york.ac.uk> References: <7B2B7CA8-EBA8-461C-89D0-C9C4CC0F5598@cs.uu.nl> <49D11AA2.1090004@btinternet.com> <9FEB7608-558F-40CF-BE90-9CC1EA5B72EA@cs.york.ac.uk> Message-ID: <20090401211132.GV12860@whirlpool.galois.com> malcolm.wallace: > > On 30 Mar 2009, at 20:16, Andrew Coppin wrote: >>> Lennart, what is the next language DSL you are going to build? >>> Prolog? XSLT? >> >> Declarative 3D scene construction? ;-) > > The ICFP programming contest in year 2000 was to write a ray tracer for a > given declarative 3D scene construction language (CSG - constructive > solid geometry). A team from Galois wrote a decent entry in Haskell, > which did not win (those were the glory days of O'Caml), but it was > placed in the top three. I believe with some careful googling, you > should still be able to find a copy of the source code. > > I'm sure that if someone were to return to the idea now, the DSL for CSG > could be improved in many ways, since the original language was simply > given in the contest description, and there was no point in altering it. > I believe the Galois 2000 ray tracer is now part of the GHC multicore benchmark suite. From claus.reinke at talk21.com Wed Apr 1 17:20:07 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Wed Apr 1 17:07:23 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: vacuum-cairo: a cairo frontend tovacuum for live Haskell data visualization References: <20090331054038.GA5648@whirlpool.galois.com> <20090401201353.GJ12860@whirlpool.galois.com> Message-ID: > Did you use hubigraph? > > http://ooxo.org/hubigraph/ Ah, there it is, then. Btw, more interesting than the 3d nature of the visualizations is that Ubigraph seems to have been designed for incremental updates of the layout (see the paper available via their home site). The lack of support for this in standard graph layout packages was the main reason that I had to give GHood its own naive layout algorithm. So I was delighted to see the design criteria for Ubigraph - until I noticed that it is not only unavailable for Windows, but closed source as well:-( Let us hope that at least one of these two items is going to change soon? Then both Hood and Vacuum visual animations could use the same backend, offering visualizations of both data and observations. A platform-independent, open-source, 2d/3d graph layout engine for incrementally updated graphs (where the graph after the update has to be similar enough to the one before that one can follow the animation and make sense of the data displayed) might be a good project for frp+opengl hackers - force equations between nodes, influenced by edges, and keeping the structure stable while adding nodes (parsed from an input stream). Claus > This cabalized project doesn't appear to be on hackage! > > gleb.alexeev: >> Don Stewart wrote: >>> I am pleased to announce the release of vacuum-cairo, a Haskell library >>> for interactive rendering and display of values on the GHC heap using >>> Matt Morrow's vacuum library. >> >> Awesome stuff, kudos to you and Matt Morrow! >> >> I thought it'd be fun to visualize data structures in three dimensions. >> Attached is quick and dirty hack based on your code and Ubigraph server >> (http://ubietylab.net/ubigraph/). >> >> The demo video (apologies for poor quality): >> http://www.youtube.com/watch?v=3mMH1cHWB6c >> >> If someone finds it fun enough, I'll cabalize it and upload to Hackage. > >> module Ubigraph where >> >> import Network.XmlRpc.Client >> >> type Url = String >> type VertexId = Int >> type EdgeId = Int >> >> defaultServer = "http://127.0.0.1:20738/RPC2" >> >> void :: IO Int -> IO () >> void m = m >> return () >> >> clear :: Url -> IO () >> clear url = void (remote url "ubigraph.clear") >> >> newVertex :: Url -> IO VertexId >> newVertex url = remote url "ubigraph.new_vertex" >> >> newEdge :: Url -> VertexId -> VertexId -> IO EdgeId >> newEdge url = remote url "ubigraph.new_edge" >> >> removeVertex :: Url -> VertexId -> IO () >> removeVertex url vid = void (remote url "ubigraph.remove_vertex" vid) >> >> removeEgde :: Url -> EdgeId -> IO () >> removeEgde url eid= void (remote url "ubigraph.remove_edge" eid) >> >> >> zeroOnSuccess :: IO Int -> IO Bool >> zeroOnSuccess = fmap (==0) >> >> newVertexWithId :: Url -> VertexId -> IO Bool >> newVertexWithId url vid = zeroOnSuccess (remote url "ubigraph.new_vertex_w_id" vid) >> >> newEdgeWithId :: Url -> EdgeId -> VertexId -> VertexId -> IO Bool >> newEdgeWithId url eid x y = zeroOnSuccess (remote url "ubigraph.new_edge_w_id" eid x y) >> >> setVertexAttribute :: Url -> VertexId -> String -> String -> IO Bool >> setVertexAttribute url vid attr val = zeroOnSuccess (remote url "ubigraph.set_vertex_attribute" >> vid attr val) >> >> setEdgeAttribute :: Url -> VertexId -> String -> String -> IO Bool >> setEdgeAttribute url eid attr val = zeroOnSuccess (remote url "ubigraph.set_edge_attribute" eid >> attr val) > >> module VacuumUbigraph where >> >> import GHC.Vacuum >> import Data.Char >> import Text.Printf >> import Data.List >> >> import qualified Data.IntMap as IntMap >> import qualified Data.IntSet as IntSet >> >> import qualified Ubigraph as U >> >> nodeStyle n = >> case nodeName n of >> ":" -> ("(:)", "cube", "#0000ff") >> >> -- atomic stuff is special >> k | k `elem` ["S#" ,"I#" ,"W#" >> ,"I8#" ,"I16#" ,"I32#" ,"I64#" >> ,"W8#" ,"W16#" ,"W32#" ,"W64#"] -> (showLit n, "sphere", "#00ff00") >> -- chars >> "C#" -> (show . chr . fromIntegral . head . nodeLits $ n, "sphere", "#00ff00") >> "D#" -> ("Double", "sphere", "#009900") >> "F#" -> ("Float", "sphere", "#009900") >> >> -- bytestrings >> "PS" -> (printf "ByteString[%d,%d]" (nodeLits n !! 1) (nodeLits n !! 2), "cube", >> "#ff0000") >> "Chunk" -> (printf "Chunk[%d,%d]" (nodeLits n !! 1) (nodeLits n !! 2), "cube", "#ff0000") >> >> -- otherwise just the constructor and local fields >> c | z > 0 -> >> (c ++ show (take (fromIntegral z) $ nodeLits n), "cube", "#990000") >> | otherwise -> (c, "cube", "#990000") >> where z = itabLits (nodeInfo n) >> where >> showLit n = show (head $ nodeLits n) >> >> view a = do >> U.clear srv >> mapM_ renderNode nodes >> mapM_ renderEdge edges >> where >> g = vacuum a >> alist = toAdjList g >> nodes = nub $ map fst alist ++ concatMap snd alist >> edges = concatMap (\(n, ns) -> map ((,) n) ns) alist >> >> style nid = maybe ("...", "cube", "#ff0000") nodeStyle (IntMap.lookup nid g) >> >> renderNode nid = do >> U.newVertexWithId srv nid >> let (label, shape, color) = style nid >> U.setVertexAttribute srv nid "label" label >> U.setVertexAttribute srv nid "shape" shape >> U.setVertexAttribute srv nid "color" color >> >> renderEdge (a, b) = do >> e <- U.newEdge srv a b >> U.setEdgeAttribute srv e "stroke" "dotted" >> U.setEdgeAttribute srv e "arrow" "true" >> >> srv = U.defaultServer >> > >> _______________________________________________ >> 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 claus.reinke at talk21.com Wed Apr 1 17:25:50 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Wed Apr 1 17:13:05 2009 Subject: [Haskell-cafe] Reverting to any old version using Darcs References: <20090401171436.GA12860@whirlpool.galois.com><873acsxi3y.fsf@malde.org> <20090401202953.GK12860@whirlpool.galois.com> Message-ID: <96FAB1873AA14AF39F2189B2E9F64B80@cr3lt> Perhaps the rumours refer to non-tagged "versions"? In conventional non-distributed version control systems, one might go back to the version on a specific date, while with darcs, that only makes sense wrt a specific repo (I think?). So you can unpull all patches after a date from your local repo, but that doesn't mean that you get a repo that matches someone else's repo after they perform the same procedure. If both parties commit to a central repo, and pull all changes via that, there is a greater chance of date-based synchronicity. Claus > Yes. It would be fairly easy to check this in the docs, too :) > > bugfact: >> Okay, thanks. So the rumors about this must be incorrect? >> >> On Wed, Apr 1, 2009 at 9:57 PM, Ketil Malde wrote: >> >> Don Stewart writes: >> >> >> Rumor goes that this is very difficult to do with Darcs. Is this >> correct? >> >> > darcs unpull >> >> Or just cd to a different directory, and darcs get -t ? >> >> -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 From bugfact at gmail.com Wed Apr 1 17:39:15 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 1 17:26:27 2009 Subject: [Haskell-cafe] Reverting to any old version using Darcs In-Reply-To: <20090401202953.GK12860@whirlpool.galois.com> References: <20090401171436.GA12860@whirlpool.galois.com> <873acsxi3y.fsf@malde.org> <20090401202953.GK12860@whirlpool.galois.com> Message-ID: Oh I checked the docs. But I don't thrust the docs yet, I value the words of the community higher. Since we're using Darcs to guard our hard work, I thought I better double check :-) I'm not really a newbie when it comes to source control actually. I wrote a full blown version control system myself several years time ago (closed source, NTFS only, C#/C++, project for a customer), albeit much simpler than Darcs. It did figure out all file and folder additions, renames, moves, edits and multi-project dependencies fully automatically though, so the biggest problems I usually see in teams - namely forgetting to add files, forgetting to check in dependencies and the inability the merge after renames or moves - did not exist. Forgetting to add a file can be a nasty one, since if you discover that too late, the original file at patch time might not exist anymore (how do you guys solve this? Just plain discipline I guess?). I actually tried to make a patch model like Darcs, but failed big time, my head almost exploded trying to understand it ;-) On Wed, Apr 1, 2009 at 10:29 PM, Don Stewart wrote: > Yes. It would be fairly easy to check this in the docs, too :) > > bugfact: > > Okay, thanks. So the rumors about this must be incorrect? > > > > On Wed, Apr 1, 2009 at 9:57 PM, Ketil Malde wrote: > > > > Don Stewart writes: > > > > >> Rumor goes that this is very difficult to do with Darcs. Is this > > correct? > > > > > darcs unpull > > > > Or just cd to a different directory, and darcs get -t want>? > > > > -k > > -- > > If I haven't seen further, it is by standing in the footprints of > giants > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090401/fcf7054e/attachment.htm From bugfact at gmail.com Wed Apr 1 17:43:36 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 1 17:30:46 2009 Subject: [Haskell-cafe] Reverting to any old version using Darcs In-Reply-To: <96FAB1873AA14AF39F2189B2E9F64B80@cr3lt> References: <20090401171436.GA12860@whirlpool.galois.com> <873acsxi3y.fsf@malde.org> <20090401202953.GK12860@whirlpool.galois.com> <96FAB1873AA14AF39F2189B2E9F64B80@cr3lt> Message-ID: Yes, that might be the rumor indeed, it surely sounds like it :) Darcs is really very different, so it takes a while to get used to it when coming from other systems. On Wed, Apr 1, 2009 at 11:25 PM, Claus Reinke wrote: > Perhaps the rumours refer to non-tagged "versions"? In conventional > non-distributed version control systems, one > might go back to the version on a specific date, while with > darcs, that only makes sense wrt a specific repo (I think?). > > So you can unpull all patches after a date from your local > repo, but that doesn't mean that you get a repo that matches > someone else's repo after they perform the same procedure. > If both parties commit to a central repo, and pull all changes > via that, there is a greater chance of date-based synchronicity. > > Claus > > Yes. It would be fairly easy to check this in the docs, too :) >> >> bugfact: >> >>> Okay, thanks. So the rumors about this must be incorrect? >>> >>> On Wed, Apr 1, 2009 at 9:57 PM, Ketil Malde wrote: >>> >>> Don Stewart writes: >>> >>> >> Rumor goes that this is very difficult to do with Darcs. Is this >>> correct? >>> >>> > darcs unpull >>> >>> Or just cd to a different directory, and darcs get -t >> want>? >>> >>> -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 >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090401/60596070/attachment.htm From ben.franksen at online.de Wed Apr 1 18:07:20 2009 From: ben.franksen at online.de (Ben Franksen) Date: Wed Apr 1 17:54:47 2009 Subject: [Haskell-cafe] Re: Re: Definition of "tail recursive" wrt Folds References: <4937.79543689943$1237965988@news.gmane.org> <49ce63e6.0ab6660a.4f9b.ffffadb4@mx.google.com> Message-ID: Bertram Felgenhauer wrote: > Ben Franksen wrote: >> Mark Spezzano wrote: >> > Just looking at the definitions for foldr and foldl I see that foldl is >> > (apparently) tail recursive while foldr is not. >> The point is that foldr still needs to do something (namely to apply (y >> `k`)) to the result of applying itself. It needs to remember to do so, >> and thus the stack grows linearly with the size of the list. > > Sorry, but that's wrong. It would be right in a strict language. In Haskell, > [...snip...] Thanks very much for this very nice explanation. I was aware that what I wrote is not the whole truth in a lazy language. Indeed I hoped someone else would explain the finer points better than I could. I was right. ;-) Cheers Ben From csaba.hruska at gmail.com Wed Apr 1 18:14:03 2009 From: csaba.hruska at gmail.com (Csaba Hruska) Date: Wed Apr 1 18:01:14 2009 Subject: [Haskell-cafe] GSoC proposal Message-ID: <8914b92d0904011514g542c63c8o511a1c4e65824dc7@mail.gmail.com> Hi! I've submitted my proposal on gsoc portal. (3D Rendering Engine) What's your opinion? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090402/38a366ee/attachment.htm From bugfact at gmail.com Wed Apr 1 18:32:43 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 1 18:19:53 2009 Subject: [Haskell-cafe] GSoC proposal In-Reply-To: <8914b92d0904011514g542c63c8o511a1c4e65824dc7@mail.gmail.com> References: <8914b92d0904011514g542c63c8o511a1c4e65824dc7@mail.gmail.com> Message-ID: Not good. If you succeed, this might attract a shitload of hackers like me to Haskell (as soon as they see that your render engine does about the same in 1/10th the lines of code...) And we want to avoid success at all cost :-) 2009/4/2 Csaba Hruska > Hi! > > I've submitted my proposal on gsoc portal. (3D Rendering Engine) > > What's your opinion? > > > _______________________________________________ > 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/20090402/ea27ba5e/attachment.htm From ndmitchell at gmail.com Wed Apr 1 18:42:49 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Apr 1 18:29:59 2009 Subject: [Haskell-cafe] GSoC proposal In-Reply-To: <8914b92d0904011514g542c63c8o511a1c4e65824dc7@mail.gmail.com> References: <8914b92d0904011514g542c63c8o511a1c4e65824dc7@mail.gmail.com> Message-ID: <404396ef0904011542p153782few2229168b65e55dde@mail.gmail.com> Hi Csaba, Do you mean you have submitted your proposal to the Haskell wiki thing, or to the official google application? If its the wiki, then submit it to the official Google thing as well. You can always edit it later, but the deadline is fast approaching. If its the Google thing, then not everyone can see. I'd recommend you send out your proposal on this list and let people comment, to perhaps revise your submission. Thanks Neil 2009/4/1 Csaba Hruska : > Hi! > > I've submitted my proposal on gsoc portal. (3D Rendering Engine) > > What's your opinion? > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From bugfact at gmail.com Wed Apr 1 18:45:12 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 1 18:32:22 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: vacuum-cairo: a cairo frontend tovacuum for live Haskell data visualization In-Reply-To: References: <20090331054038.GA5648@whirlpool.galois.com> <20090401201353.GJ12860@whirlpool.galois.com> Message-ID: Wed, Apr 1, 2009 at 11:20 PM, Claus Reinke wrote: > A platform-independent, open-source, 2d/3d graph layout engine >> > for incrementally updated graphs (where the graph after the update > has to be similar enough to the one before that one can follow the > animation and make sense of the data displayed) might be a good > project for frp+opengl hackers - force equations between nodes, > influenced by edges, and keeping the structure stable while adding > nodes (parsed from an input stream). Something like this? http://en.wikipedia.org/wiki/Force-based_algorithms Yes, I'm all for it :-) The only problem is finding time to do it :-( Although QuickSilver might be able to pull this off easily? Claus > > This cabalized project doesn't appear to be on hackage! >> >> gleb.alexeev: >> >>> Don Stewart wrote: >>> >>>> I am pleased to announce the release of vacuum-cairo, a Haskell library >>>> for interactive rendering and display of values on the GHC heap using >>>> Matt Morrow's vacuum library. >>>> >>> >>> Awesome stuff, kudos to you and Matt Morrow! >>> >>> I thought it'd be fun to visualize data structures in three dimensions. >>> Attached is quick and dirty hack based on your code and Ubigraph server >>> (http://ubietylab.net/ubigraph/). >>> >>> The demo video (apologies for poor quality): >>> http://www.youtube.com/watch?v=3mMH1cHWB6c >>> >>> If someone finds it fun enough, I'll cabalize it and upload to Hackage. >>> >> >> module Ubigraph where >>> >>> import Network.XmlRpc.Client >>> >>> type Url = String >>> type VertexId = Int >>> type EdgeId = Int >>> >>> defaultServer = "http://127.0.0.1:20738/RPC2" >>> >>> void :: IO Int -> IO () >>> void m = m >> return () >>> >>> clear :: Url -> IO () >>> clear url = void (remote url "ubigraph.clear") >>> >>> newVertex :: Url -> IO VertexId >>> newVertex url = remote url "ubigraph.new_vertex" >>> >>> newEdge :: Url -> VertexId -> VertexId -> IO EdgeId >>> newEdge url = remote url "ubigraph.new_edge" >>> >>> removeVertex :: Url -> VertexId -> IO () >>> removeVertex url vid = void (remote url "ubigraph.remove_vertex" vid) >>> >>> removeEgde :: Url -> EdgeId -> IO () >>> removeEgde url eid= void (remote url "ubigraph.remove_edge" eid) >>> >>> >>> zeroOnSuccess :: IO Int -> IO Bool >>> zeroOnSuccess = fmap (==0) >>> >>> newVertexWithId :: Url -> VertexId -> IO Bool >>> newVertexWithId url vid = zeroOnSuccess (remote url >>> "ubigraph.new_vertex_w_id" vid) >>> >>> newEdgeWithId :: Url -> EdgeId -> VertexId -> VertexId -> IO Bool >>> newEdgeWithId url eid x y = zeroOnSuccess (remote url >>> "ubigraph.new_edge_w_id" eid x y) >>> >>> setVertexAttribute :: Url -> VertexId -> String -> String -> IO Bool >>> setVertexAttribute url vid attr val = zeroOnSuccess (remote url >>> "ubigraph.set_vertex_attribute" vid attr val) >>> >>> setEdgeAttribute :: Url -> VertexId -> String -> String -> IO Bool >>> setEdgeAttribute url eid attr val = zeroOnSuccess (remote url >>> "ubigraph.set_edge_attribute" eid attr val) >>> >> >> module VacuumUbigraph where >>> >>> import GHC.Vacuum >>> import Data.Char >>> import Text.Printf >>> import Data.List >>> >>> import qualified Data.IntMap as IntMap >>> import qualified Data.IntSet as IntSet >>> >>> import qualified Ubigraph as U >>> >>> nodeStyle n = >>> case nodeName n of >>> ":" -> ("(:)", "cube", "#0000ff") >>> >>> -- atomic stuff is special >>> k | k `elem` ["S#" ,"I#" ,"W#" >>> ,"I8#" ,"I16#" ,"I32#" ,"I64#" >>> ,"W8#" ,"W16#" ,"W32#" ,"W64#"] -> (showLit n, >>> "sphere", "#00ff00") >>> -- chars >>> "C#" -> (show . chr . fromIntegral . head . nodeLits $ n, "sphere", >>> "#00ff00") >>> "D#" -> ("Double", "sphere", "#009900") >>> "F#" -> ("Float", "sphere", "#009900") >>> >>> -- bytestrings >>> "PS" -> (printf "ByteString[%d,%d]" (nodeLits n !! 1) (nodeLits n >>> !! 2), "cube", "#ff0000") >>> "Chunk" -> (printf "Chunk[%d,%d]" (nodeLits n !! 1) (nodeLits n !! >>> 2), "cube", "#ff0000") >>> >>> -- otherwise just the constructor and local fields >>> c | z > 0 -> >>> (c ++ show (take (fromIntegral z) $ nodeLits n), >>> "cube", "#990000") >>> | otherwise -> (c, "cube", "#990000") >>> where z = itabLits (nodeInfo n) >>> where >>> showLit n = show (head $ nodeLits n) >>> >>> view a = do >>> U.clear srv >>> mapM_ renderNode nodes >>> mapM_ renderEdge edges >>> where >>> g = vacuum a >>> alist = toAdjList g >>> nodes = nub $ map fst alist ++ concatMap snd alist >>> edges = concatMap (\(n, ns) -> map ((,) n) ns) alist >>> >>> style nid = maybe ("...", "cube", "#ff0000") nodeStyle >>> (IntMap.lookup nid g) >>> >>> renderNode nid = do >>> U.newVertexWithId srv nid >>> let (label, shape, color) = style nid >>> U.setVertexAttribute srv nid "label" label >>> U.setVertexAttribute srv nid "shape" shape >>> U.setVertexAttribute srv nid "color" color >>> >>> renderEdge (a, b) = do >>> e <- U.newEdge srv a b >>> U.setEdgeAttribute srv e "stroke" "dotted" >>> U.setEdgeAttribute srv e "arrow" "true" >>> >>> srv = U.defaultServer >>> >>> >> _______________________________________________ >>> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090402/66bc8ed6/attachment.htm From csaba.hruska at gmail.com Wed Apr 1 18:51:21 2009 From: csaba.hruska at gmail.com (Csaba Hruska) Date: Wed Apr 1 18:38:33 2009 Subject: [Haskell-cafe] GSoC proposal In-Reply-To: <404396ef0904011542p153782few2229168b65e55dde@mail.gmail.com> References: <8914b92d0904011514g542c63c8o511a1c4e65824dc7@mail.gmail.com> <404396ef0904011542p153782few2229168b65e55dde@mail.gmail.com> Message-ID: <8914b92d0904011551y485c994ewd310a078de20e338@mail.gmail.com> Abstract: The objective of this project is to create a useful, fast and feature rich 3D rendering engine in Haskell which supports advanced rendering features like level of detail, material state sorting, geometry instancing, scene handling, fast vertex buffer handling and so on. This would be beneficial for various applications, e.g. AI or virtual reality environments, simulation, games, and scientific applications. Current version available at http://code.google.com/p/lambdacube/ Content: *== Project Overview ==* This project aims to be the first general purpose 3D rendering engine written in a pure functional language. There is no graphics library available for Haskell that would be suitable as a basis for a complex graphical program. My Haskell rendering engine (called Lambda Cube Engine) uses the same model and material format as Ogre3D (http://www.ogre3d.org). This choice is motivated by the fact that Ogre3D has well-designed mesh model and material formats, and it also provides exporter plugins for nearly every significant 3D modeling software (3DS-Max, Maya, XSI, Blender etc.). This design decision lets us reuse existing 3D content and Ogre3D exporter plugins with ease. My knowledge of the Ogre3D architecture will help in making correct design decisions during development. * = Current State =* The source code is surprisingly small considering the current feature list. The program consists of 9 small Haskell modules and 2 script scanner description files. It can load a model from Ogre XML format and it parses the material definition scripts. It prevents model and material duplication using a cache. However, the features implemented are still just a subset of what these files can describe. Here is a list of (mainly) partially working features: - mesh loading from XML file - parsing material script (see its format: http://www.ogre3d.org/docs/manual/manual_14.html#SEC23) - caching loaded data - loading resource files from zip archive or filesystem - rendering data There is already an example available, which demonstrates all listed features. The example also uses Yampa FRP (Functional Rective Programming) library. One of the core ideas of the design was separating the high and low-level data representations. The high-level representation provides a convenient interface for the user and the low-level representation ensures efficient rendering on hardware. The Lambda Cube Engine depends on some (platform independent) libraries: - OpenGL binding - uulib - Utrecht Parser Combinator library used for script parsing - HXT - Haskell XML Toolkit is used for reading XML representation of mesh files. There is a more efficient binary version of the mesh format that will be supported later. - zip-archive - used for loading files from zip files. This helps decerase the number of media files. - stb-image - this is a temporary solution to support loading various image files. A more professional freeimage (freeimage.sf.net) loader is planned later. *= Goals for the Summer =* Fortunately the current state of the engine is advanced enough to start adding some more interesting functionality, such as: - Skeletal Animation This covers keyframe animation of objects. With skeletal animation we can create a very dynamic and alive environment (e.g. walking people). Outcome: interpolation function (spline), vertex buffer update functions - Level Of Detail support This is required for good performance and it is a very commonly used technique. With this feature we will be able to build high-complexity scenes. Outcome: vertex buffer switcher function in render pipeline. - Shadow Mapping (shadow support) Shadows are very a basic requirement of a modern 3D application. Shadow mapping is a technique that fits modern graphics hardware. Outcome: changes in the render function. - Post Processing Effects support (e.g. Motion Blur, HDR) This is a relatively new technique. It is widely used in present games because it increases visual quality very much. Outcome: compositor script parser functions. Some changes in the render function. - Particle System support Particle systems are used to create nice effects like explosions, rain, smoke. This is also a very basic technique of computer graphics. Outcome: particle system parser functions. - Optimization function for rendering It is required to minimize the state changes of graphical hardware during the rendering process to get top performance. This is one of the most important parts of a rendering engine. A well-chosen ordering of rendering batches could increase the performance considerably. Outcome: a new low-level (incremental) data structure and an update function for it. - The most interesting planned feature and possibly the most difficult one is the mesh modifier combinator set. This will let the user build a mesh in runtime. This extends the range of usability of the library (e.g. tesselation of impicit surfaces, subdivision, smoothing). Only an initial interface and some example mesh modifier combinator will be implemented until September. Outcome: high-level mesh data structure which contains the adjacency information of vertices and faces, plus some related modifier functions. Many components required for these functions are already available in the current implementation (e.g. vertex buffer handling, script parsing, resource framework). Having these working components will help us deal with the high-level part of a visual application. And possibly it will enable compiler developers to find out about the weak points of the compiler through interactive user application benchmarks. *== Rough Schedule ==* I'll start the implementation of smaller features as it is shown in the feature list. The example programs will be created after adding each feature. The overview documentation will be written in late July, I hope to have a stable interface by that time. I'll have exams at the university in June, so the development will advance at a moderate pace during that time. But judging by my experience since beginning this project it seems realistic to achieve the project goals by mid-August. * == Documentation ==* The documentation will include a short overview for every submodule (e.g. material system or scene management) and a system wide overview which aims to introduce the library to a newbie user. The provided example programs will be written in literate Haskell, so a text document can be generated from each of them. This will provide a detailed use case tutorial for user. A full API documentation will be generated with Haddock (http://www.haskell.org/haddock/). *== Testing ==* During the implementation of each feature a small demo example will be written. These examples can be used as documentation as well as test cases. These would be quite similar to Ogre3D examples and they could be used for performance comparison. I would also like to build a more complex example (a mini game) which should be able to show off all features and strengths of the engine. It will also serve as a baseline for the expected performance. *== Platform ==* The library does not contain platform dependent code, it is portable to every platform with a suitable Haskell compiler (currently GHC) and OpenGL. This currently means Windows, Linux, Mac OS X. In the future, I'd like to support other Haskell compilers than GHC, but for the time being GHC is the only compiler that can cope with all required libraries. *== Resulting Code ==* As a result of the summer project there will be a functional rendering engine, several small example programs and one bigger mini game. All documentation and source code including examples will be hosted on the project page. (http://code.google.com/p/lambdacube/) *== Licensing ==* The Lambda Cube Engine library is free software. The source code is covered by GPLv3. This gives maximum freedom to the community. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090402/12d98249/attachment-0001.htm From muad.dib.space at gmail.com Wed Apr 1 19:59:10 2009 From: muad.dib.space at gmail.com (muad) Date: Wed Apr 1 19:46:19 2009 Subject: [Haskell-cafe] Parsing with Proof In-Reply-To: <96232696-E63A-48EB-A5FC-6E4AE0E72BFA@cs.nott.ac.uk> References: <22814576.post@talk.nabble.com> <96232696-E63A-48EB-A5FC-6E4AE0E72BFA@cs.nott.ac.uk> Message-ID: <22835016.post@talk.nabble.com> Hi Martijn and Wouter, Based on the parser combinators paper, I put a monad together, > data Parser s t = Parser ([s] -> [(t, [s])]) > > pFail = Parser (const []) > pReturn a = Parser (\inp -> [(a, inp)]) > pSymbol s = Parser (\inp -> case inp of x:xs | x == s -> [(s,xs)] ; _ -> > []) > pChoice (Parser m) (Parser n) = Parser (\inp -> m inp ++ n inp) > pBind :: Parser s a -> (a -> Parser s b) -> Parser s b > pBind (Parser m) f = Parser (x m f) where > x :: ([s] -> [(a, [s])]) -> (a -> Parser s b) -> [s] -> [(b, [s])] > x m f inp = concatMap (y f) (m inp) > y f (a,s) = case f a of Parser g -> g s > > instance Monad (Parser s) where return = pReturn ; (>>=) = pBind > instance MonadPlus (Parser s) where mzero = pFail ; mplus = pChoice > > runParser (Parser f) inp = f inp and wrote the parser using that: > left = pSymbol '(' > right = pSymbol ')' > > parens = wrappend `mplus` empty where > empty = return Empty > wrappend = do left ; p <- parens ; right ; q <- parens ; return (Wrap p & > q) where > m & Empty = m > m & n = Append m n I really like the approach Wouter used for the State monad and I hope to follow that idea for this, I am not sure how to do it yet but I will scribble and see where it goes. Thanks very much for the advice! -- View this message in context: http://www.nabble.com/Parsing-with-Proof-tp22814576p22835016.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From wren at freegeek.org Wed Apr 1 20:10:54 2009 From: wren at freegeek.org (wren ng thornton) Date: Wed Apr 1 19:58:05 2009 Subject: [Haskell-cafe] Re: Looking for practical examples of Zippers In-Reply-To: <49a77b7a0903312254ka4c521br936e2fdc77baaf55@mail.gmail.com> References: <20090330193532.GB4181@whirlpool.galois.com> <49D2E30C.4060000@freegeek.org> <49a77b7a0903312254ka4c521br936e2fdc77baaf55@mail.gmail.com> Message-ID: <49D4028E.2090007@freegeek.org> David Menendez wrote: > On Tue, Mar 31, 2009 at 11:44 PM, wren ng thornton wrote: > > Another tricky thing for this particular example is answering the question > > of what you want to call the "focus". Usually zippered datastructures are > > functors, so given F X we can pick one X to be the focus and then unzip the > > F around it. > > The functor part isn't important. You can make a zipper from any > recursive structure. This seems at odds with the below > In general, if I have a type T and functors F and F' such that T is > isomorphic to F T and F' is the derivative of F, then ([F' T], T) is a > zipper for T. Right, for any equi-recursive type we can rewrite it as an iso-recursive type (Fix F ~ F (Fix F)) and the rest follows. But the F we feed into the fixed-point is a functor, otherwise Fix isn't going to like it; which goes against the claim that functorness isn't important. I didn't mean that T itself needs to be a functor, only that most often T = Fix F for some F, and the functorness of F is the helpful bit. Perhaps I was unclear. Of course, if T _is_ a functor then we can take the derivative of T instead, which may be sufficient for the task; I'd still call this a zipper. (The derivative of F is implicit here, but it can be hidden which is good for abstract types.) The point I was making, though, is that the abstract type "Map" is in fact smaller than the recursive type defined by the ADT we use to model it. For the type defined only by the ADT: convert to iso-recursion, take the derivative, and voila. But for the abstract type the ADT approximates, it's not as easy. -- Live well, ~wren From wren at freegeek.org Wed Apr 1 20:21:10 2009 From: wren at freegeek.org (wren ng thornton) Date: Wed Apr 1 20:08:18 2009 Subject: [Haskell-cafe] Zippers from any traversable [Was: Looking for practical examples of Zippers] In-Reply-To: <20090401065946.AC6B7AF97@Adric.metnet.fnmoc.navy.mil> References: <20090401065946.AC6B7AF97@Adric.metnet.fnmoc.navy.mil> Message-ID: <49D404F6.7070002@freegeek.org> oleg@okmij.org wrote: > wren ng thornton wrote: > > > how, for instance, turn a nested Map like > > > > > > Map Int (Map Int (Map String Double) > > > > > > into a "zipped" version. > > You can't. Or rather, you can't unless you have access to the > > implementation of the datastructure itself; and Data.Map doesn't provide > > enough details to do it. > > Actually Data.Map does provide enough details: Data.Map is a member of > Traversable and anything that supports Traversable (at the very least, Ah right, I forgot it had a Traversable instance (which is as good as having the implementation ;) -- Live well, ~wren From wren at freegeek.org Wed Apr 1 20:46:58 2009 From: wren at freegeek.org (wren ng thornton) Date: Wed Apr 1 20:34:08 2009 Subject: [Haskell-cafe] uvector package appendU: memory leak? In-Reply-To: <49D33EEA.8080500@libero.it> References: <49CFC944.4050805@libero.it><20090329193408.GB32044@whirlpool.galois.com><49CFD455.8070601@libero.it><20090329201500.GC32044@whirlpool.galois.com><49CFF240.7090700@libero.it><694810ED728D46F3AFED546B0049A230@cr3lt> <49D0F430.5000006@libero.it> <49D206BB.9040001@libero.it> <49D2DDE4.6010201@freegeek.org> <49D33EEA.8080500@libero.it> Message-ID: <49D40B02.6080608@freegeek.org> Manlio Perillo wrote: > wren ng thornton ha scritto: > > Manlio Perillo wrote: > > > Since ratings for each customers are parsed "at the same time", using > > > a plain list would consume a lot of memory, since stream fusion can > > > only be executed at the end of the parsing. > > > > > > On the other hand, when I want to group ratings by movies, stream > > > fusion seems to work fine. > > > > > [...] > > > > For the problem as you've discussed it, I'd suggest a different > > approach: You can't fit all the data into memory at once, so you > > shouldn't try to. You should write one program that takes in the > > per-movie grouping of data and produces a per-user file as output. > > Well, creating 480189 files in a directory is not a very nice thing to > do to a normal file system. I said *a* per-user file; that is, a file of (Movie,User,Rating) records sorted by User, as opposed to your current file which is sorted by Movie. As for the interim binning process, one file per user is only in the extreme case. Honestly, you should be able to get away with just reading through the file and splitting it into a handful of bins (8 or 16 at most) and assigning each user, u, to bin u = u `mod` qtyBins. The bins will be of uneven sizes, but they should be even enough that each is small enough to fit into memory. For this size data you can probably even leave the bins as a bag of (User,Movie,Rating) records and forgo the follow up step of sorting each bin by User. -- Live well, ~wren From duane.johnson at gmail.com Wed Apr 1 21:20:01 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Wed Apr 1 21:07:18 2009 Subject: [Haskell-cafe] ANNOUNCE: vacuum: extract graph representations of ghc heap values. In-Reply-To: <1bc51a990903302154l7ab82bedt2fefc9ea550b5235@mail.gmail.com> References: <1bc51a990903302154l7ab82bedt2fefc9ea550b5235@mail.gmail.com> Message-ID: Hi Matt, That looks pretty neat. Can you explain a little more about what I'm seeing in these visualizations, and where this kind of visualization would be most useful? (Debugging, algorithm tuning, etc.)? Take care, Duane Johnson http://blog.inquirylabs.com/ On Mar 30, 2009, at 10:54 PM, Matt Morrow wrote: > I am pleased to announce the release of vacuum, a Haskell library > for extracting graph > representations of values from the GHC heap, which may then be > further processed and/or > translated to Graphviz dot format to be visualized. > > The package website is at http://moonpatio.com/vacuum/, which > contains a gallery section > (which i intend to add to over time). > > The most recent version is 0.0.6, which is available on Hackage: > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vacuum/. > > Feedback, comments, and/or gallery submissions will be gratefully > received via this email > address (contrary to the email address currently on the vacuum > Hackage page (i fail at > setting up email :)). > > Matt > > _______________________________________________ > 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/20090401/c897df4d/attachment.htm From duane.johnson at gmail.com Wed Apr 1 21:25:38 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Wed Apr 1 21:12:52 2009 Subject: [Haskell-cafe] ANNOUNCE: vacuum: extract graph representations of ghc heap values. In-Reply-To: <1bc51a990903302154l7ab82bedt2fefc9ea550b5235@mail.gmail.com> References: <1bc51a990903302154l7ab82bedt2fefc9ea550b5235@mail.gmail.com> Message-ID: <016630E0-A8A6-401E-BD66-8891058CAC4F@gmail.com> Ah, I hadn't read Don's thread before posting my previous comment. That cleared things up for me :) Thanks! Duane Johnson On Mar 30, 2009, at 10:54 PM, Matt Morrow wrote: > I am pleased to announce the release of vacuum, a Haskell library > for extracting graph > representations of values from the GHC heap, which may then be > further processed and/or > translated to Graphviz dot format to be visualized. > > The package website is at http://moonpatio.com/vacuum/, which > contains a gallery section > (which i intend to add to over time). > > The most recent version is 0.0.6, which is available on Hackage: > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vacuum/. > > Feedback, comments, and/or gallery submissions will be gratefully > received via this email > address (contrary to the email address currently on the vacuum > Hackage page (i fail at > setting up email :)). > > Matt > > _______________________________________________ > 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/20090401/99d8c7d9/attachment.htm From jnf at arcor.de Wed Apr 1 23:59:16 2009 From: jnf at arcor.de (=?ISO-8859-1?Q?J=FCrgen?= Nicklisch-Franken) Date: Wed Apr 1 23:46:26 2009 Subject: [Haskell-cafe] Leksah patch release 0.4.4.1 Message-ID: <1238644756.5992.6.camel@jutaro-laptop> I've pushed a patch with a minor fix for the recurring query to open a file: * Doesn't attempt a background build, when there is no open package. * Doesn't keep bugging the user if the session they select does not have a valid package * Improved title on package open dialog * Updated the manual for better Ubuntu installation description Please note that Leksah doesn't work with GHC version 6.10.2 currently, because gtk2hs has problems with the changes on finalizers. Hope they can fix this soon. J?rgen From noteed at gmail.com Thu Apr 2 03:01:25 2009 From: noteed at gmail.com (minh thu) Date: Thu Apr 2 02:48:32 2009 Subject: [Haskell-cafe] GSoC proposal In-Reply-To: <8914b92d0904011551y485c994ewd310a078de20e338@mail.gmail.com> References: <8914b92d0904011514g542c63c8o511a1c4e65824dc7@mail.gmail.com> <404396ef0904011542p153782few2229168b65e55dde@mail.gmail.com> <8914b92d0904011551y485c994ewd310a078de20e338@mail.gmail.com> Message-ID: <40a414c20904020001o5d1012fft4c0ad238335abc25@mail.gmail.com> 2009/4/2 Csaba Hruska : > Abstract: > The objective of this project is to create a useful, fast and feature rich > 3D rendering engine in Haskell which supports advanced rendering features > like level of detail, material state sorting, geometry instancing, scene > handling, fast vertex buffer handling and so on. This would be beneficial > for various applications, e.g. AI or virtual reality environments, > simulation, games, and scientific applications. > Current version available at http://code.google.com/p/lambdacube/ > Content: > > == Project Overview == > > This project aims to be the first general purpose 3D rendering engine > written in a pure functional language. There is no graphics library > available for Haskell that would be suitable as a basis for a complex > graphical program. My Haskell rendering engine (called Lambda Cube > Engine) uses the same model and material format as Ogre3D > (http://www.ogre3d.org). This choice is motivated by the fact that > Ogre3D has well-designed mesh model and material formats, and it also > provides exporter plugins for nearly every significant 3D modeling > software (3DS-Max, Maya, XSI, Blender etc.). This design decision lets > us reuse existing 3D content and Ogre3D exporter plugins with ease. My > knowledge of the Ogre3D architecture will help in making correct > design decisions during development. > > = Current State = > > The source code is surprisingly small considering the current feature > list. The program consists of 9 small Haskell modules and 2 script > scanner description files. It can load a model from Ogre XML format > and it parses the material definition scripts. It prevents model and > material duplication using a cache. However, the features implemented > are still just a subset of what these files can describe. > > Here is a list of (mainly) partially working features: > - mesh loading from XML file > - parsing material script (see its format: > http://www.ogre3d.org/docs/manual/manual_14.html#SEC23) > - caching loaded data > - loading resource files from zip archive or filesystem > - rendering data > > There is already an example available, which demonstrates all listed > features. The example also uses Yampa FRP (Functional Rective > Programming) library. > > One of the core ideas of the design was separating the high and > low-level data representations. The high-level representation provides > a convenient interface for the user and the low-level representation > ensures efficient rendering on hardware. > > The Lambda Cube Engine depends on some (platform independent) > libraries: > - OpenGL binding > - uulib - Utrecht Parser Combinator library used for script parsing > - HXT - Haskell XML Toolkit is used for reading XML representation of > mesh files. There is a more efficient binary version of the mesh > format that will be supported later. > - zip-archive - used for loading files from zip files. This helps > decerase the number of media files. > - stb-image - this is a temporary solution to support loading various > image files. A more professional freeimage (freeimage.sf.net) > loader is planned later. > > = Goals for the Summer = > > Fortunately the current state of the engine is advanced enough to > start adding some more interesting functionality, such as: > > - Skeletal Animation > This covers keyframe animation of objects. With skeletal animation > we can create a very dynamic and alive environment (e.g. walking > people). Outcome: interpolation function (spline), vertex buffer > update functions > > - Level Of Detail support > This is required for good performance and it is a very commonly > used technique. With this feature we will be able to build > high-complexity scenes. Outcome: vertex buffer switcher function in > render pipeline. > > - Shadow Mapping (shadow support) > Shadows are very a basic requirement of a modern 3D > application. Shadow mapping is a technique that fits modern > graphics hardware. Outcome: changes in the render function. > > - Post Processing Effects support (e.g. Motion Blur, HDR) > This is a relatively new technique. It is widely used in present > games because it increases visual quality very much. > Outcome: compositor script parser functions. Some changes in the > render function. > > - Particle System support > Particle systems are used to create nice effects like explosions, > rain, smoke. This is also a very basic technique of computer > graphics. Outcome: particle system parser functions. > > - Optimization function for rendering > It is required to minimize the state changes of graphical hardware > during the rendering process to get top performance. This is one > of the most important parts of a rendering engine. A well-chosen > ordering of rendering batches could increase the performance > considerably. Outcome: a new low-level (incremental) data structure > and an update function for it. > > - The most interesting planned feature and possibly the most > difficult one is the mesh modifier combinator set. This will let > the user build a mesh in runtime. This extends the range of > usability of the library (e.g. tesselation of impicit surfaces, > subdivision, smoothing). Only an initial interface and some example > mesh modifier combinator will be implemented until September. > Outcome: high-level mesh data structure which contains the > adjacency information of vertices and faces, plus some related > modifier functions. > > Many components required for these functions are already available in > the current implementation (e.g. vertex buffer handling, script > parsing, resource framework). > > Having these working components will help us deal with the high-level > part of a visual application. And possibly it will enable compiler > developers to find out about the weak points of the compiler through > interactive user application benchmarks. > > == Rough Schedule == > > I'll start the implementation of smaller features as it is shown in > the feature list. The example programs will be created after adding > each feature. The overview documentation will be written in late July, > I hope to have a stable interface by that time. I'll have exams at the > university in June, so the development will advance at a moderate pace > during that time. But judging by my experience since beginning this > project it seems realistic to achieve the project goals by mid-August. > > == Documentation == > > The documentation will include a short overview for every submodule > (e.g. material system or scene management) and a system wide overview > which aims to introduce the library to a newbie user. The provided > example programs will be written in literate Haskell, so a text > document can be generated from each of them. This will provide a > detailed use case tutorial for user. A full API documentation will be > generated with Haddock (http://www.haskell.org/haddock/). > > == Testing == > > During the implementation of each feature a small demo example will be > written. These examples can be used as documentation as well as test > cases. These would be quite similar to Ogre3D examples and they could > be used for performance comparison. I would also like to build a more > complex example (a mini game) which should be able to show off all > features and strengths of the engine. It will also serve as a baseline > for the expected performance. > > == Platform == > > The library does not contain platform dependent code, it is portable > to every platform with a suitable Haskell compiler (currently GHC) and > OpenGL. This currently means Windows, Linux, Mac OS X. In the future, > I'd like to support other Haskell compilers than GHC, but for the time > being GHC is the only compiler that can cope with all required > libraries. > > == Resulting Code == > > As a result of the summer project there will be a functional rendering > engine, several small example programs and one bigger mini game. All > documentation and source code including examples will be hosted on the > project page. (http://code.google.com/p/lambdacube/) > > == Licensing == > > The Lambda Cube Engine library is free software. The source code is Hi, All this sounds very good but I'm not sure I understand the complete goal. Is it more about rendering or (game) engine ? Ok, the title is Engine, but is it more a library or a complete framework (with archive loading, saving/load state, behaviors (ai, user interaction, ...), sound placement, networking, ...) ? You mention Yampa. Is it just for the example or do you plane to rely on it ? What is the part of state-of-the-art rendering ? I'm not really aware of all of this, but I think current focus is on non-fixed pipeline (i.e. vertex and fragment program), how is taken into account here ? By the OGRE material files ? Or what about frustum culling and space partitioning ? Is it up to the user of you code ? Do you use an extant engine or scene graph library as inspiration ? I'm sure I had other questions by reading your proposal but I forgot... Anyway, this is very interesting and I wish you good luck, ... and success. Cheers, Thu From gleb.alexeev at gmail.com Thu Apr 2 03:25:48 2009 From: gleb.alexeev at gmail.com (Gleb Alexeyev) Date: Thu Apr 2 03:12:33 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: vacuum-cairo: a cairo frontend to vacuum for live Haskell data visualization In-Reply-To: <20090401201353.GJ12860@whirlpool.galois.com> References: <20090331054038.GA5648@whirlpool.galois.com> <20090401201353.GJ12860@whirlpool.galois.com> Message-ID: Don Stewart wrote: > Did you use hubigraph? > > http://ooxo.org/hubigraph/ > > This cabalized project doesn't appear to be on hackage! > Oh, I wasn't aware of hubigraph until now. Ubigraph has very simple XML-RPC-based API so I used it directly. Hubigraph, of course, looks nicer with its custom monad, datatypes for shapes etc. BTW, it seems that you didn't notice the complete source code attached to my first message. Like I said it's just a quick and dirty hack, all real job is done by vacuum, Ubigraph server and a bit of code copy-pasted from vacuum-cairo. From csaba.hruska at gmail.com Thu Apr 2 03:56:24 2009 From: csaba.hruska at gmail.com (Csaba Hruska) Date: Thu Apr 2 03:43:34 2009 Subject: [Haskell-cafe] GSoC proposal In-Reply-To: <40a414c20904020001o5d1012fft4c0ad238335abc25@mail.gmail.com> References: <8914b92d0904011514g542c63c8o511a1c4e65824dc7@mail.gmail.com> <404396ef0904011542p153782few2229168b65e55dde@mail.gmail.com> <8914b92d0904011551y485c994ewd310a078de20e338@mail.gmail.com> <40a414c20904020001o5d1012fft4c0ad238335abc25@mail.gmail.com> Message-ID: <8914b92d0904020056w3670057fs9fcae28c84582e4c@mail.gmail.com> 2009/4/2 minh thu > 2009/4/2 Csaba Hruska : > > Abstract: > > The objective of this project is to create a useful, fast and feature > rich > > 3D rendering engine in Haskell which supports advanced rendering features > > like level of detail, material state sorting, geometry instancing, scene > > handling, fast vertex buffer handling and so on. This would be beneficial > > for various applications, e.g. AI or virtual reality environments, > > simulation, games, and scientific applications. > > Current version available at http://code.google.com/p/lambdacube/ > > Content: > > > > == Project Overview == > > > > This project aims to be the first general purpose 3D rendering engine > > written in a pure functional language. There is no graphics library > > available for Haskell that would be suitable as a basis for a complex > > graphical program. My Haskell rendering engine (called Lambda Cube > > Engine) uses the same model and material format as Ogre3D > > (http://www.ogre3d.org). This choice is motivated by the fact that > > Ogre3D has well-designed mesh model and material formats, and it also > > provides exporter plugins for nearly every significant 3D modeling > > software (3DS-Max, Maya, XSI, Blender etc.). This design decision lets > > us reuse existing 3D content and Ogre3D exporter plugins with ease. My > > knowledge of the Ogre3D architecture will help in making correct > > design decisions during development. > > > > = Current State = > > > > The source code is surprisingly small considering the current feature > > list. The program consists of 9 small Haskell modules and 2 script > > scanner description files. It can load a model from Ogre XML format > > and it parses the material definition scripts. It prevents model and > > material duplication using a cache. However, the features implemented > > are still just a subset of what these files can describe. > > > > Here is a list of (mainly) partially working features: > > - mesh loading from XML file > > - parsing material script (see its format: > > http://www.ogre3d.org/docs/manual/manual_14.html#SEC23) > > - caching loaded data > > - loading resource files from zip archive or filesystem > > - rendering data > > > > There is already an example available, which demonstrates all listed > > features. The example also uses Yampa FRP (Functional Rective > > Programming) library. > > > > One of the core ideas of the design was separating the high and > > low-level data representations. The high-level representation provides > > a convenient interface for the user and the low-level representation > > ensures efficient rendering on hardware. > > > > The Lambda Cube Engine depends on some (platform independent) > > libraries: > > - OpenGL binding > > - uulib - Utrecht Parser Combinator library used for script parsing > > - HXT - Haskell XML Toolkit is used for reading XML representation of > > mesh files. There is a more efficient binary version of the mesh > > format that will be supported later. > > - zip-archive - used for loading files from zip files. This helps > > decerase the number of media files. > > - stb-image - this is a temporary solution to support loading various > > image files. A more professional freeimage (freeimage.sf.net) > > loader is planned later. > > > > = Goals for the Summer = > > > > Fortunately the current state of the engine is advanced enough to > > start adding some more interesting functionality, such as: > > > > - Skeletal Animation > > This covers keyframe animation of objects. With skeletal animation > > we can create a very dynamic and alive environment (e.g. walking > > people). Outcome: interpolation function (spline), vertex buffer > > update functions > > > > - Level Of Detail support > > This is required for good performance and it is a very commonly > > used technique. With this feature we will be able to build > > high-complexity scenes. Outcome: vertex buffer switcher function in > > render pipeline. > > > > - Shadow Mapping (shadow support) > > Shadows are very a basic requirement of a modern 3D > > application. Shadow mapping is a technique that fits modern > > graphics hardware. Outcome: changes in the render function. > > > > - Post Processing Effects support (e.g. Motion Blur, HDR) > > This is a relatively new technique. It is widely used in present > > games because it increases visual quality very much. > > Outcome: compositor script parser functions. Some changes in the > > render function. > > > > - Particle System support > > Particle systems are used to create nice effects like explosions, > > rain, smoke. This is also a very basic technique of computer > > graphics. Outcome: particle system parser functions. > > > > - Optimization function for rendering > > It is required to minimize the state changes of graphical hardware > > during the rendering process to get top performance. This is one > > of the most important parts of a rendering engine. A well-chosen > > ordering of rendering batches could increase the performance > > considerably. Outcome: a new low-level (incremental) data structure > > and an update function for it. > > > > - The most interesting planned feature and possibly the most > > difficult one is the mesh modifier combinator set. This will let > > the user build a mesh in runtime. This extends the range of > > usability of the library (e.g. tesselation of impicit surfaces, > > subdivision, smoothing). Only an initial interface and some example > > mesh modifier combinator will be implemented until September. > > Outcome: high-level mesh data structure which contains the > > adjacency information of vertices and faces, plus some related > > modifier functions. > > > > Many components required for these functions are already available in > > the current implementation (e.g. vertex buffer handling, script > > parsing, resource framework). > > > > Having these working components will help us deal with the high-level > > part of a visual application. And possibly it will enable compiler > > developers to find out about the weak points of the compiler through > > interactive user application benchmarks. > > > > == Rough Schedule == > > > > I'll start the implementation of smaller features as it is shown in > > the feature list. The example programs will be created after adding > > each feature. The overview documentation will be written in late July, > > I hope to have a stable interface by that time. I'll have exams at the > > university in June, so the development will advance at a moderate pace > > during that time. But judging by my experience since beginning this > > project it seems realistic to achieve the project goals by mid-August. > > > > == Documentation == > > > > The documentation will include a short overview for every submodule > > (e.g. material system or scene management) and a system wide overview > > which aims to introduce the library to a newbie user. The provided > > example programs will be written in literate Haskell, so a text > > document can be generated from each of them. This will provide a > > detailed use case tutorial for user. A full API documentation will be > > generated with Haddock (http://www.haskell.org/haddock/). > > > > == Testing == > > > > During the implementation of each feature a small demo example will be > > written. These examples can be used as documentation as well as test > > cases. These would be quite similar to Ogre3D examples and they could > > be used for performance comparison. I would also like to build a more > > complex example (a mini game) which should be able to show off all > > features and strengths of the engine. It will also serve as a baseline > > for the expected performance. > > > > == Platform == > > > > The library does not contain platform dependent code, it is portable > > to every platform with a suitable Haskell compiler (currently GHC) and > > OpenGL. This currently means Windows, Linux, Mac OS X. In the future, > > I'd like to support other Haskell compilers than GHC, but for the time > > being GHC is the only compiler that can cope with all required > > libraries. > > > > == Resulting Code == > > > > As a result of the summer project there will be a functional rendering > > engine, several small example programs and one bigger mini game. All > > documentation and source code including examples will be hosted on the > > project page. (http://code.google.com/p/lambdacube/) > > > > == Licensing == > > > > The Lambda Cube Engine library is free software. The source code is > > Hi, > > All this sounds very good but I'm not sure I understand the complete goal. > > Is it more about rendering or (game) engine ? Ok, the title is Engine, but > is > it more a library or a complete framework (with archive loading, > saving/load state, behaviors (ai, user interaction, ...), sound > placement, networking, ...) ? It is about rendering. A complete game engine implementation is not fitting into one summer project. > > > You mention Yampa. Is it just for the example or do you plane to rely on it > ? The library must be as independent as possibe so it is not using Yampa. Only the current example depends on it. > > > What is the part of state-of-the-art rendering ? I'm not really aware > of all of this, but I think > current focus is on non-fixed pipeline (i.e. vertex and fragment > program), how is taken into account here ? By the OGRE material files > ? The material file format can describe both shader programs and fixed function attributes which are optional. But the implementation details are hidden from the user. The format does not limit the functionality. Modern approach is base concept of Lambda Cube Engine. > > > Or what about frustum culling and space partitioning ? Is it up to the > user of you code ? These are definitely included in the engine's scene handling module. > > > Do you use an extant engine or scene graph library as inspiration ? I've checked frag (http://www.haskell.org/haskellwiki/Frag) and scenegraph ( http://www.haskell.org/haskellwiki/SceneGraph) source code but just for collect some info and I will not use them. Scenegraph's scene combinators seems good maybe I'll reuse its concept in scene module. But firstly I'd like implement the low level part of the engine. > > > I'm sure I had other questions by reading your proposal but I forgot... > > Anyway, this is very interesting and I wish you good luck, ... and success. > > Cheers, > Thu > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090402/ad478427/attachment.htm From mpm at alumni.caltech.edu Thu Apr 2 03:57:20 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Thu Apr 2 03:44:48 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] Re: making translation from imperative code In-Reply-To: References: <49D21274.80106@alumni.caltech.edu> <49D30AB7.9070909@alumni.caltech.edu> Message-ID: <49D46FE0.9050106@alumni.caltech.edu> Thanks very much for the help... I will look at this over the next couple of days. Your code actually addresses a different problem, the one of merging separates lists of timed events. I do need to write code to do that eventually, so I will try to understand what you have written here. However, the original problem concerns visual layout, which actually takes place *after* creating a merged list. In layout, items do have times associated with them, but also take up physical space. Different items takes up different amounts of space, and at any given "time," there may be items on all the staves or just some of them. I will try to come up with (1) a more succinct explanation of the problem (with textual graphics as a visual aid) (2) a more succinct algorithm. For example, you are right that I'm mixing concerns. The system layout can terminate for two reasons: (1) reached the end of the score (2) reached the right edge of the page. There might be a way to simplify the loop or fold so that these concerns look more unified. -Mike PS a question below: Heinrich Apfelmus wrote: > Michael Mossey wrote: >> Heinrich Apfelmus wrote: >>> Can you elaborate on what exactly the algorithm is doing? Does it just >>> emit notes/chords/symbols at given positions or does it also try to >>> arrange them nicely? And most importantly, "where" does it emit them to, >>> i.e. what's the resulting data structure? >>> >>> So far, the problem looks like a basic fold to me. >> Here is some Haskell code that explains the problem in >> more detail. >> [...] > > Thanks for the elaboration. > > I think the code doesn't separate concerns very well; mixing information > about widths and times, page size and the recursion itself into one big > gnarl. > > Also, there is one important issue, namely returning a special value > like -1 as error code in > >> tryAgain state = >> case scoreNextTime score (time state) of >> -1 -> indicateNoMoreChunks state >> t -> layoutSystem' (setTime state t) > > Don't do this, use Maybe instead > > tryAgain state = case scoreNextTime score (time state) of > Nothing -> indicateNoMoreChunks state > Just t -> layoutSystem' (state { time = t }) > > where Nothing indicates failure and Just success. > > > Back to the gnarl in general, I still don't have a good grasp on the > problem domain, which is key to structuring the algorithm. Therefore, > I'll expand on toy model and you tell me how it differs from the real thing. > > The model is this: we are given several lists of notes (f.i. a piano > part and a vocal line) where each note is annotated with the time it is > to be played at. We abstract away the fact that we are dealing with > musical notes and simply consider a list of *events* > > type Time = Integer > type Events a = [(Time, a)] > > with the invariant that the timestamps are (strictly) increasing: > > valid :: Events a -> Bool > valid xs = all $ zipWith (\(t1,_) (t2,_) -> t1 < t2) xs (drop 1 xs) > > Now, the toy task is to merge several lists of similar events into one > big list that is ordered by time as well. > > merge :: [Events a] -> Events [a] > > Since some events may now occur simultaneously, the events of the > results are actually lists of "primitive" events. > > One possibility for implementing merge is to start with a function to > merge two event lists > > merge2 :: Events [a] -> Events [a] -> Events [a] > merge2 [] ys = ys > merge2 xs [] = xs > merge2 xs@((tx,x):xt) ys@((ty,y):yt) = case compare tx ty of > LT -> (tx,x ) : merge2 xt ys > EQ -> (tx,x++y) : merge2 xt yt > GT -> (ty, y) : merge2 xs yt > > and to apply it several times > > merge = foldr merge2 [] . map lift > where lift = map $ \(t,x) -> (t,[x]) > > > Another possibility is to simply concatenate everything first and then > sort by time > > merge = map (\((t,x):xs) -> (t,x:map snd xs)) > . groupBy ((==) `on` fst) > . sortBy (comparing fst) > . concat > > > The code above can be made more readable by choosing nice names like > > time = fst > event = snd > > or avoiding pairs altogether and implementing these names as record > fields. Also, the (&&&) combinator from Control.Arrow is very handy. > > merge = map (time . head &&& map event) > . groupBy ((==) `on` time) > . sortBy (comparing time) > . concat > > > I hope this gives you a few ideas to think about. How does this toy > model differ from the real thing? > > > Regards, > apfelmus > > > PS: If some parts of my example code give you trouble, it's probably > fastest to ask around on the #haskell IRC channel. > > -- > http://apfelmus.nfshost.com > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners From nicolas.pouillard at gmail.com Thu Apr 2 04:32:54 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Thu Apr 2 04:21:15 2009 Subject: [Haskell-cafe] Reverting to any old version using Darcs In-Reply-To: References: <20090401171436.GA12860@whirlpool.galois.com> <873acsxi3y.fsf@malde.org> <20090401202953.GK12860@whirlpool.galois.com> Message-ID: <1238660704-sup-3258@ausone.inria.fr> Excerpts from Peter Verswyvelen's message of Wed Apr 01 23:39:15 +0200 2009: [...] > biggest problems I usually see in teams - namely forgetting to add files, > forgetting to check in dependencies and the inability the merge after > renames or moves - Have a look at the --look-for-adds flag that makes the enables the detection of new files. Removing files is already detected and moving should be done with "darcs mv" which makes it pretty close to what one can expect. Best regards, -- Nicolas Pouillard From dmehrtash at gmail.com Thu Apr 2 05:44:39 2009 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Thu Apr 2 05:31:48 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: vacuum-cairo: a cairo frontend to vacuum for live Haskell data visualization In-Reply-To: References: <20090331054038.GA5648@whirlpool.galois.com> <20090401201353.GJ12860@whirlpool.galois.com> Message-ID: When I try to install the hubigraph I get the following error: :~/Desktop/hubigraph-0.1$ cabal install Resolving dependencies... 'haxr-3000.1.1.2' is cached. Configuring haxr-3000.1.1.2... Preprocessing library haxr-3000.1.1.2... Building haxr-3000.1.1.2... [1 of 6] Compiling Network.XmlRpc.DTD_XMLRPC ( Network/XmlRpc/DTD_XMLRPC.hs, dist/build/Network/XmlRpc/DTD_XMLRPC.o ) Network/XmlRpc/DTD_XMLRPC.hs:183:4: Warning: Pattern match(es) are overlapped In the definition of `fromElem': fromElem (CMisc _ : rest) = ... fromElem (CString _ s : rest) = ... fromElem rest = ... [2 of 6] Compiling Network.XmlRpc.Base64 ( Network/XmlRpc/Base64.hs, dist/build/Network/XmlRpc/Base64.o ) [3 of 6] Compiling Network.XmlRpc.Internals ( Network/XmlRpc/Internals.hs, dist/build/Network/XmlRpc/Internals.o ) [4 of 6] Compiling Network.XmlRpc.Server ( Network/XmlRpc/Server.hs, dist/build/Network/XmlRpc/Server.o ) [5 of 6] Compiling Network.XmlRpc.Client ( Network/XmlRpc/Client.hs, dist/build/Network/XmlRpc/Client.o ) Network/XmlRpc/Client.hs:113:23: Not in scope: type constructor or class `ConnError' Network/XmlRpc/Client.hs:113:51: Not in scope: type constructor or class `ConnError' cabal: Error: some packages failed to install: HUBIGraph-0.1 depends on haxr-3000.1.1.2 which failed to install. haxr-3000.1.1.2 failed during the building phase. The exception was: exit: ExitFailure 1 Any ideas? Thanks, Daryoush On Thu, Apr 2, 2009 at 12:25 AM, Gleb Alexeyev wrote: > Don Stewart wrote: > >> Did you use hubigraph? >> >> http://ooxo.org/hubigraph/ >> >> This cabalized project doesn't appear to be on hackage! >> >> Oh, I wasn't aware of hubigraph until now. > Ubigraph has very simple XML-RPC-based API so I used it directly. > Hubigraph, of course, looks nicer with its custom monad, datatypes for > shapes etc. > > BTW, it seems that you didn't notice the complete source code attached to > my first message. Like I said it's just a quick and dirty hack, all real job > is done by vacuum, Ubigraph server and a bit of code copy-pasted from > vacuum-cairo. > > > _______________________________________________ > 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/20090402/431d6660/attachment.htm From manlio_perillo at libero.it Thu Apr 2 05:54:34 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Thu Apr 2 05:41:50 2009 Subject: [Haskell-cafe] binary package: memory problem decoding an IntMap Message-ID: <49D48B5A.4080406@libero.it> Hi. I'm having memory problems decoding a big IntMap. The data structure is: IntMap (UArr (Word16 :*: Word8)) There are 480189 keys, and a total of 100480507 elements (Netflix Prize). The size of the encoded (and compressed) data is 184 MB. When I load data from the Netflix Prize data set, total memory usage is 1030 Mb. However when I try to decode the data, memory usage grows too much (even using the -F1.1 option in the RTS). The problem seems to be with `fromAscList` function, defined as: fromList :: [(Key,a)] -> IntMap a fromList xs = foldlStrict ins empty xs where ins t (k,x) = insert k x t (by the way, why IntMap module does not use Data.List.foldl'?). The `ins` function is not strict. This seems an hard problem to solve. First of all, IntMap should provide strict variants of the implemented functions. And the binary package should choose whether use the strict or lazy version. For me, the simplest solution is to serialize the association list obtained from `toAscList` function, instead of directly serialize the IntMap. The question is: can I "reuse" the data already serialized? Is the binary format of `IntMap a` and `[(Int, a)]` compatible? Thanks Manlio Perillo From duncan.coutts at worc.ox.ac.uk Thu Apr 2 05:56:30 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Apr 2 05:43:33 2009 Subject: [Haskell-cafe] Announcement: Beta of Leksah IDE available In-Reply-To: References: <1238538058.6785.11.camel@jutaro-laptop> <20090401011918.0a3af602@solaris> <22831401.post@talk.nabble.com> <404396ef0904011047n45f36662yf6fc728097c60f28@mail.gmail.com> <22834510.post@talk.nabble.com> Message-ID: <1238666190.25888.1391.camel@localhost> On Wed, 2009-04-01 at 22:13 +0200, David Waern wrote: > 2009/4/1 jutaro : > > I guess you mean the dialog which should help leksah to find sources > > for installed packages. It needs this so you can go to all the definitions > > in the base packages ... This is very handy if it works. Look to the manual > > for details. > > Maybe could add support to Cabal for installing sources? Should be > very useful to have in general. http://hackage.haskell.org/trac/hackage/ticket/364 Duncan From ketil at malde.org Thu Apr 2 06:20:48 2009 From: ketil at malde.org (Ketil Malde) Date: Thu Apr 2 06:06:53 2009 Subject: [Haskell-cafe] Reverting to any old version using Darcs In-Reply-To: (Peter Verswyvelen's message of "Wed\, 1 Apr 2009 23\:39\:15 +0200") References: <20090401171436.GA12860@whirlpool.galois.com> <873acsxi3y.fsf@malde.org> <20090401202953.GK12860@whirlpool.galois.com> Message-ID: <87wsa3uzjz.fsf@malde.org> Peter Verswyvelen writes: > Forgetting to add a file can be a nasty one, since if you discover > that too late, the original file at patch time might not exist > anymore (how do you guys solve this? Just plain discipline I > guess?). I've done this once, but with the cabal dependencies, not darcs. Thus the uploaded sdist was missing one of the source files, and consequently failed to build. I suppose the best way is to test this with a separate test repository which you don't touch, except from pulling from your development repo and checking that it builds. -k -- If I haven't seen further, it is by standing in the footprints of giants From david.waern at gmail.com Thu Apr 2 07:24:35 2009 From: david.waern at gmail.com (David Waern) Date: Thu Apr 2 07:11:43 2009 Subject: [Haskell-cafe] Announcement: Beta of Leksah IDE available In-Reply-To: <1238666190.25888.1391.camel@localhost> References: <1238538058.6785.11.camel@jutaro-laptop> <20090401011918.0a3af602@solaris> <22831401.post@talk.nabble.com> <404396ef0904011047n45f36662yf6fc728097c60f28@mail.gmail.com> <22834510.post@talk.nabble.com> <1238666190.25888.1391.camel@localhost> Message-ID: 2009/4/2 Duncan Coutts : > On Wed, 2009-04-01 at 22:13 +0200, David Waern wrote: >> 2009/4/1 jutaro : >> > I guess you mean the dialog which should help leksah to find sources >> > for installed packages. It needs this so you can go to all the definitions >> > in the base packages ... This is very handy if it works. Look to the manual >> > for details. >> >> Maybe could add support to Cabal for installing sources? Should be >> very useful to have in general. > > http://hackage.haskell.org/trac/hackage/ticket/364 Jutaru, perhaps a nice Hackathon project? :-) David From patai_gergely at fastmail.fm Thu Apr 2 07:26:29 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Thu Apr 2 07:13:37 2009 Subject: [Haskell-cafe] ZipList monad, anyone? In-Reply-To: <7ca3f0160904010445x4c4ac154n5e8d06669618810d@mail.gmail.com> References: <1238582675.10366.1308390907@webmail.messagingengine.com> <7ca3f0160904010445x4c4ac154n5e8d06669618810d@mail.gmail.com> Message-ID: <1238671589.29863.1308595069@webmail.messagingengine.com> > Having spent several months on this exact problem, I'll say that I > consider it pretty unlikely. I wouldn't be very surprised if that was the case. > A clever data structure might give you logarithmic or even amortized > constant time access in sequential cases, but you probably will not have > good garbage collection properties (all data will remain for all time). I guess cleverness should be concentrated on aging streams properly. But I do see how the ability to extract the diagonal conflicts with such efforts. > Stick with Applicative for this type of thing. Monad will drive you > insane :-) In fact, even applicative is far from trivial. ;) For instance, I still can't see how I could implement the <*> operator with stateless streams that don't need to keep track of their local time (needed when combining them with stateful streams, that is). Gergely -- http://www.fastmail.fm - Access all of your messages and folders wherever you are From patai_gergely at fastmail.fm Thu Apr 2 07:41:20 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Thu Apr 2 07:28:28 2009 Subject: [Haskell-cafe] ZipList monad, anyone? In-Reply-To: <49a77b7a0904010842w41801cccm21326537e290912f@mail.gmail.com> References: <1238582675.10366.1308390907@webmail.messagingengine.com> <7ca3f0160904010445x4c4ac154n5e8d06669618810d@mail.gmail.com> <49a77b7a0904010842w41801cccm21326537e290912f@mail.gmail.com> Message-ID: <1238672480.32119.1308596361@webmail.messagingengine.com> > Yes, although you should use an actual infinite list type if you're > depending on that. I know, I just wanted to stick with the basic list type for the sake of the discussion. > In fact, the Stream package provides an infinite list type with > Applicative and Monad instances. I didn't know that, but now that I checked it out, it is indeed the same thing. > Really, you're better off just using Nat -> a. The primary advantage > to using a list over a function is avoiding recomputation, but nothing > is getting recomputed here. Well, at least streams can be made efficient in the absence of bind, as opposed to functions, but I see your point. After all, that's the problem with bind: it receives a function, which has no visible internal structure, so it can only grow as you combine it with other things... Gergely -- http://www.fastmail.fm - A no graphics, no pop-ups email service From patai_gergely at fastmail.fm Thu Apr 2 07:52:59 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Thu Apr 2 07:40:07 2009 Subject: [Haskell-cafe] ZipList monad, anyone? In-Reply-To: <200904011142.57428.dan.doel@gmail.com> References: <1238582675.10366.1308390907@webmail.messagingengine.com> <200904011142.57428.dan.doel@gmail.com> Message-ID: <1238673179.2291.1308598583@webmail.messagingengine.com> > For instance, if we consider just join, with the above definition: > > join [[1,2],[3]] = [1, _|_] > > Which, I think, is fairly undesirable. You can try to avoid bottoms like > so: Well, there is a trick you can use here: wrap everything in a Maybe. Not that it helps with the efficiency issue, but at least you can mark the empty spots of the diagonal, since it's possible to check the length of the list before extracting its nth element. Which leads to some kind of MaybeZipList: newtype MaybeZipList a = MZL { getMZL :: [Maybe a] } deriving Show instance Monad MaybeZipList where return = MZL . repeat . Just MZL mxs >>= f = MZL $ zipWith bind mxs [0..] where bind mx n = do x <- mx let ys = getMZL (f x) if length (take (n+1) ys) <= n then Nothing else ys !! n But it's still not perfect, since the laws only apply modulo extra Nothings at the end of the resulting lists... > This monad works fine for size enforced vectors Sure, I just can't see any good use for those. After all, if you use arrays, you have to keep the whole structure in the memory just to discard most of it. Thanks for all the answers! Gergely -- http://www.fastmail.fm - Or how I learned to stop worrying and love email again From marlowsd at gmail.com Thu Apr 2 08:09:54 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Thu Apr 2 07:57:07 2009 Subject: [Haskell-cafe] Re: Announcement: Beta of Leksah IDE available In-Reply-To: References: <1238538058.6785.11.camel@jutaro-laptop> <20090401011918.0a3af602@solaris> <22831401.post@talk.nabble.com> <404396ef0904011047n45f36662yf6fc728097c60f28@mail.gmail.com> <22834510.post@talk.nabble.com> <1238666190.25888.1391.camel@localhost> Message-ID: <49D4AB12.2090100@gmail.com> David Waern wrote: > 2009/4/2 Duncan Coutts : >> On Wed, 2009-04-01 at 22:13 +0200, David Waern wrote: >>> 2009/4/1 jutaro : >>>> I guess you mean the dialog which should help leksah to find sources >>>> for installed packages. It needs this so you can go to all the definitions >>>> in the base packages ... This is very handy if it works. Look to the manual >>>> for details. >>> Maybe could add support to Cabal for installing sources? Should be >>> very useful to have in general. >> http://hackage.haskell.org/trac/hackage/ticket/364 > > Jutaru, perhaps a nice Hackathon project? :-) I think there's some design work to do there. See the discussion on the GHC ticket: http://hackage.haskell.org/trac/ghc/ticket/2630. In short: just keeping the source code around isn't enough. You need some metadata in order to make sense of the source code - for example, you can't feed the source code to the GHC API without knowing which additional flags need to be passed, and those come from the .cabal file. Also you probably want to stash the results of the 'cabal configure' step so that you can get a view of the source code that is consistent with the version(s?) you compiled. We need to think about about backwards and forwards-compatibility of whatever metadata format is used. And then you'll need Cabal APIs to extract the metadata. So we need to think about what APIs make sense, and the best way to do that is to think about what tool(s) you want to write and use that to drive the API design. Perhaps all this is going a bit too far. Maybe we want to just stash the source code and accept that there are some things that you just can't do with it. However, I imagine that pretty soon people will want to feed the source code into the GHC API, and at that point we have to tackle the build metadata issues. Cheers, Simon From jon at ffconsultancy.com Thu Apr 2 08:25:05 2009 From: jon at ffconsultancy.com (Jon Harrop) Date: Thu Apr 2 08:05:58 2009 Subject: [Haskell-cafe] SciMark2 benchmark Message-ID: <200904021325.05063.jon@ffconsultancy.com> Has anyone ported the SciMark2 benchmark suite to Haskell? -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e From jnf at arcor.de Thu Apr 2 08:27:10 2009 From: jnf at arcor.de (jutaro) Date: Thu Apr 2 08:14:18 2009 Subject: [Haskell-cafe] Announcement: Beta of Leksah IDE available In-Reply-To: <49D4AB12.2090100@gmail.com> References: <1238538058.6785.11.camel@jutaro-laptop> <20090401011918.0a3af602@solaris> <22831401.post@talk.nabble.com> <404396ef0904011047n45f36662yf6fc728097c60f28@mail.gmail.com> <22834510.post@talk.nabble.com> <1238666190.25888.1391.camel@localhost> <49D4AB12.2090100@gmail.com> Message-ID: <22846713.post@talk.nabble.com> Hi Simon, you quite nicely describe what leksah is doing already. Try to find find the source code for all installed packages by locating cabal files, parse the module sources via the Ghc API (actually not so much the API), using info from cabal files for this (which is a dark art). It extracts comments and locations. It's quite an ad hoc solution. On my machine it's 97% successful, but its a notorious support theme, because it depends so much on the environment. J?rgen Simon Marlow-7 wrote: > > David Waern wrote: >> 2009/4/2 Duncan Coutts : >>> On Wed, 2009-04-01 at 22:13 +0200, David Waern wrote: >>>> 2009/4/1 jutaro : >>>>> I guess you mean the dialog which should help leksah to find sources >>>>> for installed packages. It needs this so you can go to all the >>>>> definitions >>>>> in the base packages ... This is very handy if it works. Look to the >>>>> manual >>>>> for details. >>>> Maybe could add support to Cabal for installing sources? Should be >>>> very useful to have in general. >>> http://hackage.haskell.org/trac/hackage/ticket/364 >> >> Jutaru, perhaps a nice Hackathon project? :-) > > I think there's some design work to do there. See the discussion on the > GHC ticket: http://hackage.haskell.org/trac/ghc/ticket/2630. > > In short: just keeping the source code around isn't enough. You need some > metadata in order to make sense of the source code - for example, you > can't > feed the source code to the GHC API without knowing which additional flags > need to be passed, and those come from the .cabal file. Also you probably > want to stash the results of the 'cabal configure' step so that you can > get > a view of the source code that is consistent with the version(s?) you > compiled. We need to think about about backwards and > forwards-compatibility of whatever metadata format is used. > > And then you'll need Cabal APIs to extract the metadata. So we need to > think about what APIs make sense, and the best way to do that is to think > about what tool(s) you want to write and use that to drive the API design. > > Perhaps all this is going a bit too far. Maybe we want to just stash the > source code and accept that there are some things that you just can't do > with it. However, I imagine that pretty soon people will want to feed the > source code into the GHC API, and at that point we have to tackle the > build > metadata issues. > > Cheers, > Simon > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/Announcement%3A-Beta-of-Leksah-IDE-available-tp22816032p22846713.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From jefferson.r.heard at gmail.com Thu Apr 2 09:05:15 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Thu Apr 2 08:52:23 2009 Subject: [Haskell-cafe] ANN: Buster 0.99.1, a library for application orchestration that is not FRP Message-ID: <4165d3a70904020605s27d1d92ge9443aecc9485262@mail.gmail.com> Read more about it on its webpage: http://vs.renci.org/jeff/buster Yes, it?s to solve a particular problem. And yes, this is a rough draft of an explanation of how it works. I?ve not even really solidified the vocabulary yet, but I have this module which couches a large, abstract, interactive (both with the user and the system), multicomponent application in terms of a bus, inputs, behaviours, and events. * Time is continuous and infinite. * An event is a static, discrete item associated with a particular time. * The bus is the discrete view of event in time at an instant. * A widget is an IO action that assigns events to a particular time based only upon sampling the outside world (other events and behaviours are irrelevant to it). e.g. a Gtk Button is a widget, a readable network socket is an widget, the mouse is an widget, the keyboard is an widget, a multitouch gesture engine is a widget. * A behaviour is a continuous item ? it exists for the entire program and for all times ? which maps events on the bus to other events on the bus. It is an IO action as well ? where widgets only sample the outside world and are in a sense read only, behaviours encapsulate reading and writing. From Steve.Schuldenzucker at web.de Thu Apr 2 09:26:21 2009 From: Steve.Schuldenzucker at web.de (Steffen Schuldenzucker) Date: Thu Apr 2 09:13:34 2009 Subject: [Haskell-cafe] HXT: desperatedly trying to "concat" Message-ID: <1549432836@web.de> Hi. I've got a problem with the Haskell XML Toolkit (hxt). I want to write a little app that performs REST requests from a certain (rather simple) XML format. A example procedure Call looks like testData defined below. What I'd like to do is to transform this xml tree into a GET variable string using an XmlArrow. The task sounds easy, and it has to be easy, but I've been sitting here for about a day now, staring at my code. It looks like this (the transformation should be done by the arrow "mkGetStr"): -- Rest.hs -- This is also on HPaste: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3210#a3210 {-# LANGUAGE NoMonomorphismRestriction #-} module Rest where import Text.XML.HXT.Arrow import Data.List getParamsA = hasName "param" >>> getChildren >>> isElem >>> (getName &&& (getChildren >>> getText)) >>> arr2 mkGetPair mkMethodStr = ("method=" ++) mkGetPair k v = k ++ "=" ++ v getMethodA = hasName "method" >>> getChildren >>> getText >>> arr mkMethodStr mkGetStr = isElem >>> (getMethodA <+> getParamsA) >>. intercalate "&" -- Try it with: runX (testData >>> mkGetStr) >>= print testData = xread <<< constA ( "my.Method" ++ "" ++ "Foo" ++ "Bar" ++ "" ) -- End of Rest.hs What I get out of it is this (in ghci): *Rest> runX (testData >>> mkGetStr) >>= print "method=my.Methodfoo_arg=Foo&bar_arg=Bar" There is an "&" missing right after "method=my.Method"! Why? I've tried many variants of this and they give me either this or a similar result or multiple results (what I don't want either). I'd be really happy if someone could save my day and help me with this issue. Thanks in advance, Steffen ________________________________________________________________________ Neu bei WEB.DE: Kostenlose maxdome Movie-FLAT! https://register.maxdome.de/xml/order/LpWebDe?ac=OM.MD.MD008K15726T7073a From marlowsd at gmail.com Thu Apr 2 09:27:00 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Thu Apr 2 09:14:12 2009 Subject: [Haskell-cafe] Re: Character I/O In-Reply-To: <6d74b0d20903311342k52f01d46t68ea936bdefd4e82@mail.gmail.com> References: <49D27124.60808@btinternet.com> <7fb8f82f0903311244u7d8156c9pe29967335284acfb@mail.gmail.com> <49D274CA.4090907@btinternet.com> <6d74b0d20903311342k52f01d46t68ea936bdefd4e82@mail.gmail.com> Message-ID: <49D4BD24.5020800@gmail.com> Judah Jacobson wrote: > Not sure if it will help, but you could take a look at what I did in Haskeline: > > http://code.haskell.org/haskeline/System/Console/Haskeline/Backend/Win32.hsc It would be nice to get some of that into the main win32 package... Cheers, Simon From bugfact at gmail.com Thu Apr 2 09:51:28 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Apr 2 09:38:36 2009 Subject: [Haskell-cafe] ANN: Buster 0.99.1, a library for application orchestration that is not FRP In-Reply-To: <4165d3a70904020605s27d1d92ge9443aecc9485262@mail.gmail.com> References: <4165d3a70904020605s27d1d92ge9443aecc9485262@mail.gmail.com> Message-ID: Sounds vaguely like Grapefruit's circuits, but I could be very wrong... The link you provided seems to be broken? On Thu, Apr 2, 2009 at 3:05 PM, Jeff Heard wrote: > Read more about it on its webpage: http://vs.renci.org/jeff/buster > > Yes, it?s to solve a particular problem. And yes, this is a rough > draft of an explanation of how it works. I?ve not even really > solidified the vocabulary yet, but I have this module which couches a > large, abstract, interactive (both with the user and the system), > multicomponent application in terms of a bus, inputs, behaviours, and > events. > > * Time is continuous and infinite. > * An event is a static, discrete item associated with a particular time. > * The bus is the discrete view of event in time at an instant. > * A widget is an IO action that assigns events to a particular > time based only upon sampling the outside world (other events and > behaviours are irrelevant to it). e.g. a Gtk Button is a widget, a > readable network socket is an widget, the mouse is an widget, the > keyboard is an widget, a multitouch gesture engine is a widget. > * A behaviour is a continuous item ? it exists for the entire > program and for all times ? which maps events on the bus to other > events on the bus. It is an IO action as well ? where widgets only > sample the outside world and are in a sense read only, behaviours > encapsulate reading and writing. > _______________________________________________ > 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/20090402/ab9d2dfd/attachment.htm From noteed at gmail.com Thu Apr 2 09:53:55 2009 From: noteed at gmail.com (minh thu) Date: Thu Apr 2 09:41:17 2009 Subject: [Haskell-cafe] ANN: Buster 0.99.1, a library for application orchestration that is not FRP In-Reply-To: References: <4165d3a70904020605s27d1d92ge9443aecc9485262@mail.gmail.com> Message-ID: <40a414c20904020653y73dc3c5fue85558080652cf4a@mail.gmail.com> It's vis instead of vs: http://vis.renci.org/jeff/buster/ 2009/4/2 Peter Verswyvelen : > Sounds vaguely like Grapefruit's circuits, but I could be very wrong... > The link you provided seems to be broken? > On Thu, Apr 2, 2009 at 3:05 PM, Jeff Heard > wrote: >> >> Read more about it on its webpage: http://vs.renci.org/jeff/buster >> >> Yes, it?s to solve a particular problem. And yes, this is a rough >> draft of an explanation of how it works. I?ve not even really >> solidified the vocabulary yet, but I have this module which couches a >> large, abstract, interactive (both with the user and the system), >> multicomponent application in terms of a bus, inputs, behaviours, and >> events. >> >> * Time is continuous and infinite. >> * An event is a static, discrete item associated with a particular >> time. >> * The bus is the discrete view of event in time at an instant. >> * A widget is an IO action that assigns events to a particular >> time based only upon sampling the outside world (other events and >> behaviours are irrelevant to it). e.g. a Gtk Button is a widget, a >> readable network socket is an widget, the mouse is an widget, the >> keyboard is an widget, a multitouch gesture engine is a widget. >> * A behaviour is a continuous item ? it exists for the entire >> program and for all times ? which maps events on the bus to other >> events on the bus. It is an IO action as well ? where widgets only >> sample the outside world and are in a sense read only, behaviours >> encapsulate reading and writing. >> _______________________________________________ >> 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 jefferson.r.heard at gmail.com Thu Apr 2 10:05:14 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Thu Apr 2 09:52:22 2009 Subject: [Haskell-cafe] ANN: Buster 0.99.1, a library for application orchestration that is not FRP In-Reply-To: <40a414c20904020653y73dc3c5fue85558080652cf4a@mail.gmail.com> References: <4165d3a70904020605s27d1d92ge9443aecc9485262@mail.gmail.com> <40a414c20904020653y73dc3c5fue85558080652cf4a@mail.gmail.com> Message-ID: <4165d3a70904020705y4f420a8dx839ef3638d1e916f@mail.gmail.com> Yes,sorry. vis, not vs. http://vis.renci.org/buster It is a bit like grapefruit's circuits, but where Grapefruit circuits describe the flow of events from place to place, Buster never does. Events exist for all behaviours, to be selected by name, group, or source. The other major difference is the |~| or "beside" operator, which describes concurrent application of behaviours. A last but somewhat minor thing is that the Event type is fairly general, allowing for multiple data to be attached to a single event and this data to be of many of the standard types (Int, String, Double, ByteString, etc) as well as a user-defined type. Of course, such an event type could be defined for other FRP frameworks as well. -- Jeff On Thu, Apr 2, 2009 at 9:53 AM, minh thu wrote: > It's vis instead of vs: > http://vis.renci.org/jeff/buster/ > > 2009/4/2 Peter Verswyvelen : >> Sounds vaguely like Grapefruit's circuits, but I could be very wrong... >> The link you provided seems to be broken? >> On Thu, Apr 2, 2009 at 3:05 PM, Jeff Heard >> wrote: >>> >>> Read more about it on its webpage: http://vs.renci.org/jeff/buster >>> >>> Yes, it?s to solve a particular problem. ?And yes, this is a rough >>> draft of an explanation of how it works. ?I?ve not even really >>> solidified the vocabulary yet, but I have this module which couches a >>> large, abstract, interactive (both with the user and the system), >>> multicomponent application in terms of a bus, inputs, behaviours, and >>> events. >>> >>> ? ?* Time is continuous and infinite. >>> ? ?* An event is a static, discrete item associated with a particular >>> time. >>> ? ?* The bus is the discrete view of event in time at an instant. >>> ? ?* A widget is an IO action that assigns events to a particular >>> time based only upon sampling the outside world (other events and >>> behaviours are irrelevant to it). ?e.g. a Gtk Button is a widget, a >>> readable network socket is an widget, the mouse is an widget, the >>> keyboard is an widget, a multitouch gesture engine is a widget. >>> ? ?* A behaviour is a continuous item ? it exists for the entire >>> program and for all times ? which maps events on the bus to other >>> events on the bus. ?It is an IO action as well ? where widgets only >>> sample the outside world and are in a sense read only, behaviours >>> encapsulate reading and writing. >>> _______________________________________________ >>> 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 jefferson.r.heard at gmail.com Thu Apr 2 10:06:19 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Thu Apr 2 09:53:27 2009 Subject: [Haskell-cafe] ANN: Buster 0.99.1, a library for application orchestration that is not FRP In-Reply-To: <4165d3a70904020705y4f420a8dx839ef3638d1e916f@mail.gmail.com> References: <4165d3a70904020605s27d1d92ge9443aecc9485262@mail.gmail.com> <40a414c20904020653y73dc3c5fue85558080652cf4a@mail.gmail.com> <4165d3a70904020705y4f420a8dx839ef3638d1e916f@mail.gmail.com> Message-ID: <4165d3a70904020706p403492c0i56a400cff2daf29d@mail.gmail.com> Check links... god. http://vis.renci.org/jeff/buster (can you tell I was up till 3am last night?) On Thu, Apr 2, 2009 at 10:05 AM, Jeff Heard wrote: > Yes,sorry. ?vis, not vs. http://vis.renci.org/buster > > It is a bit like grapefruit's circuits, but where Grapefruit circuits > describe the flow of events from place to place, Buster never does. > Events exist for all behaviours, to be selected by name, group, or > source. ?The other major difference is the |~| or "beside" operator, > which describes concurrent application of behaviours. > > A last but somewhat minor thing is that the Event type is fairly > general, allowing for multiple data to be attached to a single event > and this data to be of many of the standard types (Int, String, > Double, ByteString, etc) as well as a user-defined type. ?Of course, > such an event type could be defined for other FRP frameworks as well. > > -- Jeff > > On Thu, Apr 2, 2009 at 9:53 AM, minh thu wrote: >> It's vis instead of vs: >> http://vis.renci.org/jeff/buster/ >> >> 2009/4/2 Peter Verswyvelen : >>> Sounds vaguely like Grapefruit's circuits, but I could be very wrong... >>> The link you provided seems to be broken? >>> On Thu, Apr 2, 2009 at 3:05 PM, Jeff Heard >>> wrote: >>>> >>>> Read more about it on its webpage: http://vs.renci.org/jeff/buster >>>> >>>> Yes, it?s to solve a particular problem. ?And yes, this is a rough >>>> draft of an explanation of how it works. ?I?ve not even really >>>> solidified the vocabulary yet, but I have this module which couches a >>>> large, abstract, interactive (both with the user and the system), >>>> multicomponent application in terms of a bus, inputs, behaviours, and >>>> events. >>>> >>>> ? ?* Time is continuous and infinite. >>>> ? ?* An event is a static, discrete item associated with a particular >>>> time. >>>> ? ?* The bus is the discrete view of event in time at an instant. >>>> ? ?* A widget is an IO action that assigns events to a particular >>>> time based only upon sampling the outside world (other events and >>>> behaviours are irrelevant to it). ?e.g. a Gtk Button is a widget, a >>>> readable network socket is an widget, the mouse is an widget, the >>>> keyboard is an widget, a multitouch gesture engine is a widget. >>>> ? ?* A behaviour is a continuous item ? it exists for the entire >>>> program and for all times ? which maps events on the bus to other >>>> events on the bus. ?It is an IO action as well ? where widgets only >>>> sample the outside world and are in a sense read only, behaviours >>>> encapsulate reading and writing. >>>> _______________________________________________ >>>> 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 noteed at gmail.com Thu Apr 2 10:12:21 2009 From: noteed at gmail.com (minh thu) Date: Thu Apr 2 09:59:29 2009 Subject: [Haskell-cafe] ANN: Buster 0.99.1, a library for application orchestration that is not FRP In-Reply-To: <4165d3a70904020706p403492c0i56a400cff2daf29d@mail.gmail.com> References: <4165d3a70904020605s27d1d92ge9443aecc9485262@mail.gmail.com> <40a414c20904020653y73dc3c5fue85558080652cf4a@mail.gmail.com> <4165d3a70904020705y4f420a8dx839ef3638d1e916f@mail.gmail.com> <4165d3a70904020706p403492c0i56a400cff2daf29d@mail.gmail.com> Message-ID: <40a414c20904020712g6334e302w25524d82b54ebe04@mail.gmail.com> Funny ... I never write an url in a mail : I type it in firefox (so I actually check it) then copy/paste it. 2009/4/2 Jeff Heard : > Check links... god. http://vis.renci.org/jeff/buster (can you tell > I was up till 3am last night?) > > On Thu, Apr 2, 2009 at 10:05 AM, Jeff Heard wrote: >> Yes,sorry. vis, not vs. http://vis.renci.org/buster >> >> It is a bit like grapefruit's circuits, but where Grapefruit circuits >> describe the flow of events from place to place, Buster never does. >> Events exist for all behaviours, to be selected by name, group, or >> source. The other major difference is the |~| or "beside" operator, >> which describes concurrent application of behaviours. >> >> A last but somewhat minor thing is that the Event type is fairly >> general, allowing for multiple data to be attached to a single event >> and this data to be of many of the standard types (Int, String, >> Double, ByteString, etc) as well as a user-defined type. Of course, >> such an event type could be defined for other FRP frameworks as well. >> >> -- Jeff >> >> On Thu, Apr 2, 2009 at 9:53 AM, minh thu wrote: >>> It's vis instead of vs: >>> http://vis.renci.org/jeff/buster/ >>> >>> 2009/4/2 Peter Verswyvelen : >>>> Sounds vaguely like Grapefruit's circuits, but I could be very wrong... >>>> The link you provided seems to be broken? >>>> On Thu, Apr 2, 2009 at 3:05 PM, Jeff Heard >>>> wrote: >>>>> >>>>> Read more about it on its webpage: http://vs.renci.org/jeff/buster >>>>> >>>>> Yes, it?s to solve a particular problem. And yes, this is a rough >>>>> draft of an explanation of how it works. I?ve not even really >>>>> solidified the vocabulary yet, but I have this module which couches a >>>>> large, abstract, interactive (both with the user and the system), >>>>> multicomponent application in terms of a bus, inputs, behaviours, and >>>>> events. >>>>> >>>>> * Time is continuous and infinite. >>>>> * An event is a static, discrete item associated with a particular >>>>> time. >>>>> * The bus is the discrete view of event in time at an instant. >>>>> * A widget is an IO action that assigns events to a particular >>>>> time based only upon sampling the outside world (other events and >>>>> behaviours are irrelevant to it). e.g. a Gtk Button is a widget, a >>>>> readable network socket is an widget, the mouse is an widget, the >>>>> keyboard is an widget, a multitouch gesture engine is a widget. >>>>> * A behaviour is a continuous item ? it exists for the entire >>>>> program and for all times ? which maps events on the bus to other >>>>> events on the bus. It is an IO action as well ? where widgets only >>>>> sample the outside world and are in a sense read only, behaviours >>>>> encapsulate reading and writing. >>>>> _______________________________________________ >>>>> 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 bugfact at gmail.com Thu Apr 2 10:15:14 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Apr 2 10:02:23 2009 Subject: [Haskell-cafe] ANN: Buster 0.99.1, a library for application orchestration that is not FRP In-Reply-To: <4165d3a70904020706p403492c0i56a400cff2daf29d@mail.gmail.com> References: <4165d3a70904020605s27d1d92ge9443aecc9485262@mail.gmail.com> <40a414c20904020653y73dc3c5fue85558080652cf4a@mail.gmail.com> <4165d3a70904020705y4f420a8dx839ef3638d1e916f@mail.gmail.com> <4165d3a70904020706p403492c0i56a400cff2daf29d@mail.gmail.com> Message-ID: It seems to be a trend to use more and more IO in new FRP approaches. Grapefruit's circuits encapsulate side effects, as does your approach This is a big departure from the "pure" libs like Fran, Yampa, Reactive, ... I wander if this is because of some fundamental problem with functional programming when it comes to FRP? Some people claim that IO is also pure, and I tend to agree if we can capture the state of the real world and rewind to it somehow :) On Thu, Apr 2, 2009 at 4:06 PM, Jeff Heard wrote: > Check links... god. http://vis.renci.org/jeff/buster (can you tell > I was up till 3am last night?) > > On Thu, Apr 2, 2009 at 10:05 AM, Jeff Heard > wrote: > > Yes,sorry. vis, not vs. http://vis.renci.org/buster > > > > It is a bit like grapefruit's circuits, but where Grapefruit circuits > > describe the flow of events from place to place, Buster never does. > > Events exist for all behaviours, to be selected by name, group, or > > source. The other major difference is the |~| or "beside" operator, > > which describes concurrent application of behaviours. > > > > A last but somewhat minor thing is that the Event type is fairly > > general, allowing for multiple data to be attached to a single event > > and this data to be of many of the standard types (Int, String, > > Double, ByteString, etc) as well as a user-defined type. Of course, > > such an event type could be defined for other FRP frameworks as well. > > > > -- Jeff > > > > On Thu, Apr 2, 2009 at 9:53 AM, minh thu wrote: > >> It's vis instead of vs: > >> http://vis.renci.org/jeff/buster/ > >> > >> 2009/4/2 Peter Verswyvelen : > >>> Sounds vaguely like Grapefruit's circuits, but I could be very wrong... > >>> The link you provided seems to be broken? > >>> On Thu, Apr 2, 2009 at 3:05 PM, Jeff Heard < > jefferson.r.heard@gmail.com> > >>> wrote: > >>>> > >>>> Read more about it on its webpage: http://vs.renci.org/jeff/buster > >>>> > >>>> Yes, it?s to solve a particular problem. And yes, this is a rough > >>>> draft of an explanation of how it works. I?ve not even really > >>>> solidified the vocabulary yet, but I have this module which couches a > >>>> large, abstract, interactive (both with the user and the system), > >>>> multicomponent application in terms of a bus, inputs, behaviours, and > >>>> events. > >>>> > >>>> * Time is continuous and infinite. > >>>> * An event is a static, discrete item associated with a particular > >>>> time. > >>>> * The bus is the discrete view of event in time at an instant. > >>>> * A widget is an IO action that assigns events to a particular > >>>> time based only upon sampling the outside world (other events and > >>>> behaviours are irrelevant to it). e.g. a Gtk Button is a widget, a > >>>> readable network socket is an widget, the mouse is an widget, the > >>>> keyboard is an widget, a multitouch gesture engine is a widget. > >>>> * A behaviour is a continuous item ? it exists for the entire > >>>> program and for all times ? which maps events on the bus to other > >>>> events on the bus. It is an IO action as well ? where widgets only > >>>> sample the outside world and are in a sense read only, behaviours > >>>> encapsulate reading and writing. > >>>> _______________________________________________ > >>>> 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/20090402/35940470/attachment.htm From jules at jellybean.co.uk Thu Apr 2 11:05:32 2009 From: jules at jellybean.co.uk (Jules Bean) Date: Thu Apr 2 10:52:39 2009 Subject: [Haskell-cafe] ANN: Buster 0.99.1, a library for application orchestration that is not FRP In-Reply-To: <4165d3a70904020705y4f420a8dx839ef3638d1e916f@mail.gmail.com> References: <4165d3a70904020605s27d1d92ge9443aecc9485262@mail.gmail.com> <40a414c20904020653y73dc3c5fue85558080652cf4a@mail.gmail.com> <4165d3a70904020705y4f420a8dx839ef3638d1e916f@mail.gmail.com> Message-ID: <49D4D43C.4030500@jellybean.co.uk> Jeff Heard wrote: > A last but somewhat minor thing is that the Event type is fairly > general, allowing for multiple data to be attached to a single event > and this data to be of many of the standard types (Int, String, > Double, ByteString, etc) as well as a user-defined type. Of course, > such an event type could be defined for other FRP frameworks as well. That sounds the opposite of general. That sounds specific. (Int, String, Double, ByteString as well as a user-defined type....). Can you explain the reason for the EDouble, EString (etc.) alternatives as opposed to making the event simply (parametrically) polymorphic in "a" ? Jules From jefferson.r.heard at gmail.com Thu Apr 2 11:15:16 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Thu Apr 2 11:02:23 2009 Subject: [Haskell-cafe] ANN: Buster 0.99.1, a library for application orchestration that is not FRP In-Reply-To: <49D4D43C.4030500@jellybean.co.uk> References: <4165d3a70904020605s27d1d92ge9443aecc9485262@mail.gmail.com> <40a414c20904020653y73dc3c5fue85558080652cf4a@mail.gmail.com> <4165d3a70904020705y4f420a8dx839ef3638d1e916f@mail.gmail.com> <49D4D43C.4030500@jellybean.co.uk> Message-ID: <4165d3a70904020815h4629e0ffq114cee5fbbac422a@mail.gmail.com> It is parametrically polymorphic in a. And no, it's an arbitrary decision, BUT... it allows me and other users to define generally useful behaviours and widgets to package with the library using the basic types without locking down 'a'. The EventData type looks like this: data Event a { ..., edata :: EData a, ... } data EData a = EChar Char | EString String | EStringL [String] | EByteString ByteString | EByteStringL [ByteString] | EInt Int | EIntL [Int] | EDouble Double | EDoubleL [Double] | EBool Bool | EBoolL [Bool] | EOther a | EOtherL [a] Now, given that arbitrary decision, I'd be willing to modify Event so that it is parametric on 'a' without EData and include EData as an "example" binding for 'a' if the user chooses to use it. However, I foresee most behaviours and widgets that are "generally useful" to be dependent on this type, which is why I made it a basic part of Event. -- Jeff On Thu, Apr 2, 2009 at 11:05 AM, Jules Bean wrote: > Jeff Heard wrote: >> >> A last but somewhat minor thing is that the Event type is fairly >> general, allowing for multiple data to be attached to a single event >> and this data to be of many of the standard types (Int, String, >> Double, ByteString, etc) as well as a user-defined type. ?Of course, >> such an event type could be defined for other FRP frameworks as well. > > That sounds the opposite of general. That sounds specific. (Int, String, > Double, ByteString as well as a user-defined type....). > > Can you explain the reason for the EDouble, EString (etc.) alternatives as > opposed to making the event simply (parametrically) polymorphic in "a" ? > > Jules > From jules at jellybean.co.uk Thu Apr 2 11:22:37 2009 From: jules at jellybean.co.uk (Jules Bean) Date: Thu Apr 2 11:09:45 2009 Subject: [Haskell-cafe] ANN: Buster 0.99.1, a library for application orchestration that is not FRP In-Reply-To: <4165d3a70904020815h4629e0ffq114cee5fbbac422a@mail.gmail.com> References: <4165d3a70904020605s27d1d92ge9443aecc9485262@mail.gmail.com> <40a414c20904020653y73dc3c5fue85558080652cf4a@mail.gmail.com> <4165d3a70904020705y4f420a8dx839ef3638d1e916f@mail.gmail.com> <49D4D43C.4030500@jellybean.co.uk> <4165d3a70904020815h4629e0ffq114cee5fbbac422a@mail.gmail.com> Message-ID: <49D4D83D.3080006@jellybean.co.uk> Jeff Heard wrote: > It is parametrically polymorphic in a. And no, it's an arbitrary > decision, BUT... it allows me and other users to define generally > useful behaviours and widgets to package with the library using the > basic types without locking down 'a'. The EventData type looks like > this: > > data Event a { ..., edata :: EData a, ... } > > data EData a = EChar Char > | EString String > | EStringL [String] > | EByteString ByteString > | EByteStringL [ByteString] > | EInt Int > | EIntL [Int] > | EDouble Double > | EDoubleL [Double] > | EBool Bool > | EBoolL [Bool] > | EOther a > | EOtherL [a] Maybe I wasn't clear, and probably I'm being dense. I understand what you've done - I looked at the type declarations before commenting - but I don't understand why. Why is it useful to be able to use basic types without locking down 'a'? Why is it useful to have a value of type "Event FooBar" which, in apparent defiance of the FooBar parameter, actually contains a value of type Double? Jules From gleb.alexeev at gmail.com Thu Apr 2 11:32:28 2009 From: gleb.alexeev at gmail.com (Gleb Alexeyev) Date: Thu Apr 2 11:19:15 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: vacuum-cairo: a cairo frontend to vacuum for live Haskell data visualization In-Reply-To: References: <20090331054038.GA5648@whirlpool.galois.com> <20090401201353.GJ12860@whirlpool.galois.com> Message-ID: Daryoush Mehrtash wrote: > When I try to install the hubigraph I get the following error: > > skip > > Network/XmlRpc/Client.hs:113:23: > Not in scope: type constructor or class `ConnError' > > Network/XmlRpc/Client.hs:113:51: > Not in scope: type constructor or class `ConnError' > cabal: Error: some packages failed to install: > HUBIGraph-0.1 depends on haxr-3000.1.1.2 which failed to install. > haxr-3000.1.1.2 failed during the building phase. The exception was: > exit: ExitFailure 1 > > Any ideas? I've just run into this problem as well. It seems that haxr doesn't build with HTTP-4000, though its cabal file doesn't specify the upper bound. From jefferson.r.heard at gmail.com Thu Apr 2 11:53:00 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Thu Apr 2 11:40:07 2009 Subject: [Haskell-cafe] ANN: Buster 0.99.1, a library for application orchestration that is not FRP In-Reply-To: <49D4D83D.3080006@jellybean.co.uk> References: <4165d3a70904020605s27d1d92ge9443aecc9485262@mail.gmail.com> <40a414c20904020653y73dc3c5fue85558080652cf4a@mail.gmail.com> <4165d3a70904020705y4f420a8dx839ef3638d1e916f@mail.gmail.com> <49D4D43C.4030500@jellybean.co.uk> <4165d3a70904020815h4629e0ffq114cee5fbbac422a@mail.gmail.com> <49D4D83D.3080006@jellybean.co.uk> Message-ID: <4165d3a70904020853y37d35ff7m9088c7ca00309362@mail.gmail.com> On Thu, Apr 2, 2009 at 11:22 AM, Jules Bean wrote: > > Maybe I wasn't clear, and probably I'm being dense. I understand what you've > done - I looked at the type declarations before commenting - but I don't > understand why. > > Why is it useful to be able to use basic types without locking down 'a'? > > Why is it useful to have a value of type "Event FooBar" which, in apparent > defiance of the FooBar parameter, actually contains a value of type Double? > > Jules > I'm assuming everyone won't want to start from scratch in creating all their widgets and behaviours. A bus contains only events of type 'a', therefore all widgets and behaviours on that bus must use events of type 'a'. It is possible to run multiple buses at the same time in the same program, and even possible to have them communicate between each other (forkIO-ing the buses and attaching some arbitrary behaviour that takes events from bus0, translates their types and then puts them on bus1), and so that way you could use multiple types, but I don't see a problem with a user having to read the documentation and understand that an Event of type a contains data that is a variant including type a. How is it useful? Consider the following widgets: commandLineArgsWidget :: Widget a commandLineArgsWidget = getArgs >>= \args -> produce' "Environment" "CommandLineArgsWidget" "argv" Persistent [EStringL args] environmentWidget :: Widget a environmentWidget b = getEnvironment >>= mapM_ (\(k,v) -> produce' "Environment" "EnvironmentWidget" k Persistent [EString v] b) progNameWidget :: Widget a progNameWidget b = getProgName >>= \v -> produce' "Environment" "ProgramNameWidget" "ProgramName" Persistent [EString v] b As the library stands right now, I can take these widgets and put them in a module and include them as part of the Buster library, and they can be used pretty arbitrarily. I can see being more semantically pure and changing Event a to contain data of type a instead of data of type [EData a], in which case the type signatures would look like this: progNameWidget :: WIdget [EData a] and so forth to be compatible with Bus [EData a], but I think that in the end so many widgets will reuse the EData type that it's just as well to make it part of the Event rather than force the user to be explicit about it every time. But if I'm generally disagreed with about this, I can change it -- I'm pretty neutral about it, to be honest. -- Jeff From nadine.and.henry at pobox.com Thu Apr 2 11:59:30 2009 From: nadine.and.henry at pobox.com (Henry Laxen) Date: Thu Apr 2 11:46:52 2009 Subject: [Haskell-cafe] Problem with prepose.lhs and ghc6.10.1 Message-ID: Dear Group, I'm trying to read the paper: "Functional Pearl: Implicit Configurations" at http://www.cs.rutgers.edu/~ccshan/prepose/ and when running the code in prepose.lhs I get: ../haskell/prepose.lhs:707:0: Parse error in pattern which is pointing at: normalize a :: M s a = M (mod a (modulus (undefined :: s))) The paper says it uses lexically scoped type variables. I tried reading about them at: http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#scoped-type-variables so I added -XScopedTypeVariables to my OPTIONS but I still get the same error message. I would really like to play with the code in the paper, but I'm stuck at this point. Any pointers would be appreciated. Best wishes, Henry Laxen From wasserman.louis at gmail.com Thu Apr 2 11:59:39 2009 From: wasserman.louis at gmail.com (Louis Wasserman) Date: Thu Apr 2 11:47:03 2009 Subject: [Haskell-cafe] Type families and kind signatures Message-ID: The following module does not compile, and I can't figure out why: {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE KindSignatures #-} module Foo where import Control.Monad import Data.Maybe class Key k where type Map k :: * -> * empty :: Map k v look :: k -> Map k v -> Maybe v update :: k -> (Maybe v -> Maybe v) -> Map k v -> Map k v instance (Key k1, Key k2) => Key (k1, k2) where type Map (k1, k2) v = Map k1 (Map k2 v) empty = empty update (k1, k2) f = update k1 (update k2 f . fromMaybe empty) look (k1, k2) = look k1 >=> look k2 The compile fails with Foo.hs:16:1: Number of parameters must match family declaration; expected 1 In the type synonym instance declaration for `Map' In the instance declaration for `Key (k1, k2)' Is this a bug with type synonym families? Is there something silly I'm missing? Louis Wasserman wasserman.louis@gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090402/fff3cc56/attachment.htm From lrpalmer at gmail.com Thu Apr 2 12:05:13 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Apr 2 11:52:21 2009 Subject: [Haskell-cafe] Type families and kind signatures In-Reply-To: References: Message-ID: <7ca3f0160904020905q2f6c7e3aqd0410db60069443b@mail.gmail.com> 2009/4/2 Louis Wasserman > The following module does not compile, and I can't figure out why: > {-# LANGUAGE TypeFamilies #-} > {-# LANGUAGE KindSignatures #-} > > module Foo where > > import Control.Monad > import Data.Maybe > > class Key k where > type Map k :: * -> * > empty :: Map k v > look :: k -> Map k v -> Maybe v > update :: k -> (Maybe v -> Maybe v) -> Map k v -> Map k v > > instance (Key k1, Key k2) => Key (k1, k2) where > type Map (k1, k2) v = Map k1 (Map k2 v) > The arity of the instance has to be *exactly* the same as is declared. So the v is one too many parameters. That does make your life a little more difficult (but points to an abstraction you may not have seen :-). I would resolve this as: type Map (k1,k2) = Map k1 `O` Map k2 Where O is functor composition from TypeCompose on hackage. > empty = empty > update (k1, k2) f = update k1 (update k2 f . fromMaybe empty) > look (k1, k2) = look k1 >=> look k2 > > The compile fails with > Foo.hs:16:1: > Number of parameters must match family declaration; expected 1 > In the type synonym instance declaration for `Map' > In the instance declaration for `Key (k1, k2)' > > Is this a bug with type synonym families? Is there something silly I'm > missing? > > Louis Wasserman > wasserman.louis@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/20090402/0954b72b/attachment-0001.htm From wasserman.louis at gmail.com Thu Apr 2 12:12:36 2009 From: wasserman.louis at gmail.com (Louis Wasserman) Date: Thu Apr 2 11:59:57 2009 Subject: [Haskell-cafe] Type families and kind signatures In-Reply-To: <7ca3f0160904020905q2f6c7e3aqd0410db60069443b@mail.gmail.com> References: <7ca3f0160904020905q2f6c7e3aqd0410db60069443b@mail.gmail.com> Message-ID: Mkay. One more quick thing -- the wiki demonstrates a place where the original attempt worked, with a data family instead. (That is, replacing 'type' with 'data' and adjusting the instance makes this program compile immediately.) a) Is there a type-hackery reason this is different from data families? b) Is there a reason this isn't made a lot clearer in the documentation? GHC's docs say that higher-order type families can be declared with kind signatures, but never gives any examples -- which would make it a lot clearer that the below program doesn't work. Louis Wasserman wasserman.louis@gmail.com On Thu, Apr 2, 2009 at 12:05 PM, Luke Palmer wrote: > 2009/4/2 Louis Wasserman > >> The following module does not compile, and I can't figure out why: >> {-# LANGUAGE TypeFamilies #-} >> {-# LANGUAGE KindSignatures #-} >> >> module Foo where >> >> import Control.Monad >> import Data.Maybe >> >> class Key k where >> type Map k :: * -> * >> empty :: Map k v >> look :: k -> Map k v -> Maybe v >> update :: k -> (Maybe v -> Maybe v) -> Map k v -> Map k v >> >> instance (Key k1, Key k2) => Key (k1, k2) where >> type Map (k1, k2) v = Map k1 (Map k2 v) >> > > The arity of the instance has to be *exactly* the same as is declared. So > the v is one too many parameters. That does make your life a little more > difficult (but points to an abstraction you may not have seen :-). > > I would resolve this as: > > type Map (k1,k2) = Map k1 `O` Map k2 > > Where O is functor composition from TypeCompose on hackage. > > > >> empty = empty >> update (k1, k2) f = update k1 (update k2 f . fromMaybe empty) >> look (k1, k2) = look k1 >=> look k2 >> >> The compile fails with >> Foo.hs:16:1: >> Number of parameters must match family declaration; expected 1 >> In the type synonym instance declaration for `Map' >> In the instance declaration for `Key (k1, k2)' >> >> Is this a bug with type synonym families? Is there something silly I'm >> missing? >> >> Louis Wasserman >> wasserman.louis@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/20090402/7990fc4a/attachment.htm From jefferson.r.heard at gmail.com Thu Apr 2 12:33:36 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Thu Apr 2 12:20:43 2009 Subject: [Haskell-cafe] ANN: Buster 0.99.1, a library for application orchestration that is not FRP In-Reply-To: <4165d3a70904020853y37d35ff7m9088c7ca00309362@mail.gmail.com> References: <4165d3a70904020605s27d1d92ge9443aecc9485262@mail.gmail.com> <40a414c20904020653y73dc3c5fue85558080652cf4a@mail.gmail.com> <4165d3a70904020705y4f420a8dx839ef3638d1e916f@mail.gmail.com> <49D4D43C.4030500@jellybean.co.uk> <4165d3a70904020815h4629e0ffq114cee5fbbac422a@mail.gmail.com> <49D4D83D.3080006@jellybean.co.uk> <4165d3a70904020853y37d35ff7m9088c7ca00309362@mail.gmail.com> Message-ID: <4165d3a70904020933t34a14ed3n9f3a72a6c4e2bacb@mail.gmail.com> Alright, updated it to extract EData from the Event type and make it separate. Basically, now all type signatures Event a Widget a Behaviour a should read Event [EData a] Widget [EData a] Behaviour [EData a] for backward compatibility. On Thu, Apr 2, 2009 at 11:53 AM, Jeff Heard wrote: > On Thu, Apr 2, 2009 at 11:22 AM, Jules Bean wrote: >> >> Maybe I wasn't clear, and probably I'm being dense. I understand what you've >> done - I looked at the type declarations before commenting - but I don't >> understand why. >> >> Why is it useful to be able to use basic types without locking down 'a'? >> >> Why is it useful to have a value of type "Event FooBar" which, in apparent >> defiance of the FooBar parameter, actually contains a value of type Double? >> >> Jules >> > > I'm assuming everyone won't want to start from scratch in creating all > their widgets and behaviours. ?A bus contains only events of type 'a', > therefore all widgets and behaviours on that bus must use events of > type 'a'. ?It is possible to run multiple buses at the same time in > the same program, and even possible to have them communicate between > each other (forkIO-ing the buses and attaching some arbitrary > behaviour that takes events from bus0, translates their types and then > puts them on bus1), and so that way you could use multiple types, but > I don't see a problem with a user having to read the documentation and > understand that an Event of type a contains data that is a variant > including type a. ?How is it useful? ?Consider the following widgets: > > commandLineArgsWidget :: Widget a > commandLineArgsWidget = getArgs >>= > ? ?\args -> produce' "Environment" > ? ? ? ? ? ? ? ? ? ? ?"CommandLineArgsWidget" > ? ? ? ? ? ? ? ? ? ? ?"argv" > ? ? ? ? ? ? ? ? ? ? ?Persistent > ? ? ? ? ? ? ? ? ? ? ?[EStringL args] > > environmentWidget :: Widget a > environmentWidget b = getEnvironment >>= > ? ?mapM_ (\(k,v) -> produce' "Environment" "EnvironmentWidget" k > Persistent [EString v] b) > > progNameWidget :: Widget a > progNameWidget b = getProgName >>= > ? ?\v -> produce' "Environment" "ProgramNameWidget" "ProgramName" > Persistent [EString v] b > > As the library stands right now, I can take these widgets and put them > in a module and include them as part of the Buster library, and they > can be used pretty arbitrarily. ?I can see being more semantically > pure and changing Event a to contain data of type a instead of data of > type [EData a], in which case the type signatures would look like > this: > > progNameWidget :: WIdget [EData a] > > and so forth to be compatible with Bus [EData a], but I think that in > the end so many widgets will reuse the EData type that it's just as > well to make it part of the Event rather than force the user to be > explicit about it every time. ?But if I'm generally disagreed with > about this, I can change it -- I'm pretty neutral about it, to be > honest. > > -- Jeff > From andy at adradh.org.uk Thu Apr 2 12:40:01 2009 From: andy at adradh.org.uk (andy morris) Date: Thu Apr 2 12:27:23 2009 Subject: [Haskell-cafe] Problem with prepose.lhs and ghc6.10.1 In-Reply-To: References: Message-ID: 2009/4/2 Henry Laxen : > Dear Group, > > I'm trying to read the paper: > "Functional Pearl: Implicit Configurations" > at http://www.cs.rutgers.edu/~ccshan/prepose/ > and when running the code in prepose.lhs I get: > ../haskell/prepose.lhs:707:0: Parse error in pattern > which is pointing at: > normalize a :: M s a = M (mod a (modulus (undefined :: s))) > > The paper says it uses lexically scoped type variables. ?I tried reading about > them at: > http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#scoped-type-variables > > so I added -XScopedTypeVariables to my OPTIONS but I still get the same error > message. ?I would really like to play with the code in the paper, but I'm stuck > at this point. ?Any pointers would be appreciated. > Best wishes, > Henry Laxen It probably needs brackets: normalize (a :: M s a) = ... From felipe.lessa at gmail.com Thu Apr 2 12:58:37 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Thu Apr 2 12:46:01 2009 Subject: [Haskell-cafe] ANN: Buster 0.99.1, a library for application orchestration that is not FRP In-Reply-To: <4165d3a70904020853y37d35ff7m9088c7ca00309362@mail.gmail.com> References: <4165d3a70904020605s27d1d92ge9443aecc9485262@mail.gmail.com> <40a414c20904020653y73dc3c5fue85558080652cf4a@mail.gmail.com> <4165d3a70904020705y4f420a8dx839ef3638d1e916f@mail.gmail.com> <49D4D43C.4030500@jellybean.co.uk> <4165d3a70904020815h4629e0ffq114cee5fbbac422a@mail.gmail.com> <49D4D83D.3080006@jellybean.co.uk> <4165d3a70904020853y37d35ff7m9088c7ca00309362@mail.gmail.com> Message-ID: <20090402165837.GA27501@kira.casa> On Thu, Apr 02, 2009 at 11:53:00AM -0400, Jeff Heard wrote: > and so forth to be compatible with Bus [EData a], but I think that in > the end so many widgets will reuse the EData type that it's just as > well to make it part of the Event rather than force the user to be > explicit about it every time. But if I'm generally disagreed with > about this, I can change it -- I'm pretty neutral about it, to be > honest. Why not trying something like what was done with the new extensible extensions, using typeable existencials and casts? That way you could put any value you want and they would all be first class citizens. Another random idea: a phantom type could be used to be explicit about the type of event something produces or expects, something on the lines of > data EData a = forall b. Typeable b => EData b > deriving (Typeable) > > -- | Extract the data. > extract :: EData a -> a > extract (EData d) = case cast d of > Just x -> x > Nothing -> error "extract: phantom didn't match" > > -- | Carefull extract the data, returns @Nothing@ if the phantom > -- type doesn't match. > extractM :: EData a -> Maybe a > extractM (EData d) = cast d > > -- | Extracts any type of data from a polymorphic 'EData'. > extractAny :: (forall a. EData a) -> Maybe b > extractAny (EData d) = cast d > -- Is the forall above useful to prevent mistakes or not? > > -- | Unsafely casts the phantom type to another one. > unsafeCastData :: EData a -> EData b > unsafeCastData (EData d) = EData d Your examples would become something like > commandLineArgsWidget :: Widget [String] > commandLineArgsWidget = getArgs >>= > \args -> produce' "Environment" > "CommandLineArgsWidget" > "argv" > Persistent > args > > environmentWidget :: Widget String > environmentWidget b = getEnvironment >>= > mapM_ (\(k,v) -> produce' "Environment" "EnvironmentWidget" k > Persistent v b) > > progNameWidget :: Widget String > progNameWidget b = getProgName >>= > \v -> produce' "Environment" "ProgramNameWidget" "ProgramName" > Persistent v b where I'm assuming that you could construct the EData inside produce' as now that's the only constructor available. The bus could then be polymorphic on the phantom type. Why use phantom types at all, then? It at least serves for documentation purposes. Well, it is a random idea after all :). -- Felipe. From gleb.alexeev at gmail.com Thu Apr 2 13:01:26 2009 From: gleb.alexeev at gmail.com (Gleb Alexeyev) Date: Thu Apr 2 12:48:07 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: vacuum-cairo: a cairo frontend to vacuum for live Haskell data visualization In-Reply-To: <20090401171530.GB12860@whirlpool.galois.com> References: <20090331054038.GA5648@whirlpool.galois.com> <1bc51a990904010954m1253c08eld5a5e14882f31449@mail.gmail.com> <20090401171530.GB12860@whirlpool.galois.com> Message-ID: Don Stewart wrote: > Please upload!! > I've run into 2 problems while trying to do this. The first one - haxr won't build with HTTP-4000, so I had to edit haxr.cabal and add the upper version bound for HTTP. The second one is puzzling me. I've cabal-installed the package, but keep getting linking errors from ghci (though interactive loading of the same module from source works fine): Prelude> :m + System.Vacuum.Ubigraph Prelude System.Vacuum.Ubigraph> view 42 Loading package syb ... linking ... done. Loading package vacuum-0.0.6 ... linking ... done. Loading package haxr-3000.1.1.2 ... linking ... done. Loading package vacuum-ubigraph-0.1.0.2 ... linking ... : /home/gleb/.cabal/lib/vacuum-ubigraph-0.1.0.2/ghc-6.10.1/HSvacuum-ubigraph-0.1.0.2.o: unknown symbol `vacuumzmubigraphzm0zi1zi0zi2_GraphicsziUbigraph_lvl_closure' ghc: unable to load package `vacuum-ubigraph-0.1.0.2' Prelude System.Vacuum.Ubigraph> Non-working package is here: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vacuum-ubigraph-0.1.0.1. Any hints appreciated. From iavor.diatchki at gmail.com Thu Apr 2 13:20:16 2009 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Thu Apr 2 13:07:23 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: vacuum-cairo: a cairo frontend to vacuum for live Haskell data visualization In-Reply-To: References: <20090331054038.GA5648@whirlpool.galois.com> <1bc51a990904010954m1253c08eld5a5e14882f31449@mail.gmail.com> <20090401171530.GB12860@whirlpool.galois.com> Message-ID: <5ab17e790904021020v72e20694y4ea48db8e740b76d@mail.gmail.com> Hi, The linking problem might be due to a bug in the cabal file: if you have modules that are not exposed, you still need to list them in the "other-modules" section. -Iavor On Thu, Apr 2, 2009 at 10:01 AM, Gleb Alexeyev wrote: > Don Stewart wrote: >> >> Please upload!! >> > > I've run into 2 problems while trying to do this. > The first one - haxr won't build with HTTP-4000, so I had to edit haxr.cabal > and add the upper version bound for HTTP. > > The second one is puzzling me. > > I've cabal-installed the package, but keep getting linking errors from ghci > (though interactive loading of the same module from source works fine): > > Prelude> :m + System.Vacuum.Ubigraph > Prelude System.Vacuum.Ubigraph> view 42 > Loading package syb ... linking ... done. > > Loading package vacuum-0.0.6 ... linking ... done. > Loading package haxr-3000.1.1.2 ... linking ... done. > Loading package vacuum-ubigraph-0.1.0.2 ... linking ... : > /home/gleb/.cabal/lib/vacuum-ubigraph-0.1.0.2/ghc-6.10.1/HSvacuum-ubigraph-0.1.0.2.o: > unknown symbol `vacuumzmubigraphzm0zi1zi0zi2_GraphicsziUbigraph_lvl_closure' > ghc: unable to load package `vacuum-ubigraph-0.1.0.2' > Prelude System.Vacuum.Ubigraph> > > Non-working package is here: > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vacuum-ubigraph-0.1.0.1. > > Any hints appreciated. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From vigalchin at gmail.com Thu Apr 2 13:23:51 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Thu Apr 2 13:11:14 2009 Subject: [Haskell-cafe] Retargeting the ghc code generator Message-ID: <5ae4f2ba0904021023t62226b17td5b94a2c3e7b671d@mail.gmail.com> Hello, Is there any project to retarget the GHC code generator to generate Common Intermediate Language(CLI) in order to run on Mono or .NET? I assume that Mondrian did precisely that. Thanks, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090402/2726109f/attachment.htm From gleb.alexeev at gmail.com Thu Apr 2 13:27:47 2009 From: gleb.alexeev at gmail.com (Gleb Alexeyev) Date: Thu Apr 2 13:14:34 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: vacuum-cairo: a cairo frontend to vacuum for live Haskell data visualization In-Reply-To: <5ab17e790904021020v72e20694y4ea48db8e740b76d@mail.gmail.com> References: <20090331054038.GA5648@whirlpool.galois.com> <1bc51a990904010954m1253c08eld5a5e14882f31449@mail.gmail.com> <20090401171530.GB12860@whirlpool.galois.com> <5ab17e790904021020v72e20694y4ea48db8e740b76d@mail.gmail.com> Message-ID: Iavor Diatchki wrote: > Hi, > The linking problem might be due to a bug in the cabal file: if you > have modules that are not exposed, you still need to list them in the > "other-modules" section. This was the problem, thanks! From simon at joyful.com Thu Apr 2 13:33:32 2009 From: simon at joyful.com (Simon Michael) Date: Thu Apr 2 13:21:00 2009 Subject: [Haskell-cafe] Re: Reverting to any old version using Darcs In-Reply-To: <87wsa3uzjz.fsf@malde.org> References: <20090401171436.GA12860@whirlpool.galois.com> <873acsxi3y.fsf@malde.org> <20090401202953.GK12860@whirlpool.galois.com> <87wsa3uzjz.fsf@malde.org> Message-ID: I'm learning useful things in this thread. Ketil Malde wrote: > I've done this once, but with the cabal dependencies, not darcs. Thus > the uploaded sdist was missing one of the source files, and > consequently failed to build. I have a pre-release make target where I test everything I can think of. I think it prevents the above, am I right ? # run pre-release checks: cabal is happy, the code builds, tests pass.. check: setversion unittest doctest haddocktest cabal clean cabal check cabal configure cabal build dist/build/hledger/hledger test 2>&1 | tail -1 | grep -q 'Errors: 0 Failures: 0' | From dave at zednenem.com Thu Apr 2 13:47:14 2009 From: dave at zednenem.com (David Menendez) Date: Thu Apr 2 13:34:21 2009 Subject: [Haskell-cafe] Type families and kind signatures In-Reply-To: References: <7ca3f0160904020905q2f6c7e3aqd0410db60069443b@mail.gmail.com> Message-ID: <49a77b7a0904021047t1cd59722i850b29944fae986d@mail.gmail.com> 2009/4/2 Louis Wasserman : > Mkay. ?One more quick thing -- the wiki demonstrates a place where the > original attempt worked, with a data family instead. (That is, replacing > 'type' with 'data' and adjusting the instance makes this program compile > immediately.) > a) Is there a type-hackery reason this is different from data families? It's not type hackery. Data families are different from type families, and the syntax for declaring instances of higher-kinded families is a consequence of those differences. An instance of a data family is a new type constructor, so you have to provide the additional arguments in order to declare the data constructors. data family Foo a :: * -> * data instance Foo Bool a = FB a a -- Foo Bool has kind * -> *, like [], so I could make it a Functor Instance of type families are always pre-existing type constructors. type family Bar a :: * -> * -- Bar a must equal something of kind * -> * type instance Bar () = Maybe > b) Is there a reason this isn't made a lot clearer in the documentation? > ?GHC's docs say that higher-order type families can be declared with kind > signatures, but never gives any examples -- which would make it a lot > clearer that the below program doesn't work. Here's a higher-kinded type family I've used. type family Sig t :: * -> * class (Traversable (Sig t)) => Recursive t where roll :: Sig t t -> t unroll :: t -> Sig t t The Traversable context wouldn't be valid if I had declared Sig t a :: *, because type families must always be fully applied. The difference is analogous to the difference between type M0 a = StateT Int IO a type M1 = StateT Int IO Since type synonyms (like type and data families) must always be fully applied, you can use M1 in places where you can't use M0, even though they're effectively the same thing. foo :: ErrorT String M1 a -- valid bar :: ErrorT String M0 a -- not valid -- Dave Menendez From michael at snoyman.com Thu Apr 2 14:03:14 2009 From: michael at snoyman.com (Michael Snoyman) Date: Thu Apr 2 13:50:21 2009 Subject: [Haskell-cafe] Funny type signature question Message-ID: <29bf512f0904021103s16395578u8f9c566788fb22b2@mail.gmail.com> I've butted into this problem multiple times, so I thought it's finally time to get a good solution. I don't even have the terminology to describe the issue, so I'll just post the code I'm annoyed with and hope someone understands what I mean. import Control.Monad.Random import System.Random data Marital = Single | Married | Divorced deriving (Enum, Bounded, Show) randomEnum :: (Enum a, Bounded a, RandomGen g) => Rand g a randomEnum = do let minb = minBound maxb = maxBound randVal <- getRandomR (fromEnum minb, fromEnum maxb) return $ head [toEnum randVal, minb, maxb] -- if I do the obvious thing (return $ toEnum randVal) I get funny errors main = do stdGen <- newStdGen let marital = evalRand randomEnum stdGen :: Marital putStrLn $ "Random marital status: " ++ show marital Any help is appreciated. Thanks! Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090402/7960bb43/attachment.htm From bugfact at gmail.com Thu Apr 2 14:18:27 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Apr 2 14:05:34 2009 Subject: [Haskell-cafe] Funny type signature question In-Reply-To: <29bf512f0904021103s16395578u8f9c566788fb22b2@mail.gmail.com> References: <29bf512f0904021103s16395578u8f9c566788fb22b2@mail.gmail.com> Message-ID: The type inferer seems to struggle to find the type of minBound and maxBound, and GHC asks to use a type annotation. To only way I see how to add a type annotation here is to use a GHC extension: {-# LANGUAGE ScopedTypeVariables #-} randomEnum :: forall a g. (Enum a, Bounded a, RandomGen g) => Rand g a randomEnum = do randVal <- getRandomR (fromEnum (minBound::a), fromEnum (maxBound::a)) return $ toEnum randVal It is annoying when the type inferer encounters ambiguities - you also get this all the time when using OpenGL e.g. GL.colour - but I don't know how to solve this without adding type annotations On Thu, Apr 2, 2009 at 8:03 PM, Michael Snoyman wrote: > I've butted into this problem multiple times, so I thought it's finally > time to get a good solution. I don't even have the terminology to describe > the issue, so I'll just post the code I'm annoyed with and hope someone > understands what I mean. > > import Control.Monad.Random > import System.Random > > data Marital = Single | Married | Divorced > deriving (Enum, Bounded, Show) > > randomEnum :: (Enum a, Bounded a, RandomGen g) => Rand g a > randomEnum = do > let minb = minBound > maxb = maxBound > randVal <- getRandomR (fromEnum minb, fromEnum maxb) > return $ head [toEnum randVal, minb, maxb] -- if I do the obvious thing > (return $ toEnum randVal) I get funny errors > > main = do > stdGen <- newStdGen > let marital = evalRand randomEnum stdGen :: Marital > putStrLn $ "Random marital status: " ++ show marital > > Any help is appreciated. Thanks! > Michael > > _______________________________________________ > 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/20090402/00e08957/attachment.htm From rmm-haskell at z.odi.ac Thu Apr 2 14:23:39 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Thu Apr 2 14:10:49 2009 Subject: [Haskell-cafe] Funny type signature question In-Reply-To: References: <29bf512f0904021103s16395578u8f9c566788fb22b2@mail.gmail.com> Message-ID: <4CFEEE79-2909-4FE5-AFF9-AA32AE3A1EA4@z.odi.ac> There's nothing connecting the Enum/Bounded used in fromEnum and min/ maxBound to the toEnum, as there's an Int in the middle. Annotated very explicitly, the type inferrer probably sees something like: > randomEnum :: (Enum a, Bounded a, RandomGen g) => Rand g a > randomEnum = do > let minb = (minBound :: a1) > maxb = (maxBound :: a1) > randVal <- getRandomR (fromEnum minb, fromEnum maxb) -- a1 here > return $ head [toEnum randVal, minb, maxb] -- putting minb and > maxb in the list forces the unknown a1 to be a, because lists are > homogeneous So you have to give it some clue what you really want. -Ross On Apr 2, 2009, at 2:18 PM, Peter Verswyvelen wrote: > The type inferer seems to struggle to find the type of minBound and > maxBound, and GHC asks to use a type annotation. > > To only way I see how to add a type annotation here is to use a GHC > extension: > > {-# LANGUAGE ScopedTypeVariables #-} > > randomEnum :: forall a g. (Enum a, Bounded a, RandomGen g) => Rand g a > randomEnum = do > randVal <- getRandomR (fromEnum (minBound::a), fromEnum > (maxBound::a)) > return $ toEnum randVal > > > It is annoying when the type inferer encounters ambiguities - you > also get this all the time when using OpenGL e.g. GL.colour - but I > don't know how to solve this without adding type annotations > > > On Thu, Apr 2, 2009 at 8:03 PM, Michael Snoyman > wrote: > I've butted into this problem multiple times, so I thought it's > finally time to get a good solution. I don't even have the > terminology to describe the issue, so I'll just post the code I'm > annoyed with and hope someone understands what I mean. > > import Control.Monad.Random > import System.Random > > data Marital = Single | Married | Divorced > deriving (Enum, Bounded, Show) > > randomEnum :: (Enum a, Bounded a, RandomGen g) => Rand g a > randomEnum = do > let minb = minBound > maxb = maxBound > randVal <- getRandomR (fromEnum minb, fromEnum maxb) > return $ head [toEnum randVal, minb, maxb] -- if I do the > obvious thing (return $ toEnum randVal) I get funny errors > > main = do > stdGen <- newStdGen > let marital = evalRand randomEnum stdGen :: Marital > putStrLn $ "Random marital status: " ++ show marital > > Any help is appreciated. Thanks! > Michael > > _______________________________________________ > 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 michael at snoyman.com Thu Apr 2 14:45:00 2009 From: michael at snoyman.com (Michael Snoyman) Date: Thu Apr 2 14:32:09 2009 Subject: [Haskell-cafe] Funny type signature question In-Reply-To: References: <29bf512f0904021103s16395578u8f9c566788fb22b2@mail.gmail.com> Message-ID: <29bf512f0904021145m75e69873odd47ecea190f79dd@mail.gmail.com> Peter and Lennart, Scoped type variables is exactly what I needed to know. Thanks for solving this annoyance for me! Michael On Thu, Apr 2, 2009 at 9:18 PM, Peter Verswyvelen wrote: > The type inferer seems to struggle to find the type of minBound and > maxBound, and GHC asks to use a type annotation. > To only way I see how to add a type annotation here is to use a GHC > extension: > > {-# LANGUAGE ScopedTypeVariables #-} > > randomEnum :: forall a g. (Enum a, Bounded a, RandomGen g) => Rand g a > randomEnum = do > randVal <- getRandomR (fromEnum (minBound::a), fromEnum (maxBound::a)) > return $ toEnum randVal > > > It is annoying when the type inferer encounters ambiguities - you also get > this all the time when using OpenGL e.g. GL.colour - but I don't know how to > solve this without adding type annotations > > > On Thu, Apr 2, 2009 at 8:03 PM, Michael Snoyman wrote: > >> I've butted into this problem multiple times, so I thought it's finally >> time to get a good solution. I don't even have the terminology to describe >> the issue, so I'll just post the code I'm annoyed with and hope someone >> understands what I mean. >> >> import Control.Monad.Random >> import System.Random >> >> data Marital = Single | Married | Divorced >> deriving (Enum, Bounded, Show) >> >> randomEnum :: (Enum a, Bounded a, RandomGen g) => Rand g a >> randomEnum = do >> let minb = minBound >> maxb = maxBound >> randVal <- getRandomR (fromEnum minb, fromEnum maxb) >> return $ head [toEnum randVal, minb, maxb] -- if I do the obvious >> thing (return $ toEnum randVal) I get funny errors >> >> main = do >> stdGen <- newStdGen >> let marital = evalRand randomEnum stdGen :: Marital >> putStrLn $ "Random marital status: " ++ show marital >> >> Any help is appreciated. Thanks! >> Michael >> >> _______________________________________________ >> 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/20090402/2c375e7b/attachment.htm From felipe.lessa at gmail.com Thu Apr 2 14:51:19 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Thu Apr 2 14:38:33 2009 Subject: [Haskell-cafe] Funny type signature question In-Reply-To: References: <29bf512f0904021103s16395578u8f9c566788fb22b2@mail.gmail.com> Message-ID: <20090402185119.GA7840@kira.casa> On Thu, Apr 02, 2009 at 08:18:27PM +0200, Peter Verswyvelen wrote: > The type inferer seems to struggle to find the type of minBound and > maxBound, and GHC asks to use a type annotation. > To only way I see how to add a type annotation here is to use a GHC > extension: > > {-# LANGUAGE ScopedTypeVariables #-} Just use 'asTypeOf'. It is defined as > asTypeOf :: a -> a -> a > asTypeOf = const so that @asTypeOf x y == x@ but both types are constrained to be equal. The above function would become > randomEnum :: (Enum a, Bounded a, RandomGen g) => Rand g a > randomEnum = do > let min = minBound; max = maxBound > randVal <- getRandomR (fromEnum min, fromEnum max) > return $ toEnum randVal `asTypeOf` min `asTypeOf` max Note that I use the fact that 'return' is constrained to the type variable 'a' we want to constrain its argument, and the 'asTypeOf' constrains everything to be of the same type. HTH, -- Felipe. From michael at snoyman.com Thu Apr 2 14:54:16 2009 From: michael at snoyman.com (Michael Snoyman) Date: Thu Apr 2 14:41:23 2009 Subject: [Haskell-cafe] Funny type signature question In-Reply-To: <20090402185119.GA7840@kira.casa> References: <29bf512f0904021103s16395578u8f9c566788fb22b2@mail.gmail.com> <20090402185119.GA7840@kira.casa> Message-ID: <29bf512f0904021154t3ec14c6cw4248ef3c2cda9a6e@mail.gmail.com> On Thu, Apr 2, 2009 at 9:51 PM, Felipe Lessa wrote: > On Thu, Apr 02, 2009 at 08:18:27PM +0200, Peter Verswyvelen wrote: > > The type inferer seems to struggle to find the type of minBound and > > maxBound, and GHC asks to use a type annotation. > > To only way I see how to add a type annotation here is to use a GHC > > extension: > > > > {-# LANGUAGE ScopedTypeVariables #-} > > Just use 'asTypeOf'. It is defined as > > > asTypeOf :: a -> a -> a > > asTypeOf = const > > so that @asTypeOf x y == x@ but both types are constrained to be > equal. The above function would become > > > randomEnum :: (Enum a, Bounded a, RandomGen g) => Rand g a > > randomEnum = do > > let min = minBound; max = maxBound > > randVal <- getRandomR (fromEnum min, fromEnum max) > > return $ toEnum randVal `asTypeOf` min `asTypeOf` max > > Note that I use the fact that 'return' is constrained to the type > variable 'a' we want to constrain its argument, and the > 'asTypeOf' constrains everything to be of the same type. > > HTH, > > -- > Felipe. > Interesting alternative. However, I think the ScopedTypeVariables looks a little bit cleaner. I'll keep the asTypeOf in mind for the future though. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090402/600089df/attachment.htm From bugfact at gmail.com Thu Apr 2 14:59:56 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Apr 2 14:47:03 2009 Subject: [Haskell-cafe] Funny type signature question In-Reply-To: <29bf512f0904021154t3ec14c6cw4248ef3c2cda9a6e@mail.gmail.com> References: <29bf512f0904021103s16395578u8f9c566788fb22b2@mail.gmail.com> <20090402185119.GA7840@kira.casa> <29bf512f0904021154t3ec14c6cw4248ef3c2cda9a6e@mail.gmail.com> Message-ID: Ah, I did not know this asTypeOf function. But ScopedTypeVariables also allows you to give inner functions type signatures that reuse polymorphic type parameters of the parent scope, which makes code clearer I think. On Thu, Apr 2, 2009 at 8:54 PM, Michael Snoyman wrote: > > > On Thu, Apr 2, 2009 at 9:51 PM, Felipe Lessa wrote: > >> On Thu, Apr 02, 2009 at 08:18:27PM +0200, Peter Verswyvelen wrote: >> > The type inferer seems to struggle to find the type of minBound and >> > maxBound, and GHC asks to use a type annotation. >> > To only way I see how to add a type annotation here is to use a GHC >> > extension: >> > >> > {-# LANGUAGE ScopedTypeVariables #-} >> >> Just use 'asTypeOf'. It is defined as >> >> > asTypeOf :: a -> a -> a >> > asTypeOf = const >> >> so that @asTypeOf x y == x@ but both types are constrained to be >> equal. The above function would become >> >> > randomEnum :: (Enum a, Bounded a, RandomGen g) => Rand g a >> > randomEnum = do >> > let min = minBound; max = maxBound >> > randVal <- getRandomR (fromEnum min, fromEnum max) >> > return $ toEnum randVal `asTypeOf` min `asTypeOf` max >> >> Note that I use the fact that 'return' is constrained to the type >> variable 'a' we want to constrain its argument, and the >> 'asTypeOf' constrains everything to be of the same type. >> >> HTH, >> >> -- >> Felipe. >> > > Interesting alternative. However, I think the ScopedTypeVariables looks a > little bit cleaner. I'll keep the asTypeOf in mind for the future though. > > Michael > > > _______________________________________________ > 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/20090402/6e00f6a8/attachment.htm From felipe.lessa at gmail.com Thu Apr 2 15:06:04 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Thu Apr 2 14:53:19 2009 Subject: [Haskell-cafe] Funny type signature question In-Reply-To: <29bf512f0904021154t3ec14c6cw4248ef3c2cda9a6e@mail.gmail.com> References: <29bf512f0904021103s16395578u8f9c566788fb22b2@mail.gmail.com> <20090402185119.GA7840@kira.casa> <29bf512f0904021154t3ec14c6cw4248ef3c2cda9a6e@mail.gmail.com> Message-ID: <20090402190604.GA8992@kira.casa> On Thu, Apr 02, 2009 at 09:54:16PM +0300, Michael Snoyman wrote: > Interesting alternative. However, I think the ScopedTypeVariables looks a > little bit cleaner. I'll keep the asTypeOf in mind for the future though. That is a matter of taste. However 'asTypeOf' has a clear advantage: it is Haskell 98. This is also a matter of taste, but I prefer not to use extensions whenever they don't bring any real gain (e.g. sometimes you can't use 'asTypeOf', and the scoped type variables are your only option). -- Felipe. From moonpatio at gmail.com Thu Apr 2 15:47:48 2009 From: moonpatio at gmail.com (Matt Morrow) Date: Thu Apr 2 15:34:57 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: vacuum-cairo: a cairo frontend to vacuum for live Haskell data visualization In-Reply-To: References: <20090331054038.GA5648@whirlpool.galois.com> <1bc51a990904010954m1253c08eld5a5e14882f31449@mail.gmail.com> <20090401171530.GB12860@whirlpool.galois.com> Message-ID: <1bc51a990904021247y6a10f403q46bea6993805d61b@mail.gmail.com> Very nice. Gleb Alexeyev wrote: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vacuum-ubigraph -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090402/ed25be32/attachment.htm From clawsie at fastmail.fm Thu Apr 2 16:02:20 2009 From: clawsie at fastmail.fm (brad clawsie) Date: Thu Apr 2 15:49:38 2009 Subject: [Haskell-cafe] .editrc Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 does anyone have a .editrc they can provide that allows ghci to be used on freebsd? i'm not looking for anything fancy, just backspace not being broken etc thanks brad -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.10 (Darwin) iEYEARECAAYFAknVGdQACgkQxRg3RkRK91NZ4gCgm8Oktcs3sCYl6YoY6X4igZAR IDIAn2cpF7QnI4zz4LFN1cVlzG7qSHHk =CJXp -----END PGP SIGNATURE----- From Steve.Schuldenzucker at web.de Thu Apr 2 17:14:24 2009 From: Steve.Schuldenzucker at web.de (Steffen Schuldenzucker) Date: Thu Apr 2 17:01:32 2009 Subject: [Haskell-cafe] Re: HXT: desperatedly trying to "concat" Message-ID: <1550323751@web.de> Hello again. I finally got it myself. It was just a matter of parentheses: See http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3229 for the corrected version. Looks like what I was trying to do is not expressable via just an arrow, one needs a function mapping the input arrow to a new one. I'm gonna make a big "WATCH YOUR PARENTHESES!" poster... Yeah, with some arrows on it... Thanks for reading, anyway. Steffen ________________________________________________________________________ Neu bei WEB.DE: Kostenlose maxdome Movie-FLAT! https://register.maxdome.de/xml/order/LpWebDe?ac=OM.MD.MD008K15726T7073a From carette at mcmaster.ca Thu Apr 2 17:15:23 2009 From: carette at mcmaster.ca (Jacques Carette) Date: Thu Apr 2 17:03:05 2009 Subject: [Haskell-cafe] Issue with IsFunction/Vspace in GHC 6.10.1 Message-ID: <49D52AEB.1080506@mcmaster.ca> I was playing with some of Oleg's code (at end for convenience). After minor adjustments for ghc 6.10.1, it still didn't work. The error message is quite puzzling too, as it suggests adding exactly the constraint which is present... Any ideas? Jacques -- Oleg's definition of a vector space class, based on IsFunction and -- TypeCast. See http://okmij.org/ftp/Haskell/isFunction.lhs -- for the January 2003 message, which works in GHC 6.2.1 and 6.4 -- code below *works* in 6.8.1 AFAIK {-# LANGUAGE EmptyDataDecls, MultiParamTypeClasses, FunctionalDependencies #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE OverlappingInstances #-} module Q where class Vspace a v | v -> a where (<+>) :: v -> v -> v (*>) :: a -> v -> v instance (IsFunction v f, Vspace' f a v) => Vspace a v where (<+>) = doplus (undefined::f) (*>) = dostar (undefined::f) class Vspace' f a v | f v -> a where doplus :: f -> v -> v -> v dostar :: f -> a -> v -> v instance Num a => Vspace' HFalse a a where doplus _ = (+) dostar _ = (*) -- etc. No problem. instance (IsFunction v f, Vspace' f a v, Vspace a v) => Vspace' HTrue a (c->v) where doplus _ f g = \x -> f x <+> g x dostar _ a f x = a *> (f x) test1 = (1::Int) <+> 2 test2 = ((\x -> x <+> (10::Int)) <+> (\x -> x <+> (10::Int))) 1 test3 = ((\x y -> x <+> y) <+> (\x y -> (x <+> y) <+> x)) (1::Int) (2::Int) test4 = ((\x y -> x <+> y) <+> (\x y -> ((2 *> x) <+> (3 *> y)))) (1::Int) (2::Int) data HTrue data HFalse class IsFunction a b | a -> b instance TypeCast f HTrue => IsFunction (x->y) f instance TypeCast f HFalse => IsFunction a f -- literally lifted from the HList library class TypeCast a b | a -> b, b->a where typeCast :: a -> b class TypeCast' t a b | t a -> b, t b -> a where typeCast' :: t->a->b class TypeCast'' t a b | t a -> b, t b -> a where typeCast'' :: t->a->b instance TypeCast' () a b => TypeCast a b where typeCast x = typeCast' () x instance TypeCast'' t a b => TypeCast' t a b where typeCast' = typeCast'' instance TypeCast'' () a a where typeCast'' _ x = x From claus.reinke at talk21.com Thu Apr 2 18:38:13 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Thu Apr 2 18:25:27 2009 Subject: [Haskell-cafe] Issue with IsFunction/Vspace in GHC 6.10.1 References: <49D52AEB.1080506@mcmaster.ca> Message-ID: <7EE2BB5B4FF545D6B781DC06B5DFE88F@cr3lt> {-# LANGUAGE ScopedTypeVariables #-} without, the 'f's in the instance are independent. Claus ----- Original Message ----- From: "Jacques Carette" To: Sent: Thursday, April 02, 2009 10:15 PM Subject: [Haskell-cafe] Issue with IsFunction/Vspace in GHC 6.10.1 >I was playing with some of Oleg's code (at end for convenience). After > minor adjustments for ghc 6.10.1, it still didn't work. The error > message is quite puzzling too, as it suggests adding exactly the > constraint which is present... Any ideas? > > Jacques > > -- Oleg's definition of a vector space class, based on IsFunction and > -- TypeCast. See http://okmij.org/ftp/Haskell/isFunction.lhs > -- for the January 2003 message, which works in GHC 6.2.1 and 6.4 > -- code below *works* in 6.8.1 AFAIK > {-# LANGUAGE EmptyDataDecls, MultiParamTypeClasses, > FunctionalDependencies #-} > {-# LANGUAGE FlexibleInstances #-} > {-# LANGUAGE UndecidableInstances #-} > {-# LANGUAGE OverlappingInstances #-} > > module Q where > > class Vspace a v | v -> a > where > (<+>) :: v -> v -> v > (*>) :: a -> v -> v > > instance (IsFunction v f, Vspace' f a v) => Vspace a v > where > (<+>) = doplus (undefined::f) > (*>) = dostar (undefined::f) > > class Vspace' f a v | f v -> a > where > doplus :: f -> v -> v -> v > dostar :: f -> a -> v -> v > > instance Num a => Vspace' HFalse a a where > doplus _ = (+) > dostar _ = (*) > -- etc. No problem. > > instance (IsFunction v f, Vspace' f a v, Vspace a v) > => Vspace' HTrue a (c->v) where > doplus _ f g = \x -> f x <+> g x > dostar _ a f x = a *> (f x) > > > test1 = (1::Int) <+> 2 > test2 = ((\x -> x <+> (10::Int)) <+> (\x -> x <+> (10::Int))) 1 > test3 = ((\x y -> x <+> y) <+> (\x y -> (x <+> y) <+> x)) (1::Int) (2::Int) > > test4 = ((\x y -> x <+> y) <+> (\x y -> ((2 *> x) <+> (3 *> y)))) > (1::Int) (2::Int) > > data HTrue > data HFalse > > class IsFunction a b | a -> b > instance TypeCast f HTrue => IsFunction (x->y) f > instance TypeCast f HFalse => IsFunction a f > > -- literally lifted from the HList library > class TypeCast a b | a -> b, b->a where typeCast :: a -> b > class TypeCast' t a b | t a -> b, t b -> a where typeCast' :: t->a->b > class TypeCast'' t a b | t a -> b, t b -> a where typeCast'' :: t->a->b > instance TypeCast' () a b => TypeCast a b where typeCast x = typeCast' () x > instance TypeCast'' t a b => TypeCast' t a b where typeCast' = typeCast'' > instance TypeCast'' () a a where typeCast'' _ x = x > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From gue.schmidt at web.de Thu Apr 2 18:52:18 2009 From: gue.schmidt at web.de (=?UTF-8?B?R8O8wp9udGhlciBTY2htaWR0?=) Date: Thu Apr 2 18:39:44 2009 Subject: [Haskell-cafe] Re: Looking for practical examples of Zippers In-Reply-To: <49a77b7a0903312302y53d3fc91hb9857ebc53fb9955@mail.gmail.com> References: <20090330193532.GB4181@whirlpool.galois.com> <49a77b7a0903312302y53d3fc91hb9857ebc53fb9955@mail.gmail.com> Message-ID: David, guys, sorry, this all started with a misconception on my behalf of what a Zipper is and what it is good for. In the days that followed my post this became much clearer though and I now realize my original question was pointless. It seems you spotted that and yes, "generalized trie" is probably more what I'm looking for, thanks! G?nther David Menendez schrieb: > On Mon, Mar 30, 2009 at 3:46 PM, G??nther Schmidt wrote: >> Thanks Don, >> >> I followed some examples but have not yet seen anything that would show me >> how, for instance, turn a nested Map like >> >> Map Int (Map Int (Map String Double) >> >> into a "zipped" version. >> >> That is presuming of course that this use is feasible at all. > > Are you asking about the technique for navigating recursive > structures, or did you mean something having to do with the > isomorphism between "Map Int (Map Int (Map String Double))" and "Map > (Int,Int,String) Double"? > > For the latter, the term you want is "generalized trie". > From lucas at die.net.au Thu Apr 2 19:06:43 2009 From: lucas at die.net.au (lucas@die.net.au) Date: Thu Apr 2 18:53:56 2009 Subject: [Haskell-cafe] Program using 500MB RAM to process 5MB file Message-ID: <20090402230642.GA12413@die.net.au> I'm relatively new to haskell so as one does, I am rewriting an existing program in haskell to help learn the language. However, it eats up all my RAM whenever I run the program. http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3175#a3175 Obviously I'm doing something wrong, but without my magical FP pants I don't know what that might be. -- Lucas Hazel -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090403/84b8b450/attachment.bin From lists at qseep.net Thu Apr 2 19:13:02 2009 From: lists at qseep.net (Lyle Kopnicky) Date: Thu Apr 2 19:00:07 2009 Subject: [Haskell-cafe] Missing dependency? Message-ID: <670e468e0904021613l4f2ba5cbkf4979c6c10a00994@mail.gmail.com> Hi folks, Since the time package is not included in ghc-6.10.2, I installed it via cabal. Then I tried to configure my project, and it says that the dependency is missing. Mysterious. Can anyone explain? lwk@lwk-desktop:~/devel/vintage-basic$ ghc-pkg list /usr/local/lib/ghc-6.10.2/./package.conf: Cabal-1.6.0.3, HUnit-1.2.0.3, 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, 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, filepath-1.1.0.2, (ghc-6.10.2), 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, 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, unix-2.3.2.0, xhtml-3000.2.0.1 /home/lwk/.ghc/i386-linux-6.10.2/package.conf: HTTP-4000.0.4, time-1.1.2.3, zlib-0.5.0.0 lwk@lwk-desktop:~/devel/vintage-basic$ runhaskell Setup.hs configure Configuring vintage-basic-1.0.1... Setup.hs: At least the following dependencies are missing: time >=1.1 lwk@lwk-desktop:~/devel/vintage-basic$ Thanks, Lyle -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090402/1d0c4ded/attachment.htm From wasserman.louis at gmail.com Thu Apr 2 19:18:40 2009 From: wasserman.louis at gmail.com (Louis Wasserman) Date: Thu Apr 2 19:06:02 2009 Subject: [Haskell-cafe] Type families and kind signatures In-Reply-To: <49a77b7a0904021047t1cd59722i850b29944fae986d@mail.gmail.com> References: <7ca3f0160904020905q2f6c7e3aqd0410db60069443b@mail.gmail.com> <49a77b7a0904021047t1cd59722i850b29944fae986d@mail.gmail.com> Message-ID: Mkay. I get it now. I was under the impression that, essentially, a data family was precisely equivalent to a type family aliasing to a separately declared datatype. One more question: is there any way to get the low overhead of newtypes for particular instances of a data family? Is this impossible? That is, is there any way to do something like data family Foo a data instance Foo Int = Bar Int -- Bar is actually a newtype Louis Wasserman wasserman.louis@gmail.com On Thu, Apr 2, 2009 at 12:47 PM, David Menendez wrote: > 2009/4/2 Louis Wasserman : > > Mkay. One more quick thing -- the wiki demonstrates a place where the > > original attempt worked, with a data family instead. (That is, replacing > > 'type' with 'data' and adjusting the instance makes this program compile > > immediately.) > > a) Is there a type-hackery reason this is different from data families? > > It's not type hackery. Data families are different from type families, > and the syntax for declaring instances of higher-kinded families is a > consequence of those differences. > > An instance of a data family is a new type constructor, so you have to > provide the additional arguments in order to declare the data > constructors. > > data family Foo a :: * -> * > data instance Foo Bool a = FB a a > -- Foo Bool has kind * -> *, like [], so I could make it a Functor > > Instance of type families are always pre-existing type constructors. > > type family Bar a :: * -> * -- Bar a must equal something of kind * -> * > type instance Bar () = Maybe > > > b) Is there a reason this isn't made a lot clearer in the documentation? > > GHC's docs say that higher-order type families can be declared with kind > > signatures, but never gives any examples -- which would make it a lot > > clearer that the below program doesn't work. > > Here's a higher-kinded type family I've used. > > type family Sig t :: * -> * > > class (Traversable (Sig t)) => Recursive t where > roll :: Sig t t -> t > unroll :: t -> Sig t t > > > The Traversable context wouldn't be valid if I had declared Sig t a :: > *, because type families must always be fully applied. > > > The difference is analogous to the difference between > > type M0 a = StateT Int IO a > type M1 = StateT Int IO > > Since type synonyms (like type and data families) must always be fully > applied, you can use M1 in places where you can't use M0, even though > they're effectively the same thing. > > foo :: ErrorT String M1 a -- valid > bar :: ErrorT String M0 a -- not valid > > > > -- > Dave Menendez > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090402/478c7a42/attachment.htm From toby.hutton at gmail.com Thu Apr 2 19:19:30 2009 From: toby.hutton at gmail.com (Toby Hutton) Date: Thu Apr 2 19:06:36 2009 Subject: [Haskell-cafe] Retargeting the ghc code generator In-Reply-To: <5ae4f2ba0904021023t62226b17td5b94a2c3e7b671d@mail.gmail.com> References: <5ae4f2ba0904021023t62226b17td5b94a2c3e7b671d@mail.gmail.com> Message-ID: <711894390904021619q54e551b5ta2c232a077591a3e@mail.gmail.com> 2009/4/3 Vasili I. Galchin : > Hello, > > ????? Is there any project to retarget the GHC code generator to generate > Common Intermediate Language(CLI) in order to run on Mono or .NET? I assume > that Mondrian did precisely that. There are/were a couple of projects attempting that or to bring Haskell to .NET in general, but with limited success. MSR were considering it but due to qualities like purity and laziness making it difficult they chose to bring Ocaml to .NET and came up with F#. http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/ From carette at mcmaster.ca Thu Apr 2 19:23:00 2009 From: carette at mcmaster.ca (Jacques Carette) Date: Thu Apr 2 19:10:37 2009 Subject: [Haskell-cafe] Issue with IsFunction/Vspace in GHC 6.10.1 In-Reply-To: <7EE2BB5B4FF545D6B781DC06B5DFE88F@cr3lt> References: <49D52AEB.1080506@mcmaster.ca> <7EE2BB5B4FF545D6B781DC06B5DFE88F@cr3lt> Message-ID: <49D548D4.8010700@mcmaster.ca> Claus Reinke wrote: > {-# LANGUAGE ScopedTypeVariables #-} > > without, the 'f's in the instance are independent. > Claus Thanks - I discovered this (by trial-and-error) at about the same time you sent the email. Is there a ticket somewhere to add a warning about this? I expected me 'f's to be the same, and the error messages were not the least bit enlightening. Jacques From jonathanccast at fastmail.fm Thu Apr 2 19:17:58 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Thu Apr 2 19:12:01 2009 Subject: [Haskell-cafe] Missing dependency? In-Reply-To: <670e468e0904021613l4f2ba5cbkf4979c6c10a00994@mail.gmail.com> References: <670e468e0904021613l4f2ba5cbkf4979c6c10a00994@mail.gmail.com> Message-ID: <1238714278.32689.15.camel@jcchost> On Thu, 2009-04-02 at 16:13 -0700, Lyle Kopnicky wrote: > Hi folks, > > Since the time package is not included in ghc-6.10.2, I installed it > via cabal. Then I tried to configure my project, and it says that the > dependency is missing. Mysterious. Can anyone explain? > > lwk@lwk-desktop:~/devel/vintage-basic$ ghc-pkg list > /usr/local/lib/ghc-6.10.2/./package.conf: > Cabal-1.6.0.3, HUnit-1.2.0.3, 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, > 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, filepath-1.1.0.2, (ghc-6.10.2), > 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, 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, > unix-2.3.2.0, xhtml-3000.2.0.1 > /home/lwk/.ghc/i386-linux-6.10.2/package.conf: > HTTP-4000.0.4, time-1.1.2.3, zlib-0.5.0.0 > lwk@lwk-desktop:~/devel/vintage-basic$ runhaskell Setup.hs configure > Configuring vintage-basic-1.0.1... > Setup.hs: At least the following dependencies are missing: > time >=1.1 > lwk@lwk-desktop:~/devel/vintage-basic$ You need to use runhaskell Setup.hs configure --user, or else re-install time globally (as root). jcc From rick.richardson at gmail.com Thu Apr 2 19:55:07 2009 From: rick.richardson at gmail.com (Rick R) Date: Thu Apr 2 19:42:13 2009 Subject: [Haskell-cafe] Program using 500MB RAM to process 5MB file In-Reply-To: <20090402230642.GA12413@die.net.au> References: <20090402230642.GA12413@die.net.au> Message-ID: <9810b81b0904021655g14fff277pf377698e33e0c491@mail.gmail.com> You could profile your app for memory usage. Then you could figure out just what function is blowing up the mem usage and figure out how to optimize it. http://book.realworldhaskell.org/read/profiling-and-optimization.html 2009/4/2 > I'm relatively new to haskell so as one does, I am rewriting an > existing program in haskell to help learn the language. > > However, it eats up all my RAM whenever I run the program. > > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3175#a3175 > > Obviously I'm doing something wrong, but without my magical FP pants I > don't know what that might be. > > -- > Lucas Hazel > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- We can't solve problems by using the same kind of thinking we used when we created them. - A. Einstein -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090402/94406b4e/attachment.htm From duane.johnson at gmail.com Thu Apr 2 20:01:44 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Thu Apr 2 19:48:57 2009 Subject: [Haskell-cafe] Wishful thinking: a text editor that expands function applications into function definitions Message-ID: So I was thinking about a "killer feature" for a text editor. Wouldn't it be neat if you could expand function calls into their definitions, in-place? For example, suppose we have "minus" defined like so, somewhere in another file: > minus (a, b, c) (x, y, z) = (a - x, b - y, c - z) Later, we make use of the function in our current context: > let p1 = (1, 2, 3) > p2 = (4, 5, 6) > in p1 `minus` p2 By telling the editor to "expand" the minus, we get a temporary replacing of the above with: > (1 - 4, 2 - 5, 3 - 6) Another example: > parse s = map readLine ls And supposing that readLine is defined somewhere else, moving the cursor to readLine in the line above and "expanding" becomes: > parse s = map (\line -> words $ dropWhile (== ' ') line) This is all pretty standard for the kinds of things we do in Haskell to work it out by hand, but is there any reason the parser couldn't do this? I think it would be even harder to do automatically in any other language. Maybe it's already been attempted or done? Curious, Duane Johnson From derek.a.elkins at gmail.com Thu Apr 2 20:18:55 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Thu Apr 2 20:06:07 2009 Subject: [Haskell-cafe] Wishful thinking: a text editor that expands function applications into function definitions In-Reply-To: References: Message-ID: <1238717935.5818.3.camel@derek-laptop> On Thu, 2009-04-02 at 18:01 -0600, Duane Johnson wrote: > So I was thinking about a "killer feature" for a text editor. > Wouldn't it be neat if you could expand function calls into their > definitions, in-place? > > For example, suppose we have "minus" defined like so, somewhere in > another file: > > > minus (a, b, c) (x, y, z) = (a - x, b - y, c - z) > > Later, we make use of the function in our current context: > > > let p1 = (1, 2, 3) > > p2 = (4, 5, 6) > > in p1 `minus` p2 > > By telling the editor to "expand" the minus, we get a temporary > replacing of the above with: > > > (1 - 4, 2 - 5, 3 - 6) > > Another example: > > > parse s = map readLine ls > > And supposing that readLine is defined somewhere else, moving the > cursor to readLine in the line above and "expanding" becomes: > > > parse s = map (\line -> words $ dropWhile (== ' ') line) > > This is all pretty standard for the kinds of things we do in Haskell > to work it out by hand, but is there any reason the parser couldn't do > this? I think it would be even harder to do automatically in any > other language. Maybe it's already been attempted or done? See HaRe http://www.cs.kent.ac.uk/projects/refactor-fp/hare.html From divisortheory at gmail.com Thu Apr 2 20:24:42 2009 From: divisortheory at gmail.com (Zachary Turner) Date: Thu Apr 2 20:11:49 2009 Subject: [Haskell-cafe] Wishful thinking: a text editor that expands function applications into function definitions In-Reply-To: References: Message-ID: <478231340904021724mf465284mde22bcf2dacd30df@mail.gmail.com> It seems like a neat feature, and it could just be my inexperience with Haskell but it doesn't seem "killer". For example, why would you want to expand readLine like that if you already have it defined? It seems to defeat much of the benefit of functional languages in the first place, which is that it's so easy to reuse code by composing functions into new functions. I can see the case where you're passing all constants to a function, because then supposedly inlining it might be more efficient, but I would think the compiler would optimize most of the cases for you anyway. One feature that I -do- think would be killer though, is the ability for the editor to do a mouse-over tooltip of a) function definitions, and b) arbitrary expressions. So like in your example above, hovering the mouse over `minus` in the expression p1 `minus` p2 would pop up a two line tooltip that looked like this minus :: (Num a, Num b, Num c) => (a,b,c) -> (a,b,c) -> (a,b,c) minus :: first -> second -> (a,b,c) Something along those lines. It's nice to be able to see names of function arguments without having to navigate away from the line you're editing. This isn't the killer yet though since it's actually pretty standard for most sufficiently advanced programming language IDEs. The killer is that the mouse-over event would also look one line above the function definition for a comment. It would then scan backward until it finds no more comments. It would then display that text above the function definition. It's great having a type signature, but comments would just be icing on the cake. For arbitrary expressions, suppose you had the following function: replaceItem :: [a] -> (a -> Bool) -> a -> [a] let replaceItem xs pred = (: filter (not.pred) xs) You then highlight the text "filter (not.pred)" and hover over the highlighted text. The mouse then pops up a tooltip that says "[a] -> [a]". That would be killer IMO On Thu, Apr 2, 2009 at 7:01 PM, Duane Johnson wrote: > So I was thinking about a "killer feature" for a text editor. Wouldn't it > be neat if you could expand function calls into their definitions, in-place? > > For example, suppose we have "minus" defined like so, somewhere in another > file: > > minus (a, b, c) (x, y, z) = (a - x, b - y, c - z) >> > > Later, we make use of the function in our current context: > > let p1 = (1, 2, 3) >> p2 = (4, 5, 6) >> in p1 `minus` p2 >> > > By telling the editor to "expand" the minus, we get a temporary replacing > of the above with: > > (1 - 4, 2 - 5, 3 - 6) >> > > Another example: > > parse s = map readLine ls >> > > And supposing that readLine is defined somewhere else, moving the cursor to > readLine in the line above and "expanding" becomes: > > parse s = map (\line -> words $ dropWhile (== ' ') line) >> > > This is all pretty standard for the kinds of things we do in Haskell to > work it out by hand, but is there any reason the parser couldn't do this? I > think it would be even harder to do automatically in any other language. > Maybe it's already been attempted or done? > > Curious, > > Duane Johnson > > _______________________________________________ > 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/20090402/a0ee9de5/attachment.htm From duane.johnson at gmail.com Thu Apr 2 20:36:29 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Thu Apr 2 20:23:40 2009 Subject: [Haskell-cafe] Wishful thinking: a text editor that expands function applications into function definitions In-Reply-To: <478231340904021724mf465284mde22bcf2dacd30df@mail.gmail.com> References: <478231340904021724mf465284mde22bcf2dacd30df@mail.gmail.com> Message-ID: <5E2DDE76-824F-408A-A63C-383329B390BC@gmail.com> Perhaps it wouldn't be as all-wonderful as I think, but as a "new" Haskell user, I am constantly switching back and forth between various definitions of things trying to compare documentation and files... The purpose of "expansion" as I was explaining it is not to *permanently replace* what is in the text, but rather to *temporarily replace* it. I imagine it kind of like a "zoom in" for code. You could "zoom in" on one function, and seeing a new function that you don't recognize, "zoom in" again, and so on. Once done, you would hit "ESC" to make it all return as it was. BTW, I do like your suggestion of tooltip types. That would be very handy! Duane Johnson On Apr 2, 2009, at 6:24 PM, Zachary Turner wrote: > It seems like a neat feature, and it could just be my inexperience > with Haskell but it doesn't seem "killer". For example, why would > you want to expand readLine like that if you already have it > defined? It seems to defeat much of the benefit of functional > languages in the first place, which is that it's so easy to reuse > code by composing functions into new functions. I can see the case > where you're passing all constants to a function, because then > supposedly inlining it might be more efficient, but I would think > the compiler would optimize most of the cases for you anyway. > > One feature that I -do- think would be killer though, is the ability > for the editor to do a mouse-over tooltip of a) function > definitions, and b) arbitrary expressions. So like in your example > above, hovering the mouse over `minus` in the expression p1 `minus` > p2 would pop up a two line tooltip that looked like this > > minus :: (Num a, Num b, Num c) => (a,b,c) -> (a,b,c) -> (a,b,c) > minus :: first -> second -> (a,b,c) > > Something along those lines. It's nice to be able to see names of > function arguments without having to navigate away from the line > you're editing. This isn't the killer yet though since it's > actually pretty standard for most sufficiently advanced programming > language IDEs. The killer is that the mouse-over event would also > look one line above the function definition for a comment. It would > then scan backward until it finds no more comments. It would then > display that text above the function definition. It's great having > a type signature, but comments would just be icing on the cake. > > For arbitrary expressions, suppose you had the following function: > > replaceItem :: [a] -> (a -> Bool) -> a -> [a] > let replaceItem xs pred = (: filter (not.pred) xs) > > You then highlight the text "filter (not.pred)" and hover over the > highlighted text. The mouse then pops up a tooltip that says "[a] - > > [a]". That would be killer IMO > > > > On Thu, Apr 2, 2009 at 7:01 PM, Duane Johnson > wrote: > So I was thinking about a "killer feature" for a text editor. > Wouldn't it be neat if you could expand function calls into their > definitions, in-place? > > For example, suppose we have "minus" defined like so, somewhere in > another file: > > minus (a, b, c) (x, y, z) = (a - x, b - y, c - z) > > Later, we make use of the function in our current context: > > let p1 = (1, 2, 3) > p2 = (4, 5, 6) > in p1 `minus` p2 > > By telling the editor to "expand" the minus, we get a temporary > replacing of the above with: > > (1 - 4, 2 - 5, 3 - 6) > > Another example: > > parse s = map readLine ls > > And supposing that readLine is defined somewhere else, moving the > cursor to readLine in the line above and "expanding" becomes: > > parse s = map (\line -> words $ dropWhile (== ' ') line) > > This is all pretty standard for the kinds of things we do in Haskell > to work it out by hand, but is there any reason the parser couldn't > do this? I think it would be even harder to do automatically in any > other language. Maybe it's already been attempted or done? > > Curious, > > Duane Johnson > > _______________________________________________ > 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/20090402/6abdaa2b/attachment.htm From chak at cse.unsw.edu.au Thu Apr 2 20:43:57 2009 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Thu Apr 2 20:31:14 2009 Subject: [Haskell-cafe] Type families and kind signatures In-Reply-To: References: <7ca3f0160904020905q2f6c7e3aqd0410db60069443b@mail.gmail.com> <49a77b7a0904021047t1cd59722i850b29944fae986d@mail.gmail.com> Message-ID: <7118D2B4-9C33-47C1-A8F0-266497139170@cse.unsw.edu.au> Louis Wasserman: > Mkay. I get it now. I was under the impression that, essentially, > a data family was precisely equivalent to a type family aliasing to > a separately declared datatype. No, they are not equivalent. You can see that as follows. Assume, data family T a type family S a Now, given `T a ~ T b', we know that `a ~ b'. (We call this implication "decomposition".) In contrast, given `S a ~ S b' we do *not* know whether `a ~ b'. Why not? Consider the instances type instance S Int = Bool type instance S Float = Bool Clearly, `S Int ~ S Float', but surely not `Int ~ Float'. So, decomposition does not hold for type synonym families, but it does hold for data families. This is actually, not really a property of type *families* alone. It already distinguishes vanilla data types from vanilla type synonyms. We know, say, that if `Maybe a ~ Maybe b', then `a ~ b'. However, given type Const a = Int we have `Const Int ~ Const Float' (and still not `Int ~ Float'). Definitions, such as that of `Const', are rarely used, which is why this issue doesn't come up much until you use type families. > One more question: is there any way to get the low overhead of > newtypes for particular instances of a data family? Is this > impossible? That is, is there any way to do something like > > data family Foo a > data instance Foo Int = Bar Int -- Bar is actually a newtype You can use newtype instance Foo Int = MkFoo Int So, the instances of a data family can be data or newtype instances., and you can freely mix them. Manuel > On Thu, Apr 2, 2009 at 12:47 PM, David Menendez > wrote: > 2009/4/2 Louis Wasserman : > > Mkay. One more quick thing -- the wiki demonstrates a place where > the > > original attempt worked, with a data family instead. (That is, > replacing > > 'type' with 'data' and adjusting the instance makes this program > compile > > immediately.) > > a) Is there a type-hackery reason this is different from data > families? > > It's not type hackery. Data families are different from type families, > and the syntax for declaring instances of higher-kinded families is a > consequence of those differences. > > An instance of a data family is a new type constructor, so you have to > provide the additional arguments in order to declare the data > constructors. > > data family Foo a :: * -> * > data instance Foo Bool a = FB a a > -- Foo Bool has kind * -> *, like [], so I could make it a Functor > > Instance of type families are always pre-existing type constructors. > > type family Bar a :: * -> * -- Bar a must equal something of kind * > -> * > type instance Bar () = Maybe > > > b) Is there a reason this isn't made a lot clearer in the > documentation? > > GHC's docs say that higher-order type families can be declared > with kind > > signatures, but never gives any examples -- which would make it a > lot > > clearer that the below program doesn't work. > > Here's a higher-kinded type family I've used. > > type family Sig t :: * -> * > > class (Traversable (Sig t)) => Recursive t where > roll :: Sig t t -> t > unroll :: t -> Sig t t > > > The Traversable context wouldn't be valid if I had declared Sig t a :: > *, because type families must always be fully applied. > > > The difference is analogous to the difference between > > type M0 a = StateT Int IO a > type M1 = StateT Int IO > > Since type synonyms (like type and data families) must always be fully > applied, you can use M1 in places where you can't use M0, even though > they're effectively the same thing. > > foo :: ErrorT String M1 a -- valid > bar :: ErrorT String M0 a -- not valid > > > > -- > 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/20090403/041b2efe/attachment.htm From trentbuck at gmail.com Thu Apr 2 20:56:46 2009 From: trentbuck at gmail.com (Trent W. Buck) Date: Thu Apr 2 20:42:10 2009 Subject: [Haskell-cafe] Reverting to any old version using Darcs References: <20090401171436.GA12860@whirlpool.galois.com> <873acsxi3y.fsf@malde.org> <20090401202953.GK12860@whirlpool.galois.com> <1238660704-sup-3258@ausone.inria.fr> Message-ID: <307i225zch.fsf@alexlance.com> Nicolas Pouillard writes: > Excerpts from Peter Verswyvelen's message of Wed Apr 01 23:39:15 +0200 2009: > [...] > >> biggest problems I usually see in teams - namely forgetting to add files, >> forgetting to check in dependencies and the inability the merge after >> renames or moves - > > Have a look at the --look-for-adds flag that makes the enables the detection > of new files. If you were really paranoid about this, you could turn --look-for-adds on by default in a repo or for a user, so that any "darcs record" would also ask about new files. This would probably get annoying unless you added a bunch of entries to _darcs/prefs/boring. From trentbuck at gmail.com Thu Apr 2 20:58:49 2009 From: trentbuck at gmail.com (Trent W. Buck) Date: Thu Apr 2 20:57:14 2009 Subject: [Haskell-cafe] Re: Reverting to any old version using Darcs References: <20090401171436.GA12860@whirlpool.galois.com> <873acsxi3y.fsf@malde.org> <20090401202953.GK12860@whirlpool.galois.com> <87wsa3uzjz.fsf@malde.org> Message-ID: <303acq5z92.fsf@alexlance.com> Ketil Malde writes: > Peter Verswyvelen writes: > >> Forgetting to add a file can be a nasty one, since if you discover >> that too late, the original file at patch time might not exist >> anymore (how do you guys solve this? Just plain discipline I >> guess?). > > I've done this once, but with the cabal dependencies, not darcs. Thus > the uploaded sdist was missing one of the source files, and > consequently failed to build. > > I suppose the best way is to test this with a separate test repository > which you don't touch, except from pulling from your development repo > and checking that it builds. For what its worth, the darcs "test" preference performs the tests in a completely fresh working tree that it creates ONLY using files that have been checked in. This helps avoid the problem of things only working "accidentally", because of uncommitted changes. From trentbuck at gmail.com Thu Apr 2 21:06:40 2009 From: trentbuck at gmail.com (Trent W. Buck) Date: Thu Apr 2 21:02:06 2009 Subject: [Haskell-cafe] Re: Reverting to any old version using Darcs References: <20090401171436.GA12860@whirlpool.galois.com> <873acsxi3y.fsf@malde.org> <20090401202953.GK12860@whirlpool.galois.com> <87wsa3uzjz.fsf@malde.org> Message-ID: <30wsa24kbj.fsf@alexlance.com> Simon Michael writes: > I'm learning useful things in this thread. > > Ketil Malde wrote: >> I've done this once, but with the cabal dependencies, not darcs. Thus >> the uploaded sdist was missing one of the source files, and >> consequently failed to build. > > I have a pre-release make target where I test everything I can think > of. I think it prevents the above, am I right ? Dunno. > # run pre-release checks: cabal is happy, the code builds, tests > pass.. > check: setversion unittest doctest haddocktest > cabal clean > cabal check > cabal configure > cabal build > > dist/build/hledger/hledger test 2>&1 | tail -1 | grep -q 'Errors: 0 > Failures: 0' | You'd also want to test cabal haddock cabal test cabal copy "$(TMPDIR="$PWD" mktemp -dt yow.XXXXXX)" # untested IMO even if your tests aren't implemented in Setup.lhs, you should still teach "cabal test" how to run them. That helps distributors like me automatically run the test -- i.e. you get testing "for free" because we don't have to go out of our way to turn it on. From lucas at die.net.au Thu Apr 2 21:56:59 2009 From: lucas at die.net.au (lucas@die.net.au) Date: Thu Apr 2 21:44:10 2009 Subject: [Haskell-cafe] Program using 500MB RAM to process 5MB file In-Reply-To: <9810b81b0904021655g14fff277pf377698e33e0c491@mail.gmail.com> References: <20090402230642.GA12413@die.net.au> <9810b81b0904021655g14fff277pf377698e33e0c491@mail.gmail.com> Message-ID: <20090403015658.GB12413@die.net.au> On Thu, Apr 02, 2009 at 07:55:07PM -0400, Rick R wrote: > You could profile your app for memory usage. Then you could figure out just > what function is blowing up the mem usage and figure out how to optimize it. > > > http://book.realworldhaskell.org/read/profiling-and-optimization.html > > > 2009/4/2 > > > I'm relatively new to haskell so as one does, I am rewriting an > > existing program in haskell to help learn the language. > > > > However, it eats up all my RAM whenever I run the program. > > > > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3175#a3175 > > > > Obviously I'm doing something wrong, but without my magical FP pants I > > don't know what that might be. > > I ran some profiling as suggested, [SNIP] total time = 8.36 secs (418 ticks @ 20 ms) total alloc = 3,882,593,720 bytes (excludes profiling overheads) COST CENTRE MODULE %time %alloc line PkgDb 89.7 93.5 COST CENTRE MODULE no. entries %time %alloc %time %alloc line PkgDb 305 109771 89.7 93.3 89.7 93.3 [SNIP] The line function is part of the file parser line :: Parser String line = anyChar `manyTill` newline files' :: Parser Files files' = line `manyTill` newline Perhaps I should also explain the structure of the file. It's for a simple package manager called pkgutils, used for CRUX[1]. The file contains information for all the packages installed and is structured as follows ... ... From profiling it shows that the memory is simple consumed by reading in all the lines, the graph from using -p -hd shows an almost Ologn2 growth of the heap as the collection of lines grows. Is there a better way to do this? [1] http://crux.nu -- Lucas Hazel -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090403/c798a921/attachment.bin From lrpalmer at gmail.com Thu Apr 2 22:08:28 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Apr 2 21:55:36 2009 Subject: [Haskell-cafe] Program using 500MB RAM to process 5MB file In-Reply-To: <20090402230642.GA12413@die.net.au> References: <20090402230642.GA12413@die.net.au> Message-ID: <7ca3f0160904021908l65fd8bd7of7c4ab72e437d92d@mail.gmail.com> 2009/4/2 > I'm relatively new to haskell so as one does, I am rewriting an > existing program in haskell to help learn the language. > > However, it eats up all my RAM whenever I run the program. > > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3175#a3175 > > Obviously I'm doing something wrong, but without my magical FP pants I > don't know what that might be. (1) You are using plain Strings. Those things are like 8 bytes per character (or something, someone more knowledgeable can give a more accurate figure). Use bytestrings (with bytestring-utf8 if you need it) instead. (2) You are parsing strictly, meaning you have to read the whole input file before anything can be output. This may be necessary for your application, but Haskell is *very* strong with streaming applications. Change to a lazy parser and you will run in constant memory. (I don't know offhand of any lazy parsing libraries, but I've heard them discussed before, so they're somewhere) Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090402/8641e772/attachment-0001.htm From allbery at ece.cmu.edu Thu Apr 2 22:16:27 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Apr 2 22:03:52 2009 Subject: [Haskell-cafe] Missing dependency? In-Reply-To: <670e468e0904021613l4f2ba5cbkf4979c6c10a00994@mail.gmail.com> References: <670e468e0904021613l4f2ba5cbkf4979c6c10a00994@mail.gmail.com> Message-ID: <612137C3-3022-4671-AE4A-5738BBAFB71D@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/20090402/419091a5/PGP.bin From bjorn.buckwalter at gmail.com Thu Apr 2 22:28:52 2009 From: bjorn.buckwalter at gmail.com (Bjorn Buckwalter) Date: Thu Apr 2 22:16:13 2009 Subject: [Haskell-cafe] ANNOUNCE: fad 1.0 -- Forward Automatic Differentiation library Message-ID: <8b2a1a960904021928s2c44abb2g63143aa9823cc1ae@mail.gmail.com> I'm pleased to announce the initial release of the Haskell fad library, developed by Barak A. Pearlmutter and Jeffrey Mark Siskind. Fad provides Forward Automatic Differentiation (AD) for functions polymorphic over instances of 'Num'. There have been many Haskell implementations of forward AD, with varying levels of completeness, published in papers and blog posts[1], but alarmingly few of these have made it into hackage -- to date Conal Elliot's vector-spaces[2] package is the only one I am aware of. Fad is an attempt to make as comprehensive and usable a forward AD package as is possible in Haskell. However, correctness is given priority over ease of use, and this is in my opinion the defining quality of fad. Specifically, Fad leverages Haskell's expressive type system to tackle the problem of _perturbation confusion_, brought to light in Pearlmutter and Siskind's 2005 paper "Perturbation Confusion and Referential Transparency"[3]. Fad prevents perturbation confusion by employing type-level "branding" as proposed by myself in a 2007 post to haskell-cafe[4]. To the best of our knowledge all other forward AD implementations in Haskell are susceptible to perturbation confusion. As this library has been in the works for quite some time it is worth noting that it hasn't benefited from Conal's ground-breaking work[5] in the area. Once we wrap our heads around his beautiful constructs perhaps we'll be able to borrow some tricks from him. As mentioned already, fad was developed primarily by Barak A. Pearlmutter and Jeffrey Mark Siskind. My own contribution has been providing Haskell infrastructure support and wrapping up loose ends in order to get the library into a releasable state. Many thanks to Barak and Jeffrey for permitting me to release fad under the BSD license. Fad resides on GitHub[6] and hackage[7] and is only a "cabal install fad" away! What follows is Fad's README, refer to the haddocks for detailed documentation. Thanks, Bjorn Buckwalter [1] http://www.haskell.org/haskellwiki/Functional_differentiation [2] http://www.haskell.org/haskellwiki/Vector-space [3]: http://www.bcl.hamilton.ie/~qobi/nesting/papers/ifl2005.pdf [4]: http://thread.gmane.org/gmane.comp.lang.haskell.cafe/22308/ [5]: http://conal.net/papers/beautiful-differentiation/ [6] http://github.com/bjornbm/fad/ [7] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/fad ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Copyright : 2008-2009, Barak A. Pearlmutter and Jeffrey Mark Siskind License : BSD3 Maintainer : bjorn.buckwalter@gmail.com Stability : experimental Portability: GHC only? Forward Automatic Differentiation via overloading to perform nonstandard interpretation that replaces original numeric type with corresponding generalized dual number type. Each invocation of the differentiation function introduces a distinct perturbation, which requires a distinct dual number type. In order to prevent these from being confused, tagging, called branding in the Haskell community, is used. This seems to prevent perturbation confusion, although it would be nice to have an actual proof of this. The technique does require adding invocations of lift at appropriate places when nesting is present. For more information on perturbation confusion and the solution employed in this library see: Installation ============ To install: cabal install Or: runhaskell Setup.lhs configure runhaskell Setup.lhs build runhaskell Setup.lhs install Examples ======== Define an example function 'f': > import Numeric.FAD > f x = 6 - 5 * x + x ^ 2 -- Our example function Basic usage of the differentiation operator: > y = f 2 -- f(2) = 0 > y' = diff f 2 -- First derivative f'(2) = -1 > y'' = diff (diff f) 2 -- Second derivative f''(2) = 2 List of derivatives: > ys = take 3 $ diffs f 2 -- [0, -1, 2] Example optimization method; find a zero using Newton's method: > y_newton1 = zeroNewton f 0 -- converges to first zero at 2.0. > y_newton2 = zeroNewton f 10 -- converges to second zero at 3.0. Credits ======= Authors: Copyright 2008, Barak A. Pearlmutter & Jeffrey Mark Siskind Work started as stripped-down version of higher-order tower code published by Jerzy Karczmarczuk which used a non-standard standard prelude. Initial perturbation-confusing code is a modified version of Tag trick, called "branding" in the Haskell community, from Bjorn Buckwalter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From michael at snoyman.com Thu Apr 2 22:33:26 2009 From: michael at snoyman.com (Michael Snoyman) Date: Thu Apr 2 22:20:32 2009 Subject: [Haskell-cafe] Wishful thinking: a text editor that expands function applications into function definitions In-Reply-To: <5E2DDE76-824F-408A-A63C-383329B390BC@gmail.com> References: <478231340904021724mf465284mde22bcf2dacd30df@mail.gmail.com> <5E2DDE76-824F-408A-A63C-383329B390BC@gmail.com> Message-ID: <29bf512f0904021933n4db0e2daya99344f9c7303f4e@mail.gmail.com> 2009/4/3 Duane Johnson > Perhaps it wouldn't be as all-wonderful as I think, but as a "new" Haskell > user, I am constantly switching back and forth between various definitions > of things trying to compare documentation and files... > The purpose of "expansion" as I was explaining it is not to *permanently > replace* what is in the text, but rather to *temporarily replace* it. I > imagine it kind of like a "zoom in" for code. You could "zoom in" on one > function, and seeing a new function that you don't recognize, "zoom in" > again, and so on. Once done, you would hit "ESC" to make it all return as > it was. > Sounds exactly like the F9 feature in Excel (that's where you got the idea, right?). I can personally attest that it can be an incredibly useful feature. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090403/318d0bfd/attachment.htm From divisortheory at gmail.com Thu Apr 2 22:36:25 2009 From: divisortheory at gmail.com (Zachary Turner) Date: Thu Apr 2 22:23:30 2009 Subject: [Haskell-cafe] Wishful thinking: a text editor that expands function applications into function definitions In-Reply-To: <29bf512f0904021933n4db0e2daya99344f9c7303f4e@mail.gmail.com> References: <478231340904021724mf465284mde22bcf2dacd30df@mail.gmail.com> <5E2DDE76-824F-408A-A63C-383329B390BC@gmail.com> <29bf512f0904021933n4db0e2daya99344f9c7303f4e@mail.gmail.com> Message-ID: <478231340904021936y5d16122elfe4017cc8965a407@mail.gmail.com> On Thu, Apr 2, 2009 at 9:33 PM, Michael Snoyman wrote: > > > 2009/4/3 Duane Johnson > >> Perhaps it wouldn't be as all-wonderful as I think, but as a "new" Haskell >> user, I am constantly switching back and forth between various definitions >> of things trying to compare documentation and files... >> The purpose of "expansion" as I was explaining it is not to *permanently >> replace* what is in the text, but rather to *temporarily replace* it. I >> imagine it kind of like a "zoom in" for code. You could "zoom in" on one >> function, and seeing a new function that you don't recognize, "zoom in" >> again, and so on. Once done, you would hit "ESC" to make it all return as >> it was. >> > > Sounds exactly like the F9 feature in Excel (that's where you got the idea, > right?). I can personally attest that it can be an incredibly useful > feature. > > Michael > > I actually wasn't thinking about temporarily replacing it. That sounds cooler than how I originally interpreted it :) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090402/8613e6eb/attachment.htm From michael at snoyman.com Fri Apr 3 00:00:58 2009 From: michael at snoyman.com (Michael Snoyman) Date: Thu Apr 2 23:48:06 2009 Subject: [Haskell-cafe] List and description of language extensions Message-ID: <29bf512f0904022100y19822c30n98a10e75b5868815@mail.gmail.com> It's been multiple times now that I've been confounded by something in Haskell which was then solved by a language extension (first FunctionalDependencies, most recently ScopedTypeVariables). I'm wondering if there is a list anywhere of all the language extensions supported by GHC and a brief description of them. I looked around, but couldn't find one. If there isn't one, would others be willing to fill one in on the Haskell wiki? I'll do what I can, but I obviously have a very limited knowledge of the extensions available. Thanks, Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090402/a9daf87f/attachment.htm From duane.johnson at gmail.com Fri Apr 3 00:07:53 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Thu Apr 2 23:55:03 2009 Subject: [Haskell-cafe] Wishful thinking: a text editor that expands function applications into function definitions In-Reply-To: <29bf512f0904021933n4db0e2daya99344f9c7303f4e@mail.gmail.com> References: <478231340904021724mf465284mde22bcf2dacd30df@mail.gmail.com> <5E2DDE76-824F-408A-A63C-383329B390BC@gmail.com> <29bf512f0904021933n4db0e2daya99344f9c7303f4e@mail.gmail.com> Message-ID: I hadn't seen that feature in Excel before. When I press F9 it seems to evaluate the expression, which isn't quite what I had in mind (Mac OS). Is that the same as what you get? Duane On Apr 2, 2009, at 8:33 PM, Michael Snoyman wrote: > > > 2009/4/3 Duane Johnson > Perhaps it wouldn't be as all-wonderful as I think, but as a "new" > Haskell user, I am constantly switching back and forth between > various definitions of things trying to compare documentation and > files... > > The purpose of "expansion" as I was explaining it is not to > *permanently replace* what is in the text, but rather to > *temporarily replace* it. I imagine it kind of like a "zoom in" for > code. You could "zoom in" on one function, and seeing a new > function that you don't recognize, "zoom in" again, and so on. Once > done, you would hit "ESC" to make it all return as it was. > > Sounds exactly like the F9 feature in Excel (that's where you got > the idea, right?). I can personally attest that it can be an > incredibly useful feature. > > Michael > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090402/560e5346/attachment.htm From allbery at ece.cmu.edu Fri Apr 3 00:16:56 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Apr 3 00:04:14 2009 Subject: [Haskell-cafe] List and description of language extensions In-Reply-To: <29bf512f0904022100y19822c30n98a10e75b5868815@mail.gmail.com> References: <29bf512f0904022100y19822c30n98a10e75b5868815@mail.gmail.com> Message-ID: <23CA07FC-6104-4F5D-93A8-6D7F302E2F39@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/20090403/044661a2/PGP.bin From s.clover at gmail.com Fri Apr 3 00:28:11 2009 From: s.clover at gmail.com (Sterling Clover) Date: Fri Apr 3 00:12:55 2009 Subject: [Haskell-cafe] Program using 500MB RAM to process 5MB file In-Reply-To: <7ca3f0160904021908l65fd8bd7of7c4ab72e437d92d@mail.gmail.com> References: <20090402230642.GA12413@die.net.au> <7ca3f0160904021908l65fd8bd7of7c4ab72e437d92d@mail.gmail.com> Message-ID: I also suspect that manyTill is a really bad choice, since it doesn't give you anything until the end token. It would be much better if you could rewrite your parser in terms of many and many1. --Sterl On Apr 2, 2009, at 10:08 PM, Luke Palmer wrote: > 2009/4/2 > I'm relatively new to haskell so as one does, I am rewriting an > existing program in haskell to help learn the language. > > However, it eats up all my RAM whenever I run the program. > > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3175#a3175 > > Obviously I'm doing something wrong, but without my magical FP pants I > don't know what that might be. > > (1) You are using plain Strings. Those things are like 8 bytes per > character (or something, someone more knowledgeable can give a more > accurate figure). Use bytestrings (with bytestring-utf8 if you > need it) instead. > > (2) You are parsing strictly, meaning you have to read the whole > input file before anything can be output. This may be necessary > for your application, but Haskell is very strong with streaming > applications. Change to a lazy parser and you will run in constant > memory. > > (I don't know offhand of any lazy parsing libraries, but I've heard > them discussed before, so they're somewhere) > > Luke > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From murray at sonology.net Fri Apr 3 00:32:02 2009 From: murray at sonology.net (Murray) Date: Fri Apr 3 00:19:16 2009 Subject: [Haskell-cafe] Loading C object files into ghci Message-ID: <200904030432.n334WAaW003510@fiennes-ds.lumison.net> Hi Cafe, A quick question: Is there a way to load a C object file associated with FFI imports into ghci after invocation (or in a .ghci file)? I've checked the docs as carefully as I can and can't find anything. Naming the file on the command line works of course but I was hoping for something I could keep in a per-directory .ghci file so that emacs and yi interactive modes work properly. I know I can (setq haskell-program-name "ghci /long/path/to/my/project/build/dist/.../blah.o") for emacs but I think it's hard-coded in yi. Sorry if this is obvious, or a FAQ. Murray. From dagit at codersbase.com Fri Apr 3 00:48:00 2009 From: dagit at codersbase.com (Jason Dagit) Date: Fri Apr 3 00:35:05 2009 Subject: [Haskell-cafe] Program using 500MB RAM to process 5MB file In-Reply-To: <20090403015658.GB12413@die.net.au> References: <20090402230642.GA12413@die.net.au> <9810b81b0904021655g14fff277pf377698e33e0c491@mail.gmail.com> <20090403015658.GB12413@die.net.au> Message-ID: 2009/4/2 : > On Thu, Apr 02, 2009 at 07:55:07PM -0400, Rick R wrote: >> You could profile your app for memory usage. Then you could figure out just >> what function is blowing up the mem usage and figure out how to optimize it. >> >> >> http://book.realworldhaskell.org/read/profiling-and-optimization.html >> >> >> 2009/4/2 >> >> > I'm relatively new to haskell so as one does, I am rewriting an >> > existing program in haskell to help learn the language. >> > >> > However, it eats up all my RAM whenever I run the program. >> > >> > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3175#a3175 >> > >> > Obviously I'm doing something wrong, but without my magical FP pants I >> > don't know what that might be. >> > > > I ran some profiling as suggested, > > [SNIP] > > total time ?= ? ? ? ?8.36 secs ? (418 ticks @ 20 ms) > total alloc = 3,882,593,720 bytes ?(excludes profiling overheads) > > COST CENTRE ? ? ? ? ? ? ? ? ? ?MODULE ? ? ? ? ? ? ? %time %alloc > > line ? ? ? ? ? ? ? ? ? ? ? ? ? PkgDb ? ? ? ? ? ? ? ? 89.7 ? 93.5 > > COST CENTRE MODULE no. entries %time %alloc %time %alloc > line ? ? ? ?PkgDb ?305 109771 ?89.7 ?93.3 ? 89.7 ?93.3 > > [SNIP] > > The line function is part of the file parser > > line :: Parser String > line = anyChar `manyTill` newline > > files' :: Parser Files > files' = line `manyTill` newline > > Perhaps I should also explain the structure of the file. It's for a > simple package manager called pkgutils, used for CRUX[1]. The file > contains information for all the packages installed and is structured > as follows > > > > > > ... > > > > ... > > From profiling it shows that the memory is simple consumed by reading > in all the lines, the graph from using -p -hd shows an almost Ologn2 > growth of the heap as the collection of lines grows. > > Is there a better way to do this? In this case the syntax of your file seems pretty simple. Someone else suggested a streaming approach. Putting those ideas together, I defined testInput as follows: testInput = "\n" ++"\n" ++"\n" ++"\n" ++"...\n" ++"\n" ++"\n" ++"\n" ++"...\n" Here is an interactive experiment I tried: GHCi> :t lines lines :: String -> [String] GHCi> lines testInput ["","","","","...","","","","..."] Okay, looks we can use 'lines' from the Prelude to split the input into lines. GHCi> :t cycle cycle :: [a] -> [a] GHCi> :t cycle testInput cycle testInput :: [Char] Using cycle on the testInput like this will give us an infinite input that we can use to see if we have a streaming approach. GHCi> take 10 $ lines $ cycle testInput ["","","","","...","","","","...",""] Success. So if you like, you could use something like hGetContents that reads a file lazily, run lines over the file and get a lazy stream of the file lines. Then you can use something like takeWhile to take lines until you hit an empty line to build up your parsing functions. You could experiment with bytestrings, but in this particular application I wouldn't expect to see a huge benefit. Here I think you can run in space proportional to the longest list of files that you encounter in the input. Hope that helps, Jason From michael at snoyman.com Fri Apr 3 01:01:55 2009 From: michael at snoyman.com (Michael Snoyman) Date: Fri Apr 3 00:49:02 2009 Subject: [Haskell-cafe] Wishful thinking: a text editor that expands function applications into function definitions In-Reply-To: References: <478231340904021724mf465284mde22bcf2dacd30df@mail.gmail.com> <5E2DDE76-824F-408A-A63C-383329B390BC@gmail.com> <29bf512f0904021933n4db0e2daya99344f9c7303f4e@mail.gmail.com> Message-ID: <29bf512f0904022201r336b0d9bx806fe5af725b8cd9@mail.gmail.com> On Fri, Apr 3, 2009 at 7:07 AM, Duane Johnson wrote: > I hadn't seen that feature in Excel before. When I press F9 it seems to > evaluate the expression, which isn't quite what I had in mind (Mac OS). Is > that the same as what you get? > Duane > Yeah, it's the same feature. It's just that in Excel, the functions always return a value, not an expression. For example, a VLOOKUP doesn't call other Excel functions to return the result, it simply calculates what you're looking for. Hope that made sense. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090403/ac3b558a/attachment.htm From hrushikesh.til.ak at gmail.com Fri Apr 3 02:11:20 2009 From: hrushikesh.til.ak at gmail.com (Hrushikesh Tilak) Date: Fri Apr 3 01:58:40 2009 Subject: [Haskell-cafe] Wrappers, API's for Web Apps - Google Summer of Code Message-ID: <5940269c0904022311k29067b24pc7346f19c17ba276@mail.gmail.com> Hi, I am interested in participating in this year's Google Summer of Code. One of my proposals is going to be to write and extend existing Haskell wrappers and API's for web services. Some of the popular web services that I use are Google Maps, Flickr, digg, reddit, Facebook and twitter, Quick google searches reveal that great haskell tools already exist for twitter, while there is an ongoing project for a Facebook API by Jeremy Shaw. I couldn't find any haskell projects for the other tools. I find this project interesting primarily because I use these tools and would like to have haskell interfaces to them. Along with tools like Happstack, these interfaces would extend the power of haskell for developing Web 2.0 apps and mashups. I would like to enquire about the community's opinions and interests in such a project. I would also appreciate any suggestions either pertaining to any other web services. I have created a ticket at http://hackage.haskell.org/trac/summer-of-code/ticket/1578 Thanks, Hrushikesh Tilak From oleg at okmij.org Fri Apr 3 02:22:34 2009 From: oleg at okmij.org (oleg@okmij.org) Date: Fri Apr 3 02:12:37 2009 Subject: [Haskell-cafe] Problem with prepose.lhs and ghc6.10.1 Message-ID: <20090403062234.3A90DAF98@Adric.metnet.fnmoc.navy.mil> > ../haskell/prepose.lhs:707:0: Parse error in pattern > which is pointing at: > normalize a :: M s a = M (mod a (modulus (undefined :: s))) The code indeed used lexically scoped type variables -- which GHC at that time implemented differently. Incidentally, on the above line, M s a is the type annotation on the result of (normalize a) rather than on the argument 'a'. Therefore, putting a parentheses like (a :: M s a) is wrong. Since the implementation of local type variables in GHC changed over the years, it's best to get rid of them. Here is the same line in the Hugs version of the code > normalize :: (Modular s a, Integral a) => a -> M s a > normalize a = r a __ > where > r :: (Modular s a, Integral a) => a -> s -> M s a > r a s = M (mod a (modulus s)) Of course the signature for normalize can be omitted. Hugs did not support lexically scoped type variables then (and probably doesn't support now). Today I would have written this definition simpler: > normalize :: (Modular s a, Integral a) => a -> M s a > normalize a = r > where r = M (mod a (modulus (tcar2 r))) > > tcar2:: f s x -> s > tcar2 = undefined (the function tcar2 is used in a few other places in the Hugs code, for a similar purpose). From simon at joyful.com Fri Apr 3 02:26:36 2009 From: simon at joyful.com (Simon Michael) Date: Fri Apr 3 02:13:45 2009 Subject: [Haskell-cafe] ANN: hledger 0.4 released Message-ID: Dear all, I have released hledger 0.4 on hackage. There is also a new website at http://hledger.org , with screenshots (textual!), a demo (will it survive!?), and docs (not too many!) Release notes are at http://hledger.org/NEWS , and bravely pasted below. In case you forgot: hledger is a text-mode double-entry accounting tool. It reads a plain text journal file describing your transactions and generates precise activity and balance reports. I use it every day to track money and time, and as the basis for client invoices and tax returns. hledger is a partial clone, in haskell, of John Wiegley's excellent ledger. I wrote it because I did not want to hack on c++ and because haskell seemed a good fit. Please cabal update and cabal install hledger and give it a whirl. Install with the "-f happs" flag to enable the new happstack-based web interface. I am sm on the #ledger channel on freenode, and I welcome your feedback, especially if you notice a problem. Best - Simon ------------------------------------------------- 2009/04/03 hledger 0.4 released Changes: * new "web" command serves reports in a web browser (install with -f happs to build this) * make the vty-based curses ui a cabal build option, which will be ignored on MS windows * drop the --options-anywhere flag, that is now the default * patterns now use not: and desc: prefixes instead of ^ and ^^ * patterns are now case-insensitive, like ledger * !include directives are now relative to the including file (Tim Docker) * "Y2009" default year directives are now supported, allowing m/d dates in ledger * individual transactions now have a cleared status * unbalanced entries now cause a proper warning * balance report now passes all ledger compatibility tests * balance report now shows subtotals by default, like ledger 3 * balance report shows the final zero total when -E is used * balance report hides the final total when --no-total is used * --depth affects print and register reports (aggregating with a reporting interval, filtering otherwise) * register report sorts transactions by date * register report shows zero-amount transactions when -E is used * provide more convenient timelog querying when invoked as "hours" * multi-day timelog sessions are split at midnight * unterminated timelog sessions are now counted. Accurate time reports at last! * the test command gives better --verbose output * --version gives more detailed version numbers including patchlevel for dev builds * new make targets include: ghci, haddocktest, doctest, unittest, view-api-docs * a doctest-style framework for functional/shell tests has been added * performance has decreased slightly: || hledger-0.3 | hledger-0.4 | ledger-0.3 ==============================++========== -f sample.ledger balance || 0.02 | 0.01 | 0.07 -f sample1000.ledger balance || 1.02 | 1.39 | 0.53 -f sample10000.ledger balance || 12.72 | 14.97 | 4.63 Contributors: * Simon Michael * Tim Docker * HAppS, happstack and testpack developers Stats: * Known errors: 0 * Commits: 132 * Committers: 2 * Tests: 56 * Non-test code lines: 2600 * Days since release: 75 From claus.reinke at talk21.com Fri Apr 3 03:54:04 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Fri Apr 3 03:41:14 2009 Subject: [Haskell-cafe] Problem with prepose.lhs and ghc6.10.1 References: <20090403062234.3A90DAF98@Adric.metnet.fnmoc.navy.mil> Message-ID: > Hugs did not support lexically scoped type variables then (and > probably doesn't support now). I may be misremembering, but I think Hugs had them first;-) http://cvs.haskell.org/Hugs/pages/hugsman/exts.html#sect7.3.3 It is just that Hugs and GHC interpret the language extension differently (as usual), so it doesn't quite support the same code in both. That is made worse by differences in other language features relevant to using this extension. Not to mention that all of that keeps evolving over time. Claus From ketil at malde.org Fri Apr 3 04:22:07 2009 From: ketil at malde.org (Ketil Malde) Date: Fri Apr 3 04:08:08 2009 Subject: [Haskell-cafe] Program using 500MB RAM to process 5MB file In-Reply-To: <20090402230642.GA12413@die.net.au> (lucas@die.net.au's message of "Fri\, 3 Apr 2009 10\:06\:43 +1100") References: <20090402230642.GA12413@die.net.au> Message-ID: <871vsatads.fsf@malde.org> lucas@die.net.au writes: > I'm relatively new to haskell so as one does, I am rewriting an > existing program in haskell to help learn the language. > However, it eats up all my RAM whenever I run the program. This typically happens to me when I parse large files and either am a) using a parser that is too strict (like Luke says) or b) using a parser that is too lazy - or rather, it parses into a lazy data structure which is then populated with unevaluated thunks holding onto the input data. Also, you probably want memory profiling (+RTS -h and friends), not time profiling (+RTS -p). -k -- If I haven't seen further, it is by standing in the footprints of giants From Malcolm.Wallace at cs.york.ac.uk Fri Apr 3 05:23:35 2009 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Fri Apr 3 05:15:36 2009 Subject: [Haskell-cafe] Re: Reverting to any old version using Darcs In-Reply-To: References: <20090401171436.GA12860@whirlpool.galois.com> <873acsxi3y.fsf@malde.org> <20090401202953.GK12860@whirlpool.galois.com> <87wsa3uzjz.fsf@malde.org> Message-ID: <20090403102335.352e9e70.Malcolm.Wallace@cs.york.ac.uk> > > Thus the uploaded sdist was missing one of the source files, and > > consequently failed to build. > > I have a pre-release make target where I test everything I can think > of. I think it prevents the above, am I right ? Not unless you run 'make check' in a separate pristine copy of the repo. The problem occurs when your local development repo contains some essential files that have not been checked into the VCS. Your 'make check' will work fine for you, but not for other people. Regards, Malcolm From Malcolm.Wallace at cs.york.ac.uk Fri Apr 3 05:35:35 2009 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Fri Apr 3 05:25:41 2009 Subject: [Haskell-cafe] Program using 500MB RAM to process 5MB file In-Reply-To: References: <20090402230642.GA12413@die.net.au> <7ca3f0160904021908l65fd8bd7of7c4ab72e437d92d@mail.gmail.com> Message-ID: <20090403103535.2a85c3f7.Malcolm.Wallace@cs.york.ac.uk> > > (2) You are parsing strictly, meaning you have to read the whole > > input file before anything can be output. This is likely the main performance problem. I'm guessing you are using parsec. Try switching to polyparse if you want to try out lazy parser combinators instead. (module Text.ParserCombinators.Poly.Lazy) http://www.cs.york.ac.uk/fp/polyparse/ There are other incremental parsers out there too, although they may be more complicated because they solve a larger problem: http://yi-editor.blogspot.com/2008/11/incremental-parsing-in-yi.html > I also suspect that manyTill is a really bad choice, since it doesn't > give you anything until the end token. This is not an "also" - it is the same problem of too much strictness. Polyparse's combinator 'manyFinally' is the corresponding combinator that works lazily if you want it to. Regards, Malcolm From claus.reinke at talk21.com Fri Apr 3 06:30:42 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Fri Apr 3 06:17:57 2009 Subject: [Haskell-cafe] Wishful thinking: a text editor that expands function applications into function definitions References: <478231340904021724mf465284mde22bcf2dacd30df@mail.gmail.com> Message-ID: One word says more than a thousand pictures: Vim . (well, okay, I'm sure Emacs will do just as well, and some of the more recent IDEs seem to be catching up;-) plus plugins, of course!-) - unfolding definitions: if you really want that, it is in the domain of program transformation systems and refactorers (HaRe, the Haskell refactorer, has been mentioned - it worked on Haskell'98 sources, plugging into Vim or Emacs; it would really be great to have funding for porting that to a modern GHC/Cabal-based environment, but if you're happy with Haskell'98, and have all the sources, the old HaRe should still do the job once you get it to build with recent GHCs/libraries) - looking up definitions: that is supported in various ways in Vim/Emacs and the like - I'll talk about some Vim examples, as that is what I use. - tag files (generated by running tools like 'ghc -e :ctags', hasktags,.. over the sources) are a simple database linking identifiers to definition sites. Based on these, one can jump from identifiers to definitions (keeping a stack of locations, so one can go back easily), or open split windows on the definition sites. See the "Moving through programs" section in Vim's help, also online at: http://vimdoc.sourceforge.net/htmldoc/usr_29.html . - the haskellmode plugins for Vim support documentation lookup (opening the haddocs for the identifier under cursor in a browser), and the documentation provides source links, if the docs themselves aren't sufficient. Useful for all those sourceless package installations. - the haskellmode plugins also support type tooltips (or, if you don't like tooltips, or are working in a terminal without gui, type signatures can be displayed in the status line, or added to the source code). This is currently based on GHCi's :browse!, though, so you can only get the types of toplevel definitions that way. One of the insertmode completions also displays types. - if you explain Haskell's import syntax to Vim, you can also search in (local) imported files, using Vim's standard keyword search, for instance ([I). The haskellmode plugins for Vim are currently in the process of moving to http://projects.haskell.org/haskellmode-vim/ . Which made me notice that I hadn't updated the publicly available version in quite some time (announcement to follow when that process has settled down somewhat). Claus From waldmann at imn.htwk-leipzig.de Fri Apr 3 06:47:31 2009 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Fri Apr 3 06:34:42 2009 Subject: [Haskell-cafe] how to upgrade? Message-ID: <49D5E943.2020005@imn.htwk-leipzig.de> Is there a nice way of upgrading ghc: I mean does cabal-upgrade know to install exactly the packages that I had with the previous ghc version? - J.W. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 257 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090403/f9b3d101/signature.bin From lucas at die.net.au Fri Apr 3 07:27:08 2009 From: lucas at die.net.au (lucas@die.net.au) Date: Fri Apr 3 07:14:19 2009 Subject: [Haskell-cafe] Program using 500MB RAM to process 5MB file In-Reply-To: <871vsatads.fsf@malde.org> References: <20090402230642.GA12413@die.net.au> <871vsatads.fsf@malde.org> Message-ID: <20090403112707.GC12413@die.net.au> On Fri, Apr 03, 2009 at 10:22:07AM +0200, Ketil Malde wrote: > lucas@die.net.au writes: > > > I'm relatively new to haskell so as one does, I am rewriting an > > existing program in haskell to help learn the language. > > > However, it eats up all my RAM whenever I run the program. > > This typically happens to me when I parse large files and either am a) > using a parser that is too strict (like Luke says) or b) using a > parser that is too lazy - or rather, it parses into a lazy data > structure which is then populated with unevaluated thunks holding onto > the input data. > Thanks for all the help everyone . I've decided to dump Parsec, as the file structure is simple enough to implement using basic list manipulation (which is, I've read, one of haskell's strong points) and has turned out to be much simpler code. I think I was reading the write your own scheme tutorial when I started writing that code, so natually started using parsec. As a side note, I was reading the I/O section of RWH last night and came across the lazy vs. strict I/O part, however it didn't occur to me that Parsec was strict. Anyway, thanks for all the help and suggestions. -- Lucas Hazel -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090403/4cfee7b8/attachment.bin From bugfact at gmail.com Fri Apr 3 07:32:02 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Apr 3 07:19:07 2009 Subject: [Haskell-cafe] Re: Reverting to any old version using Darcs In-Reply-To: <20090403102335.352e9e70.Malcolm.Wallace@cs.york.ac.uk> References: <20090401171436.GA12860@whirlpool.galois.com> <873acsxi3y.fsf@malde.org> <20090401202953.GK12860@whirlpool.galois.com> <87wsa3uzjz.fsf@malde.org> <20090403102335.352e9e70.Malcolm.Wallace@cs.york.ac.uk> Message-ID: Regarding these files that people forget to checkin. Doesn't every project have a well define directory structure? Shouldn't the "prefs/boring" file use this fact to encapsulate the rules of file inclusion and exclusion? Isn't it safer to checkin too many files (by accident) than forgetting one? Shouldn't this behavior be the default? To me version control also means "if it works on my machine, it should work on all other peoples machines after they are in synch". Of course in reality people can also have different environment variables, different versions of operating systems, different hardware, etc so this idea certainly is utopia (however the version control system "VESTA " tried to version everything, they even considered versioning the operating system :-) On Fri, Apr 3, 2009 at 11:23 AM, Malcolm Wallace < Malcolm.Wallace@cs.york.ac.uk> wrote: > > > Thus the uploaded sdist was missing one of the source files, and > > > consequently failed to build. > > > > I have a pre-release make target where I test everything I can think > > of. I think it prevents the above, am I right ? > > Not unless you run 'make check' in a separate pristine copy of the repo. > > The problem occurs when your local development repo contains some > essential files that have not been checked into the VCS. Your 'make > check' will work fine for you, but not for other people. > > Regards, > Malcolm > _______________________________________________ > 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/20090403/f374c795/attachment.htm From michael at snoyman.com Fri Apr 3 07:47:12 2009 From: michael at snoyman.com (Michael Snoyman) Date: Fri Apr 3 07:34:17 2009 Subject: [Haskell-cafe] List and description of language extensions In-Reply-To: <23CA07FC-6104-4F5D-93A8-6D7F302E2F39@ece.cmu.edu> References: <29bf512f0904022100y19822c30n98a10e75b5868815@mail.gmail.com> <23CA07FC-6104-4F5D-93A8-6D7F302E2F39@ece.cmu.edu> Message-ID: <29bf512f0904030447i48b76cd5l3f6717198ae04f1d@mail.gmail.com> On Fri, Apr 3, 2009 at 7:16 AM, Brandon S. Allbery KF8NH < allbery@ece.cmu.edu> wrote: > On 2009 Apr 3, at 0:00, Michael Snoyman wrote: > > It's been multiple times now that I've been confounded by something in > Haskell which was then solved by a language extension (first > FunctionalDependencies, most recently ScopedTypeVariables). I'm wondering if > there is a list anywhere of all the language extensions supported by GHC and > a brief description of them. I looked around, but couldn't find one. If > there isn't one, would others be willing to fill one in on the Haskell wiki? > I'll do what I can, but I obviously have a very limited knowledge of the > extensions available. > > > > http://www.haskell.org/ghc/docs/latest/html/users_guide/ghc-language-features.html > Thanks, that's what I was looking for. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090403/b2111853/attachment-0001.htm From lucas at die.net.au Fri Apr 3 08:32:10 2009 From: lucas at die.net.au (lucas@die.net.au) Date: Fri Apr 3 08:19:20 2009 Subject: [Haskell-cafe] Program using 500MB RAM to process 5MB file In-Reply-To: <20090403112707.GC12413@die.net.au> References: <20090402230642.GA12413@die.net.au> <871vsatads.fsf@malde.org> <20090403112707.GC12413@die.net.au> Message-ID: <20090403123209.GD12413@die.net.au> On Fri, Apr 03, 2009 at 10:27:08PM +1100, lucas@die.net.au wrote: > On Fri, Apr 03, 2009 at 10:22:07AM +0200, Ketil Malde wrote: > > lucas@die.net.au writes: > > > > > I'm relatively new to haskell so as one does, I am rewriting an > > > existing program in haskell to help learn the language. > > > > > However, it eats up all my RAM whenever I run the program. > > > > Thanks for all the help everyone . I've decided to dump Parsec, as the file > structure is simple enough to implement using basic list manipulation > (which is, I've read, one of haskell's strong points) and has turned > out to be much simpler code. > Using lazy I/O has reduced run time by 75% and RAM consumption to 3MB Thank you :) -- Lucas Hazel -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090403/512defac/attachment.bin From ketil at malde.org Fri Apr 3 09:18:18 2009 From: ketil at malde.org (Ketil Malde) Date: Fri Apr 3 09:04:17 2009 Subject: [Haskell-cafe] Re: Reverting to any old version using Darcs In-Reply-To: (Peter Verswyvelen's message of "Fri\, 3 Apr 2009 13\:32\:02 +0200") References: <20090401171436.GA12860@whirlpool.galois.com> <873acsxi3y.fsf@malde.org> <20090401202953.GK12860@whirlpool.galois.com> <87wsa3uzjz.fsf@malde.org> <20090403102335.352e9e70.Malcolm.Wallace@cs.york.ac.uk> Message-ID: <87iqllri3p.fsf@malde.org> Peter Verswyvelen writes: > Regarding these files that people forget to checkin. > Doesn't every project have a well define directory structure? Shouldn't the > "prefs/boring" file use this fact to encapsulate the rules of file inclusion > and exclusion? Isn't it safer to checkin too many files (by accident) than > forgetting one? Shouldn't this behavior be the default? IMO: No. My development directories tend to litter up with files containing test input data, output data, profiling data, and all kinds of junk. Better to occasionally forget a file and get an error message in the mail when somebody else tries to use it (i.e. non-strictly) than have my darcs repository and Hackage sdists working but littered with junk. (My current testing involves 118GB of input data, you sure you want to see that on Hackage? :-) -k -- If I haven't seen further, it is by standing in the footprints of giants From leather at cs.uu.nl Fri Apr 3 09:46:06 2009 From: leather at cs.uu.nl (Sean Leather) Date: Fri Apr 3 09:33:25 2009 Subject: [Haskell-cafe] List and description of language extensions In-Reply-To: <29bf512f0904030447i48b76cd5l3f6717198ae04f1d@mail.gmail.com> References: <29bf512f0904022100y19822c30n98a10e75b5868815@mail.gmail.com> <23CA07FC-6104-4F5D-93A8-6D7F302E2F39@ece.cmu.edu> <29bf512f0904030447i48b76cd5l3f6717198ae04f1d@mail.gmail.com> Message-ID: <3c6288ab0904030646u3c8c8e2audce214bb093a394@mail.gmail.com> > It's been multiple times now that I've been confounded by something in >> Haskell which was then solved by a language extension (first >> FunctionalDependencies, most recently ScopedTypeVariables). I'm wondering if >> there is a list anywhere of all the language extensions supported by GHC and >> a brief description of them. I looked around, but couldn't find one. If >> there isn't one, would others be willing to fill one in on the Haskell wiki? >> I'll do what I can, but I obviously have a very limited knowledge of the >> extensions available. >> >> >> >> http://www.haskell.org/ghc/docs/latest/html/users_guide/ghc-language-features.html >> > > Thanks, that's what I was looking for. > Also: $ ghc --supported-languages or $ ghc --supported-languages | sort There's no description, but it's useful for a quick look-up and/or a copy-and-paste. Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090403/591b4124/attachment.htm From bugfact at gmail.com Fri Apr 3 09:51:49 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Apr 3 09:38:54 2009 Subject: [Haskell-cafe] Re: Reverting to any old version using Darcs In-Reply-To: <87iqllri3p.fsf@malde.org> References: <873acsxi3y.fsf@malde.org> <20090401202953.GK12860@whirlpool.galois.com> <87wsa3uzjz.fsf@malde.org> <20090403102335.352e9e70.Malcolm.Wallace@cs.york.ac.uk> <87iqllri3p.fsf@malde.org> Message-ID: Okay. I always put these in the boring file. Matter of taste I guess. On Fri, Apr 3, 2009 at 3:18 PM, Ketil Malde wrote: > Peter Verswyvelen writes: > > > Regarding these files that people forget to checkin. > > Doesn't every project have a well define directory structure? Shouldn't > the > > "prefs/boring" file use this fact to encapsulate the rules of file > inclusion > > and exclusion? Isn't it safer to checkin too many files (by accident) > than > > forgetting one? Shouldn't this behavior be the default? > > IMO: No. My development directories tend to litter up with files > containing test input data, output data, profiling data, and all kinds > of junk. Better to occasionally forget a file and get an error > message in the mail when somebody else tries to use it > (i.e. non-strictly) than have my darcs repository and Hackage sdists > working but littered with junk. (My current testing involves 118GB of > input data, you sure you want to see that on Hackage? :-) > > -k > -- > If I haven't seen further, it is by standing in the footprints of giants > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090403/19dcf21b/attachment.htm From ekmett at gmail.com Fri Apr 3 10:26:26 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Apr 3 10:13:30 2009 Subject: [Haskell-cafe] ANNOUNCE: fad 1.0 -- Forward Automatic Differentiation library In-Reply-To: <8b2a1a960904021928s2c44abb2g63143aa9823cc1ae@mail.gmail.com> References: <8b2a1a960904021928s2c44abb2g63143aa9823cc1ae@mail.gmail.com> Message-ID: <7fb8f82f0904030726v10fd37bep3bfdcb61cc5c62eb@mail.gmail.com> Very nice to have! FYI- there is at least one more quantification-based automatic differentiation implementation in Hackage: http://comonad.com/haskell/monoids/dist/doc/html/monoids/Data-Ring-Module-AutomaticDifferentiation.html My implementation is/was focused upon use with monoids and other more-limited-than-Num classes and only included the equivalent of your 'lift' and 'diffUU' operations, however. -Edward Kmett On Thu, Apr 2, 2009 at 10:28 PM, Bjorn Buckwalter < bjorn.buckwalter@gmail.com> wrote: > I'm pleased to announce the initial release of the Haskell fad > library, developed by Barak A. Pearlmutter and Jeffrey Mark Siskind. > Fad provides Forward Automatic Differentiation (AD) for functions > polymorphic over instances of 'Num'. There have been many Haskell > implementations of forward AD, with varying levels of completeness, > published in papers and blog posts[1], but alarmingly few of these > have made it into hackage -- to date Conal Elliot's vector-spaces[2] > package is the only one I am aware of. > > Fad is an attempt to make as comprehensive and usable a forward AD > package as is possible in Haskell. However, correctness is given > priority over ease of use, and this is in my opinion the defining > quality of fad. Specifically, Fad leverages Haskell's expressive > type system to tackle the problem of _perturbation confusion_, > brought to light in Pearlmutter and Siskind's 2005 paper "Perturbation > Confusion and Referential Transparency"[3]. Fad prevents perturbation > confusion by employing type-level "branding" as proposed by myself > in a 2007 post to haskell-cafe[4]. To the best of our knowledge all > other forward AD implementations in Haskell are susceptible to > perturbation confusion. > > As this library has been in the works for quite some time it is > worth noting that it hasn't benefited from Conal's ground-breaking > work[5] in the area. Once we wrap our heads around his beautiful > constructs perhaps we'll be able to borrow some tricks from him. > > As mentioned already, fad was developed primarily by Barak A. > Pearlmutter and Jeffrey Mark Siskind. My own contribution has been > providing Haskell infrastructure support and wrapping up loose ends > in order to get the library into a releasable state. Many thanks > to Barak and Jeffrey for permitting me to release fad under the BSD > license. > > Fad resides on GitHub[6] and hackage[7] and is only a "cabal install > fad" away! What follows is Fad's README, refer to the haddocks for > detailed documentation. > > Thanks, > Bjorn Buckwalter > > > [1] http://www.haskell.org/haskellwiki/Functional_differentiation > [2] http://www.haskell.org/haskellwiki/Vector-space > [3]: http://www.bcl.hamilton.ie/~qobi/nesting/papers/ifl2005.pdf > [4]: http://thread.gmane.org/gmane.comp.lang.haskell.cafe/22308/ > [5]: http://conal.net/papers/beautiful-differentiation/ > [6] http://github.com/bjornbm/fad/ > [7] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/fad > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Copyright : 2008-2009, Barak A. Pearlmutter and Jeffrey Mark Siskind > License : BSD3 > > Maintainer : bjorn.buckwalter@gmail.com > Stability : experimental > Portability: GHC only? > > Forward Automatic Differentiation via overloading to perform > nonstandard interpretation that replaces original numeric type with > corresponding generalized dual number type. > > Each invocation of the differentiation function introduces a > distinct perturbation, which requires a distinct dual number type. > In order to prevent these from being confused, tagging, called > branding in the Haskell community, is used. This seems to prevent > perturbation confusion, although it would be nice to have an actual > proof of this. The technique does require adding invocations of > lift at appropriate places when nesting is present. > > For more information on perturbation confusion and the solution > employed in this library see: > > > > > Installation > ============ > To install: > cabal install > > Or: > runhaskell Setup.lhs configure > runhaskell Setup.lhs build > runhaskell Setup.lhs install > > > Examples > ======== > Define an example function 'f': > > > import Numeric.FAD > > f x = 6 - 5 * x + x ^ 2 -- Our example function > > Basic usage of the differentiation operator: > > > y = f 2 -- f(2) = 0 > > y' = diff f 2 -- First derivative f'(2) = -1 > > y'' = diff (diff f) 2 -- Second derivative f''(2) = 2 > > List of derivatives: > > > ys = take 3 $ diffs f 2 -- [0, -1, 2] > > Example optimization method; find a zero using Newton's method: > > > y_newton1 = zeroNewton f 0 -- converges to first zero at 2.0. > > y_newton2 = zeroNewton f 10 -- converges to second zero at 3.0. > > > Credits > ======= > Authors: Copyright 2008, > Barak A. Pearlmutter & > Jeffrey Mark Siskind > > Work started as stripped-down version of higher-order tower code > published by Jerzy Karczmarczuk > which used a non-standard standard prelude. > > Initial perturbation-confusing code is a modified version of > > > Tag trick, called "branding" in the Haskell community, from > Bjorn Buckwalter > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > _______________________________________________ > 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/20090403/eaaaf0b4/attachment.htm From ekmett at gmail.com Fri Apr 3 11:18:04 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Apr 3 11:05:08 2009 Subject: [Haskell-cafe] ANNOUNCE: fad 1.0 -- Forward Automatic Differentiation library In-Reply-To: References: <8b2a1a960904021928s2c44abb2g63143aa9823cc1ae@mail.gmail.com> <7fb8f82f0904030726v10fd37bep3bfdcb61cc5c62eb@mail.gmail.com> Message-ID: <7fb8f82f0904030818o1018bfc6xc99568843a30b3e0@mail.gmail.com> A somewhat tricky concern is that that the extra functionality in question depends on a bunch of primitive definitions that lie below this in the package and the AD engine is used by a layer on top. So moving it out would introduce a circular dependency back into the package or require me to stratify into two packages. When I looked into partitioning the package for another reason I found that I couldn't do so without introducing some orphan instances, so it'll probably be a tricky bit of surgery to split out. That said, it's probably still worth doing. I also agree that I should be somewhat more pedantic about the name. =) -Edward Kmett On Fri, Apr 3, 2009 at 10:49 AM, Barak A. Pearlmutter wrote: > I feel silly, did not even notice that! Thanks for the pointer. > > Would be sensible to merge the functionalities; will try to import > functionality in Data.Ring.Module.AutomaticDifferentiation currently > missing from Numeric.FAD. > > (One pedantic note: should really be named > Data.Ring.Module.AutomaticDifferentiation.Forward, since it is doing > forward-mode accumulation automatic differentiation; reverse is > an adjoint kettle of fish.) > -- > Barak A. Pearlmutter > Hamilton Institute & Dept Comp Sci, NUI Maynooth, Co. Kildare, Ireland > http://www.bcl.hamilton.ie/~barak/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090403/1b82d489/attachment.htm From jefferson.r.heard at gmail.com Fri Apr 3 11:46:59 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Fri Apr 3 11:34:02 2009 Subject: [Haskell-cafe] Announcement: Beta of Leksah IDE available In-Reply-To: <22846713.post@talk.nabble.com> References: <1238538058.6785.11.camel@jutaro-laptop> <20090401011918.0a3af602@solaris> <22831401.post@talk.nabble.com> <404396ef0904011047n45f36662yf6fc728097c60f28@mail.gmail.com> <22834510.post@talk.nabble.com> <1238666190.25888.1391.camel@localhost> <49D4AB12.2090100@gmail.com> <22846713.post@talk.nabble.com> Message-ID: <4165d3a70904030846k470e6eb1w10e4851272cc00bc@mail.gmail.com> Jurgen... I have one more question, or rather request... I'm running under Ubuntu, and I get inconsistencies with packages that I build and install via Leksah not showing up when I configure other packages that depend on them. Then I notice that you're using runhaskell Setup.lhs ... to configure build and install. I wonder if you could change all that from "runhaskell Setup.lhs" to "cabal" wherever you run it? That would make things a lot more consistent overall, and probably jive better with the way most people install packages. -- Jeff On Thu, Apr 2, 2009 at 8:27 AM, jutaro wrote: > > Hi Simon, > you quite nicely describe what leksah is doing already. Try to find find the > source code for all installed packages by locating cabal files, parse the > module sources via the Ghc API (actually not so much the API), using info > from cabal files for this (which is a dark art). It extracts comments and > locations. It's quite an ad hoc solution. On my machine it's 97% successful, > but its a notorious support theme, because it depends so much on the > environment. > J?rgen > > > Simon Marlow-7 wrote: >> >> David Waern wrote: >>> 2009/4/2 Duncan Coutts : >>>> On Wed, 2009-04-01 at 22:13 +0200, David Waern wrote: >>>>> 2009/4/1 jutaro : >>>>>> I guess you mean the dialog which should help leksah to find sources >>>>>> for installed packages. It needs this so you can go to all the >>>>>> definitions >>>>>> in the base packages ... This is very handy if it works. Look to the >>>>>> manual >>>>>> for details. >>>>> Maybe could add support to Cabal for installing sources? Should be >>>>> very useful to have in general. >>>> http://hackage.haskell.org/trac/hackage/ticket/364 >>> >>> Jutaru, perhaps a nice Hackathon project? :-) >> >> I think there's some design work to do there. ?See the discussion on the >> GHC ticket: http://hackage.haskell.org/trac/ghc/ticket/2630. >> >> In short: just keeping the source code around isn't enough. ?You need some >> metadata in order to make sense of the source code - for example, you >> can't >> feed the source code to the GHC API without knowing which additional flags >> need to be passed, and those come from the .cabal file. ?Also you probably >> want to stash the results of the 'cabal configure' step so that you can >> get >> a view of the source code that is consistent with the version(s?) you >> compiled. ?We need to think about about backwards and >> forwards-compatibility of whatever metadata format is used. >> >> And then you'll need Cabal APIs to extract the metadata. ?So we need to >> think about what APIs make sense, and the best way to do that is to think >> about what tool(s) you want to write and use that to drive the API design. >> >> Perhaps all this is going a bit too far. ?Maybe we want to just stash the >> source code and accept that there are some things that you just can't do >> with it. ?However, I imagine that pretty soon people will want to feed the >> source code into the GHC API, and at that point we have to tackle the >> build >> metadata issues. >> >> Cheers, >> ? ? ? Simon >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > -- > View this message in context: http://www.nabble.com/Announcement%3A-Beta-of-Leksah-IDE-available-tp22816032p22846713.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 jnf at arcor.de Fri Apr 3 12:25:26 2009 From: jnf at arcor.de (jutaro) Date: Fri Apr 3 12:12:31 2009 Subject: [Haskell-cafe] Announcement: Beta of Leksah IDE available In-Reply-To: <4165d3a70904030846k470e6eb1w10e4851272cc00bc@mail.gmail.com> References: <1238538058.6785.11.camel@jutaro-laptop> <20090401011918.0a3af602@solaris> <22831401.post@talk.nabble.com> <404396ef0904011047n45f36662yf6fc728097c60f28@mail.gmail.com> <22834510.post@talk.nabble.com> <1238666190.25888.1391.camel@localhost> <49D4AB12.2090100@gmail.com> <22846713.post@talk.nabble.com> <4165d3a70904030846k470e6eb1w10e4851272cc00bc@mail.gmail.com> Message-ID: <22871892.post@talk.nabble.com> Hello Jeff, I'm not so shure if I understand what you mean (and I'm off for vacations in a few minute). So lets find out later. But you may try to set the --user to your config flags in menu: Packages/Edit Flags. J?rgen Jeff Heard wrote: > > Jurgen... I have one more question, or rather request... I'm running > under Ubuntu, and I get inconsistencies with packages that I build and > install via Leksah not showing up when I configure other packages that > depend on them. Then I notice that you're using runhaskell Setup.lhs > ... to configure build and install. I wonder if you could change all > that from "runhaskell Setup.lhs" to "cabal" wherever you run it? > That would make things a lot more consistent overall, and probably > jive better with the way most people install packages. > > -- Jeff > > On Thu, Apr 2, 2009 at 8:27 AM, jutaro wrote: >> >> Hi Simon, >> you quite nicely describe what leksah is doing already. Try to find find >> the >> source code for all installed packages by locating cabal files, parse the >> module sources via the Ghc API (actually not so much the API), using info >> from cabal files for this (which is a dark art). It extracts comments and >> locations. It's quite an ad hoc solution. On my machine it's 97% >> successful, >> but its a notorious support theme, because it depends so much on the >> environment. >> J?rgen >> >> >> Simon Marlow-7 wrote: >>> >>> David Waern wrote: >>>> 2009/4/2 Duncan Coutts : >>>>> On Wed, 2009-04-01 at 22:13 +0200, David Waern wrote: >>>>>> 2009/4/1 jutaro : >>>>>>> I guess you mean the dialog which should help leksah to find sources >>>>>>> for installed packages. It needs this so you can go to all the >>>>>>> definitions >>>>>>> in the base packages ... This is very handy if it works. Look to the >>>>>>> manual >>>>>>> for details. >>>>>> Maybe could add support to Cabal for installing sources? Should be >>>>>> very useful to have in general. >>>>> http://hackage.haskell.org/trac/hackage/ticket/364 >>>> >>>> Jutaru, perhaps a nice Hackathon project? :-) >>> >>> I think there's some design work to do there. ?See the discussion on the >>> GHC ticket: http://hackage.haskell.org/trac/ghc/ticket/2630. >>> >>> In short: just keeping the source code around isn't enough. ?You need >>> some >>> metadata in order to make sense of the source code - for example, you >>> can't >>> feed the source code to the GHC API without knowing which additional >>> flags >>> need to be passed, and those come from the .cabal file. ?Also you >>> probably >>> want to stash the results of the 'cabal configure' step so that you can >>> get >>> a view of the source code that is consistent with the version(s?) you >>> compiled. ?We need to think about about backwards and >>> forwards-compatibility of whatever metadata format is used. >>> >>> And then you'll need Cabal APIs to extract the metadata. ?So we need to >>> think about what APIs make sense, and the best way to do that is to >>> think >>> about what tool(s) you want to write and use that to drive the API >>> design. >>> >>> Perhaps all this is going a bit too far. ?Maybe we want to just stash >>> the >>> source code and accept that there are some things that you just can't do >>> with it. ?However, I imagine that pretty soon people will want to feed >>> the >>> source code into the GHC API, and at that point we have to tackle the >>> build >>> metadata issues. >>> >>> Cheers, >>> ? ? ? Simon >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> >> >> -- >> View this message in context: >> http://www.nabble.com/Announcement%3A-Beta-of-Leksah-IDE-available-tp22816032p22846713.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://www.nabble.com/Announcement%3A-Beta-of-Leksah-IDE-available-tp22816032p22871892.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From mroth at nessie.de Fri Apr 3 12:49:36 2009 From: mroth at nessie.de (Michael Roth) Date: Fri Apr 3 12:36:43 2009 Subject: [Haskell-cafe] Monad transformer, liftIO Message-ID: <49D63E20.9050205@nessie.de> Hello list, maybe I'm just stupid, I'm trying to do something like this: import Control.Monad import Control.Monad.Trans import Control.Monad.List foobar = do a <- [1,2,3] b <- [4,5,6] liftIO $ putStrLn $ (show a) ++ " " ++ (show b) return (a+b) main = do sums <- foobar print sums But this apparently doesn't work... I'm total clueless how to achieve the correct solution. Maybe my mental image on the monad transformer thing is totally wrong? Michael From wagner.andrew at gmail.com Fri Apr 3 13:14:33 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Fri Apr 3 13:01:39 2009 Subject: [Haskell-cafe] Monad transformer, liftIO In-Reply-To: <49D63E20.9050205@nessie.de> References: <49D63E20.9050205@nessie.de> Message-ID: You haven't really said what happens when you try this, but I would bet that things would be clarified greatly if you put type signatures on your two definitions. On Fri, Apr 3, 2009 at 12:49 PM, Michael Roth wrote: > Hello list, > > maybe I'm just stupid, I'm trying to do something like this: > > > import Control.Monad > import Control.Monad.Trans > import Control.Monad.List > > foobar = do > a <- [1,2,3] > b <- [4,5,6] > liftIO $ putStrLn $ (show a) ++ " " ++ (show b) > return (a+b) > > main = do > sums <- foobar > print sums > > > But this apparently doesn't work... I'm total clueless how > to achieve the correct solution. Maybe my mental image > on the monad transformer thing is totally wrong? > > > Michael > _______________________________________________ > 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/20090403/29af79ac/attachment.htm From wchogg at gmail.com Fri Apr 3 13:16:57 2009 From: wchogg at gmail.com (Creighton Hogg) Date: Fri Apr 3 13:04:00 2009 Subject: [Haskell-cafe] Monad transformer, liftIO In-Reply-To: <49D63E20.9050205@nessie.de> References: <49D63E20.9050205@nessie.de> Message-ID: <814617240904031016h31dd1678u886379213c0baa5a@mail.gmail.com> On Fri, Apr 3, 2009 at 11:49 AM, Michael Roth wrote: > Hello list, > > maybe I'm just stupid, I'm trying to do something like this: > > > ? ? ? ?import Control.Monad > ? ? ? ?import Control.Monad.Trans > ? ? ? ?import Control.Monad.List > > ? ? ? ?foobar = do > ? ? ? ? ? ? ? ?a <- [1,2,3] > ? ? ? ? ? ? ? ?b <- [4,5,6] > ? ? ? ? ? ? ? ?liftIO $ putStrLn $ (show a) ++ " " ++ (show b) > ? ? ? ? ? ? ? ?return (a+b) > > ? ? ? ?main = do > ? ? ? ? ? ? ? ?sums <- foobar > ? ? ? ? ? ? ? ?print sums > > > But this apparently doesn't work... I'm total clueless how > to achieve the correct solution. Maybe my mental image > on the monad transformer thing is totally wrong? Okay, so I think what you want is import Control.Monad import Control.Monad.Trans import Control.Monad.List foobar :: ListT IO Int foobar = do a <- msum . map return $ [1,2,3] b <- msum . map return $ [4,5,6] liftIO $ putStrLn $ (show a) ++ " " ++ (show b) return (a+b) main = do sums <- runListT foobar print sums There were a couple of things going on here: first, that you tried to use literal list syntax in do notation which I believe only works in the actual [] monad. Second, you didn't have the runListT acting on the foobar, which is how you go from a ListT IO Int to a IO [Int]. From vasyl.pasternak at gmail.com Fri Apr 3 13:44:01 2009 From: vasyl.pasternak at gmail.com (Vasyl Pasternak) Date: Fri Apr 3 13:31:06 2009 Subject: [Haskell-cafe] ANNOUNCE hgettext-0.1.5 - GetText based internationalization of Haskell programs Message-ID: <8feb08f70904031044r6420319frb2c46c35965e3bd3@mail.gmail.com> Hello, I have extended my previous version of the library to support distribution and installation of PO files. Source tarball - http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hgettext Also I described how to use this feature to distribute haskell packages in my blog entry http://progandprog.blogspot.com/2009/04/configure-and-install-internationalized.html Same description was added to the Haskell Wiki - http://www.haskell.org/haskellwiki/Internationalization_of_Haskell_programs Complete example, which uses internationalization capabilities is here: http://hgettext.googlecode.com/files/hello-0.1.3.tar.gz --- Best regards, Vasyl Pasternak From jefferson.r.heard at gmail.com Fri Apr 3 13:56:30 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Fri Apr 3 13:43:47 2009 Subject: [Haskell-cafe] A fair number of updates to Buster since the other day - 0.99.5 Message-ID: <4165d3a70904031056t2ef34a5ek639329961a95a496@mail.gmail.com> http://vis.renci.org/jeff/2009/04/03/major-updates-to-buster/ Added several new widgets and several new behaviours related to file reading and writing, exceptions, and the system/program environment. -- Jeff From bugfact at gmail.com Fri Apr 3 13:58:35 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Apr 3 13:45:40 2009 Subject: [Haskell-cafe] Possible floating point bug in GHC? Message-ID: For days I'm fighting against a weird bug. My Haskell code calls into a C function residing in a DLL (I'm on Windows, the DLL is generated using Visual Studio). This C function computes a floating point expression. However, the floating point result is incorrect. I think I found the source of the problem: the C code expects that all the Intel's x86's floating point register tag bits are set to 1, but it seems the Haskell code does not preserve that. Since the x86 has all kinds of floating point weirdness - it is both a stack based and register based system - so it is crucially important that generated code plays nice. For example, when using MMX one must always emit an EMMS instructionto clear these tag bits. If I manually clear these tags bits, my code works fine. Is this something other people encountered as well? I'm trying to make a very simple test case to reproduce the behavior... I'm not sure if this is a visual C compiler bug, GHC bug, or something I'm doing wrong... Is it possible to annotate a foreign imported C function to tell the Haskell code generator the functioin is using floating point registers somehow? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090403/4836d571/attachment.htm From mroth at nessie.de Fri Apr 3 14:07:19 2009 From: mroth at nessie.de (Michael Roth) Date: Fri Apr 3 13:54:24 2009 Subject: [Haskell-cafe] Monad transformer, liftIO In-Reply-To: <814617240904031016h31dd1678u886379213c0baa5a@mail.gmail.com> References: <49D63E20.9050205@nessie.de> <814617240904031016h31dd1678u886379213c0baa5a@mail.gmail.com> Message-ID: <49D65057.4090709@nessie.de> Creighton Hogg schrieb: > Okay, so I think what you want is > > [...] Yes. Your solution works. Thank you. But: > a <- msum . map return $ [1,2,3] Why Do I need this "msum . map return" thing? The "map return" part is somewhat clear. But not entirely. Which type of monad is created here? The msum-part ist totally confusing me: First we create a list with some monads (?) and then msum them? What is going on there? > first, that you tried to use literal list syntax in > do notation which I believe only works in the actual [] monad. Is the "x <- xs" in the list monad a form of syntactic sugar? > Second, you didn't have the runListT acting on > the foobar, which is how you go from a ListT IO Int to a IO [Int]. Ah, yes. This point I understood now. Thank you again. Michael From vanenkj at gmail.com Fri Apr 3 14:26:13 2009 From: vanenkj at gmail.com (John Van Enk) Date: Fri Apr 3 14:13:18 2009 Subject: [Haskell-cafe] Announcement: Beta of Leksah IDE available In-Reply-To: <1238538058.6785.11.camel@jutaro-laptop> References: <1238538058.6785.11.camel@jutaro-laptop> Message-ID: What's the chance things like hsc2hs and c2hs will ever be supported? :) I'm aware this is a horribly difficult task (or I think it is). Perhaps it would be possible to find the .hsc and .chs files and run the corresponding processor over them and extract data/types/functions from the corresponding .hs files? I tried running leksah on one of my projects which uses a lot of FFI without much success. /jve 2009/3/31 J?rgen Nicklisch-Franken > I'm proud to announce release 0.4.4 of Leksah, the Haskell IDE written > in Haskell. > Leksahs current features include: > * On the fly error reporting with location of compilation errors > * Completion > * Import helper for constructing the import statements > * Module browser with navigation to definition > * Search for identifiers with information about types and comments > * Project management support based on Cabal with a visual editor > * Haskell customised editor with "source candy" > * Configuration with session support, keymaps and flexible panes > For further information: leksah.org > > Please don't compare what we have reached to IDE's like VisualStudio, > Eclipse or NetBeans. I started Leksah June 1997 and work on it in my > spare time for fun. I started the project for various reasons. One was > to contribute to make Haskell successful in industry, because I suffer > from the use of inappropriate programming languages like C, C++, C# or > Java in my daily job. Another was to contribute to open source, which > I'm using privately almost exclusively. The first alpha version of > Leksah was published February 2008. Since the beginning of this year > Hamish Mackenzie joined the project and merged his Funa project with > Leksah, which gave a real boost. > > I thank the people who have encouraged and helped me with their > comments, enthusiasm and support. I learned as well that the IDE issue > is a controversial theme in the community. I learned that "IDEs are big > evil nasty things", that "if you need an IDE, something is wrong with > your language", that it is scientifically proved, that "real cool > hackers will always use Emacs or vi". Most stupid I found the recurring > comment: "Every few years there is someone who starts a Haskell IDE > project and then gives up after a few years.". That will be true for > Leksah as well, if it will not be accepted and supported by the > community. The current state of Leksah is a proof of concept, that an > IDE for Haskell is not a difficult thing to do if the community supports > it and that it will in my view be of great help and will contribute > tremendously to spread Haskell. > > So I please the members of the community to pause for a moment and try > out Leksah with a benevolent attitude. > > J?rgen Nicklisch-Franken > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090403/8aad2d8e/attachment.htm From Malcolm.Wallace at cs.york.ac.uk Fri Apr 3 15:02:51 2009 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Fri Apr 3 14:50:06 2009 Subject: [Haskell-cafe] Possible floating point bug in GHC? In-Reply-To: References: Message-ID: <03ED07F2-FAA1-4AC0-A29F-CD24C2B4A483@cs.york.ac.uk> Interesting. This could be the cause of a weird floating point bug that has been showing up in the ghc testsuite recently, specifically affecting MacOS/Intel (but not MacOS/ppc). http://darcs.haskell.org/testsuite/tests/ghc-regress/lib/Numeric/num009.hs That test compares the result of the builtin floating point ops with the same ops imported via FFI. The should not be different, but on Intel they sometimes are. Regards, Malcolm On 3 Apr 2009, at 18:58, Peter Verswyvelen wrote: > For days I'm fighting against a weird bug. > > My Haskell code calls into a C function residing in a DLL (I'm on > Windows, the DLL is generated using Visual Studio). This C function > computes a floating point expression. However, the floating point > result is incorrect. > > I think I found the source of the problem: the C code expects that > all the Intel's x86's floating point register tag bits are set to 1, > but it seems the Haskell code does not preserve that. > > Since the x86 has all kinds of floating point weirdness - it is both > a stack based and register based system - so it is crucially > important that generated code plays nice. For example, when using > MMX one must always emit an EMMS instruction to clear these tag bits. > > If I manually clear these tags bits, my code works fine. > > Is this something other people encountered as well? I'm trying to > make a very simple test case to reproduce the behavior... > > I'm not sure if this is a visual C compiler bug, GHC bug, or > something I'm doing wrong... > > Is it possible to annotate a foreign imported C function to tell the > Haskell code generator the functioin is using floating point > registers somehow? From ekmett at gmail.com Fri Apr 3 15:29:18 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Apr 3 15:16:21 2009 Subject: [Haskell-cafe] Problem with prepose.lhs and ghc6.10.1 In-Reply-To: References: Message-ID: <7fb8f82f0904031229o2ba48c5ybb636273bb8bc8d0@mail.gmail.com> With the changes to ScopedTypeVariables in GHC you can't pick up the type from the return type of your function directly, so you'll need either a combinator to do the work or to pass the type in question in as an argument to a helper function. normalize :: (Modular s a, Integral a) => a -> (M s a) normalize = normalize' undefined where normalize' :: (Modular s a, Integral a) => s -> a -> (M s a) normalize' s a = M (a `mod` modulus s) There is an implementation of the reflection code with minor modifications to work with the modern version of GHC's ScopedTypeVariables in hackage as 'reflection' and a minimalist implementation of modular arithmetic from the same paper (if not yet including the residue number system based optimizations) available in 'monoids' as Data.Ring.ModularArithmetic. Both have only been fleshed out as far as I've needed them for other purposes, but should be usable. -Edward Kmett On Thu, Apr 2, 2009 at 11:59 AM, Henry Laxen wrote: > Dear Group, > > I'm trying to read the paper: > "Functional Pearl: Implicit Configurations" > at http://www.cs.rutgers.edu/~ccshan/prepose/ > and when running the code in prepose.lhs I get: > ../haskell/prepose.lhs:707:0: Parse error in pattern > which is pointing at: > normalize a :: M s a = M (mod a (modulus (undefined :: s))) > > The paper says it uses lexically scoped type variables. I tried reading > about > them at: > > http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#scoped-type-variables > > so I added -XScopedTypeVariables to my OPTIONS but I still get the same > error > message. I would really like to play with the code in the paper, but I'm > stuck > at this point. Any pointers would be appreciated. > Best wishes, > Henry Laxen > > > _______________________________________________ > 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/20090403/043a8b50/attachment.htm From bugfact at gmail.com Fri Apr 3 15:31:46 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Apr 3 15:18:53 2009 Subject: [Haskell-cafe] Possible floating point bug in GHC? In-Reply-To: <03ED07F2-FAA1-4AC0-A29F-CD24C2B4A483@cs.york.ac.uk> References: <03ED07F2-FAA1-4AC0-A29F-CD24C2B4A483@cs.york.ac.uk> Message-ID: Well this situation can indeed not occur on PowerPCs since these CPUs just have floating point registers, not some weird dual stack sometimes / registers sometimes architecture. But in my case the bug is consistent, not from time to time. So I'll try to reduce this to a small reproducible test case, maybe including the assembly generated by the VC++ compiler. On Fri, Apr 3, 2009 at 9:02 PM, Malcolm Wallace < Malcolm.Wallace@cs.york.ac.uk> wrote: > Interesting. This could be the cause of a weird floating point bug that > has been showing up in the ghc testsuite recently, specifically affecting > MacOS/Intel (but not MacOS/ppc). > > http://darcs.haskell.org/testsuite/tests/ghc-regress/lib/Numeric/num009.hs > > That test compares the result of the builtin floating point ops with the > same ops imported via FFI. The should not be different, but on Intel they > sometimes are. > > Regards, > Malcolm > > > On 3 Apr 2009, at 18:58, Peter Verswyvelen wrote: > > For days I'm fighting against a weird bug. >> >> My Haskell code calls into a C function residing in a DLL (I'm on Windows, >> the DLL is generated using Visual Studio). This C function computes a >> floating point expression. However, the floating point result is incorrect. >> >> I think I found the source of the problem: the C code expects that all the >> Intel's x86's floating point register tag bits are set to 1, but it seems >> the Haskell code does not preserve that. >> >> Since the x86 has all kinds of floating point weirdness - it is both a >> stack based and register based system - so it is crucially important that >> generated code plays nice. For example, when using MMX one must always emit >> an EMMS instruction to clear these tag bits. >> >> If I manually clear these tags bits, my code works fine. >> >> Is this something other people encountered as well? I'm trying to make a >> very simple test case to reproduce the behavior... >> >> I'm not sure if this is a visual C compiler bug, GHC bug, or something I'm >> doing wrong... >> >> Is it possible to annotate a foreign imported C function to tell the >> Haskell code generator the functioin is using floating point registers >> somehow? >> > _______________________________________________ > 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/20090403/a2fa0120/attachment-0001.htm From divisortheory at gmail.com Fri Apr 3 15:54:44 2009 From: divisortheory at gmail.com (Zachary Turner) Date: Fri Apr 3 15:41:49 2009 Subject: [Haskell-cafe] Possible floating point bug in GHC? In-Reply-To: References: <03ED07F2-FAA1-4AC0-A29F-CD24C2B4A483@cs.york.ac.uk> Message-ID: <478231340904031254k6b28befcqd9afbe5d51abc853@mail.gmail.com> What floating point model is your DLL compiled with? There are a variety of different options here with regards to optimizations, and I don't know about the specific assembly that each option produces, but I know there are options like Strict, Fast, or Precise, and maybe when you do something like that it makes different assumptions about the caller. Although that doesn't say anything about whose "fault" it is, but at least it might be helpful to know if changing the floating point model causes the bug to go away. On Fri, Apr 3, 2009 at 2:31 PM, Peter Verswyvelen wrote: > Well this situation can indeed not occur on PowerPCs since these CPUs just > have floating point registers, not some weird dual stack sometimes / > registers sometimes architecture. > But in my case the bug is consistent, not from time to time. > > So I'll try to reduce this to a small reproducible test case, maybe > including the assembly generated by the VC++ compiler. > > On Fri, Apr 3, 2009 at 9:02 PM, Malcolm Wallace < > Malcolm.Wallace@cs.york.ac.uk> wrote: > >> Interesting. This could be the cause of a weird floating point bug that >> has been showing up in the ghc testsuite recently, specifically affecting >> MacOS/Intel (but not MacOS/ppc). >> >> http://darcs.haskell.org/testsuite/tests/ghc-regress/lib/Numeric/num009.hs >> >> That test compares the result of the builtin floating point ops with the >> same ops imported via FFI. The should not be different, but on Intel they >> sometimes are. >> >> Regards, >> Malcolm >> >> >> On 3 Apr 2009, at 18:58, Peter Verswyvelen wrote: >> >> For days I'm fighting against a weird bug. >>> >>> My Haskell code calls into a C function residing in a DLL (I'm on >>> Windows, the DLL is generated using Visual Studio). This C function computes >>> a floating point expression. However, the floating point result is >>> incorrect. >>> >>> I think I found the source of the problem: the C code expects that all >>> the Intel's x86's floating point register tag bits are set to 1, but it >>> seems the Haskell code does not preserve that. >>> >>> Since the x86 has all kinds of floating point weirdness - it is both a >>> stack based and register based system - so it is crucially important that >>> generated code plays nice. For example, when using MMX one must always emit >>> an EMMS instruction to clear these tag bits. >>> >>> If I manually clear these tags bits, my code works fine. >>> >>> Is this something other people encountered as well? I'm trying to make a >>> very simple test case to reproduce the behavior... >>> >>> I'm not sure if this is a visual C compiler bug, GHC bug, or something >>> I'm doing wrong... >>> >>> Is it possible to annotate a foreign imported C function to tell the >>> Haskell code generator the functioin is using floating point registers >>> somehow? >>> >> _______________________________________________ >> 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/20090403/f72aab70/attachment.htm From bugfact at gmail.com Fri Apr 3 16:10:17 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Apr 3 15:57:22 2009 Subject: [Haskell-cafe] Possible floating point bug in GHC? In-Reply-To: <478231340904031254k6b28befcqd9afbe5d51abc853@mail.gmail.com> References: <03ED07F2-FAA1-4AC0-A29F-CD24C2B4A483@cs.york.ac.uk> <478231340904031254k6b28befcqd9afbe5d51abc853@mail.gmail.com> Message-ID: I tried both precise and fast, but that did not help. Compiling to SSE2 fixed it, since that does not use a floating point stack I guess. I'm preparing a repro test case, but it is tricky since removing code tends to change the optimizations and then the bug does not occur. Does anybody know what the calling convention for floating points is for cdecl on x86? The documentation says that the result is returned in st(0), but it says nothing about the floating point tags. I assume that every function expects the FP stack to be empty, potentially containing just argument values. But GHC calls the C function with some FP registers reserved on the stack... On Fri, Apr 3, 2009 at 9:54 PM, Zachary Turner wrote: > What floating point model is your DLL compiled with? There are a variety > of different options here with regards to optimizations, and I don't know > about the specific assembly that each option produces, but I know there are > options like Strict, Fast, or Precise, and maybe when you do something like > that it makes different assumptions about the caller. Although that doesn't > say anything about whose "fault" it is, but at least it might be helpful to > know if changing the floating point model causes the bug to go away. > > > On Fri, Apr 3, 2009 at 2:31 PM, Peter Verswyvelen wrote: > >> Well this situation can indeed not occur on PowerPCs since these CPUs just >> have floating point registers, not some weird dual stack sometimes / >> registers sometimes architecture. >> But in my case the bug is consistent, not from time to time. >> >> So I'll try to reduce this to a small reproducible test case, maybe >> including the assembly generated by the VC++ compiler. >> >> On Fri, Apr 3, 2009 at 9:02 PM, Malcolm Wallace < >> Malcolm.Wallace@cs.york.ac.uk> wrote: >> >>> Interesting. This could be the cause of a weird floating point bug that >>> has been showing up in the ghc testsuite recently, specifically affecting >>> MacOS/Intel (but not MacOS/ppc). >>> >>> http://darcs.haskell.org/testsuite/tests/ghc-regress/lib/Numeric/num009.hs >>> >>> That test compares the result of the builtin floating point ops with the >>> same ops imported via FFI. The should not be different, but on Intel they >>> sometimes are. >>> >>> Regards, >>> Malcolm >>> >>> >>> On 3 Apr 2009, at 18:58, Peter Verswyvelen wrote: >>> >>> For days I'm fighting against a weird bug. >>>> >>>> My Haskell code calls into a C function residing in a DLL (I'm on >>>> Windows, the DLL is generated using Visual Studio). This C function computes >>>> a floating point expression. However, the floating point result is >>>> incorrect. >>>> >>>> I think I found the source of the problem: the C code expects that all >>>> the Intel's x86's floating point register tag bits are set to 1, but it >>>> seems the Haskell code does not preserve that. >>>> >>>> Since the x86 has all kinds of floating point weirdness - it is both a >>>> stack based and register based system - so it is crucially important that >>>> generated code plays nice. For example, when using MMX one must always emit >>>> an EMMS instruction to clear these tag bits. >>>> >>>> If I manually clear these tags bits, my code works fine. >>>> >>>> Is this something other people encountered as well? I'm trying to make a >>>> very simple test case to reproduce the behavior... >>>> >>>> I'm not sure if this is a visual C compiler bug, GHC bug, or something >>>> I'm doing wrong... >>>> >>>> Is it possible to annotate a foreign imported C function to tell the >>>> Haskell code generator the functioin is using floating point registers >>>> somehow? >>>> >>> _______________________________________________ >>> 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/20090403/5837aaff/attachment.htm From igloo at earth.li Fri Apr 3 16:35:05 2009 From: igloo at earth.li (Ian Lynagh) Date: Fri Apr 3 16:22:11 2009 Subject: [Haskell-cafe] Possible floating point bug in GHC? In-Reply-To: References: <03ED07F2-FAA1-4AC0-A29F-CD24C2B4A483@cs.york.ac.uk> <478231340904031254k6b28befcqd9afbe5d51abc853@mail.gmail.com> Message-ID: <20090403203505.GA4694@matrix.chaos.earth.li> On Fri, Apr 03, 2009 at 10:10:17PM +0200, Peter Verswyvelen wrote: > I tried both precise and fast, but that did not help. Compiling to SSE2 > fixed it, since that does not use a floating point stack I guess. You didn't say what version of GHC you are using, but it sounds like this might already be fixed in 6.10.2 by: Tue Nov 11 12:56:19 GMT 2008 Simon Marlow * Fix to i386_insert_ffrees (#2724, #1944) The i386 native code generator has to arrange that the FPU stack is clear on exit from any function that uses the FPU. Unfortunately it was getting this wrong (and has been ever since this code was written, I think): it was looking for basic blocks that used the FPU and adding the code to clear the FPU stack on any non-local exit from the block. In fact it should be doing this on a whole-function basis, rather than individual basic blocks. Thanks Ian From bugfact at gmail.com Fri Apr 3 16:47:04 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Apr 3 16:34:08 2009 Subject: [Haskell-cafe] Possible floating point bug in GHC? In-Reply-To: <20090403203505.GA4694@matrix.chaos.earth.li> References: <03ED07F2-FAA1-4AC0-A29F-CD24C2B4A483@cs.york.ac.uk> <478231340904031254k6b28befcqd9afbe5d51abc853@mail.gmail.com> <20090403203505.GA4694@matrix.chaos.earth.li> Message-ID: Ouch, what a waste of time on my side :-( This bugfix is not mentioned in the "notable bug fixes" here Since this is such a severe bug, I would recommend listing it :) Anyway, I have a very small repro test case now. Will certainly test this with GHC 6.10.2. On Fri, Apr 3, 2009 at 10:35 PM, Ian Lynagh wrote: > On Fri, Apr 03, 2009 at 10:10:17PM +0200, Peter Verswyvelen wrote: > > I tried both precise and fast, but that did not help. Compiling to SSE2 > > fixed it, since that does not use a floating point stack I guess. > > You didn't say what version of GHC you are using, but it sounds like > this might already be fixed in 6.10.2 by: > > Tue Nov 11 12:56:19 GMT 2008 Simon Marlow > * Fix to i386_insert_ffrees (#2724, #1944) > The i386 native code generator has to arrange that the FPU stack is > clear on exit from any function that uses the FPU. Unfortunately it > was getting this wrong (and has been ever since this code was written, > I think): it was looking for basic blocks that used the FPU and adding > the code to clear the FPU stack on any non-local exit from the block. > In fact it should be doing this on a whole-function basis, rather than > individual basic blocks. > > > Thanks > Ian > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090403/1ff5db61/attachment.htm From bugfact at gmail.com Fri Apr 3 17:04:10 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Apr 3 16:51:14 2009 Subject: [Haskell-cafe] Possible floating point bug in GHC? In-Reply-To: References: <03ED07F2-FAA1-4AC0-A29F-CD24C2B4A483@cs.york.ac.uk> <478231340904031254k6b28befcqd9afbe5d51abc853@mail.gmail.com> <20090403203505.GA4694@matrix.chaos.earth.li> Message-ID: Okay, I can confirm the bug is fixed. It's insane this bug did not cause any more problems. Every call into every C function that uses floating point could have been affected (OpenGL, BLAS, etc) On Fri, Apr 3, 2009 at 10:47 PM, Peter Verswyvelen wrote: > Ouch, what a waste of time on my side :-( > This bugfix is not mentioned in the "notable bug fixes" here > > > Since this is such a severe bug, I would recommend listing it :) > > Anyway, I have a very small repro test case now. Will certainly test this > with GHC 6.10.2. > > On Fri, Apr 3, 2009 at 10:35 PM, Ian Lynagh wrote: > >> On Fri, Apr 03, 2009 at 10:10:17PM +0200, Peter Verswyvelen wrote: >> > I tried both precise and fast, but that did not help. Compiling to SSE2 >> > fixed it, since that does not use a floating point stack I guess. >> >> You didn't say what version of GHC you are using, but it sounds like >> this might already be fixed in 6.10.2 by: >> >> Tue Nov 11 12:56:19 GMT 2008 Simon Marlow >> * Fix to i386_insert_ffrees (#2724, #1944) >> The i386 native code generator has to arrange that the FPU stack is >> clear on exit from any function that uses the FPU. Unfortunately it >> was getting this wrong (and has been ever since this code was written, >> I think): it was looking for basic blocks that used the FPU and adding >> the code to clear the FPU stack on any non-local exit from the block. >> In fact it should be doing this on a whole-function basis, rather than >> individual basic blocks. >> >> >> Thanks >> Ian >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090403/688f511c/attachment.htm From wren at freegeek.org Fri Apr 3 18:51:39 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri Apr 3 18:38:42 2009 Subject: [Haskell-cafe] ANN: logfloat 0.12.0.1 Message-ID: <49D692FB.6040600@freegeek.org> -------------------------------------------- -- logfloat 0.12.0.1 -------------------------------------------- This package provides a type for storing numbers in the log-domain, primarily useful for preventing underflow when multiplying many probabilities as in HMMs and other probabilistic models. The package also provides modules for dealing with floating numbers correctly. -------------------------------------------- -- Now using FFI -------------------------------------------- We now use the FFI to gain access to C's accurate log1p (and expm1) functions. This greatly increases the range of resolution, especially for very small LogFloat values. These are currently exposed from Data.Number.LogFloat, though they may move to a different module in future versions. On GHC 6.10 the use of -fvia-C had to be disabled because it conflicts with the FFI (version 0.12.0.0 still used it, which is fine on GHC 6.8). I'm still investigating the use of -fasm and getting proper benchmarking numbers. Contact me if you notice significant performance degradation. Using the FFI complicates the build process for Hugs; details are noted in the INSTALL file. It may also complicate building on Windows (due to ccall vs stdcall), though I'm not familiar with Windows FFI and don't have a machine to test on. The calling convention is "unsafe" in order to avoid overhead. However, in the past this has been noted to cause issues with multithreaded applications since it locks all RTS threads instead of just the calling thread. If you're using logfloat in a multithreaded application and notice a slowdown, or if you're more familiar with these details than I, tell me so I can fix things. If you have any difficulties with the FFI, let me know. As an interim solution the FFI can be disabled by turning off the useFFI Cabal flag during configure, which will compile the package to use the naive log1p implementation from earlier versions. -------------------------------------------- -- Other changes since 0.11.0 -------------------------------------------- * (0.11.1) Felipe Lessa added an instance for IArray UArray LogFloat. On GHC we use newtype deriving; On Hugs we fall back to unsafeCoerce to distribute the newtype over IArray UArray Double. * (0.11.2 Darcs) Moved the log/exp fusion rules from Data.Number.LogFloat into Data.Number.Transfinite where our log function is defined. * Added a Storable LogFloat instance for GHC. No implementation is available yet for Hugs. * Removed orphaned toRational/fromRational fusion rules, which were obviated by the introduction of the Data.Number.RealToFrac module in 0.11.0. * Changed the Real LogFloat instance to throw errors when trying to convert transfinite values into Rational. -------------------------------------------- -- Compatibility / Portability -------------------------------------------- The package is compatible with Hugs (September 2006) and GHC (6.8, 6.10). For anyone still using GHC 6.6, the code may still work if you replace LANGUAGE pragma by equivalent OPTIONS_GHC pragma. The package is not compatible with nhc98 and Yhc because Data.Number.RealToFrac uses MPTCs. The other modules should be compatible. -------------------------------------------- -- Links -------------------------------------------- Homepage: http://code.haskell.org/~wren/ Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/logfloat Darcs: http://code.haskell.org/~wren/logfloat/ Haddock (Darcs version): http://code.haskell.org/~wren/logfloat/dist/doc/html/logfloat/ -- Live well, ~wren From robgreayer at yahoo.com Fri Apr 3 21:05:45 2009 From: robgreayer at yahoo.com (Robert Greayer) Date: Fri Apr 3 20:52:48 2009 Subject: [Haskell-cafe] ANN: logfloat 0.12.0.1 In-Reply-To: <49D692FB.6040600@freegeek.org> References: <49D692FB.6040600@freegeek.org> Message-ID: <839007.91761.qm@web65704.mail.ac4.yahoo.com> wren ng thornton wrote: > Using the FFI complicates the build process for Hugs; details are noted in the INSTALL file. It may also complicate building on Windows (due to ccall vs stdcall), > though I'm not familiar with Windows FFI and don't have a machine to test on. On XP with GHC 6.10.1 it installed cleanly and easily via cabal-install (and a test program comparing results of (log . (1+)) v. log1p) showed that it worked properly). From kannan at cakoose.com Fri Apr 3 21:17:08 2009 From: kannan at cakoose.com (Kannan Goundan) Date: Fri Apr 3 21:12:05 2009 Subject: [Haskell-cafe] Optional EOF in Parsec. Message-ID: I'm writing a parser with Parsec. In the input language, elements of a sequence are separated by commas: [1, 2, 3] However, instead of a comma, you can also use an EOL: [1, 2 3] Anywhere else, EOL is considered ignorable whitespace. So it's not as simple as just making EOL a token and looking for (comma | eol). I've implemented this functionality in a hand-written parser (basically a hack that keeps track of whether the last read token was preceded by an EOL, without making EOL itself a token). Does anybody have ideas about how to do this with Parsec? From gwern0 at gmail.com Fri Apr 3 21:43:37 2009 From: gwern0 at gmail.com (gwern0@gmail.com) Date: Fri Apr 3 21:30:49 2009 Subject: [Haskell-cafe] Generating functions for games Message-ID: So some time ago I saw mentioned the game of Zendo https://secure.wikimedia.org/wikipedia/en/wiki/Zendo_(game) as a good game for programmers to play (and not just by Okasaki). The basic idea of Zendo is that another player is creating arrangements of little colored plastic shapes and you have to guess what rule they satisfy. I thought it'd be fun to play, but not knowing anyone who has it, I figured a Haskell version would be best. 3D graphics and that sort of geometry is a bit complex, though. Better to start with a simplified version to get the fundamentals right. Why not sequences of numbers? For example: [2, 4, 6] could satisfy quite a few rules - the rule could be all evens, or it could be ascending evens, or it could be incrementing by 2, or it could just be ascending period. Now, being in the position of the player who created the rule is no good. A good guesser is basically AI, which is a bit far afield. But it seems reasonable to have the program create a rule and provide examples. Have a few basic rules, some ways to combine them (perhaps a QuickCheck generator), and bob's your uncle. So I set off creating a dataype. The user could type in their guessed rules and then read could be used to compare. I got up to something like 'data Function = Not | Add' and began writing a 'translate' function, along the lines of 'translate Not = not\ntranslate Add = (+)', at which point I realized that translate was returning different types and this is a Bad Thing in Haskell. After trying out a few approaches, I decided the basic idea was flawed and sought help. Someone in #haskell suggested GADTs, which I've never used. Before I plunge into the abyss, I was wondering: does anyone know of any existing examples of this sort of thing or alternative approachs? I'd much rather crib than create. :) -- gwern -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 270 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090403/4ca920af/signature.bin From andy at adradh.org.uk Fri Apr 3 23:19:23 2009 From: andy at adradh.org.uk (andy morris) Date: Fri Apr 3 23:06:41 2009 Subject: [Haskell-cafe] Generating functions for games In-Reply-To: References: Message-ID: 2009/4/4 : > So some time ago I saw mentioned the game of Zendo > https://secure.wikimedia.org/wikipedia/en/wiki/Zendo_(game) as a good game > for programmers to play (and not just by Okasaki). The basic idea of Zendo > is that another player is creating arrangements of little colored plastic > shapes and you have to guess what rule they satisfy. I thought it'd be fun > to play, but not knowing anyone who has it, I figured a Haskell version > would be best. > > 3D graphics and that sort of geometry is a bit complex, though. Better to > start with a simplified version to get the fundamentals right. Why not > sequences of numbers? For example: [2, 4, 6] could satisfy quite a few rules > - the rule could be all evens, or it could be ascending evens, or it could > be incrementing by 2, or it could just be ascending period. > > Now, being in the position of the player who created the rule is no good. A > good guesser is basically AI, which is a bit far afield. But it seems > reasonable to have the program create a rule and provide examples. Have a > few basic rules, some ways to combine them (perhaps a QuickCheck generator), > and bob's your uncle. > > So I set off creating a dataype. The user could type in their guessed rules > and then read could be used to compare. ?I got up to something like 'data > Function = Not | Add' and began writing a 'translate' function, along the > lines of 'translate Not = not\ntranslate Add = (+)', at which point I > realized that translate was returning different types and this is a Bad > Thing in Haskell. After trying out a few approaches, I decided the basic > idea was flawed and sought help. > > Someone in #haskell suggested GADTs, which I've never used. Before I plunge > into the abyss, I was wondering: does anyone know of any existing examples > of this sort of thing or alternative approachs? I'd much rather crib than > create. :) > > -- > gwern > A simple example for this using GADTs might be: data Function a where Not :: Function (Bool -> Bool) Add :: Function (Int -> Int -> Int) ... -- BTW, type signatures are mandatory if you're using GADTs translate :: Function a -> a translate Not = not translate Add = (+) ... The important part here is the parameter to Function, and how it's made more specific in the constructors: even though you're returning values of different types from translate, it's always the same as the type the argument is parametrised over. Not to be all RTFM, but I found the example in the GHC docs quite helpful as well: http://www.haskell.org/ghc/docs/latest/html/users_guide/data-type-extensions.html#gadt From aslatter at gmail.com Sat Apr 4 00:13:03 2009 From: aslatter at gmail.com (Antoine Latter) Date: Sat Apr 4 00:00:06 2009 Subject: [Haskell-cafe] Optional EOF in Parsec. In-Reply-To: References: Message-ID: <694519c50904032113s18fd248evac8f2b9a36726d5f@mail.gmail.com> On Fri, Apr 3, 2009 at 8:17 PM, Kannan Goundan wrote: > > I'm writing a parser with Parsec. ?In the input language, elements of a sequence > are separated by commas: > > ? [1, 2, 3] > > However, instead of a comma, you can also use an EOL: > > ?[1, 2 > ?3] > > Anywhere else, EOL is considered ignorable whitespace. ?So it's not as simple as > just making EOL a token and looking for (comma | eol). > Untested, but hopefully enough so you get an idea of where to start: > -- End of line parser. Consumes the carriage return, if present. > eol :: Parser () > eol = eof <|> char '\n' > -- list-element separator. > listSep :: Parser () > listSep = eol <|> (char ',' >> spaces) > -- list parser. The list may be empty - denoted by "[]" > myListOf :: Parser a -> Parser [a] > myListOf p = > char '[' >> > sepBy p listSep >>= \vals -> > char ']' >> > return vals This would probably be better off with a custom version of the 'spaces' parser that didn't parse newlines. Antoine From paolo.losi at gmail.com Sat Apr 4 03:52:38 2009 From: paolo.losi at gmail.com (Paolo Losi) Date: Sat Apr 4 03:47:06 2009 Subject: [Haskell-cafe] Re: Monad transformer, liftIO In-Reply-To: <49D63E20.9050205@nessie.de> References: <49D63E20.9050205@nessie.de> Message-ID: <49D711C6.40101@gmail.com> Michael Roth wrote: > Hello list, > > maybe I'm just stupid, I'm trying to do something like this: Ciao Michael, As an alternative solution to Creighton's: import Control.Monad.List foobar :: ListT IO Int foobar = do a <- ListT . return $ [1,2,3] b <- ListT . return $ [4,5,6] liftIO $ putStrLn $ (show a) ++ " " ++ (show b) return (a+b) main = do sums <- runListT foobar print sums For the expression ListT . return $ [1,2,3] of type ListT IO Int, the return inferred is: return: a -> IO a return [1,2,3] = IO [1,2,3] and then you wrap the IO [] with the ListT newtype constructor. Paolo From tphyahoo at gmail.com Sat Apr 4 04:33:16 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sat Apr 4 04:20:19 2009 Subject: [Haskell-cafe] about Haskell code written to be "too smart" In-Reply-To: References: <49C91B52.6080101@libero.it> <49C92990.9040402@libero.it> Message-ID: <910ddf450904040133j1615df5dycf0f7984f88313f5@mail.gmail.com> > takeListSt' = evalState . foldr k (return []) . map (State . splitAt) > where k m m' = cutNull $ do x<-m; xs<-m'; return (x:xs) > cutNull m = do s<-get; if null s then return [] else m Not only is ths not that elegant anymore, I think it *still* has a bug, stack overflow against testP pf = mapM_ putStrLn [ show $ take 5 $ pf (repeat 0) [1,2,3] , show $ pf ( take 1000 [3,7..] ) [1..100] , show . pf [3,7,11,15] $ ( take (10^6) [1..]) , show . head . last $ pf (take 1000 $ [3,3..]) [1..10^6] ] where the first test (with take 5) is new. whereas the version with explicit recursion and pattern matching doesn't suffer from this problem partitions [] xs = [] partitions (n:parts) xs = let (beg,end) = splitAt n xs in beg : ( case end of [] -> [] xs -> partitions parts xs) I am starting to think that the tricky part in all these functions is that by using higher order functions from the prelude, you sweep the failure case under the rug. Specifically, what happens when splitAt n doesn't have a list of length n? The answer isn't in fact obvious at all. I can think of three things that could hapen. You coud return (list,[]) where list is however many elements there are left. (Which is what all the partitions functions do so far, and the default behavior of splitAt. Or, you could print an error message. Or, you could return ([],[]) My tentative conclusion is that good haskell style makes error modalities explicit when error behavior isn't obvious, or when there is arguably more than one right way to fail. So: partitionsE = partitionsE' error partitionsE2 = partitionsE' ( \e n xs -> []) partitionsE3 = partitionsE' (\e n xs -> [take n xs]) -- corresponds to the behavior of partitions partitionsE' err [] xs = [] partitionsE' err (n:parts) xs = case splitAtE n xs of Left e -> err e n xs Right (beg,end) -> beg : ( case end of [] -> [] xs -> partitionsE' err parts xs ) where splitAtE n as@(x:xs) | n <= length as = Right $ splitAt n as splitAtE n ys = Left $ "can't split at " ++ (show n) ++ ": " ++ (show ys) 2009/3/26 Claus Reinke : > Continuing our adventures into stylistic and semantic differences:-) > > Comparing the 'State' and explicit recursion versions > > ? takeListSt = evalState . mapM (State . splitAt) > > ? -- ..with a derivation leading to.. > > ? takeListSt [] ? ?s = [] > ? takeListSt (h:t) s = x : takeListSt t s' > ? ? where (x,s') = splitAt h s > > instead of > > ? takeList [] _ ? ? ? ? = ?[] > ? takeList _ [] ? ? ? ? = ?[] > ? takeList (n : ns) xs ?= ?head : takeList ns tail > ? ? ? where (head, tail) = splitAt n xs > > we can see some differences, leading to different functions: > > ? *Main> null $ takeListSt [1] undefined > ? False > ? *Main> null $ takeList [1] undefined > ? *** Exception: Prelude.undefined > ? *Main> takeList [0] [] > ? [] > ? *Main> takeListSt [0] [] > ? [[]] > > and similarly for the 'scanl' version > > ? takeListSc ns xs = zipWith take ns $ init $ scanl (flip drop) xs ns > > Depending on usage, these differences might not matter, but what if > we want these different styles to lead to the same function, with only > stylistic and no semantic differences, taking the explicit recursion as > our spec? > > In the 'State' version, the issue is that 'mapM' does not terminate > early, while the specification requires an empty list whenever 'xs' > (the state) is empty. Following the derivation at > > http://www.haskell.org/pipermail/haskell-cafe/2009-March/058603.html > > the first step where we have a handle on that is after unfolding > 'sequence': > > ? takeListSt = evalState . foldr k (return []) . map (State . splitAt) > ? ? where k m m' = do x<-m; xs<-m'; return (x:xs) > > If we change that to > > ? takeListSt' = evalState . foldr k (return []) . map (State . splitAt) > ? ? where k m m' ? ?= cutNull $ do x<-m; xs<-m'; return (x:xs) > ? ? ? ? ? cutNull m = do s<-get; if null s then return [] else m > > and continue with the modified derivation, we should end up with > the right spec (I haven't done this, so you should check!-). This > isn't all that elegant any more, but support for 'mapM' with early > exit isn't all that uncommon a need, either, so one might expect > a 'mapM' variant that takes a 'cut' parameter to make it into the > libraries. > > For the 'scanl' version, we have a more direct handle on the issue: > we can simply drop the offending extras from the 'scanl' result, > replacing 'init' with 'takeWhile (not.null)': > > ? takeListSc' ns xs = zipWith take ns $ takeWhile (not.null) $ scanl (flip > drop) xs ns > > A somewhat abbreviated derivation at the end of this message > seems to confirm that this matches the spec (as usual with proofs, > writing them down doesn't mean that they are correct, but that > readers can check whether they are). > > (btw, both 'takeListSt'' and 'takeListSc'' pass Thomas' 'testP', as does > his 'partitions', but 'partitions' is not the same function as 'takeList': > consider 'null $ takeList [1] undefined' and 'takeList [0] []' ;-) > > Someone suggested using 'mapAccumL' instead of 'State', and > that does indeed work, only that everything is the wrong way round: > > ? takeListMAL = (snd.) . flip (mapAccumL (((snd&&&fst).).(flip splitAt))) > > This is an example where all the "cleverness" is spent on the > irrelevant details, giving them way too much importance. So one > might prefer a version that more clearly says that this is mostly > 'mapAccumL splitAt', with some administratory complications > that might be ignored on cursory inspection: > > ? takeListMAL' = mapAccumL' splitAt' > ? ? where splitAt' l n ? ? ? = swap $ splitAt n l > ? ? ? ? ? mapAccumL' f l acc = snd $ mapAccumL f acc l > ? ? ? ? ? swap (x,y) ? ? ? ? = (y,x) > > Of course, this suffers from the "does not terminate early" issue, > but as this thread encourages us to look at functions we might > not otherwise consider, I thought I'd follow the suggestion, and > perhaps someone might want to modify it with a 'mapAccumL' > with cutoff, and demonstrate whether it matches the spec;-) > > Claus > > -- view transformation: reducing the level of abstraction > > takeList ns xs = zipWith take ns $ takeWhile (not.null) $ scanl (flip drop) > xs ns > > -- fetch definitions of 'zipWith', 'takeWhile', and 'scanl' > > takeList ns xs = zipWith take ns $ takeWhile (not.null) $ scanl (flip drop) > xs ns > ?where scanl f q ls = q : case ?ls of > ? ? ? ? ? ? ? ? ? ? ? ? ? ?[] -> [] > ? ? ? ? ? ? ? ? ? ? ? ? ? ?x:xs -> scanl f (f q x) xs > ? ? ? takeWhile _ [] ? ? ? ? ? ? ? ? = [] > ? ? ? takeWhile p (x:xs) | p x ? ? ? = x : takeWhile p xs > ? ? ? ? ? ? ? ? ? ? ? ? ?| otherwise = [] > ? ? ? zipWith f (a:as) (b:bs) = f a b : zipWith f as bs > ? ? ? zipWith _ _ ? ? ?_ ? ? ?= [] > > -- specialize for 'take', 'not.null', and 'flip drop' > > takeList ns xs = zipWith ns $ takeWhile $ scanl xs ns > ?where scanl q ls = q : case ?ls of > ? ? ? ? ? ? ? ? ? ? ? ? ? ?[] -> [] > ? ? ? ? ? ? ? ? ? ? ? ? ? ?x:xs -> scanl (drop x q) xs > ? ? ? takeWhile [] ? ? ? ? ? ? ? ? ? ?= [] > ? ? ? takeWhile (x:xs) | not (null x) = x : takeWhile xs > ? ? ? ? ? ? ? ? ? ? ? ?| otherwise ? ?= [] > ? ? ? zipWith (a:as) (b:bs) = take a b : zipWith as bs > ? ? ? zipWith _ ? ? ?_ ? ? ?= [] > > -- fuse 'takeWhile' and 'scanl' into 'tws' > > takeList ns xs = zipWith ns $ tws xs ns > ?where tws q ls | not (null q) = q : case ?ls of > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?[] -> [] > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?x:xs -> tws (drop x q) xs > ? ? ? ? ? ? ? ?| otherwise ? ?= [] > ? ? ? zipWith (a:as) (b:bs) = take a b : zipWith as bs > ? ? ? zipWith _ ? ? ?_ ? ? ?= [] > > -- fuse 'zipWith' and 'tws' into 'ztws' > > takeList ns xs = ztws ns xs ns > ?where ztws (a:as) q ls | not (null q) = take a q : case ?ls of > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?[] -> [] > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?x:xs -> ztws as (drop x > q) xs > ? ? ? ? ? ? ? ? ? ? ? ?| otherwise ? ?= [] > ? ? ? ztws _ ? ? ?_ _ ? ? ? ? ? ? ? ? = [] > > -- 'ls' is 'as' > > takeList ns xs = ztws ns xs > ?where ztws (a:as) q | not (null q) = take a q : ztws as (drop a q) > ? ? ? ? ? ? ? ? ? ? | otherwise ? ?= [] > ? ? ? ztws _ ? ? ?_ ? ? ? ? ? ? ? ?= [] > > -- remove indirection > > takeList (a:as) q | not (null q) = take a q : takeList as (drop a q) > ? ? ? ? ? ? ? ? | otherwise ? ?= [] > takeList _ ? ? ?_ ? ? ? ? ? ? ? ?= [] > > -- replace guard by clause > > takeList (a:as) [] = [] > takeList (a:as) q ?= take a q : takeList as (drop a q) > takeList _ ? ? ?_ ?= [] > > -- '_' in last clause has to be '[]' > > takeList (a:as) [] = [] > takeList (a:as) q ?= take a q : takeList as (drop a q) > takeList [] ? ? _ ?= [] > > -- switch non-overlapping clauses > > takeList [] ? ? _ ?= [] > takeList (a:as) [] = [] > takeList (a:as) q ?= take a q : takeList as (drop a q) > > -- for second parameter '[]', both ':' and '[]' in first parameter result in > '[]' > > takeList [] ? ? _ ?= [] > takeList _ ? ? ?[] = [] > takeList (a:as) q ?= take a q : takeList as (drop a q) > > -- (take a q,drop a q) = splitAt a q > > takeList [] ? ? _ ?= [] > takeList _ ? ? ?[] = [] > takeList (a:as) q ?= t : takeList as d > ?where (t,d) = splitAt a q > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From martijn at van.steenbergen.nl Sat Apr 4 05:58:48 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Sat Apr 4 05:45:51 2009 Subject: [Haskell-cafe] Optional EOF in Parsec. In-Reply-To: References: Message-ID: <49D72F58.7010505@van.steenbergen.nl> Kannan Goundan wrote: > I've implemented this functionality in a hand-written parser (basically a hack > that keeps track of whether the last read token was preceded by an EOL, > without making EOL itself a token). Does anybody have ideas about how to > do this with Parsec? You can do exactly the same with Parsec: * create a lexer that yields a [Token], including EOL tokens; * write a function of type [Token] -> [(Token, Bool)] that discards EOLs and tells for each token whether it was preceded by a (now discarded) EOL; * write your pToken :: Token -> Parsec Token function (I omitted some type variables there) that recognises one (Token, Bool)-tuple from the input stream. Or, perhaps easier: * create a lexer that yields a [Token], including EOL tokens; * write a function of type [Token] -> [Token] that discards only those EOL tokens that aren't needed -- for example, those EOL tokens that occur when there are no open ['s, then parse those EOL's explicitly in your parser. Hope this helps, Martijn. From deduktionstheorem at web.de Sat Apr 4 06:01:20 2009 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Sat Apr 4 05:48:24 2009 Subject: [Haskell-cafe] Optional EOF in Parsec. In-Reply-To: References: Message-ID: <49D72FF0.1000500@web.de> Kannan Goundan wrote: > I'm writing a parser with Parsec. In the input language, elements of a sequence > are separated by commas: > > [1, 2, 3] > > However, instead of a comma, you can also use an EOL: > > [1, 2 > 3] > > Anywhere else, EOL is considered ignorable whitespace. So it's not as simple as > just making EOL a token and looking for (comma | eol). Hi Kannan, let's construct the parser top-down. On the top level, you have opening and closing characters, '[' and ']'. Parsec has a function for that: between (char '[') (char ']) And what's in between? A list of elements separated by something. Parsec provides a sepBy function for that: element `sepBy` separator which parses a list of elements separated by separator. What's your separator? Well it's either ',' or a new line and spaces before and after that: mySpaces >> (newline <|> char ',') >> mySpaces -- [1] Let's combine what we've got: myListOf :: (Parsec String () a) -> Parsec String () [a] myListOf elem = between (char '[') (char ']') (elem `sepBy` (mySpaces >> (newline <|> char ',') >> mySpaces)) where mySpaces = many (oneOf (" \t")) And test it in ghci: *Main> parseTest (myListOf anyChar) "[a , b, d ,d\np]" "abddp" Hope this helps! Stephan PS: The important thing is that there are a lot solutions for tricky situations (like yours) in Text.Parsec.Combinator (especially the sepBy and many families). Knowing them can save a lot of work :) [1] I don't use parsec's spaces function because it also accepts newline characters. > > I've implemented this functionality in a hand-written parser (basically a hack > that keeps track of whether the last read token was preceded by an EOL, > without making EOL itself a token). Does anybody have ideas about how to > do this with Parsec? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From bulat.ziganshin at gmail.com Sat Apr 4 06:10:28 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Apr 4 06:00:38 2009 Subject: [Haskell-cafe] ANN: logfloat 0.12.0.1 In-Reply-To: <49D692FB.6040600@freegeek.org> References: <49D692FB.6040600@freegeek.org> Message-ID: <869404872.20090404141028@gmail.com> Hello wren, Saturday, April 4, 2009, 2:51:39 AM, you wrote: > On GHC 6.10 the use of -fvia-C had to be disabled because it conflicts > with the FFI (version 0.12.0.0 still used it, which is fine on GHC 6.8). > I'm still investigating the use of -fasm and getting proper benchmarking > numbers. Contact me if you notice significant performance degradation. isn't this the same bug as in recent thread "[Haskell-cafe] Possible floating point bug in GHC?" ? -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From claus.reinke at talk21.com Sat Apr 4 06:17:50 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Sat Apr 4 06:04:58 2009 Subject: [Haskell-cafe] about Haskell code written to be "too smart" References: <49C91B52.6080101@libero.it><49C92990.9040402@libero.it> <910ddf450904040133j1615df5dycf0f7984f88313f5@mail.gmail.com> Message-ID: > takeListSt' = evalState . foldr k (return []) . map (State . splitAt) > where k m m' = cutNull $ do x<-m; xs<-m'; return (x:xs) > cutNull m = do s<-get; if null s then return [] else m |Not only is ths not that elegant anymore, As I was saying, sequence/mapM with early cutout is common enough that one might want it in the libraries, which would return this variant into readability again. |I think it *still* has a bug, stack overflow against That would really surprise me. Not that it is impossible - as I was also saying, I haven't replayed the derivation for the modified code. However, the modification was arrived at by taking the original derivation, seeing where its result deviated from the explicitly recursive specification, and spotting the aspect of the implicitly recursive version that was responsible for the deviation. Of course, the derivation itself could have an error, but equating the functions themselves gives me rather more confidence/coverage than any finite number of tests could. If I were to enter the derivation into a proof checking tool and be successful, that would further raise the level of confidence/coverage (leaving bugs in the proof checker). Note that I'm not asking whether the original spec did the "right" thing, only whether or not the variations "correctly" do the same thing as the original spec. |testP pf = mapM_ putStrLn [ | show $ take 5 $ pf (repeat 0) [1,2,3] | , show $ pf ( take 1000 [3,7..] ) [1..100] | , show . pf [3,7,11,15] $ ( take (10^6) [1..]) | , show . head . last $ pf (take 1000 $ [3,3..]) [1..10^6] | ] | |where the first test (with take 5) is new. |whereas the version with explicit recursion and pattern matching |doesn't suffer from this problem I get identical results for 'takeListSt'' and the original 'takeList1' (code repeated below). It took me a couple of moments to remember that you had been playing with Control.Monad.State.Strict instead of the default Control.Monad.State(.Lazy). That would invalidate the original derivation (different definition of '>>=', therefore a different end result after unfolding '>>='), let alone the modified code based on it. If you replay the derivation, taking the strictness variations into account, you should arrive at an explicitly recursive version that differs from the spec. Which might make it easier to see what the difference is. |partitions [] xs = [] |partitions (n:parts) xs = | let (beg,end) = splitAt n xs | in beg : ( case end of | [] -> [] | xs -> partitions parts xs) That version cannot be transformed into the original spec, because it doesn't define the same function. As I mentioned: > (btw, both 'takeListSt'' and 'takeListSc'' pass Thomas' 'testP', as does > his 'partitions', but 'partitions' is not the same function as 'takeList': > consider 'null $ takeList [1] undefined' and 'takeList [0] []' ;-) With the original spec takeList1 [] _ = [] takeList1 _ [] = [] takeList1 (n : ns) xs = h : takeList1 ns t where (h, t) = splitAt n xs and 'takeList4' being your 'partitions', we get: *Main> null $ takeList1 [1] undefined *** Exception: Prelude.undefined *Main> null $ takeList4 [1] undefined False *Main> takeList1 [0] [] [] *Main> takeList4 [0] [] [[]] >I am starting to think that the tricky part in all these functions is >that by using higher order functions from the prelude, you sweep the >failure case under the rug. Yes, the reason that more abstract functions are useful is that they hide irrelevant details, allowing us to spend our limited capacity on relevant details. If all abstract functions happen to hide details that matter, more concrete functions that expose those details can be more helpful. But even that has to be qualified: for instance, at first I found it easier to see the issues with the original 'State' variant in its transformed, explicitly recursive version, but after the derivation had convinced me that there was no magic going on, I realized that it was just the old 'mapM' doesn't stop early issue. So I could have seen the issue in the abstract form, but my mind (and apparently other minds, too;-) refused to think about the cornercases there until prompted. If not for this tendency to ignore details that might be relevant, the abstract code would provide an abstract treatment of the failure case as well: instead of working out the details by trying to find useful tests for the explicit pattern matches, we can just look at wether the definition uses 'mapM' or 'mapMWithCut', or whether it uses 'Control.Monad.State' or 'Control.Monad.State.Strict'. Just exposing all the details all the time isn't going to help, as the 'partition' example demonstrates: we might still ignore the relevant details, this time not because they are hidden in abstractions, but because they are hidden in other irrelevant details. There really isn't a single view of software that will serve all purposes, one has to find appropriate views for every task, including using multiple views of the same piece of software. Which is where program transformation comes in handy!-) >Specifically, what happens when splitAt n doesn't have a list >of length n? The answer isn't in fact obvious at all. I can think >of three things that could hapen. I agree that the "right" thing to do can be a matter of dispute, and so I based my definition of "correct" on equivalence to a specific version of the code, the first explicitly recursive version I could find ('takeList1' above). Claus From jon at ffconsultancy.com Sat Apr 4 06:42:37 2009 From: jon at ffconsultancy.com (Jon Harrop) Date: Sat Apr 4 06:23:19 2009 Subject: [Haskell-cafe] g++ std:map vs GHC IntMap In-Reply-To: <49CBA1A0.5000709@libero.it> References: <49CBA1A0.5000709@libero.it> Message-ID: <200904041142.37165.jon@ffconsultancy.com> On Thursday 26 March 2009 15:39:12 Manlio Perillo wrote: > I also tried with Data.HashTable: > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2902 > > but memory usage is 703 MB, and execution time is about 4.5 times slower! This is due to a perf bug in GHC's GC implementation that causes it to traverse entire arrays when a single element has been changed. Hence the Haskell is over an order of magnitude slower than most languages and even slower than Python (!). The purely functional trees that you also used are apparently the idiomatic Haskell workaround but, of course, they are extremely inefficient and still over an order of magnitude slower than any decent hash table. For comparison: Haskell hash table: 44s Haskell map: 7s F# hash table: 0.7s -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e From bugfact at gmail.com Sat Apr 4 08:58:56 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sat Apr 4 08:45:57 2009 Subject: [Haskell-cafe] g++ std:map vs GHC IntMap In-Reply-To: <200904041142.37165.jon@ffconsultancy.com> References: <49CBA1A0.5000709@libero.it> <200904041142.37165.jon@ffconsultancy.com> Message-ID: On Sat, Apr 4, 2009 at 12:42 PM, Jon Harrop wrote: > For comparison: > > Haskell hash table: 44s > Haskell map: 7s > F# hash table: 0.7s Ouch! That's pretty insane. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090404/fe91dc14/attachment.htm From bugfact at gmail.com Sat Apr 4 09:02:48 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sat Apr 4 08:49:50 2009 Subject: [Haskell-cafe] g++ std:map vs GHC IntMap In-Reply-To: References: <49CBA1A0.5000709@libero.it> <200904041142.37165.jon@ffconsultancy.com> Message-ID: So how does F# IntMap version compares to Haskell's IntMap? On Sat, Apr 4, 2009 at 2:58 PM, Peter Verswyvelen wrote: > On Sat, Apr 4, 2009 at 12:42 PM, Jon Harrop wrote: > >> For comparison: >> >> Haskell hash table: 44s >> Haskell map: 7s >> F# hash table: 0.7s > > > Ouch! That's pretty insane. > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090404/0b425112/attachment.htm From gue.schmidt at web.de Sat Apr 4 09:40:56 2009 From: gue.schmidt at web.de (=?UTF-8?B?R8O8wp9udGhlciBTY2htaWR0?=) Date: Sat Apr 4 09:28:13 2009 Subject: [Haskell-cafe] Haskell EDSL to generate SQL? Message-ID: Hi, I tried to solve some large data processing solely in Haskell so I could avoid lots of eventually very long and complex SQL statements. Unfortunately, as was to be expected, that approach doesn't scale. So I do need an SQL backend. But I hope to be able to use an DSL from which I can automatically generate SQL-Strings instead of writing the SQL statements literally. Has anyone else taken a similar approach? G?nther From jeremy at n-heptane.com Sat Apr 4 09:49:57 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Sat Apr 4 09:37:00 2009 Subject: [Haskell-cafe] Haskell EDSL to generate SQL? In-Reply-To: References: Message-ID: <877i20frzu.wl%jeremy@n-heptane.com> At Sat, 04 Apr 2009 15:40:56 +0200, G??nther Schmidt wrote: > But I hope to be able to use an DSL from which I can automatically > generate SQL-Strings instead of writing the SQL statements literally. > > Has anyone else taken a similar approach? HaskellDB has an DSL for generating SQL strings. Though, it is not a straightforward mapping. The haskellDB DSL provides you with relational algebra operators that you use to build your query. - jeremy From akamaus at gmail.com Sat Apr 4 12:59:14 2009 From: akamaus at gmail.com (Dmitry V'yal) Date: Sat Apr 4 09:44:49 2009 Subject: [Haskell-cafe] How to get glyph outline from ttf font. Message-ID: <49D791E2.2010704@gmail.com> Greetings. I'm trying to render some glyphs from ttf font to svg image using gtk2hs cairo binding. Since I can find nothing appropriate in gtk2hs API, I decided to draw outlines with bezier curves myself. But how to get them out of font? As far as I know, freetype library is capable of extracting outlines, but is there any haskell binding for it which supports this functionality? Here [1] one such lib was mentioned, but it wasn't availible online that time. Have situation changed today? Thanks in advance [1] http://www.nabble.com/Re%3A-Rendering-TTF-fonts-in-Haskell-and-OpenGL-p15635659.html From jon at ffconsultancy.com Sat Apr 4 10:14:16 2009 From: jon at ffconsultancy.com (Jon Harrop) Date: Sat Apr 4 09:54:57 2009 Subject: [Haskell-cafe] g++ std:map vs GHC IntMap In-Reply-To: References: <49CBA1A0.5000709@libero.it> Message-ID: <200904041514.16367.jon@ffconsultancy.com> On Saturday 04 April 2009 14:02:48 Peter Verswyvelen wrote: > > On Sat, Apr 4, 2009 at 12:42 PM, Jon Harrop wrote: > >> For comparison: > >> > >> Haskell hash table: 44s > >> Haskell map: 7s > >> F# hash table: 0.7s > > So how does F# IntMap version compares to Haskell's IntMap? F# map: 43.5s -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e From gue.schmidt at web.de Sat Apr 4 10:07:41 2009 From: gue.schmidt at web.de (=?UTF-8?B?R8O8wp9udGhlciBTY2htaWR0?=) Date: Sat Apr 4 09:54:59 2009 Subject: [Haskell-cafe] Re: Haskell EDSL to generate SQL? In-Reply-To: <877i20frzu.wl%jeremy@n-heptane.com> References: <877i20frzu.wl%jeremy@n-heptane.com> Message-ID: Hi Jeremy, thanks for that. I had come across it before but I think I'd prefer a more light-weight approach. G?nther Jeremy Shaw schrieb: > At Sat, 04 Apr 2009 15:40:56 +0200, > G??nther Schmidt wrote: > >> But I hope to be able to use an DSL from which I can automatically >> generate SQL-Strings instead of writing the SQL statements literally. >> >> Has anyone else taken a similar approach? > > HaskellDB has an DSL for generating SQL strings. Though, it is not a > straightforward mapping. The haskellDB DSL provides you with > relational algebra operators that you use to build your query. > > - jeremy From jefferson.r.heard at gmail.com Sat Apr 4 10:08:58 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Sat Apr 4 09:55:59 2009 Subject: [Haskell-cafe] How to get glyph outline from ttf font. In-Reply-To: <49D791E2.2010704@gmail.com> References: <49D791E2.2010704@gmail.com> Message-ID: <4165d3a70904040708i1915ba36o3192cbad470c145e@mail.gmail.com> Yes, the FTGL library, but it uses FTGL on the backend and not freetype directly. You might be able to get the flyph shapes from Pango... On Sat, Apr 4, 2009 at 12:59 PM, Dmitry V'yal wrote: > ? ? ? ?Greetings. I'm trying to render some glyphs from ttf font to svg > image using gtk2hs cairo binding. Since I can find nothing appropriate in > gtk2hs API, ?I decided to draw outlines with bezier curves myself. But how > to get them out of font? As far as I know, freetype library is capable of > extracting outlines, but is there any haskell binding for it which supports > this functionality? > > ? ? ? ?Here [1] one such lib was mentioned, but it wasn't availible online > that time. Have situation changed today? > > Thanks in advance > > [1] > http://www.nabble.com/Re%3A-Rendering-TTF-fonts-in-Haskell-and-OpenGL-p15635659.html > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bugfact at gmail.com Sat Apr 4 10:14:16 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sat Apr 4 10:01:18 2009 Subject: [Haskell-cafe] How to get glyph outline from ttf font. In-Reply-To: <4165d3a70904040708i1915ba36o3192cbad470c145e@mail.gmail.com> References: <49D791E2.2010704@gmail.com> <4165d3a70904040708i1915ba36o3192cbad470c145e@mail.gmail.com> Message-ID: A Haskell binding to Freetype2 is indeed missing. Would be nice to have. On Sat, Apr 4, 2009 at 4:08 PM, Jeff Heard wrote: > Yes, the FTGL library, but it uses FTGL on the backend and not > freetype directly. You might be able to get the flyph shapes from > Pango... > > On Sat, Apr 4, 2009 at 12:59 PM, Dmitry V'yal wrote: > > Greetings. I'm trying to render some glyphs from ttf font to svg > > image using gtk2hs cairo binding. Since I can find nothing appropriate in > > gtk2hs API, I decided to draw outlines with bezier curves myself. But > how > > to get them out of font? As far as I know, freetype library is capable of > > extracting outlines, but is there any haskell binding for it which > supports > > this functionality? > > > > Here [1] one such lib was mentioned, but it wasn't availible > online > > that time. Have situation changed today? > > > > Thanks in advance > > > > [1] > > > http://www.nabble.com/Re%3A-Rendering-TTF-fonts-in-Haskell-and-OpenGL-p15635659.html > > _______________________________________________ > > 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/20090404/7db39c34/attachment.htm From waldmann at imn.htwk-leipzig.de Sat Apr 4 10:55:52 2009 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Sat Apr 4 10:43:05 2009 Subject: [Haskell-cafe] happstack example code wanted Message-ID: <49D774F8.7030709@imn.htwk-leipzig.de> Hi, I'm thinking of using happstack for a simple online registration system. [ Customer gives Name and Address and registers for certain workshops. Then the app server should just produce a bill. (Payment is handled through a different channel.) The "store owner" needs to get some overview of registrations. ] According to happs(tack) marketing department, this should be an easy exercise? Any code that I could use as a starting point? ( Or, if you do the coding, I can link to you from the workshop site. But I don't have a serious budget :-) Thanks - J.W. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 257 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090404/084e8eb5/signature.bin From Tillmann.Vogt at rwth-aachen.de Sat Apr 4 11:33:57 2009 From: Tillmann.Vogt at rwth-aachen.de (Tillmann Vogt) Date: Sat Apr 4 11:21:01 2009 Subject: [Haskell-cafe] How to get glyph outline from ttf font. In-Reply-To: References: Message-ID: <49D77DE5.9080901@rwth-aachen.de> Dmitry V'yal schrieb: > Greetings. I'm trying to render some glyphs from ttf font to svg > image using gtk2hs cairo binding. Since I can find nothing appropriate > in gtk2hs API, I decided to draw outlines with bezier curves myself. > But how to get them out of font? As far as I know, freetype library is > capable of extracting outlines, but is there any haskell binding for it > which supports this functionality? > > Here [1] one such lib was mentioned, but it wasn't availible online > that time. Have situation changed today? > > Thanks in advance > > [1] > http://www.nabble.com/Re%3A-Rendering-TTF-fonts-in-Haskell-and-OpenGL-p15635659.html > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe Hi Dmitry, I cannot help you directly with freetype. But I have developped a library that parses the svg-font format (this is not svg). Since svg-font is XML it is much easier to parse than ttf. There is also a program called fontforge that can be used to convert nearly every format into svg-font. The only problem is that currently triangulation has some bugs and is only O(n^2), the algorithm for deleting holes is not finished, and memoization isn't implemented. Should I upload the work although it is not finished? From manlio_perillo at libero.it Sat Apr 4 11:33:55 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sat Apr 4 11:21:10 2009 Subject: [Haskell-cafe] about import alias Message-ID: <49D77DE3.60900@libero.it> Hi. Haskell 98 allows import alias: import qualified VeryLongModuleName as C however it does not allow aliasing for imported names import NormalModule (veryLongFunctionName as C) what is the rational? IMHO this can be very useful in some cases. Thanks Manlio From marcin.kosiba at gmail.com Sat Apr 4 11:42:48 2009 From: marcin.kosiba at gmail.com (Marcin Kosiba) Date: Sat Apr 4 11:29:58 2009 Subject: [Haskell-cafe] about import alias In-Reply-To: <49D77DE3.60900@libero.it> References: <49D77DE3.60900@libero.it> Message-ID: <200904041742.52087.marcin.kosiba@gmail.com> On Saturday 04 April 2009, Manlio Perillo wrote: > Hi. > > Haskell 98 allows import alias: > import qualified VeryLongModuleName as C > > however it does not allow aliasing for imported names > import NormalModule (veryLongFunctionName as C) > > > what is the rational? > IMHO this can be very useful in some cases. While I do agree with the argument that it could be useful in some cases, misuse of this feature would cause a lot of confusion, consider: from System.IO.Unsafe import (unsafePerformIO as safe) I think that the alias feature is OK, when the namespace is long, longfunctionnameswhichareapaintoreadandespeciallywrite are a bug and should be treated and fixed by the owner of that code, not by the user. If very function names are that much of a problem to you consider a wrapper library. -- Cheers! Marcin Kosiba -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part. Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090404/0a390f79/attachment.bin From daniel.is.fischer at web.de Sat Apr 4 11:43:35 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Apr 4 11:30:43 2009 Subject: [Haskell-cafe] about import alias In-Reply-To: <49D77DE3.60900@libero.it> References: <49D77DE3.60900@libero.it> Message-ID: <200904041743.35443.daniel.is.fischer@web.de> Am Samstag 04 April 2009 17:33:55 schrieb Manlio Perillo: > Hi. > > Haskell 98 allows import alias: > import qualified VeryLongModuleName as C > > however it does not allow aliasing for imported names > import NormalModule (veryLongFunctionName as C) > > > what is the rational? > IMHO this can be very useful in some cases. > You can always do {-# INLINE short #-} short = C.veryLongFunctionNameThatIReallyDoNotWantToTypeOutEveryTimeIUseIt so it's not necessary. > > > Thanks Manlio From ndmitchell at gmail.com Sat Apr 4 12:13:48 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sat Apr 4 12:00:49 2009 Subject: [Haskell-cafe] about import alias In-Reply-To: <200904041743.35443.daniel.is.fischer@web.de> References: <49D77DE3.60900@libero.it> <200904041743.35443.daniel.is.fischer@web.de> Message-ID: <404396ef0904040913v6a619e7br5b637e0769ddd060@mail.gmail.com> Hi > You can always do > > {-# INLINE short #-} > short = > C.veryLongFunctionNameThatIReallyDoNotWantToTypeOutEveryTimeIUseIt The INLINE pragma is not necessary, if an optimising compiler fails to inline that then it's not very good. However, you might want to consider the (evil) monomorphism restriction which will make that pattern fail for any functions with type classes. Thanks Neil From bugfact at gmail.com Sat Apr 4 12:19:07 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sat Apr 4 12:06:09 2009 Subject: [Haskell-cafe] ANN: logfloat 0.12.0.1 In-Reply-To: <869404872.20090404141028@gmail.com> References: <49D692FB.6040600@freegeek.org> <869404872.20090404141028@gmail.com> Message-ID: Indeed. I recommend upgrading to GHC 6.10.2, all the weird floating point FFI bugs I encountered with GHC 6.10.1 seem to be resolved now. On Sat, Apr 4, 2009 at 12:10 PM, Bulat Ziganshin wrote: > Hello wren, > > Saturday, April 4, 2009, 2:51:39 AM, you wrote: > > > On GHC 6.10 the use of -fvia-C had to be disabled because it conflicts > > with the FFI (version 0.12.0.0 still used it, which is fine on GHC 6.8). > > I'm still investigating the use of -fasm and getting proper benchmarking > > numbers. Contact me if you notice significant performance degradation. > > isn't this the same bug as in recent thread "[Haskell-cafe] Possible > floating point bug in GHC?" ? > > > -- > 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/20090404/ca481555/attachment.htm From bugfact at gmail.com Sat Apr 4 12:40:21 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sat Apr 4 12:27:22 2009 Subject: [Haskell-cafe] ANN: logfloat 0.12.0.1 In-Reply-To: <869404872.20090404141028@gmail.com> References: <49D692FB.6040600@freegeek.org> <869404872.20090404141028@gmail.com> Message-ID: Indeed. I recommend upgrading to GHC 6.10.2, all the weird floating point FFI bugs I encountered with GHC 6.10.1 seem to be resolved now. On Sat, Apr 4, 2009 at 12:10 PM, Bulat Ziganshin wrote: > Hello wren, > > Saturday, April 4, 2009, 2:51:39 AM, you wrote: > > > On GHC 6.10 the use of -fvia-C had to be disabled because it conflicts > > with the FFI (version 0.12.0.0 still used it, which is fine on GHC 6.8). > > I'm still investigating the use of -fasm and getting proper benchmarking > > numbers. Contact me if you notice significant performance degradation. > > isn't this the same bug as in recent thread "[Haskell-cafe] Possible > floating point bug in GHC?" ? > > > -- > 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/20090404/07d9be14/attachment.htm From bugfact at gmail.com Sat Apr 4 12:57:00 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sat Apr 4 12:44:05 2009 Subject: [Haskell-cafe] ANN: logfloat 0.12.0.1 In-Reply-To: <869404872.20090404141028@gmail.com> References: <49D692FB.6040600@freegeek.org> <869404872.20090404141028@gmail.com> Message-ID: Indeed. I recommend upgrading to GHC 6.10.2, all the weird floating point FFI bugs I encountered with GHC 6.10.1 seem to be resolved now. On Sat, Apr 4, 2009 at 12:10 PM, Bulat Ziganshin wrote: > Hello wren, > > Saturday, April 4, 2009, 2:51:39 AM, you wrote: > > > On GHC 6.10 the use of -fvia-C had to be disabled because it conflicts > > with the FFI (version 0.12.0.0 still used it, which is fine on GHC 6.8). > > I'm still investigating the use of -fasm and getting proper benchmarking > > numbers. Contact me if you notice significant performance degradation. > > isn't this the same bug as in recent thread "[Haskell-cafe] Possible > floating point bug in GHC?" ? > > > -- > 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/20090404/0a990e08/attachment.htm From tphyahoo at gmail.com Sat Apr 4 13:30:22 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sat Apr 4 13:17:27 2009 Subject: [Haskell-cafe] happstack example code wanted In-Reply-To: <49D774F8.7030709@imn.htwk-leipzig.de> References: <49D774F8.7030709@imn.htwk-leipzig.de> Message-ID: <910ddf450904041030x6a31c7e2m2a2030abbed39842@mail.gmail.com> Johannes, You'll have a better response if you post to the happs list. Have you had a look at tutorial.happstack.com? Thomas. 2009/4/4 Johannes Waldmann : > Hi, I'm thinking of using happstack for a simple > online registration system. [ Customer gives > Name and Address and registers for certain workshops. > Then the app server should just produce a bill. > (Payment is handled through a different channel.) > The "store owner" needs to get some overview of > registrations. ] According to happs(tack) marketing > department, this should be an easy exercise? > Any code that I could use as a starting point? > ( Or, if you do the coding, I can link to you from > the workshop site. But I don't have a serious budget :-) > Thanks - J.W. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From wagner.andrew at gmail.com Sat Apr 4 13:32:43 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Sat Apr 4 13:19:44 2009 Subject: [Haskell-cafe] happstack example code wanted In-Reply-To: <910ddf450904041030x6a31c7e2m2a2030abbed39842@mail.gmail.com> References: <49D774F8.7030709@imn.htwk-leipzig.de> <910ddf450904041030x6a31c7e2m2a2030abbed39842@mail.gmail.com> Message-ID: Copied there. On Sat, Apr 4, 2009 at 1:30 PM, Thomas Hartman wrote: > Johannes, > > You'll have a better response if you post to the happs list. > > Have you had a look at tutorial.happstack.com? > > Thomas. > > 2009/4/4 Johannes Waldmann : > > Hi, I'm thinking of using happstack for a simple > > online registration system. [ Customer gives > > Name and Address and registers for certain workshops. > > Then the app server should just produce a bill. > > (Payment is handled through a different channel.) > > The "store owner" needs to get some overview of > > registrations. ] According to happs(tack) marketing > > department, this should be an easy exercise? > > Any code that I could use as a starting point? > > ( Or, if you do the coding, I can link to you from > > the workshop site. But I don't have a serious budget :-) > > Thanks - J.W. > > > > > > _______________________________________________ > > 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/20090404/a54e34b3/attachment.htm From tphyahoo at gmail.com Sat Apr 4 13:41:31 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sat Apr 4 13:28:34 2009 Subject: [Haskell-cafe] about Haskell code written to be "too smart" In-Reply-To: References: <49C91B52.6080101@libero.it> <49C92990.9040402@libero.it> <910ddf450904040133j1615df5dycf0f7984f88313f5@mail.gmail.com> Message-ID: <910ddf450904041041w5e48fd46vfb845e95b1334930@mail.gmail.com> Thanks Claus, Indeed the problem was that I was using the Strict state monad, with lazy state it does the right thing when run through testP. I will try and get back to this thread if I manage the derivation which "proves" (or at least supports) that the two versions are equivalent. 2009/4/4 Claus Reinke : >> ?takeListSt' = evalState . foldr k (return []) . map (State . splitAt) >> ? ?where k m m' ? ?= cutNull $ do x<-m; xs<-m'; return (x:xs) >> ? ? ? ? ?cutNull m = do s<-get; if null s then return [] else m > > |Not only is ths not that elegant anymore, > As I was saying, sequence/mapM with early cutout is common > enough that one might want it in the libraries, which would return > this variant into readability again. > > |I think it *still* has a bug, stack overflow against > > That would really surprise me. Not that it is impossible - as I was > also saying, I haven't replayed the derivation for the modified code. > However, the modification was arrived at by taking the original > derivation, seeing where its result deviated from the explicitly > recursive specification, and spotting the aspect of the implicitly > recursive version that was responsible for the deviation. > Of course, the derivation itself could have an error, but equating the > functions themselves gives me rather more confidence/coverage than any > finite number of tests could. If I were to enter the derivation > into a proof checking tool and be successful, that would further raise > the level of confidence/coverage (leaving bugs in the proof checker). > > Note that I'm not asking whether the original spec did the "right" > thing, only whether or not the variations "correctly" do the same > thing as the original spec. > > |testP pf = mapM_ putStrLn ?[ > | ? ? ? ? ?show $ take 5 $ pf (repeat 0) [1,2,3] > | ? ? ? ? ?, show $ pf ( take 1000 [3,7..] ) [1..100] > | ? ? ? ? ?, show . pf [3,7,11,15] $ ( take (10^6) [1..]) > | ? ? ? ? ?, show . head . last $ pf (take 1000 $ [3,3..]) [1..10^6] > | ? ? ? ?] > | > |where the first test (with take 5) is new. > |whereas the version with explicit recursion and pattern matching > |doesn't suffer from this problem > > I get identical results for 'takeListSt'' and the original 'takeList1' > (code repeated below). > It took me a couple of moments to remember that you had been playing with > Control.Monad.State.Strict instead of the default > Control.Monad.State(.Lazy). That would invalidate the original derivation > (different definition of '>>=', therefore a different end result after > unfolding '>>='), let alone the modified code based on it. > If you replay the derivation, taking the strictness variations into account, > you should arrive at an explicitly recursive version that > differs from the spec. Which might make it easier to see what > the difference is. > > |partitions [] xs = [] > |partitions (n:parts) xs = > | ?let (beg,end) = splitAt n xs > | ?in ?beg : ( case end of > | ? ? ? ? ? ? ? [] -> [] > | ? ? ? ? ? ? ? xs -> partitions parts xs) > > That version cannot be transformed into the original spec, because > it doesn't define the same function. As I mentioned: > >> (btw, both 'takeListSt'' and 'takeListSc'' pass Thomas' 'testP', as does >> his 'partitions', but 'partitions' is not the same function as 'takeList': >> consider 'null $ takeList [1] undefined' and 'takeList [0] []' ;-) > > With the original spec > > takeList1 [] _ ? ? ? ? = ?[] > takeList1 _ [] ? ? ? ? = ?[] > takeList1 (n : ns) xs ?= ?h : takeList1 ns t > ? where (h, t) = splitAt n xs > > and 'takeList4' being your 'partitions', we get: > > *Main> null $ takeList1 [1] undefined > *** Exception: Prelude.undefined > *Main> null $ takeList4 [1] undefined > False > *Main> takeList1 [0] [] > [] > *Main> takeList4 [0] [] > [[]] > >> I am starting to think that the tricky part in all these functions is >> that by using higher order functions from the prelude, you sweep the >> failure case under the rug. > > Yes, the reason that more abstract functions are useful is that they > hide irrelevant details, allowing us to spend our limited capacity on > relevant details. If all abstract functions happen to hide details that > matter, more concrete functions that expose those details can be more > helpful. > But even that has to be qualified: for instance, at first I found it easier > to see the issues with the original 'State' variant in its transformed, > explicitly recursive version, but after the derivation had convinced me that > there was no magic going on, I realized that it was just the old 'mapM' > doesn't stop early issue. So I could have seen the issue in the abstract > form, but my mind (and apparently other minds, too;-) refused to think about > the cornercases there until prompted. > If not for this tendency to ignore details that might be relevant, the > abstract code would provide an abstract treatment of the failure case as > well: instead of working out the details by trying to find useful tests for > the explicit pattern matches, we can just look at > wether the definition uses 'mapM' or 'mapMWithCut', or whether > it uses 'Control.Monad.State' or 'Control.Monad.State.Strict'. > > Just exposing all the details all the time isn't going to help, as the > 'partition' example demonstrates: we might still ignore the relevant > details, this time not because they are hidden in abstractions, but > because they are hidden in other irrelevant details. There really > isn't a single view of software that will serve all purposes, one > has to find appropriate views for every task, including using > multiple views of the same piece of software. Which is where > program transformation comes in handy!-) > >> Specifically, what happens when splitAt n doesn't have a list of length n? >> The answer isn't in fact obvious at all. I can think of three things that >> could hapen. > > I agree that the "right" thing to do can be a matter of dispute, and > so I based my definition of "correct" on equivalence to a specific version > of the code, the first explicitly recursive version I could find > ('takeList1' above). > > Claus > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jefferson.r.heard at gmail.com Sat Apr 4 13:57:21 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Sat Apr 4 13:44:20 2009 Subject: [Haskell-cafe] First time I've gotten gtk2hs to install from ports on Mac OS X from scratch Message-ID: <4165d3a70904041057s5524cdecgbd05d16a5455c0c@mail.gmail.com> The instructions in the leksah manuals seem to work for doing a straight-up ports install of gtk2hs. I've never managed to get it to install without compiling manually, but this worked $ sudo port install gtk2 cairo librsvg libglade2 gtksourceview2 gtkglext gtk-chtheme gtk2-clearlooks $ sudo port -k install ghc gtk2hs hs-cabal Unfortunately leksah itself won't link... From jefferson.r.heard at gmail.com Sat Apr 4 14:01:03 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Sat Apr 4 13:48:05 2009 Subject: [Haskell-cafe] Leksah+Gtk2Hs link error on Mac OS X Leopard Message-ID: <4165d3a70904041101k723edb64n6ea3a3d6b2233de8@mail.gmail.com> I tried installing leskah on OS X using the x11 version of gtk2hs (because I use gtkglext a lot in my work, and need it, therefore the quartz build won't work for me) I get these errors. Is this leksah specific or is this a more general problem with gtk2hs? Linking dist/build/leksah/leksah ... ld warning: atom sorting error for _ghczm6zi10zi1_LibFFI_Czuffizutype_closure_tbl and _ghczm6zi10zi1_LibFFI_Czuffizucif_closure_tbl in /opt/local/lib/ghc-6.10.1/ghc-6.10.1/libHSghc-6.10.1.a(LibFFI.o) ld warning: atom sorting error for _ghczm6zi10zi1_LibFFI_Czuffizutype_closure_tbl and _ghczm6zi10zi1_LibFFI_Czuffizucif_closure_tbl in /opt/local/lib/ghc-6.10.1/ghc-6.10.1/libHSghc-6.10.1.a(LibFFI.o) $ ~/.cabal/bin/leksah dyld: lazy symbol binding failed: Symbol not found: _cairo_quartz_font_face_create_for_atsu_font_id Referenced from: /opt/local/lib/libpangocairo-1.0.0.dylib Expected in: /opt/local/lib/libcairo.2.dylib dyld: Symbol not found: _cairo_quartz_font_face_create_for_atsu_font_id Referenced from: /opt/local/lib/libpangocairo-1.0.0.dylib Expected in: /opt/local/lib/libcairo.2.dylib Trace/BPT trap From dagit at codersbase.com Sat Apr 4 15:15:01 2009 From: dagit at codersbase.com (Jason Dagit) Date: Sat Apr 4 15:02:01 2009 Subject: [Haskell-cafe] First time I've gotten gtk2hs to install from ports on Mac OS X from scratch In-Reply-To: <4165d3a70904041057s5524cdecgbd05d16a5455c0c@mail.gmail.com> References: <4165d3a70904041057s5524cdecgbd05d16a5455c0c@mail.gmail.com> Message-ID: Hi Jeff, On Sat, Apr 4, 2009 at 10:57 AM, Jeff Heard wrote: > The instructions in the leksah manuals seem to work for doing a > straight-up ports install of gtk2hs. ?I've never managed to get it to > install without compiling manually, but this worked > > $ sudo port install gtk2 cairo librsvg libglade2 gtksourceview2 > gtkglext gtk-chtheme gtk2-clearlooks > $ sudo port -k install ghc gtk2hs hs-cabal > > Unfortunately leksah itself won't link... I think people might be able to help you, but I think we need the exact error message. Unfortunately, "won't link" is a bit too vague to make any suggestions. Jason From dagit at codersbase.com Sat Apr 4 15:19:42 2009 From: dagit at codersbase.com (Jason Dagit) Date: Sat Apr 4 15:06:42 2009 Subject: [Haskell-cafe] First time I've gotten gtk2hs to install from ports on Mac OS X from scratch In-Reply-To: References: <4165d3a70904041057s5524cdecgbd05d16a5455c0c@mail.gmail.com> Message-ID: On Sat, Apr 4, 2009 at 12:15 PM, Jason Dagit wrote: > I think people might be able to help you, but I think we need the > exact error message. ?Unfortunately, "won't link" is a bit too vague > to make any suggestions. Nevermind my message. I see you sent the error in a different thread. Jason From cristiano.paris at gmail.com Sat Apr 4 16:05:02 2009 From: cristiano.paris at gmail.com (Cristiano Paris) Date: Sat Apr 4 15:52:22 2009 Subject: [Haskell-cafe] System.Process.Posix Message-ID: Is it me or the above package is not included in Hoogle? Cristiano From jefferson.r.heard at gmail.com Sat Apr 4 16:16:43 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Sat Apr 4 16:03:45 2009 Subject: [Haskell-cafe] Link errors in Gtk2Hs are more general than I thought. Message-ID: <4165d3a70904041316n55bd47e6g9c44e48ae63f883e@mail.gmail.com> I tried to get yi to run on my Mac earlier and I get the following errors: dyld: lazy symbol binding failed: Symbol not found: _cairo_quartz_font_face_create_for_atsu_font_id Referenced from: /opt/local/lib/libpangocairo-1.0.0.dylib Expected in: /opt/local/lib/libcairo.2.dylib dyld: Symbol not found: _cairo_quartz_font_face_create_for_atsu_font_id Referenced from: /opt/local/lib/libpangocairo-1.0.0.dylib Expected in: /opt/local/lib/libcairo.2.dylib Trace/BPT trap The commands I used to install gtk2hs (which gave me no errors were) $ sudo port selfupdate $ sudo port install gtk2 cairo librsvg libglade2 gtksourceview2 gtkglext $ sudo port install gtk-chtheme gtk2-clearlooks && sudo port -k install ghc gtk2hs hs-cabal $ cabal install yi Running OS X 10.5.6 (Leopard) on a MacBook 2.4 gHz Core 2 Duo -- Jeff ---------- Forwarded message ---------- From: Jeff Heard Date: Sat, Apr 4, 2009 at 2:01 PM Subject: Leksah+Gtk2Hs link error on Mac OS X Leopard To: Haskell Cafe I tried installing leskah on OS X using the x11 version of gtk2hs (because I use gtkglext a lot in my work, and need it, therefore the quartz build won't work for me) ?I get these errors. ?Is this leksah specific or is this a more general problem with gtk2hs? Linking dist/build/leksah/leksah ... ld warning: atom sorting error for _ghczm6zi10zi1_LibFFI_Czuffizutype_closure_tbl and _ghczm6zi10zi1_LibFFI_Czuffizucif_closure_tbl in /opt/local/lib/ghc-6.10.1/ghc-6.10.1/libHSghc-6.10.1.a(LibFFI.o) ld warning: atom sorting error for _ghczm6zi10zi1_LibFFI_Czuffizutype_closure_tbl and _ghczm6zi10zi1_LibFFI_Czuffizucif_closure_tbl in /opt/local/lib/ghc-6.10.1/ghc-6.10.1/libHSghc-6.10.1.a(LibFFI.o) $ ~/.cabal/bin/leksah dyld: lazy symbol binding failed: Symbol not found: _cairo_quartz_font_face_create_for_atsu_font_id ?Referenced from: /opt/local/lib/libpangocairo-1.0.0.dylib ?Expected in: /opt/local/lib/libcairo.2.dylib dyld: Symbol not found: _cairo_quartz_font_face_create_for_atsu_font_id ?Referenced from: /opt/local/lib/libpangocairo-1.0.0.dylib ?Expected in: /opt/local/lib/libcairo.2.dylib Trace/BPT trap From bulat.ziganshin at gmail.com Sat Apr 4 16:21:36 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Apr 4 16:08:52 2009 Subject: [Haskell-cafe] System.Process.Posix In-Reply-To: References: Message-ID: <20481029.20090405002136@gmail.com> Hello Cristiano, Sunday, April 5, 2009, 12:05:02 AM, you wrote: > Is it me or the above package is not included in Hoogle? afair, Neil, being windows user, includes only packages available for his own system there was a large thread a few months ago and many peoples voted for excluding any OS-specific packages at all since this decreases portability of code developed by Hoogle users :))) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From cristiano.paris at gmail.com Sat Apr 4 16:28:10 2009 From: cristiano.paris at gmail.com (Cristiano Paris) Date: Sat Apr 4 16:15:30 2009 Subject: [Haskell-cafe] System.Process.Posix In-Reply-To: <20481029.20090405002136@gmail.com> References: <20481029.20090405002136@gmail.com> Message-ID: On Sat, Apr 4, 2009 at 10:21 PM, Bulat Ziganshin wrote: > Hello Cristiano, > ... > there was a large thread a few months ago and many peoples voted for > excluding any OS-specific packages at all since this decreases > portability of code developed by Hoogle users :))) Nice shot :D So how do I fork a new system process ? Thank you folks. Cristiano From dons at galois.com Sat Apr 4 16:28:46 2009 From: dons at galois.com (Don Stewart) Date: Sat Apr 4 16:16:50 2009 Subject: [Haskell-cafe] System.Process.Posix In-Reply-To: References: <20481029.20090405002136@gmail.com> Message-ID: <20090404202846.GB26834@whirlpool.galois.com> cristiano.paris: > On Sat, Apr 4, 2009 at 10:21 PM, Bulat Ziganshin > wrote: > > Hello Cristiano, > > ... > > there was a large thread a few months ago and many peoples voted for > > excluding any OS-specific packages at all since this decreases > > portability of code developed by Hoogle users :))) > > Nice shot :D > > So how do I fork a new system process ? Thank you folks. Isn't this the goal of the process package? http://hackage.haskell.org/cgi-bin/hackage-scripts/package/process -- Don From ben.franksen at online.de Sat Apr 4 16:59:55 2009 From: ben.franksen at online.de (Ben Franksen) Date: Sat Apr 4 16:47:14 2009 Subject: [Haskell-cafe] Re: .editrc References: Message-ID: brad clawsie wrote: > does anyone have a .editrc they can provide that allows ghci to be used > on freebsd? > > i'm not looking for anything fancy, just backspace not being broken etc You could try to cabal install ghci-haskeline and see if that works better. Cheers Ben From lemming at henning-thielemann.de Sat Apr 4 18:32:10 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Apr 4 18:19:14 2009 Subject: [Haskell-cafe] Reverting to any old version using Darcs In-Reply-To: <20090401171436.GA12860@whirlpool.galois.com> References: <20090401171436.GA12860@whirlpool.galois.com> Message-ID: On Wed, 1 Apr 2009, Don Stewart wrote: > bugfact: >> Rumor goes that this is very difficult to do with Darcs. Is this correct? > > darcs unpull Be careful - you cannot revert this! If you want to unpull patches, that were not distributed so far, you should better call 'darcs get' to get a copy of the repository and then run 'darcs unpull' in this copy. From lemming at henning-thielemann.de Sat Apr 4 18:38:37 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Apr 4 18:25:38 2009 Subject: [Haskell-cafe] Announcement: Beta of Leksah IDE available In-Reply-To: <4165d3a70904030846k470e6eb1w10e4851272cc00bc@mail.gmail.com> References: <1238538058.6785.11.camel@jutaro-laptop> <20090401011918.0a3af602@solaris> <22831401.post@talk.nabble.com> <404396ef0904011047n45f36662yf6fc728097c60f28@mail.gmail.com> <22834510.post@talk.nabble.com> <1238666190.25888.1391.camel@localhost> <49D4AB12.2090100@gmail.com> <22846713.post@talk.nabble.com> <4165d3a70904030846k470e6eb1w10e4851272cc00bc@mail.gmail.com> Message-ID: On Fri, 3 Apr 2009, Jeff Heard wrote: > Jurgen... I have one more question, or rather request... I'm running > under Ubuntu, and I get inconsistencies with packages that I build and > install via Leksah not showing up when I configure other packages that > depend on them. Then I notice that you're using runhaskell Setup.lhs > ... to configure build and install. I wonder if you could change all > that from "runhaskell Setup.lhs" to "cabal" wherever you run it? I think 'cabal' has more dependencies (zlib, HTTP) and is thus more difficult to port than Setup.lhs. From lemming at henning-thielemann.de Sat Apr 4 18:59:37 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Apr 4 18:46:38 2009 Subject: [Haskell-cafe] ANNOUNCE: fad 1.0 -- Forward Automatic Differentiation library In-Reply-To: <8b2a1a960904021928s2c44abb2g63143aa9823cc1ae@mail.gmail.com> References: <8b2a1a960904021928s2c44abb2g63143aa9823cc1ae@mail.gmail.com> Message-ID: On Thu, 2 Apr 2009, Bjorn Buckwalter wrote: > I'm pleased to announce the initial release of the Haskell fad > library, developed by Barak A. Pearlmutter and Jeffrey Mark Siskind. > Fad provides Forward Automatic Differentiation (AD) for functions > polymorphic over instances of 'Num'. There have been many Haskell > implementations of forward AD, with varying levels of completeness, > published in papers and blog posts[1], but alarmingly few of these > have made it into hackage -- to date Conal Elliot's vector-spaces[2] > package is the only one I am aware of. Do you count computations with power series also as Automatic Differentiation? I mean, arithmetic on power series is just working with all derivatives simultaneously. with Haskell 98 type classes: http://darcs.haskell.org/htam/src/PowerSeries/Taylor.hs with advanced type classes: http://hackage.haskell.org/packages/archive/numeric-prelude/0.0.5/doc/html/MathObj-PowerSeries.html From nowgate at yahoo.com Sat Apr 4 20:40:33 2009 From: nowgate at yahoo.com (michael rice) Date: Sat Apr 4 20:27:33 2009 Subject: [Haskell-cafe] Combining sequences Message-ID: <790464.36313.qm@web31104.mail.mud.yahoo.com> Is there a simple way to combine two sequences that are in ascending order into a single sequence that's also in ascending order? An example would be the squares [1,4,9,16,25..] combined with the cubes [1,8,27,64,125..] to form [1,1,4,8,9,16,25,27..]. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090404/cbe80822/attachment.htm From wagner.andrew at gmail.com Sat Apr 4 20:56:37 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Sat Apr 4 20:43:37 2009 Subject: [Haskell-cafe] Combining sequences In-Reply-To: <790464.36313.qm@web31104.mail.mud.yahoo.com> References: <790464.36313.qm@web31104.mail.mud.yahoo.com> Message-ID: Here's a pretty straightforward approach: combine [] ys = ys combine xs [] = xs combine (x:xs) (y:ys) | x <= y = x : combine xs (y:ys) | otherwise = y : combine (x:xs) ys On Sat, Apr 4, 2009 at 8:40 PM, michael rice wrote: > Is there a simple way to combine two sequences that are in ascending order > into a single sequence that's also in ascending order? An example would be > the squares [1,4,9,16,25..] combined with the cubes [1,8,27,64,125..] to > form [1,1,4,8,9,16,25,27..]. > > Michael > > > > _______________________________________________ > 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/20090404/3fb5e6a1/attachment.htm From trentbuck at gmail.com Sat Apr 4 21:13:53 2009 From: trentbuck at gmail.com (Trent W. Buck) Date: Sat Apr 4 21:02:01 2009 Subject: [Haskell-cafe] Re: Reverting to any old version using Darcs References: <20090401171436.GA12860@whirlpool.galois.com> Message-ID: <30hc137vhq.fsf@alexlance.com> Henning Thielemann writes: > On Wed, 1 Apr 2009, Don Stewart wrote: > >> bugfact: >>> Rumor goes that this is very difficult to do with Darcs. Is this correct? >> >> darcs unpull > > Be careful - you cannot revert this! If you want to unpull patches, > that were not distributed so far, you should better call 'darcs get' > to get a copy of the repository and then run 'darcs unpull' in this > copy. For the record, unpull is now called "obliterate", and "unpull" is an alias for it. This new name is meant to instill caution in the user :-) From nowgate at yahoo.com Sat Apr 4 23:29:34 2009 From: nowgate at yahoo.com (michael rice) Date: Sat Apr 4 23:16:34 2009 Subject: [Haskell-cafe] Combining sequences Message-ID: <394457.93625.qm@web31101.mail.mud.yahoo.com> Thanks, guys! This one works perfectly. I was monkeying with similar logic but wasn't sure about syntax. Michael --- On Sat, 4/4/09, Andrew Wagner wrote: From: Andrew Wagner Subject: Re: [Haskell-cafe] Combining sequences To: "michael rice" Cc: haskell-cafe@haskell.org Date: Saturday, April 4, 2009, 8:56 PM Here's a pretty straightforward approach: combine [] ys = ys combine xs [] = xs combine (x:xs) (y:ys) | x <= y = x : combine xs (y:ys) ????????????????????????????????? | otherwise = y : combine (x:xs) ys On Sat, Apr 4, 2009 at 8:40 PM, michael rice wrote: Is there a simple way to combine two sequences that are in ascending order into a single sequence that's also in ascending order? An example would be the squares [1,4,9,16,25..] combined with the cubes [1,8,27,64,125..] to form [1,1,4,8,9,16,25,27..]. Michael _______________________________________________ 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/20090404/451a0f20/attachment.htm From byorgey at seas.upenn.edu Sun Apr 5 00:15:13 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sun Apr 5 00:02:12 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 112 - April 5, 2009 Message-ID: <20090405041513.GA20612@seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090405 Issue 112 - April 05, 2009 --------------------------------------------------------------------------- Welcome to issue 112 of HWN, a newsletter covering developments in the [1]Haskell community. Announcements hgettext-0.1.5 - GetText based internationalization of Haskell programs. Vasyl Pasternak [2]announced a new release of the [3]hgettext package for internationalization of Haskell programs, which now supports distribution and installation of PO files. Buster 0.99.1, a library for application orchestration that is not FRP. Jeff Heard [4]announced the release of [5]Buster, an FRP-like framework for constructing reactive programs with a bus model. Call for Contributions - Haskell Communities and Activities Report, May 2009 edition. Janis Voigtlaender [6]issued a call for contributions to the 16th edition of the [7]Haskell Communities & Activities Report. The submission deadline is 1 May 2009. If you are working on any project that is in some way related to Haskell, please write a short entry and submit it. Even if the project is very small or unfinished or you think it is not important enough -- please reconsider and submit an entry anyway! fad 1.0 -- Forward Automatic Differentiation library. Bjorn Buckwalter [8]announced the initial release of the Haskell [9]fad library, developed by Barak A. Pearlmutter and Jeffrey Mark Siskind. Fad provides Forward Automatic Differentiation (AD) for functions polymorphic over instances of 'Num'. hledger 0.4 released. Simon Michael [10]announced the release of [11]hledger 0.4, a text-mode double-entry accounting tool. It reads a plain text journal file describing your transactions and generates precise activity and balance reports. Changes include the ability to serve reports in a web browser, and many other fixes and improvements. GHC version 6.10.2. Ian Lynagh [12]announced a new patchlevel release of [13]GHC. This release contains a number of bugfixes relative to 6.10.1, including some performance fixes; see the [14]release notes. Beta of Leksah IDE available. J?rgen Nicklisch-Franken [15]announced release 0.4.4 of [16]Leksah, the Haskell IDE written in Haskell. Current features include on the fly error reporting with location of compilation errors, completion , import helper for constructing import statements, module browser with navigation to definition, project management support based on Cabal with a visual editor, "source candy", and more. satchmo: monadic SAT encoding library. Johannes Waldmann [17]announced a preliminary version of [18]satchmo, a monadic library for encoding boolean and integral number constraints to CNF-SAT. It uses [19]minisat as a backend solver. vacuum-cairo: a cairo frontend to vacuum for live Haskell data visualization. Don Stewart [20]announced the release of [21]vacuum-cairo, a Haskell library for interactive rendering and display of values on the GHC heap using Matt Morrow's vacuum library. This library takes vacuum's output, generates dot graph format from it, renders it to SVG with graphviz, and displays the resulting structure using the gtk2hs Cairo vector graphics bindings ... all at the GHCi command line. Watch some [22]screencasts! vacuum: extract graph representations of ghc heap values.. Matt Morrow [23]announced the release of [24]vacuum, a library for extracting graph representations of values from the GHC heap, which may then be further processed and/or translated to Graphviz dot format to be visualized. new release of HTTP, version 4000.0.5. Sigbjorn Finne [25]announced a [26]new version of the HTTP package, which includes a bunch of fixes and cleanups along with some API documentation. type-level programming support library. spoon [27]asked for feedback on a [28]support library for type level programming. cmonad 0.1.1. Lennart Augustsson [29]announced the [30]CMonad package, which allows one to write Haskell code in a C style. Marketing Haskell. Ketil "Simon Peyton-Jones" Malde [31]announced the new [32]official Haskell mascot. Haskell Platform: status update and call for volunteers. Duncan Coutts gave an [33]update on the status of the [34]Haskell Platform. There are no more policy questions to resolve for the first release. It is a matter of getting things done. The first platform release will contain ghc-6.10.2, the "extra libs", haddock, happy and alex, and the cabal command line tool and it's dependencies. We are calling for volunteers for an action group. We need volunteers to take charge of various platforms and to manage the overall release. See Duncan's email for a list of what is needed, and volunteer! Blog noise [35]Haskell news from the [36]blogosphere. * Jeff Heard: [37]Major updates to Buster. * Bjorn Buckwalter: [38]ANNOUNCE: fad 1.0---Forward Automatic Differentiation for Haskell. * Roman Cheplyaka: [39]Hpysics + GrapeFruit (and hackathon). * Joachim Breitner: [40]Bejeweled AI in Haskell. * >>> iampalmmute: [41]Vacuum + Ubigraph. Visualizing Haskell values in 3D. * Jeff Heard: [42]ANN: Buster, the not quite entirely unlike FRP library.. * Edward Kmett: [43]Reflecting On Incremental Folds. * beelsebob: [44]How you should(n't) use Monad. * Sean Leather: [45]Incremental attributes. * Jeff Heard: [46]Almost, but not quite entirely unlike FRP.. * >>> Gregory Collins: [47]Building a website with Haskell, part 2. * >>> Rubin Mcgowan: [48]Irradiation Tracing in Haskell. * Conal Elliott: [49]Notions of purity in Haskell. * mightybyte: [50]Finished HAppS Application. * Sean Leather: [51]Experiments with EMGM: Emacs org files. * Yi: [52]Haddock is back. * >>> Lab 49: [53]Does Haskell Support Subtyping? It Depends.. * >>> Tim Lopez: [54]Haskell Performance: Lowercase. * >>> Gregory Collins: [55]Building a website with Haskell, part 1. * happstack.com: [56]Happstack-powered Website launched by Gregory David Collins. * >>> LispCast: [57]Writing map in Haskell. * >>> hellfeuer: [58]Laziness and Dynamic Programming. * >>> Leon Smith: [59]Lloyd Allison's Corecursive Queues. Quotes of the Week * mstr: haskell is like f'gg'fggf'fg'g'fg'foldliftM2 f g ''f' :) * simonmar: Wondering how popular Haskell needs to become for intel to optimize their processors for my runtime, rather than the other way around * quicksilver: [about uninstalling packages installed with cabal-install] packages are for life, not just for christmas. * Ethereal: If this conversation had been had in #python #ruby or #php it would have lots of angry people shouting about how it doesn't matter or isn't true or isn't important and what's the point, and no, you guys are like ahhh but no, your preconceived notions of dimensional space are so passe. * Duqicnk: a monad is like a train that runs backwards in time, which is made of tiny chocolate robots * jfredett: I do all of my version numbers in Roman Numerals... * Cale: But in another sense, functional programmers are applied logicians who spend all their time proving trivial theorems in interesting ways in an inconsistent intuitionist logic. About the Haskell Weekly News New editions are posted to [60]the Haskell mailing list as well as to [61]the Haskell Sequence and [62]Planet Haskell. [63]RSS is also available, and headlines appear on [64]haskell.org. To help create new editions of this newsletter, please see the information on [65]how to contribute. Send stories to byorgey at cis dot upenn dot edu. The darcs repository is available at darcs get [66]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56301 3. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hgettext 4. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56209 5. http://vis.renci.org/jeff/buster 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56148 7. http://www.haskell.org/communities/ 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56268 9. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/fad 10. http://article.gmane.org/gmane.comp.lang.haskell.general/17054 11. http://hledger.org/ 12. http://article.gmane.org/gmane.comp.lang.haskell.general/17041 13. http://www.haskell.org/ghc/ 14. http://haskell.org/ghc/docs/6.10.2/html/users_guide/release-6-10-2.html 15. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56116 16. http://www.leksah.org/ 17. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56107 18. http://dfa.imn.htwk-leipzig.de/satchmo/ 19. http://minisat.se/ 20. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56063 21. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vacuum-cairo 22. http://www.youtube.com/watch?v=oujaqo9GAmA 23. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56062 24. http://moonpatio.com/vacuum/ 25. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56058 26. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HTTP 27. http://article.gmane.org/gmane.comp.lang.haskell.cafe/55983 28. http://www.killersmurf.com/projects/typelib 29. http://article.gmane.org/gmane.comp.lang.haskell.cafe/55936 30. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/cmonad 31. http://article.gmane.org/gmane.comp.lang.haskell.general/17021 32. http://www.haskell.org/pipermail/haskell/attachments/20090401/9fb8fa05/haskell-mascot.jpg 33. http://article.gmane.org/gmane.comp.lang.haskell.general/17020 34. http://www.haskell.org/haskellwiki/Haskell_Platform 35. http://planet.haskell.org/ 36. http://haskell.org/haskellwiki/Blog_articles 37. http://vis.renci.org/jeff/2009/04/03/major-updates-to-buster/ 38. http://flygdynamikern.blogspot.com/2009/04/announce-fad-10-forward-automatic.html 39. http://physics-dph.blogspot.com/2009/04/hpysics-grapefruit-and-hackathon.html 40. https://www.joachim-breitner.de/blog/archives/324-Bejeweled-AI-in-Haskell.html 41. http://www.youtube.com/watch?v=3mMH1cHWB6c 42. http://vis.renci.org/jeff/2009/04/01/ann-buster-the-not-quite-entirely-unlike-frp-library/ 43. http://comonad.com/reader/2009/incremental-folds/ 44. http://noordering.wordpress.com/2009/03/31/how-you-shouldnt-use-monad/ 45. http://feedproxy.google.com/~r/splonderzoek/~3/4B0bHoeTCeQ/incremental-attributes.html 46. http://vis.renci.org/jeff/2009/03/31/almost-but-not-quite-entirely-like-frp/ 47. http://gregorycollins.net/posts/2009/03/30/building-a-website-part-2 48. http://rubinmcgowaneh.blogspot.com/2009/03/irradiation-tracing-in-haskell.html 49. http://conal.net/blog/posts/notions-of-purity-in-haskell/ 50. http://softwaresimply.blogspot.com/2008/02/finished-happs-application.html 51. http://feedproxy.google.com/~r/splonderzoek/~3/6bxI33NIRMc/experiments-with-emgm-emacs-org-files.html 52. http://yi-editor.blogspot.com/2009/03/haddock-is-back.html 53. http://blog.lab49.com/archives/2954 54. http://www.brool.com/index.php/haskell-performance-lowercase 55. http://gregorycollins.net/posts/2009/03/28/building-a-website-part-1 56. http://blog.happstack.com/2009/03/28/happstack-powered-website-launched-by-gregory-david-collins/ 57. http://www.lispcast.com/haskell-map.html 58. http://caffeinatedcode.wordpress.com/2009/03/26/laziness-and-dynamic-programming/ 59. http://blog.melding-monads.com/2009/03/09/lloyd-allisons-corecursive-queues/ 60. http://www.haskell.org/mailman/listinfo/haskell 61. http://sequence.complete.org/ 62. http://planet.haskell.org/ 63. http://sequence.complete.org/node/feed 64. http://haskell.org/ 65. http://haskell.org/haskellwiki/HWN 66. http://code.haskell.org/~byorgey/code/hwn/ From bertram.felgenhauer at googlemail.com Sun Apr 5 01:12:39 2009 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Sun Apr 5 00:59:42 2009 Subject: [Haskell-cafe] Link errors in Gtk2Hs are more general than I thought. In-Reply-To: <4165d3a70904041316n55bd47e6g9c44e48ae63f883e@mail.gmail.com> References: <4165d3a70904041316n55bd47e6g9c44e48ae63f883e@mail.gmail.com> Message-ID: <49d83dc9.02e2660a.34b2.4cb3@mx.google.com> Jeff Heard wrote: > I tried to get yi to run on my Mac earlier and I get the following errors: > > dyld: lazy symbol binding failed: Symbol not found: > _cairo_quartz_font_face_create_for_atsu_font_id > Referenced from: /opt/local/lib/libpangocairo-1.0.0.dylib > Expected in: /opt/local/lib/libcairo.2.dylib > > dyld: Symbol not found: _cairo_quartz_font_face_create_for_atsu_font_id > Referenced from: /opt/local/lib/libpangocairo-1.0.0.dylib > Expected in: /opt/local/lib/libcairo.2.dylib This looks like the quartz backend was disabled in the cairo C library, not like a gtk2hs problem. I don't know how ports work, but http://trac.macports.org/browser/trunk/dports/graphics/cairo/Portfile defines a 'quartz' variant that enables that backend. Another idea is to reinstall pango. HTH, Bertram From vigalchin at gmail.com Sun Apr 5 01:26:18 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Sun Apr 5 01:13:17 2009 Subject: [Haskell-cafe] trying to download "leksah" .... Message-ID: <5ae4f2ba0904042226g40fac200ifda291e986eaab3f@mail.gmail.com> vigalchin@ubuntu:~/FTP$ darcs get http://code.haskell.org/leksah Invalid repository: http://code.haskell.org/leksah darcs failed: Failed to download URL http://code.haskell.org/leksah/_darcs/inventory : HTTP error (404?) I did a google on "HTTP 404" => not found .... why? Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090405/2528cd13/attachment.htm From jeff at nokrev.com Sun Apr 5 01:46:53 2009 From: jeff at nokrev.com (Jeff Wheeler) Date: Sun Apr 5 01:34:12 2009 Subject: [Haskell-cafe] Link errors in Gtk2Hs are more general than I thought. In-Reply-To: <49d83dc9.02e2660a.34b2.4cb3@mx.google.com> References: <4165d3a70904041316n55bd47e6g9c44e48ae63f883e@mail.gmail.com> <49d83dc9.02e2660a.34b2.4cb3@mx.google.com> Message-ID: <1238910413.26406.6.camel@ulysses> On Sun, 2009-04-05 at 07:12 +0200, Bertram Felgenhauer wrote: > This looks like the quartz backend was disabled in the cairo C library, > not like a gtk2hs problem. I don't know how ports work, but > > http://trac.macports.org/browser/trunk/dports/graphics/cairo/Portfile > > defines a 'quartz' variant that enables that backend. Another idea is > to reinstall pango. I installed Gtk2Hs on a similar machine earlier tonight, with much success, even with Yi. I did not use MacPorts, and instead followed the instructions on the HaskellWiki [1] under "Using the GTK+ OS X Framework" (including compiling pkg-config from src). I'm not sure how having attempted the installation through MacPorts may have littered your system, unfortunately. After that installation has succeeded, compiling Yi normally and running `yi -fpango` to launch the GTK UI should work. Earlier tonight, though, I reported an issue that causes only the first line of any buffer in the Pango Yi UI to be visible [2], which makes this much less useful. Jeff Wheeler [1] http://www.haskell.org/haskellwiki/Gtk2Hs [2] http://code.google.com/p/yi-editor/issues/detail?id=261 From bertram.felgenhauer at googlemail.com Sun Apr 5 01:54:34 2009 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Sun Apr 5 01:41:37 2009 Subject: [Haskell-cafe] trying to download "leksah" .... In-Reply-To: <5ae4f2ba0904042226g40fac200ifda291e986eaab3f@mail.gmail.com> References: <5ae4f2ba0904042226g40fac200ifda291e986eaab3f@mail.gmail.com> Message-ID: <49d8479d.0aec660a.2ffb.71b9@mx.google.com> Vasili I. Galchin wrote: > vigalchin@ubuntu:~/FTP$ darcs get http://code.haskell.org/leksah > Invalid repository: http://code.haskell.org/leksah > > darcs failed: Failed to download URL > http://code.haskell.org/leksah/_darcs/inventory : HTTP error (404?) > > I did a google on "HTTP 404" => not found .... why? It's a darcs 2 repository, so you'll need to install darcs 2. See http://code.haskell.org/leksah/_darcs/format Admittedly, the error message is horrible. HTH, Bertram From colin at colina.demon.co.uk Sun Apr 5 02:03:23 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sun Apr 5 01:50:24 2009 Subject: [Haskell-cafe] Link errors in Gtk2Hs are more general than I thought. In-Reply-To: <1238910413.26406.6.camel@ulysses> (Jeff Wheeler's message of "Sun\, 05 Apr 2009 00\:46\:53 -0500") References: <4165d3a70904041316n55bd47e6g9c44e48ae63f883e@mail.gmail.com> <49d83dc9.02e2660a.34b2.4cb3@mx.google.com> <1238910413.26406.6.camel@ulysses> Message-ID: >>>>> "Jeff" == Jeff Wheeler writes: Jeff> I installed Gtk2Hs on a similar machine earlier tonight, Jeff> with much success, even with Yi. Jeff> I did not use MacPorts, and instead followed the Jeff> instructions on the HaskellWiki [1] under "Using the GTK+ OS Jeff> X Framework" (including compiling pkg-config from src). I'm Jeff> not sure how having attempted the installation through Jeff> MacPorts may have littered your system, unfortunately. A lot I think (I tried the Framework install once, and spent a LOT of time cleaning up, and the same when I reverted macports). -- Colin Adams Preston Lancashire From noel.kalman at googlemail.com Sun Apr 5 05:16:51 2009 From: noel.kalman at googlemail.com (Kalman Noel) Date: Sun Apr 5 05:03:52 2009 Subject: [Haskell-cafe] ANNOUNCE: fad 1.0 -- Forward Automatic Differentiation library In-Reply-To: References: Message-ID: <49D87703.5010907@googlemail.com> Henning Thielemann schrieb: > with advanced type classes: > http://hackage.haskell.org/packages/archive/numeric-prelude/0.0.5/doc/html/MathObj-PowerSeries.html I'll take this as another opportunity to point out that the Haddock docs of the Numeric Prelude are highly unreadable, due to all qualified class and type names appearing as just C or T. I'm wondering, too, if the Numeric Prelude could be organized more cleanly if we had a fancier module system - does someone have sufficient experience with, say, ML-style module systems to tell? Kalman From johan.tibell at gmail.com Sun Apr 5 06:16:15 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Sun Apr 5 06:03:16 2009 Subject: [Haskell-cafe] Hackage not updating package list Message-ID: <90889fe70904050316g27764ab4hc14971c29b503133@mail.gmail.com> Hi, I just uploaded network-2.2.1. It appears on Hackage [1] but a `cabal update` followed by `cabal install network-2.2.1` results in: Resolving dependencies... cabal: There is no available version of network that satisfies ==2.2.1 The upload took a very long time and it seemed to time out at some point. My guess is that Hackage got itself into an inconsistent state. Could someone who has access to the Hackage server check what happened? 1. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/network-2.2.1 Cheers, Johan From gue.schmidt at web.de Sun Apr 5 08:32:21 2009 From: gue.schmidt at web.de (=?UTF-8?B?R8O8wp9udGhlciBTY2htaWR0?=) Date: Sun Apr 5 08:19:35 2009 Subject: [Haskell-cafe] Re: Haskell EDSL to generate SQL? In-Reply-To: <877i20frzu.wl%jeremy@n-heptane.com> References: <877i20frzu.wl%jeremy@n-heptane.com> Message-ID: <49D8A4D5.4000802@web.de> Hi Jeremy, apologies for my initial response, that was definately premature. I had a second look and am quite impressed now. What is the best resource to look for more detail examples? G?nther Jeremy Shaw schrieb: > At Sat, 04 Apr 2009 15:40:56 +0200, > G??nther Schmidt wrote: > >> But I hope to be able to use an DSL from which I can automatically >> generate SQL-Strings instead of writing the SQL statements literally. >> >> Has anyone else taken a similar approach? > > HaskellDB has an DSL for generating SQL strings. Though, it is not a > straightforward mapping. The haskellDB DSL provides you with > relational algebra operators that you use to build your query. > > - jeremy From johan.tibell at gmail.com Sun Apr 5 09:01:47 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Sun Apr 5 08:48:46 2009 Subject: [Haskell-cafe] ANN: network-bytestring 0.1.2 Message-ID: <90889fe70904050601n25512fdanee6263ff039860c7@mail.gmail.com> I am pleased to announce a new release of network-bytestring, a Haskell library for fast socket I/O using ByteStrings. New in this release is support for scatter/gather I/O (also known as vectored I/O). Scatter/gather I/O provides more efficient I/O by using one system call to send several separate pieces of data and by avoiding unnecessary copying. I would like to thank Brian Lewis, Bryan O'Sullivan, and Thomas Schilling for contributing patches for this release. Get it: cabal install network-bytestring And on Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/network-bytestring Windows hackers needed: I've made sure that the library builds on Windows but since I don't use Windows myself I haven't implemented scatter/gather I/O support for Windows. It should be straightforward to add and I'd be happy to review the patches. Cheers, Johan From lemming at henning-thielemann.de Sun Apr 5 09:33:51 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Apr 5 09:21:26 2009 Subject: [Haskell-cafe] Numeric Prelude and identifiers (Was: fad 1.0 -- Forward AutomaticDifferentiation library) In-Reply-To: <49D87703.5010907@googlemail.com> References: <49D87703.5010907@googlemail.com> Message-ID: On Sun, 5 Apr 2009, Kalman Noel wrote: > Henning Thielemann schrieb: >> with advanced type classes: >> http://hackage.haskell.org/packages/archive/numeric-prelude/0.0.5/doc/html/MathObj-PowerSeries.html > > I'll take this as another opportunity to point out that the Haddock docs > of the Numeric Prelude are highly unreadable, due to all qualified class > and type names appearing as just C or T. It's Haddock's fault. :-) I have written a Trac ticket, but trac.haskell.org does currently not respond. > I'm wondering, too, if the Numeric Prelude could be organized more > cleanly if we had a fancier module system - does someone have sufficient > experience with, say, ML-style module systems to tell? Are you complaining about the organisation or about the identifiers? If you mean the former, then what organisation do you propose? If you mean the latter ... Many proposals about extended import facilities I saw were complicated and could simply be avoided using the naming style I use. From jmaessen at alum.mit.edu Sun Apr 5 09:52:08 2009 From: jmaessen at alum.mit.edu (Jan-Willem Maessen) Date: Sun Apr 5 09:39:11 2009 Subject: [Haskell-cafe] Numeric Prelude and identifiers (Was: fad 1.0 -- Forward AutomaticDifferentiation library) In-Reply-To: References: <49D87703.5010907@googlemail.com> Message-ID: On Apr 5, 2009, at 9:33 AM, Henning Thielemann wrote: > > On Sun, 5 Apr 2009, Kalman Noel wrote: > >> Henning Thielemann schrieb: >>> with advanced type classes: >>> http://hackage.haskell.org/packages/archive/numeric-prelude/0.0.5/doc/html/MathObj-PowerSeries.html >> >> I'll take this as another opportunity to point out that the Haddock >> docs >> of the Numeric Prelude are highly unreadable, due to all qualified >> class >> and type names appearing as just C or T. > > It's Haddock's fault. :-) I have written a Trac ticket, but > trac.haskell.org does currently not respond. I may be treading in murky waters here, but I do think a large part of the problem is that the Numeric Prelude has chosen to use ML naming conventions (which refer to types in a module as T, etc.) when you're writing a Haskell program. Surely if the types, classes, and so forth were given evocative names, numeric prelude programs would become readable? And as a special bonus, though it may offend your sensibilities, numeric prelude programs might be able to use unqualified import in certain circumstances? -Jan-Willem Maessen [For each language, its own idiom!] From jason.dusek at gmail.com Sun Apr 5 10:22:44 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Sun Apr 5 10:09:43 2009 Subject: [Haskell-cafe] Lazy vs correct IO [Was: A round of golf] In-Reply-To: <20080919065159.616A5AF09@Adric.metnet.fnmoc.navy.mil> References: <20080919065159.616A5AF09@Adric.metnet.fnmoc.navy.mil> Message-ID: <42784f260904050722o2432b123ra3418fdc63014b22@mail.gmail.com> 2008/09/18 : > Operationally, the code does not open more than one file at a > time. More importantly, the code *never* reads more than 4096 > characters at a time. A block of the file is read, split into > words, counted, and only then another chunk is read. After one > file is done, it is closed, and another file is processed. One > can see that only one file is being opened at a time by > enabling traces. The processing is fully incremental. It opens and closes each file in turn; but it would it be unwise to open and close each file as we'd read a chunk from it? This would allow arbitrary interleaving. -- Jason Dusek From jason.dusek at gmail.com Sun Apr 5 10:32:44 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Sun Apr 5 10:19:43 2009 Subject: [Haskell-cafe] Lazy vs correct IO [Was: A round of golf] In-Reply-To: <42784f260904050722o2432b123ra3418fdc63014b22@mail.gmail.com> References: <20080919065159.616A5AF09@Adric.metnet.fnmoc.navy.mil> <42784f260904050722o2432b123ra3418fdc63014b22@mail.gmail.com> Message-ID: <42784f260904050732u6a483b25q9568b37f56fd6ec@mail.gmail.com> I hate to say it; but you know you can tweak the OS to allow excessive file handle usage. I once wrote a Haskell script to empty a very, vary large S3 bucket. On Linux, I had to put it in a shell while loop to keep it going, due to file handle exhaustion. On my Mac it ran without incident. :; ulimit unlimited Turns out the `ulimit` on my Mac is pretty high. -- Jason Dusek |...tweak the OS...| http://www.kegel.com/c10k.html#limits.filehandles From jason.dusek at gmail.com Sun Apr 5 10:35:50 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Sun Apr 5 10:22:51 2009 Subject: [Haskell-cafe] Lazy vs correct IO [Was: A round of golf] In-Reply-To: <42784f260904050732u6a483b25q9568b37f56fd6ec@mail.gmail.com> References: <20080919065159.616A5AF09@Adric.metnet.fnmoc.navy.mil> <42784f260904050722o2432b123ra3418fdc63014b22@mail.gmail.com> <42784f260904050732u6a483b25q9568b37f56fd6ec@mail.gmail.com> Message-ID: <42784f260904050735n1ae9f6b6m568827ffcf1f97c0@mail.gmail.com> Oh, curses. I didn't run it with the right option. :; ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) 6144 file size (blocks, -f) unlimited max locked memory (kbytes, -l) unlimited max memory size (kbytes, -m) unlimited open files (-n) 256 pipe size (512 bytes, -p) 1 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 266 virtual memory (kbytes, -v) unlimited So now I'm not sure why it worked on my Mac. -- Jason Dusek From ttencate at gmail.com Sun Apr 5 10:36:02 2009 From: ttencate at gmail.com (Thomas ten Cate) Date: Sun Apr 5 10:23:02 2009 Subject: [Haskell-cafe] EclipseFP proposal for Google Summer of Code Message-ID: To everyone involved in the Google Summer of Code program, I have submitted a GSoC proposal to work on EclipseFP, the Haskell plugin for Eclipse. The proposal is crossposted to both haskell.org and the Eclipse Foundation, each in their respective templates. This is also stated at the top of the proposal. I send this e-mail because of possible scheduling issues: I will be away starting on April 15. So, if you want to ask me things, have suggestions for improvement, or want to do an interview or something, this can only be done *before* that date. This is also stated in the proposal, but since I have no idea how the proposals are processed by the mentoring organizations, I figured that an explicit notification would be a good idea. For your convenience, here are links to the proposal. haskell.org version: http://socghop.appspot.com/student_proposal/show/google/gsoc2009/thomastc/t123799996710 and also on http://docs.google.com/Doc?id=dfmvb7sr_13fzdg5qhr Eclipse Foundation version: http://socghop.appspot.com/student_proposal/show/google/gsoc2009/thomastc/t123867654843 and also on http://docs.google.com/Doc?id=dfmvb7sr_15gb9258fg If my schedule causes any problems, please let me know. Also, comments on the proposal in general would be much appreciated. Thanks, Thomas P.S. I hope it's okay that I post this to the haskell-cafe list as well; since haskell.org has no GSoC-specific mailing list, it seems to be the most appropriate place that I could find. From cristiano.paris at gmail.com Sun Apr 5 11:01:15 2009 From: cristiano.paris at gmail.com (Cristiano Paris) Date: Sun Apr 5 10:48:33 2009 Subject: [Haskell-cafe] System.Process.Posix In-Reply-To: <20090404202846.GB26834@whirlpool.galois.com> References: <20481029.20090405002136@gmail.com> <20090404202846.GB26834@whirlpool.galois.com> Message-ID: On Sat, Apr 4, 2009 at 10:28 PM, Don Stewart wrote: > cristiano.paris: >... > Isn't this the goal of the process package? Hi Don, thank you for the reference. I saw System.Process but when I needed it I was in a hurry and having a UNIX background I googled for some snippet daemonizing a process which led me to the System.Process.Posix package. Yet, I was surprised not to find it in Hoogle as I thought it to be a comprehensive search engine. But I was wrong :D Thanks. Cristiano From rick.richardson at gmail.com Sun Apr 5 11:06:50 2009 From: rick.richardson at gmail.com (Rick R) Date: Sun Apr 5 10:53:49 2009 Subject: [Haskell-cafe] Lazy vs correct IO [Was: A round of golf] In-Reply-To: <42784f260904050735n1ae9f6b6m568827ffcf1f97c0@mail.gmail.com> References: <20080919065159.616A5AF09@Adric.metnet.fnmoc.navy.mil> <42784f260904050722o2432b123ra3418fdc63014b22@mail.gmail.com> <42784f260904050732u6a483b25q9568b37f56fd6ec@mail.gmail.com> <42784f260904050735n1ae9f6b6m568827ffcf1f97c0@mail.gmail.com> Message-ID: <9810b81b0904050806pdabee34nc77181ce81cce729@mail.gmail.com> It depends on the underlying file control used by ghc. if it's the FILE stream pointer, some implementations suffer from a 255 file limit. If it's a standard file descriptor (open instead of fopen), then it's limited by ulimit. On Sun, Apr 5, 2009 at 10:35 AM, Jason Dusek wrote: > Oh, curses. I didn't run it with the right option. > > :; ulimit -a > core file size (blocks, -c) 0 > data seg size (kbytes, -d) 6144 > file size (blocks, -f) unlimited > max locked memory (kbytes, -l) unlimited > max memory size (kbytes, -m) unlimited > open files (-n) 256 > pipe size (512 bytes, -p) 1 > stack size (kbytes, -s) 8192 > cpu time (seconds, -t) unlimited > max user processes (-u) 266 > virtual memory (kbytes, -v) unlimited > > So now I'm not sure why it worked on my Mac. > > -- > Jason Dusek > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- We can't solve problems by using the same kind of thinking we used when we created them. - A. Einstein -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090405/f0afd73d/attachment.htm From dons at galois.com Sun Apr 5 12:47:28 2009 From: dons at galois.com (Don Stewart) Date: Sun Apr 5 12:35:31 2009 Subject: [Haskell-cafe] Hackage not updating package list In-Reply-To: <90889fe70904050316g27764ab4hc14971c29b503133@mail.gmail.com> References: <90889fe70904050316g27764ab4hc14971c29b503133@mail.gmail.com> Message-ID: <20090405164728.GL26834@whirlpool.galois.com> johan.tibell: > Hi, > > I just uploaded network-2.2.1. It appears on Hackage [1] but a `cabal > update` followed by `cabal install network-2.2.1` results in: > > Resolving dependencies... > cabal: There is no available version of network that satisfies ==2.2.1 > > The upload took a very long time and it seemed to time out at some > point. My guess is that Hackage got itself into an inconsistent state. > Could someone who has access to the Hackage server check what > happened? > > 1. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/network-2.2.1 > Seems to have worked now. We had time out problems a couple of weeks ago too. Unknown cause at this point. All seems to be working though: $ cabal install network-bytestring ... Installing library in /home/dons/.cabal/lib/network-bytestring-0.1.2/ghc-6.10.1 Registering network-bytestring-0.1.2... Reading package info from "dist/installed-pkg-config" ... done. Writing new package config file... done. From martijn at van.steenbergen.nl Sun Apr 5 13:06:07 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Sun Apr 5 12:53:07 2009 Subject: [Haskell-cafe] Confused about readline/editline Message-ID: <49D8E4FF.8090600@van.steenbergen.nl> Hello caf?, I'm trying to write an executable that depends on Yogurt-0.3, readline (indirectly) and hint. However, including hint in the build-depends field causes cabal to link the executable against editline instead of readline. Here is a small test case: File: Test.cabal > Name: Test > Version: 0 > > Build-Type: Simple > Cabal-Version: >= 1.2 > > Executable test > Main-Is: Test.hs > Build-Depends: base, Yogurt, hint > GHC-Options: -threaded File: Test.hs > module Main where > > import Network.Yogurt > > main:: IO () > main = do > connect "eclipse.cs.pdx.edu" 7680 (return ()) The example doesn't use any functions from hint, but simply mentioning it in the cabal file causes this behaviour. What's going on? How can I fix or work around this? I am able to reproduce this behaviour in two configurations: * Leopard Intel; cabal-install version 0.6.2, using version 1.6.0.1 of the Cabal library; GHC 6.10.1 * Ubuntu; cabal-install version 0.6.2, using version 1.6.0.3 of the Cabal library; GHC 6.10.2 Thank you very much in advance, Martijn. From fft1976 at gmail.com Sun Apr 5 14:22:20 2009 From: fft1976 at gmail.com (FFT) Date: Sun Apr 5 14:09:17 2009 Subject: [Haskell-cafe] high probability of installation problems and quality of the glorious implementation Message-ID: I'm still learning Haskell and also evaluating whether I want to use the language in my work. It seems like a fascinating language so far (although I don't know if laziness will be a detriment later for me eventually), but I'm a bit worried about the overall quality of its GHC implementation. For example, I tried installing GHC-6.10.2 on my Ubuntu 8.04 machine (probably the most mainstream Linux these days). 1st attempt: binary => failed "the impossible happened, report bug" (I think it's already in bugzilla for an even earlier version) 2nd attempt: source and docs => followed README, but "make" failed while building docs 3rd attempt: source only, no docs => make install succeeded, but ghci now seems to have its "readline" screwed up (no editing, can't quit even with Ctrl-C or Ctrl-D), while Ubuntu-bundled 6.8.* ghci works fine in this regard. If these kinds of issues are common only during installation, I can live with that, but if GHC is flaky overall, having to deal with this may cancel out whatever productivity advantages Haskell provides. If the quality of the installation procedures is different from the compiler itself, can you explain why? From ekmett at gmail.com Sun Apr 5 14:30:40 2009 From: ekmett at gmail.com (Edward Kmett) Date: Sun Apr 5 14:17:38 2009 Subject: [Haskell-cafe] Hackage not updating package list In-Reply-To: <20090405164728.GL26834@whirlpool.galois.com> References: <90889fe70904050316g27764ab4hc14971c29b503133@mail.gmail.com> <20090405164728.GL26834@whirlpool.galois.com> Message-ID: <7fb8f82f0904051130g56a3ffedte021e45f09487d75@mail.gmail.com> It has been slow for me today as well. I spammed up 3 released of a package in rapid succession because it wasn't showing up in the list. Apparently stuff is at least showing up several minutes after the upload completes though as evidenced by the fact that I can see all of those versions now. -Edward Kmett On Sun, Apr 5, 2009 at 12:47 PM, Don Stewart wrote: > johan.tibell: > > Hi, > > > > I just uploaded network-2.2.1. It appears on Hackage [1] but a `cabal > > update` followed by `cabal install network-2.2.1` results in: > > > > Resolving dependencies... > > cabal: There is no available version of network that satisfies ==2.2.1 > > > > The upload took a very long time and it seemed to time out at some > > point. My guess is that Hackage got itself into an inconsistent state. > > Could someone who has access to the Hackage server check what > > happened? > > > > 1. > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/network-2.2.1 > > > > Seems to have worked now. We had time out problems a couple of weeks ago > too. Unknown cause at this point. > > All seems to be working though: > > $ cabal install network-bytestring > ... > Installing library in > /home/dons/.cabal/lib/network-bytestring-0.1.2/ghc-6.10.1 > Registering network-bytestring-0.1.2... > Reading package info from "dist/installed-pkg-config" ... done. > Writing new package config file... done. > > _______________________________________________ > 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/20090405/0fc05657/attachment.htm From judah.jacobson at gmail.com Sun Apr 5 15:20:10 2009 From: judah.jacobson at gmail.com (Judah Jacobson) Date: Sun Apr 5 15:07:07 2009 Subject: [Haskell-cafe] Confused about readline/editline In-Reply-To: <49D8E4FF.8090600@van.steenbergen.nl> References: <49D8E4FF.8090600@van.steenbergen.nl> Message-ID: <6d74b0d20904051220h4c57a481o7ce5d7cfeb6145f4@mail.gmail.com> On Sun, Apr 5, 2009 at 10:06 AM, Martijn van Steenbergen wrote: > Hello caf?, > > I'm trying to write an executable that depends on Yogurt-0.3, readline > (indirectly) and hint. However, including hint in the build-depends field > causes cabal to link the executable against editline instead of readline. > Here is a small test case: > > File: Test.cabal > >> Name: Test >> Version: 0 >> >> Build-Type: Simple >> Cabal-Version: >= 1.2 >> >> Executable test >> ?Main-Is: ? ? ? ?Test.hs >> ?Build-Depends: ?base, Yogurt, hint >> ?GHC-Options: ? ?-threaded > > File: Test.hs > >> module Main where >> >> import Network.Yogurt >> >> main:: IO () >> main = do >> ?connect "eclipse.cs.pdx.edu" 7680 (return ()) > > The example doesn't use any functions from hint, but simply mentioning it in > the cabal file causes this behaviour. What's going on? How can I fix or work > around this? > > I am able to reproduce this behaviour in two configurations: > * Leopard Intel; cabal-install version 0.6.2, using version 1.6.0.1 of the > Cabal library; GHC 6.10.1 > * Ubuntu; cabal-install version 0.6.2, using version 1.6.0.3 of the Cabal > library; GHC 6.10.2 > Probably what's happening is that hint depends on the ghc package, which links to editline in 6.10 since it includes all the code for ghci. I'm not sure, but there might be some order of flags or packages you could give to Cabal which would cause it to link to readline first; I think if gcc gets "-lreadline -ledit" in that order then it will do what you want. Passing "-v" or "-v3" to cabal build should let you see what's going on. For ghc-6.12 there's plans to prevent this issue by separating out ghci as a separate program than the core ghc package. -Judah From haskell at colquitt.org Sun Apr 5 15:35:43 2009 From: haskell at colquitt.org (John Dorsey) Date: Sun Apr 5 15:22:42 2009 Subject: [Haskell-cafe] high probability of installation problems and quality of the glorious implementation In-Reply-To: References: Message-ID: <20090405193543.GB2207@colquitt.org> FFT, > I'm still learning Haskell and also evaluating whether I want to use > the language in my work. I've been learning and using GHC in spare hours for several years. I've had challenges installing it on MacOSX-ppc, and on RHEL4; kind folks on irc and the mailing lists have always been very helpful, and if you haven't gone to either for help it's strongly recommended. Bring as much detail as you can about your environment and the errors you're getting. I should add that a lot of the great code available for Haskell is in the form of libraries on the hackage site. It's worth the time to get cabal-install working before doing anything else; many of those libraries will then install without a fuss. But the quality of packages varies (naturally), and the cabal tools, while handy, have their quirks. When in doubt, ask what packages people like, and ask for help before you're frustrated. There's reason to think that installation issues are about to improve somewhat, with the release of "The Haskell Platform" (THP). Take a minute to read about it if you haven't heard of it. THP promises to provide installation packages for common platforms, bundling the compiler, cabal-install, and a set of libraries with compatible versions and with active support. It's a small set for now, THP is in its infancy. Before you give up, consider using GHC 6.8.* for the time being, since it sounds like ubuntu's installer works for that. I think a lot of folks are still using 6.8, and earlier versions, quite happily. If you do end up giving up on Haskell because of installation frustrations, come back in a few months and see if things are better. Once it's installed and working, GHC's a very decent compiler. Naturally, it's not as mature as GCC. There are outstanding bugs and corner cases where performance isn't what it should be. From where I'm sitting, it seems to be improving in all those areas. There are several individuals and companies in this community who are using GHC, in production, with commercial success. Overall, challenges with the toolset have been less of a hurdle for me than mastering the language. I hope you are able to spend some time using it. Regards, John From martijn at van.steenbergen.nl Sun Apr 5 15:41:42 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Sun Apr 5 15:28:40 2009 Subject: [Haskell-cafe] Confused about readline/editline In-Reply-To: <6d74b0d20904051220h4c57a481o7ce5d7cfeb6145f4@mail.gmail.com> References: <49D8E4FF.8090600@van.steenbergen.nl> <6d74b0d20904051220h4c57a481o7ce5d7cfeb6145f4@mail.gmail.com> Message-ID: <49D90976.8000204@van.steenbergen.nl> Judah Jacobson wrote: > I'm not sure, but there might be some order of flags or packages you > could give to Cabal which would cause it to link to readline first; I > think if gcc gets "-lreadline -ledit" in that order then it will do > what you want. Passing "-v" or "-v3" to cabal build should let you > see what's going on. Yes, -v3 indeed shows that edit comes before readline. Adding this extra line fixes it: > Extra-Libraries: readline Is adding that extra line a robust, portable and documented way of solving the problem? Whew, I'm really glad it's fixed now. It took me half a day to narrow the problem down. :-) Thanks, Martijn. From fft1976 at gmail.com Sun Apr 5 16:19:12 2009 From: fft1976 at gmail.com (FFT) Date: Sun Apr 5 16:06:09 2009 Subject: [Haskell-cafe] high probability of installation problems and quality of the glorious implementation In-Reply-To: <20090405193543.GB2207@colquitt.org> References: <20090405193543.GB2207@colquitt.org> Message-ID: On Sun, Apr 5, 2009 at 12:35 PM, John Dorsey wrote: > Once it's installed and working, GHC's a very decent compiler. My general null hypothesis is, as Alec Baldwin put it, that a loser is a loser, or a buggy project is buggy. If GHC is robust overall (which I'm yet to find out), why is the installation so broken? From wren at freegeek.org Sun Apr 5 16:33:21 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun Apr 5 16:20:21 2009 Subject: [Haskell-cafe] high probability of installation problems and quality of the glorious implementation In-Reply-To: <20090405193543.GB2207@colquitt.org> References: <20090405193543.GB2207@colquitt.org> Message-ID: <49D91591.90108@freegeek.org> John Dorsey wrote: > Before you give up, consider using GHC 6.8.* for the time being, since > it sounds like ubuntu's installer works for that. I think a lot of > folks are still using 6.8, and earlier versions, quite happily. If you > do end up giving up on Haskell because of installation frustrations, > come back in a few months and see if things are better. +1. GHC 6.8.2 is mature and stable, but the 6.10 line is still very new. The new line introduced a major refactoring of the code base and a redesign of the compiler backend--- both of which are necessary for progress, but they've introduced some instability in the interim. Version 6.10.1 introduced a number of regressions which would interfere with my work (many have been fixed in 6.10.2), so I'm one of the many still using the older line. For stability and practicality, unless you're doing something that hits a bug in 6.8.2 or requires a new feature in 6.10.*, I'd suggest waiting for 6.10 development to settle down a bit before making the transition. -- Live well, ~wren From bugfact at gmail.com Sun Apr 5 16:41:59 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Apr 5 16:28:58 2009 Subject: [Haskell-cafe] high probability of installation problems and quality of the glorious implementation In-Reply-To: References: <20090405193543.GB2207@colquitt.org> Message-ID: That is strange, I'm using Ubuntu myself, and I come from Windows so know absolutely nothing about Linux whatsoever, but GHC 6.10.2 binary installed without problems. But anyway, in this case, if you're on Windows, installation of GHC works like a charm: download, install, play. But for most of the packages on Hackage, Windows is not a good platform :) On Sun, Apr 5, 2009 at 10:19 PM, FFT wrote: > On Sun, Apr 5, 2009 at 12:35 PM, John Dorsey wrote: > > > Once it's installed and working, GHC's a very decent compiler. > > My general null hypothesis is, as Alec Baldwin put it, that a loser is > a loser, or a buggy project is buggy. > > If GHC is robust overall (which I'm yet to find out), why is the > installation so broken? > _______________________________________________ > 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/20090405/ff9034b4/attachment.htm From manlio_perillo at libero.it Sun Apr 5 16:41:57 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Apr 5 16:29:51 2009 Subject: [Haskell-cafe] binary package: memory problem decoding an IntMap In-Reply-To: <49D48B5A.4080406@libero.it> References: <49D48B5A.4080406@libero.it> Message-ID: <49D91795.1060808@libero.it> Manlio Perillo ha scritto: > Hi. > > I'm having memory problems decoding a big IntMap. > > The data structure is: > > IntMap (UArr (Word16 :*: Word8)) > > > There are 480189 keys, and a total of 100480507 elements > (Netflix Prize). > The size of the encoded (and compressed) data is 184 MB. > > When I load data from the Netflix Prize data set, total memory usage is > 1030 Mb. > It seems there is a problem with tuples, too. I have a: [(Word16, UArr (Word32 :*:* Word8))] This eats more memory than it should, since tuples are decoded lazily. Manlio From miguelimo38 at yandex.ru Sun Apr 5 16:52:31 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Sun Apr 5 16:39:50 2009 Subject: [Haskell-cafe] high probability of installation problems and quality of the glorious implementation In-Reply-To: References: Message-ID: <82A16BF6-B850-4804-AE38-FC5375EB1105@yandex.ru> What about 6.10.1? Is it failing too? On 5 Apr 2009, at 22:22, FFT wrote: > I'm still learning Haskell and also evaluating whether I want to use > the language in my work. > > It seems like a fascinating language so far (although I don't know if > laziness will be a detriment later for me eventually), but I'm a bit > worried about the overall quality of its GHC implementation. > > For example, I tried installing GHC-6.10.2 on my Ubuntu 8.04 machine > (probably the most mainstream Linux these days). > > 1st attempt: binary => failed "the impossible happened, report bug" (I > think it's already in bugzilla for an even earlier version) > > 2nd attempt: source and docs => followed README, but "make" failed > while building docs > > 3rd attempt: source only, no docs => make install succeeded, but ghci > now seems to have its "readline" screwed up (no editing, can't quit > even with Ctrl-C or Ctrl-D), while Ubuntu-bundled 6.8.* ghci works > fine in this regard. > > If these kinds of issues are common only during installation, I can > live with that, but if GHC is flaky overall, having to deal with this > may cancel out whatever productivity advantages Haskell provides. > > If the quality of the installation procedures is different from the > compiler itself, can you explain why? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From wren at freegeek.org Sun Apr 5 17:00:59 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun Apr 5 16:47:56 2009 Subject: [Haskell-cafe] high probability of installation problems and quality of the glorious implementation In-Reply-To: References: <20090405193543.GB2207@colquitt.org> Message-ID: <49D91C0B.7000309@freegeek.org> FFT wrote: > John Dorsey wrote: > > Once it's installed and working, GHC's a very decent compiler. > > My general null hypothesis is, as Alec Baldwin put it, that a loser is > a loser, or a buggy project is buggy. > > If GHC is robust overall (which I'm yet to find out), why is the > installation so broken? Part of the problem is that GHC 6.6 is the last version that supported bootstrapping. Some of the changes in 6.8 broke that, and so the longer it goes the harder bootstrapping/installation becomes. It's a major bug that many people would like fixed; I don't know the details, but I'm sure the GHC mailing lists[1] or #ghc would have more to say about it. There are also some issues about libeditline which is used for the interactive debugger, and has a lot to do with Linux vs BSD nonsense. Once these two issues are dealt with, the rest is smooth sailing. As the flagship Haskell compiler a lot of work has been invested in optimizations and the general running of GHC. Installation is less glorious work, so less academic and corporate investment has been paid to that part of things. Since most of the community already has a GHC installed, the bootstrapping issue isn't devastating to those already in the loop. Consequently, a lot of work has been done on making the post-compiler development cycle more robust with projects like Cabal, Hackage, cabal-install, and the Haskell Platform. These projects are still under rapid development, but they are fairly stable and they make it very friendly to install libraries--- which greatly speeds up development. [1] http://www.haskell.org/ghc/docs/latest/html/users_guide/introduction-GHC.html#mailing-lists-GHC -- Live well, ~wren From haskell at colquitt.org Sun Apr 5 17:10:56 2009 From: haskell at colquitt.org (John Dorsey) Date: Sun Apr 5 16:57:53 2009 Subject: [Haskell-cafe] high probability of installation problems and quality of the glorious implementation In-Reply-To: References: <20090405193543.GB2207@colquitt.org> Message-ID: <20090405211055.GC2207@colquitt.org> Quoth FFT: > My general null hypothesis is, as Alec Baldwin put it, that a loser is > a loser, or a buggy project is buggy. I can't see the world in such black and white terms. GHC has strengths and weaknesses, as do other projects. GHC is changing over time, as are other projects. Formally verified software is still rare. Most of the useful stuff lies somewhere between "buggy" and "bug-free". > If GHC is robust overall (which I'm yet to find out), why is the > installation so broken? History. Limited resources. Complexity and diversity of target environments. Moving targets. Day jobs. Of course, you have to determine what your needs and standards are for any product you use. Regards, John From nicolas.pouillard at gmail.com Sun Apr 5 17:10:27 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Sun Apr 5 16:58:36 2009 Subject: [Haskell-cafe] binary package: memory problem decoding an IntMap In-Reply-To: <49D91795.1060808@libero.it> References: <49D48B5A.4080406@libero.it> <49D91795.1060808@libero.it> Message-ID: <1238965788-sup-7561@ausone.local> Excerpts from Manlio Perillo's message of Sun Apr 05 22:41:57 +0200 2009: > Manlio Perillo ha scritto: > > Hi. > > > > I'm having memory problems decoding a big IntMap. > > > > The data structure is: > > > > IntMap (UArr (Word16 :*: Word8)) > > > > > > There are 480189 keys, and a total of 100480507 elements > > (Netflix Prize). > > The size of the encoded (and compressed) data is 184 MB. > > > > When I load data from the Netflix Prize data set, total memory usage is > > 1030 Mb. > > > > It seems there is a problem with tuples, too. > > I have a: > [(Word16, UArr (Word32 :*:* Word8))] > > This eats more memory than it should, since tuples are decoded lazily. Why not switch to [(Word16 :*: UArr (Word32 :*: Word8))] then? -- Nicolas Pouillard From manlio_perillo at libero.it Sun Apr 5 18:58:01 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Apr 5 18:45:05 2009 Subject: [Haskell-cafe] binary package: memory problem decoding an IntMap In-Reply-To: <49D91795.1060808@libero.it> References: <49D48B5A.4080406@libero.it> <49D91795.1060808@libero.it> Message-ID: <49D93779.6000906@libero.it> Manlio Perillo ha scritto: > [...] > > It seems there is a problem with tuples, too. > > I have a: > [(Word16, UArr (Word32 :*:* Word8))] > > This eats more memory than it should, since tuples are decoded lazily. > My bad, sorry. I simply solved by using a strict consumer (foldl' instead of foldl). Manlio From mle+hs at mega-nerd.com Sun Apr 5 19:13:48 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Sun Apr 5 19:00:48 2009 Subject: [Haskell-cafe] high probability of installation problems and quality of the glorious implementation In-Reply-To: References: Message-ID: <20090406091348.33cebac7.mle+hs@mega-nerd.com> FFT wrote: > I'm still learning Haskell and also evaluating whether I want to use > the language in my work. < snip> > For example, I tried installing GHC-6.10.2 on my Ubuntu 8.04 machine > (probably the most mainstream Linux these days). I'm on Ubuntu 8.10 and soon to move to 9.04 and I agree that the standard 6.8.2 compiler on Debian/Ubuntu is a PITA. I haven't tried 6.10.2 yet, but the way I installed 6.10.1 and a bunch of other packages was by installing them from the Debian unstable source packages. HTH, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From dagit at codersbase.com Sun Apr 5 19:37:49 2009 From: dagit at codersbase.com (Jason Dagit) Date: Sun Apr 5 19:24:46 2009 Subject: [Haskell-cafe] high probability of installation problems and quality of the glorious implementation In-Reply-To: <20090406091348.33cebac7.mle+hs@mega-nerd.com> References: <20090406091348.33cebac7.mle+hs@mega-nerd.com> Message-ID: On Sun, Apr 5, 2009 at 4:13 PM, Erik de Castro Lopo wrote: > FFT wrote: > >> I'm still learning Haskell and also evaluating whether I want to use >> the language in my work. > > < snip> > >> For example, I tried installing GHC-6.10.2 on my Ubuntu 8.04 machine >> (probably the most mainstream Linux these days). > > I'm on Ubuntu 8.10 and soon to move to 9.04 and I agree that the > standard 6.8.2 compiler on Debian/Ubuntu is a PITA. In particular, I advise my friends not to install GHC from apt on Debian/Ubuntu because of the way the packages are fractured on those distros. Nothing but problems for casual Haskell hackers. If you know your distro and Haskell well, then sure it's easy to install all the packages that constitute a normal ghc install. For everyone else it's just confusing and frustrating. I've heard that from a distro point of view the split packages are nice and that the solution to my complaint is a proper meta or virtual package. I wonder when we'll get a good haskell virtual package on Debian? Just my $0.02, Jason From mle+hs at mega-nerd.com Sun Apr 5 19:47:56 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Sun Apr 5 19:34:56 2009 Subject: [Haskell-cafe] high probability of installation problems and quality of the glorious implementation In-Reply-To: References: <20090406091348.33cebac7.mle+hs@mega-nerd.com> Message-ID: <20090406094756.4a5baae5.mle+hs@mega-nerd.com> Jason Dagit wrote: > In particular, I advise my friends not to install GHC from apt on > Debian/Ubuntu because of the way the packages are fractured on those > distros. Fractured? > Nothing but problems for casual Haskell hackers. If you > know your distro and Haskell well, then sure it's easy to install all > the packages that constitute a normal ghc install. Well I admit that having done a lot of debian packaging in my day job I know the debian packaging system pretty well. I chose to stick to the debian packages because I found cabal to be a pain in the neck in comparison :-). > I've heard that from a distro > point of view the split packages are nice and that the solution to my > complaint is a proper meta or virtual package. My overwhelming complaint about the packages in Ubuntu and Debian stable/testing is that they are for ghc-6.8.2. > I wonder when we'll get a good haskell virtual package on Debian? What would this package do? Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From fft1976 at gmail.com Sun Apr 5 20:59:23 2009 From: fft1976 at gmail.com (FFT) Date: Sun Apr 5 20:46:34 2009 Subject: [Haskell-cafe] high probability of installation problems and quality of the glorious implementation In-Reply-To: References: <20090405193543.GB2207@colquitt.org> Message-ID: On Sun, Apr 5, 2009 at 1:41 PM, Peter Verswyvelen wrote: > That is strange, I'm using Ubuntu myself, and I come from Windows so know > absolutely nothing about Linux whatsoever, but GHC 6.10.2 binary installed > without problems. Are you running 32-bit Ubuntu 8.04 ? /etc/lsb-release and /etc/issue* may contain this info, also $ uname -a It may also be the presence or absence of some packages that the installation requires, but ./configure doesn't check. From kowey at darcs.net Sun Apr 5 21:03:18 2009 From: kowey at darcs.net (Eric Kow) Date: Sun Apr 5 20:50:17 2009 Subject: [darcs-users] [Haskell-cafe] Reverting to any old version using Darcs In-Reply-To: References: <20090401171436.GA12860@whirlpool.galois.com> <873acsxi3y.fsf@malde.org> <20090401202953.GK12860@whirlpool.galois.com> <96FAB1873AA14AF39F2189B2E9F64B80@cr3lt> Message-ID: <20090406010318.GC32396@Macintosh.local> On Wed, Apr 1, 2009 at 11:25 PM, Claus Reinke wrote: > > Perhaps the rumours refer to non-tagged "versions"? In conventional > > non-distributed version control systems, one > > might go back to the version on a specific date, while with > > darcs, that only makes sense wrt a specific repo (I think?). On Wed, Apr 01, 2009 at 23:43:36 +0200, Peter Verswyvelen wrote: > Yes, that might be the rumor indeed, it surely sounds like it :) > Darcs is really very different, so it takes a while to get used to it when > coming from other systems. This has been said in one of the earlier responses, but I thought it was worth repeating: darcs has a notion of context files which can be used to retrieve exactly another version of a repository with darcs get --context name-of-file. You can generate such files by invoking darcs changes --context. For that matter, patch bundles (as created by darcs send) can also be used as context files. It's sometimes quite handy to do something like darcs get --context foo.dpatch to retrieve exactly the version of the repository a patch bundle was meant to apply to. This is one of the little known features of darcs, and should probably appear in some kind of darcs tips series of blog articles :-) -- Eric Kow PGP Key ID: 08AC04F9 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 194 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090406/32382e72/attachment.bin From allbery at ece.cmu.edu Sun Apr 5 21:05:14 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun Apr 5 20:52:26 2009 Subject: [Haskell-cafe] high probability of installation problems and quality of the glorious implementation In-Reply-To: <20090406094756.4a5baae5.mle+hs@mega-nerd.com> References: <20090406091348.33cebac7.mle+hs@mega-nerd.com> <20090406094756.4a5baae5.mle+hs@mega-nerd.com> Message-ID: <3149CC07-D8FD-45E5-B7A1-34EA0890CC3E@ece.cmu.edu> On 2009 Apr 5, at 19:47, Erik de Castro Lopo wrote: > Jason Dagit wrote: >> I wonder when we'll get a good haskell virtual package on Debian? > > What would this package do? Install ghc + all the little pieces of libghc6-cruft needed to get a sane working environment? -- 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/20090405/16e0d809/PGP.bin From lemming at henning-thielemann.de Sun Apr 5 21:09:41 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Apr 5 20:56:39 2009 Subject: [Haskell-cafe] Combining sequences In-Reply-To: <790464.36313.qm@web31104.mail.mud.yahoo.com> References: <790464.36313.qm@web31104.mail.mud.yahoo.com> Message-ID: On Sat, 4 Apr 2009, michael rice wrote: > Is there a simple way to combine two sequences that are in ascending order into a single > sequence that's also in ascending order? An example would be the squares [1,4,9,16,25..] > combined with the cubes [1,8,27,64,125..] to form [1,1,4,8,9,16,25,27..]. http://hackage.haskell.org/packages/archive/utility-ht/0.0.4/doc/html/Data-List-HT.html#v%3AmergeBy From gue.schmidt at web.de Sun Apr 5 21:14:38 2009 From: gue.schmidt at web.de (=?UTF-8?B?R8O8wp9udGhlciBTY2htaWR0?=) Date: Sun Apr 5 21:01:51 2009 Subject: [Haskell-cafe] haskelldb, how to escape table names Message-ID: Hi, how can I "escape" table and column names, from something like: kh-internes-kennz to this: [kh-internes-kennz] ? G?nther From ok at cs.otago.ac.nz Sun Apr 5 22:59:06 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Sun Apr 5 22:46:08 2009 Subject: [Haskell-cafe] high probability of installation problems and quality of the glorious implementation In-Reply-To: <3149CC07-D8FD-45E5-B7A1-34EA0890CC3E@ece.cmu.edu> References: <20090406091348.33cebac7.mle+hs@mega-nerd.com> <20090406094756.4a5baae5.mle+hs@mega-nerd.com> <3149CC07-D8FD-45E5-B7A1-34EA0890CC3E@ece.cmu.edu> Message-ID: <4E82C30E-2B37-44D7-B1C9-444E17A060E6@cs.otago.ac.nz> On 6 Apr 2009, at 1:05 pm, Brandon S. Allbery KF8NH wrote: > On 2009 Apr 5, at 19:47, Erik de Castro Lopo wrote: >> >> What would this package do? > > > Install ghc + all the little pieces of libghc6-cruft needed to get a > sane working environment? I want the Zen package: "Make me one with everything." From nowgate at yahoo.com Sun Apr 5 23:02:57 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Apr 5 22:49:54 2009 Subject: [Haskell-cafe] Combining sequences Message-ID: <534983.77638.qm@web31108.mail.mud.yahoo.com> Thanks. It looks like mergeBy will do the job, but is it available in Hugs? Michael --- On Sun, 4/5/09, Henning Thielemann wrote: From: Henning Thielemann Subject: Re: [Haskell-cafe] Combining sequences To: "michael rice" Cc: haskell-cafe@haskell.org Date: Sunday, April 5, 2009, 9:09 PM On Sat, 4 Apr 2009, michael rice wrote: > Is there a simple way to combine two sequences that are in ascending order into a single > sequence that's also in ascending order? An example would be the squares [1,4,9,16,25..] > combined with the cubes [1,8,27,64,125..] to form [1,1,4,8,9,16,25,27..]. http://hackage.haskell.org/packages/archive/utility-ht/0.0.4/doc/html/Data-List-HT.html#v%3AmergeBy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090405/9d8d1bf7/attachment.htm From dagit at codersbase.com Mon Apr 6 00:23:46 2009 From: dagit at codersbase.com (Jason Dagit) Date: Mon Apr 6 00:10:43 2009 Subject: [Haskell-cafe] high probability of installation problems and quality of the glorious implementation In-Reply-To: <20090406094756.4a5baae5.mle+hs@mega-nerd.com> References: <20090406091348.33cebac7.mle+hs@mega-nerd.com> <20090406094756.4a5baae5.mle+hs@mega-nerd.com> Message-ID: On Sun, Apr 5, 2009 at 4:47 PM, Erik de Castro Lopo wrote: > Jason Dagit wrote: > >> In particular, I advise my friends not to install GHC from apt on >> Debian/Ubuntu because of the way the packages are fractured on those >> distros. > > Fractured? In the sense that they split up the things GHC builds. Specifically, you need to install quite a few packages to get everything that GHC would come with. >> ?Nothing but problems for casual Haskell hackers. ?If you >> know your distro and Haskell well, then sure it's easy to install all >> the packages that constitute a normal ghc install. > > Well I admit that having done a lot of debian packaging in my day job > I know the debian packaging system pretty well. Nice! Debian is my favorite distro by leaps and bounds. > I chose to stick to the debian packages because I found cabal to be a > pain in the neck in comparison :-). Interesting. I'm glad that Open Source provides enough diversity that people can use the tools they enjoy working with. I like cabal just fine but I'm glad we can both choose different paths to meet a common goal. >> I wonder when we'll get a good haskell virtual package on Debian? > > What would this package do? At a minimum it will give you everything that the GHC HQ installer gives you. For the casual haskell hacker, it ideally also gives you the profiled versions of everything thath GHC HQ installer gives you. Perhaps this is the Debian equivalent of the 'batteries included' haskell platform. Thanks, Jason From tphyahoo at gmail.com Mon Apr 6 00:26:18 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Mon Apr 6 00:13:14 2009 Subject: [Haskell-cafe] Combining sequences In-Reply-To: <534983.77638.qm@web31108.mail.mud.yahoo.com> References: <534983.77638.qm@web31108.mail.mud.yahoo.com> Message-ID: <910ddf450904052126r1023c894j4b7a737283551fb2@mail.gmail.com> It's not in hugs, nor in ghc. It's just in hackage. However, by the looks of it, you should probably be able to use it in hugs. I didn't actually check this, but the cabal file didn't name any fancy extensions, so it looks pretty cross-compiler. You can just go to http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utility-ht-0.0.4 wget http://hackage.haskell.org/packages/archive/utility-ht/0.0.4/utility-ht-0.0.4.tar.gz untar and put them with the rest of the files your hugs compiler uses for package import. (I don't actually know how package installation works in hugs... isn't it just put the files into a dir?) thomas. 2009/4/5 michael rice : > Thanks. It looks like mergeBy will do the job, but is it available in Hugs? > > Michael > > > --- On Sun, 4/5/09, Henning Thielemann > wrote: > > From: Henning Thielemann > Subject: Re: [Haskell-cafe] Combining sequences > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Sunday, April 5, 2009, 9:09 PM > > > On Sat, 4 Apr 2009, michael rice wrote: > >> Is there a simple way to combine two sequences that are in ascending order >> into a single >> sequence that's also in ascending order? An example would be the squares >> [1,4,9,16,25..] >> combined with the cubes [1,8,27,64,125..] to form [1,1,4,8,9,16,25,27..]. > > http://hackage.haskell.org/packages/archive/utility-ht/0.0.4/doc/html/Data-List-HT.html#v%3AmergeBy > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From oleg at okmij.org Mon Apr 6 00:28:32 2009 From: oleg at okmij.org (oleg@okmij.org) Date: Mon Apr 6 00:18:29 2009 Subject: [Haskell-cafe] Lazy vs correct IO [Was: A round of golf] In-Reply-To: <42784f260904050722o2432b123ra3418fdc63014b22@mail.gmail.com> Message-ID: <20090406042832.36022AE8C@Adric.metnet.fnmoc.navy.mil> > It opens and closes each file in turn; but it would it be > unwise to open and close each file as we'd read a chunk from > it? This would allow arbitrary interleaving. If I understand you correctly, you are proposing processing several files in parallel, so to interleave IO. If the `files' in question are communication pipes, or if KAIO (kernel asynchronous IO) is available, it is indeed a good strategy. The last example in the file http://okmij.org/ftp/Haskell/Iteratee/IterateeM.hs (called test_driver_mux) demonstrates how to interleave IO with Iteratees. Iteratees of course do not care how the source data have been obtained, with or without interleaving. From briand at aracnet.com Mon Apr 6 01:00:26 2009 From: briand at aracnet.com (brian) Date: Mon Apr 6 00:47:23 2009 Subject: [Haskell-cafe] cabal build on mac os 10.5.6 , can't find gmp Message-ID: <3A500C19-1C62-4BA1-A19A-FFAF8220F0CF@aracnet.com> Hi, Cabal won't build zlib because it can't find libgmp. It's there, in /sw/lib (fink installation). I've modified the bootstrap script and added -L/sw/lib to the ghc options. This is a mystery in itself because ghc is itself a fink package and should know where gmp is, so that's already a bad sign. I can get to the build step with the additional -L option but then ./ Setup fails again because it can't find gmp. Help .... ? Thanks, Brian From duane.johnson at gmail.com Mon Apr 6 01:02:07 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Mon Apr 6 00:49:12 2009 Subject: [Haskell-cafe] Linking hmatrix without LAPACK Message-ID: I'm curious if there is a quick fix to this. I installed GLS and hmatrix, and it runs wonderfully together in ghci. When I run ghc -- make, however, I run into the following link dependency: Linking SilkwormGame ... Undefined symbols: "_dgemm_", referenced from: _multiplyR in libHShmatrix-0.5.0.1.a(lapack-aux.o) "_dgesv_", referenced from: _linearSolveR_l in libHShmatrix-0.5.0.1.a(lapack-aux.o) ... etc Is there a way to tell ghc to not link these? Or am I making a poor assumption that if my code runs in ghci, it does not need LAPACK? Thanks, Duane Johnson From duane.johnson at gmail.com Mon Apr 6 01:35:42 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Mon Apr 6 01:22:46 2009 Subject: [Haskell-cafe] Re: Linking hmatrix without LAPACK In-Reply-To: References: Message-ID: <79A0FBF5-1DCB-447C-9021-8F8700AF0EC8@gmail.com> On a related note, I've installed Atlas, and I get the following error when linking: > Linking SilkwormGame ... > ld: in /opt/local/lib/liblapack.a(), not a valid archive member > collect2: ld returned 1 exit status How would I go about diagnosing this? I've never seen an ld error like that. Thanks again! Duane Johnson On Apr 5, 2009, at 11:02 PM, Duane Johnson wrote: > I'm curious if there is a quick fix to this. I installed GLS and > hmatrix, and it runs wonderfully together in ghci. When I run ghc -- > make, however, I run into the following link dependency: > > Linking SilkwormGame ... > Undefined symbols: > "_dgemm_", referenced from: > _multiplyR in libHShmatrix-0.5.0.1.a(lapack-aux.o) > "_dgesv_", referenced from: > _linearSolveR_l in libHShmatrix-0.5.0.1.a(lapack-aux.o) > ... etc > > Is there a way to tell ghc to not link these? Or am I making a poor > assumption that if my code runs in ghci, it does not need LAPACK? > > Thanks, > Duane Johnson From fft1976 at gmail.com Mon Apr 6 03:07:33 2009 From: fft1976 at gmail.com (FFT) Date: Mon Apr 6 02:54:29 2009 Subject: [Haskell-cafe] Questions about slow GC with STArray Message-ID: I've been following with interest the recent discussions on reddit about the extremely slow hash tables in Haskell compared to F# and OCaml, and as I understood it, this performance problem is caused by GC not liking mutable arrays http://hackage.haskell.org/trac/ghc/ticket/650 It appears from the discussion there that this is more than a simple bug, but a fundamental difficulty (slow writes vs slow GC trade-off). What I'm wondering though is how can this be unique to GHC: all arrays in OCaml and probably F# are mutable (and usually unboxed). How is this problem addressed there? Why is this supposed to be specific to boxed arrays only: wouldn't GC have to scan the whole mutable array whether it's boxed or unboxed? From ketil at malde.org Mon Apr 6 03:36:26 2009 From: ketil at malde.org (Ketil Malde) Date: Mon Apr 6 03:22:13 2009 Subject: [Haskell-cafe] high probability of installation problems and quality of the glorious implementation In-Reply-To: <3149CC07-D8FD-45E5-B7A1-34EA0890CC3E@ece.cmu.edu> (Brandon S. Allbery's message of "Sun\, 5 Apr 2009 21\:05\:14 -0400") References: <20090406091348.33cebac7.mle+hs@mega-nerd.com> <20090406094756.4a5baae5.mle+hs@mega-nerd.com> <3149CC07-D8FD-45E5-B7A1-34EA0890CC3E@ece.cmu.edu> Message-ID: <87skkmmdxh.fsf@malde.org> "Brandon S. Allbery KF8NH" writes: >>> I wonder when we'll get a good haskell virtual package on Debian? >> What would this package do? > Install ghc + all the little pieces of libghc6-cruft needed to get a > sane working environment? Sounds easy to do (after all, it's just an empty package with a bunch of dependencies, right?), but I'm unsure exactly what pieces you want included. This is the current ghc6 package: Provides: ghc, haskell-compiler, libghc6-array-dev, libghc6-base-dev, libghc6-bytestring-dev, libghc6-cabal-dev, libghc6-containers-dev, libghc6-directory-dev, libghc6-filepath-dev, libghc6-haskell98-dev, libghc6-hpc-dev, libghc6-old-locale-dev, libghc6-old-time-dev, libghc6-packedstring-dev, libghc6-pretty-dev, libghc6-process-dev, libghc6-random-dev, libghc6-readline-dev, libghc6-rts-dev, libghc6-template-haskell-dev, libghc6-unix-dev In Ubuntu 8.10, there are 90 separate libghc6.*dev packages, which ones do you think should be added to a GHC meta package? -k -- If I haven't seen further, it is by standing in the footprints of giants From DekuDekuplex at Yahoo.com Mon Apr 6 03:56:13 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Mon Apr 6 03:43:22 2009 Subject: [Haskell-cafe] minor typo in "The Haskell 98 Report" Message-ID: <6pcjt4lehqo1r5g8d19borfu8pbdvuhfbd@4ax.com> Today, as I was reading through "The Haskell 98 Report" (see http://www.haskell.org/onlinereport/), I came across a minor typo, but it seems that the only way to fix such typos is to report them on one of the Haskell mailing lists; viz.: >The original committees ceased to exist when the original Haskell 98 Reports were published, so every change was instead proposed to the entire Haskell mailing list. Therefore, please allow me to report this typo, though minor, here, as follows: The Haskell 98 Report - Preface (see http://www.haskell.org/onlinereport/preface-jfp.html), under the heading "Haskell 98: language and libraries," fourth paragraph, second line: >If these program were to be portable, a set of libraries would have to be standardised too. should be as follows: >If these programs were to be portable, a set of libraries would have to be standardised too. (I.e., the word "program" should be plural.) Is this the proper place to report any forthcoming similar typos? -- 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 ajb at spamcop.net Mon Apr 6 04:02:17 2009 From: ajb at spamcop.net (ajb@spamcop.net) Date: Mon Apr 6 03:49:19 2009 Subject: [Haskell-cafe] Re: [Haskell] [OT] Plural forms of the word "octopus" [Was: Re: Marketing Haskell] In-Reply-To: References: <87d4bwpzjj.fsf@malde.org> <0769t4lt9b4nuo7jkt7fneblt8qf2gibcl@4ax.com> <732349793.20090402162542@gmail.com> <200904030712.36748.coeus@gmx.de> <953e0d250904030009m612343dch8e2e148873614886@mail.gmail.com> <69ebt4db7gbkulv5bmuqdbvt20t56mbplp@4ax.com> <94319932-0C37-481B-96CC-3BF9376E2409@kent.ac.uk> <20090404224413.c2z8g1k0co84wsss-nwo@webmail.spamcop.net> Message-ID: <20090406040217.e1vlq6p6144sw4ck-nwo@webmail.spamcop.net> [Shifted to haskell-cafe.] G'day all. Quoting "Benjamin L.Russell" : > According to the Merriam-Webster Online Dictionary, it is "topoi" (see > http://www.merriam-webster.com/dictionary/topos). Topoi form a certain class of category. You can study topous, you can prove theorems about topois and you can discover properties of topon. (That last one is an omega, so it's pronounced more like "top-own".) > Where did you find "octoposi?" In my ancient copy of Liddell and Scott. Here's the online entry: http://tinyurl.com/ck8gst Cheers, Andrew Bromage From malcolm.wallace at cs.york.ac.uk Mon Apr 6 04:07:22 2009 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Mon Apr 6 03:54:21 2009 Subject: [Haskell-cafe] minor typo in "The Haskell 98 Report" In-Reply-To: <6pcjt4lehqo1r5g8d19borfu8pbdvuhfbd@4ax.com> References: <6pcjt4lehqo1r5g8d19borfu8pbdvuhfbd@4ax.com> Message-ID: <87D648AF-F00A-4E14-922F-296CF6E8EEDC@cs.york.ac.uk> On 6 Apr 2009, at 08:56, Benjamin L.Russell wrote: > Today, as I was reading through "The Haskell 98 Report" (see > http://www.haskell.org/onlinereport/), I came across a minor typo, but > it seems that the only way to fix such typos is to report them on one > of the Haskell mailing lists; Thanks for the bug report. As noted on the page http://haskell.org/haskellwiki/Language_and_library_specification "The report still has minor bugs. There are tracked at the Haskell 98 bugs page. Report any new bugs to Malcolm Wallace". (There are links for the bugs page, and for my email address.) Regards, Malcolm From bulat.ziganshin at gmail.com Mon Apr 6 04:10:43 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Apr 6 04:00:51 2009 Subject: [Haskell-cafe] Questions about slow GC with STArray In-Reply-To: References: Message-ID: <648106222.20090406121043@gmail.com> Hello FFT, Monday, April 6, 2009, 11:07:33 AM, you wrote: > this problem addressed there? Why is this supposed to be specific to > boxed arrays only: wouldn't GC have to scan the whole mutable array > whether it's boxed or unboxed? you need to scan only boxes: if array just contains plain cpu-level numbers, there is nothing to scan one way to solve this problem is to make one `modified` bit per each 256 elements rather than entire array so GC will have to scan only modified chunks -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From fft1976 at gmail.com Mon Apr 6 04:32:53 2009 From: fft1976 at gmail.com (FFT) Date: Mon Apr 6 04:19:49 2009 Subject: [Haskell-cafe] Questions about slow GC with STArray In-Reply-To: <648106222.20090406121043@gmail.com> References: <648106222.20090406121043@gmail.com> Message-ID: On Mon, Apr 6, 2009 at 1:10 AM, Bulat Ziganshin wrote: > you need to scan only boxes: if array just contains plain cpu-level > numbers, there is nothing to scan Are those the only legal contents of STUArray? From pkeir at dcs.gla.ac.uk Mon Apr 6 04:32:58 2009 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Mon Apr 6 04:20:02 2009 Subject: [Haskell-cafe] Unary Minus Message-ID: <3CDFB8AFEA98E34CB599475AB11589C81C7679@EX2.ad.dcs.gla.ac.uk> If I use :info (-) I get information on the binary minus. Is unary minus also a function? Thanks, Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090406/4456d5d9/attachment.htm From dan.doel at gmail.com Mon Apr 6 04:35:14 2009 From: dan.doel at gmail.com (Dan Doel) Date: Mon Apr 6 04:22:14 2009 Subject: [Haskell-cafe] Questions about slow GC with STArray In-Reply-To: <648106222.20090406121043@gmail.com> References: <648106222.20090406121043@gmail.com> Message-ID: <200904060435.15475.dan.doel@gmail.com> On Monday 06 April 2009 4:10:43 am Bulat Ziganshin wrote: > one way to solve this problem is to make one `modified` bit per each 256 > elements rather than entire array so GC will have to scan only > modified chunks For reference, I constructed a benchmark that takes advantage of GHC's tagging of whole arrays to approximate this: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3316 Since each array has a dirty bit, making a type that stores an array of arrays that add up to the desired size is similar to having a dirty bit for chunks the size of the sub-array. The test then fills a 10 million element array. However, something about the benchmark makes it perform poorly for both small chunks and large chunks. -sstderr reports that lots of copying occurs for small chunk sizes, and I haven't bothered to figure out why this is the case. You can, however, see that marking dirty chunks in this fashion would be profitable. The un-chunked array takes around a minute here, while with chunks of 10,000 (which seems to be about the optimal value with the above copying tradeoff), it takes about 6 seconds, and that's still with 60+% GC time. -- Dan From wss at cs.nott.ac.uk Mon Apr 6 04:36:02 2009 From: wss at cs.nott.ac.uk (Wouter Swierstra) Date: Mon Apr 6 04:22:59 2009 Subject: [Haskell-cafe] Unary Minus In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C81C7679@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C81C7679@EX2.ad.dcs.gla.ac.uk> Message-ID: <4CB567B2-87ED-477C-B7C9-48844B474A72@cs.nott.ac.uk> > If I use :info (-) I get information on the binary minus. Is unary > minus also a function? You can define it yourself or use "negate" from the Prelude. Wouter From martijn at van.steenbergen.nl Mon Apr 6 04:36:23 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Mon Apr 6 04:23:19 2009 Subject: [Haskell-cafe] Unary Minus In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C81C7679@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C81C7679@EX2.ad.dcs.gla.ac.uk> Message-ID: <49D9BF07.70909@van.steenbergen.nl> Paul Keir wrote: > If I use :info (-) I get information on the binary minus. Is unary minus > also a function? No, as far as I know the unary minus is part of the number literals. You can use "negate" if you want it as a function. Hope this helps, Martijn. From bulat.ziganshin at gmail.com Mon Apr 6 04:47:06 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Apr 6 04:34:13 2009 Subject: [Haskell-cafe] Questions about slow GC with STArray In-Reply-To: <200904060435.15475.dan.doel@gmail.com> References: <648106222.20090406121043@gmail.com> <200904060435.15475.dan.doel@gmail.com> Message-ID: <875248545.20090406124706@gmail.com> Hello Dan, Monday, April 6, 2009, 12:35:14 PM, you wrote: > the size of the sub-array. The test then fills a 10 million element array. > However, something about the benchmark makes it perform poorly for both small > chunks and large chunks. -sstderr reports that lots of copying occurs for > small chunk sizes, and I haven't bothered to figure out why this is the case. > You can, however, see that marking dirty chunks in this fashion would be > profitable. The un-chunked array takes around a minute here, while with chunks > of 10,000 (which seems to be about the optimal value with the above copying > tradeoff), it takes about 6 seconds, and that's still with 60+% GC time. i don't think that 60% GC time is bad for *this* benchmark. array filling is very trivial operation, after all. important part is 10x GC times reduce, apply these numbers to original benchmark -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Mon Apr 6 04:49:49 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Apr 6 04:37:12 2009 Subject: [Haskell-cafe] Questions about slow GC with STArray In-Reply-To: References: <648106222.20090406121043@gmail.com> Message-ID: <698084143.20090406124949@gmail.com> Hello FFT, Monday, April 6, 2009, 12:32:53 PM, you wrote: >> you need to scan only boxes: if array just contains plain cpu-level >> numbers, there is nothing to scan > Are those the only legal contents of STUArray? numbers, chars, vanilla pointers. UArray just mimics C arrays, after all -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From fft1976 at gmail.com Mon Apr 6 04:56:51 2009 From: fft1976 at gmail.com (FFT) Date: Mon Apr 6 04:43:48 2009 Subject: [Haskell-cafe] Questions about slow GC with STArray In-Reply-To: <698084143.20090406124949@gmail.com> References: <648106222.20090406121043@gmail.com> <698084143.20090406124949@gmail.com> Message-ID: On Mon, Apr 6, 2009 at 1:49 AM, Bulat Ziganshin wrote: >> Are those the only legal contents of STUArray? > > numbers, chars, vanilla pointers. UArray just mimics C arrays, after all > I haven't gotten to learning about them in detail yet, but my hope was that STUArray was like vector in C++, and STArray was like vector. Both are fairly general. So if I need a array of complex numbers in Haskell, will I need an extra level of indirection compared to C? And in addition to that some serious issues with GC speed if those arrays need to be mutable? From claus.reinke at talk21.com Mon Apr 6 05:04:51 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon Apr 6 04:51:54 2009 Subject: [Haskell-cafe] high probability of installation problems andquality of the glorious implementation References: <20090406091348.33cebac7.mle+hs@mega-nerd.com><20090406094756.4a5baae5.mle+hs@mega-nerd.com><3149CC07-D8FD-45E5-B7A1-34EA0890CC3E@ece.cmu.edu> <4E82C30E-2B37-44D7-B1C9-444E17A060E6@cs.otago.ac.nz> Message-ID: <7C19CBB9832D4439907B952D20CDC226@cr3lt> > I want the Zen package: "Make me one with everything." But would you find that on hackage?-) If an author had contemplated the perfect package, they wouldn't have put it on hackage, they wouldn't have a hackage account, they wouldn't have written the package, they might not even exist - you would just get the idea. Claus (inspired by the ZenBot entry in the list of programs that play on the computer Go server: http://senseis.xmp.net/?ComputerGoServer ) From ndmitchell at gmail.com Mon Apr 6 05:13:25 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon Apr 6 05:00:20 2009 Subject: [Haskell-cafe] EclipseFP proposal for Google Summer of Code In-Reply-To: References: Message-ID: <404396ef0904060213x57c5a27arf60d541c4f8e691e@mail.gmail.com> Hi Thomas, > I send this e-mail because of possible scheduling issues: I will be > away starting on April 15. So, if you want to ask me things, have > suggestions for improvement, or want to do an interview or something, > this can only be done *before* that date. I am pretty sure all the questions from Haskell will be asked in the next few days, so I wouldn't worry - although usually there aren't any. > P.S. I hope it's okay that I post this to the haskell-cafe list as > well; since haskell.org has no GSoC-specific mailing list, it seems to > be the most appropriate place that I could find. We discuss SoC stuff on haskell-cafe so it's fine. Thanks Neil From lennart at augustsson.net Mon Apr 6 05:14:52 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Mon Apr 6 05:01:48 2009 Subject: [Haskell-cafe] Unary Minus In-Reply-To: <49D9BF07.70909@van.steenbergen.nl> References: <3CDFB8AFEA98E34CB599475AB11589C81C7679@EX2.ad.dcs.gla.ac.uk> <49D9BF07.70909@van.steenbergen.nl> Message-ID: Unary minus is a hack in the syntax for allowing the function negate to be written as prefix -. On Mon, Apr 6, 2009 at 10:36 AM, Martijn van Steenbergen wrote: > Paul Keir wrote: >> >> If I use :info (-) I get information on the binary minus. Is unary minus >> also a function? > > No, as far as I know the unary minus is part of the number literals. You can > use "negate" if you want it as a function. > > Hope this helps, > > Martijn. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bulat.ziganshin at gmail.com Mon Apr 6 05:25:34 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Apr 6 05:17:15 2009 Subject: [Haskell-cafe] Questions about slow GC with STArray In-Reply-To: References: <648106222.20090406121043@gmail.com> <698084143.20090406124949@gmail.com> Message-ID: <1648414268.20090406132534@gmail.com> Hello FFT, Monday, April 6, 2009, 12:56:51 PM, you wrote: >>> Are those the only legal contents of STUArray? >> >> numbers, chars, vanilla pointers. UArray just mimics C arrays, after all >> > I haven't gotten to learning about them in detail yet, but my hope was > that STUArray was like vector in C++, and STArray was like > vector. Both are fairly general. well, that's good comparison for some degree, but the catch is that Haskell doesn't have unboxed types at all. therefore, [ST]UArray is something that you can't implement in pure Haskell, it's just like providing API to some C arrays. they are implemented via special operations in GHC runtime that are limited to support only numbers/chars/pointers. so you can't have UArray of Complex numbers (although you can use two array of Doubles of course) UArray is rather old thing, nowadays you may use StorableArray or one of many newer array/vector libraries. unfortunately, they tend to don't support ST monad, so you will need to write a little wrappers using unsafeIOtoST operation > So if I need a array of complex numbers in Haskell, will I need an > extra level of indirection compared to C? And in addition to that some > serious issues with GC speed if those arrays need to be mutable? [1] http://haskell.org/haskellwiki/Library/ArrayRef [2] http://www.haskell.org/haskellwiki/Storable_Vector recent cafe threads http://www.haskell.org/pipermail/haskell-cafe/2008-July/045229.html http://www.haskell.org/pipermail/haskell-cafe/2009-March/057240.html -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From DekuDekuplex at Yahoo.com Mon Apr 6 06:04:17 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Mon Apr 6 05:51:22 2009 Subject: [Haskell-cafe] Re: Unary Minus References: <3CDFB8AFEA98E34CB599475AB11589C81C7679@EX2.ad.dcs.gla.ac.uk> <49D9BF07.70909@van.steenbergen.nl> Message-ID: Interesting. How is this hack implemented? I just checked the BNF grammar for the lexical syntax of Haskell in "The Haskell 98 Language Report" (see the BNF grammer given under "9.2 Lexical Syntax" under "9 Syntax Reference" at http://www.haskell.org/onlinereport/syntax-iso.html), but had difficulty in deriving a unary minus. Could somebody please enlighten me on how to derive the expression "-1" (a unary minus followed the the ascDigit 1) from the above-mentioned BNF grammar? Or is a unary minus not part of this grammar? -- Benjamin L. Russell On Mon, 6 Apr 2009 11:14:52 +0200, Lennart Augustsson wrote: >Unary minus is a hack in the syntax for allowing the function negate >to be written as prefix -. > >On Mon, Apr 6, 2009 at 10:36 AM, Martijn van Steenbergen > wrote: >> Paul Keir wrote: >>> >>> If I use :info (-) I get information on the binary minus. Is unary minus >>> also a function? >> >> No, as far as I know the unary minus is part of the number literals. You can >> use "negate" if you want it as a function. >> >> Hope this helps, >> >> Martijn. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> -- 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 vandijk.roel at gmail.com Mon Apr 6 06:13:09 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Mon Apr 6 06:00:04 2009 Subject: [Haskell-cafe] Re: Unary Minus In-Reply-To: References: <3CDFB8AFEA98E34CB599475AB11589C81C7679@EX2.ad.dcs.gla.ac.uk> <49D9BF07.70909@van.steenbergen.nl> Message-ID: On Mon, Apr 6, 2009 at 12:04 PM, Benjamin L.Russell wrote: > Interesting. ?How is this hack implemented? This seems to be the relevant grammar: lexp6 -> - exp7 lpat6 -> - (integer | float) (negative literal) The '6's and the '7' are superscripts. Perhaps the hack is in the precedence of the expression in which an unary minus is allowed. From DekuDekuplex at Yahoo.com Mon Apr 6 06:33:31 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Mon Apr 6 06:20:40 2009 Subject: [Haskell-cafe] Re: Unary Minus References: <3CDFB8AFEA98E34CB599475AB11589C81C7679@EX2.ad.dcs.gla.ac.uk> <49D9BF07.70909@van.steenbergen.nl> Message-ID: On Mon, 6 Apr 2009 12:13:09 +0200, Roel van Dijk wrote: >On Mon, Apr 6, 2009 at 12:04 PM, Benjamin L.Russell > wrote: >> Interesting. ?How is this hack implemented? > >This seems to be the relevant grammar: > lexp6 -> - exp7 > lpat6 -> - (integer | float) (negative literal) > >The '6's and the '7' are superscripts. >Perhaps the hack is in the precedence of the expression in which an >unary minus is allowed. Yes, I see it now. It's under "9.5 Context-Free Syntax," instead of being under "9.2 Lexical Syntax," so it's a syntactic rule, rather than a lexical rule. According to the rule, "a left-expression of precedence level 6" consists of "'-' followed by an expression of precedence level 7", and "a left-pattern of precedence level 6" consists of "'-' followed by (an integer or a float)", and by definition, this is a "negative literal." Integers and floats, in turn, are part of the lexical syntax. -- 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 DekuDekuplex at Yahoo.com Mon Apr 6 07:02:58 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Mon Apr 6 06:50:06 2009 Subject: [Haskell-cafe] Re: Unary Minus References: <3CDFB8AFEA98E34CB599475AB11589C81C7679@EX2.ad.dcs.gla.ac.uk> <49D9BF07.70909@van.steenbergen.nl> Message-ID: On Mon, 6 Apr 2009 12:13:09 +0200, Roel van Dijk wrote: >On Mon, Apr 6, 2009 at 12:04 PM, Benjamin L.Russell > wrote: >> Interesting. ?How is this hack implemented? > >This seems to be the relevant grammar: > lexp6 -> - exp7 > lpat6 -> - (integer | float) (negative literal) > >The '6's and the '7' are superscripts. >Perhaps the hack is in the precedence of the expression in which an >unary minus is allowed. What's interesting are the following definitions of the functions '-' (binary minus) and "negate" given in "8 Standard Prelude" (see http://www.haskell.org/onlinereport/standard-prelude.html#$tNum): >class (Eq a, Show a) => Num a where > (+), (-), (*) :: a -> a -> a > negate :: a -> a > abs, signum :: a -> a > fromInteger :: Integer -> a > > -- Minimal complete definition: > -- All, except negate or (-) > x - y = x + negate y > negate x = 0 - x The type of "negate," "a -> a", where a is a Num, is precisely what is needed for a unary minus. -- 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 gue.schmidt at web.de Mon Apr 6 08:46:00 2009 From: gue.schmidt at web.de (=?UTF-8?B?R8O8wp9udGhlciBTY2htaWR0?=) Date: Mon Apr 6 08:33:10 2009 Subject: [Haskell-cafe] Paper: Translating donotation to SQL, Leijden, Meijer Message-ID: Hi all, is the paper "Translating donotation to SQL, Leijden, Meijer (1999)" available anywhere? G?nther From sjoerd at w3future.com Mon Apr 6 10:02:41 2009 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Mon Apr 6 09:50:56 2009 Subject: [Haskell-cafe] replicateM should be called mreplicate? Message-ID: Considering these naming conventions: http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad.html#3 ? A postfix 'M' always stands for a function in the Kleisli category: The monad type constructor m is added to function results (modulo currying) and nowhere else. So, for example, filter :: (a -> Bool) -> [a] -> [a] filterM :: (Monad m) => (a -> m Bool) -> [a] -> m [a] ? A postfix '_' changes the result type from (m a) to (m ()). Thus, for example: sequence :: Monad m => [m a] -> m [a] sequence_ :: Monad m => [m a] -> m () ? A prefix 'm' generalizes an existing function to a monadic form. Thus, for example: sum :: Num a => [a] -> a msum :: MonadPlus m => [m a] -> m a replicateM has the following type: replicateM :: Monad m => Int -> m a -> m [a] Am I missing something or should this have been called mreplicate? greetings, -- Sjoerd Visscher sjoerd@w3future.com From nowgate at yahoo.com Mon Apr 6 11:12:42 2009 From: nowgate at yahoo.com (michael rice) Date: Mon Apr 6 10:59:40 2009 Subject: [Haskell-cafe] Combining sequences Message-ID: <961870.28311.qm@web31102.mail.mud.yahoo.com> I downloaded it and it appears more complicated than just adding files to a directory. There's a setup and a build, and no assurances it will work with Hugs. I think I'll wait for more information. Michael --- On Mon, 4/6/09, Thomas Hartman wrote: From: Thomas Hartman Subject: Re: [Haskell-cafe] Combining sequences To: "michael rice" Cc: "Henning Thielemann" , haskell-cafe@haskell.org Date: Monday, April 6, 2009, 12:26 AM It's not in hugs, nor in ghc. It's just in hackage. However, by the looks of it, you should probably be able to use it in hugs. I didn't actually check this, but the cabal file didn't name any fancy extensions, so it looks pretty cross-compiler. You can just go to http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utility-ht-0.0.4 wget http://hackage.haskell.org/packages/archive/utility-ht/0.0.4/utility-ht-0.0.4.tar.gz untar and put them with the rest of the files your hugs compiler uses for package import. (I don't actually know how package installation works in hugs... isn't it just put the files into a dir?) thomas. 2009/4/5 michael rice : > Thanks. It looks like mergeBy will do the job, but is it available in Hugs? > > Michael > > > --- On Sun, 4/5/09, Henning Thielemann > wrote: > > From: Henning Thielemann > Subject: Re: [Haskell-cafe] Combining sequences > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Sunday, April 5, 2009, 9:09 PM > > > On Sat, 4 Apr 2009, michael rice wrote: > >> Is there a simple way to combine two sequences that are in ascending order >> into a single >> sequence that's also in ascending order? An example would be the squares >> [1,4,9,16,25..] >> combined with the cubes [1,8,27,64,125..] to form [1,1,4,8,9,16,25,27..]. > > http://hackage.haskell.org/packages/archive/utility-ht/0.0.4/doc/html/Data-List-HT.html#v%3AmergeBy > > > _______________________________________________ > 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/20090406/3d79d8f9/attachment.htm From jeremy at n-heptane.com Mon Apr 6 11:48:36 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Mon Apr 6 11:35:34 2009 Subject: [Haskell-cafe] Re: Haskell EDSL to generate SQL? In-Reply-To: <49D8A4D5.4000802@web.de> References: <877i20frzu.wl%jeremy@n-heptane.com> <49D8A4D5.4000802@web.de> Message-ID: <87y6udeqaz.wl%jeremy@n-heptane.com> At Sun, 05 Apr 2009 14:32:21 +0200, G??nther Schmidt wrote: > What is the best resource to look for more detail examples? No idea. I have not used it in years. And, last I checked, it is far from perfect. For example, I believe that field names must be unique across all tables. Also, there was a project, coddfish that may be of interest. http://wiki.di.uminho.pt/twiki/bin/view/Research/PURe/CoddFish I think it provides a more direct mapping to SQL. - jeremy From pkeir at dcs.gla.ac.uk Mon Apr 6 11:53:24 2009 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Mon Apr 6 11:40:21 2009 Subject: [Haskell-cafe] Infix tuple comma query (,) Message-ID: <3CDFB8AFEA98E34CB599475AB11589C81C768A@EX2.ad.dcs.gla.ac.uk> module Main where data (:%^&) a b = a :%^& b deriving (Show) main = do print $ 18 :%^& (Just 99) print $ (,) 9 10 print $ 9 , 10 The last line in the code above causes a compile error. Why does infix use of the comma (tuple constructor?) function fail without brackets? Thanks, Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090406/aafa07fe/attachment.htm From daniel.is.fischer at web.de Mon Apr 6 12:04:31 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Apr 6 11:51:35 2009 Subject: [Haskell-cafe] Combining sequences In-Reply-To: <961870.28311.qm@web31102.mail.mud.yahoo.com> References: <961870.28311.qm@web31102.mail.mud.yahoo.com> Message-ID: <200904061804.31875.daniel.is.fischer@web.de> Am Montag 06 April 2009 17:12:42 schrieb michael rice: > I downloaded it and it appears more complicated than just adding files to a > directory. There's a setup and a build, and no assurances it will work with > Hugs. > > I think I'll wait for more information. > > Michael > Try installing it with Cabal: ./Setup.lhs configure --hugs if that doesn't say otherwise, chances are that it will work, so try ./Setup.lhs build sudo ./Setup.lhs install If it doesn't work, you can copy the code from Data.List.HT From daniel.is.fischer at web.de Mon Apr 6 12:08:17 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Apr 6 11:55:20 2009 Subject: [Haskell-cafe] Infix tuple comma query (,) In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C81C768A@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C81C768A@EX2.ad.dcs.gla.ac.uk> Message-ID: <200904061808.18032.daniel.is.fischer@web.de> Am Montag 06 April 2009 17:53:24 schrieb Paul Keir: > module Main where > > > > data (:%^&) a b = a :%^& b deriving (Show) > > > > main = do > > print $ 18 :%^& (Just 99) > > print $ (,) 9 10 > > print $ 9 , 10 > > > > The last line in the code above causes a compile error. > > Why does infix use of the comma (tuple constructor?) function fail > without brackets? > Tuples are special baked-in syntax. The parentheses are part of the tuple constructor(s). It may be confusing you that you can use it prefix as well as "aroundfix". > > > Thanks, > > Paul From Tillmann.Vogt at rwth-aachen.de Mon Apr 6 13:22:09 2009 From: Tillmann.Vogt at rwth-aachen.de (Tillmann Vogt) Date: Mon Apr 6 13:09:09 2009 Subject: [Haskell-cafe] ANN: SVGFonts 0.1 In-Reply-To: References: Message-ID: <49DA3A41.2070409@rwth-aachen.de> I hereby publish my first library in Haskell. SVGFonts 0.1 It parses the pretty unknown SVG Font format to produce outlines of characters. The big advantage of this format is that it is XML, which means easy parsing and manipulating. Because I haven't found any svg-files on the Internet the typical way is to convert a more popular format (i.e. .ttf) into SVG Font via fontforge. This library may be useful if you want to have a direct access to specific algorithms which is of course harder when using a binding (i.e. Jeff Heards FTGL binding). The speed is improvable (see TO DO list) and since since this is my first library there might some errors which I am not aware of (please tell me). I also wonder why the library doesn't appear under graphics on hackage, although there is Category: Graphics in my cabal file. Depending on which library I like more, I will maybe integrate SVGFonts into LambdaCube or Fieldtrip Cheers, Tillmann From vanenkj at gmail.com Mon Apr 6 13:24:45 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon Apr 6 13:11:40 2009 Subject: [Haskell-cafe] ANN: SVGFonts 0.1 In-Reply-To: <49DA3A41.2070409@rwth-aachen.de> References: <49DA3A41.2070409@rwth-aachen.de> Message-ID: This sounds very cool. Is is just a program, or is there a library sitting behind it? From your .cabal file, it seems to be just a binary program. Is this correct? http://hackage.haskell.org/packages/archive/SVGFonts/0.1/SVGFonts.cabal On Mon, Apr 6, 2009 at 1:22 PM, Tillmann Vogt wrote: > I hereby publish my first library in Haskell. > > SVGFonts 0.1 > > It parses the pretty unknown SVG Font format to produce outlines of > characters. The big advantage of this format is that it is XML, which means > easy parsing and manipulating. Because I haven't found any svg-files on the > Internet the typical way is to convert a more popular format (i.e. .ttf) > into SVG Font via fontforge. > > This library may be useful if you want to have a direct access to specific > algorithms which is of course harder when using a binding (i.e. Jeff Heards > FTGL binding). The speed is improvable (see TO DO list) and since since this > is my first library there might some errors which I am not aware of (please > tell me). I also wonder why the library doesn't appear under graphics on > hackage, although there is Category: Graphics in my cabal file. > > Depending on which library I like more, I will maybe integrate SVGFonts > into LambdaCube or Fieldtrip > > Cheers, > Tillmann > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090406/597f7c72/attachment.htm From claus.reinke at talk21.com Mon Apr 6 13:32:33 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon Apr 6 13:19:37 2009 Subject: [Haskell-cafe] community.haskell.org unreachable? Message-ID: I seem to be having problems reaching anything on that server. Does anyone know what is going on, or who to contact? It would help if the haskellwiki page http://www.haskell.org/haskellwiki/Haskell.org_domain would mention the admin address directly, instead of referring to http://community.haskell.org/admin/ which is also unreachable. Claus From Tillmann.Vogt at rwth-aachen.de Mon Apr 6 13:32:50 2009 From: Tillmann.Vogt at rwth-aachen.de (Tillmann Vogt) Date: Mon Apr 6 13:19:49 2009 Subject: [Haskell-cafe] ANN: SVGFonts 0.1 In-Reply-To: References: Message-ID: <49DA3CC2.9070509@rwth-aachen.de> John Van Enk schrieb: > This sounds very cool. Is is just a program, or is there a library sitting > behind it? From your .cabal file, it seems to be just a binary program. > > Is this correct? > > http://hackage.haskell.org/packages/archive/SVGFonts/0.1/SVGFonts.cabal > > On Mon, Apr 6, 2009 at 1:22 PM, Tillmann Vogt > wrote: > It is a real library made of pure Haskell. What is wrong with my .cabal file? From wagner.andrew at gmail.com Mon Apr 6 13:37:31 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Mon Apr 6 13:24:25 2009 Subject: [Haskell-cafe] community.haskell.org unreachable? In-Reply-To: References: Message-ID: Works for me. The admin address referenced there is support [AT] community.haskell.org On Mon, Apr 6, 2009 at 1:32 PM, Claus Reinke wrote: > I seem to be having problems reaching anything on that server. > Does anyone know what is going on, or who to contact? It would > help if the haskellwiki page > > http://www.haskell.org/haskellwiki/Haskell.org_domain > > would mention the admin address directly, instead of referring to > > http://community.haskell.org/admin/ > which is also unreachable. > > Claus > > _______________________________________________ > 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/20090406/4250be4d/attachment.htm From claus.reinke at talk21.com Mon Apr 6 13:37:37 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon Apr 6 13:24:38 2009 Subject: [Haskell-cafe] Making videos of your project References: <20090324205915.GA7030@whirlpool.galois.com><3313A5D8A9FA49DBABAEAAE4449612C3@cr3lt> <20090331151012.GA24756@matrix.chaos.earth.li> Message-ID: Btw, there seem to be many Haskells on YouTube - should we have some way of marking clips related to our Haskell? I've used haskell.org as a tag, but noone else has, yet - also, perhaps there should be a Haskell channel or something? And just in case there are others on the same Windows adventure:-) >> Is there anyone here with experience in screencasting of text-based >> applications, who could offer advice on how to produce screencasts >> on windows/xp? The basic screencasting (capture+annotation/editing) >> is not the problem, eg, CamStudio seems ok, and Wink gives me >> more control for mostly input-driven sessions (where I want >> screenshots whenever something useful happens, not long videos of >> my mousepointer wavering about the screen;-). Both can generate .swf. >.. > I think making .swf is a mistake, but I'm not sure. I should have believed you there!-) I did actually check that Youtube listed .swf among its supported file types before making my screencast, but when I had actually joined and uploaded, I discovered that it would fail on conversion.. More detailed search in the user forums indicated that this is a common problem, with no solution other than to convert to another, video- rather than animation-based, format. Problem is, .swf is very suited to this particular input-driven kind of screencast (and renders just fine in my browser), eg, Wink has a non-video capture mode that only adds frames when something happens (the only negative: while one can extend the time frames are shown, I've not yet found a way to reduce the minimum time, so typing looks rather unnaturally ssllooww). Any attempt to convert my just over 1Mb .swf files (one screencast, split and edited into 3 sections of 4 minutes or less) to something listed as supported (such as .avi, .mpeg2) resulted in huge files sizes (60Mb and upwards) that would be impractical to upload with my old narrowband connection (might just be that I don't have the right compressing codecs for these formats?). Fortunately, while trying to find some way of contacting YT staff, I stumbled on other help pages that mentioned .wmv in their version of supported file types. For that, one of the codecs on my machine produces files that are only 10x the size of the original .swf, so I'm slowly uploading them to YT, and the first two parts have now been published without conversion failure. I was sorely tempted just to upload the small .swfs to haskell.org, instead of the .wnk->.swf(1Mb)->.avi(60Mb)->.wmf(10Mb) plus tedious upload route I had to follow with the free or preinstalled tools available to me. But community.haskell.org seems to be having enough trouble right now, without hosting clips there.. > I rendered it in 2 or 3 formats (at 640x480 etc, following the you tube > / google video recommendations), and uploaded the one that looked best. > You-tube immediately(ish) makes a low quality version available > (320x240?), and a high quality version(480x360?), with more readable > text etc, is available a little later. Testing with multiple formats/codecs/uploads is recommended, though the conversion can be somewhat nightmarish (too many options and tools, many of which look less than trustworthy, too complex, too expensive, or all of the above; and too few roads to something that works). For 640x400 uploads, the near immediately available version seems readable enough (search for tag haskell.org or wait for the announcement;-). > I would recommend working in a 640x480 screen area. If you can't show > anything in that area, then people won't be able to see anything in your > video (at the size/quality youtube shows it, at least). Sound advice, which I followed in the end. Just took some more preparation to find a setup that would fit the screencast, rather than my usual working habits. I also noticed that I had somehow managed to switch off my ClearType support, which explained the initially low quality font rendering. Thanks, Claus From dave at zednenem.com Mon Apr 6 13:42:31 2009 From: dave at zednenem.com (David Menendez) Date: Mon Apr 6 13:29:27 2009 Subject: [Haskell-cafe] replicateM should be called mreplicate? In-Reply-To: References: Message-ID: <49a77b7a0904061042ra528a29v5e976a19ba0aa71b@mail.gmail.com> On Mon, Apr 6, 2009 at 10:02 AM, Sjoerd Visscher wrote: > Considering these naming conventions: > http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Monad.html#3 > > ? A postfix 'M' always stands for a function in the Kleisli category: The > monad type constructor m is added to function results (modulo currying) and > nowhere else. So, for example, > > ?filter ?:: ? ? ? ? ? ? ?(a -> ? Bool) -> [a] -> ? [a] > ?filterM :: (Monad m) => (a -> m Bool) -> [a] -> m [a] > > ? A postfix '_' changes the result type from (m a) to (m ()). Thus, for > example: > > ?sequence ?:: Monad m => [m a] -> m [a] > ?sequence_ :: Monad m => [m a] -> m () > > ? A prefix 'm' generalizes an existing function to a monadic form. Thus, for > example: > > ?sum ?:: Num a ? ? ? => [a] ? -> a > ?msum :: MonadPlus m => [m a] -> m a > > replicateM has the following type: > > ?replicateM :: Monad m => Int -> m a -> m [a] > > Am I missing something or should this have been called mreplicate? Not necessarily. If you use replicateM in the identity monad, you get replicate. Similarly with filterM and filter, or foldM and foldl. In contrast, msum and sum are essentially mconcat specialized to the monoids (mplus, mzero) and ((+), 0), respectively. Of course, this suggests that mfix should be fixM, so perhaps a better distinction is that mplus and mfix need to be defined per-monad, whereas filterM and replicateM are generic. -- Dave Menendez From max.rabkin at gmail.com Mon Apr 6 13:42:45 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Mon Apr 6 13:29:57 2009 Subject: [Haskell-cafe] ANN: SVGFonts 0.1 In-Reply-To: <49DA3CC2.9070509@rwth-aachen.de> References: <49DA3CC2.9070509@rwth-aachen.de> Message-ID: On Mon, Apr 6, 2009 at 7:32 PM, Tillmann Vogt wrote: > It is a real library made of pure Haskell. What is wrong with my .cabal > file? The issue is not about whether it is pure Haskell. You have simply marked it up as an executable rather than a library. Executable Fonts Main-is: test/Fonts.hs Build-Depends: haskell98, base, OpenGL, GLUT, xml, parsec --Max From vanenkj at gmail.com Mon Apr 6 13:46:07 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon Apr 6 13:33:01 2009 Subject: [Haskell-cafe] ANN: SVGFonts 0.1 In-Reply-To: <49DA3CC2.9070509@rwth-aachen.de> References: <49DA3CC2.9070509@rwth-aachen.de> Message-ID: What your cabal file describes is a single executable, Executable Fonts main-is: tests/Fonts.hs This just tells us to build the file tests/Fonts.hs into a single executable named 'Fonts'. You probably want to retructure your project a bit into something like this. ./LICENSE ./README ./Setup.hs ./src ./src/SVGFonts ./src/SVGFonts/KETTriangulation.hs ./src/SVGFonts/PointOfView.hs ./src/SVGFonts/ReadFont.hs ./SVGFonts.cabal ./test ./test/Fonts.hs ./test/GirlsareWeird.svg ./test/LinLibertineO.svg ./test/Scriptin.svg ./TODO Here's what your cabal file should probably look like: Name: SVGFonts Version: 0.1 Description: parse svg-font files and generate outlines of letters and sentences License: GPL License-file: LICENSE Author: Tillmann Vogt Maintainer: Tillmann.Vogt@rwth-aachen.de Build-Type: Simple Cabal-Version: >=1.2 library build-depends: haskell98, base, OpenGL, GLUT, xml, parsec exposed-modules: SVGFonts.KETTriangulation SVGFonts.PointOfView SVGFonts.ReadFont That isn't exact, but it should be close. /jve On Mon, Apr 6, 2009 at 1:32 PM, Tillmann Vogt wrote: > John Van Enk schrieb: > >> This sounds very cool. Is is just a program, or is there a library sitting >> behind it? From your .cabal file, it seems to be just a binary program. >> >> Is this correct? >> >> http://hackage.haskell.org/packages/archive/SVGFonts/0.1/SVGFonts.cabal >> >> On Mon, Apr 6, 2009 at 1:22 PM, Tillmann Vogt >> wrote: >> >> > > It is a real library made of pure Haskell. What is wrong with my .cabal > file? > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090406/74ceedb7/attachment.htm From lrpalmer at gmail.com Mon Apr 6 13:46:17 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Apr 6 13:33:12 2009 Subject: [Haskell-cafe] replicateM should be called mreplicate? In-Reply-To: <49a77b7a0904061042ra528a29v5e976a19ba0aa71b@mail.gmail.com> References: <49a77b7a0904061042ra528a29v5e976a19ba0aa71b@mail.gmail.com> Message-ID: <7ca3f0160904061046x3a03ca00jfe325c4ae9ea8021@mail.gmail.com> On Mon, Apr 6, 2009 at 11:42 AM, David Menendez wrote: > Of course, this suggests that mfix should be fixM, so perhaps a better > distinction is that mplus and mfix need to be defined per-monad, > whereas filterM and replicateM are generic. Don't you think that is an incidental distinction, not an essential one? It would be like naming our favorite operations mbind and joinM, just because of the way we happened to write the monad class. Luke > > > -- > 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/20090406/a377ffc2/attachment.htm From xofon at pikomat.mff.cuni.cz Mon Apr 6 14:15:37 2009 From: xofon at pikomat.mff.cuni.cz (Petr Skovron) Date: Mon Apr 6 14:02:31 2009 Subject: [Haskell-cafe] Ghc: -O harmful? Message-ID: <20090406181537.GA14402@pikomat.mff.cuni.cz> Hello all, I have a haskell program that runs an order of magnitude slower when compiled with optimisations turned on. This happens on 6.8.2 as well as 6.10.1: petr@r4at184:/tmp[1]% ghc --make -fforce-recomp -o out buga.hs [1 of 1] Compiling Main ( buga.hs, buga.o ) Linking out ... petr@r4at184:/tmp% time ./out < 3-med.in >|/dev/null ./out < 3-med.in >| /dev/null 0,03s user 0,00s system 99% cpu 0,038 total petr@r4at184:/tmp% ghc --make -fforce-recomp -o out buga.hs -O [1 of 1] Compiling Main ( buga.hs, buga.o ) Linking out ... petr@r4at184:/tmp% time ./out < 3-med.in >|/dev/null ./out < 3-med.in >| /dev/null 0,99s user 0,01s system 99% cpu 1,001 total petr@r4at184:/tmp[1]% ghc --make -fforce-recomp -o out buga.hs -O2 [1 of 1] Compiling Main ( buga.hs, buga.o ) Linking out ... petr@r4at184:/tmp% time ./out < 3-med.in >|/dev/null ./out < 3-med.in >| /dev/null 0,99s user 0,01s system 99% cpu 1,004 total petr@r4at184:/tmp% ghc --version The Glorious Glasgow Haskell Compilation System, version 6.8.2 psxxxxxx:/tmp$ ghc --make -fforce-recomp -o out buga.hs [1 of 1] Compiling Main ( buga.hs, buga.o ) Linking out ... psxxxxxx:/tmp$ time ./out < 3-med.in >|/dev/null real 0m0.028s user 0m0.011s sys 0m0.007s psxxxxxx:/tmp$ ghc --make -fforce-recomp -o out buga.hs -O [1 of 1] Compiling Main ( buga.hs, buga.o ) Linking out ... psxxxxxx:/tmp$ time ./out < 3-med.in >|/dev/null real 0m0.252s user 0m0.225s sys 0m0.011s psxxxxxx:/tmp$ ghc --make -fforce-recomp -o out buga.hs -O2 [1 of 1] Compiling Main ( buga.hs, buga.o ) Linking out ... Vazeny pane, cekam na Vase rozkazy. psxxxxxx:/tmp$ time ./out < 3-med.in >|/dev/null real 0m0.239s user 0m0.225s sys 0m0.010s psxxxxxx:/tmp$ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.10.1 The GHC documentation states that > -O2: > Means: "Apply every non-dangerous optimisation, even if it means > significantly longer compile times." The avoided "dangerous" > optimisations are those that can make runtime or space worse if > you're unlucky. They are normally turned on or off individually. If I understand this correctly, the dangerous optimisations should not be performed with -O. Am I doing anything wrong? Am I hitting a bug in GHC optimiser? A known one? The program source: -------------- petr@r4at184:/tmp$ cat buga.hs {-# LANGUAGE FlexibleContexts #-} import Control.Monad import Control.Monad.State data Predpoc a = Nic | Kus { delka :: Int, levy :: Predpoc a, pravy :: Predpoc a } deriving Show gList i = Kus 1 Nic Nic gPredpoc kus1 kus2 = Kus (delka kus1 + delka kus2) kus1 kus2 pop :: MonadState [a] m => m a pop = get >>= \(x:xs) -> put xs >> return x mbuild :: MonadState [Int] m => Int -> m (Predpoc Int) mbuild 1 = gList `liftM` pop mbuild n = liftM2 gPredpoc (mbuild n1) (mbuild n2) where n1 = n`div`2 n2 = n - n1 build n li = evalState (mbuild n) li best :: Predpoc Int -> Int -> Int -> Int best kus i j | i == 1 && j == delka kus = delka kus | j <= del1 = best (levy kus) i j | i > del1 = best (pravy kus) (i-del1) (j-del1) | otherwise = best (levy kus) i del1 + best (pravy kus) 1 (j-del1) where del1 = delka (levy kus) main = do n <- read `liftM` getLine pole <- liftM (build n . map read . words) getLine replicateM_ 100 $ do getLine print $ best pole 42 420 -------------- The sample input file (30k) can be downloaded from http://pikomat.mff.cuni.cz/petr/3-med.in I suspect that the main's variable "pole" (which is a large binary tree of type Predpoc Int) may be built from scratch in each iteration of the replicateM_ loop. Petr From martijn at van.steenbergen.nl Mon Apr 6 14:32:57 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Mon Apr 6 14:20:02 2009 Subject: [Haskell-cafe] cabal haddock and Paths_Xxx Message-ID: <49DA4AD9.80704@van.steenbergen.nl> Hello, cabal generates a Paths_Xxx file for me which I import and use, but cabal haddock doesn't seem to like it much. If I don't specify the generated module at all in my cabal file, cabal haddock generates visible documentation for the module, which is not what I want: the module should stay internal. If I specify it in either Exposed-Modules or Other-Modules, 'cabal configure; cabal haddock' fails with: > cabal: can't find source for Paths_Xxx in ., dist/build/autogen While 'cabal configure; cabal build; cabal haddock' fails with: > cabal: can't find source for module Paths_Xxx Can I have the best of both, i.e. generate docs without problems and use the generated module? Thanks, Martijn. From dons at galois.com Mon Apr 6 14:37:46 2009 From: dons at galois.com (Don Stewart) Date: Mon Apr 6 14:25:48 2009 Subject: [Haskell-cafe] Ghc: -O harmful? In-Reply-To: <20090406181537.GA14402@pikomat.mff.cuni.cz> References: <20090406181537.GA14402@pikomat.mff.cuni.cz> Message-ID: <20090406183746.GA3248@whirlpool.galois.com> -fno-state-hack? xofon: > > Hello all, > > I have a haskell program that runs an order of magnitude slower > when compiled with optimisations turned on. This happens on 6.8.2 > as well as 6.10.1: > > > petr@r4at184:/tmp[1]% ghc --make -fforce-recomp -o out buga.hs > [1 of 1] Compiling Main ( buga.hs, buga.o ) > Linking out ... > petr@r4at184:/tmp% time ./out < 3-med.in >|/dev/null > ./out < 3-med.in >| /dev/null 0,03s user 0,00s system 99% cpu 0,038 total > > petr@r4at184:/tmp% ghc --make -fforce-recomp -o out buga.hs -O > [1 of 1] Compiling Main ( buga.hs, buga.o ) > Linking out ... > petr@r4at184:/tmp% time ./out < 3-med.in >|/dev/null > ./out < 3-med.in >| /dev/null 0,99s user 0,01s system 99% cpu 1,001 total > > petr@r4at184:/tmp[1]% ghc --make -fforce-recomp -o out buga.hs -O2 > [1 of 1] Compiling Main ( buga.hs, buga.o ) > Linking out ... > petr@r4at184:/tmp% time ./out < 3-med.in >|/dev/null > ./out < 3-med.in >| /dev/null 0,99s user 0,01s system 99% cpu 1,004 total > > petr@r4at184:/tmp% ghc --version > The Glorious Glasgow Haskell Compilation System, version 6.8.2 > > > psxxxxxx:/tmp$ ghc --make -fforce-recomp -o out buga.hs > [1 of 1] Compiling Main ( buga.hs, buga.o ) > Linking out ... > psxxxxxx:/tmp$ time ./out < 3-med.in >|/dev/null > real 0m0.028s > user 0m0.011s > sys 0m0.007s > > psxxxxxx:/tmp$ ghc --make -fforce-recomp -o out buga.hs -O > [1 of 1] Compiling Main ( buga.hs, buga.o ) > Linking out ... > psxxxxxx:/tmp$ time ./out < 3-med.in >|/dev/null > real 0m0.252s > user 0m0.225s > sys 0m0.011s > > psxxxxxx:/tmp$ ghc --make -fforce-recomp -o out buga.hs -O2 > [1 of 1] Compiling Main ( buga.hs, buga.o ) > Linking out ... > Vazeny pane, cekam na Vase rozkazy. > psxxxxxx:/tmp$ time ./out < 3-med.in >|/dev/null > real 0m0.239s > user 0m0.225s > sys 0m0.010s > > psxxxxxx:/tmp$ ghc --version > The Glorious Glasgow Haskell Compilation System, version 6.10.1 > > > The GHC documentation states that > > > -O2: > > Means: "Apply every non-dangerous optimisation, even if it means > > significantly longer compile times." The avoided "dangerous" > > optimisations are those that can make runtime or space worse if > > you're unlucky. They are normally turned on or off individually. > > If I understand this correctly, the dangerous optimisations should not > be performed with -O. Am I doing anything wrong? Am I hitting a bug > in GHC optimiser? A known one? > > > The program source: > > -------------- > petr@r4at184:/tmp$ cat buga.hs > {-# LANGUAGE FlexibleContexts #-} > > import Control.Monad > import Control.Monad.State > > data Predpoc a = Nic | Kus { delka :: Int, > levy :: Predpoc a, > pravy :: Predpoc a } > deriving Show > > gList i = Kus 1 Nic Nic > > gPredpoc kus1 kus2 = > Kus (delka kus1 + delka kus2) > kus1 kus2 > > > pop :: MonadState [a] m => m a > pop = get >>= \(x:xs) -> put xs >> return x > > mbuild :: MonadState [Int] m => Int -> m (Predpoc Int) > mbuild 1 = gList `liftM` pop > mbuild n = liftM2 gPredpoc (mbuild n1) (mbuild n2) > where n1 = n`div`2 > n2 = n - n1 > > build n li = evalState (mbuild n) li > > best :: Predpoc Int -> Int -> Int -> Int > best kus i j > | i == 1 && j == delka kus > = delka kus > | j <= del1 = best (levy kus) i j > | i > del1 = best (pravy kus) (i-del1) (j-del1) > | otherwise = best (levy kus) i del1 + > best (pravy kus) 1 (j-del1) > where > del1 = delka (levy kus) > > main = do > n <- read `liftM` getLine > pole <- liftM (build n . map read . words) getLine > replicateM_ 100 $ do > getLine > print $ best pole 42 420 > -------------- > > The sample input file (30k) can be downloaded from > http://pikomat.mff.cuni.cz/petr/3-med.in > > I suspect that the main's variable "pole" (which is a large > binary tree of type Predpoc Int) may be built from scratch in each > iteration of the replicateM_ loop. > > Petr > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From claus.reinke at talk21.com Mon Apr 6 14:50:27 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon Apr 6 14:37:37 2009 Subject: [Haskell-cafe] community.haskell.org unreachable? References: Message-ID: <6F4D057FE37E4990B6B532BCCE996A70@cr3lt> > Works for me. The admin address referenced there is support [AT] > community.haskell.org Thanks. Yes, it is working again for me too, now, but had been quite persistently unreachable before, while www.haskell.org was reachable, so I'd be surprised if the the problem was at this end of the connection. If I read the bandwith graph correctly, there was a peak followed by several hours of silence, matched by odd memory usage (though I don't see what the load average is trying to tell us?): http://community.haskell.org/mrtg/daily.html Claus > On Mon, Apr 6, 2009 at 1:32 PM, Claus Reinke wrote: > >> I seem to be having problems reaching anything on that server. >> Does anyone know what is going on, or who to contact? It would >> help if the haskellwiki page >> >> http://www.haskell.org/haskellwiki/Haskell.org_domain >> >> would mention the admin address directly, instead of referring to >> >> http://community.haskell.org/admin/ >> which is also unreachable. >> >> Claus >> >> _______________________________________________ >> 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 MarkoSchuetz at web.de Mon Apr 6 14:50:49 2009 From: MarkoSchuetz at web.de (Marko =?ISO-8859-1?Q?Sch=FCtz?=) Date: Mon Apr 6 14:37:52 2009 Subject: [Haskell-cafe] strange performance issue with takusen 0.8.3 Message-ID: <87d4bp39bq.wl%MarkoSchuetz@web.de> Dear All, I have an application where some simple data extracted from some source files is inserted into a PostgreSQL database. The application uses Takusen and is compiled with GHC 6.8.3. Some (59 in the test data) of the selects take on average 460ms each for a total time for this sample run of 30s. I prepare one select statement at the beginning of the run into which I then bind the specific values for every one of the selects. It does not seem to make a difference whether I do this or whether I just use a new statement for every select. For comparison, I have collected the SQL statements in a file with PREPARE ... and DEALLOCATE for _every_ select and then run this file through psql. This takes 2s! During the run of the GHC-compiled executable the cpu load goes up. In top I see %CPU of above 72%. Any ideas that might enlighten are welcome. Best regards, Marko -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 194 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090406/ccbcde38/attachment.bin From noel.kalman at googlemail.com Mon Apr 6 14:57:10 2009 From: noel.kalman at googlemail.com (Kalman Noel) Date: Mon Apr 6 14:44:07 2009 Subject: [Haskell-cafe] Re: Numeric Prelude and identifiers (Was: fad 1.0 -- Forward AutomaticDifferentiation library) In-Reply-To: References: <49D87703.5010907@googlemail.com> Message-ID: <49DA5086.7080808@googlemail.com> Henning Thielemann schrieb: > On Sun, 5 Apr 2009, Kalman Noel wrote: >> I'm wondering, too, if the Numeric Prelude could be organized more >> cleanly if we had a fancier module system - does someone have >> sufficient experience with, say, ML-style module systems to tell? > > Are you complaining about the organisation or about the identifiers? If > you mean the former, then what organisation do you propose? I'm not complaining, and I'm not sure what I mean :) I may like a scheme where functions operating on a type or type class live in a module seperate from the type (class) definition, so you could import a specific module to get only, say, (Ring, (*), one, ...). But that would be too tedious in the Haskell hierarchical module system, which is why I was asking about others. > If you mean > the latter ... Many proposals about extended import facilities I saw > were complicated and could simply be avoided using the naming style I use. I'm ready to believe you that the naming style you chose is optimal within the hierarchical module system. Regards, Kalman From nowgate at yahoo.com Mon Apr 6 15:16:13 2009 From: nowgate at yahoo.com (nowgate@yahoo.com) Date: Mon Apr 6 15:03:07 2009 Subject: [Haskell-cafe] Combining sequences Message-ID: <970737.66304.qm@web31105.mail.mud.yahoo.com> Hi Daniel, Thanks, but apparently no go. This isn't critical, as I already have a function that will combine two sequences. Michael ============= Michael [michael@localhost untitled folder]$ cd utility-ht-0.0.4 [michael@localhost utility-ht-0.0.4]$ ls LICENSE? Setup.lhs? src? utility-ht.cabal [michael@localhost utility-ht-0.0.4]$ ./Setup.lhs configure --hugs /usr/bin/env: runhaskell: No such file or directory????? --OOPS! [michael@localhost utility-ht-0.0.4]$ su Password: [root@localhost utility-ht-0.0.4]# ./Setup.lhs configure --hugs /usr/bin/env: runhaskell: No such file or directory [root@localhost utility-ht-0.0.4]# --- On Mon, 4/6/09, Daniel Fischer wrote: From: Daniel Fischer Subject: Re: [Haskell-cafe] Combining sequences To: haskell-cafe@haskell.org Cc: "michael rice" Date: Monday, April 6, 2009, 12:04 PM Am Montag 06 April 2009 17:12:42 schrieb michael rice: > I downloaded it and it appears more complicated than just adding files to a > directory. There's a setup and a build, and no assurances it will work with > Hugs. > > I think I'll wait for more information. > > Michael > Try installing it with Cabal: ./Setup.lhs configure --hugs if that doesn't say otherwise, chances are that it will work, so try ./Setup.lhs build sudo ./Setup.lhs install If it doesn't work, you can copy the code from Data.List.HT -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090406/8bd77de7/attachment.htm From duane.johnson at gmail.com Mon Apr 6 15:51:45 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Mon Apr 6 15:39:15 2009 Subject: [Haskell-cafe] Re: Linking hmatrix without LAPACK In-Reply-To: <49DA4867.70707@um.es> References: <20090406054838.GD31757@whirlpool.galois.com> <9367B0CF-7C32-4B3A-AB08-BAB4B7BA5F2E@gmail.com> <49DA4867.70707@um.es> Message-ID: Hi Alberto! Thanks for your informative reply. I looked in to the versions of liblapack on my system... it turns out there is indeed a liblapack.dylib that (apparently) comes with Mac OS X. How to tell ghc to link to that instead is still in question. I can run simple matrix operations in ghci as you suggest (in fact, "runTests 20" succeeds wonderfully); however, I created the following simple module (test.hs) and it fails: > module Main where > import Numeric.LinearAlgebra.Tests > > main = do > runTests 20 I tried plain "--make", as well as the "-dynamic" flag, and then I tried the "-L" shell argument to point to the /usr/lib dir where the liblapack.dylib library is located: > $ ghc --make test.hs -o test > [1 of 1] Compiling Main ( test.hs, test.o ) > Linking test ... > ld: in /opt/local/lib/liblapack.a( > ), not a valid archive member > collect2: ld returned 1 exit status > > $ ghc --make -dynamic test.hs -o test > Linking test ... > ld: library not found for -lHShmatrix-0.5.0.1-ghc6.10.1 > collect2: ld returned 1 exit status > > $ ghc --make -L/usr/lib test.hs -o test > Linking test ... > Undefined symbols: > "_zgemm_", referenced from: > _multiplyC in libHShmatrix-0.5.0.1.a(lapack-aux.o) > "_zgesv_", referenced from: > _linearSolveC_l in libHShmatrix-0.5.0.1.a(lapack-aux.o) > "_zpotrf_", referenced from: > _chol_l_H in libHShmatrix-0.5.0.1.a(lapack-aux.o) > "_dpotrf_", referenced from: > _chol_l_S in libHShmatrix-0.5.0.1.a(lapack-aux.o) > "_dgemm_", referenced from: > _multiplyR in libHShmatrix-0.5.0.1.a(lapack-aux.o) > "_dgesv_", referenced from: > _linearSolveR_l in libHShmatrix-0.5.0.1.a(lapack-aux.o) > "_zgetrf_", referenced from: > _lu_l_C in libHShmatrix-0.5.0.1.a(lapack-aux.o) > "_zgetrs_", referenced from: > _luS_l_C in libHShmatrix-0.5.0.1.a(lapack-aux.o) > "_dgetrf_", referenced from: > _lu_l_R in libHShmatrix-0.5.0.1.a(lapack-aux.o) > "_dgetrs_", referenced from: > _luS_l_R in libHShmatrix-0.5.0.1.a(lapack-aux.o) > ld: symbol(s) not found > collect2: ld returned 1 exit status I attempted to install hmatrix with the "-faccelerate" option, but when using "ghc --make" for the above test code, I received the same error messages noted previously. Is there a way to tell if the "- faccelerate" was acknowledged and that the alternate library was used? One more clue: I took a look at the directions found on the page at mit.edu/harold... it turns out I had installed atlas/lapack unnecessarily. That explains the mysterious "not a valid archive member" message. Nevertheless, I am still befuddled by the "Undefined symbols" above. ghc --make is still unable to figure out where the liblapack.dylib file is in spite of ghci's success. Any suggestions from here? Regards, Duane Johnson P.S. I'm CC'ing the Haskell Cafe so that our journey so far can be archived. On Apr 6, 2009, at 12:22 PM, Alberto Ruiz wrote: > Hi Duane, > > I have seen your messages to Haskell Cafe but I am still thinking > about the problem... :) > > Can you run simple matrix operations in ghci? > > $ ghci > Prelude> import Numeric.LinearAlgebra > Prelude Numeric.LinearAlgebra> let m = (2><2) [1..4 :: Double] > > (...Loading packages...) > > Prelude Numeric.LinearAlgebra> m <> m > (2><2) > [ 7.0, 10.0 > , 15.0, 22.0 ] > > If so, some version of blas/lapack can be found in your system, it > is strange that ghc --make doesn't find them. > > Perhaps the problem is that dynamic libraries like liblapack.so are > required instead of static ones like liblapack.a. (In ubuntu they > are in the "devel" packages for blas/lapack.) > > I am not familiar with Mac OS, but if you can use the "accelerate > framework" in your system you may try the -faccelerate configuration > option for hmatrix: > > cabal install hmatrix -faccelerate > > See also the following page (steps 3-8). It explains how to install > hmatrix on Mac OS (required for other project). > > http://mit.edu/harold/Public/easyVisionNotes.html > > Please let me know if any of these methods works for you. > > Thanks for your message, > > Alberto > > > > Duane Johnson wrote: >> Hi Alberto, >> I've been very happy with hmatrix as I've used it in ghci, and I >> should first thank you for making such an excellent package. I've >> had trouble when linking it using "ghc --make" on Mac OS >> (Leopard). Below are two messages I sent to the Haskell Cafe >> mailing list. Do you have any insight into either question: >> 1. How to link without atlas/lapack >> 2. What the "not a valid archive member" message means? >> Thank you! >> Duane Johnson >> Brigham Young University >> Provo, UT >> Begin forwarded message: >>> From: Don Stewart >>> Date: April 5, 2009 11:48:38 PM MDT >>> To: Duane Johnson >>> Subject: Re: [Haskell-cafe] Re: Linking hmatrix without LAPACK >>> >>> It would be best to contact the author of hmatrix directly. >>> >>> >>> duane.johnson: >>>> On a related note, I've installed Atlas, and I get the following >>>> error >>>> when linking: >>>> >>>>> Linking SilkwormGame ... >>>>> ld: in /opt/local/lib/liblapack.a(), not a valid archive member >>>>> collect2: ld returned 1 exit status >>>> >>>> How would I go about diagnosing this? I've never seen an ld >>>> error like >>>> that. >>>> >>>> Thanks again! >>>> Duane Johnson >>>> >>>> >>>> On Apr 5, 2009, at 11:02 PM, Duane Johnson wrote: >>>> >>>>> I'm curious if there is a quick fix to this. I installed GLS and >>>>> hmatrix, and it runs wonderfully together in ghci. When I run >>>>> ghc -- >>>>> make, however, I run into the following link dependency: >>>>> >>>>> Linking SilkwormGame ... >>>>> Undefined symbols: >>>>> "_dgemm_", referenced from: >>>>> _multiplyR in libHShmatrix-0.5.0.1.a(lapack-aux.o) >>>>> "_dgesv_", referenced from: >>>>> _linearSolveR_l in libHShmatrix-0.5.0.1.a(lapack-aux.o) >>>>> ... etc >>>>> >>>>> Is there a way to tell ghc to not link these? Or am I making a >>>>> poor >>>>> assumption that if my code runs in ghci, it does not need LAPACK? >>>>> >>>>> Thanks, >>>>> Duane Johnson >>>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe From lemming at henning-thielemann.de Mon Apr 6 15:53:04 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Apr 6 15:41:12 2009 Subject: [Haskell-cafe] Combining sequences In-Reply-To: <970737.66304.qm@web31105.mail.mud.yahoo.com> References: <970737.66304.qm@web31105.mail.mud.yahoo.com> Message-ID: On Mon, 6 Apr 2009, nowgate@yahoo.com wrote: > Michael > [michael@localhost untitled folder]$ cd utility-ht-0.0.4 > [michael@localhost utility-ht-0.0.4]$ ls > LICENSE? Setup.lhs? src? utility-ht.cabal > [michael@localhost utility-ht-0.0.4]$ ./Setup.lhs configure --hugs > /usr/bin/env: runhaskell: No such file or directory????? --OOPS! > [michael@localhost utility-ht-0.0.4]$ su > Password: > [root@localhost utility-ht-0.0.4]# ./Setup.lhs configure --hugs > /usr/bin/env: runhaskell: No such file or directory > [root@localhost utility-ht-0.0.4]# $ runhugs Setup.lhs configure --hugs might work From duane.johnson at gmail.com Mon Apr 6 15:58:13 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Mon Apr 6 15:45:44 2009 Subject: [Haskell-cafe] ghc --make unable to find dynamic library, but ghci can Message-ID: <4A1BC6DC-D6D8-4468-8B04-830DF5FD8663@gmail.com> Hi Haskellers, This is related to my previous message, "Linking hmatrix without LAPACK". Apparently, ghc --make is not finding the lapack.dylib library where ghci is (dylib is Mac OS X specific) . For example, the following test module does NOT work when compiled with ghc --make: > module Main where > import Numeric.LinearAlgebra.Tests > > main = do > runTests 20 But the following runs fine in ghci: > $ ghci > GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help > [...loading packages...] > Prelude> :m Numeric.LinearAlgebra.Tests > Prelude Numeric.LinearAlgebra.Tests> runTests 20 > [...loading packages...] > ------ mult > OK, passed 100 tests. > OK, passed 100 tests. > [...more tests pass...] Can anyone point me in the right direction? Thank you, Duane Johnson From lemming at henning-thielemann.de Mon Apr 6 16:05:21 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Apr 6 15:52:17 2009 Subject: [Haskell-cafe] Combining sequences In-Reply-To: <534983.77638.qm@web31108.mail.mud.yahoo.com> References: <534983.77638.qm@web31108.mail.mud.yahoo.com> Message-ID: On Sun, 5 Apr 2009, michael rice wrote: > Thanks. It looks like mergeBy will do the job, but is it available in Hugs? The package is Haskell98 and needs no further package, thus it should work with almost every Haskell system. From daniel.is.fischer at web.de Mon Apr 6 16:30:23 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Apr 6 16:17:27 2009 Subject: [Haskell-cafe] Ghc: -O harmful? In-Reply-To: <20090406183746.GA3248@whirlpool.galois.com> References: <20090406181537.GA14402@pikomat.mff.cuni.cz> <20090406183746.GA3248@whirlpool.galois.com> Message-ID: <200904062230.23844.daniel.is.fischer@web.de> Am Montag 06 April 2009 20:37:46 schrieb Don Stewart: > -fno-state-hack? That, or {-# LANGUAGE BangPatterns #-} main = do ? n <- read `liftM` getLine ? !pole <- liftM (build n . map read . words) getLine ? replicateM_ 100 $ do ? ? getLine ? ? print $ best pole 42 420 if the state-hack is beneficial in other places of the programme. The bang on pole tells GHC to calculate it only once, not inline it. From deduktionstheorem at web.de Mon Apr 6 16:37:21 2009 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Mon Apr 6 16:24:19 2009 Subject: [Haskell-cafe] Monad transformer to consume a list Message-ID: <49DA6801.1030209@web.de> Hello, is there a monad transformer to consume an input list? I've got external events "streaming into the monad" that are consumed on demand and I'm not sure if there's something better than a StateT. //Stephan -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From lemming at henning-thielemann.de Mon Apr 6 16:42:35 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Apr 6 16:29:30 2009 Subject: [Haskell-cafe] Monad transformer to consume a list In-Reply-To: <49DA6801.1030209@web.de> References: <49DA6801.1030209@web.de> Message-ID: On Mon, 6 Apr 2009, Stephan Friedrichs wrote: > Hello, > > is there a monad transformer to consume an input list? I've got external > events "streaming into the monad" that are consumed on demand and I'm > not sure if there's something better than a StateT. I wondered that, too. I wondered whether there is something inverse to Writer, and Reader is appearently not the answer. Now I think, that State is indeed the way to go to consume a list. Even better is StateT List Maybe: next :: StateT [a] Maybe a next = StateT Data.List.HT.viewL -- see utility-ht package From bugfact at gmail.com Mon Apr 6 17:34:58 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Apr 6 17:21:56 2009 Subject: [Haskell-cafe] GHC accepts libraries compiled with Visual Studio? Message-ID: To my surprise GHC seems to accept .lib files (produced by e.g. Visual Studio on Windows) directly; I don't need to convert these to .a files using e.g. reimp That's really cool. Is this by design or did I miss something? The manual does not seem to mention this. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090406/72e5f77a/attachment.htm From pwberry at gmail.com Mon Apr 6 17:36:45 2009 From: pwberry at gmail.com (Peter Berry) Date: Mon Apr 6 17:23:40 2009 Subject: [Haskell-cafe] Strange type error with associated type synonyms Message-ID: <646230a00904061436x41af1055se39e8892eb4e3083@mail.gmail.com> > {-# LANGUAGE TypeFamilies, TypeSynonymInstances, ScopedTypeVariables #-} The following is a class of memo tries indexed by d: > class Fun d where > type Memo d :: * -> * > abst :: (d -> a) -> Memo d a > appl :: Memo d a -> (d -> a) > -- Law: abst . appl = id > -- Law: appl . abst = id (denotationally) Any such type Memo d is naturally a functor: > memo_fmap f x = abst (f . appl x) The type of memo_fmap (as given by ghci) is (Fun d) => (a -> c) -> Memo d a -> Memo d c. (Obviously this would also be the type of fmap for Memo d, so we could declare a Functor instance in principle.) If we add this signature: > memo_fmap' :: Fun d => (a -> b) -> Memo d a -> Memo d b > memo_fmap' f x = abst (f . appl x) it doesn't type check: TypeSynonymTest.hs:14:17: Couldn't match expected type `Memo d1 b' against inferred type `Memo d b' In the expression: abst (f . appl x) In the definition of `memo_fmap'': memo_fmap' f x = abst (f . appl x) TypeSynonymTest.hs:14:32: Couldn't match expected type `Memo d a' against inferred type `Memo d1 a' In the first argument of `appl', namely `x' In the second argument of `(.)', namely `appl x' In the first argument of `abst', namely `(f . appl x)' Failed, modules loaded: none. As I understand it, the type checker's thought process should be along these lines: 1) the type signature dictates that x has type Memo d a. 2) appl has type Memo d1 a -> d1 -> a for some d1. 3) we apply appl to x, so Memo d1 a = Memo d a. unify d = d1 But for some reason, step 3 fails. If we annotate appl with the correct type (using scoped type variables), it type checks: > -- thanks to mmorrow on #haskell for this > memo_fmap'' :: forall a b d. Fun d => (a -> b) -> Memo d a -> Memo d b > memo_fmap'' f x = abst (f . (appl :: Memo d a -> d -> a) x) My ghc is 6.8.2, but apparently this happens in 6.10 as well. -- Peter Berry Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html From lemming at henning-thielemann.de Mon Apr 6 17:53:47 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Apr 6 17:40:43 2009 Subject: [Haskell-cafe] Re: Numeric Prelude and identifiers In-Reply-To: <49DA5086.7080808@googlemail.com> References: <49D87703.5010907@googlemail.com> <49DA5086.7080808@googlemail.com> Message-ID: On Mon, 6 Apr 2009, Kalman Noel wrote: > I'm not complaining, and I'm not sure what I mean :) I may like a scheme > where functions operating on a type or type class live in a module > seperate from the type (class) definition, so you could import a > specific module to get only, say, (Ring, (*), one, ...). But that would > be too tedious in the Haskell hierarchical module system, which is why I > was asking about others. It was precisely my goal to bundle the type with the functions that operate on it. Why do you want to separate them? From xj2106 at columbia.edu Mon Apr 6 17:43:09 2009 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Mon Apr 6 17:46:50 2009 Subject: [Haskell-cafe] Volunteer Message-ID: <878wmdtpcz.fsf@columbia.edu> Hi, I learned that no one is doing generic unix source tarball, right now, and thought I might help to get it start. I have decent skills on Makefile, but knows very little about auto-tools. I can only spent a few hours every week on it, because I don't have too much spare time as a PhD student. But I still want to help, since it is quite important for Haskell to distribute as widely as possible. So, how should I start? I learned that ghc supports quite a lot of platforms in its tier2 support list through community supporters. I'm not sure what is the most convenient way to combine these into a generic source tarball. And what do we use to bootstrap ghc? Some pre-compiled binary? I'm not sure how I should start. Any insight? Best, Xiao-Yong P.S. I tried to send to haskell-platform, but got rejected. What's going on? ---------- begin error message ---------- ... while talking to community.haskell.org.: >>> DATA <<< 550 Unrouteable address 550 5.1.1 ... User unknown <<< 503 valid RCPT command must precede DATA ---------- end error message ---------- -- c/* __o/* <\ * (__ */\ < From duane.johnson at gmail.com Mon Apr 6 18:19:49 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Mon Apr 6 18:06:56 2009 Subject: [Haskell-cafe] Re: Linking hmatrix without LAPACK In-Reply-To: References: <20090406054838.GD31757@whirlpool.galois.com> <9367B0CF-7C32-4B3A-AB08-BAB4B7BA5F2E@gmail.com> <49DA4867.70707@um.es> Message-ID: <415ED70A-0237-4CB6-B9D3-46DC3533BD5E@gmail.com> FYI, the following solution worked on Mac OS X (Leopard): > ghc -o SilkwormGame --make -framework Accelerate Main.hs The key addition is "-framework Accelerate". Thus, on Mac OS X, it is only necessary to install the "gls" library via macports. Atlas/ LAPACK/BLAS etc. come with the operating system framework above. Also, I had to replace a DYLD_LIBRARY_PATH assignment in my .profile with DYLD_FALLBACK_LIBRARY_PATH: > export DYLD_LIBRARY_PATH=/opt/local/lib:/usr/local/cuda/lib becomes: > export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib:/usr/local/cuda/lib The above change permitted me to use Apple's libraries by default, and my macports libraries as fallbacks. In particular, when I installed the "atlas" package via macports, it seems to have updated a key "libjpeg.dylib" file, thus causing other headaches. Using the "fallback" method above, the problems went away. Regards, Duane Johnson On Apr 6, 2009, at 1:51 PM, Duane Johnson wrote: > Hi Alberto! > > Thanks for your informative reply. I looked in to the versions of > liblapack on my system... it turns out there is indeed a > liblapack.dylib that (apparently) comes with Mac OS X. How to tell > ghc to link to that instead is still in question. > > I can run simple matrix operations in ghci as you suggest (in fact, > "runTests 20" succeeds wonderfully); however, I created the > following simple module (test.hs) and it fails: > >> module Main where >> import Numeric.LinearAlgebra.Tests >> >> main = do >> runTests 20 > > I tried plain "--make", as well as the "-dynamic" flag, and then I > tried the "-L" shell argument to point to the /usr/lib dir where the > liblapack.dylib library is located: > > >> $ ghc --make test.hs -o test >> [1 of 1] Compiling Main ( test.hs, test.o ) >> Linking test ... >> ld: in /opt/local/lib/liblapack.a( >> ), not a valid archive member >> collect2: ld returned 1 exit status >> >> $ ghc --make -dynamic test.hs -o test >> Linking test ... >> ld: library not found for -lHShmatrix-0.5.0.1-ghc6.10.1 >> collect2: ld returned 1 exit status >> >> $ ghc --make -L/usr/lib test.hs -o test >> Linking test ... >> Undefined symbols: >> "_zgemm_", referenced from: >> _multiplyC in libHShmatrix-0.5.0.1.a(lapack-aux.o) >> "_zgesv_", referenced from: >> _linearSolveC_l in libHShmatrix-0.5.0.1.a(lapack-aux.o) >> "_zpotrf_", referenced from: >> _chol_l_H in libHShmatrix-0.5.0.1.a(lapack-aux.o) >> "_dpotrf_", referenced from: >> _chol_l_S in libHShmatrix-0.5.0.1.a(lapack-aux.o) >> "_dgemm_", referenced from: >> _multiplyR in libHShmatrix-0.5.0.1.a(lapack-aux.o) >> "_dgesv_", referenced from: >> _linearSolveR_l in libHShmatrix-0.5.0.1.a(lapack-aux.o) >> "_zgetrf_", referenced from: >> _lu_l_C in libHShmatrix-0.5.0.1.a(lapack-aux.o) >> "_zgetrs_", referenced from: >> _luS_l_C in libHShmatrix-0.5.0.1.a(lapack-aux.o) >> "_dgetrf_", referenced from: >> _lu_l_R in libHShmatrix-0.5.0.1.a(lapack-aux.o) >> "_dgetrs_", referenced from: >> _luS_l_R in libHShmatrix-0.5.0.1.a(lapack-aux.o) >> ld: symbol(s) not found >> collect2: ld returned 1 exit status > > > I attempted to install hmatrix with the "-faccelerate" option, but > when using "ghc --make" for the above test code, I received the same > error messages noted previously. Is there a way to tell if the "- > faccelerate" was acknowledged and that the alternate library was used? > > One more clue: I took a look at the directions found on the page at > mit.edu/harold... it turns out I had installed atlas/lapack > unnecessarily. That explains the mysterious "not a valid archive > member" message. Nevertheless, I am still befuddled by the > "Undefined symbols" above. ghc --make is still unable to figure out > where the liblapack.dylib file is in spite of ghci's success. > > Any suggestions from here? > > Regards, > Duane Johnson > > P.S. I'm CC'ing the Haskell Cafe so that our journey so far can be > archived. > > > > On Apr 6, 2009, at 12:22 PM, Alberto Ruiz wrote: > >> Hi Duane, >> >> I have seen your messages to Haskell Cafe but I am still thinking >> about the problem... :) >> >> Can you run simple matrix operations in ghci? >> >> $ ghci >> Prelude> import Numeric.LinearAlgebra >> Prelude Numeric.LinearAlgebra> let m = (2><2) [1..4 :: Double] >> >> (...Loading packages...) >> >> Prelude Numeric.LinearAlgebra> m <> m >> (2><2) >> [ 7.0, 10.0 >> , 15.0, 22.0 ] >> >> If so, some version of blas/lapack can be found in your system, it >> is strange that ghc --make doesn't find them. >> >> Perhaps the problem is that dynamic libraries like liblapack.so are >> required instead of static ones like liblapack.a. (In ubuntu they >> are in the "devel" packages for blas/lapack.) >> >> I am not familiar with Mac OS, but if you can use the "accelerate >> framework" in your system you may try the -faccelerate >> configuration option for hmatrix: >> >> cabal install hmatrix -faccelerate >> >> See also the following page (steps 3-8). It explains how to install >> hmatrix on Mac OS (required for other project). >> >> http://mit.edu/harold/Public/easyVisionNotes.html >> >> Please let me know if any of these methods works for you. >> >> Thanks for your message, >> >> Alberto >> >> >> >> Duane Johnson wrote: >>> Hi Alberto, >>> I've been very happy with hmatrix as I've used it in ghci, and I >>> should first thank you for making such an excellent package. I've >>> had trouble when linking it using "ghc --make" on Mac OS >>> (Leopard). Below are two messages I sent to the Haskell Cafe >>> mailing list. Do you have any insight into either question: >>> 1. How to link without atlas/lapack >>> 2. What the "not a valid archive member" message means? >>> Thank you! >>> Duane Johnson >>> Brigham Young University >>> Provo, UT >>> Begin forwarded message: >>>> From: Don Stewart >>>> Date: April 5, 2009 11:48:38 PM MDT >>>> To: Duane Johnson >>>> Subject: Re: [Haskell-cafe] Re: Linking hmatrix without LAPACK >>>> >>>> It would be best to contact the author of hmatrix directly. >>>> >>>> >>>> duane.johnson: >>>>> On a related note, I've installed Atlas, and I get the following >>>>> error >>>>> when linking: >>>>> >>>>>> Linking SilkwormGame ... >>>>>> ld: in /opt/local/lib/liblapack.a(), not a valid archive member >>>>>> collect2: ld returned 1 exit status >>>>> >>>>> How would I go about diagnosing this? I've never seen an ld >>>>> error like >>>>> that. >>>>> >>>>> Thanks again! >>>>> Duane Johnson >>>>> >>>>> >>>>> On Apr 5, 2009, at 11:02 PM, Duane Johnson wrote: >>>>> >>>>>> I'm curious if there is a quick fix to this. I installed GLS and >>>>>> hmatrix, and it runs wonderfully together in ghci. When I run >>>>>> ghc -- >>>>>> make, however, I run into the following link dependency: >>>>>> >>>>>> Linking SilkwormGame ... >>>>>> Undefined symbols: >>>>>> "_dgemm_", referenced from: >>>>>> _multiplyR in libHShmatrix-0.5.0.1.a(lapack-aux.o) >>>>>> "_dgesv_", referenced from: >>>>>> _linearSolveR_l in libHShmatrix-0.5.0.1.a(lapack-aux.o) >>>>>> ... etc >>>>>> >>>>>> Is there a way to tell ghc to not link these? Or am I making a >>>>>> poor >>>>>> assumption that if my code runs in ghci, it does not need LAPACK? >>>>>> >>>>>> Thanks, >>>>>> Duane Johnson >>>>> >>>>> _______________________________________________ >>>>> Haskell-Cafe mailing list >>>>> Haskell-Cafe@haskell.org >>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe > From jefferson.r.heard at gmail.com Mon Apr 6 18:23:28 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Mon Apr 6 18:10:22 2009 Subject: [Haskell-cafe] GHC accepts libraries compiled with Visual Studio? In-Reply-To: References: Message-ID: <4165d3a70904061523p27e41e6cjc08569417aacf9b9@mail.gmail.com> I've noticed this before. I in fact have really only tried FTGL with VC compiled lib files... On Mon, Apr 6, 2009 at 5:34 PM, Peter Verswyvelen wrote: > To my surprise GHC seems to accept .lib files (produced by e.g. Visual > Studio on Windows) directly; I don't need to convert these to .a files using > e.g. reimp > That's really cool. Is this by design or did I miss something? The manual > does not seem to mention this. > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From jefferson.r.heard at gmail.com Mon Apr 6 18:53:15 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Mon Apr 6 18:40:26 2009 Subject: [Haskell-cafe] Configuring cabal dependencies at install-time Message-ID: <4165d3a70904061553o7f3032c8x34ff1f25423fb64a@mail.gmail.com> Is there a way to do something like autoconf and configure dependencies at install time? Building buster, I keep adding dependencies and I'd like to keep that down to a minimum without the annoyance of littering Hackage with dozens of packages. For instance, today I developed an HTTP behaviour and that of course requires network and http, which were previously not required. I'm about to put together a haxr XML-RPC behaviour as well, and that of course would add that much more to the dependency list. HaXml, haxr, and haxr-th most likely. so... any way to do that short of making a bunch of separate packages with one or two modules apiece? Otherwise I'm thinking of breaking things up into buster, buster-ui, buster-network, buster-console, and buster-graphics to start and adding more as I continue along. -- Jeff From ryani.spam at gmail.com Mon Apr 6 19:46:14 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Apr 6 19:33:08 2009 Subject: [Haskell-cafe] Infix tuple comma query (,) In-Reply-To: <200904061808.18032.daniel.is.fischer@web.de> References: <3CDFB8AFEA98E34CB599475AB11589C81C768A@EX2.ad.dcs.gla.ac.uk> <200904061808.18032.daniel.is.fischer@web.de> Message-ID: <2f9b2d30904061646h35c0becbt1041392a2aeafc52@mail.gmail.com> The prefix notation for > \a b c -> (a,b,c) is (,,) Without the parentheses, it's not immediately clear whether > foo $ a,b means > foo (a,b) or > foo (\c -> (a,b,c)) or some other, bigger tuple size. Anyways, it's just syntax :) -- ryan On Mon, Apr 6, 2009 at 9:08 AM, Daniel Fischer wrote: > Am Montag 06 April 2009 17:53:24 schrieb Paul Keir: >> module Main where >> >> >> >> data (:%^&) a b = a :%^& b ? ?deriving (Show) >> >> >> >> main = do >> >> ? print $ 18 :%^& (Just 99) >> >> ? print $ (,) 9 10 >> >> ? print $ 9 , 10 >> >> >> >> The last line in the code above causes a compile error. >> >> Why does infix use of the comma (tuple constructor?) function fail >> without brackets? >> > > Tuples are special baked-in syntax. The parentheses are part of the tuple > constructor(s). > It may be confusing you that you can use it prefix as well as "aroundfix". > >> >> >> Thanks, >> >> Paul > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From MarkoSchuetz at web.de Mon Apr 6 19:57:46 2009 From: MarkoSchuetz at web.de (Marko =?ISO-8859-1?Q?Sch=FCtz?=) Date: Mon Apr 6 19:44:55 2009 Subject: [Haskell-cafe] Volunteer In-Reply-To: <878wmdtpcz.fsf@columbia.edu> References: <878wmdtpcz.fsf@columbia.edu> Message-ID: <87bpr92v45.wl%MarkoSchuetz@web.de> Dear Xiao-Yong, thank you very much for your willingness to help. I would suggest you look into some of the builds for various platforms as you mentioned. One infrastructure I find particularly interesting is pkgsrc (www.pkgsrc.org) which can be used to effortlessly build numerous packages from source on various OSs and platforms. The approach taken there for building GHC is to provide pre-compiled C sources of an early GHC version, that is then used to bootstrap a more recent version. Unfortunately, the GHC package in pkgsrc is currently limited to i386 only. As far as I understand this limitation is only due to the fact that the maintainer only generated the intermediate C sources for i386 and I would think a similar approach should work with other platforms. Take all this with a lot of salt: I have only looked into these matters cursorily, but it's where I would start looking deeper... Good luck and best regards, Marko At Mon, 06 Apr 2009 17:43:09 -0400, Xiao-Yong Jin wrote: > > Hi, > > I learned that no one is doing generic unix source tarball, > right now, and thought I might help to get it start. I have > decent skills on Makefile, but knows very little about > auto-tools. I can only spent a few hours every week on it, > because I don't have too much spare time as a PhD student. > But I still want to help, since it is quite important for > Haskell to distribute as widely as possible. > > So, how should I start? I learned that ghc supports quite a > lot of platforms in its tier2 support list through community > supporters. I'm not sure what is the most convenient way to > combine these into a generic source tarball. And what do we > use to bootstrap ghc? Some pre-compiled binary? > > I'm not sure how I should start. Any insight? > > Best, > Xiao-Yong > > P.S. I tried to send to haskell-platform, but got rejected. What's > going on? > > ---------- begin error message ---------- > ... while talking to community.haskell.org.: > >>> DATA > <<< 550 Unrouteable address > 550 5.1.1 ... User unknown > <<< 503 valid RCPT command must precede DATA > ---------- end error message ---------- > -- > c/* __o/* > <\ * (__ > */\ < > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 194 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090406/5151f8ba/attachment.bin From ryani.spam at gmail.com Mon Apr 6 20:07:04 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Apr 6 19:53:59 2009 Subject: [Haskell-cafe] Strange type error with associated type synonyms In-Reply-To: <646230a00904061436x41af1055se39e8892eb4e3083@mail.gmail.com> References: <646230a00904061436x41af1055se39e8892eb4e3083@mail.gmail.com> Message-ID: <2f9b2d30904061707v5b37eb73nceb87c7d1bcc50bf@mail.gmail.com> On Mon, Apr 6, 2009 at 2:36 PM, Peter Berry wrote: > As I understand it, the type checker's thought process should be along > these lines: > > 1) the type signature dictates that x has type Memo d a. > 2) appl has type Memo d1 a -> d1 -> a for some d1. > 3) we apply appl to x, so Memo d1 a = Memo d a. unify d = d1 This isn't true, though, and for similar reasons why you can't declare a generic "instance Fun d => Functor (Memo d)". Type synonyms are not injective; you can have two instances that point at the same type: data Unit1 = Unit1 data Unit2 = Unit2 newtype Identity x = Id x unit_abst x f = Id (f x) unit_appl (Id v) _ = v instance Fun Unit1 where type Memo Unit1 = Identity abst = unit_abst Unit1 appl = unit_appl instance Fun Unit2 where type Memo Unit2 = Identity abst = unit_abst Unit2 appl = unit_appl Now, Memo Unit1 a = Identity a = Memo Unit2 a, but that does not give us that Unit1 = Unit2. In fact, memo_fmap' is ambiguous; what should this application do? memo_fmap' id (Id ()) Should it look at the instance for Unit1, or Unit2, or some other instance we haven't given yet? You can use a data family instead, and then you get the property you want; if you make Memo a data family, then Memo d1 = Memo d2 does indeed give you d1 = d2. You can still use other types in your instances, just use "newtype instance Memo Unit1 a = MemoUnit1 (Identity a)" and add the appropriate newtype wrappers and unwrappers. > But for some reason, step 3 fails. If we annotate appl with the > correct type (using scoped type variables), it type checks: > >> -- thanks to mmorrow on #haskell for this >> memo_fmap'' :: forall a b d. Fun d => (a -> b) -> Memo d a -> Memo d b >> memo_fmap'' f x = abst (f . (appl :: Memo d a -> d -> a) x) Right, because now you have constrained appl ahead of time, passing in the correct type, instead of hoping the compiler can guess how you meant to use "appl". I don't know if this function is callable, though; at the very least you need to annotate its call site to get the proper instance passed through. This is somewhat solvable with a proxy element to fix the instance of Fun: data Proxy d = Proxy memo_fmap_nonamb :: Fun d => Proxy d -> (a -> b) -> Memo d a -> Memo d b memo_fmap_nonamb _ f x = abst (f . appl x) I don't know if this version compiles without the type annotation; my guess is that it might! But even if it doesn't, once you add the proper annotation it is at least callable: test = memo_fmap_nonamb (Proxy :: Proxy Unit1) id (Id ()) I think, for this problem, data families are a better solution. They also let you write the generic Functor instance. -- ryan From chak at cse.unsw.edu.au Mon Apr 6 20:39:55 2009 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Mon Apr 6 20:26:52 2009 Subject: [Haskell-cafe] Strange type error with associated type synonyms In-Reply-To: <646230a00904061436x41af1055se39e8892eb4e3083@mail.gmail.com> References: <646230a00904061436x41af1055se39e8892eb4e3083@mail.gmail.com> Message-ID: <4580278B-D5B6-4A4E-9233-415B57F60A3E@cse.unsw.edu.au> Peter Berry: >> {-# LANGUAGE TypeFamilies, TypeSynonymInstances, >> ScopedTypeVariables #-} > > The following is a class of memo tries indexed by d: > >> class Fun d where >> type Memo d :: * -> * >> abst :: (d -> a) -> Memo d a >> appl :: Memo d a -> (d -> a) >> -- Law: abst . appl = id >> -- Law: appl . abst = id (denotationally) > > Any such type Memo d is naturally a functor: > >> memo_fmap f x = abst (f . appl x) > > The type of memo_fmap (as given by ghci) is (Fun d) => (a -> c) -> > Memo d a -> Memo d c. (Obviously this would also be the type of fmap > for Memo d, so we could declare a Functor instance in principle.) If > we add this signature: > >> memo_fmap' :: Fun d => (a -> b) -> Memo d a -> Memo d b >> memo_fmap' f x = abst (f . appl x) > > it doesn't type check: > > TypeSynonymTest.hs:14:17: > Couldn't match expected type `Memo d1 b' > against inferred type `Memo d b' > In the expression: abst (f . appl x) > In the definition of `memo_fmap'': > memo_fmap' f x = abst (f . appl x) > > TypeSynonymTest.hs:14:32: > Couldn't match expected type `Memo d a' > against inferred type `Memo d1 a' > In the first argument of `appl', namely `x' > In the second argument of `(.)', namely `appl x' > In the first argument of `abst', namely `(f . appl x)' > Failed, modules loaded: none. > > As I understand it, the type checker's thought process should be along > these lines: > > 1) the type signature dictates that x has type Memo d a. > 2) appl has type Memo d1 a -> d1 -> a for some d1. > 3) we apply appl to x, so Memo d1 a = Memo d a. unify d = d1 > > But for some reason, step 3 fails. Step 3 is invalid - cf, . More generally, the signature of memo_fmap is ambiguous, and hence, correctly rejected. We need to improve the error message, though. Here is a previous discussion of the subject: http://www.mail-archive.com/haskell-cafe@haskell.org/msg39673.html Manuel From jason.dusek at gmail.com Mon Apr 6 21:19:05 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Mon Apr 6 21:06:01 2009 Subject: [Haskell-cafe] Lazy vs correct IO [Was: A round of golf] In-Reply-To: <20090406042832.36022AE8C@Adric.metnet.fnmoc.navy.mil> References: <42784f260904050722o2432b123ra3418fdc63014b22@mail.gmail.com> <20090406042832.36022AE8C@Adric.metnet.fnmoc.navy.mil> Message-ID: <42784f260904061819u3dc4a2faj11d863f114bfbb70@mail.gmail.com> Is the choice of whether or not to open/close with each chunk read something that we can reasonably hide from the I/O API's user? There is at least one way in which is semantically distinct -- that old trick of opening a tempfile and then unlinking it to hide it. It may be the sort of thing that you do on demand, too -- we have a file handle pool and as we run out of handles we switch to opening/closing. For a single really long read, opening/closing every 4k is just churn; if your doing thousands of long reads at once, though, it can't be helped. -- Jason Dusek From fft1976 at gmail.com Mon Apr 6 23:06:26 2009 From: fft1976 at gmail.com (FFT) Date: Mon Apr 6 22:53:19 2009 Subject: [Haskell-cafe] automatically inserting type declarations Message-ID: I remember hearing about a Haskell mode for Vim, Emacs, Yi or VisualHaskell that inserts type declarations automatically (it's lazier to just check the type than to write it manually), but I can't remember any details. What editor mode / IDE was it? What do most people use with GHC on Linux? I'm more used to Vim than to Emacs. Yi sounds like something I might like. Is it stable enough to solve more problems than it would create? (I hate buggy and broken stuff) From alexander.dunlap at gmail.com Mon Apr 6 23:39:20 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Mon Apr 6 23:26:14 2009 Subject: [Haskell-cafe] Infix tuple comma query (,) In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C81C768A@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C81C768A@EX2.ad.dcs.gla.ac.uk> Message-ID: <57526e770904062039o2800255fvba1c14b6b882b7cc@mail.gmail.com> On Mon, Apr 6, 2009 at 8:53 AM, Paul Keir wrote: > module Main where > > > > data (:%^&) a b = a :%^& b? ??deriving (Show) > > > > main = do > > ? print $ 18 :%^& (Just 99) > > ? print $ (,) 9 10 > > ? print $ 9 , 10 > > > > The last line in the code above causes a compile error. > > Why does infix use of the comma (tuple constructor?) function fail without > brackets? > > > > Thanks, > > Paul > When I want a lighter syntax for pairs (when doing a long list of them, e.g.), I often define (&) :: a -> b -> (a,b) a & b = (a,b) and then you can indeed write print $ 1 & 2 (assuming you get precedence right). Alex From nonowarn at gmail.com Tue Apr 7 00:11:09 2009 From: nonowarn at gmail.com (Yusaku Hashimoto) Date: Mon Apr 6 23:58:06 2009 Subject: [Haskell-cafe] Generating arbitrary function in QuickCheck Message-ID: Hi, today, I want to ask about QuickCheck. I have known recently that arbitrary works on functions as well. I played on this for a while, and met a strange behavior. I tried to write property for sortBy. import Test.QuickCheck import Data.List instance Show (a -> b) where show _ = "<>" instance Arbitrary Ordering where arbitrary = elements [LT,EQ,GT] mySortBy :: (Ord a) => (a -> a -> Ordering) -> [a] -> [a] mySortBy = sortBy prop_mysortby_sorted :: (Int -> Int -> Ordering) -> [Int] -> Property prop_mysortby_sorted cmp ls = null ls `trivial` all eq_or_lt (zipWith cmp sorted (tail sorted)) where sorted = mySortBy cmp ls eq_or_lt ord = ord == EQ || ord == LT I had thought Arbitrary instance for Ord and property for sortBy both fine. But checking fails: ghci> quickCheck prop_mysortby_sorted Falsifiable, after 2 tests: <> [2,3] I guess arbitrary for (Int -> Int -> Ordering) generates a non-sense function like this: -- let (arb_compare :: Int -> Int -> Ordering) generated function. arb_compare 0 1 = GT arb_compare 1 0 = GT arb_compare _ _ = EQ Then, I want to ask two questions. 1. Is my guessing in function generated by arbitrary right? 2. If so, How do I generate right function? Thanks, Yusaku Hashimoto From ekirpichov at gmail.com Tue Apr 7 01:09:15 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Tue Apr 7 00:56:08 2009 Subject: [Haskell-cafe] Generating arbitrary function in QuickCheck In-Reply-To: References: Message-ID: <5e0214850904062209p2a73343p3fb3e6fe001a042a@mail.gmail.com> Since the argument to sortBy must impose a linear ordering on its arguments, and any linear ordering may as well be generated by assigning an integer to each element of type 'a', and your sorting function is polymorphic, from the free theorem for the sorting function we may deduce that it suffices to test your function on integer lists with a casual comparison function (Data.Ord.compare), and there is no need to generate a random comparison function. 2009/4/7 Yusaku Hashimoto : > Hi, > > today, I want to ask about QuickCheck. > > I have known recently that arbitrary works on functions as well. I > played on this for a while, and met a strange behavior. > > I tried to write property for sortBy. > > ? ?import Test.QuickCheck > ? ?import Data.List > > ? ?instance Show (a -> b) where show _ = "<>" > ? ?instance Arbitrary Ordering where > ? ? ? ?arbitrary = elements [LT,EQ,GT] > > ? ?mySortBy :: (Ord a) => (a -> a -> Ordering) -> [a] -> [a] > ? ?mySortBy = sortBy > > ? ?prop_mysortby_sorted :: (Int -> Int -> Ordering) -> [Int] -> Property > ? ?prop_mysortby_sorted cmp ls = null ls > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?`trivial` all eq_or_lt (zipWith cmp sorted > (tail sorted)) > ? ? ? ?where sorted = mySortBy cmp ls > ? ? ? ? ? ? ?eq_or_lt ord = ord == EQ || ord == LT > > I had thought Arbitrary instance for Ord and property for sortBy both > fine. But checking fails: > > ? ?ghci> quickCheck prop_mysortby_sorted > ? ?Falsifiable, after 2 tests: > ? ?<> > ? ?[2,3] > > I guess arbitrary for (Int -> Int -> Ordering) generates a non-sense > function like this: > > ? ?-- let (arb_compare :: Int -> Int -> Ordering) generated function. > ? ?arb_compare 0 1 = GT > ? ?arb_compare 1 0 = GT > ? ?arb_compare _ _ = EQ > > Then, I want to ask two questions. > > 1. Is my guessing in function generated by arbitrary right? > 2. If so, How do I generate right function? > > Thanks, > Yusaku Hashimoto > > _______________________________________________ > 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 dagit at codersbase.com Tue Apr 7 01:16:51 2009 From: dagit at codersbase.com (Jason Dagit) Date: Tue Apr 7 01:03:44 2009 Subject: [Haskell-cafe] Generating arbitrary function in QuickCheck In-Reply-To: <5e0214850904062209p2a73343p3fb3e6fe001a042a@mail.gmail.com> References: <5e0214850904062209p2a73343p3fb3e6fe001a042a@mail.gmail.com> Message-ID: On Mon, Apr 6, 2009 at 10:09 PM, Eugene Kirpichov wrote: > Since the argument to sortBy must impose a linear ordering on its > arguments, and any linear ordering may as well be generated by > assigning an integer to each element of type 'a', and your sorting > function is polymorphic, from the free theorem for the sorting > function we may deduce that it suffices to test your function on > integer lists with a casual comparison function (Data.Ord.compare), > and there is no need to generate a random comparison function. Interesting. How is this free theorem stated for the sorting function? Intuitively I understand that if the type is polymorphic, then it seems reasonable to just pick one type and go with it. Thanks, Jason From dave at zednenem.com Tue Apr 7 01:37:41 2009 From: dave at zednenem.com (David Menendez) Date: Tue Apr 7 01:24:34 2009 Subject: [Haskell-cafe] replicateM should be called mreplicate? In-Reply-To: <7ca3f0160904061046x3a03ca00jfe325c4ae9ea8021@mail.gmail.com> References: <49a77b7a0904061042ra528a29v5e976a19ba0aa71b@mail.gmail.com> <7ca3f0160904061046x3a03ca00jfe325c4ae9ea8021@mail.gmail.com> Message-ID: <49a77b7a0904062237jaf6bec3sd8d657ef33ba854a@mail.gmail.com> On Mon, Apr 6, 2009 at 1:46 PM, Luke Palmer wrote: > On Mon, Apr 6, 2009 at 11:42 AM, David Menendez wrote: >> >> Of course, this suggests that mfix should be fixM, so perhaps a better >> distinction is that mplus and mfix need to be defined per-monad, >> whereas filterM and replicateM are generic. > > Don't you think that is an incidental distinction, not an essential one?? It > would be like naming our favorite operations mbind and joinM, just because > of the way we happened to write the monad class. Fair enough. I only added that comment when I noticed that my explanation for picking replicateM over mreplicate also applied to mfix. Looking through Control.Monad, I see that all the *M functions require Monad, whereas the m* functions require MonadPlus (or MonadFix). I wonder to what extent that pattern holds in other libraries? -- Dave Menendez From allbery at ece.cmu.edu Tue Apr 7 02:06:12 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Apr 7 01:53:18 2009 Subject: [Haskell-cafe] automatically inserting type declarations In-Reply-To: References: Message-ID: On 2009 Apr 6, at 23:06, FFT wrote: > I remember hearing about a Haskell mode for Vim, Emacs, Yi or > VisualHaskell that inserts type declarations automatically (it's > lazier to just check the type than to write it manually), but I can't > remember any details. What editor mode / IDE was it? I think you're talking about Shim. Sadly I've heard zero about it since its announcement, and at the time it was rather buggy. -- 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/20090407/fb72fb5f/PGP.bin From voigt at tcs.inf.tu-dresden.de Tue Apr 7 02:19:23 2009 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Tue Apr 7 02:06:17 2009 Subject: [Haskell-cafe] Generating arbitrary function in QuickCheck In-Reply-To: References: <5e0214850904062209p2a73343p3fb3e6fe001a042a@mail.gmail.com> Message-ID: <49DAF06B.60002@tcs.inf.tu-dresden.de> Jason Dagit wrote: > On Mon, Apr 6, 2009 at 10:09 PM, Eugene Kirpichov wrote: > >>Since the argument to sortBy must impose a linear ordering on its >>arguments, and any linear ordering may as well be generated by >>assigning an integer to each element of type 'a', and your sorting >>function is polymorphic, from the free theorem for the sorting >>function we may deduce that it suffices to test your function on >>integer lists with a casual comparison function (Data.Ord.compare), >>and there is no need to generate a random comparison function. > > > Interesting. How is this free theorem stated for the sorting > function? Intuitively I understand that if the type is polymorphic, > then it seems reasonable to just pick one type and go with it. You can try free theorems here: http://linux.tcs.inf.tu-dresden.de/~voigt/ft/ For example, for sort :: Ord a => [a] -> [a] it generates the following: forall t1,t2 in TYPES(Ord), f :: t1 -> t2, f respects Ord. forall x :: [t1]. map f (sort x) = sort (map f x) where: f respects Ord if f respects Eq and forall x :: t1. forall y :: t1. compare x y = compare (f x) (f y) forall x :: t1. forall y :: t1. (<) x y = (<) (f x) (f y) forall x :: t1. forall y :: t1. (<=) x y = (<=) (f x) (f y) forall x :: t1. forall y :: t1. (>) x y = (>) (f x) (f y) forall x :: t1. forall y :: t1. (>=) x y = (>=) (f x) (f y) f respects Eq if forall x :: t1. forall y :: t1. (==) x y = (==) (f x) (f y) forall x :: t1. forall y :: t1. (/=) x y = (/=) (f x) (f y) Assuming that all the comparison functions relate to each other in the mathematically sensible way, the latter can be reduced to: f respects Ord if forall x :: t1. forall y :: t1. (x <= y) = (f x <= f y) For sortBy you would get a similar free theorem. To see how the free theorem allows you to switch from an arbitrary type to just integers, set t2=Int and simply use f to build a order-preserving bijection between elements in the list x and a prefix of [1,2,3,4,...] Ciao, Janis. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From tom.davie at gmail.com Tue Apr 7 02:53:32 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Tue Apr 7 02:40:28 2009 Subject: [Haskell-cafe] replicateM should be called mreplicate? In-Reply-To: <49a77b7a0904062237jaf6bec3sd8d657ef33ba854a@mail.gmail.com> References: <49a77b7a0904061042ra528a29v5e976a19ba0aa71b@mail.gmail.com> <7ca3f0160904061046x3a03ca00jfe325c4ae9ea8021@mail.gmail.com> <49a77b7a0904062237jaf6bec3sd8d657ef33ba854a@mail.gmail.com> Message-ID: <95DAAD26-9A04-4AB2-9261-B5EAE51A88A2@gmail.com> On 7 Apr 2009, at 07:37, David Menendez wrote: > On Mon, Apr 6, 2009 at 1:46 PM, Luke Palmer > wrote: >> On Mon, Apr 6, 2009 at 11:42 AM, David Menendez >> wrote: >>> >>> Of course, this suggests that mfix should be fixM, so perhaps a >>> better >>> distinction is that mplus and mfix need to be defined per-monad, >>> whereas filterM and replicateM are generic. >> >> Don't you think that is an incidental distinction, not an essential >> one? It >> would be like naming our favorite operations mbind and joinM, just >> because >> of the way we happened to write the monad class. > > Fair enough. I only added that comment when I noticed that my > explanation for picking replicateM over mreplicate also applied to > mfix. > > Looking through Control.Monad, I see that all the *M functions require > Monad, whereas the m* functions require MonadPlus (or MonadFix). Actually, most of the *M functions only require Applicative ? they're just written in a time when that wasn't in the libraries. > I wonder to what extent that pattern holds in other libraries? I'm not sure how to generalise this pattern, but it's probably worth noting that fmap is fmap, not mapF. I can't see any pattern that it fits into, really I suspect it's a case of "what shall we name this" and not enough thought about consistant naming as the libraries evolved. Bob From dmehrtash at gmail.com Tue Apr 7 03:34:04 2009 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Tue Apr 7 03:20:59 2009 Subject: [Haskell-cafe] tail recursion Message-ID: Is the call to "go" in the following code considered as tail recursion? data DList a = DLNode (DList a) a (DList a) mkDList :: [a] -> DList a mkDList [] = error "must have at least one element" mkDList xs = let (first,last ) = go last xs first in first where go :: DList a -> [a] -> DList a -> (DList a, DList a) go prev [] next = (next,prev) go prev (x:xs) next = let this = DLNode prev x rest (rest,last ) = *go this xs next* in (this,last ) Daryoush -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090407/b9236197/attachment-0001.htm From deduktionstheorem at web.de Tue Apr 7 05:05:39 2009 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Tue Apr 7 04:52:39 2009 Subject: [Haskell-cafe] Monad transformer to consume a list In-Reply-To: References: <49DA6801.1030209@web.de> Message-ID: <49DB1763.10002@web.de> Henning Thielemann wrote: >> is there a monad transformer to consume an input list? I've got external >> events "streaming into the monad" that are consumed on demand and I'm >> not sure if there's something better than a StateT. > > I wondered that, too. I wondered whether there is something inverse to > Writer, and Reader is appearently not the answer. Now I think, that > State is indeed the way to go to consume a list. Even better is StateT > List Maybe: > > next :: StateT [a] Maybe a > next = StateT Data.List.HT.viewL -- see utility-ht package > But a StateT provides the power to modify the list in other ways than reading the first element (modify (x:)). Maybe ParsecT is closer to what I'm looking for ;) -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From claus.reinke at talk21.com Tue Apr 7 05:08:39 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Apr 7 04:55:41 2009 Subject: [Haskell-cafe] automatically inserting type declarations References: Message-ID: <54A4CE01858F444EB4D397B53C5D8C88@cr3lt> >I remember hearing about a Haskell mode for Vim, Emacs, Yi or > VisualHaskell that inserts type declarations automatically (it's > lazier to just check the type than to write it manually), but I can't > remember any details. What editor mode / IDE was it? As far as I know, my haskellmode plugins for Vim were the first to do that, in their long-gone predecessor incarnation of hugs.vim. But I'm pretty sure this feature was adopted by the Emacs folks as soon as people started saying they liked it. That is, types for top-level declarations - more precise types are on everyone's todo list, I think (by just doing what VisualHaskell used to do: ask a dedicated GHC API client for details). Take the identifier under cursor, run something like ghc -e ":t " and either show the result, or insert it. These days, the plugins no longer call out to GHC every time, instead they update an internal map whenever you use ':make' in quickfix mode and get no errors from GHC. Anyway, the plugins have recently moved here: http://projects.haskell.org/haskellmode-vim > What do most people use with GHC on Linux? I'm more used to Vim than > to Emacs. Yi sounds like something I might like. Is it stable enough > to solve more problems than it would create? (I hate buggy and broken > stuff) haskellmode-vim isn't free of problems (mostly to do with large numbers of installed libraries vs naive scripts). The reason it exists is to solve problems I don't want to have, so it tends to improve whenever a problem bugs me enough, but whether the result works for you, you have to try for yourself!-) Claus From lemming at henning-thielemann.de Tue Apr 7 05:09:53 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Apr 7 04:57:07 2009 Subject: [Haskell-cafe] Monad transformer to consume a list In-Reply-To: <49DB1763.10002@web.de> References: <49DA6801.1030209@web.de> <49DB1763.10002@web.de> Message-ID: On Tue, 7 Apr 2009, Stephan Friedrichs wrote: > Henning Thielemann wrote: > >>> is there a monad transformer to consume an input list? I've got external >>> events "streaming into the monad" that are consumed on demand and I'm >>> not sure if there's something better than a StateT. >> >> I wondered that, too. I wondered whether there is something inverse to >> Writer, and Reader is appearently not the answer. Now I think, that >> State is indeed the way to go to consume a list. Even better is StateT >> List Maybe: >> >> next :: StateT [a] Maybe a >> next = StateT Data.List.HT.viewL -- see utility-ht package >> > > But a StateT provides the power to modify the list in other ways than > reading the first element (modify (x:)). Maybe ParsecT is closer to what > I'm looking for ;) If you want to restrict the functionality of StateT, then wrap it in a newtype. From jwlato at gmail.com Tue Apr 7 05:18:00 2009 From: jwlato at gmail.com (John Lato) Date: Tue Apr 7 05:04:54 2009 Subject: [Haskell-cafe] Re: Configuring cabal dependencies at install-time Message-ID: <9979e72e0904070218p7934efd7sa72b2fc348d27ca9@mail.gmail.com> > From: Jeff Heard > > Is there a way to do something like autoconf and configure > dependencies at install time? ?Building buster, I keep adding > dependencies and I'd like to keep that down to a minimum without the > annoyance of littering Hackage with dozens of packages. ?For instance, > today I developed an HTTP behaviour and that of course requires > network and http, which were previously not required. ?I'm about to > put together a haxr XML-RPC behaviour as well, and that of course > would add that much more to the dependency list. ?HaXml, haxr, and > haxr-th most likely. > > so... any way to do that short of making a bunch of separate packages > with one or two modules apiece? ?Otherwise I'm thinking of breaking > things up into buster, buster-ui, buster-network, buster-console, and > buster-graphics to start and adding more as I continue along. > I'd be interested in hearing answers to this as well. I'm not a fan of configure-style compile-time conditional compilation, at least for libraries. It makes it much harder to specify dependencies. With this, if package Foo depends on buster and the HTTP behavior, it's no longer enough to specify "build-depends: buster" because that will only work if buster was configured properly on any given system. I think that the proper solution is to break up libraries into separate packages as Jeff suggests (buster, buster-ui, etc.), but then the total packages on hackage would explode. I don't feel great about doing that with my own packages either; is it a problem? If so, maybe there could be just one extra package, e.g. buster and buster-extras. Is there a better solution I'm missing? John Lato From martijn at van.steenbergen.nl Tue Apr 7 05:20:46 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Tue Apr 7 05:07:39 2009 Subject: [Haskell-cafe] Re: Configuring cabal dependencies at install-time In-Reply-To: <9979e72e0904070218p7934efd7sa72b2fc348d27ca9@mail.gmail.com> References: <9979e72e0904070218p7934efd7sa72b2fc348d27ca9@mail.gmail.com> Message-ID: <49DB1AEE.4040102@van.steenbergen.nl> John Lato wrote: >> From: Jeff Heard >> >> Is there a way to do something like autoconf and configure >> dependencies at install time? Building buster, I keep adding >> dependencies and I'd like to keep that down to a minimum without the >> annoyance of littering Hackage with dozens of packages. For instance, >> today I developed an HTTP behaviour and that of course requires >> network and http, which were previously not required. I'm about to >> put together a haxr XML-RPC behaviour as well, and that of course >> would add that much more to the dependency list. HaXml, haxr, and >> haxr-th most likely. >> >> so... any way to do that short of making a bunch of separate packages >> with one or two modules apiece? Otherwise I'm thinking of breaking >> things up into buster, buster-ui, buster-network, buster-console, and >> buster-graphics to start and adding more as I continue along. >> > > I'd be interested in hearing answers to this as well. I'm not a fan > of configure-style compile-time conditional compilation, at least for > libraries. It makes it much harder to specify dependencies. With > this, if package Foo depends on buster and the HTTP behavior, it's no > longer enough to specify "build-depends: buster" because that will > only work if buster was configured properly on any given system. > > I think that the proper solution is to break up libraries into > separate packages as Jeff suggests (buster, buster-ui, etc.), but then > the total packages on hackage would explode. I don't feel great about > doing that with my own packages either; is it a problem? If so, maybe > there could be just one extra package, e.g. buster and buster-extras. > Is there a better solution I'm missing? Cabal's flag system sounds like a nice solution for this, except I don't know if it's possible to add specific flags to your build dependencies, i.e. build-depends: buster -fhttp Martijn. From claus.reinke at talk21.com Tue Apr 7 05:23:21 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Apr 7 05:10:21 2009 Subject: [Haskell-cafe] UPDATE: haskellmode for Vim now at projects.haskell.org (+screencast; -) Message-ID: <38C7795C42FF4C8CA587C95603632431@cr3lt> I have become aware that many Haskellers are not aware of the Haskell mode plugins for Vim, in spite of the >100 downloads per month I saw when I last checked. Since the plugins have just completed their move to their new home at http://projects.haskell.org/haskellmode-vim/ this seems to be a good opportunity to mention them again (now with 100% more screencasts!-). They do much (though certainly not all) of the stuff people often wish for here, such as showing or adding types, looking up source where available locally or looking up documentation where source isn't available. Mostly, they collect my attempts to automate tasks when I have to do them often enough. Here is a section of the quick reference (:help haskellmode-quickref): |:make| load into GHCi, show errors (|quickfix| |:copen|) |_ct| create |tags| file |_si| show info for id under cursor |_t| show type for id under cursor |_T| insert type declaration for id under cursor |balloon| show type for id under mouse pointer |_?| browse Haddock entry for id under cursor |:IDoc| {identifier} browse Haddock entry for unqualified {identifier} |:MDoc| {module} browse Haddock entry for {module} |:FlagReference| {s} browse Users Guide Flag Reference for section {s} |_.| qualify unqualified id under cursor |_i| add 'import ()' for id under cursor |_im| add 'import ' for id under cursor |_iq| add 'import qualified ()' for id under cursor |_iqm| add 'import qualified ' for id under cursor |_ie| make imports explit for import statement under cursor |_opt| add OPTIONS_GHC pragma |_lang| add LANGUAGE pragma |i_CTRL-X_CTRL-O| insert-mode completion based on imported ids (|haskellmode-XO|) |i_CTRL-X_CTRL-U| insert-mode completion based on documented ids (|haskellmode-XU|) |i_CTRL-N| insert-mode completion based on imported sources |:GHCi|{command/expr} run GHCi command/expr in current module For those who have never used these plugins, or haven't used Vim at all, it has often been difficult to imagine what editing in Vim can be like. The old quick tour of features available has now been updated from screenshots to screencasts (my first venture into this area - please let me know whether that is useful or a waste of time!-), so you can watch them on Youtube before deciding to invest time into learning Vim. For those who are using Vim, the only reason not to use my haskellmode plugins would be if you had your own (not uncommon among Vim users;-), in which case I hope you make yours available as well (feel free to adopt features from my plugins, and let me know if you have some useful features to contribute), here: http://www.haskell.org/haskellwiki/Libraries_and_tools/Program_development#Vim For those who have happily been using these plugins: in the process of moving the site, I noticed that I hadn't updated the published version for a quite some time - apparently, noone had missed the fixes, but in case you want to check, the relevant section of my update log is appended below. Happy Vimming!-) Claus ------------- updates since last published version on old site 04/04/2009 haskell_doc.vim: when narrowing choices by qualifier for _?, take lookup index from un-narrowed list (else we could end up in the docs for the wrong module) 02/04/2009 ghc.vim: actually, we can try to make a reasonable guess at the parent type for constructors in _ie, from their type signature 01/04/2009 ghc.vim: try a bit harder to escape " and ' in :GHCi eliminate duplicates in _ie and mark data constructor imports as ???(Cons) - we can't reliably figure out the parent type for the constructor:-( handle Prelude as special case in _ie (can't just comment out import, need to import [qualified] Prelude [as X]() ) haskell_doc.vim: fix keys (no namespace tags) and urls (modules) for :MDoc 31/03/2009 all files: new home page at projects.haskell.org 28/03/2009 haskell_doc.vim: in ProcessHaddockIndexes2, fix a case where making new entries could lose old ones (eg, zipWith's base package locations got lost when adding its vector package locations) 07/12/2008 haskell_doc.vim: since we're now reading from multiple haddock indices in DocIndex, we need to extend, not overwrite entries.. 03/12/2008 ghc.vim: do not reset b:ghc_static_options on every reload From Tom.Schrijvers at cs.kuleuven.be Tue Apr 7 06:01:47 2009 From: Tom.Schrijvers at cs.kuleuven.be (Tom Schrijvers) Date: Tue Apr 7 05:49:56 2009 Subject: [Haskell-cafe] Monad transformer to consume a list In-Reply-To: References: <49DA6801.1030209@web.de> Message-ID: >> Hello, >> >> is there a monad transformer to consume an input list? I've got external >> events "streaming into the monad" that are consumed on demand and I'm >> not sure if there's something better than a StateT. > > I wondered that, too. I wondered whether there is something inverse to > Writer, and Reader is appearently not the answer. Now I think, that State is > indeed the way to go to consume a list. Even better is StateT List Maybe: > > next :: StateT [a] Maybe a > next = StateT Data.List.HT.viewL -- see utility-ht package Or make the transformer a MonadPlus transformer and call mzero for the empty list? Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: tom.schrijvers@cs.kuleuven.be url: http://www.cs.kuleuven.be/~toms/ From alistair at abayley.org Tue Apr 7 06:23:24 2009 From: alistair at abayley.org (Alistair Bayley) Date: Tue Apr 7 06:10:17 2009 Subject: [Haskell-cafe] strange performance issue with takusen 0.8.3 In-Reply-To: <87d4bp39bq.wl%MarkoSchuetz@web.de> References: <87d4bp39bq.wl%MarkoSchuetz@web.de> Message-ID: <79d7c4980904070323o67b8530flfb3e85d9ece6da61@mail.gmail.com> 2009/4/6 Marko Sch?tz : > > I have an application where some simple data extracted from some > source files is inserted into a PostgreSQL database. The application > uses Takusen and is compiled with GHC 6.8.3. Some (59 in the test > data) of the selects take on average 460ms each for a total time for > this sample run of 30s. I prepare one select statement at the > beginning of the run into which I then bind the specific values for > every one of the selects. It does not seem to make a difference > whether I do this or whether I just use a new statement for every > select. > > For comparison, I have collected the SQL statements in a file with > PREPARE ... and DEALLOCATE for _every_ select and then run this file > through psql. This takes 2s! Hello Marko, I'm finding it hard to see what the problem is here. Is it that your query takes 460ms, and you need it to be quicker? Or is it something else? It would help to have some example code. Can you make a test case which reproduces te problem, that you could share? > For comparison, I have collected the SQL statements in a file with > PREPARE ... and DEALLOCATE for _every_ select and then run this file > through psql. This takes 2s! If all you are doing is preparing and deallocating - i.e. not executing - then that will be very quick, because the queries are never executed. Alistair From matthijs at stdin.nl Tue Apr 7 06:23:42 2009 From: matthijs at stdin.nl (Matthijs Kooijman) Date: Tue Apr 7 06:10:36 2009 Subject: [Haskell-cafe] UPDATE: haskellmode for Vim now at projects.haskell.org (+screencast; -) In-Reply-To: <38C7795C42FF4C8CA587C95603632431@cr3lt> References: <38C7795C42FF4C8CA587C95603632431@cr3lt> Message-ID: <20090407102342.GX25888@katherina.student.utwente.nl> Hi Claus, > http://projects.haskell.org/haskellmode-vim/ The download link on this page seems to use \ instead of /, making it not work. For anyone eager to download it, just replace \ (or %5C) in your address bar with \ and it should work. Gr. Matthijs -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090407/82d97975/attachment.bin From ndmitchell at gmail.com Tue Apr 7 06:25:12 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Apr 7 06:12:05 2009 Subject: [Haskell-cafe] Parallel combinator, performance advice Message-ID: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> Hi, I've written a parallel_ function, code attached. I'm looking for criticism, suggestions etc on how to improve the performance and fairness of this parallel construct. (If it turns out this construct is already in a library somewhere, I'd be interested in that too!) The problem I'm trying to solve is running system commands in parallel. Importantly (unlike other Haskell parallel stuff) I'm not expecting computationally heavy Haskell to be running in the threads, and only want a maximum of n commands to fire at a time. The way I'm trying to implement this is with a parallel_ function: parallel_ :: [IO a] -> IO () The semantics are that after parallel_ returns each action will have been executed exactly once. The implementation (attached) creates a thread pool of numCapabililties-1 threads, each of which reads from a task pool and attempts to do some useful work. I use an idempotent function to ensure that all work is done at most one, and a sequence_ to ensure all work is done at least once. Running a benchmark of issuing 1 million trivial tasks (create, modify, read and IO ref) the version without any parallelism is really fast (< 0.1 sec), and the version with parallelism is slow (> 10 sec). This could be entirely due to space leaks etc when queueing many tasks. I'm useful for any thoughts people might have! Thanks in advance, Neil -------------- next part -------------- A non-text attachment was scrubbed... Name: Parallel.hs Type: application/octet-stream Size: 1348 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090407/252130a2/Parallel.obj From claus.reinke at talk21.com Tue Apr 7 06:35:49 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Apr 7 06:22:48 2009 Subject: [Haskell-cafe] UPDATE: haskellmode for Vim now atprojects.haskell.org (+screencast; -) References: <38C7795C42FF4C8CA587C95603632431@cr3lt> <20090407102342.GX25888@katherina.student.utwente.nl> Message-ID: >> http://projects.haskell.org/haskellmode-vim/ >The download link on this page seems to use \ instead of /, making it not work. >For anyone eager to download it, just replace \ (or %5C) in your address bar >with \ and it should work. argh, thanks, now fixed (filename completion in Vim, :help i_CTRL-X_CTRL-F, is useful for making sure one links to the correct file names, but gives platform- specific paths, which I usually correct before publishing; this one I missed). Claus From moonpatio at gmail.com Tue Apr 7 06:48:26 2009 From: moonpatio at gmail.com (Matt Morrow) Date: Tue Apr 7 06:35:20 2009 Subject: [Haskell-cafe] Strange type error with associated type synonyms In-Reply-To: <4580278B-D5B6-4A4E-9233-415B57F60A3E@cse.unsw.edu.au> References: <646230a00904061436x41af1055se39e8892eb4e3083@mail.gmail.com> <4580278B-D5B6-4A4E-9233-415B57F60A3E@cse.unsw.edu.au> Message-ID: <1bc51a990904070348p7e6fc849qeaa45b155279e435@mail.gmail.com> On Mon, Apr 6, 2009 at 7:39 PM, Manuel M T Chakravarty wrote: > Peter Berry: > >> 3) we apply appl to x, so Memo d1 a = Memo d a. unify d = d1 >> >> But for some reason, step 3 fails. >> > > Step 3 is invalid - cf, < > http://www.haskell.org/pipermail/haskell-cafe/2009-April/059196.html>. > > More generally, the signature of memo_fmap is ambiguous, and hence, > correctly rejected. We need to improve the error message, though. Here is > a previous discussion of the subject: > > http://www.mail-archive.com/haskell-cafe@haskell.org/msg39673.html > > Manuel The thing that confuses me about this case is how, if the type sig on memo_fmap is omitted, ghci has no problem with it, and even gives it the type that it rejected: ------------------------------------------------ {-# LANGUAGE TypeFamilies #-} class Fun d where type Memo d :: * -> * abst :: (d -> a) -> Memo d a appl :: Memo d a -> (d -> a) memo_fmap f x = abst (f . appl x) -- [m@monire a]$ ghci -ignore-dot-ghci -- GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help -- -- Prelude> :l ./Memo.hs -- [1 of 1] Compiling Main ( Memo.hs, interpreted ) -- Ok, modules loaded: Main. -- -- *Main> :t memo_fmap -- memo_fmap :: (Fun d) => (a -> c) -> Memo d a -> Memo d c -- copy/paste the :t sig memo_fmap_sig :: (Fun d) => (a -> c) -> Memo d a -> Memo d c memo_fmap_sig f x = abst (f . appl x) -- and, -- *Main> :r -- [1 of 1] Compiling Main ( Memo.hs, interpreted ) -- -- Memo.hs:26:35: -- Couldn't match expected type `Memo d' -- against inferred type `Memo d1' -- In the first argument of `appl', namely `x' -- In the second argument of `(.)', namely `appl x' -- In the first argument of `abst', namely `(f . appl x)' -- Failed, modules loaded: none. ------------------------------------------------ Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090407/ac30f24d/attachment.htm From haskell at list.mightyreason.com Tue Apr 7 07:04:08 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Tue Apr 7 06:51:37 2009 Subject: [Haskell-cafe] Re: Parallel combinator, performance advice In-Reply-To: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> Message-ID: <49DB3328.8040707@list.mightyreason.com> You create one MVar for each task in order to ensure all the tasks are done. This is pretty heavyweight. You could create a single Control.Concurrent.QSemN to count the completed tasks, starting with 0. Each task is followed by signalQSemN with a value of 1. (I would use "finally"). As parallel_ launches the tasks it can count their number, then it would call waitQSemN for that quantity to have finished. -- Chris From wren at freegeek.org Tue Apr 7 07:11:55 2009 From: wren at freegeek.org (wren ng thornton) Date: Tue Apr 7 06:58:49 2009 Subject: [Haskell-cafe] tail recursion In-Reply-To: References: Message-ID: <49DB34FB.7090804@freegeek.org> Daryoush Mehrtash wrote: > Is the call to "go" in the following code considered as tail recursion? > > data DList a = DLNode (DList a) a (DList a) > > mkDList :: [a] -> DList a > > mkDList [] = error "must have at least one element" > mkDList xs = let (first,last) = go last xs first > in first > > where go :: DList a -> [a] -> DList a -> (DList a, DList a) > go prev [] next = (next,prev) > go prev (x:xs) next = let this = DLNode prev x rest > (rest,last) = go this xs next > in (this,last) No. For @go _ (_:_) _@ the tail expression is @(this,last)@ and so the tail call is to @(,)@. Consider this general transformation[1]: go prev [] next = (next,prev) go prev (x:xs) next = case DLNode prev x rest of this -> case go this xs next of (rest,last) -> (this,last) Let binding is ignored when determining tail-callingness, and case evaluation only contributes in as far as allowing multiple tails. [1] Which isn't laziness-preserving and so will break on your recursive let binding. It's a valid transformation for non-recursive let bindings, though, provided the appropriate strictness analysis. -- Live well, ~wren From chak at cse.unsw.edu.au Tue Apr 7 07:41:22 2009 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Tue Apr 7 07:28:17 2009 Subject: [Haskell-cafe] Strange type error with associated type synonyms In-Reply-To: <1bc51a990904070348p7e6fc849qeaa45b155279e435@mail.gmail.com> References: <646230a00904061436x41af1055se39e8892eb4e3083@mail.gmail.com> <4580278B-D5B6-4A4E-9233-415B57F60A3E@cse.unsw.edu.au> <1bc51a990904070348p7e6fc849qeaa45b155279e435@mail.gmail.com> Message-ID: Matt Morrow: > On Mon, Apr 6, 2009 at 7:39 PM, Manuel M T Chakravarty > wrote: > Peter Berry: > > 3) we apply appl to x, so Memo d1 a = Memo d a. unify d = d1 > > But for some reason, step 3 fails. > > Step 3 is invalid - cf, >. > > More generally, the signature of memo_fmap is ambiguous, and hence, > correctly rejected. We need to improve the error message, though. > Here is a previous discussion of the subject: > > http://www.mail-archive.com/haskell-cafe@haskell.org/msg39673.html > > Manuel > > The thing that confuses me about this case is how, if the type sig > on memo_fmap is omitted, ghci has no problem with it, and even gives > it the type that it rejected: Basically, type checking proceeds in one of two modes: inferring or checking. The former is when there is no signature is given; the latter, if there is a user-supplied signature. GHC can infer ambiguous signatures, but it cannot check them. This is of course very confusing and we need to fix this (by preventing GHC from inferring ambiguous signatures). The issue is also discussed in the mailing list thread I cited in my previous reply. Manuel PS: I do realise that ambiguous signatures are the single most confusing issue concerning type families (at least judging from the amount of mailing list traffic generated). We'll do our best to improve the situation before 6.12 comes out. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090407/4742e5c1/attachment.htm From haskell at utr.dk Tue Apr 7 07:41:36 2009 From: haskell at utr.dk (Ulrik Rasmussen) Date: Tue Apr 7 07:28:37 2009 Subject: [Haskell-cafe] threadDelay granularity Message-ID: <20090407114134.GA6497@squish> Hello. I am writing a simple game in Haskell as an exercise, and in the rendering loop I want to cap the framerate to 60fps. I had planned to do this with GHC.Conc.threadDelay, but looking at it's documentation, I discovered that it can only delay the thread in time spans that are multiples of 20ms: http://www.haskell.org/ghc/docs/6.4/html/libraries/base/Control.Concurrent.html I need a much finer granularity than that, so I wondered if it is possible to either get a higher resolution for threadDelay, or if there is an alternative to threadDelay? I noticed that the SDL library includes the function "delay", which indeed works with a resolution down to one millisecond. However, since I'm using HOpenGL and GLUT, I think it would be a little overkill to depend on SDL just for this :). Thanks, Ulrik Rasmussen From manlio_perillo at libero.it Tue Apr 7 07:49:56 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Tue Apr 7 07:36:56 2009 Subject: [Haskell-cafe] advice on space efficient data structure with efficient snoc operation Message-ID: <49DB3DE4.9090300@libero.it> Hi. I'm still working on my Netflix Prize project. For a function I wrote, I really need a data structure that is both space efficient (unboxed elements) and with an efficient snoc operation. I have pasted a self contained module with the definition of the function I'm using: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3453 The movie ratings are loaded from serialized data, and the result is serialized again, using the binary package: transcodeIO :: IO () transcodeIO = do input <- L.hGetContents stdin let output = encodeZ $ transcode $ decodeZ input L.hPut stdout output (here encodeZ and decodeZ are wrappers around Data.Binary.encode and Data.Binary.decode, with support to gzip compression/decompression) This function (transcodeIO, not transcode) takes, on my Core2 CPU T7200 @ 2.00GHz: real 30m8.794s user 29m30.659s sys 0m10.313s 1068 Mb total memory in use The problem here is with snocU, that requires a lot of copying. I rewrote the transcode function so that the input data set is split in N parts: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3453#a3456 The mapReduce function is the one defined in the Real World Haskell. The new function takes (using only one thread): real 18m48.039s user 18m30.901s sys 0m6.520s 1351 Mb total memory in use The additional required memory is probably caused by unionsWith, that is not strict. The function takes less time, since array copying is optimized. I still use snocU, but on small arrays. GC time is very high: 54.4% Unfortunately I can not test with more then one thread, since I get segmentation faults (probably a bug with uvector packages). I also got two strange errors (but this may be just the result of the segmentation fault, I'm not able to reproduce them): tpp.c:63: __pthread_tpp_change_priority: Assertion `new_prio == -1 || (new_prio >= __sched_fifo_min_prio && new_prio <= __sched_fifo_max_prio)' failed. internal error: removeThreadFromQueue: not found (GHC version 6.8.2 for i386_unknown_linux) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug Now the question is: what data structure should I use to optimize the transcode function? IMHO there are two solutions: 1) Use a "lazy" array. Something like ByteString.Lazy, and what is available in storablevector package. Using this data structure, I can avoid the use of appendU. 2) Use an "unboxed" list. Something like: http://mdounin.ru/hg/nginx-vendor-current/file/tip/src/core/ngx_list.h That is: a linked list of unboxed arrays, but unlike the lazy array solution, a snoc operation avoid copying if there is space in the current array. I don't know if this is easy/efficient to implement in Haskell. Any other suggestions? Thanks Manlio Perillo From matthijs at stdin.nl Tue Apr 7 08:29:07 2009 From: matthijs at stdin.nl (Matthijs Kooijman) Date: Tue Apr 7 08:16:00 2009 Subject: [Haskell-cafe] UPDATE: haskellmode for Vim now at projects.haskell.org (+screencast; -) In-Reply-To: <38C7795C42FF4C8CA587C95603632431@cr3lt> References: <38C7795C42FF4C8CA587C95603632431@cr3lt> Message-ID: <20090407122907.GZ25888@katherina.student.utwente.nl> Hi Claus, I've installed the vimball, and it spit a few errors at me. In particular, it couldn't find the haddock documentation directory. A quick look at haskell_doc.vim shows that it should autodetect the directory. However, for some reason my ghc-pkg command returns the doc directory twice: $ ghc-pkg field base haddock-html haddock-html: /usr/local/ghc-6.10.1/share/doc/ghc/libraries/base haddock-html: /usr/local/ghc-6.10.1/share/doc/ghc/libraries/base The haskell_doc.vim contains the following line, which seems to deal with multiple lines: let field = substitute(system(g:ghc_pkg . ' field base haddock-html'),'\n','','') However, this simply concats the lines, which obviously makes a mess of the output and makes the detection fail. I've made things work by throwing away everything except for the first line, by replacing the above line with: let field = substitute(system(g:ghc_pkg . ' field base haddock-html'),'\n.*','','') This solution works for me, though it might be better to iterate all lines and try each of them in turn, for the case that ghc-pkg returns different paths? I can't really think of a case why this would be needed, though. Gr. Matthijs -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090407/a4f98433/attachment.bin From bulat.ziganshin at gmail.com Tue Apr 7 08:40:11 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Apr 7 08:33:57 2009 Subject: [Haskell-cafe] Parallel combinator, performance advice In-Reply-To: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> Message-ID: <856996247.20090407164011@gmail.com> Hello Neil, Tuesday, April 7, 2009, 2:25:12 PM, you wrote: > The problem I'm trying to solve is running system commands in > parallel. "system commands" means execution of external commands or just system calls inside Haskell? > Running a benchmark of issuing 1 million trivial tasks (create, > modify, read and IO ref) the version without any parallelism is really > fast (< 0.1 sec), and the version with parallelism is slow (> 10 sec). > This could be entirely due to space leaks etc when queueing many > tasks. i think it's just because use of MVar/Chan is much slower than IORef activity. once i checked that on 1GHz cpu and got 2 million withMVar-s per second i don't understood exactly what you need, but my first shot is to create N threads executing commands from channel: para xs = do done <- newEmptyMVar chan <- newChan writeList2Chan chan (map Just xs ++ [Nothing]) replicateM_ numCapabilities $ do forkIO $ do forever $ do x <- readChan chan case x of Just cmd -> cmd Nothing -> putMVar done () takeMVar done -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bugfact at gmail.com Tue Apr 7 08:53:20 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Apr 7 08:40:13 2009 Subject: [Haskell-cafe] threadDelay granularity In-Reply-To: <20090407114134.GA6497@squish> References: <20090407114134.GA6497@squish> Message-ID: I think this is an RTS option. http://www.haskell.org/ghc/docs/latest/html/users_guide/using-concurrent.html On Tue, Apr 7, 2009 at 1:41 PM, Ulrik Rasmussen wrote: > Hello. > > I am writing a simple game in Haskell as an exercise, and in the > rendering loop I want to cap the framerate to 60fps. I had planned to do > this with GHC.Conc.threadDelay, but looking at it's documentation, I > discovered that it can only delay the thread in time spans that are > multiples of 20ms: > > > http://www.haskell.org/ghc/docs/6.4/html/libraries/base/Control.Concurrent.html > > I need a much finer granularity than that, so I wondered if it is > possible to either get a higher resolution for threadDelay, or if there > is an alternative to threadDelay? > > I noticed that the SDL library includes the function "delay", which > indeed works with a resolution down to one millisecond. However, since > I'm using HOpenGL and GLUT, I think it would be a little overkill to > depend on SDL just for this :). > > > Thanks, > > Ulrik Rasmussen > _______________________________________________ > 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/20090407/3d9b7e56/attachment.htm From jgoerzen at complete.org Tue Apr 7 09:18:39 2009 From: jgoerzen at complete.org (John Goerzen) Date: Tue Apr 7 09:05:34 2009 Subject: [Haskell-cafe] System.Process.Posix In-Reply-To: <20481029.20090405002136@gmail.com> References: <20481029.20090405002136@gmail.com> Message-ID: <49DB52AF.10307@complete.org> Bulat Ziganshin wrote: > Hello Cristiano, > > Sunday, April 5, 2009, 12:05:02 AM, you wrote: > >> Is it me or the above package is not included in Hoogle? > > afair, Neil, being windows user, includes only packages available for > his own system > > there was a large thread a few months ago and many peoples voted for > excluding any OS-specific packages at all since this decreases > portability of code developed by Hoogle users :))) > > Urm, I realize that was half in jest, but no. It just makes Hoogle less useful. If I need to fork, I need to fork, and no amount of sugarcoating is going to get around that. -- John From haskell at colquitt.org Tue Apr 7 09:20:56 2009 From: haskell at colquitt.org (John Dorsey) Date: Tue Apr 7 09:07:48 2009 Subject: [Haskell-cafe] Re: Configuring cabal dependencies at install-time In-Reply-To: <9979e72e0904070218p7934efd7sa72b2fc348d27ca9@mail.gmail.com> References: <9979e72e0904070218p7934efd7sa72b2fc348d27ca9@mail.gmail.com> Message-ID: <20090407132056.GE2207@colquitt.org> John Lato wrote: > I think that the proper solution is to break up libraries into > separate packages as Jeff suggests (buster, buster-ui, etc.), but then > the total packages on hackage would explode. I don't feel great about I thought about this a while back and came to the conclusion that the package count should only grow by a small contant factor due to this, and that's a lot better than dealing with hairy and problematic dependencies. It should usually be: libfoo libfoo-blarg libfoo-xyzzy etc. and more rarely: libbar-with-xyzzy libbar-no-xyzzy etc. each providing libbar. Although I don't remember whether Cabal has 'provides'. The latter case could explode exponentially for weird packages that have several soft dependencies that can't be managed in the plugin manner, but I can't see that being a real issue. This looks manageable to me, but I'm no packaging guru. I guess it's a little harder for authors/maintainers of packages that look like leaves in the dependency tree, which could be bad. Am I missing something bad? Regards, John From ndmitchell at gmail.com Tue Apr 7 09:31:09 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Apr 7 09:18:02 2009 Subject: [Haskell-cafe] System.Process.Posix In-Reply-To: <49DB52AF.10307@complete.org> References: <20481029.20090405002136@gmail.com> <49DB52AF.10307@complete.org> Message-ID: <404396ef0904070631o78306bcie2790a0b2c8f9e85@mail.gmail.com> Hi >>> Is it me or the above package is not included in Hoogle? >> >> afair, Neil, being windows user, includes only packages available for >> his own system >> >> there was a large thread a few months ago and many peoples voted for >> excluding any OS-specific packages at all since this decreases >> portability of code developed by Hoogle users :))) > > Urm, I realize that was half in jest, but no. ?It just makes Hoogle less > useful. ?If I need to fork, I need to fork, and no amount of > sugarcoating is going to get around that. I was implementing full package support last weekend. With any luck, I'll manage to push the changes tonight. If not, I'll push them as soon as I get back from holiday (a week or so) Thanks Neil From frodo at theshire.org Tue Apr 7 09:38:51 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Apr 7 09:26:03 2009 Subject: [Haskell-cafe] System.Process.Posix In-Reply-To: <404396ef0904070631o78306bcie2790a0b2c8f9e85@mail.gmail.com> References: <20481029.20090405002136@gmail.com> <49DB52AF.10307@complete.org> <404396ef0904070631o78306bcie2790a0b2c8f9e85@mail.gmail.com> Message-ID: On Tue, Apr 7, 2009 at 3:31 PM, Neil Mitchell wrote: > > I was implementing full package support last weekend. With any luck, > I'll manage to push the changes tonight. If not, I'll push them as > soon as I get back from holiday (a week or so) Thank you, Neil. Cristiano From matthijs at stdin.nl Tue Apr 7 09:41:44 2009 From: matthijs at stdin.nl (Matthijs Kooijman) Date: Tue Apr 7 09:28:37 2009 Subject: [Haskell-cafe] UPDATE: haskellmode for Vim now at projects.haskell.org (+screencast; -) In-Reply-To: <20090407122907.GZ25888@katherina.student.utwente.nl> References: <38C7795C42FF4C8CA587C95603632431@cr3lt> <20090407122907.GZ25888@katherina.student.utwente.nl> Message-ID: <20090407134144.GC25888@katherina.student.utwente.nl> Hi Claus, I've found two more little bugs. The first is that version comparison is incorrect. It now requires that all components are greater, so comparing 6.10.1 >= 6.8.2 returns false (since 1 < 2). Also, there is a "ghc-pkg field * haddock-html" call, but here the * will be expanded by the shell into the files in the current directory. To prevent this, the * should be escaped. Both of these are fixed in the attached patch. I'm also looking at the Qualify() function, which allows you to select a qualification using tab completion. However, when there is only a single choice, its a bit silly to have to use tabcompletion. At the very least, the value should be prefilled, but ideally the qualification should just happen. Also, I think that a dropdown menu is also available in text mode vim (at least with vim7), which would be nice for multiple choices (since you can see all choices in one glance). I'll have a look at these things as well, expect another patch :-) Gr. Matthijs -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090407/72ccbdd4/attachment.bin From claus.reinke at talk21.com Tue Apr 7 09:46:11 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Apr 7 09:33:11 2009 Subject: [Haskell-cafe] UPDATE: haskellmode for Vim now atprojects.haskell.org (+screencast; -) References: <38C7795C42FF4C8CA587C95603632431@cr3lt> <20090407122907.GZ25888@katherina.student.utwente.nl> Message-ID: <8B7E71DABA4044F1B36625A78C77C1DF@cr3lt> Hi Matthijs, >I've installed the vimball, and it spit a few errors at me. In particular, it >couldn't find the haddock documentation directory. A quick look at >haskell_doc.vim shows that it should autodetect the directory. However, for >some reason my ghc-pkg command returns the doc directory twice: > > $ ghc-pkg field base haddock-html > haddock-html: /usr/local/ghc-6.10.1/share/doc/ghc/libraries/base > haddock-html: /usr/local/ghc-6.10.1/share/doc/ghc/libraries/base Interesting. The reason for the double listing is that recent GHCs come with two base packages (since the packages differ in content, having both point to the same documentation location looks wrong to me, btw). >The haskell_doc.vim contains the following line, which seems to deal with >multiple lines: > > let field = substitute(system(g:ghc_pkg . ' field base haddock-html'),'\n','','') This just used to remove the final '\n', in the days when multiple versions of base were still unthinkable. What I'm really after in that part of the script is the location of the GHC docs, and the library index (the actual package docs are processed later). Unfortunately, past GHC versions haven't been too helpful (#1226, #1878, #1572), hence all that guesswork in my scripts (for a while, there was a ghc --print-docdir, but that didn't quite work and disappeared quickly, nowadays, there is the nice ghc-paths package, but that doesn't give a concrete path for docdir, so I still need to find the http top dir for GHC). I hadn't noticed this change, because (a) the scripts look in "likely suspects" for the docs location as well, and (b) the docs location can be configured (bypassing all that guesswork) by setting 'g:haddock_docdir' before loading the scripts (:help g:haddock_docdir, :help haskellmode-settings-fine). Using g:haddock_docdir to configure the right path for your installation is probably the least wrong thing to do for now, and requires no changes to the scripts, but I'll have a look at how to improve the guesswork code for convenience, looking at the first match only or looking for the relevant directories in all matches.. Thanks for the report! Claus From haskell at list.mightyreason.com Tue Apr 7 09:48:45 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Tue Apr 7 09:35:55 2009 Subject: [Haskell-cafe] Re: Parallel combinator, performance advice In-Reply-To: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> Message-ID: <49DB59BD.6040201@list.mightyreason.com> Neil Mitchell wrote: > Sorry, accidentally sent before finishing the response! I also noticed > you sent this directly to me, not to -cafe, was that intentional? The mail/news gateway makes it look like that, but I also sent to the mailing list. > You mean something like: > > parallel_ xs = > sem <- createSemapore (length xs) > enqueue [x >> signalSemapore sem | x <- xs] > waitOnSemaphore sem > > I thought of something like this, but then the thread that called > parallel_ is blocked, which means if you fire off N threads you only > get N-1 executing. If you have nested calls to parallel, then you end > up with thread exhaustion. Is there a way to avoid that problem? > > Thanks > > Neil Your parallel_ does not return until all operations are finished. > parallel_ (x:xs) = do > ys <- mapM idempotent xs > mapM_ addParallel ys > sequence_ $ x : reverse ys By the way, there is no obvious reason to insert "reverse" there. What I meant was something like: > > para [] = return () > para [x] = x > para xs = do > q <- newQSemN 0 > let wrap x = finally x (signalQSemN q 1) > go [y] n = wrap x >> waitQSemN q (succ n) > go (y:ys) n = addParallel (wrap y) >> go ys $! succ n > go xs 0 This is nearly identical to your code, and avoid creating the MVar for each operation. I use "finally" to ensure the count is correct, but if a worker threads dies then bas things will happen. You can replace finally with (>>) if speed is important. This is also lazy since the length of the list is not forced early. From jonathanccast at fastmail.fm Tue Apr 7 09:57:41 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Tue Apr 7 09:44:33 2009 Subject: [Haskell-cafe] System.Process.Posix In-Reply-To: <404396ef0904070631o78306bcie2790a0b2c8f9e85@mail.gmail.com> References: <20481029.20090405002136@gmail.com> <49DB52AF.10307@complete.org> <404396ef0904070631o78306bcie2790a0b2c8f9e85@mail.gmail.com> Message-ID: <1239112661.6303.0.camel@jonathans-macbook> On Tue, 2009-04-07 at 14:31 +0100, Neil Mitchell wrote: > Hi > > >>> Is it me or the above package is not included in Hoogle? > >> > >> afair, Neil, being windows user, includes only packages available for > >> his own system > >> > >> there was a large thread a few months ago and many peoples voted for > >> excluding any OS-specific packages at all since this decreases > >> portability of code developed by Hoogle users :))) > > > > Urm, I realize that was half in jest, but no. It just makes Hoogle less > > useful. If I need to fork, I need to fork, and no amount of > > sugarcoating is going to get around that. > > I was implementing full package support last weekend. With any luck, > I'll manage to push the changes tonight. If not, I'll push them as > soon as I get back from holiday (a week or so) Yay! jcc From claus.reinke at talk21.com Tue Apr 7 10:04:40 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Apr 7 09:51:40 2009 Subject: [Haskell-cafe] Strange type error with associated type synonyms References: <646230a00904061436x41af1055se39e8892eb4e3083@mail.gmail.com><4580278B-D5B6-4A4E-9233-415B57F60A3E@cse.unsw.edu.au><1bc51a990904070348p7e6fc849qeaa45b155279e435@mail.gmail.com> Message-ID: <9DC371FCEE914C19966965FB38881AC1@cr3lt> > Basically, type checking proceeds in one of two modes: inferring or > checking. The former is when there is no signature is given; the > latter, if there is a user-supplied signature. GHC can infer > ambiguous signatures, but it cannot check them. This is of course > very confusing and we need to fix this (by preventing GHC from > inferring ambiguous signatures). The issue is also discussed in the > mailing list thread I cited in my previous reply. As the error message demonstrates, the inferred type is not correctly represented - GHC doesn't really infer an ambiguous type, it infers a type with a specific idea of what the type variable should match. Representing that as an unconstrained forall-ed type variable just doesn't seem accurate (as the unconstrained type variable won't match the internal type variable) and it is this misrepresentation of the inferred type that leads to the ambiguity. Here is a variation to make this point clearer: {-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE TypeFamilies, ScopedTypeVariables #-} class Fun d where type Memo d :: * -> * abst :: (d -> a) -> Memo d a appl :: Memo d a -> (d -> a) f = abst . appl -- f' :: forall d a. (Fun d) => Memo d a -> Memo d a f' = abst . (id :: (d->a)->(d->a)) . appl There is a perfectly valid type signature for f', as given in comment, but GHCi gives an incorrect one (the same as for f): *Main> :browse Main class Fun d where abst :: (d -> a) -> Memo d a appl :: Memo d a -> d -> a f :: (Fun d) => Memo d a -> Memo d a f' :: (Fun d) => Memo d a -> Memo d a What I suspect is that GHCi does infer the correct type, with constrained 'd', but prints it incorrectly (no forall to indicate the use of scoped variable). Perhaps GHCi should always indicate in its type output which type variables have been unified with type variables that no longer occur in the output type (here the local 'd'). If ScopedTypeVariables are enabled, that might be done via explicit forall, if the internal type variable occurs in the source file (as for f' here). Otherwise, one might use type equalities. In other words, I'd expect :browse output more like this: f :: forall a d. (Fun d, d~_d) => Memo d a -> Memo d a f' :: forall a d. (Fun d) => Memo d a -> Memo d a making the first signature obviously ambiguous, and the second signature simply valid. Claus From claus.reinke at talk21.com Tue Apr 7 10:09:08 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Apr 7 09:56:08 2009 Subject: [Haskell-cafe] UPDATE: haskellmode for Vim now atprojects.haskell.org (+screencast; -) References: <38C7795C42FF4C8CA587C95603632431@cr3lt> <20090407122907.GZ25888@katherina.student.utwente.nl> <20090407134144.GC25888@katherina.student.utwente.nl> Message-ID: <369A4B15C378478CB8721E960187EC2A@cr3lt> Matthijs, thanks for the reports, and analyses and suggested patches are even better! We should probably take this offlist at some point, though. >I've found two more little bugs. The first is that version comparison is >incorrect. It now requires that all components are greater, so comparing >6.10.1 >= 6.8.2 returns false (since 1 < 2). quite right! will fix. >Also, there is a "ghc-pkg field * haddock-html" call, but here the * will be >expanded by the shell into the files in the current directory. To prevent >this, the * should be escaped. there is a comment in there suggesting that escaping was the wrong thing to do on some configurations/platforms (obviously, the current code works on my platform, so I depend on reports from users on other platforms), but I can't recall what the issue was at the moment. Will have to check, and implement a platform-specific solution, if necessary. >I'm also looking at the Qualify() function, which allows you to select a >qualification using tab completion. However, when there is only a single >choice, its a bit silly to have to use tabcompletion. At the very least, the >value should be prefilled, but ideally the qualification should just happen. Yes, that has been requested before, at least as an option (see the file haskellmode-files.txt for other open issues and change log). But it should be done consistently for all menus (all functions, and both GUI and terminal mode). >Also, I think that a dropdown menu is also available in text mode vim (at >least with vim7), which would be nice for multiple choices (since you can >see all choices in one glance). There is a note on using :emenu instead of the old home-brewn haskellmode-files.txt menu code. I would generally want to clean up the script code (some of which is very old), and factor out the handling of menus into a single place before making these changes. >I'll have a look at these things as well, expect another patch :-) Looking forward to it!-) Claus From ekmett at gmail.com Tue Apr 7 10:10:49 2009 From: ekmett at gmail.com (Edward Kmett) Date: Tue Apr 7 09:57:41 2009 Subject: [Haskell-cafe] Re: Configuring cabal dependencies at install-time In-Reply-To: <20090407132056.GE2207@colquitt.org> References: <9979e72e0904070218p7934efd7sa72b2fc348d27ca9@mail.gmail.com> <20090407132056.GE2207@colquitt.org> Message-ID: <7fb8f82f0904070710w23714a0erda6ae22b1f31c121@mail.gmail.com> This has been a lot on my mind lately as my current library provides additional functionality to data types from a wide array of other packages. I face a version of Wadler's expression problem. I provide a set of classes for injecting into monoids/seminearrings/etc. to allow for quick reductions over different data structures. The problem is that of course the interfaces are fairly general so whole swathes of types (including every applicative functor!) qualifies for certain operations. Perhaps the ultimate answer would be to push more of the instances down into the source packages. I can do this with some of the monoid instances, but convincing folks of the utility of the fact that their particular applicative forms a right-seminearring when it contains a monoid is another matter entirely. The problem is there is no path to get there from here. Getting another library to depend on mine, they have to pick up the brittle dependency set I have now. Splitting my package into smaller packages fails because I need to keep the instances for 3rd party data types packed with the class definitions to avoid orphan instances and poor API design. So the option to split things into the equivalent of 'buster-ui', 'buster-network' and so forth largely fails on that design criterion. I can do that for new monoids, rings and so forth that I define that purely layer on top of the base functionality I provide, but not for ones that provide additional instances for 3rd party data types. I can keep adding libraries as dependencies like I am doing now, but that means that my library continues to accrete content at an alarming rate and more importantly every one introduces a greater possibility of build issues, because I can only operate in an environment where every one of my dependencies can install. This further exacerbates the problem that no one would want to add all of my pedantic instances because to do so they would have to inject a huge brittle dependency into their package. The only other alternative that I seem to have at this point in the cabal packaging system is to create a series of flags for optional functionality. This solves _my_ problem, in particular it lets me install on a much broader base of environments, but now the order in which my package was installed with respect to its dependencies matters. In particular, clients of the library won't know if they have access to half of the instances, and so are stuck limiting themselves to working either on a particular computer, or using the intersection of the functionality I can provide. Perhaps, what I would ideally like to have would be some kind of 'augments' or 'codependencies' clause in the cabal file inside of flags and build targets that indicates packages that should force my package to reinstall after a package matching the version range inside the codependencies clause is installed or at least prompt indicatig that new functionality would be available and what packages you should reinstall. This would let me have my cake and eat it too. I could provide a wide array of instances for different stock data types, and I could know that if someone depends on both, say, 'monoids' and 'parsec 3' that the parsec instances will be present and usable in my package. Most importantly, it would allow me to fix my 'expression problem'. Others could introduce dependencies on the easier to install library allowing me to shrink the library and I would be able to install in more environments. -Edward Kmett On Tue, Apr 7, 2009 at 9:20 AM, John Dorsey wrote: > John Lato wrote: > > I think that the proper solution is to break up libraries into > > separate packages as Jeff suggests (buster, buster-ui, etc.), but then > > the total packages on hackage would explode. I don't feel great about > > I thought about this a while back and came to the conclusion that the > package count should only grow by a small contant factor due to this, > and that's a lot better than dealing with hairy and problematic > dependencies. > > It should usually be: > > libfoo > libfoo-blarg > libfoo-xyzzy > etc. > > and more rarely: > > libbar-with-xyzzy > libbar-no-xyzzy > etc. > > each providing libbar. Although I don't remember whether Cabal has > 'provides'. The latter case could explode exponentially for weird > packages that have several soft dependencies that can't be managed in > the plugin manner, but I can't see that being a real issue. > > This looks manageable to me, but I'm no packaging guru. I guess it's a > little harder for authors/maintainers of packages that look like leaves > in the dependency tree, which could be bad. Am I missing something bad? > > Regards, > John > > _______________________________________________ > 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/20090407/aea7d1f2/attachment.htm From ndmitchell at gmail.com Tue Apr 7 10:13:29 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Apr 7 10:00:22 2009 Subject: [Haskell-cafe] Re: Parallel combinator, performance advice In-Reply-To: <49DB59BD.6040201@list.mightyreason.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> Message-ID: <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> Hi > > The problem I'm trying to solve is running system commands in > > parallel. > "system commands" means execution of external commands or just system > calls inside Haskell? Calls to System.Cmd.system, i.e. running external console processes. It's a make system I'm writing, so virtually all the time is spent in calls to ghc etc. To Bulat: I should have been clearer with the spec. The idea is that multiple calls to paralell_ can execute, and a function executing inside parallel_ can itself call parallel_. For this reason I need one top-level thread pool, which requires unsafePerformIO. If I create a thread pool every time, I end up with more threads than I want. > Your parallel_ does not return until all operations are finished. > >> parallel_ (x:xs) = do >> ? ? ys <- mapM idempotent xs >> ? ? mapM_ addParallel ys >> ? ? sequence_ $ x : reverse ys > > By the way, there is no obvious reason to insert "reverse" there. There is a reason :-) Imagine I do parallel_ [a,b,c] That's roughly doing (if b' is idempotent b): enqueue b' enqueue c' a b' c' If while executing a the thread pool starts on b', then after I've finished a, I end up with both threads waiting for b', and nothing doing c'. If I do a reverse, then the thread pool and me are starting at different ends, so if we lock then I know it's something important to me that the thread pool started first. It's still not idea, but it happens less often. > What I meant was something like: >> >> para [] = return () >> para [x] = x >> para xs = do >> ? q <- newQSemN 0 >> ? let wrap x = finally x (signalQSemN q 1) >> ? ? ? go [y] n = wrap x >> waitQSemN q (succ n) >> ? ? ? go (y:ys) n = addParallel (wrap y) >> go ys $! succ n >> ? go xs 0 > > This is nearly identical to your code, and avoid creating the MVar for each > operation. ?I use "finally" to ensure the count is correct, but if a worker > threads dies then bas things will happen. ?You can replace finally with (>>) if > speed is important. Consider a thread pool with 2 threads and the call parallel_ [parallel_ [b,c],a] You get the sequence: enqueue (parallel_ [b,c]) a wait on parallel_ [b,c] While you are executing a, a thread pool starts: enqueue b c wait for b Now you have all the threads waiting, and no one dealing with the thread pool. This results in deadlock. I guess the "nested calls to parallel_" bit is the part of the spec that makes everything much harder! Thanks Neil From haskell at utr.dk Tue Apr 7 10:24:28 2009 From: haskell at utr.dk (Ulrik Rasmussen) Date: Tue Apr 7 10:11:37 2009 Subject: [Haskell-cafe] threadDelay granularity In-Reply-To: References: <20090407114134.GA6497@squish> <20090407132104.GC6497@squish> Message-ID: <20090407142428.GD6497@squish> On Tue, Apr 07, 2009 at 04:01:01PM +0200, Peter Verswyvelen wrote: > Are you on Windows? Because this might be because GHC is not using a high > resolution timer for doing its scheduling, I don't know... No, Ubuntu 8.10. That may very well be, I'm not that much into the details of GHC. I'm thinking about importing a system dependent delay method through the FFI to get more control over the delay interval, but that seems like overkill too. Also, I don't know if that would introduce some nasty problems, again, I'm not that into the inner workings of GHC. For now I'll just allow the application to render as fast as possible, the primary motivation for capping the framerate was to prevent my laptop from getting so hot that I can't have it in my lap :). (I see that I replied to you instead of to the list by accident. I'm CC'ing the message to the list now) /Ulrik > On Tue, Apr 7, 2009 at 3:21 PM, Ulrik Rasmussen wrote: > > > On Tue, Apr 07, 2009 at 02:53:20PM +0200, Peter Verswyvelen wrote: > > > I think this is an RTS option. > > > > > http://www.haskell.org/ghc/docs/latest/html/users_guide/using-concurrent.html > > > > Ahh, I found it now. Seems like the `-C' option didn't work because it > > still limited by the master tick interval. Using `+RTS -V0.001' helps. > > It is a bit inaccurate at that resolution though. > > > > > > > > > > > > > > On Tue, Apr 7, 2009 at 1:41 PM, Ulrik Rasmussen wrote: > > > > > > > Hello. > > > > > > > > I am writing a simple game in Haskell as an exercise, and in the > > > > rendering loop I want to cap the framerate to 60fps. I had planned to > > do > > > > this with GHC.Conc.threadDelay, but looking at it's documentation, I > > > > discovered that it can only delay the thread in time spans that are > > > > multiples of 20ms: > > > > > > > > > > > > > > http://www.haskell.org/ghc/docs/6.4/html/libraries/base/Control.Concurrent.html > > > > > > > > I need a much finer granularity than that, so I wondered if it is > > > > possible to either get a higher resolution for threadDelay, or if there > > > > is an alternative to threadDelay? > > > > > > > > I noticed that the SDL library includes the function "delay", which > > > > indeed works with a resolution down to one millisecond. However, since > > > > I'm using HOpenGL and GLUT, I think it would be a little overkill to > > > > depend on SDL just for this :). > > > > > > > > > > > > Thanks, > > > > > > > > Ulrik Rasmussen > > > > _______________________________________________ > > > > Haskell-Cafe mailing list > > > > Haskell-Cafe@haskell.org > > > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > From bugfact at gmail.com Tue Apr 7 10:34:22 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Apr 7 10:21:15 2009 Subject: [Haskell-cafe] threadDelay granularity In-Reply-To: <20090407114134.GA6497@squish> References: <20090407114134.GA6497@squish> Message-ID: Do you want to cap the rendering framerate at 60FPS or the animation framerate? Because when you use OpenGL and GLFW, you can just GLFW.swapInterval $= 1 to cap the rendering framerate at the refresh rate of your monitor or LCD screen (usually 60Hz) On Tue, Apr 7, 2009 at 1:41 PM, Ulrik Rasmussen wrote: > Hello. > > I am writing a simple game in Haskell as an exercise, and in the > rendering loop I want to cap the framerate to 60fps. I had planned to do > this with GHC.Conc.threadDelay, but looking at it's documentation, I > discovered that it can only delay the thread in time spans that are > multiples of 20ms: > > > http://www.haskell.org/ghc/docs/6.4/html/libraries/base/Control.Concurrent.html > > I need a much finer granularity than that, so I wondered if it is > possible to either get a higher resolution for threadDelay, or if there > is an alternative to threadDelay? > > I noticed that the SDL library includes the function "delay", which > indeed works with a resolution down to one millisecond. However, since > I'm using HOpenGL and GLUT, I think it would be a little overkill to > depend on SDL just for this :). > > > Thanks, > > Ulrik Rasmussen > _______________________________________________ > 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/20090407/9aa290d4/attachment.htm From ekmett at gmail.com Tue Apr 7 10:45:07 2009 From: ekmett at gmail.com (Edward Kmett) Date: Tue Apr 7 10:32:00 2009 Subject: [Haskell-cafe] advice on space efficient data structure with efficient snoc operation In-Reply-To: <49DB3DE4.9090300@libero.it> References: <49DB3DE4.9090300@libero.it> Message-ID: <7fb8f82f0904070745m158715f4xe8e5beaaf2b8830c@mail.gmail.com> I'm in the process of adding a Data.Sequence.Unboxed to unboxed-containers. I hope to have it in hackage today or tomorrow, should its performance work out as well as Data.Set.Unboxed. Be warned the API will likely be shifting on you for a little while, while I figure out a better way to manage all of the instances. -Edward Kmett On Tue, Apr 7, 2009 at 7:49 AM, Manlio Perillo wrote: > Hi. > > I'm still working on my Netflix Prize project. > > For a function I wrote, I really need a data structure that is both space > efficient (unboxed elements) and with an efficient snoc operation. > > I have pasted a self contained module with the definition of the function > I'm using: > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3453 > > > The movie ratings are loaded from serialized data, and the result is > serialized again, using the binary package: > > transcodeIO :: IO () > transcodeIO = do > input <- L.hGetContents stdin > let output = encodeZ $ transcode $ decodeZ input > L.hPut stdout output > > (here encodeZ and decodeZ are wrappers around Data.Binary.encode and > Data.Binary.decode, with support to gzip compression/decompression) > > > This function (transcodeIO, not transcode) takes, on my > Core2 CPU T7200 @ 2.00GHz: > > real 30m8.794s > user 29m30.659s > sys 0m10.313s > > 1068 Mb total memory in use > > > The problem here is with snocU, that requires a lot of copying. > > I rewrote the transcode function so that the input data set is split in N > parts: > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3453#a3456 > > The mapReduce function is the one defined in the Real World Haskell. > > > The new function takes (using only one thread): > > real 18m48.039s > user 18m30.901s > sys 0m6.520s > > 1351 Mb total memory in use > > > The additional required memory is probably caused by unionsWith, that is > not strict. > The function takes less time, since array copying is optimized. > I still use snocU, but on small arrays. > > GC time is very high: 54.4% > > > Unfortunately I can not test with more then one thread, since I get > segmentation faults (probably a bug with uvector packages). > > I also got two strange errors (but this may be just the result of the > segmentation fault, I'm not able to reproduce them): > > tpp.c:63: __pthread_tpp_change_priority: Assertion `new_prio == -1 || > (new_prio >= __sched_fifo_min_prio && new_prio <= __sched_fifo_max_prio)' > failed. > > > internal error: removeThreadFromQueue: not found > (GHC version 6.8.2 for i386_unknown_linux) > Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug > > > > Now the question is: what data structure should I use to optimize the > transcode function? > > IMHO there are two solutions: > > 1) Use a "lazy" array. > Something like ByteString.Lazy, and what is available in > storablevector package. > > Using this data structure, I can avoid the use of appendU. > > 2) Use an "unboxed" list. > > Something like: > http://mdounin.ru/hg/nginx-vendor-current/file/tip/src/core/ngx_list.h > > That is: a linked list of unboxed arrays, but unlike the lazy array > solution, a snoc operation avoid copying if there is space in the > current array. > > I don't know if this is easy/efficient to implement in Haskell. > > > Any other suggestions? > > > Thanks Manlio Perillo > _______________________________________________ > 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/20090407/0e1f0142/attachment.htm From simonpj at microsoft.com Tue Apr 7 10:45:08 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Tue Apr 7 10:32:07 2009 Subject: [Haskell-cafe] Strange type error with associated type synonyms In-Reply-To: <9DC371FCEE914C19966965FB38881AC1@cr3lt> References: <646230a00904061436x41af1055se39e8892eb4e3083@mail.gmail.com><4580278B-D5B6-4A4E-9233-415B57F60A3E@cse.unsw.edu.au><1bc51a990904070348p7e6fc849qeaa45b155279e435@mail.gmail.com> <9DC371FCEE914C19966965FB38881AC1@cr3lt> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C335080DECA1@EA-EXMSG-C334.europe.corp.microsoft.com> | Here is a variation to make this point clearer: | | {-# LANGUAGE NoMonomorphismRestriction #-} | {-# LANGUAGE TypeFamilies, ScopedTypeVariables #-} | | class Fun d where | type Memo d :: * -> * | abst :: (d -> a) -> Memo d a | appl :: Memo d a -> (d -> a) | | f = abst . appl | | -- f' :: forall d a. (Fun d) => Memo d a -> Memo d a | f' = abst . (id :: (d->a)->(d->a)) . appl | | There is a perfectly valid type signature for f', as given in | comment, but GHCi gives an incorrect one (the same as for f): | | *Main> :browse Main | class Fun d where | abst :: (d -> a) -> Memo d a | appl :: Memo d a -> d -> a | f :: (Fun d) => Memo d a -> Memo d a | f' :: (Fun d) => Memo d a -> Memo d a I'm missing something here. Those types are identical to the one given in your type signature for f' above, save that the forall is suppressed (because you are allowed to omit it, and GHC generally does when printing types). I must be missing the point. Simon From icfp.publicity at googlemail.com Tue Apr 7 10:50:26 2009 From: icfp.publicity at googlemail.com (Matthew Fluet (ICFP Publicity Chair)) Date: Tue Apr 7 10:37:25 2009 Subject: [Haskell-cafe] CFP: JFP Special Issue on Generic Programming Message-ID: <53ff55480904070750n60637431id708029c6bebcabe@mail.gmail.com> OPEN CALL FOR PAPERS JFP Special Issue on Generic Programming Deadline: 1 October 2009 http://www.comlab.ox.ac.uk/ralf.hinze/JFP/cfp.html Scope ----- Generic programming is about making programs more adaptable by making them more general. Generic programs often embody non-traditional kinds of polymorphism; ordinary programs are obtained from them by suitably instantiating their parameters. In contrast to normal programs, the parameters of a generic program are often quite rich in structure; for example they may be other programs, types or type constructors, classes, concepts, or even programming paradigms. This special issue aims at documenting state-of-the-art research, new developments and directions for future investigation in the broad field of Generic Programming. It is an outgrowth of the series of Workshops on Generic Programming, which started in 1998 and which continues this year with an ICFP affiliated workshop in Edinburgh. Participants of the workshops are invited to submit a suitably revised and expanded version of their paper to the special issue. The call for papers is, however, open. Other contributions are equally welcome and are, indeed, encouraged. All submitted papers will be subjected to the same quality criteria, meeting the standards of the Journal of Functional Programming. The special issue seeks original contributions on all aspects of generic programming including but not limited to o adaptive object-oriented programming, o aspect-oriented programming, o case studies, o concepts (as in the STL/C++ sense), o component-based programming, o datatype-generic programming, o generic programming with dependent types, o meta-programming, o polytypic programming, and o programming with modules. Submission details ------------------ Manuscripts should be unpublished works and not submitted elsewhere. Revised versions of papers published in conference or workshop proceedings that have not appeared in archival journals are eligible for submission. Deadline for submission: 1 October 2009 Notification of acceptance or rejection: 15 January 2010 Revised version due: 15 March 2010 For submission details, please consult http://www.comlab.ox.ac.uk/ralf.hinze/JFP/cfp.html or see the Journal's web page http://journals.cambridge.org/jfp Guest Editor ------------ Ralf Hinze University of Oxford Computing Laboratory Wolfson Building, Parks Road, Oxford OX1 3QD, UK. Telephone: +44 (1865) 610700 Fax: +44 (1865) 283531 Email: ralf.hinze@comlab.ox.ac.uk WWW: http://www.comlab.ox.ac.uk/ralf.hinze/ ------------------------------------------------------------------------------- From bulat.ziganshin at gmail.com Tue Apr 7 10:50:14 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Apr 7 10:37:28 2009 Subject: [Haskell-cafe] Re[2]: Parallel combinator, performance advice In-Reply-To: <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> Message-ID: <29485438.20090407185014@gmail.com> Hello Neil, Tuesday, April 7, 2009, 6:13:29 PM, you wrote: > Calls to System.Cmd.system, i.e. running external console processes. > It's a make system I'm writing, so virtually all the time is spent in > calls to ghc etc. > To Bulat: I should have been clearer with the spec. The idea is that > multiple calls to paralell_ can execute, and a function executing > inside parallel_ can itself call parallel_. For this reason I need one > top-level thread pool, which requires unsafePerformIO. If I create a > thread pool every time, I end up with more threads than I want. this is smth new to solve i propose to use concept similar to Capability of GHC RTS: we have one Capability provided by thread calling para and N-1 Capabilities provided by your thread pool. all that we need is to reuse current thread Capability as part of pool! para xs = do sem <- newQSem for xs $ \x -> do writeChan chan (x `finally` signalQSem sem) tid <- forkIO (executing commands from chan...) waitQSem sem killThread tid instead of killThread we really should send pseudo-job (like my Nothing value) that will led to self-killing of job that gets this signal this solution still may lead to a bit more or less than N threads executed at the same time. your turn! -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From pwberry at gmail.com Tue Apr 7 10:55:17 2009 From: pwberry at gmail.com (Peter Berry) Date: Tue Apr 7 10:42:09 2009 Subject: [Haskell-cafe] Strange type error with associated type synonyms In-Reply-To: <2f9b2d30904061707v5b37eb73nceb87c7d1bcc50bf@mail.gmail.com> References: <646230a00904061436x41af1055se39e8892eb4e3083@mail.gmail.com> <2f9b2d30904061707v5b37eb73nceb87c7d1bcc50bf@mail.gmail.com> Message-ID: <646230a00904070755g489e754dsc6be73d91b7911e3@mail.gmail.com> On 07/04/2009, Ryan Ingram wrote: > On Mon, Apr 6, 2009 at 2:36 PM, Peter Berry wrote: >> As I understand it, the type checker's thought process should be along >> these lines: >> >> 1) the type signature dictates that x has type Memo d a. >> 2) appl has type Memo d1 a -> d1 -> a for some d1. >> 3) we apply appl to x, so Memo d1 a = Memo d a. unify d = d1 > > This isn't true, though, and for similar reasons why you can't declare > a generic "instance Fun d => Functor (Memo d)". Type synonyms are not > injective; you can have two instances that point at the same type: Doh! I'm too used to interpreting words like "Memo" with an initial capital as constructors, which are injective, when it's really a function, which need not be. > You can use a data family instead, and then you get the property you > want; if you make Memo a data family, then Memo d1 = Memo d2 does > indeed give you d1 = d2. I'm now using Data.MemoTrie, which indeed uses data families, instead of a home-brewed solution, and now GHC accepts the type signature. In fact, it already has a Functor instance, so funmap is redundant. -- Peter Berry Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html From claus.reinke at talk21.com Tue Apr 7 10:59:07 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Apr 7 10:46:06 2009 Subject: [Haskell-cafe] Strange type error with associated type synonyms References: <646230a00904061436x41af1055se39e8892eb4e3083@mail.gmail.com><4580278B-D5B6-4A4E-9233-415B57F60A3E@cse.unsw.edu.au><1bc51a990904070348p7e6fc849qeaa45b155279e435@mail.gmail.com> <9DC371FCEE914C19966965FB38881AC1@cr3lt> <638ABD0A29C8884A91BC5FB5C349B1C335080DECA1@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <3E3186D9A0F34311825C9D476DB9F1D9@cr3lt> | Here is a variation to make this point clearer: | | {-# LANGUAGE NoMonomorphismRestriction #-} | {-# LANGUAGE TypeFamilies, ScopedTypeVariables #-} | | class Fun d where | type Memo d :: * -> * | abst :: (d -> a) -> Memo d a | appl :: Memo d a -> (d -> a) | | f = abst . appl | | -- f' :: forall d a. (Fun d) => Memo d a -> Memo d a | f' = abst . (id :: (d->a)->(d->a)) . appl | | There is a perfectly valid type signature for f', as given in | comment, but GHCi gives an incorrect one (the same as for f): | | *Main> :browse Main | class Fun d where | abst :: (d -> a) -> Memo d a | appl :: Memo d a -> d -> a | f :: (Fun d) => Memo d a -> Memo d a | f' :: (Fun d) => Memo d a -> Memo d a >I'm missing something here. Those types are identical to the one given >in your type signature for f' above, save that the forall is suppressed >(because you are allowed to omit it, and GHC generally does when >printing types). Not with ScopedTypeVariables, though, where explicit foralls have been given an additional significance. Uncommenting the f' signature works, while dropping the 'forall d a' from it fails with the usual match failure due to ambiguity "Couldn't match expected type `Memo d1' against inferred type `Memo d'". >I must be missing the point. The point was in the part you didn't quote: |In other words, I'd expect :browse output more like this: | |f :: forall a d. (Fun d, d~_d) => Memo d a -> Memo d a |f' :: forall a d. (Fun d) => Memo d a -> Memo d a | |making the first signature obviously ambiguous, and the |second signature simply valid. Again, the validity of the second signature depends on ScopedTypeVariables - without that, both f and f' should get a signature similar to the first one (or some other notation that implies that 'd' isn't freely quantified, but must match a non-accessible '_d'). Claus From bulat.ziganshin at gmail.com Tue Apr 7 11:00:47 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Apr 7 10:47:58 2009 Subject: [Haskell-cafe] Re[3]: Parallel combinator, performance advice In-Reply-To: <29485438.20090407185014@gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> <29485438.20090407185014@gmail.com> Message-ID: <1262925074.20090407190047@gmail.com> Hello Bulat, Tuesday, April 7, 2009, 6:50:14 PM, you wrote: > tid <- forkIO (executing commands from chan...) > waitQSem sem > killThread tid > instead of killThread we really should send pseudo-job (like my > Nothing value) that will led to self-killing of job that gets this > signal > this solution still may lead to a bit more or less than N threads > executed at the same time. your turn! solved! every job should go together with Bool flag `killItself`. last job should have this flag set to True. thread will execute job and kill itself if this flag is True. so we get strong guarantees that there are exactly N threads in the system: para xs = do sem <- newQSem for (init xs) $ \x -> do writeChan chan (x `finally` signalQSem sem, False) writeChan chan (last x `finally` signalQSem sem, True) -- tid <- forkIO $ do let cycle = do (x,flag) <- readChan chan x unless flag cycle cycle -- waitQSem sem btw, this problem looks a great contribution into "Haskell way" book of exercises -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From haskell at list.mightyreason.com Tue Apr 7 11:01:33 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Tue Apr 7 10:48:31 2009 Subject: [Haskell-cafe] Re: Parallel combinator, performance advice In-Reply-To: <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> Message-ID: <49DB6ACD.8070000@list.mightyreason.com> Neil Mitchell wrote: > > I guess the "nested calls to parallel_" bit is the part of the spec > that makes everything much harder! > > Thanks > > Neil Yes. Much more annoying. But the problem here is generic. To avoid it you must never allow all thread to block at once. The parallel_ function is such a job, so you solved this with the 'idempotent' trick. You solution works by blocking all but 1 thread. 1a) Some worker thread 1 executes parallel_ with some jobs 1b) These get submitted the work queue 'chan' 1c) worker thread 1 starts on those same jobs, ignoring the queue 1d) worker thread 1 reaches the job being processed by thread 2 1e) worker thread 1 blocks until the jobs is finished in modifyMVar 2a) Worker thread 2 grabs a job posted by thread 1, that calls parallel_ 2b) This batch of jobs gets submitted to the work queue 'chan' 2c) worker thread 2 starts on those same jobs, ignoring the queue 1d) worker thread 2 reaches the job being processed by thread 3 1e) worker thread 2 blocks until the jobs is finished in modifyMVar 3...4...5... And now only 1 thread is still working, and it has to work in series. I think I can fix this... From haskell at list.mightyreason.com Tue Apr 7 11:01:33 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Tue Apr 7 10:48:45 2009 Subject: [Haskell-cafe] Re: Parallel combinator, performance advice In-Reply-To: <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> Message-ID: <49DB6ACD.8070000@list.mightyreason.com> Neil Mitchell wrote: > > I guess the "nested calls to parallel_" bit is the part of the spec > that makes everything much harder! > > Thanks > > Neil Yes. Much more annoying. But the problem here is generic. To avoid it you must never allow all thread to block at once. The parallel_ function is such a job, so you solved this with the 'idempotent' trick. You solution works by blocking all but 1 thread. 1a) Some worker thread 1 executes parallel_ with some jobs 1b) These get submitted the work queue 'chan' 1c) worker thread 1 starts on those same jobs, ignoring the queue 1d) worker thread 1 reaches the job being processed by thread 2 1e) worker thread 1 blocks until the jobs is finished in modifyMVar 2a) Worker thread 2 grabs a job posted by thread 1, that calls parallel_ 2b) This batch of jobs gets submitted to the work queue 'chan' 2c) worker thread 2 starts on those same jobs, ignoring the queue 1d) worker thread 2 reaches the job being processed by thread 3 1e) worker thread 2 blocks until the jobs is finished in modifyMVar 3...4...5... And now only 1 thread is still working, and it has to work in series. I think I can fix this... From sebastian.sylvan at gmail.com Tue Apr 7 11:02:55 2009 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Tue Apr 7 10:49:47 2009 Subject: [Haskell-cafe] Parallel combinator, performance advice In-Reply-To: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> Message-ID: <3d96ac180904070802g551d0cbfo2876a96b9f5e045f@mail.gmail.com> This is a random idea, that's probably not going to work, but I don't have a way of testing it so I'll just post it! How about using unsafeInterleaveIO to get a lazy suspension of the result of each action, and then using par to spark off each of them? If that works you can reuse the existing task-parallel system of GHC to do the heavily lifting for you, instead of having to write your own. On Tue, Apr 7, 2009 at 11:25 AM, Neil Mitchell wrote: > Hi, > > I've written a parallel_ function, code attached. I'm looking for > criticism, suggestions etc on how to improve the performance and > fairness of this parallel construct. (If it turns out this construct > is already in a library somewhere, I'd be interested in that too!) > > The problem I'm trying to solve is running system commands in > parallel. Importantly (unlike other Haskell parallel stuff) I'm not > expecting computationally heavy Haskell to be running in the threads, > and only want a maximum of n commands to fire at a time. The way I'm > trying to implement this is with a parallel_ function: > > parallel_ :: [IO a] -> IO () > > The semantics are that after parallel_ returns each action will have > been executed exactly once. The implementation (attached) creates a > thread pool of numCapabililties-1 threads, each of which reads from a > task pool and attempts to do some useful work. I use an idempotent > function to ensure that all work is done at most one, and a sequence_ > to ensure all work is done at least once. > > Running a benchmark of issuing 1 million trivial tasks (create, > modify, read and IO ref) the version without any parallelism is really > fast (< 0.1 sec), and the version with parallelism is slow (> 10 sec). > This could be entirely due to space leaks etc when queueing many > tasks. > > I'm useful for any thoughts people might have! > > Thanks in advance, > > Neil > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090407/6b18f0c2/attachment.htm From manlio_perillo at libero.it Tue Apr 7 11:07:50 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Tue Apr 7 10:55:10 2009 Subject: [Haskell-cafe] advice on space efficient data structure with efficient snoc operation In-Reply-To: <7fb8f82f0904070745m158715f4xe8e5beaaf2b8830c@mail.gmail.com> References: <49DB3DE4.9090300@libero.it> <7fb8f82f0904070745m158715f4xe8e5beaaf2b8830c@mail.gmail.com> Message-ID: <49DB6C46.8080704@libero.it> Edward Kmett ha scritto: > I'm in the process of adding a Data.Sequence.Unboxed to > unboxed-containers. I hope to have it in hackage today or tomorrow, > should its performance work out as well as Data.Set.Unboxed. > Looking at the data definition of Data.Sequence I suspect that it is not really space efficient. Please note that I have 480189 arrays, where each array has, on average, 209 (Word16 :*: Word8) elements. Using a [(Word32, UArr (Word16 :*: Word8))] takes about 800 MB (but it's hard to measure exact memory usage). > [...] Thanks Manlio From pwberry at gmail.com Tue Apr 7 11:09:29 2009 From: pwberry at gmail.com (Peter Berry) Date: Tue Apr 7 10:56:22 2009 Subject: [Haskell-cafe] Strange type error with associated type synonyms In-Reply-To: References: <646230a00904061436x41af1055se39e8892eb4e3083@mail.gmail.com> <4580278B-D5B6-4A4E-9233-415B57F60A3E@cse.unsw.edu.au> <1bc51a990904070348p7e6fc849qeaa45b155279e435@mail.gmail.com> Message-ID: <646230a00904070809u48db0cdfp3b748a08bfd5891b@mail.gmail.com> On Mon, Apr 6, 2009 at 7:39 PM, Manuel M T Chakravarty wrote: > Peter Berry: > >> 3) we apply appl to x, so Memo d1 a = Memo d a. unify d = d1 >> >> But for some reason, step 3 fails. > > Step 3 is invalid - cf, > . > > More generally, the signature of memo_fmap is ambiguous, and hence, > correctly rejected. We need to improve the error message, though. > Here is a previous discussion of the subject: > > http://www.mail-archive.com/haskell-cafe@haskell.org/msg39673.html Aha! Very informative, thanks. On 07/04/2009, Manuel M T Chakravarty wrote: > Matt Morrow: >> The thing that confuses me about this case is how, if the type sig >> on memo_fmap is omitted, ghci has no problem with it, and even gives >> it the type that it rejected: > > Basically, type checking proceeds in one of two modes: inferring or > checking. The former is when there is no signature is given; the > latter, if there is a user-supplied signature. GHC can infer > ambiguous signatures, but it cannot check them. This is of course > very confusing and we need to fix this (by preventing GHC from > inferring ambiguous signatures). The issue is also discussed in the > mailing list thread I cited in my previous reply. I see. So GHC is wrong to accept memo_fmap? -- Peter Berry Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html From bulat.ziganshin at gmail.com Tue Apr 7 11:22:55 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Apr 7 11:09:58 2009 Subject: [Haskell-cafe] Re[2]: Parallel combinator, performance advice In-Reply-To: <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> Message-ID: <1588416099.20090407192255@gmail.com> Hello Neil, Tuesday, April 7, 2009, 6:13:29 PM, you wrote: > Consider a thread pool with 2 threads and the call parallel_ [parallel_ [b,c],a] > You get the sequence: > enqueue (parallel_ [b,c]) > a > wait on parallel_ [b,c] > While you are executing a, a thread pool starts: > enqueue b > c > wait for b > Now you have all the threads waiting, and no one dealing with the > thread pool. This results in deadlock. i think the only way to solve this problem is to create one more thread each time. let's see: on every call to para you need to alloc one thread to wait for jobs completion. so on each nested call to para you have minus one worker thread. finally you will eat them all! so you need to make fork: one thread should serve jobs and another one wait for completion of this jobs bucket. and with killItself flag you will finish superfluous thread JIT -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From haskell at utr.dk Tue Apr 7 11:25:18 2009 From: haskell at utr.dk (Ulrik Rasmussen) Date: Tue Apr 7 11:12:16 2009 Subject: [Haskell-cafe] threadDelay granularity In-Reply-To: References: <20090407114134.GA6497@squish> Message-ID: <20090407152518.GE6497@squish> On Tue, Apr 07, 2009 at 04:34:22PM +0200, Peter Verswyvelen wrote: > Do you want to cap the rendering framerate at 60FPS or the animation > framerate? > Because when you use OpenGL and GLFW, you can just > > GLFW.swapInterval $= 1 > > to cap the rendering framerate at the refresh rate of your monitor or LCD > screen (usually 60Hz) I just want to cap the rendering framerate. The game logic is running in other threads, and sends rendering information via a Chan to the renderer. I'm using GLUT, and have never heard of GLFW. However, that seems to be a better tool to get the job done. I'll check it out, thanks :). /Ulrik > > > On Tue, Apr 7, 2009 at 1:41 PM, Ulrik Rasmussen wrote: > > > Hello. > > > > I am writing a simple game in Haskell as an exercise, and in the > > rendering loop I want to cap the framerate to 60fps. I had planned to do > > this with GHC.Conc.threadDelay, but looking at it's documentation, I > > discovered that it can only delay the thread in time spans that are > > multiples of 20ms: > > > > > > http://www.haskell.org/ghc/docs/6.4/html/libraries/base/Control.Concurrent.html > > > > I need a much finer granularity than that, so I wondered if it is > > possible to either get a higher resolution for threadDelay, or if there > > is an alternative to threadDelay? > > > > I noticed that the SDL library includes the function "delay", which > > indeed works with a resolution down to one millisecond. However, since > > I'm using HOpenGL and GLUT, I think it would be a little overkill to > > depend on SDL just for this :). > > > > > > Thanks, > > > > Ulrik Rasmussen > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From ndmitchell at gmail.com Tue Apr 7 11:33:25 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Apr 7 11:20:17 2009 Subject: [Haskell-cafe] Re: Re[2]: Parallel combinator, performance advice In-Reply-To: <1588416099.20090407192255@gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> <1588416099.20090407192255@gmail.com> Message-ID: <404396ef0904070833k75d2019cga4b6b0a1027e30ec@mail.gmail.com> Hi Sebastian: > How about using unsafeInterleaveIO to get a lazy suspension of the result of each action, > and then using par to spark off each of them? If that works you can reuse the existing > task-parallel system of GHC to do the heavily lifting for you, instead of having to write your > own. par is likely to spark all the computations, and then switch between them - which will mean I've got more than N things running in parallel. > i think the only way to solve this problem is to create one more > thread each time. let's see: on every call to para you need to alloc > one thread to wait for jobs completion. so on each nested call to para > you have minus one worker thread. finally you will eat them all! > > so you need to make fork: one thread should serve jobs and another one > wait for completion of this jobs bucket. and with killItself flag you > will finish superfluous thread JIT You are right, your previous solution was running at N-1 threads if the order was a little unlucky. I've attached a new version which I think gives you N threads always executing at full potential. It's basically your idea from the last post, with the main logic being: parallel_ (x1:xs) = do sem <- newQSem $ 1 - length xs forM_ xs $ \x -> writeChan queue (x >> signalQSem sem, False) x1 addWorker waitQSem sem writeChan queue (signalQSem sem, True) waitQSem sem Where the second flag being True = kill, as you suggested. I think I've got the semaphore logic right - anyone want to see if I missed something? With this new version running 1000000 items takes ~1 second, instead of ~10 seconds before, so an order of magnitude improvement, and greater fairness. Very nice, thanks for all the help! Thanks Neil -------------- next part -------------- A non-text attachment was scrubbed... Name: Parallel3.hs Type: application/octet-stream Size: 1462 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090407/72ac00a2/Parallel3.obj From bulat.ziganshin at gmail.com Tue Apr 7 11:40:37 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Apr 7 11:27:42 2009 Subject: [Haskell-cafe] Re[2]: Parallel combinator, performance advice In-Reply-To: <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> Message-ID: <2710724650.20090407194037@gmail.com> Hello Neil, Tuesday, April 7, 2009, 6:13:29 PM, you wrote: > Calls to System.Cmd.system, i.e. running external console processes. > It's a make system I'm writing, so virtually all the time is spent in > calls to ghc etc. btw, if all that you need is to limit amount of simultaneous System.Cmd.system calls, you may go from opposite side: wrap this call into semaphore: sem = unsafePerformIO$ newQSem numCapabilities mysystem = bracket_ (waitQSem sem) (signalQSem sem) . system and implement para as simple thread population: para = mapM_ forkIO -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ndmitchell at gmail.com Tue Apr 7 11:47:17 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Apr 7 11:34:09 2009 Subject: [Haskell-cafe] Re: Re[2]: Parallel combinator, performance advice In-Reply-To: <2710724650.20090407194037@gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> <2710724650.20090407194037@gmail.com> Message-ID: <404396ef0904070847k957010aubed3b267b62e8b95@mail.gmail.com> Hi Bulat, > btw, if all that you need is to limit amount of simultaneous > System.Cmd.system calls, you may go from opposite side: wrap this call > into semaphore: > > sem = unsafePerformIO$ newQSem numCapabilities > > mysystem = bracket_ (waitQSem sem) (signalQSem sem) . system > > and implement para as simple thread population: > > para = mapM_ forkIO My main motivation is to limit the number of system calls, but it's also useful from a user point of view if the system is doing a handful of things at a time - it makes it easier to track what's going on. I might try that tomorrow and see if it makes a difference to the performance. While the majority of computation is in system calls, quite a few of the threads open files etc, and having them all run in parallel would end up with way too many open handles etc. Thanks Neil From bulat.ziganshin at gmail.com Tue Apr 7 11:45:31 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Apr 7 11:37:16 2009 Subject: [Haskell-cafe] Re[4]: Parallel combinator, performance advice In-Reply-To: <404396ef0904070833k75d2019cga4b6b0a1027e30ec@mail.gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> <1588416099.20090407192255@gmail.com> <404396ef0904070833k75d2019cga4b6b0a1027e30ec@mail.gmail.com> Message-ID: <1114428267.20090407194531@gmail.com> Hello Neil, Tuesday, April 7, 2009, 7:33:25 PM, you wrote: >> How about using unsafeInterleaveIO to get a lazy suspension of the result of each action, >> and then using par to spark off each of them? If that works you can reuse the existing >> task-parallel system of GHC to do the heavily lifting for you, instead of having to write your >> own. > par is likely to spark all the computations, and then switch between > them - which will mean I've got more than N things running in > parallel. par/GHC RTS limits amount of Haskell threads running simultaneously. with a system call marked as safe, Capability will be freed while we execute external program so nothing will be limited except for amount of tasks *starting* (as opposite to running) simultaneously :))) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Tue Apr 7 11:50:08 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Apr 7 11:37:24 2009 Subject: [Haskell-cafe] Re[4]: Parallel combinator, performance advice In-Reply-To: <404396ef0904070833k75d2019cga4b6b0a1027e30ec@mail.gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> <1588416099.20090407192255@gmail.com> <404396ef0904070833k75d2019cga4b6b0a1027e30ec@mail.gmail.com> Message-ID: <159123388.20090407195008@gmail.com> Hello Neil, Tuesday, April 7, 2009, 7:33:25 PM, you wrote: > parallel_ (x1:xs) = do > sem <- newQSem $ 1 - length xs > forM_ xs $ \x -> > writeChan queue (x >> signalQSem sem, False) > x1 > addWorker > waitQSem sem > writeChan queue (signalQSem sem, True) > waitQSem sem > Where the second flag being True = kill, as you suggested. I think > I've got the semaphore logic right - anyone want to see if I missed > something? Neil, executing x1 directly in parallel_ is incorrect idea. you should have N worker threads, not N-1 threads plus one job executed in main thread. imagine that you have 1000 jobs and N=4. that you will got here is 3 threads each executed 333 jobs and 1 job executed by main thread so you still need to detach one more worker job and finish it just before we are ready to finish waiting for QSem and continue in main thread which is sole reason why we need killItself flag. in this code snipped this flag is completely useless, btw -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Tue Apr 7 11:58:24 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Apr 7 11:45:33 2009 Subject: [Haskell-cafe] Re[4]: Parallel combinator, performance advice In-Reply-To: <404396ef0904070847k957010aubed3b267b62e8b95@mail.gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> <2710724650.20090407194037@gmail.com> <404396ef0904070847k957010aubed3b267b62e8b95@mail.gmail.com> Message-ID: <8410491222.20090407195824@gmail.com> Hello Neil, Tuesday, April 7, 2009, 7:47:17 PM, you wrote: >> para = mapM_ forkIO > I might try that tomorrow and see if it makes a difference to the > performance. While the majority of computation is in system calls, > quite a few of the threads open files etc, and having them all run in > parallel would end up with way too many open handles etc. if you have too much threads, you may replace forkIO with one more QSem-enabled call: semIO = unsafePerformIO$ newQSem 100 myForkIO = bracket_ (waitQSem semIO) (signalQSem semIO) . forkIO this limit may be much higher than for System.Cmd.system or you may go further and replace it with thread pool approach. the main problem behind is raw calls to forkIO since these increases amount of threads capable to call System.Cmd.system without any control from us -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From duane.johnson at gmail.com Tue Apr 7 12:09:18 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Tue Apr 7 11:56:14 2009 Subject: [Haskell-cafe] threadDelay granularity In-Reply-To: <20090407152518.GE6497@squish> References: <20090407114134.GA6497@squish> <20090407152518.GE6497@squish> Message-ID: <76757B38-2258-4455-9DF3-598FDF6066A4@gmail.com> The Hipmunk 2D physics engine comes with a "playground" app which includes the following function: > -- | Advances the time. > advanceTime :: IORef State -> Double -> KeyButtonState -> IO Double > advanceTime stateVar oldTime slowKey = do > newTime <- get time > > -- Advance simulation > let slower = if slowKey == Press then slowdown else 1 > mult = frameSteps / (framePeriod * slower) > framesPassed = truncate $ mult * (newTime - oldTime) > simulNewTime = oldTime + toEnum framesPassed / mult > advanceSimulTime stateVar $ min maxSteps framesPassed > > -- Correlate with reality > newTime' <- get time > let diff = newTime' - simulNewTime > sleepTime = ((framePeriod * slower) - diff) / slower > when (sleepTime > 0) $ sleep sleepTime > return simulNewTime I think the "get time" is provided by GLFW. -- Duane Johnson On Apr 7, 2009, at 9:25 AM, Ulrik Rasmussen wrote: > On Tue, Apr 07, 2009 at 04:34:22PM +0200, Peter Verswyvelen wrote: >> Do you want to cap the rendering framerate at 60FPS or the animation >> framerate? >> Because when you use OpenGL and GLFW, you can just >> >> GLFW.swapInterval $= 1 >> >> to cap the rendering framerate at the refresh rate of your monitor >> or LCD >> screen (usually 60Hz) > > I just want to cap the rendering framerate. The game logic is > running in > other threads, and sends rendering information via a Chan to the > renderer. > > I'm using GLUT, and have never heard of GLFW. However, that seems to > be > a better tool to get the job done. I'll check it out, thanks :). > > /Ulrik > >> >> >> On Tue, Apr 7, 2009 at 1:41 PM, Ulrik Rasmussen >> wrote: >> >>> Hello. >>> >>> I am writing a simple game in Haskell as an exercise, and in the >>> rendering loop I want to cap the framerate to 60fps. I had planned >>> to do >>> this with GHC.Conc.threadDelay, but looking at it's documentation, I >>> discovered that it can only delay the thread in time spans that are >>> multiples of 20ms: >>> >>> >>> http://www.haskell.org/ghc/docs/6.4/html/libraries/base/Control.Concurrent.html >>> >>> I need a much finer granularity than that, so I wondered if it is >>> possible to either get a higher resolution for threadDelay, or if >>> there >>> is an alternative to threadDelay? >>> >>> I noticed that the SDL library includes the function "delay", which >>> indeed works with a resolution down to one millisecond. However, >>> since >>> I'm using HOpenGL and GLUT, I think it would be a little overkill to >>> depend on SDL just for this :). >>> >>> >>> Thanks, >>> >>> Ulrik Rasmussen >>> _______________________________________________ >>> 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 bulat.ziganshin at gmail.com Tue Apr 7 12:10:43 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Apr 7 11:57:50 2009 Subject: [Haskell-cafe] Re[5]: Parallel combinator, performance advice In-Reply-To: <159123388.20090407195008@gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> <1588416099.20090407192255@gmail.com> <404396ef0904070833k75d2019cga4b6b0a1027e30ec@mail.gmail.com> <159123388.20090407195008@gmail.com> Message-ID: <1869076800.20090407201043@gmail.com> Hello Bulat, Tuesday, April 7, 2009, 7:50:08 PM, you wrote: >> parallel_ (x1:xs) = do >> sem <- newQSem $ 1 - length xs >> forM_ xs $ \x -> >> writeChan queue (x >> signalQSem sem, False) >> x1 >> addWorker >> waitQSem sem >> writeChan queue (signalQSem sem, True) >> waitQSem sem > Neil, executing x1 directly in parallel_ is incorrect idea. forget this. but it still a bit suboptimal: after everything was finished, we schedule one more empty job and wait while some worker thread will pick up it. it will go into Chan after all jobs scheduled at the time our jobs was executed so that we are doing here is eventually don't do any internal activity while we have all N external programs running instead, my solution packed this flag together with last job so once last job is finished we are immediately returned from parallel_ so other internal activity may go on -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ndmitchell at gmail.com Tue Apr 7 12:36:33 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Apr 7 12:23:27 2009 Subject: [Haskell-cafe] Re: Re[5]: Parallel combinator, performance advice In-Reply-To: <1869076800.20090407201043@gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> <1588416099.20090407192255@gmail.com> <404396ef0904070833k75d2019cga4b6b0a1027e30ec@mail.gmail.com> <159123388.20090407195008@gmail.com> <1869076800.20090407201043@gmail.com> Message-ID: <404396ef0904070936r38a48a1aj51ffb4244e4780f8@mail.gmail.com> Hi > par is likely to spark all the computations, and then switch between > them - which will mean I've got more than N things running in > parallel. | par/GHC RTS limits amount of Haskell threads running simultaneously. | with a system call marked as safe, Capability will be freed while we | execute external program so nothing will be limited except for amount | of tasks *starting* (as opposite to running) simultaneously :))) Yeah, I misspoke - I want to avoid starting N things. >>> parallel_ (x1:xs) = do >>> ? ? sem <- newQSem $ 1 - length xs >>> ? ? forM_ xs $ \x -> >>> ? ? ? ? writeChan queue (x >> signalQSem sem, False) >>> ? ? x1 >>> ? ? addWorker >>> ? ? waitQSem sem >>> ? ? writeChan queue (signalQSem sem, True) >>> ? ? waitQSem sem > >> Neil, executing x1 directly in parallel_ is incorrect idea. It's a very slight optimisation, as it saves us queueing and dequeueing x1, since we know the worker we're about the spawn on the line below will grab x1 immediately. > forget this. but it still a bit suboptimal: after everything was > finished, we schedule one more empty job and wait while some worker > thread will pick up it. it will go into Chan after all jobs scheduled > at the time our jobs was executed so that we are doing here is > eventually don't do any internal activity while we have all N external > programs running > > instead, my solution packed this flag together with last job so once > last job is finished we are immediately returned from parallel_ so > other internal activity may go on There is no guarantee that the last job finishes last. If the first job takes longer than the last job we'll be one thread short while waiting on the first job. It's a shame, since removing that additional writeChan isn't particularly useful. Thanks Neil From bugfact at gmail.com Tue Apr 7 12:37:51 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Apr 7 12:24:45 2009 Subject: [Haskell-cafe] threadDelay granularity In-Reply-To: <76757B38-2258-4455-9DF3-598FDF6066A4@gmail.com> References: <20090407114134.GA6497@squish> <20090407152518.GE6497@squish> <76757B38-2258-4455-9DF3-598FDF6066A4@gmail.com> Message-ID: yes "get time" comes from GLFW; that is get comes from OpenGL, time from GLFW. I think the time provided by GLFW has a very high resolution but is not very accurate in the long run, which is not a real problem for games I guess On Tue, Apr 7, 2009 at 6:09 PM, Duane Johnson wrote: > The Hipmunk 2D physics engine comes with a "playground" app which includes > the following function: > > -- | Advances the time. >> advanceTime :: IORef State -> Double -> KeyButtonState -> IO Double >> advanceTime stateVar oldTime slowKey = do >> newTime <- get time >> >> -- Advance simulation >> let slower = if slowKey == Press then slowdown else 1 >> mult = frameSteps / (framePeriod * slower) >> framesPassed = truncate $ mult * (newTime - oldTime) >> simulNewTime = oldTime + toEnum framesPassed / mult >> advanceSimulTime stateVar $ min maxSteps framesPassed >> >> -- Correlate with reality >> newTime' <- get time >> let diff = newTime' - simulNewTime >> sleepTime = ((framePeriod * slower) - diff) / slower >> when (sleepTime > 0) $ sleep sleepTime >> return simulNewTime >> > > > I think the "get time" is provided by GLFW. > > -- Duane Johnson > > > > On Apr 7, 2009, at 9:25 AM, Ulrik Rasmussen wrote: > > On Tue, Apr 07, 2009 at 04:34:22PM +0200, Peter Verswyvelen wrote: >> >>> Do you want to cap the rendering framerate at 60FPS or the animation >>> framerate? >>> Because when you use OpenGL and GLFW, you can just >>> >>> GLFW.swapInterval $= 1 >>> >>> to cap the rendering framerate at the refresh rate of your monitor or LCD >>> screen (usually 60Hz) >>> >> >> I just want to cap the rendering framerate. The game logic is running in >> other threads, and sends rendering information via a Chan to the >> renderer. >> >> I'm using GLUT, and have never heard of GLFW. However, that seems to be >> a better tool to get the job done. I'll check it out, thanks :). >> >> /Ulrik >> >> >>> >>> On Tue, Apr 7, 2009 at 1:41 PM, Ulrik Rasmussen wrote: >>> >>> Hello. >>>> >>>> I am writing a simple game in Haskell as an exercise, and in the >>>> rendering loop I want to cap the framerate to 60fps. I had planned to do >>>> this with GHC.Conc.threadDelay, but looking at it's documentation, I >>>> discovered that it can only delay the thread in time spans that are >>>> multiples of 20ms: >>>> >>>> >>>> >>>> http://www.haskell.org/ghc/docs/6.4/html/libraries/base/Control.Concurrent.html >>>> >>>> I need a much finer granularity than that, so I wondered if it is >>>> possible to either get a higher resolution for threadDelay, or if there >>>> is an alternative to threadDelay? >>>> >>>> I noticed that the SDL library includes the function "delay", which >>>> indeed works with a resolution down to one millisecond. However, since >>>> I'm using HOpenGL and GLUT, I think it would be a little overkill to >>>> depend on SDL just for this :). >>>> >>>> >>>> Thanks, >>>> >>>> Ulrik Rasmussen >>>> _______________________________________________ >>>> 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/20090407/32f30325/attachment.htm From bulat.ziganshin at gmail.com Tue Apr 7 12:40:06 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Apr 7 12:27:10 2009 Subject: [Haskell-cafe] Re[6]: Parallel combinator, performance advice In-Reply-To: <1869076800.20090407201043@gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> <1588416099.20090407192255@gmail.com> <404396ef0904070833k75d2019cga4b6b0a1027e30ec@mail.gmail.com> <159123388.20090407195008@gmail.com> <1869076800.20090407201043@gmail.com> Message-ID: <196716271.20090407204006@gmail.com> Hello Bulat, Tuesday, April 7, 2009, 8:10:43 PM, you wrote: >>> parallel_ (x1:xs) = do >>> sem <- newQSem $ 1 - length xs >>> forM_ xs $ \x -> >>> writeChan queue (x >> signalQSem sem, False) >>> x1 >>> addWorker >>> waitQSem sem >>> writeChan queue (signalQSem sem, True) >>> waitQSem sem >> Neil, executing x1 directly in parallel_ is incorrect idea. > forget this. but it still a bit suboptimal... i think i realized why you use this schema. my solution may lead to N-1 worker threads in the system if last job is too small - after its execution we finish one thread and have just N-1 working threads until parallel_ will be finished but problem i mentioned in previous letter may also take place although it looks like less important. we may solve both problems by allowing worker thread to actively select its death time: it should die only at the moment when *last* job in bucket was finished - this guarantees us exactly N worker threads at any time. so: parallel_ (x1:xs) = do sem <- newQSem $ - length xs jobsLast <- newMVar (length xs) addWorker forM_ (x1:xs) $ \x -> do writeChan queue $ do x signalQSem sem modifyMVar jobsLast $ \jobs -> do return (jobs-1, jobs==0) -- waitQSem sem and modify last 3 lines of addWorker: addWorker :: IO () addWorker = do forkIO $ f `E.catch` \(e :: SomeException) -> throwTo mainThread $ ErrorCall "Control.Concurrent.Parallel: parallel thread died." return () where f :: IO () f = do act <- readChan queue kill <- act unless kill f -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From haskell at colquitt.org Tue Apr 7 13:18:11 2009 From: haskell at colquitt.org (John Dorsey) Date: Tue Apr 7 13:05:03 2009 Subject: [Haskell-cafe] Re: Configuring cabal dependencies at install-time In-Reply-To: <7fb8f82f0904070710w23714a0erda6ae22b1f31c121@mail.gmail.com> References: <9979e72e0904070218p7934efd7sa72b2fc348d27ca9@mail.gmail.com> <20090407132056.GE2207@colquitt.org> <7fb8f82f0904070710w23714a0erda6ae22b1f31c121@mail.gmail.com> Message-ID: <20090407171811.GF2207@colquitt.org> Edward, Thanks for straightening me out; I see the problems better now. In particular I was missing: 1) Orphaned types (and related design issues) get in the way of splitting the package. 2) Viral dependencies work in two directions, since "upstream" packages must pick up your deps to include instances of your classes. I'm thinking out loud, so bear with me. > The problem is there is no path to get there from here. Getting another > library to depend on mine, they have to pick up the brittle dependency set I > have now. Splitting my package into smaller packages fails because I need to > keep the instances for 3rd party data types packed with the class > definitions to avoid orphan instances and poor API design. So the option to Some class instances can go in three places: a) The source package for the type, which then picks up your deps. Bad. b) Your package, which then has a gazillion deps. Bad. c) Your sub-packages, in which case they're orphaned. Bad. I have to wonder whether (c) isn't the least of evils. Playing the advocate: - Orphaned instances are bad because of the risk of multiple instances. That risk should be low in this case; if anyone else wanted an instance of, say, a Prelude ADT for your library's class, their obvious option is to use your sub-package. - If you accept the above, then orphaning the intance in a sub-package that's associated with either the type's or the class's home is morally better than providing an instance in an unaffiliated third package. - Orphaning in sub-packages as a stopgap could make it much easier to get your class (and the instance) added to those upstream packages where it makes sense to do so. This clearly doesn't solve all parts of the problem. You may have other design concerns that make sub-packages undesirable. Even with instance definitions removed you may still have enough dependencies to deter integration. The problem probably extends beyond just class instances. > The only other alternative that I seem to have at this point in the cabal > packaging system is to create a series of flags for optional functionality. This sounds like rat hole of a different nature. You lose the ability to tell if an API is supported based on whether the package that implements it is installed. An installed and working package can cease to function after (possibly automatic) reinstallation when other packages become available. Complicated new functionality is required in Cabal. Regards, John From simon at joyful.com Tue Apr 7 13:21:56 2009 From: simon at joyful.com (Simon Michael) Date: Tue Apr 7 13:09:03 2009 Subject: [Haskell-cafe] Re: Configuring cabal dependencies at install-time In-Reply-To: <20090407132056.GE2207@colquitt.org> References: <9979e72e0904070218p7934efd7sa72b2fc348d27ca9@mail.gmail.com> <20090407132056.GE2207@colquitt.org> Message-ID: I'm facing this problem too, with hledger. It has optional happstack and vty interfaces which add to the difficulty and platform-specificity of installation. Currently I publish all in one package with a cabal flag for each interface, with happstack off and vty on by default. vty isn't available on windows, but I understand that cabal is smart enough to flip the flags until it finds a combination that is installable, so I hoped it would just turn off vty for windows users. It didn't, though. An alternative is to publish separate packages, debian style: libhledger, hledger, hledger-vty, hledger-happs etc. These are more discoverable and easier to document for users. It does seem hackage would be less fun to browse if it fills up with all these variants. But maybe it's simpler. From jwlato at gmail.com Tue Apr 7 14:36:25 2009 From: jwlato at gmail.com (John Lato) Date: Tue Apr 7 14:23:16 2009 Subject: [Haskell-cafe] Re: Configuring cabal dependencies at install-time In-Reply-To: <7fb8f82f0904070710w23714a0erda6ae22b1f31c121@mail.gmail.com> References: <9979e72e0904070218p7934efd7sa72b2fc348d27ca9@mail.gmail.com> <20090407132056.GE2207@colquitt.org> <7fb8f82f0904070710w23714a0erda6ae22b1f31c121@mail.gmail.com> Message-ID: <9979e72e0904071136s1967e055pa1443ca25177204e@mail.gmail.com> The problem of type class instances for third-party types is exactly how I ran into this. Currently I don't know of a good solution, where "good" means that it meets these criteria: 1. Does not introduce orphan instances 2. Allows for instances to be provided based upon the user's installed libraries 3. Allows for a separation of core package dependencies and dependencies that are only included to provide instances 4. Has sane dependency requirements (within the current Cabal framework) This seems harder than the problem Jeff has with buster, because the separate packages of buster-http, buster-ui, etc. makes sense both organizationally and as an implementation issue, it's more a question of the politeness of putting that collection on hackage. For type class instances, this isn't an option unless one provides orphan instances. I like Edward's suggestion of an "augments" flag. As I envision it, package Foo would provide something like a "phantom instance" of a type from package Bar, where the instance is not actually available until the matching library Bar is installed, at which point the compiler would compile the instance (or at least flag Foo for recompilation) and make it available. I have no idea how much work this would take, or where one would go about starting to implement it, though. John On Tue, Apr 7, 2009 at 3:10 PM, Edward Kmett wrote: > This has been a lot on my mind lately as my current library provides > additional functionality to data types from a wide array of other packages. > I?face a version of Wadler's expression problem. > > I provide a set of classes for injecting into monoids/seminearrings/etc. to > allow for quick reductions over different data structures. The problem is > that of course the interfaces?are fairly general so whole swathes of types > (including every applicative functor!) qualifies for certain operations. > > Perhaps the ultimate answer would be to push more of the instances down into > the source packages. I can do this with some of the monoid instances, but > convincing folks of the utility of the fact that their particular > applicative forms a right-seminearring when it contains a monoid is another > matter entirely. > > The problem is there is no path to get there from here. Getting another > library to depend on mine, they have to pick up the brittle dependency set I > have now. Splitting my package into smaller packages fails because I?need to > keep the instances for 3rd party data types packed with the class > definitions to avoid orphan instances and poor API design. So the option to > split things into the equivalent of 'buster-ui', 'buster-network' and so > forth largely fails on that design criterion. I can do that for new monoids, > rings and so forth that I define that purely layer on top of the base > functionality I provide, but not for ones that provide additional instances > for 3rd party data types. > > I can keep adding libraries as dependencies like I am doing now, but that > means that my library continues to accrete content at an alarming rate and > more importantly every one introduces a greater possibility of build issues, > because I can only operate in an environment where every one of my > dependencies can install. > > This further exacerbates the problem that no one would want to add all of my > pedantic instances because to do so they would have to inject a huge brittle > dependency into their package. > > The only other alternative that?I seem to have at this point in the cabal > packaging system is to create a series of flags for optional functionality. > This solves _my_ problem, in particular it lets me install on a much broader > base of environments, but now the order in which my package was installed > with respect to its dependencies matters. In particular, clients of the > library won't know if they have access to half of the instances, and so are > stuck limiting themselves to working either on a particular computer, or > using the intersection of the functionality I can provide. > > Perhaps, what I would ideally like to have would be some kind of 'augments' > or 'codependencies' clause in the cabal file?inside of?flags and build > targets that indicates packages that should force my package to > reinstall?after a package matching the version range inside the > codependencies clause is installed or at least prompt indicatig that new > functionality would be available and what packages you should reinstall. > > This would let me have my cake and eat it too. I could provide a wide array > of instances for different stock data types, and I could know that if > someone depends on both, say, ?'monoids' and 'parsec 3' that the parsec > instances will be present and usable in my package. > > Most?importantly, it would allow me to fix my 'expression problem'. Others > could introduce dependencies on the easier to install library allowing me to > shrink the library and?I would be able to install in more environments. > > -Edward Kmett > > On Tue, Apr 7, 2009 at 9:20 AM, John Dorsey wrote: >> >> John Lato wrote: >> > I think that the proper solution is to break up libraries into >> > separate packages as Jeff suggests (buster, buster-ui, etc.), but then >> > the total packages on hackage would explode. ?I don't feel great about >> >> I thought about this a while back and came to the conclusion that the >> package count should only grow by a small contant factor due to this, >> and that's a lot better than dealing with hairy and problematic >> dependencies. >> >> It should usually be: >> >> ?libfoo >> ?libfoo-blarg >> ?libfoo-xyzzy >> ?etc. >> >> and more rarely: >> >> ?libbar-with-xyzzy >> ?libbar-no-xyzzy >> ?etc. >> >> each providing libbar. ?Although I don't remember whether Cabal has >> 'provides'. ?The latter case could explode exponentially for weird >> packages that have several soft dependencies that can't be managed in >> the plugin manner, but I can't see that being a real issue. >> >> This looks manageable to me, but I'm no packaging guru. ?I guess it's a >> little harder for authors/maintainers of packages that look like leaves >> in the dependency tree, which could be bad. ?Am I missing something bad? >> >> Regards, >> John >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > From deduktionstheorem at web.de Tue Apr 7 15:35:41 2009 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Tue Apr 7 15:22:34 2009 Subject: [Haskell-cafe] Monad transformer to consume a list In-Reply-To: References: <49DA6801.1030209@web.de> Message-ID: <49DBAB0D.5060107@web.de> My solution is this transformer: newtype ConsumerT c m a = ConsumerT { runConsumerT :: [c] -> m (a, [c]) } instance (Monad m) => Monad (ConsumerT c m) where return x = ConsumerT $ \cs -> return (x, cs) m >>= f = ConsumerT $ \cs -> do ~(x, cs') <- runConsumerT m cs runConsumerT (f x) cs' fail msg = ConsumerT $ const (fail msg) consume :: (Monad m) => ConsumerT c m (Maybe c) consume = ConsumerT $ \css -> case css of [] -> return (Nothing, []) (c:cs) -> return (Just c, cs) consumeAll :: (Monad m) => ConsumerT c m [c] consumeAll = ConsumerT $ \cs -> return (cs, []) -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From lemming at henning-thielemann.de Tue Apr 7 15:42:24 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Apr 7 15:29:46 2009 Subject: [Haskell-cafe] Monad transformer to consume a list In-Reply-To: <49DBAB0D.5060107@web.de> References: <49DA6801.1030209@web.de> <49DBAB0D.5060107@web.de> Message-ID: On Tue, 7 Apr 2009, Stephan Friedrichs wrote: > My solution is this transformer: > > > newtype ConsumerT c m a > = ConsumerT { runConsumerT :: [c] -> m (a, [c]) } > > instance (Monad m) => Monad (ConsumerT c m) where > return x = ConsumerT $ \cs -> return (x, cs) > m >>= f = ConsumerT $ \cs -> do > ~(x, cs') <- runConsumerT m cs > runConsumerT (f x) cs' > fail msg = ConsumerT $ const (fail msg) But this is precisely the StateT, wrapped in a newtype and with restricted operations on it. You could as well define newtype ConsumerT c m a = ConsumerT { runConsumerT :: StateT [c] m a } instance (Monad m) => Monad (ConsumerT c m) where return x = ConsumerT $ return x m >>= f = ConsumerT $ runConsumerT . f =<< runConsumerT m From kannan at cakoose.com Tue Apr 7 17:27:21 2009 From: kannan at cakoose.com (Kannan Goundan) Date: Tue Apr 7 17:14:31 2009 Subject: [Haskell-cafe] Trying to write 'safeFromInteger' Message-ID: Here's my code (in file "Test.hs") safeFromInteger :: (Num a, Integral a, Bounded a) => Integer -> Maybe a safeFromInteger i = if i > (toInteger maxBound) then Nothing else Just (fromInteger i) Here's the error from GHCi 6.10.1: Test.hs:3:19: Ambiguous type variable `a' in the constraints: `Bounded a' arising from a use of `maxBound' at Test.hs:3:19-26 `Integral a' arising from a use of `toInteger' at Test.hs:3:9-26 Probable fix: add a type signature that fixes these type variable(s) It's almost like GHC thinks that the type variable "a" can't be part of the "Bounded" lass and the "Integeral" class. I plan to use "safeFromInteger" for converting from Word8, Word16, Word32, etc. From allbery at ece.cmu.edu Tue Apr 7 17:33:25 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Apr 7 17:20:32 2009 Subject: [Haskell-cafe] Trying to write 'safeFromInteger' In-Reply-To: References: Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Apr 7, 2009, at 17:27 , Kannan Goundan wrote: > if i > (toInteger maxBound) I think you have to tell it *which* maxBound you want. - -- 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 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.10 (Darwin) iEYEARECAAYFAknbxrAACgkQIn7hlCsL25VTbwCgwIFznypXKUvRzL1qqbkDdP9g P8QAn2He/JwKiDirOn65ggbwEc2fwWQ9 =nN6C -----END PGP SIGNATURE----- From max.rabkin at gmail.com Tue Apr 7 17:34:27 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Tue Apr 7 17:21:33 2009 Subject: [Haskell-cafe] Trying to write 'safeFromInteger' In-Reply-To: References: Message-ID: On Tue, Apr 7, 2009 at 11:27 PM, Kannan Goundan wrote: > Here's my code (in file "Test.hs") > > ?safeFromInteger :: (Num a, Integral a, Bounded a) => Integer -> Maybe a > ?safeFromInteger i = > ? ?if i > (toInteger maxBound) > ? ? ?then Nothing > ? ? ?else Just (fromInteger i) > > Here's the error from GHCi 6.10.1: > > ?Test.hs:3:19: > ? ?Ambiguous type variable `a' in the constraints: > ? ? ?`Bounded a' arising from a use of `maxBound' at Test.hs:3:19-26 > ? ? ?`Integral a' arising from a use of `toInteger' at Test.hs:3:9-26 > ? ?Probable fix: add a type signature that fixes these type variable(s) > > It's almost like GHC thinks that the type variable "a" can't be part of the > "Bounded" lass and the "Integeral" class. That is not what it thinks. Ambiguous is not the same as conflicting (you could call them opposites: ambiguous means underconstrained, conflicting means overconstrained). The confusing thing here is that the `a' GHC is talking about is not the `a' in your code. The problem with your code is that the type of maxBound is unspecified. You need (maxBound `asTypeOf` i), or enable ScopedTypeVariables and use (maxBound :: a) (I think). --Max From bulat.ziganshin at gmail.com Tue Apr 7 17:35:24 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Apr 7 17:22:31 2009 Subject: [Haskell-cafe] Trying to write 'safeFromInteger' In-Reply-To: References: Message-ID: <452712223.20090408013524@gmail.com> Hello Kannan, Wednesday, April 8, 2009, 1:27:21 AM, you wrote: > if i > (toInteger maxBound) problem here is that GHC doesn't know what maxBound you mean. is it maxBound::Int8? or maxBound::Word128? it has nothing common with the value you return later so you need to use either scoped type variables or usual asTypeOf trick. look recent cafe threads for more info -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From MarkoSchuetz at web.de Tue Apr 7 17:39:03 2009 From: MarkoSchuetz at web.de (Marko =?ISO-8859-1?Q?Sch=FCtz?=) Date: Tue Apr 7 17:26:09 2009 Subject: [Haskell-cafe] strange performance issue with takusen 0.8.3 In-Reply-To: <79d7c4980904070323o67b8530flfb3e85d9ece6da61@mail.gmail.com> References: <87d4bp39bq.wl%MarkoSchuetz@web.de> <79d7c4980904070323o67b8530flfb3e85d9ece6da61@mail.gmail.com> Message-ID: <87fxgkp2iw.wl%MarkoSchuetz@web.de> Dear Alistair, At Tue, 7 Apr 2009 11:23:24 +0100, Alistair Bayley wrote: > > 2009/4/6 Marko Sch?tz : > > > > I have an application where some simple data extracted from some > > source files is inserted into a PostgreSQL database. The application > > uses Takusen and is compiled with GHC 6.8.3. Some (59 in the test > > data) of the selects take on average 460ms each for a total time for > > this sample run of 30s. I prepare one select statement at the > > beginning of the run into which I then bind the specific values for > > every one of the selects. It does not seem to make a difference > > whether I do this or whether I just use a new statement for every > > select. > > > Hello Marko, > > I'm finding it hard to see what the problem is here. Is it that your > query takes 460ms, and you need it to be quicker? Or is it something Yes, the problem was (see below) that I will end up running this program thousands of times and 30s per run is way too long. > else? It would help to have some example code. Can you make a test > case which reproduces te problem, that you could share? > > > For comparison, I have collected the SQL statements in a file with > > PREPARE ... and DEALLOCATE for _every_ select and then run this file > > through psql. This takes 2s! > > If all you are doing is preparing and deallocating - i.e. not > executing - then that will be very quick, because the queries are > never executed. I should have mentioned that I do indeed have "an EXECUTE ... in between PREPARE ... and DEALLOCATE". In the meantime I found out what the issue was: I was using `Int` on the Haskell side which was translated to `NUMERIC`, but the relevant columns of the database have type `INT`. Consequently, the indices were not being used! To debug this I used an explicit EXPLAIN ANALYZE ... on the name of the prepared statement from within a withPreparedStatement. Best regards, Marko -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 194 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090407/fff8d5d7/attachment-0001.bin From kannan at cakoose.com Tue Apr 7 17:42:13 2009 From: kannan at cakoose.com (Kannan Goundan) Date: Tue Apr 7 17:29:19 2009 Subject: [Haskell-cafe] Re: Trying to write 'safeFromInteger' References: Message-ID: Max Rabkin gmail.com> writes: > The problem with your code is that the type of maxBound is > unspecified. You need (maxBound `asTypeOf` i), or enable > ScopedTypeVariables and use (maxBound :: a) (I think). I tried doing the (maxBound :: a) thing, but got another confusing error: safeFromInteger :: (Num a, Integral a, Bounded a) => Integer -> Maybe a safeFromInteger i = if i > (toInteger (maxBound :: a)) then Nothing else Just (fromInteger i) # ghci -XScopedTypeVariables Test.hs Test.hs:3:20: Could not deduce (Bounded a1) from the context () arising from a use of `maxBound' at TestIntegerBounds.hs:3:20-27 Possible fix: add (Bounded a1) to the context of an expression type signature In the first argument of `toInteger', namely `(maxBound :: a)' In the second argument of `(>)', namely `(toInteger (maxBound :: a))' In the expression: i > (toInteger (maxBound :: a)) From lemming at henning-thielemann.de Tue Apr 7 17:43:31 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Apr 7 17:30:23 2009 Subject: [Haskell-cafe] Trying to write 'safeFromInteger' In-Reply-To: References: Message-ID: On Tue, 7 Apr 2009, Max Rabkin wrote: > The problem with your code is that the type of maxBound is > unspecified. You need (maxBound `asTypeOf` i), or enable > ScopedTypeVariables and use (maxBound :: a) (I think). i is Integer, so asTypeOf is not so easy to apply. I propose to write safeFromIntegerAux :: (Num a, Integral a) => a -> Integer -> Maybe a safeFromIntegerAux mb i = ? ?if i > toInteger mb ? ? ?then Nothing ? ? ?else Just (fromInteger i) safeFromInteger = safeFromIntegerAux maxBound Btw. this is another instance where my beloved toMaybe function is useful. :-) http://hackage.haskell.org/packages/archive/utility-ht/0.0.4/doc/html/Data-Maybe-HT.html#v%3AtoMaybe From max.rabkin at gmail.com Tue Apr 7 17:53:38 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Tue Apr 7 17:40:44 2009 Subject: [Haskell-cafe] Trying to write 'safeFromInteger' In-Reply-To: References: Message-ID: On Tue, Apr 7, 2009 at 11:43 PM, Henning Thielemann wrote: > > On Tue, 7 Apr 2009, Max Rabkin wrote: > >> The problem with your code is that the type of maxBound is >> unspecified. You need (maxBound `asTypeOf` i), or enable >> ScopedTypeVariables and use (maxBound :: a) (I think). > > i is Integer, so asTypeOf is not so easy to apply. Of course. It can, however, be done: safeFromInteger :: (Num b, Integral b, Bounded b) => Integer -> Maybe b safeFromInteger i = let result = fromInteger i in if i > (toInteger $ maxBound `asTypeOf` result) then Nothing else Just result Thank you, laziness! > (safeFromInteger 1000000000000000000000000) :: Maybe Int Nothing > (safeFromInteger 100000) :: Maybe Int Just 100000 --Max From bugfact at gmail.com Tue Apr 7 18:23:44 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Apr 7 18:10:36 2009 Subject: [Haskell-cafe] Functions from Data.Hashtable Message-ID: These functions have their arguments reversed when compare to e.g. Map For example Data.HashTable.lookup :: HashTable key val -> key -> IO (Maybe val) Data.Map.lookup :: Ord key => key -> Map key val -> Maybe val I find this a bit odd. Is this by design? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090408/a6aea57f/attachment.htm From dons at galois.com Tue Apr 7 18:25:28 2009 From: dons at galois.com (Don Stewart) Date: Tue Apr 7 18:13:23 2009 Subject: [Haskell-cafe] Functions from Data.Hashtable In-Reply-To: References: Message-ID: <20090407222528.GH7875@whirlpool.galois.com> It is a bit odd. I'd suggest improvements (particularly implementing "carding" strategies) should be uploaded to hackage. -- Don bugfact: > These functions have their arguments reversed when compare to e.g. Map > > For example > > Data.HashTable.lookup :: HashTable key val -> key -> IO (Maybe val) > > Data.Map.lookup :: Ord key => key -> Map key val -> Maybe val > > I find this a bit odd. Is this by design? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From info at goetz-isenmann.de Tue Apr 7 18:30:58 2009 From: info at goetz-isenmann.de (G.Isenmann) Date: Tue Apr 7 18:20:43 2009 Subject: [Haskell-cafe] ghci/i386/dragonfly: unhandled ELF relocation(Rel) type 15 Message-ID: <20090408003058.078911c4@horse.intern> Hi, I am trying to get a useable ghc on i386 dragonfly2.2.0. My current problem: $ /var/tmp/ghc-6.10.2/bin/ghci GHCi, version 6.10.2: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. ghc: /var/tmp/ghc-6.10.2/lib/ghc-6.10.2/base-4.1.0.0/HSbase-4.1.0.0.o: unhandled ELF relocation(Rel) type 15 Loading package base ... linking ... ghc: unable to load package `base' Looks like HSbase-4.1.0.0.o uses three different relocation types $ objdump -r lib/ghc-6.10.2/base-4.1.0.0/HSbase-4.1.0.0.o \ | awk '{print $2}' | sort -u | grep R_ R_386_32 R_386_PC32 R_386_TLS_IE but the ghc rts/Linker.c only supports two $ grep R_386_ rts/Linker.c # define R_386_32 RELOC_32 # define R_386_PC32 RELOC_PC32 case R_386_32: *pP = value; break; case R_386_PC32: *pP = value - P; break; The third seems to be the access to thread local errno $ objdump -r lib/ghc-6.10.2/base-4.1.0.0/HSbase-4.1.0.0.o \ | grep R_386_TLS_IE 001c2682 R_386_TLS_IE errno 001c2b5b R_386_TLS_IE errno 001c2f36 R_386_TLS_IE errno The difference to linux and freebsd seems to be that the access to the errno location is not hidden inside dragonflys libc but is visible for the caller similar to $ cat t.c static __thread int tls; int *get() { return &tls; } $ gcc -c t.c $ objdump -r t.o t.o: file format elf32-i386 RELOCATION RECORDS FOR [.text]: OFFSET TYPE VALUE 0000000b R_386_TLS_LE tls What would be the best or easiest way to deal with this situation? -- Goetz From dagit at codersbase.com Tue Apr 7 18:35:40 2009 From: dagit at codersbase.com (Jason Dagit) Date: Tue Apr 7 18:22:30 2009 Subject: [Haskell-cafe] Functions from Data.Hashtable In-Reply-To: References: Message-ID: On Tue, Apr 7, 2009 at 3:23 PM, Peter Verswyvelen wrote: > These functions have their arguments reversed when compare to e.g. Map > For example > Data.HashTable.lookup?::?HashTable?key val -> key ->?IO?(Maybe?val) > > Data.Map.lookup?::?Ord?key => key ->?Map?key val ->?Maybe?val > > I find this a bit odd. Is this by design? Speaking of design. I think the version in HashTable would be better for partial application in most cases. With that version you can partially apply the hashtable you want to use and then get a function (key -> IO (Maybe val)). So I think most uses wouldn't need to sneak in a flip. Jason From lemming at henning-thielemann.de Tue Apr 7 18:38:27 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Apr 7 18:25:19 2009 Subject: [Haskell-cafe] Functions from Data.Hashtable In-Reply-To: References: Message-ID: On Wed, 8 Apr 2009, Peter Verswyvelen wrote: > These functions have their arguments reversed when compare to e.g. Map > For example > > Data.HashTable.lookup?::?HashTable?key val -> key ->?IO?(Maybe?val) > > Data.Map.lookup?::?Ord?key => key ->?Map?key val ->?Maybe?val For my taste, Data.Map.lookup has the wrong parameter order, since I often need the same Map with different keys and not vice versa. The HashTable.lookup parameter order can also be read as mapping a Map to the function it represents. I mean (HashTable key val) and (Map key val) represent functions of type (key -> val) and you can write: Data.HashTable.lookup?::?HashTable?key val -> (key ->?IO?(Maybe?val)) http://www.haskell.org/haskellwiki/Parameter_order From bugfact at gmail.com Tue Apr 7 18:43:15 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Apr 7 18:30:07 2009 Subject: [Haskell-cafe] Functions from Data.Hashtable In-Reply-To: References: Message-ID: yes I agree. It seems to be mentioned here too http://www.haskell.org/haskellwiki/Parameter_order On Wed, Apr 8, 2009 at 12:38 AM, Henning Thielemann < lemming@henning-thielemann.de> wrote: > > On Wed, 8 Apr 2009, Peter Verswyvelen wrote: > > These functions have their arguments reversed when compare to e.g. Map >> For example >> >> Data.HashTable.lookup :: HashTable key val -> key -> IO (Maybe val) >> >> Data.Map.lookup :: Ord key => key -> Map key val -> Maybe val >> > > For my taste, Data.Map.lookup has the wrong parameter order, since I often > need the same Map with different keys and not vice versa. The > HashTable.lookup parameter order can also be read as mapping a Map to the > function it represents. I mean (HashTable key val) and (Map key val) > represent functions of type (key -> val) and you can write: > Data.HashTable.lookup :: HashTable key val -> (key -> IO (Maybe val)) > > http://www.haskell.org/haskellwiki/Parameter_order -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090408/b77420c6/attachment.htm From wren at freegeek.org Tue Apr 7 18:46:33 2009 From: wren at freegeek.org (wren ng thornton) Date: Tue Apr 7 18:33:25 2009 Subject: [Haskell-cafe] Functions from Data.Hashtable In-Reply-To: References: Message-ID: <49DBD7C9.3010601@freegeek.org> Peter Verswyvelen wrote: > These functions have their arguments reversed when compare to e.g. Map > For example > > Data.HashTable.lookup :: HashTable key val -> key -> IO (Maybe val) > > Data.Map.lookup :: Ord key => key -> Map key val -> Maybe val > > I find this a bit odd. Is this by design? I'd guess it's due more to antiquity than to intention. Data.Map mirrors the Prelude, along with almost everyone else: GHC.List.lookup :: (Eq a) => a -> [(a, b)] -> Maybe b Data.IntMap.lookup :: (Monad m) => Data.IntMap.Key -> IntMap a -> m a Data.Trie.lookup :: ByteString -> Trie a -> Maybe a Data.Set.member :: (Ord a) => a -> Set a -> Bool As a design issue, I think the dominant order is better for partial application since they make good arguments to Control.Monad.State.gets and similar state-like HOFs. Considering the IO ugliness of HashTable, Jason Dagit may have a point though. As I recall, this discussion has lead to flame wars in the past. -- Live well, ~wren From bugfact at gmail.com Tue Apr 7 18:49:32 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Apr 7 18:36:24 2009 Subject: [Haskell-cafe] Functions from Data.Hashtable In-Reply-To: <49DBD7C9.3010601@freegeek.org> References: <49DBD7C9.3010601@freegeek.org> Message-ID: On Wed, Apr 8, 2009 at 12:46 AM, wren ng thornton wrote: > As a design issue, I think the dominant order is better for partial > application since they make good arguments to Control.Monad.State.gets and > similar state-like HOFs. Considering the IO ugliness of HashTable, Jason > Dagit may have a point though. As I recall, this discussion has lead to > flame wars in the past. > Okay. I guess there's no clear winner here when it comes to argument order. And no need to waste energy on another flame war :-) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090408/b9117963/attachment.htm From dagit at codersbase.com Tue Apr 7 19:00:08 2009 From: dagit at codersbase.com (Jason Dagit) Date: Tue Apr 7 18:46:59 2009 Subject: [Haskell-cafe] Functions from Data.Hashtable In-Reply-To: References: <49DBD7C9.3010601@freegeek.org> Message-ID: On Tue, Apr 7, 2009 at 3:49 PM, Peter Verswyvelen wrote: > > > On Wed, Apr 8, 2009 at 12:46 AM, wren ng thornton wrote: >> >> As a design issue, I think the dominant order is better for partial >> application since they make good arguments to Control.Monad.State.gets and >> similar state-like HOFs. Considering the IO ugliness of HashTable, Jason >> Dagit may have a point though. As I recall, this discussion has lead to >> flame wars in the past. > > Okay. I guess there's no clear winner here when it comes to argument order. > And no need to waste energy on another flame war :-) Especially here with Haskell. Just use flip if the arguments come in the wrong order. Jason From bugfact at gmail.com Tue Apr 7 19:09:34 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Apr 7 18:56:26 2009 Subject: [Haskell-cafe] Re: Trying to write 'safeFromInteger' In-Reply-To: References: Message-ID: You must explicitly quantify the type parameters in the top level function when you use this extension. This works: {-# LANGUAGE ScopedTypeVariables #-} safeFromInteger :: forall a . (Num a, Integral a, Bounded a) => Integer -> Maybe a safeFromInteger i = if i > (toInteger (maxBound :: a)) then Nothing else Just (fromInteger i) On Tue, Apr 7, 2009 at 11:42 PM, Kannan Goundan wrote: > Max Rabkin gmail.com> writes: > > > The problem with your code is that the type of maxBound is > > unspecified. You need (maxBound `asTypeOf` i), or enable > > ScopedTypeVariables and use (maxBound :: a) (I think). > > I tried doing the (maxBound :: a) thing, but got another confusing error: > > safeFromInteger :: (Num a, Integral a, Bounded a) => Integer -> Maybe a > safeFromInteger i = > if i > (toInteger (maxBound :: a)) > then Nothing > else Just (fromInteger i) > > # ghci -XScopedTypeVariables Test.hs > > Test.hs:3:20: > Could not deduce (Bounded a1) from the context () > arising from a use of `maxBound' at TestIntegerBounds.hs:3:20-27 > Possible fix: > add (Bounded a1) to the context of an expression type signature > In the first argument of `toInteger', namely `(maxBound :: a)' > In the second argument of `(>)', namely > `(toInteger (maxBound :: a))' > In the expression: i > (toInteger (maxBound :: a)) > > > > _______________________________________________ > 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/20090408/caaf9e02/attachment.htm From wren at freegeek.org Tue Apr 7 19:41:56 2009 From: wren at freegeek.org (wren ng thornton) Date: Tue Apr 7 19:28:46 2009 Subject: [Haskell-cafe] Functions from Data.Hashtable In-Reply-To: References: <49DBD7C9.3010601@freegeek.org> Message-ID: <49DBE4C4.4020709@freegeek.org> Jason Dagit wrote: > Peter Verswyvelen wrote: > > wren ng thornton wrote: > > > As a design issue, I think the dominant order is better for partial > > > application since they make good arguments to Control.Monad.State.gets and > > > similar state-like HOFs. Considering the IO ugliness of HashTable, Jason > > > Dagit may have a point though. As I recall, this discussion has lead to > > > flame wars in the past. > > > > Okay. I guess there's no clear winner here when it comes to argument order. > > And no need to waste energy on another flame war :-) > > Especially here with Haskell. Just use flip if the arguments come in > the wrong order. I gotta say, I do enjoy the natural transformations Foo a b -> (a -> b) though. Perhaps Data.Map is right to have both lookup and (!)--- even though everyone's abandoned that due to the ugliness of qualified symbolic names. Is there a class somewhere which provides co-arr? There'd be a lot of instances for it[1]. Though the proper abstract nonsense should allow defining Foo a b -> F(a -> G b) for F and G other than Id (namely IO and Maybe for the functions under discussion). The problem here is the same as the (>>=) vs (=<<) issue for monads. On the one hand there's a pipelining or concatenative idiom, and on the other hand there's an applicative idiom. Both are declarative, both are functional, and both are (under different circumstances) natural. Yet we don't have a general solution for incorporating both styles, other than relegating one style to using flip everywhere. Hence the flames, since everyone wants to paint their own bikeshed, and noone wants to be a second-class citizen. [1] http://haskell.org/hoogle/?hoogle=a+b+c+-%3E+%28b+-%3E+c%29 -- Live well, ~wren From brad.larsen at gmail.com Tue Apr 7 21:11:23 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Tue Apr 7 20:58:16 2009 Subject: [Haskell-cafe] Painful Data Abstraction Message-ID: <49DBF9BB.6090705@gmail.com> I asked this earlier on #haskell, but it was quiet hour. Here goes. Suppose I have an abstract data type for prefix dictionaries of bytestrings. I define a typeclass in a module PrefixDict.Class: module PrefixDict.Class where import qualified Data.ByteString.Char8 as B type Word = B.ByteString class PrefixDict d where empty :: d isEmpty :: d -> Bool insert :: Word -> d -> d delete :: d -> Word -> d hasWord :: d -> Word -> Bool hasPrefix :: d -> Word -> Bool I then write several implementations, including a naive list implementation, and a trie implementation, in the modules PrefixDict.ListDict and PrefixDict.TrieDict, both looking something like this: module PrefixDict.ListDict where import PrefixDict.Class data ListDict = ListDict [Word] instance PrefixDict ListDict where ... Now, there are many properties that should be satisfied by any implementation of PrefixDict, that are not easily captured in the type system. Trying to be a good coder, I write up some generic QuickCheck properties, such as prop_insert_idempotent :: (Eq d, PrefixDict d) => d -> Word -> Bool prop_insert_idempotent d w = insert w d' == d' where d' = insert w d The problem is this: I can't think of a non-kludged way of checking that TrieDict and ListDict satisfy this abstract property without having to add explicit type signatures, e.g. quickCheck (prop_insert_idempotent :: TrieDict -> Word -> Bool) I have many abstract properties, and I *really* don't like having to put an explicit signature on each one. I came up with a hackishway that minimizes the number of signatures required, by checking all abstract properties in one, generic function, reflecting a type as a value, and using scoped type variables: testAbstractProperties :: forall d. (PrefixDict d) => d -> IO () testAbstractProperties _ = do quickCheck (prop_insert_idempotent :: d -> Word -> Bool) quickCheck (prop_delete_works :: d -> Word -> Property) ... I then call this function from a "test suite" function written for each module, e.g. testTrieDict :: IO () testTrieDict = do testAbstractProperties (undefined :: TrieDict) testTrieDictSpecificProperties This means I only have to write the type signatures on the properties in one place, but it is still less than ideal. Is there a better way of doing this, or is Haskell simply not good at this kind of data abstraction? Best, Brad Larsen From jfredett at gmail.com Tue Apr 7 22:42:46 2009 From: jfredett at gmail.com (Joe Fredette) Date: Tue Apr 7 22:30:03 2009 Subject: [Haskell-cafe] ANN: HCard -- A library for implementing card-like structures. Message-ID: <49DC0F26.1040907@gmail.com> HCard, is a library which supports a card-like data structures, it uses associated types [1] to provide shuffling, dealing, and other facilities. It's general enough to support many different types of playing cards, it currently comes with the common "French Deck" (4-suit, 13 card deck that is very common in the US) implemented and an example (though untested) cribbage scoring application. You can find HCard here [2,3], and a post about it's use of associated types here [1]. On another note, I can't think of a good reason I should be using associated types, as I explain in [1]. Well, no good reason other than the "cool factor" -- can anyone enlighten me on a possible practical benefit of using Assoc types as opposed to a simple indexed record? Anyway, enjoy HCard! /Joe Fredette [1] http://lowlymath.net/2009/card-games-scorekeeping-and-associated-datatypes/ [2] darcs get http://patch-tag.com/publicrepos/HCard [3] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HCard -------------- next part -------------- A non-text attachment was scrubbed... Name: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090407/230085a3/jfredett.vcf From nonowarn at gmail.com Tue Apr 7 23:11:17 2009 From: nonowarn at gmail.com (Yusaku Hashimoto) Date: Tue Apr 7 22:58:09 2009 Subject: [Haskell-cafe] Generating arbitrary function in QuickCheck In-Reply-To: <49DAF06B.60002@tcs.inf.tu-dresden.de> References: <5e0214850904062209p2a73343p3fb3e6fe001a042a@mail.gmail.com> <49DAF06B.60002@tcs.inf.tu-dresden.de> Message-ID: <715AFBD3-BCAF-4803-9122-B52B77781BD0@gmail.com> Thanks for all replies! these gave me many enlightenments. I have been looking in about free theorem for a while, and I want to try to describe what I learned, and please collect me where I am wrong or misunderstood. Generating random functions for sortBy is meaningless, because, for testing sortBy, casual comparison function is enough to it. The reason of this comes from free theorem. By the free theorem, sortBy should satisfy this theorem (copied from ftshell). forall t1,t2 in TYPES, f :: t1 -> t2. forall p :: t1 -> t1 -> Ordering. forall q :: t2 -> t2 -> Ordering. (forall x :: t1. p x = q (f x) . f) ==> (map f . sortBy p = sortBy q . map f) Any linear orderings can be defined by mapping value to Integer. And above theorem says comparing functions in the theorem must be homomorphic to each other. Hence comparing function is meaningful only when it is homomorhpic to Integer's that. (I have not tried to Generate such function yet, and it may be unnecessary, but) taking such function is easy. Furthermore, it should be satisfied by all functions that have same type signitures to sortBy, because it is implied from only its own type. Reference: - [Theorem for free!](http://citeseerx.ist.psu.edu/viewdoc/summary? doi=10.1.1.38.9875) - [ftshell](http://hackage.haskell.org/cgi-bin/hackage-scripts/ package/ftshell-0.3) Thanks, Yusaku Hashimoto On 2009/04/07, at 15:19, Janis Voigtlaender wrote: > Jason Dagit wrote: >> On Mon, Apr 6, 2009 at 10:09 PM, Eugene Kirpichov >> wrote: >>> Since the argument to sortBy must impose a linear ordering on its >>> arguments, and any linear ordering may as well be generated by >>> assigning an integer to each element of type 'a', and your sorting >>> function is polymorphic, from the free theorem for the sorting >>> function we may deduce that it suffices to test your function on >>> integer lists with a casual comparison function (Data.Ord.compare), >>> and there is no need to generate a random comparison function. >> Interesting. How is this free theorem stated for the sorting >> function? Intuitively I understand that if the type is polymorphic, >> then it seems reasonable to just pick one type and go with it. > > You can try free theorems here: > > http://linux.tcs.inf.tu-dresden.de/~voigt/ft/ > > For example, for > > sort :: Ord a => [a] -> [a] > > it generates the following: > > forall t1,t2 in TYPES(Ord), f :: t1 -> t2, f respects Ord. > forall x :: [t1]. map f (sort x) = sort (map f x) > > where: > > f respects Ord if f respects Eq and > forall x :: t1. > forall y :: t1. compare x y = compare (f x) (f y) > forall x :: t1. forall y :: t1. (<) x y = (<) (f x) (f y) > forall x :: t1. forall y :: t1. (<=) x y = (<=) (f x) (f y) > forall x :: t1. forall y :: t1. (>) x y = (>) (f x) (f y) > forall x :: t1. forall y :: t1. (>=) x y = (>=) (f x) (f y) > > f respects Eq if > forall x :: t1. forall y :: t1. (==) x y = (==) (f x) (f y) > forall x :: t1. forall y :: t1. (/=) x y = (/=) (f x) (f y) > > Assuming that all the comparison functions relate to each other in the > mathematically sensible way, the latter can be reduced to: > > f respects Ord if > forall x :: t1. forall y :: t1. (x <= y) = (f x <= f y) > > For sortBy you would get a similar free theorem. > > To see how the free theorem allows you to switch from an arbitrary > type > to just integers, set t2=Int and simply use f to build a > order-preserving bijection between elements in the list x and a prefix > of [1,2,3,4,...] > > Ciao, Janis. > > -- > Dr. Janis Voigtlaender > http://wwwtcs.inf.tu-dresden.de/~voigt/ > mailto:voigt@tcs.inf.tu-dresden.de > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ekirpichov at gmail.com Tue Apr 7 23:31:23 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Tue Apr 7 23:18:13 2009 Subject: [Haskell-cafe] Generating arbitrary function in QuickCheck In-Reply-To: <715AFBD3-BCAF-4803-9122-B52B77781BD0@gmail.com> References: <5e0214850904062209p2a73343p3fb3e6fe001a042a@mail.gmail.com> <49DAF06B.60002@tcs.inf.tu-dresden.de> <715AFBD3-BCAF-4803-9122-B52B77781BD0@gmail.com> Message-ID: <5e0214850904072031mb3b031fhb389152f4eebcc7c@mail.gmail.com> 2009/4/8 Yusaku Hashimoto : > Thanks for all replies! these gave me many enlightenments. > > I have been looking in about free theorem for a while, and I want to > try to describe what I learned, and please collect me where I am wrong > or misunderstood. > > Generating random functions for sortBy is meaningless, because, for > testing sortBy, casual comparison function is enough to it. The reason > of this comes from free theorem. By the free theorem, sortBy should > satisfy this theorem (copied from ftshell). > > ? ?forall t1,t2 in TYPES, f :: t1 -> t2. > ? ? forall p :: t1 -> t1 -> Ordering. > ? ? ?forall q :: t2 -> t2 -> Ordering. > ? ? ? (forall x :: t1. p x = q (f x) . f) > ? ? ? ==> (map f . sortBy p = sortBy q . map f) > > Any linear orderings can be defined by mapping value to Integer. And > above theorem says comparing functions in the theorem must be > homomorphic to each other. Hence comparing function is meaningful only > when it is homomorhpic to Integer's that. (I have not tried to > Generate such function yet, and it may be unnecessary, but) taking > such function is easy. Kind of like that. The theorem says that for any function of sortBy's type, it will not change permutation of the list if we replace the comparison function by another one that is monotonic with respect to it. For any correct comparison function F, there exists a mapping to integers M and 'compare' as the comparison function agreeing with F. Therefore, if you check yourSortBy on integers with 'compare', you will also be sure of all other types with correct comparison functions, because you'll be sure that it permutes the list in a correct way. > > Furthermore, it should be satisfied by all functions that have same > type signitures to sortBy, because it is implied from only its own > type. > > Reference: > - [Theorem for > free!](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.38.9875) > - > [ftshell](http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ftshell-0.3) > > Thanks, > Yusaku Hashimoto > > > On 2009/04/07, at 15:19, Janis Voigtlaender wrote: > >> Jason Dagit wrote: >>> >>> On Mon, Apr 6, 2009 at 10:09 PM, Eugene Kirpichov >>> wrote: >>>> >>>> Since the argument to sortBy must impose a linear ordering on its >>>> arguments, and any linear ordering may as well be generated by >>>> assigning an integer to each element of type 'a', and your sorting >>>> function is polymorphic, from the free theorem for the sorting >>>> function we may deduce that it suffices to test your function on >>>> integer lists with a casual comparison function (Data.Ord.compare), >>>> and there is no need to generate a random comparison function. >>> >>> Interesting. ?How is this free theorem stated for the sorting >>> function? ?Intuitively I understand that if the type is polymorphic, >>> then it seems reasonable to just pick one type and go with it. >> >> You can try free theorems here: >> >> http://linux.tcs.inf.tu-dresden.de/~voigt/ft/ >> >> For example, for >> >> sort :: Ord a => [a] -> [a] >> >> it generates the following: >> >> forall t1,t2 in TYPES(Ord), f :: t1 -> t2, f respects Ord. >> ?forall x :: [t1]. map f (sort x) = sort (map f x) >> >> where: >> >> f respects Ord if f respects Eq and >> ?forall x :: t1. >> ? forall y :: t1. compare x y = compare (f x) (f y) >> ?forall x :: t1. forall y :: t1. (<) x y = (<) (f x) (f y) >> ?forall x :: t1. forall y :: t1. (<=) x y = (<=) (f x) (f y) >> ?forall x :: t1. forall y :: t1. (>) x y = (>) (f x) (f y) >> ?forall x :: t1. forall y :: t1. (>=) x y = (>=) (f x) (f y) >> >> f respects Eq if >> ?forall x :: t1. forall y :: t1. (==) x y = (==) (f x) (f y) >> ?forall x :: t1. forall y :: t1. (/=) x y = (/=) (f x) (f y) >> >> Assuming that all the comparison functions relate to each other in the >> mathematically sensible way, the latter can be reduced to: >> >> f respects Ord if >> ?forall x :: t1. forall y :: t1. (x <= y) = (f x <= f y) >> >> For sortBy you would get a similar free theorem. >> >> To see how the free theorem allows you to switch from an arbitrary type >> to just integers, set t2=Int and simply use f to build a >> order-preserving bijection between elements in the list x and a prefix >> of [1,2,3,4,...] >> >> Ciao, Janis. >> >> -- >> Dr. Janis Voigtlaender >> http://wwwtcs.inf.tu-dresden.de/~voigt/ >> mailto:voigt@tcs.inf.tu-dresden.de >> >> _______________________________________________ >> 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 > -- Eugene Kirpichov Web IR developer, market.yandex.ru From briand at aracnet.com Wed Apr 8 00:19:48 2009 From: briand at aracnet.com (brian) Date: Wed Apr 8 00:06:39 2009 Subject: [Haskell-cafe] cabal on mac os x (gmp problem) Message-ID: <30632A65-2672-4AF2-8BA5-E0FB8C546E7E@aracnet.com> For future reference: Solved, I just created a symlink to libgmp.dylib in /usr/local, and the zlib package was able to build. From tonal.promsoft at gmail.com Wed Apr 8 01:14:43 2009 From: tonal.promsoft at gmail.com (Alexandr N. Zamaraev) Date: Wed Apr 8 01:01:40 2009 Subject: [Haskell-cafe] How to install HOpenGL to Windows? Message-ID: <49DC32C3.2040200@gmail.com> I get darcs source HOpenGL Try runghc Setup.hs configure I see: Configuring OpenGL-2.3... Warning: The 'build-type' is 'Configure' but there is no 'configure' script. Setup.hs: configure script not found. runghc Setup.hs build wrote: Preprocessing library OpenGL-2.3... Building OpenGL-2.3... Graphics\Rendering\OpenGL\GL\BasicTypes.hs:24:0: HsOpenGLConfig.h: No such file or directory How to build HOpenGL? Os Windows Vista Home Ru + sp ghc 6.10.1 From magicloud.magiclouds at gmail.com Wed Apr 8 01:20:17 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Wed Apr 8 01:07:07 2009 Subject: [Haskell-cafe] How to cut a file effciently? Message-ID: <3bd412d40904072220r3421ecc1p58de35a50e37867d@mail.gmail.com> Hi, Let us say I have a text file of a million lines, and I want to cut it into smaller (10K lines) ones. How to do this? I have tried a few ways, none I think is lazy (I mean not reading the file all at the start). -- ??????? ??????? From lrpalmer at gmail.com Wed Apr 8 01:32:22 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Apr 8 01:19:11 2009 Subject: [Haskell-cafe] How to cut a file effciently? In-Reply-To: <3bd412d40904072220r3421ecc1p58de35a50e37867d@mail.gmail.com> References: <3bd412d40904072220r3421ecc1p58de35a50e37867d@mail.gmail.com> Message-ID: <7ca3f0160904072232u473c2d1g3ac49322780f2610@mail.gmail.com> split n [] = [] split n xs = take n xs : split n (drop n xs) main = do text <- readFile "source" mapM_ (\(n,dat) -> writeFile ("dest" ++ show n) dat) . zip [0..] . split 10000 . lines $ text Modulo brainos... but you get the idea. This is lazy (because readFile is). Luke On Tue, Apr 7, 2009 at 11:20 PM, Magicloud Magiclouds < magicloud.magiclouds@gmail.com> wrote: > Hi, > Let us say I have a text file of a million lines, and I want to cut > it into smaller (10K lines) ones. > How to do this? I have tried a few ways, none I think is lazy (I > mean not reading the file all at the start). > -- > ÖñÃÜÆñ·ÁÁ÷Ë®¹ý > ɽ¸ßÄÄ×èÒ°ÔÆ·É > _______________________________________________ > 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/20090407/ca717072/attachment.htm From ryani.spam at gmail.com Wed Apr 8 01:39:06 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Apr 8 01:25:57 2009 Subject: [Haskell-cafe] Painful Data Abstraction In-Reply-To: <49DBF9BB.6090705@gmail.com> References: <49DBF9BB.6090705@gmail.com> Message-ID: <2f9b2d30904072239q3f67339cq8db7aefbc6f1c0fc@mail.gmail.com> On Tue, Apr 7, 2009 at 6:11 PM, Brad Larsen wrote: > ? prop_insert_idempotent :: (Eq d, PrefixDict d) => d -> Word -> Bool > ? prop_insert_idempotent d w = insert w d' == d' > ? ? where d' = insert w d > > The problem is this: ?I can't think of a non-kludged way of checking that > TrieDict and ListDict satisfy this abstract property without having to add > explicit type signatures, e.g. > > ? quickCheck (prop_insert_idempotent :: TrieDict -> Word -> Bool) This is one place where parametrized modules would come in handy. There hasn't been a good proposal to implement these in Haskell; in particular it's not clear how they should interact with typeclasses. You can do something like this: > data Proxy d = Proxy > -- add any other constraints required by your test properties here > data CheckPrefixDict = forall d. (PrefixDict d, Eq d, Show d, Arbitrary d) => CheckPrefixDict (Proxy d) > prop_insert_idempotent :: CheckPrefixDict -> Property > prop_insert_idempotent (CheckPrefixDict (Proxy :: Proxy d)) = property prop where > prop :: d -> Word -> Bool > prop d w = insert w d' == d' > where d' == insert w d > checkableTrie = CheckPrefixDict (Proxy :: Proxy TrieDict) You then can "quickCheck (prop_insert_idempotent checkableTrie)" Or if you want to test all your structures at once, make CheckPrefixDict an instance of Arbitrary that selects one of the implementations randomly. (In this case you probably want to add a descriptive string so that when a test fails you know which instance has the problem :) -- ryan From johan.tibell at gmail.com Wed Apr 8 01:52:34 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Wed Apr 8 01:39:24 2009 Subject: [Haskell-cafe] How to cut a file effciently? In-Reply-To: <3bd412d40904072220r3421ecc1p58de35a50e37867d@mail.gmail.com> References: <3bd412d40904072220r3421ecc1p58de35a50e37867d@mail.gmail.com> Message-ID: <90889fe70904072252i18724e4fv52ba541bb462da75@mail.gmail.com> On Wed, Apr 8, 2009 at 7:20 AM, Magicloud Magiclouds wrote: > Hi, > ?Let us say I have a text file of a million lines, and I want to cut > it into smaller (10K lines) ones. > ?How to do this? I have tried a few ways, none I think is lazy (I > mean not reading the file all at the start). I would just seek to the approximate chunk boundaries (10k, 20k, etc) and the read forward until hitting a newline. Cheers, Johan From tom.davie at gmail.com Wed Apr 8 02:55:26 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Wed Apr 8 02:42:22 2009 Subject: [Haskell-cafe] Functions from Data.Hashtable In-Reply-To: <49DBD7C9.3010601@freegeek.org> References: <49DBD7C9.3010601@freegeek.org> Message-ID: On 8 Apr 2009, at 00:46, wren ng thornton wrote: > Peter Verswyvelen wrote: >> These functions have their arguments reversed when compare to e.g. >> Map >> For example >> Data.HashTable.lookup :: HashTable key val -> key -> IO (Maybe val) >> Data.Map.lookup :: Ord key => key -> Map key val -> Maybe val >> I find this a bit odd. Is this by design? > > As a design issue, I think the dominant order is better for partial > application since they make good arguments to > Control.Monad.State.gets and similar state-like HOFs. Considering > the IO ugliness of HashTable, Jason Dagit may have a point though. > As I recall, this discussion has lead to flame wars in the past. To add my 2? to this one ? The arguments for each one can be put across as this: ? I prefer (M a b) -> a -> b, because we can do functional programming in it more easily. ? I prefer a -> (M a b) -> b, because we can do stateful programming in it more easily. Perhaps we need to remember what kind of language Haskell is ? yes it's an excellent imperative language, but when it gets down to it, it's functional, and maybe we should try to keep it that way. To add support to the other argument though ? I think the stateful version reads better when used fully applied ? it reads as lookup this key in this map. The reverse doesn't read so well in english, the best I can think of is, transform this map into a function and apply it, but that doesn't actually include the word lookup anywhere. Bob From waldmann at imn.htwk-leipzig.de Wed Apr 8 03:13:07 2009 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Wed Apr 8 03:00:00 2009 Subject: [Haskell-cafe] PatternSignatures (rant) Message-ID: <49DC4E83.3060100@imn.htwk-leipzig.de> Dear all, (this is a rant - please ignore) why has "PatternSignatures" been renamed to "ScopedTypeVariables" (in ghc-6.10)? show me the alleged "type variable" in this code: do x :: Int <- [ 1 .. 10 ] ; return $ x^2 and why on earth do I need to use a language extension at all to get to the most basic thing of declarative programming: to declare the type of an identifier? This seriously hurts (me, at least) when teaching Haskell. Thanks - J.W. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 257 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090408/612baf51/signature.bin From ndmitchell at gmail.com Wed Apr 8 03:25:55 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Apr 8 03:12:46 2009 Subject: [Haskell-cafe] PatternSignatures (rant) In-Reply-To: <49DC4E83.3060100@imn.htwk-leipzig.de> References: <49DC4E83.3060100@imn.htwk-leipzig.de> Message-ID: <404396ef0904080025h13022625r7ac7e4b446dbe641@mail.gmail.com> Hi, > why has "PatternSignatures" > been renamed to "ScopedTypeVariables" (in ghc-6.10)? It's unfortunate that 6.8 doesn't have ScopedTypeVariables and 6.10 warns on PatternSignatures. It would have been nice if you could support N.M and N.M+2 with the same code without having to turn off warnings. > show me the alleged "type variable" in this code: > do x :: Int <- [ 1 .. 10 ] ; return $ x^2 > > and why on earth do I need to use a language extension at all > to get to the most basic thing of declarative programming: > to declare the type of an identifier? Because it isn't in Haskell 98, and GHC (very kindly) only accepts Haskell 98 by default. By doing so they've kept the standard alive, and we should be very grateful for this. I think this is a guaranteed feature for H', it's really an oversight that it isn't in H98. Thanks Neil From deduktionstheorem at web.de Wed Apr 8 03:31:31 2009 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Wed Apr 8 03:18:26 2009 Subject: [Haskell-cafe] Monad transformer to consume a list In-Reply-To: References: <49DA6801.1030209@web.de> <49DBAB0D.5060107@web.de> Message-ID: <49DC52D3.7040909@web.de> Henning Thielemann wrote: > [...] > > But this is precisely the StateT, wrapped in a newtype and with > restricted operations on it. You could as well define > > newtype ConsumerT c m a = > ConsumerT { runConsumerT :: StateT [c] m a } Oh I see - my bad. I was somehow thinking I could prevent modification of the input list but that's obviously impossible when the ConsumerT constructor is... exported? public? how do you say that? > [...] //Stephan -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From fft1976 at gmail.com Wed Apr 8 03:54:42 2009 From: fft1976 at gmail.com (FFT) Date: Wed Apr 8 03:41:46 2009 Subject: [Haskell-cafe] GHC needs a 64 bit machine to be fast? Message-ID: Not that this is a very good benchmark, but I compiled the nearly equivalent C and Haskell (1st, recursive version) programs from this blog post: http://donsbot.wordpress.com/2008/06/04/haskell-as-fast-as-c-working-at-a-high-altitude-for-low-level-performance/ There, in both versions, 1e9 iterations take 1.8s. However, in my timing on 32-bit Linux machines, the C version is 5-10 times faster. Does the bitness of the OS make a big difference? Here are my timings on a 3.4GHz Pentium D: C : 4.072s (GCC 4.2.4) Haskell : 22.481s (GHC 6.10.2 and 6.8.2 are about the same here) I used the exact same compiler options as in the blog post. I only added import System import Text.Printf to the Haskell program, which seems to be missing. Suspiciously, "ghc -O2 --make" is almost as fast at 24.438s (6.10.2) From karel.gardas at centrum.cz Wed Apr 8 04:14:16 2009 From: karel.gardas at centrum.cz (Karel Gardas) Date: Wed Apr 8 04:00:19 2009 Subject: [Haskell-cafe] GHC needs a 64 bit machine to be fast? In-Reply-To: References: Message-ID: <49DC5CD8.7080609@centrum.cz> Hello, perhaps you are hit by following issue? http://hackage.haskell.org/trac/ghc/ticket/594 Cheers, Karel FFT wrote: > Not that this is a very good benchmark, but I compiled the nearly > equivalent C and Haskell (1st, recursive version) programs from this > blog post: > > http://donsbot.wordpress.com/2008/06/04/haskell-as-fast-as-c-working-at-a-high-altitude-for-low-level-performance/ > > There, in both versions, 1e9 iterations take 1.8s. > > However, in my timing on 32-bit Linux machines, the C version is 5-10 > times faster. Does the bitness of the OS make a big difference? > > Here are my timings on a 3.4GHz Pentium D: > > C : 4.072s (GCC 4.2.4) > Haskell : 22.481s (GHC 6.10.2 and 6.8.2 are about the same here) > > I used the exact same compiler options as in the blog post. I only added > > import System > import Text.Printf > > to the Haskell program, which seems to be missing. > > Suspiciously, "ghc -O2 --make" is almost as fast at 24.438s (6.10.2) > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From fft1976 at gmail.com Wed Apr 8 04:17:47 2009 From: fft1976 at gmail.com (FFT) Date: Wed Apr 8 04:04:38 2009 Subject: [Haskell-cafe] GHC needs a 64 bit machine to be fast? In-Reply-To: <49DC5CD8.7080609@centrum.cz> References: <49DC5CD8.7080609@centrum.cz> Message-ID: On Wed, Apr 8, 2009 at 1:14 AM, Karel Gardas wrote: > > Hello, > > perhaps you are hit by following issue? > http://hackage.haskell.org/trac/ghc/ticket/594 The benchmark isn't using the native code generator, it compiles via C, as I understand. What are other people's timings on 32 bit Linux machines? From waldmann at imn.htwk-leipzig.de Wed Apr 8 04:21:46 2009 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Wed Apr 8 04:08:38 2009 Subject: [Haskell-cafe] PatternSignatures (rant) In-Reply-To: <404396ef0904080025h13022625r7ac7e4b446dbe641@mail.gmail.com> References: <49DC4E83.3060100@imn.htwk-leipzig.de> <404396ef0904080025h13022625r7ac7e4b446dbe641@mail.gmail.com> Message-ID: <49DC5E9A.1070909@imn.htwk-leipzig.de> > [...] and GHC (very kindly) only accepts Haskell 98 by default. as in, hierarchical modules? continuing the rant, I'd say that "ScopedTypeVariables" is a kludge that tries to repair another hack, namely, allowing to not declare type variables. That's again counter to the very idea of declarative programming. I mean, if we'd write let f1 :: forall a . T1 a f1 = let f2 :: forall a . T2 a f3 :: T3 a in ... in ... then there'd be no need to look up the meaning of the inner a's in some command line option or pragma in the file header, both of which are miles away from the source location. (I already said it is a rant, OK?) - J.W. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 257 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090408/afd926d2/signature.bin From bugfact at gmail.com Wed Apr 8 04:58:25 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 8 04:45:14 2009 Subject: [Haskell-cafe] GHC needs a 64 bit machine to be fast? In-Reply-To: References: <49DC5CD8.7080609@centrum.cz> Message-ID: Regarding that, is it possible to generate 64-bit code using GHC on Windows? On Wed, Apr 8, 2009 at 10:17 AM, FFT wrote: > On Wed, Apr 8, 2009 at 1:14 AM, Karel Gardas > wrote: > > > > Hello, > > > > perhaps you are hit by following issue? > > http://hackage.haskell.org/trac/ghc/ticket/594 > > The benchmark isn't using the native code generator, it compiles via > C, as I understand. > > What are other people's timings on 32 bit Linux machines? > _______________________________________________ > 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/20090408/c8852d6c/attachment.htm From fft1976 at gmail.com Wed Apr 8 05:06:11 2009 From: fft1976 at gmail.com (FFT) Date: Wed Apr 8 04:53:00 2009 Subject: [Haskell-cafe] GHC needs a 64 bit machine to be fast? In-Reply-To: References: <49DC5CD8.7080609@centrum.cz> Message-ID: Update: I missed an earlier blog post and the discussion that followed it. http://donsbot.wordpress.com/2008/05/06/write-haskell-as-fast-as-c-exploiting-strictness-laziness-and-recursion/ On 32-bit machines, -fexcess-presision makes GHC output faster (only 2 times slower than C instead of 5-10, in my tests) From gleb.alexeev at gmail.com Wed Apr 8 05:09:38 2009 From: gleb.alexeev at gmail.com (Gleb Alexeyev) Date: Wed Apr 8 04:56:00 2009 Subject: [Haskell-cafe] Re: Monad transformer to consume a list In-Reply-To: <49DC52D3.7040909@web.de> References: <49DA6801.1030209@web.de> <49DBAB0D.5060107@web.de> <49DC52D3.7040909@web.de> Message-ID: Stephan Friedrichs wrote: > > Oh I see - my bad. I was somehow thinking I could prevent modification > of the input list but that's obviously impossible when the ConsumerT > constructor is... exported? public? how do you say that? You can export ConsumerT as an abstract type constructor. > {-# LANGUAGE GeneralizedNewtypeDeriving #-} > module ConsumerT(ConsumerT, runConsumerT, next) where > import Control.Monad.State > import Control.Monad.Trans > newtype ConsumerT c m a = ConsumerT { runConsumerT' :: StateT [c] m a } > deriving (Functor, Monad, MonadTrans) > runConsumerT = runStateT . runConsumerT' > next :: Monad m => ConsumerT a m a > next = ConsumerT $ StateT $ \(x:xs) -> return (x, xs) From sanzhiyan at gmail.com Wed Apr 8 05:21:00 2009 From: sanzhiyan at gmail.com (Andrea Vezzosi) Date: Wed Apr 8 05:07:50 2009 Subject: [Haskell-cafe] cabal haddock and Paths_Xxx In-Reply-To: <49DA4AD9.80704@van.steenbergen.nl> References: <49DA4AD9.80704@van.steenbergen.nl> Message-ID: <8625cd9c0904080221m6d0c644eg87f515b7d290c341@mail.gmail.com> Which version of Cabal are you using? It should be fixed with Cabal-1.6.0.2, check cabal --version to make sure it's not using an older one. On Mon, Apr 6, 2009 at 8:32 PM, Martijn van Steenbergen wrote: > Hello, > > cabal generates a Paths_Xxx file for me which I import and use, but cabal > haddock doesn't seem to like it much. > > If I don't specify the generated module at all in my cabal file, cabal > haddock generates visible documentation for the module, which is not what I > want: the module should stay internal. > > If I specify it in either Exposed-Modules or Other-Modules, 'cabal > configure; cabal haddock' fails with: > >> cabal: can't find source for Paths_Xxx in ., dist/build/autogen > > While 'cabal configure; cabal build; cabal haddock' fails with: > >> cabal: can't find source for module Paths_Xxx > > Can I have the best of both, i.e. generate docs without problems and use the > generated module? > > Thanks, > > Martijn. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jeffzaroyko at gmail.com Wed Apr 8 05:35:31 2009 From: jeffzaroyko at gmail.com (Jeff Zaroyko) Date: Wed Apr 8 05:22:20 2009 Subject: [Haskell-cafe] How to install HOpenGL to Windows? In-Reply-To: <49DC32C3.2040200@gmail.com> References: <49DC32C3.2040200@gmail.com> Message-ID: On Wed, Apr 8, 2009 at 3:14 PM, Alexandr N. Zamaraev wrote: > > How to build HOpenGL? > > Os Windows Vista Home Ru + sp Hello Alexandr, Linked from here http://www.haskell.org/haskellwiki/Opengl http://netsuperbrain.com/blog/posts/freeglut-windows-hopengl-hglut/ Jeff From bulat.ziganshin at gmail.com Wed Apr 8 05:39:16 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Apr 8 05:33:02 2009 Subject: [Haskell-cafe] Trying to write 'safeFromInteger' In-Reply-To: References: Message-ID: <1123142595.20090408133916@gmail.com> Hello Henning, Wednesday, April 8, 2009, 1:43:31 AM, you wrote: > i is Integer, so asTypeOf is not so easy to apply. I propose to write safeFromInteger i = let mb = maxBound in if i > (toInteger mb) then Nothing else Just (fromInteger i `asTypeOf` mb) or you can do it opposite way: safeFromInteger i = let res = fromInteger i in if i > (toInteger (maxBound `asTypeOf` res)) then Nothing else Just res -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Wed Apr 8 05:47:51 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Apr 8 05:43:10 2009 Subject: [Haskell-cafe] GHC needs a 64 bit machine to be fast? In-Reply-To: References: <49DC5CD8.7080609@centrum.cz> Message-ID: <1611609764.20090408134751@gmail.com> Hello Peter, Wednesday, April 8, 2009, 12:58:25 PM, you wrote: No. it seems that i'm only user asking GHC team for 64-bit version > Regarding that, is it possible to generate 64-bit code using GHC on Windows? > On Wed, Apr 8, 2009 at 10:17 AM, FFT wrote: > > On Wed, Apr 8, 2009 at 1:14 AM, Karel Gardas wrote: >> >> Hello, >> >> perhaps you are hit by following issue? >> http://hackage.haskell.org/trac/ghc/ticket/594 > > > The benchmark isn't using the native code generator, it compiles via > C, as I understand. > > What are other people's timings on 32 bit Linux machines? > > _______________________________________________ > 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 vandijk.roel at gmail.com Wed Apr 8 06:21:56 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Wed Apr 8 06:08:45 2009 Subject: [Haskell-cafe] GHC needs a 64 bit machine to be fast? In-Reply-To: References: Message-ID: > Suspiciously, "ghc -O2 ?--make" is almost as fast at 24.438s (6.10.2) You have to be careful when recompiling with a different -O setting that you first remove all intermediate files (.o and .hi). I think that GHC only looks at the source to determine which files need to be compiled and not at any settings. From ndmitchell at gmail.com Wed Apr 8 06:33:15 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Apr 8 06:20:05 2009 Subject: [Haskell-cafe] Re: Re[6]: Parallel combinator, performance advice In-Reply-To: <196716271.20090407204006@gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> <1588416099.20090407192255@gmail.com> <404396ef0904070833k75d2019cga4b6b0a1027e30ec@mail.gmail.com> <159123388.20090407195008@gmail.com> <1869076800.20090407201043@gmail.com> <196716271.20090407204006@gmail.com> Message-ID: <404396ef0904080333u41a43360j7e83c2b21d4a9c07@mail.gmail.com> Hi >>>> parallel_ (x1:xs) = do >>>> ? ? sem <- newQSem $ 1 - length xs >>>> ? ? forM_ xs $ \x -> >>>> ? ? ? ? writeChan queue (x >> signalQSem sem, False) >>>> ? ? x1 >>>> ? ? addWorker >>>> ? ? waitQSem sem >>>> ? ? writeChan queue (signalQSem sem, True) >>>> ? ? waitQSem sem > >>> Neil, executing x1 directly in parallel_ is incorrect idea. > >> forget this. but it still a bit suboptimal... > > i think i realized why you use this schema. my solution may lead to > N-1 worker threads in the system if last job is too small - after its > execution we finish one thread and have just N-1 working threads until > parallel_ will be finished > > but problem i mentioned in previous letter may also take place > although it looks like less important. we may solve both problems by > allowing worker thread to actively select its death time: it should > die only at the moment when *last* job in bucket was finished - this > guarantees us exactly N worker threads at any time. so: > > parallel_ (x1:xs) = do > ? ?sem <- newQSem $ - length xs > ? ?jobsLast <- newMVar (length xs) > ? ?addWorker > ? ?forM_ (x1:xs) $ \x -> do > ? ? ? ?writeChan queue $ do > ? ? ? ? ? x > ? ? ? ? ? signalQSem sem > ? ? ? ? ? modifyMVar jobsLast $ \jobs -> do > ? ? ? ? ? ? ? return (jobs-1, jobs==0) Yes, this saves us adding a kill job to the queue, but requires an extra MVar. I guess which one of these is to be preferred depends on performance measures. I've just found that QSem _ISN'T_ valid below 0, so the above code won't actually work with QSem as it stands. I've reported this on ghc-users@. I've also spotted that QSem creates plenty of MVar's itself, so the logic of moving to QSem instead of MVar isn't really valid (although the new approach is nicer, so that's good). Thanks Neil From bugfact at gmail.com Wed Apr 8 06:42:24 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 8 06:29:14 2009 Subject: [Haskell-cafe] GHC needs a 64 bit machine to be fast? In-Reply-To: <1611609764.20090408134751@gmail.com> References: <49DC5CD8.7080609@centrum.cz> <1611609764.20090408134751@gmail.com> Message-ID: Well, make that 2! :-) On Wed, Apr 8, 2009 at 11:47 AM, Bulat Ziganshin wrote: > Hello Peter, > > Wednesday, April 8, 2009, 12:58:25 PM, you wrote: > > No. it seems that i'm only user asking GHC team for 64-bit version > > > Regarding that, is it possible to generate 64-bit code using GHC on > Windows? > > > On Wed, Apr 8, 2009 at 10:17 AM, FFT wrote: > > > > On Wed, Apr 8, 2009 at 1:14 AM, Karel Gardas > wrote: > >> > >> Hello, > >> > >> perhaps you are hit by following issue? > >> http://hackage.haskell.org/trac/ghc/ticket/594 > > > > > > The benchmark isn't using the native code generator, it compiles via > > C, as I understand. > > > > What are other people's timings on 32 bit Linux machines? > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > > > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090408/975d2213/attachment.htm From bugfact at gmail.com Wed Apr 8 06:42:54 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 8 06:29:44 2009 Subject: [Haskell-cafe] GHC needs a 64 bit machine to be fast? In-Reply-To: References: Message-ID: pass the flag -fforce-recomp On Wed, Apr 8, 2009 at 12:21 PM, Roel van Dijk wrote: > > Suspiciously, "ghc -O2 --make" is almost as fast at 24.438s (6.10.2) > > You have to be careful when recompiling with a different -O setting > that you first remove all intermediate files (.o and .hi). I think > that GHC only looks at the source to determine which files need to be > compiled and not at any settings. > _______________________________________________ > 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/20090408/e9f4e9d6/attachment.htm From bulat.ziganshin at gmail.com Wed Apr 8 06:45:06 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Apr 8 06:33:02 2009 Subject: [Haskell-cafe] Re[8]: Parallel combinator, performance advice In-Reply-To: <404396ef0904080333u41a43360j7e83c2b21d4a9c07@mail.gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> <1588416099.20090407192255@gmail.com> <404396ef0904070833k75d2019cga4b6b0a1027e30ec@mail.gmail.com> <159123388.20090407195008@gmail.com> <1869076800.20090407201043@gmail.com> <196716271.20090407204006@gmail.com> <404396ef0904080333u41a43360j7e83c2b21d4a9c07@mail.gmail.com> Message-ID: <983523670.20090408144506@gmail.com> Hello Neil, Wednesday, April 8, 2009, 2:33:15 PM, you wrote: > Yes, this saves us adding a kill job to the queue, but requires an > extra MVar. I guess which one of these is to be preferred depends on > performance measures. i think that main problem with your last variant is that kill job added to the queue much later than real jobs. imagine the following scenario: 1. para used to add 100 jobs to the queue 2. while these jobs are executing, para in another thread adds another 100 jobs to the queue in my variant, first para exits just when its own jobs are completed. in your variant, exit job is added to the queue only after second batch of 100 jobs so we will wait until all these jobs are executed -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ndmitchell at gmail.com Wed Apr 8 07:25:51 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Apr 8 07:12:41 2009 Subject: [Haskell-cafe] Re: Re[8]: Parallel combinator, performance advice In-Reply-To: <983523670.20090408144506@gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> <1588416099.20090407192255@gmail.com> <404396ef0904070833k75d2019cga4b6b0a1027e30ec@mail.gmail.com> <159123388.20090407195008@gmail.com> <1869076800.20090407201043@gmail.com> <196716271.20090407204006@gmail.com> <404396ef0904080333u41a43360j7e83c2b21d4a9c07@mail.gmail.com> <983523670.20090408144506@gmail.com> Message-ID: <404396ef0904080425v17ae4d0dx4c69973651e41d16@mail.gmail.com> Hi Bulat, >> Yes, this saves us adding a kill job to the queue, but requires an >> extra MVar. I guess which one of these is to be preferred depends on >> performance measures. > > i think that main problem with your last variant is that kill job > added to the queue much later than real jobs. imagine the following > scenario: > > 1. para used to add 100 jobs to the queue > 2. while these jobs are executing, para in another thread adds another > 100 jobs to the queue > > in my variant, first para exits just when its own jobs are completed. > in your variant, exit job is added to the queue only after second > batch of 100 jobs so we will wait until all these jobs are executed Ah, you are indeed right. I forgot about the property of timeliness - you want parallel_ to return as soon as it can. Once you're using an MVar to do the killing, you might as well use the same MVar to wait on, and avoid the semaphores, and avoid the bug with negative semaphores: http://hackage.haskell.org/trac/ghc/ticket/3159 I've attached a revised implementation. With my benchmark it gives a stack overflow: n = 1000000 main = do r <- newIORef (0 :: Int) let incRef = atomicModifyIORef r (\a -> let a2 = a + 1 in a2 `seq` (a2,a)) parallel_ $ replicate n $ incRef v <- readIORef r parallelStop print v However, calling with that many items in a parallel queue is highly unlikely, so I'll not worry (if anyone knows why it stack overflows, I am curious). This parallel_ implementation has all the properties I want, so I'm very happy with it. As a side note, it's necessary to add parallelStop, to kill all the threads - or you get thread blocked exceptions being raised. You create a thread pool waiting on a queue as a CAF, but after the last call to parallel_ finishes GHC realises the queue is unreachable. This means that all the threads are blocked indefinitely, so GHC raises exceptions. To solve this we call parallelStop to get all the threads to die nicely. Thanks Neil -------------- next part -------------- A non-text attachment was scrubbed... Name: Parallel3.hs Type: text/x-haskell Size: 2128 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090408/465af920/Parallel3.bin From bulat.ziganshin at gmail.com Wed Apr 8 07:33:17 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Apr 8 07:20:18 2009 Subject: [Haskell-cafe] Re[10]: Parallel combinator, performance advice In-Reply-To: <404396ef0904080425v17ae4d0dx4c69973651e41d16@mail.gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> <1588416099.20090407192255@gmail.com> <404396ef0904070833k75d2019cga4b6b0a1027e30ec@mail.gmail.com> <159123388.20090407195008@gmail.com> <1869076800.20090407201043@gmail.com> <196716271.20090407204006@gmail.com> <404396ef0904080333u41a43360j7e83c2b21d4a9c07@mail.gmail.com> <983523670.20090408144506@gmail.com> <404396ef0904080425v17ae4d0dx4c69973651e41d16@mail.gmail.com> Message-ID: <1859565722.20090408153317@gmail.com> Hello Neil, Wednesday, April 8, 2009, 3:25:51 PM, you wrote: > I've attached a revised implementation. With my benchmark it gives a > stack overflow: it may be in replicate. check with let incRef = atomicModifyIORef r (\a -> (a,a)) > As a side note, it's necessary to add parallelStop, to kill all the > threads - or you get thread blocked exceptions being raised. alternatively, you can catch this exception in addWorker -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ekmett at gmail.com Wed Apr 8 08:09:55 2009 From: ekmett at gmail.com (Edward Kmett) Date: Wed Apr 8 07:56:45 2009 Subject: [Haskell-cafe] Trying to write 'safeFromInteger' In-Reply-To: References: Message-ID: <7fb8f82f0904080509t6677570dta762f3fd7d74c6b9@mail.gmail.com> Of course your safeFromInteger isn't really safe, what about the minBound? =) On Tue, Apr 7, 2009 at 5:27 PM, Kannan Goundan wrote: > Here's my code (in file "Test.hs") > > safeFromInteger :: (Num a, Integral a, Bounded a) => Integer -> Maybe a > safeFromInteger i = > if i > (toInteger maxBound) > then Nothing > else Just (fromInteger i) > > Here's the error from GHCi 6.10.1: > > Test.hs:3:19: > Ambiguous type variable `a' in the constraints: > `Bounded a' arising from a use of `maxBound' at Test.hs:3:19-26 > `Integral a' arising from a use of `toInteger' at Test.hs:3:9-26 > Probable fix: add a type signature that fixes these type variable(s) > > It's almost like GHC thinks that the type variable "a" can't be part of the > "Bounded" lass and the "Integeral" class. > > I plan to use "safeFromInteger" for converting from Word8, Word16, Word32, > etc. > > _______________________________________________ > 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/20090408/87619c10/attachment.htm From jason.dusek at gmail.com Wed Apr 8 08:24:16 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Apr 8 08:11:04 2009 Subject: [Haskell-cafe] stream fusion -- multi-module programs Message-ID: <42784f260904080524u2623f148h24ae34d3e1932874@mail.gmail.com> In the paper "Stream Fusion: From Streams To Lists To Nothing At All", we find: For large multi-module programs, the results are less clear, with just as many programs speeding up as slowing down. We ?nd that for larger programs, GHC has a tendency to miss optimisation op- portunities for stream fusible functions across module boundaries, which is the subject of further investigation. What's the state of these things? Is this still an issue for stream fusion? -- Jason Dusek From ndmitchell at gmail.com Wed Apr 8 08:28:48 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Apr 8 08:15:37 2009 Subject: [Haskell-cafe] Re: Re[10]: Parallel combinator, performance advice In-Reply-To: <1859565722.20090408153317@gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <1588416099.20090407192255@gmail.com> <404396ef0904070833k75d2019cga4b6b0a1027e30ec@mail.gmail.com> <159123388.20090407195008@gmail.com> <1869076800.20090407201043@gmail.com> <196716271.20090407204006@gmail.com> <404396ef0904080333u41a43360j7e83c2b21d4a9c07@mail.gmail.com> <983523670.20090408144506@gmail.com> <404396ef0904080425v17ae4d0dx4c69973651e41d16@mail.gmail.com> <1859565722.20090408153317@gmail.com> Message-ID: <404396ef0904080528q3fa12637m5672c58fb14d2cf0@mail.gmail.com> Hi Bulat, >> I've attached a revised implementation. With my benchmark it gives a >> stack overflow: > > let incRef = atomicModifyIORef r (\a -> (a,a)) That was the problem, I now no longer get a stack overflow. >> As a side note, it's necessary to add parallelStop, to kill all the >> threads - or you get thread blocked exceptions being raised. > > alternatively, you can catch this exception in addWorker I could, but it wouldn't be that easy to tell if the reason for the deadlock was the program finishing a real deadlock occurring in the system. I'd rather not catch exceptions where possible. Thanks Neil From dav.vire+haskell at gmail.com Wed Apr 8 08:36:11 2009 From: dav.vire+haskell at gmail.com (david48) Date: Wed Apr 8 08:23:04 2009 Subject: [Haskell-cafe] Trying to write 'safeFromInteger' In-Reply-To: <7fb8f82f0904080509t6677570dta762f3fd7d74c6b9@mail.gmail.com> References: <7fb8f82f0904080509t6677570dta762f3fd7d74c6b9@mail.gmail.com> Message-ID: <4c88418c0904080536o75c1d8f4gd9c87b5c77475e53@mail.gmail.com> What about : sffi :: (Integral a,Num a) => Integer -> Maybe a sffi n = go n (fromInteger n) where go a b | toInteger b == a = Just b | otherwise = Nothing -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090408/7a56d906/attachment.htm From ndmitchell at gmail.com Wed Apr 8 08:55:20 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Apr 8 08:42:09 2009 Subject: [Haskell-cafe] Trying to write 'safeFromInteger' In-Reply-To: <4c88418c0904080536o75c1d8f4gd9c87b5c77475e53@mail.gmail.com> References: <7fb8f82f0904080509t6677570dta762f3fd7d74c6b9@mail.gmail.com> <4c88418c0904080536o75c1d8f4gd9c87b5c77475e53@mail.gmail.com> Message-ID: <404396ef0904080555t4cc22c8et10dd0c2e021cafdc@mail.gmail.com> That seems a really weird way to write it! Who decided all auxiliary functions should be called go? (I think I'm blaming dons) - why not: sffi :: (Integral a,Num a) => Integer -> Maybe a sffi n | toInteger n2 == n = Just n2 | otherwise = Nothing where n2 = fromInteger n No need for auxiliary function definitions. Thanks Neil From briqueabraque at yahoo.com Wed Apr 8 09:07:40 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Wed Apr 8 08:54:48 2009 Subject: [Haskell-cafe] Maybe off-topic -- Writing contracts or software specifications Message-ID: Hi, I'm an engineer, and as a programmer I'm just an amateur. This easied things to me, since I could take decisions about practices based on what made sense to me. But now I need to take responsability for some formal programming tasks, and I don't know which examples to follow. I need, for instance, to write a contract with a programmer we are hiring for a task. But the only example I have of such contracts seemed to me (as I said, an amateur. I may be completely wrong) impractical. It was a 150 pages document with every possible user action and every imaginable allowed consequences. But it would be easier to me write the software than such contract itself. Are there ways already accepted by practice on how to write software contracts? It's a small program to acquire and show data from a device, a one person, two months work. I like the guy we are going to hire, and much to my surprise he sugested using Haskell for the task. But he also do not have experience writing such documents. Thanks, Maur?cio From gleb.alexeev at gmail.com Wed Apr 8 09:12:48 2009 From: gleb.alexeev at gmail.com (Gleb Alexeyev) Date: Wed Apr 8 08:59:08 2009 Subject: [Haskell-cafe] Re: Parallel combinator, performance advice In-Reply-To: <404396ef0904080333u41a43360j7e83c2b21d4a9c07@mail.gmail.com> References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> <1588416099.20090407192255@gmail.com> <404396ef0904070833k75d2019cga4b6b0a1027e30ec@mail.gmail.com> <159123388.20090407195008@gmail.com> <1869076800.20090407201043@gmail.com> <196716271.20090407204006@gmail.com> <404396ef0904080333u41a43360j7e83c2b21d4a9c07@mail.gmail.com> Message-ID: Neil Mitchell wrote: > I've just found that QSem _ISN'T_ valid below 0, so the above code > won't actually work with QSem as it stands. I may be missing something, but I guess this code will work if 'newQSem (-n)' is replaced with 'newQSemN n', every 'signalQSem sem' with 'signalQSemN sem 1' and 'waitQSem sem' with 'waitQSemN sem n'. From ndmitchell at gmail.com Wed Apr 8 09:19:19 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Apr 8 09:06:09 2009 Subject: [Haskell-cafe] Re: Parallel combinator, performance advice In-Reply-To: References: <404396ef0904070325w436da045l4a39d51a7e601e02@mail.gmail.com> <49DB59BD.6040201@list.mightyreason.com> <404396ef0904070713m57d5b13v33f0d4be2761f97d@mail.gmail.com> <1588416099.20090407192255@gmail.com> <404396ef0904070833k75d2019cga4b6b0a1027e30ec@mail.gmail.com> <159123388.20090407195008@gmail.com> <1869076800.20090407201043@gmail.com> <196716271.20090407204006@gmail.com> <404396ef0904080333u41a43360j7e83c2b21d4a9c07@mail.gmail.com> Message-ID: <404396ef0904080619l73298e0ar9a49052b88a6224f@mail.gmail.com> Hi Gleb, >> I've just found that QSem _ISN'T_ valid below 0, so the above code >> won't actually work with QSem as it stands. > > I may be missing something, but I guess this code will work if 'newQSem > (-n)' is replaced with 'newQSemN n', every 'signalQSem sem' with > 'signalQSemN sem 1' and 'waitQSem sem' with 'waitQSemN sem n'. Yep, that seems valid. However, the new solution requires an MVar to store the number of things we're waiting for anyway, so we might as well use that to also wake up the main thread. Semaphores aren't more efficient than MVar's, they are in fact implemented in terms of MVar's, so there is no benefit. Thanks Neil From manlio_perillo at libero.it Wed Apr 8 10:05:37 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Wed Apr 8 09:52:37 2009 Subject: [Haskell-cafe] Maybe off-topic -- Writing contracts or software specifications In-Reply-To: References: Message-ID: <49DCAF31.9040708@libero.it> Maur??cio ha scritto: > Hi, > [...] > I need, for instance, to write a contract with a programmer > we are hiring for a task. > [...] The question is: how much do you trust the programmer? And how much do the programmer trust you? Much of the complications of the contracts arise from the need to deal with parts that don't trust each other. A few pages should suffice. Make sure that: 1) You explain accurately what the program must do, and how the programmer intend to write the program. Do you need strong unit tests? 2) Write the deadline for program completion. What happens if the deadline is not honoured? 3) Write the estimate price for the work. Are price changes allowed? Regards Manlio From frodo at theshire.org Wed Apr 8 10:55:58 2009 From: frodo at theshire.org (Cristiano Paris) Date: Wed Apr 8 10:43:08 2009 Subject: [Haskell-cafe] Maybe off-topic -- Writing contracts or software specifications In-Reply-To: References: Message-ID: On Wed, Apr 8, 2009 at 3:07 PM, Maur??cio wrote: > Hi, > ... > Are there ways already accepted by practice on how to write > software contracts? It's a small program to acquire and show > data from a device, a one person, two months work. I like the > guy we are going to hire, and much to my surprise he sugested > using Haskell for the task. But he also do not have experience > writing such documents. It depends on how clear and stable are the requirements for the application that must be developed. If they are very clear and you think they're not going to change during development, then you can go for a contract having the product itself as the subject: you'll describe the application, stating all the requirements and the acceptance tests for each of them. But be careful: requirements in the software field are very hard to state clearly and you might end up with yourself spending a lot of time and effort just to figure out which are to be included and how they're best described. On the contrary, if you have only a vague idea of what the software should do, then I advice you to hire the person for a certain amount of time. Hence, you're supposed to collaborate closely with this person to get the job done, mostly controlling the development. In order to incentivate the person to finish the job before the end of the contract, I'd put a big bonus if the software satisfies you. The downside is that you must spend a lot of time in the project and be competent in evaluating the person's skills for the project, otherwise you'll end up with paying a person who is basically useless to you. Maybe you can get help in evaluating the programmer from a friend or a collegue. Anything between these two forms of contracts is likely to fail. My 2 cents. Cristiano From tom.davie at gmail.com Wed Apr 8 10:57:03 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Wed Apr 8 10:44:10 2009 Subject: [Haskell-cafe] A challenge Message-ID: <4EC40AC5-3AF7-4063-94F3-D1B702969E85@gmail.com> We have two possible definitions of an "iterateM" function: iterateM 0 _ _ = return [] iterateM n f i = (i:) <$> (iterateM (n-1) f =<< f i) iterateM n f i = sequence . scanl (>>=) (return i) $ replicate n f The former uses primitive recursion, and I get the feeling it should be better written without it. The latter is quadratic time ? it builds up a list of monadic actions, and then runs them each in turn. Can anyone think of a version that combines the benefits of the two? Bob From tom.davie at gmail.com Wed Apr 8 11:00:27 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Wed Apr 8 10:47:19 2009 Subject: [Haskell-cafe] Re: A challenge Message-ID: <574E81FD-F75C-4A49-86A3-E6EE22DD769D@gmail.com> Woops, the second version there applies it one too many times, it should have been replicate (n-1) f. Bob From fft1976 at gmail.com Wed Apr 8 11:20:13 2009 From: fft1976 at gmail.com (FFT) Date: Wed Apr 8 11:07:01 2009 Subject: [Haskell-cafe] GHC needs a 64 bit machine to be fast? In-Reply-To: References: Message-ID: On Wed, Apr 8, 2009 at 3:21 AM, Roel van Dijk wrote: >> Suspiciously, "ghc -O2 ?--make" is almost as fast at 24.438s (6.10.2) > > You have to be careful when recompiling with a different -O setting > that you first remove all intermediate files (.o and .hi). I think > that GHC only looks at the source to determine which files need to be > compiled and not at any settings. > Thanks, I noticed that. All these timings were done after the removal of intermediate files and recompilation. From jonathanccast at fastmail.fm Wed Apr 8 11:20:20 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Wed Apr 8 11:07:11 2009 Subject: [Haskell-cafe] A challenge In-Reply-To: <4EC40AC5-3AF7-4063-94F3-D1B702969E85@gmail.com> References: <4EC40AC5-3AF7-4063-94F3-D1B702969E85@gmail.com> Message-ID: <1239204020.6474.8.camel@jonathans-macbook> On Wed, 2009-04-08 at 16:57 +0200, Thomas Davie wrote: > We have two possible definitions of an "iterateM" function: > > iterateM 0 _ _ = return [] > iterateM n f i = (i:) <$> (iterateM (n-1) f =<< f i) > > iterateM n f i = sequence . scanl (>>=) (return i) $ replicate n f > > The former uses primitive recursion, and I get the feeling it should > be better written without it. The latter is quadratic time ? it > builds up a list of monadic actions, and then runs them each in turn. It's also quadratic in invocations of f, no? If your monad's (>>=) doesn't object to being left-associated (which is *not* the case for free monads), then I think iterateM n f i = foldl (>>=) (return i) $ replicate n f would be both correct and linear. If you're monad's (>>=) is itsef quadratic in time when left-associated, you can try applying a CPS transformation to fix the problem.[1] jcc [1] http://wwwtcs.inf.tu-dresden.de/~voigt/mpc08.pdf From tom.davie at gmail.com Wed Apr 8 11:30:37 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Wed Apr 8 11:17:33 2009 Subject: [Haskell-cafe] A challenge In-Reply-To: <1239204020.6474.8.camel@jonathans-macbook> References: <4EC40AC5-3AF7-4063-94F3-D1B702969E85@gmail.com> <1239204020.6474.8.camel@jonathans-macbook> Message-ID: <6903A5B4-EB9F-4534-A9EA-23ADED75ED59@gmail.com> On 8 Apr 2009, at 17:20, Jonathan Cast wrote: > On Wed, 2009-04-08 at 16:57 +0200, Thomas Davie wrote: >> We have two possible definitions of an "iterateM" function: >> >> iterateM 0 _ _ = return [] >> iterateM n f i = (i:) <$> (iterateM (n-1) f =<< f i) >> >> iterateM n f i = sequence . scanl (>>=) (return i) $ replicate n f >> >> The former uses primitive recursion, and I get the feeling it should >> be better written without it. The latter is quadratic time ? it >> builds up a list of monadic actions, and then runs them each in turn. > > It's also quadratic in invocations of f, no? If your monad's (>>=) > doesn't object to being left-associated (which is *not* the case for > free monads), then I think > > iterateM n f i = foldl (>>=) (return i) $ replicate n f But this isn't the same function ? it only gives back the final result, not the intermediaries. Bob From claus.reinke at talk21.com Wed Apr 8 12:21:49 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Wed Apr 8 12:08:46 2009 Subject: [Haskell-cafe] A challenge References: <4EC40AC5-3AF7-4063-94F3-D1B702969E85@gmail.com> Message-ID: <332C8BC2B7674FB393110C742CA2FDD8@cr3lt> |iterateM 0 _ _ = return [] |iterateM n f i = (i:) <$> (iterateM (n-1) f =<< f i) |iterateM' n f i = sequence . scanl (>>=) (return i) $ replicate n f These function are not the same (sequence of scanl? try using print in f). Also, I seriously hope you are not looking for this line noise:-) iterateM' = (foldr op (const $ return []) .) . replicate where f `op` x = uncurry (<$>) . ((:) &&& ((x =<<) . f)) Because if you do, your penance for using it would involve demonstrating that this is equivalent (+-1), or not (and do not mention my name anywhere near it!-) Claus From dav.vire+haskell at gmail.com Wed Apr 8 12:26:49 2009 From: dav.vire+haskell at gmail.com (david48) Date: Wed Apr 8 12:13:39 2009 Subject: [Haskell-cafe] Trying to write 'safeFromInteger' In-Reply-To: <404396ef0904080555t4cc22c8et10dd0c2e021cafdc@mail.gmail.com> References: <7fb8f82f0904080509t6677570dta762f3fd7d74c6b9@mail.gmail.com> <4c88418c0904080536o75c1d8f4gd9c87b5c77475e53@mail.gmail.com> <404396ef0904080555t4cc22c8et10dd0c2e021cafdc@mail.gmail.com> Message-ID: <4c88418c0904080926o2cff0b1t12a9d6a7d669fe9a@mail.gmail.com> On Wed, Apr 8, 2009 at 2:55 PM, Neil Mitchell wrote: > That seems a really weird way to write it! Who decided all auxiliary > functions should be called go? (I think I'm blaming dons) - why not: > > sffi :: (Integral a,Num a) => Integer -> Maybe a > sffi n | toInteger n2 == n = Just n2 > | otherwise = Nothing > where n2 = fromInteger n I know I was too lazy to clean it up :-P ( I also blame Dons for 'go' ) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090408/a56b08f9/attachment.htm From bugfact at gmail.com Wed Apr 8 12:33:29 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 8 12:20:18 2009 Subject: [Haskell-cafe] A challenge In-Reply-To: <6903A5B4-EB9F-4534-A9EA-23ADED75ED59@gmail.com> References: <4EC40AC5-3AF7-4063-94F3-D1B702969E85@gmail.com> <1239204020.6474.8.camel@jonathans-macbook> <6903A5B4-EB9F-4534-A9EA-23ADED75ED59@gmail.com> Message-ID: I don't think scanl can work here, since the monadic action has to be applied to the result of previous one and will have a side effect, so if you build a list like [return i, return i >>= f, return i >>= f >>= f, ...] the first action will do nothing, the second action will have a single side effect, but the third one will have 3 side effects instead of 2, because it operates on the side-effect performed by the second one. This seems to work (a combination of manual state monad and foldM, I could also have used a state monad transformer I guess) iterateM n f i = foldM collectEffect (i,[]) (replicate n f) >>= return . reverse . snd where collectEffect (x,rs) f = f x >>= \y -> return (y,y:rs) Ugly test: var = unsafePerformIO $ newIORef 0 inc i = do x <- readIORef var let y = x+i writeIORef var y return y results in *Main> iterateM 10 inc 1 [1,2,4,8,16,32,64,128,256,512] *Main> iterateM 10 inc 1 [513,1026,2052,4104,8208,16416,32832,65664,131328,262656] but maybe this is not what you're looking for? On Wed, Apr 8, 2009 at 5:30 PM, Thomas Davie wrote: > > On 8 Apr 2009, at 17:20, Jonathan Cast wrote: > > On Wed, 2009-04-08 at 16:57 +0200, Thomas Davie wrote: >> >>> We have two possible definitions of an "iterateM" function: >>> >>> iterateM 0 _ _ = return [] >>> iterateM n f i = (i:) <$> (iterateM (n-1) f =<< f i) >>> >>> iterateM n f i = sequence . scanl (>>=) (return i) $ replicate n f >>> >>> The former uses primitive recursion, and I get the feeling it should >>> be better written without it. The latter is quadratic time ? it >>> builds up a list of monadic actions, and then runs them each in turn. >>> >> >> It's also quadratic in invocations of f, no? If your monad's (>>=) >> doesn't object to being left-associated (which is *not* the case for >> free monads), then I think >> >> iterateM n f i = foldl (>>=) (return i) $ replicate n f >> > > But this isn't the same function ? it only gives back the final result, not > the intermediaries. > > Bob_______________________________________________ > > 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/20090408/32fb1057/attachment.htm From bugfact at gmail.com Wed Apr 8 12:38:24 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 8 12:25:13 2009 Subject: [Haskell-cafe] A challenge In-Reply-To: References: <4EC40AC5-3AF7-4063-94F3-D1B702969E85@gmail.com> <1239204020.6474.8.camel@jonathans-macbook> <6903A5B4-EB9F-4534-A9EA-23ADED75ED59@gmail.com> Message-ID: Oh, I could have written it in more point free style (with arguments reversed) as iterateM n i = fmap (reverse . snd) . foldM collectEffect (i,[]) . replicate n where collectEffect (x,rs) f = f x >>= \y -> return (y,y:rs) and I'm sure collectEffect could also be improved, but I'm still in newbieeee land On Wed, Apr 8, 2009 at 6:33 PM, Peter Verswyvelen wrote: > I don't think scanl can work here, since the monadic action has to be > applied to the result of previous one and will have a side effect, so if you > build a list like > [return i, return i >>= f, return i >>= f >>= f, ...] > > the first action will do nothing, the second action will have a single side > effect, but the third one will have 3 side effects instead of 2, because it > operates on the side-effect performed by the second one. > > This seems to work (a combination of manual state monad and foldM, I could > also have used a state monad transformer I guess) > > iterateM n f i = foldM collectEffect (i,[]) (replicate n f) >>= return . > reverse . snd > where > collectEffect (x,rs) f = f x >>= \y -> return (y,y:rs) > > Ugly test: > > var = unsafePerformIO $ newIORef 0 > > inc i = do > x <- readIORef var > let y = x+i > writeIORef var y > return y > > results in > > *Main> iterateM 10 inc 1 > [1,2,4,8,16,32,64,128,256,512] > *Main> iterateM 10 inc 1 > [513,1026,2052,4104,8208,16416,32832,65664,131328,262656] > > but maybe this is not what you're looking for? > > > > > > > > > On Wed, Apr 8, 2009 at 5:30 PM, Thomas Davie wrote: > >> >> On 8 Apr 2009, at 17:20, Jonathan Cast wrote: >> >> On Wed, 2009-04-08 at 16:57 +0200, Thomas Davie wrote: >>> >>>> We have two possible definitions of an "iterateM" function: >>>> >>>> iterateM 0 _ _ = return [] >>>> iterateM n f i = (i:) <$> (iterateM (n-1) f =<< f i) >>>> >>>> iterateM n f i = sequence . scanl (>>=) (return i) $ replicate n f >>>> >>>> The former uses primitive recursion, and I get the feeling it should >>>> be better written without it. The latter is quadratic time ? it >>>> builds up a list of monadic actions, and then runs them each in turn. >>>> >>> >>> It's also quadratic in invocations of f, no? If your monad's (>>=) >>> doesn't object to being left-associated (which is *not* the case for >>> free monads), then I think >>> >>> iterateM n f i = foldl (>>=) (return i) $ replicate n f >>> >> >> But this isn't the same function ? it only gives back the final result, >> not the intermediaries. >> >> Bob_______________________________________________ >> >> 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/20090408/32114a46/attachment.htm From dagit at codersbase.com Wed Apr 8 12:38:25 2009 From: dagit at codersbase.com (Jason Dagit) Date: Wed Apr 8 12:25:23 2009 Subject: [Haskell-cafe] Trying to write 'safeFromInteger' In-Reply-To: <4c88418c0904080926o2cff0b1t12a9d6a7d669fe9a@mail.gmail.com> References: <7fb8f82f0904080509t6677570dta762f3fd7d74c6b9@mail.gmail.com> <4c88418c0904080536o75c1d8f4gd9c87b5c77475e53@mail.gmail.com> <404396ef0904080555t4cc22c8et10dd0c2e021cafdc@mail.gmail.com> <4c88418c0904080926o2cff0b1t12a9d6a7d669fe9a@mail.gmail.com> Message-ID: On Wed, Apr 8, 2009 at 9:26 AM, david48 wrote: > > > On Wed, Apr 8, 2009 at 2:55 PM, Neil Mitchell wrote: >> >> That seems a really weird way to write it! Who decided all auxiliary >> functions should be called go? (I think I'm blaming dons) - why not: >> >> sffi :: (Integral a,Num a) => Integer -> Maybe a >> sffi n | toInteger n2 == n = Just n2 >> ? ? ? ?| otherwise = Nothing >> ? ? where n2 = fromInteger n > > I know I was too lazy to clean it up :-P > ( I also blame Dons for 'go' ) I think the Common Lisp community tends to use 'foo-aux' instead of 'go' for these sort of axillary functions. But, then in Haskell we can't use hyphen as an identify character and underscore is not popular. For this reason I started using fooAux in Haskell, but after learning that a single quote is valid identifier character I started using foo'. Other than using go and foo', what do people use in Haskell? Jason From dons at galois.com Wed Apr 8 12:38:18 2009 From: dons at galois.com (Don Stewart) Date: Wed Apr 8 12:26:11 2009 Subject: [Haskell-cafe] stream fusion -- multi-module programs In-Reply-To: <42784f260904080524u2623f148h24ae34d3e1932874@mail.gmail.com> References: <42784f260904080524u2623f148h24ae34d3e1932874@mail.gmail.com> Message-ID: <20090408163818.GC12268@whirlpool.galois.com> jason.dusek: > In the paper "Stream Fusion: From Streams To Lists To Nothing > At All", we find: > > For large multi-module programs, the results are less clear, > with just as many programs speeding up as slowing down. We > ?nd that for larger programs, GHC has a tendency to miss > optimisation op- portunities for stream fusible functions > across module boundaries, which is the subject of further > investigation. > > What's the state of these things? Is this still an issue for > stream fusion? I think it just needs rerunning in light of all the inliner changes over the past 2 years. The kinds of programs I write in practice don't seem to suffer, but I tend not to use concatMap on stream. -- Don From dons at galois.com Wed Apr 8 12:40:02 2009 From: dons at galois.com (Don Stewart) Date: Wed Apr 8 12:27:54 2009 Subject: [Haskell-cafe] GHC needs a 64 bit machine to be fast? In-Reply-To: References: Message-ID: <20090408164002.GE12268@whirlpool.galois.com> GCC is generating very different code on 32 bit and 64 bit. fft1976: > Not that this is a very good benchmark, but I compiled the nearly > equivalent C and Haskell (1st, recursive version) programs from this > blog post: > > http://donsbot.wordpress.com/2008/06/04/haskell-as-fast-as-c-working-at-a-high-altitude-for-low-level-performance/ > > There, in both versions, 1e9 iterations take 1.8s. > > However, in my timing on 32-bit Linux machines, the C version is 5-10 > times faster. Does the bitness of the OS make a big difference? > > Here are my timings on a 3.4GHz Pentium D: > > C : 4.072s (GCC 4.2.4) > Haskell : 22.481s (GHC 6.10.2 and 6.8.2 are about the same here) > > I used the exact same compiler options as in the blog post. I only added > > import System > import Text.Printf > > to the Haskell program, which seems to be missing. > > Suspiciously, "ghc -O2 --make" is almost as fast at 24.438s (6.10.2) > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jonathanccast at fastmail.fm Wed Apr 8 12:44:01 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Wed Apr 8 12:30:52 2009 Subject: [Haskell-cafe] A challenge In-Reply-To: <6903A5B4-EB9F-4534-A9EA-23ADED75ED59@gmail.com> References: <4EC40AC5-3AF7-4063-94F3-D1B702969E85@gmail.com> <1239204020.6474.8.camel@jonathans-macbook> <6903A5B4-EB9F-4534-A9EA-23ADED75ED59@gmail.com> Message-ID: <1239209041.12998.14.camel@jcchost> On Wed, 2009-04-08 at 17:30 +0200, Thomas Davie wrote: > On 8 Apr 2009, at 17:20, Jonathan Cast wrote: > > > On Wed, 2009-04-08 at 16:57 +0200, Thomas Davie wrote: > >> We have two possible definitions of an "iterateM" function: > >> > >> iterateM 0 _ _ = return [] > >> iterateM n f i = (i:) <$> (iterateM (n-1) f =<< f i) > >> iterateM n f i = sequence . scanl (>>=) (return i) $ replicate n f > >> > >> The former uses primitive recursion, and I get the feeling it should > >> be better written without it. The latter is quadratic time ? it > >> builds up a list of monadic actions, and then runs them each in turn. > > > > It's also quadratic in invocations of f, no? If your monad's (>>=) > > doesn't object to being left-associated (which is *not* the case for > > free monads), then I think > > > > iterateM n f i = foldl (>>=) (return i) $ replicate n f > > But this isn't the same function ? it only gives back the final > result, not the intermediaries. True. Should have read more carefully. jcc From bugfact at gmail.com Wed Apr 8 12:52:52 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 8 12:39:42 2009 Subject: [Haskell-cafe] A challenge In-Reply-To: References: <4EC40AC5-3AF7-4063-94F3-D1B702969E85@gmail.com> <1239204020.6474.8.camel@jonathans-macbook> <6903A5B4-EB9F-4534-A9EA-23ADED75ED59@gmail.com> Message-ID: Well okay, I don't really need the state since it is already in the list... So cleaned up iterateM n i = fmap (tail . reverse) . foldM collectEffect [i] . replicate n where collectEffect xxs@(x:xs) f = fmap (:xxs) (f x) But I'm sure it can be much simpler (I don't understand Claus' version :-) On Wed, Apr 8, 2009 at 6:38 PM, Peter Verswyvelen wrote: > Oh, I could have written it in more point free style (with arguments > reversed) as > iterateM n i = fmap (reverse . snd) . > foldM collectEffect (i,[]) . > replicate n > where > collectEffect (x,rs) f = f x >>= \y -> return (y,y:rs) > > and I'm sure collectEffect could also be improved, but I'm still in > newbieeee land > > On Wed, Apr 8, 2009 at 6:33 PM, Peter Verswyvelen wrote: > >> I don't think scanl can work here, since the monadic action has to be >> applied to the result of previous one and will have a side effect, so if you >> build a list like >> [return i, return i >>= f, return i >>= f >>= f, ...] >> >> the first action will do nothing, the second action will have a single >> side effect, but the third one will have 3 side effects instead of 2, >> because it operates on the side-effect performed by the second one. >> >> This seems to work (a combination of manual state monad and foldM, I could >> also have used a state monad transformer I guess) >> >> iterateM n f i = foldM collectEffect (i,[]) (replicate n f) >>= return . >> reverse . snd >> where >> collectEffect (x,rs) f = f x >>= \y -> return (y,y:rs) >> >> Ugly test: >> >> var = unsafePerformIO $ newIORef 0 >> >> inc i = do >> x <- readIORef var >> let y = x+i >> writeIORef var y >> return y >> >> results in >> >> *Main> iterateM 10 inc 1 >> [1,2,4,8,16,32,64,128,256,512] >> *Main> iterateM 10 inc 1 >> [513,1026,2052,4104,8208,16416,32832,65664,131328,262656] >> >> but maybe this is not what you're looking for? >> >> >> >> >> >> >> >> >> On Wed, Apr 8, 2009 at 5:30 PM, Thomas Davie wrote: >> >>> >>> On 8 Apr 2009, at 17:20, Jonathan Cast wrote: >>> >>> On Wed, 2009-04-08 at 16:57 +0200, Thomas Davie wrote: >>>> >>>>> We have two possible definitions of an "iterateM" function: >>>>> >>>>> iterateM 0 _ _ = return [] >>>>> iterateM n f i = (i:) <$> (iterateM (n-1) f =<< f i) >>>>> >>>>> iterateM n f i = sequence . scanl (>>=) (return i) $ replicate n f >>>>> >>>>> The former uses primitive recursion, and I get the feeling it should >>>>> be better written without it. The latter is quadratic time ? it >>>>> builds up a list of monadic actions, and then runs them each in turn. >>>>> >>>> >>>> It's also quadratic in invocations of f, no? If your monad's (>>=) >>>> doesn't object to being left-associated (which is *not* the case for >>>> free monads), then I think >>>> >>>> iterateM n f i = foldl (>>=) (return i) $ replicate n f >>>> >>> >>> But this isn't the same function ? it only gives back the final result, >>> not the intermediaries. >>> >>> Bob_______________________________________________ >>> >>> 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/20090408/e29ad055/attachment.htm From josef.svenningsson at gmail.com Wed Apr 8 13:05:14 2009 From: josef.svenningsson at gmail.com (Josef Svenningsson) Date: Wed Apr 8 12:52:04 2009 Subject: [Haskell-cafe] A challenge In-Reply-To: <4EC40AC5-3AF7-4063-94F3-D1B702969E85@gmail.com> References: <4EC40AC5-3AF7-4063-94F3-D1B702969E85@gmail.com> Message-ID: <8dde104f0904081005l62a99985l6e3fde1b70a2c029@mail.gmail.com> On Wed, Apr 8, 2009 at 4:57 PM, Thomas Davie wrote: > > We have two possible definitions of an "iterateM" function: > > iterateM 0 _ _ = return [] > iterateM n f i = (i:) <$> (iterateM (n-1) f =<< f i) > > iterateM n f i = sequence . scanl (>>=) (return i) $ replicate n f > > The former uses primitive recursion, and I get the feeling it should be better written without it. The latter is quadratic time ? it builds up a list of monadic actions, and then runs them each in turn. > > Can anyone think of a version that combines the benefits of the two? There seems to be a combinator missing in Control.Monad. Several people have suggested that iterateM should be implemented using a fold. But that seems very unnatural, we're trying to *build* a list, not *consume* it. This suggests that we should use an unfold function instead. Now, I haven't found one in the standard libraries that works for monads but arguably there should be one. So, let's pretend that the following function exists: unfoldM :: Monad m => (b -> m (Maybe(a,b))) -> b -> m [a] Then the implementation of iterateM becomes more natural: \begin{code} iterateM n f i = unfoldM g (n,i) where g (0,i) = return Nothing g (n,i) = do j <- f i return (Just (i,(n-1,j))) \end{code} I'm not sure whether this version is to your satisfaction but it's quite intuitive IMHO. Here's the function I used to test various versions of iterateM: \begin{code} test it = it 4 (\i -> putStrLn (show i) >> return (i+1)) 0 \end{code} Cheers, Josef -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090408/d0efb3b2/attachment.htm From tom.davie at gmail.com Wed Apr 8 13:05:20 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Wed Apr 8 12:52:13 2009 Subject: [Haskell-cafe] A challenge In-Reply-To: <332C8BC2B7674FB393110C742CA2FDD8@cr3lt> References: <4EC40AC5-3AF7-4063-94F3-D1B702969E85@gmail.com> <332C8BC2B7674FB393110C742CA2FDD8@cr3lt> Message-ID: <01878A74-9951-41F2-87DA-ABF24839897F@gmail.com> On 8 Apr 2009, at 18:21, Claus Reinke wrote: > |iterateM 0 _ _ = return [] > |iterateM n f i = (i:) <$> (iterateM (n-1) f =<< f i) > > |iterateM' n f i = sequence . scanl (>>=) (return i) $ replicate n f > > These function are not the same (sequence of scanl? try using print > in f). Also, I seriously hope you are not looking for this line > noise:-) No indeed ? that's what I meant about the latter being quadratic ? it runs the action far more times than the other. > > iterateM' = (foldr op (const $ return []) .) . replicate > where f `op` x = uncurry (<$>) . ((:) &&& ((x =<<) . f)) > > Because if you do, your penance for using it would involve > demonstrating that this is equivalent (+-1), or not (and do not > mention my name anywhere near it!-) ghci tells me this: Prelude Control.Applicative Control.Arrow> let iterateM' = let f `op` x = uncurry (<$>) . ((:) &&& ((x=<<) . f)) in (foldr op (const $ return []) .) . replicate :1:92: Ambiguous type variable `m' in the constraints: `Monad m' arising from a use of `return' at : 1:92-100 `Functor m' arising from a use of `op' at :1:80-81 Probable fix: add a type signature that fixes these type variable(s) From tom.davie at gmail.com Wed Apr 8 13:11:00 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Wed Apr 8 12:57:53 2009 Subject: [Haskell-cafe] A challenge In-Reply-To: <8dde104f0904081005l62a99985l6e3fde1b70a2c029@mail.gmail.com> References: <4EC40AC5-3AF7-4063-94F3-D1B702969E85@gmail.com> <8dde104f0904081005l62a99985l6e3fde1b70a2c029@mail.gmail.com> Message-ID: On 8 Apr 2009, at 19:05, Josef Svenningsson wrote: > On Wed, Apr 8, 2009 at 4:57 PM, Thomas Davie > wrote: > > > > We have two possible definitions of an "iterateM" function: > > > > iterateM 0 _ _ = return [] > > iterateM n f i = (i:) <$> (iterateM (n-1) f =<< f i) > > > > iterateM n f i = sequence . scanl (>>=) (return i) $ replicate n f > > > > The former uses primitive recursion, and I get the feeling it > should be better written without it. The latter is quadratic time ? > it builds up a list of monadic actions, and then runs them each in > turn. > > > > Can anyone think of a version that combines the benefits of the two? > > There seems to be a combinator missing in Control.Monad. Several > people have suggested that iterateM should be implemented using a > fold. But that seems very unnatural, we're trying to *build* a list, > not *consume* it. This suggests that we should use an unfold > function instead. Now, I haven't found one in the standard libraries > that works for monads but arguably there should be one. So, let's > pretend that the following function exists: > unfoldM :: Monad m => (b -> m (Maybe(a,b))) -> b -> m [a] > > Then the implementation of iterateM becomes more natural: > \begin{code} > iterateM n f i = unfoldM g (n,i) > where g (0,i) = return Nothing > g (n,i) = do j <- f i > return (Just (i,(n-1,j))) > \end{code} > I'm not sure whether this version is to your satisfaction but it's > quite intuitive IMHO. That one certainly seems very natural to me, now if only unfoldM existed :) Bob From josef.svenningsson at gmail.com Wed Apr 8 13:17:09 2009 From: josef.svenningsson at gmail.com (Josef Svenningsson) Date: Wed Apr 8 13:03:59 2009 Subject: [Haskell-cafe] A challenge In-Reply-To: References: <4EC40AC5-3AF7-4063-94F3-D1B702969E85@gmail.com> <8dde104f0904081005l62a99985l6e3fde1b70a2c029@mail.gmail.com> Message-ID: <8dde104f0904081017g71a34cbh33b5af58e89f21f5@mail.gmail.com> On Wed, Apr 8, 2009 at 7:11 PM, Thomas Davie wrote: > > On 8 Apr 2009, at 19:05, Josef Svenningsson wrote: > > On Wed, Apr 8, 2009 at 4:57 PM, Thomas Davie wrote: >> > >> > We have two possible definitions of an "iterateM" function: >> > >> > iterateM 0 _ _ = return [] >> > iterateM n f i = (i:) <$> (iterateM (n-1) f =<< f i) >> > >> > iterateM n f i = sequence . scanl (>>=) (return i) $ replicate n f >> > >> > The former uses primitive recursion, and I get the feeling it should be >> better written without it. The latter is quadratic time ? it builds up a >> list of monadic actions, and then runs them each in turn. >> > >> > Can anyone think of a version that combines the benefits of the two? >> >> There seems to be a combinator missing in Control.Monad. Several people >> have suggested that iterateM should be implemented using a fold. But that >> seems very unnatural, we're trying to *build* a list, not *consume* it. This >> suggests that we should use an unfold function instead. Now, I haven't found >> one in the standard libraries that works for monads but arguably there >> should be one. So, let's pretend that the following function exists: >> unfoldM :: Monad m => (b -> m (Maybe(a,b))) -> b -> m [a] >> >> Then the implementation of iterateM becomes more natural: >> \begin{code} >> iterateM n f i = unfoldM g (n,i) >> where g (0,i) = return Nothing >> g (n,i) = do j <- f i >> return (Just (i,(n-1,j))) >> \end{code} >> I'm not sure whether this version is to your satisfaction but it's quite >> intuitive IMHO. >> > > That one certainly seems very natural to me, now if only unfoldM existed :) > > Well, you can always write it yourself, but that might be a little excessive if you only want it for iterateM. The other option is of course to make a library proposal. The thing is, most people never use unfolds so I don't know how likely it is to be included. Cheers, Josef -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090408/4f7e1062/attachment-0001.htm From claus.reinke at talk21.com Wed Apr 8 13:32:51 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Wed Apr 8 13:20:46 2009 Subject: [Haskell-cafe] A challenge References: <4EC40AC5-3AF7-4063-94F3-D1B702969E85@gmail.com><332C8BC2B7674FB393110C742CA2FDD8@cr3lt> <01878A74-9951-41F2-87DA-ABF24839897F@gmail.com> Message-ID: <9C8495F14F6443CA8DAC9D748343726F@cr3lt> |No indeed ? that's what I meant about the latter being quadratic ? it |runs the action far more times than the other. 'quadratic time' usually refers to complexity, not different results, so I thought I'd mention it anyway. |ghci tells me this: |Prelude Control.Applicative Control.Arrow> let iterateM' = let f `op` |x = uncurry (<$>) . ((:) &&& ((x=<<) . f)) in (foldr op (const $ |return []) .) . replicate | |:1:92: | Ambiguous type variable `m' in the constraints: | `Monad m' arising from a use of `return' at : |1:92-100 | `Functor m' arising from a use of `op' at :1:80-81 | Probable fix: add a type signature that fixes these type |variable(s) But surely you have not enabled the monomorphism restriction while avoiding explicit recursion?-) I should, of course, have removed those nasty points - sorry about that, hope noone got hurt - to leave us with: (foldr (flip (((uncurry (<$>).).).((((:)&&&).).((.).(=<<))))) (const $ return []).) . replicate there, much better, isn't it? So obvious and clear that it doesn't even need a name anymore - it is fully declarative and self-explanatory. And it typechecks, so it must be correct!-) And it passes a test, so it isn't wrong, either!-) *Main> ((foldr (flip (((uncurry (<$>).).).((((:)&&&).).((.).(=<<))))) (const $ return []).) . replicate) 3 print () () () () [(),(),()] Sorry, just couldn't resist:-) Now, how do I get that tongue out of my cheek?-) Claus From sebf at informatik.uni-kiel.de Wed Apr 8 14:22:08 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Wed Apr 8 14:08:59 2009 Subject: [Haskell-cafe] Monads from Functors Message-ID: > {-# LANGUAGE Rank2Types #-} Dear Haskellers, I just realized that we get instances of `Monad` from pointed functors and instances of `MonadPlus` from alternative functors. Is this folklore? > import Control.Monad > import Control.Applicative In fact, every unary type constructor gives rise to a monad by the continuation monad transformer. > newtype ContT t a = ContT { unContT :: forall r . (a -> t r) -> t r } > > instance Monad (ContT t) > where > return x = ContT ($x) > m >>= f = ContT (\k -> unContT m (\x -> unContT (f x) k)) Both the `mtl` package and the `transformers` package use the same `Monad` instance for their `ContT` type but require `t` to be an instance of `Monad`. Why? [^1] If `f` is an applicative functor (in fact, a pointed functor is enough), then we can translate monadic actions back to the original type. > runContT :: Applicative f => ContT f a -> f a > runContT m = unContT m pure If `f` is an alternative functor, then `ContT f` is a `MonadPlus`. > instance Alternative f => MonadPlus (ContT f) > where > mzero = ContT (const empty) > a `mplus` b = ContT (\k -> unContT a k <|> unContT b k) That is no surprise because `empty` and `<|>` are just renamings for `mzero` and `mplus` (or the other way round). The missing piece was `>>=` which is provided by `ContT` for free. Are these instances defined somewhere? Cheers, Sebastian [^1] I recognized that Janis Voigtlaender defines the type `ContT` under the name `C` in Section 3 of his paper on "Asymptotic Improvement of Computations over Free Monads" (available at http://wwwtcs.inf.tu-dresden.de/~voigt/mpc08.pdf) and gives a monad instance without constraints on the first parameter. From martijn at van.steenbergen.nl Wed Apr 8 14:23:24 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed Apr 8 14:10:13 2009 Subject: [Haskell-cafe] Trying to write 'safeFromInteger' In-Reply-To: References: <7fb8f82f0904080509t6677570dta762f3fd7d74c6b9@mail.gmail.com> <4c88418c0904080536o75c1d8f4gd9c87b5c77475e53@mail.gmail.com> <404396ef0904080555t4cc22c8et10dd0c2e021cafdc@mail.gmail.com> <4c88418c0904080926o2cff0b1t12a9d6a7d669fe9a@mail.gmail.com> Message-ID: <49DCEB9C.6000802@van.steenbergen.nl> Jason Dagit wrote: > Other than using go and foo', what do people use in Haskell? If it's a predicate -> Bool I like to use "ok". Martijn. From antti-juhani at kaijanaho.fi Wed Apr 8 14:34:59 2009 From: antti-juhani at kaijanaho.fi (Antti-Juhani Kaijanaho) Date: Wed Apr 8 14:21:49 2009 Subject: Auxiliary function naming (Was: Re: [Haskell-cafe] Trying to write 'safeFromInteger') In-Reply-To: References: <7fb8f82f0904080509t6677570dta762f3fd7d74c6b9@mail.gmail.com> <4c88418c0904080536o75c1d8f4gd9c87b5c77475e53@mail.gmail.com> <404396ef0904080555t4cc22c8et10dd0c2e021cafdc@mail.gmail.com> <4c88418c0904080926o2cff0b1t12a9d6a7d669fe9a@mail.gmail.com> Message-ID: <20090408183457.GA5160@kukkaseppele.kaijanaho.fi> On Wed, Apr 08, 2009 at 09:38:25AM -0700, Jason Dagit wrote: > Other than using go and foo', what do people use in Haskell? I frequently use f and g. -- Antti-Juhani Kaijanaho, Jyv?skyl?, Finland http://antti-juhani.kaijanaho.fi/newblog/ http://www.flickr.com/photos/antti-juhani/ From bugfact at gmail.com Wed Apr 8 15:02:22 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 8 14:49:14 2009 Subject: [Haskell-cafe] How to install HOpenGL to Windows? In-Reply-To: <49DC32C3.2040200@gmail.com> References: <49DC32C3.2040200@gmail.com> Message-ID: 1) install "cabal-install". download this file and put it in a directory in your %PATH% 2) to compile most libraries on Hackage that link to C libraries via the FFI, you need to install MinGW and MSYS, as Jeff said explained here (many thanks to David Sankel for taking the time to write this). After you installed this, you have UNIX like environment and the GNU C compiler suite. 3) start MSYS, and type "cabal install opengl". This will download, configure, build and install opengl from hackage. this works for me. Instead of GLUT you can also use GLFW; the install this, just type "cabal install GLFW" On Wed, Apr 8, 2009 at 7:14 AM, Alexandr N. Zamaraev < tonal.promsoft@gmail.com> wrote: > I get darcs source HOpenGL > Try runghc Setup.hs configure > I see: > Configuring OpenGL-2.3... > Warning: The 'build-type' is 'Configure' but there is no 'configure' > script. > Setup.hs: configure script not found. > > runghc Setup.hs build wrote: > Preprocessing library OpenGL-2.3... > Building OpenGL-2.3... > > Graphics\Rendering\OpenGL\GL\ BasicTypes.hs:24:0: > HsOpenGLConfig.h: No such file or directory > > How to build HOpenGL? > > Os Windows Vista Home Ru + sp > ghc 6.10.1 > ______________________________ _________________ > 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/20090408/7df84259/attachment.htm From ketil at malde.org Wed Apr 8 15:47:52 2009 From: ketil at malde.org (Ketil Malde) Date: Wed Apr 8 15:33:28 2009 Subject: [Haskell-cafe] Functions from Data.Hashtable In-Reply-To: <49DBD7C9.3010601@freegeek.org> (wren ng thornton's message of "Tue\, 07 Apr 2009 18\:46\:33 -0400") References: <49DBD7C9.3010601@freegeek.org> Message-ID: <87ws9vnd07.fsf@malde.org> wren ng thornton writes: >> Data.HashTable.lookup :: HashTable key val -> key -> IO (Maybe val) >> Data.Map.lookup :: Ord key => key -> Map key val -> Maybe val > I'd guess it's due more to antiquity than to intention. I am fairly sure that FiniteMap, which preceeded Data.Map, had the same parameter order as HashTable. -k -- If I haven't seen further, it is by standing in the footprints of giants From xofon at pikomat.mff.cuni.cz Wed Apr 8 16:14:54 2009 From: xofon at pikomat.mff.cuni.cz (Petr Skovron) Date: Wed Apr 8 16:01:47 2009 Subject: [Haskell-cafe] Ghc: -O harmful? In-Reply-To: <200904062230.23844.daniel.is.fischer@web.de> References: <20090406181537.GA14402@pikomat.mff.cuni.cz> <20090406183746.GA3248@whirlpool.galois.com> <200904062230.23844.daniel.is.fischer@web.de> Message-ID: <20090408201454.GA27851@pikomat.mff.cuni.cz> > > -fno-state-hack? > > That, or > {-# LANGUAGE BangPatterns #-} > ... > ? !pole <- liftM (build n . map read . words) getLine Works for me, thanks! Petr From sebf at informatik.uni-kiel.de Wed Apr 8 16:30:21 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Wed Apr 8 16:17:14 2009 Subject: [Haskell-cafe] ANN: tree-monad 0.2 Message-ID: <95B47B80-19DF-4780-A122-72C87815C49A@informatik.uni-kiel.de> I am pleased to announce version 0.2 of the package tree-monad that provides instances of MonadPlus that represent the search space of non- deterministic computations as a tree. In version 0.2 I have implemented an optimized CPS version of the tree monad based on the idea described in "Asymptotic Improvement of Computations over Free Monads" [^1]. The package is on Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/tree-monad The sources are on Github: http://github.com/sebfisch/tree-monad Installation and usage instructions are at: http://sebfisch.github.com/tree-monad A possible application of search trees is parallel search as described in the blog post: http://www-ps.informatik.uni-kiel.de/~sebf/haskell/speedup-search-with-parallelism.lhs.html The package parallel-tree-search by Fabian Reck and myself http://hackage.haskell.org/cgi-bin/hackage-scripts/package/parallel-tree-search implements the search described in the above blog post based on the hereby announced package tree-monad. Cheers, Sebastian [^1]: http://wwwtcs.inf.tu-dresden.de/~voigt/mpc08.pdf From manlio_perillo at libero.it Wed Apr 8 16:31:26 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Wed Apr 8 16:18:19 2009 Subject: [Haskell-cafe] How to install HOpenGL to Windows? In-Reply-To: References: <49DC32C3.2040200@gmail.com> Message-ID: <49DD099E.5040101@libero.it> Peter Verswyvelen ha scritto: > 1) install "cabal-install". download this file > and > put it in a directory in your %PATH% > > 2) to compile most libraries on Hackage that link to C libraries via the > FFI, you need to install MinGW and MSYS, as Jeff said explained here > (many > thanks to David Sankel for taking the time to write this). After you > installed this, you have UNIX like environment and the GNU C compiler suite. > > 3) start MSYS, and type "cabal install opengl". This will download, > configure, build and install opengl from hackage. > > this works for me. > This is an overkill, really. IMHO, there should be no need to install an UNIX like environment on Windows. The problem, here, is that packages use autoconf. This should be avoided; instead Cabal should support some simple features for packages configuration. http://hackage.haskell.org/trac/hackage/ticket/530 Does HOpenGL really need all the features of autoconf? > [...] Regards Manlio From ben.franksen at online.de Wed Apr 8 17:20:08 2009 From: ben.franksen at online.de (Ben Franksen) Date: Wed Apr 8 17:07:09 2009 Subject: [Haskell-cafe] Re: Monads from Functors References: Message-ID: Sebastian Fischer wrote: > > {-# LANGUAGE Rank2Types #-} > > Dear Haskellers, > > I just realized that we get instances of `Monad` from pointed functors > and instances of `MonadPlus` from alternative functors. > > Is this folklore? > > > import Control.Monad > > import Control.Applicative > > In fact, every unary type constructor gives rise to a monad by the > continuation monad transformer. > > > newtype ContT t a = ContT { unContT :: forall r . (a -> t r) -> t r } > > > > instance Monad (ContT t) > > where > > return x = ContT ($x) > > m >>= f = ContT (\k -> unContT m (\x -> unContT (f x) k)) > > Both the `mtl` package and the `transformers` package use the same > `Monad` instance for their `ContT` type but require `t` to be an > instance of `Monad`. Why? [^1] Maybe because this is needed to prove monad laws? Hm, let's try it. m >>= return = ContT (\k -> unContT m (\x -> unContT (return x) k)) = ContT (\k -> unContT m (\x -> unContT (ContT ($x)) k)) = ContT (\k -> unContT m (\x -> ($x) k)) = ContT (\k -> unContT m (\x -> k x)) = ContT (\k -> unContT m k) = ContT (unContT m) = m return x >>= f = ContT (\k -> unContT (return x) (\x' -> unContT (f x') k)) = ContT (\k -> unContT (ContT ($x)) (\x' -> unContT (f x') k)) = ContT (\k -> ($x) (\x' -> unContT (f x') k)) = ContT (\k -> (\x' -> unContT (f x') k) x) = ContT (\k -> unContT (f x) k) = ContT (unContT (f x)) = f x (m >>= f) >>= g = ContT (\k -> unContT m (\x -> unContT (f x) k)) >>= g = ContT (\q -> unContT (ContT (\k -> unContT m (\x -> unContT (f x) k))) (\y -> unContT (g y) q)) = ContT (\q -> (\k -> unContT m (\x -> unContT (f x) k)) (\y -> unContT (g y) q)) = ContT (\q -> unContT m (\x -> unContT (f x) (\y -> unContT (g y) q))) = ContT (\q -> unContT m (\x -> (\k -> unContT (f x) (\y -> unContT (g y) k)) q)) = ContT (\q -> unContT m (\x -> unContT (ContT (\k -> unContT (f x) (\y -> unContT (g y) k))) q)) = ContT (\q -> unContT m (\x -> unContT (f x >>= g) q)) = ContT (\q -> unContT m (\x -> unContT ((\y -> f y >>= g) x) q)) = m >>= (\y -> f y >>= g) Uff. So, that wasn't the reason. It really is a monad. Cheers Ben From ekmett at gmail.com Wed Apr 8 17:23:33 2009 From: ekmett at gmail.com (Edward Kmett) Date: Wed Apr 8 17:10:21 2009 Subject: [Haskell-cafe] Monads from Functors In-Reply-To: References: Message-ID: <7fb8f82f0904081423xd6b8778n77e6caa78c96f49b@mail.gmail.com> I discovered them and bundled them up a year or so back in category-extras. http://comonad.com/haskell/category-extras/dist/doc/html/category-extras/Control-Monad-Codensity.html I also wrote a series of blog posts including the derivation of these and their dual in the form of right- and left- Kan extensions. http://comonad.com/reader/2008/kan-extensions/ http://comonad.com/reader/2008/kan-extensions-ii/ http://comonad.com/reader/2008/kan-extension-iii/ I shared with Janis Voigtlaender the connection to his asymptotic improvement in the performance of free monads paper as well. After I discovered the connection between these and that paper shortly thereafter. -Edward Kmett On Wed, Apr 8, 2009 at 2:22 PM, Sebastian Fischer < sebf@informatik.uni-kiel.de> wrote: > > {-# LANGUAGE Rank2Types #-} > > Dear Haskellers, > > I just realized that we get instances of `Monad` from pointed functors > and instances of `MonadPlus` from alternative functors. > > Is this folklore? > > > import Control.Monad > > import Control.Applicative > > In fact, every unary type constructor gives rise to a monad by the > continuation monad transformer. > > > newtype ContT t a = ContT { unContT :: forall r . (a -> t r) -> t r } > > > > instance Monad (ContT t) > > where > > return x = ContT ($x) > > m >>= f = ContT (\k -> unContT m (\x -> unContT (f x) k)) > > Both the `mtl` package and the `transformers` package use the same > `Monad` instance for their `ContT` type but require `t` to be an > instance of `Monad`. Why? [^1] > > If `f` is an applicative functor (in fact, a pointed functor is > enough), then we can translate monadic actions back to the original > type. > > > runContT :: Applicative f => ContT f a -> f a > > runContT m = unContT m pure > > If `f` is an alternative functor, then `ContT f` is a `MonadPlus`. > > > instance Alternative f => MonadPlus (ContT f) > > where > > mzero = ContT (const empty) > > a `mplus` b = ContT (\k -> unContT a k <|> unContT b k) > > That is no surprise because `empty` and `<|>` are just renamings for > `mzero` and `mplus` (or the other way round). The missing piece was > `>>=` which is provided by `ContT` for free. > > Are these instances defined somewhere? > > Cheers, > Sebastian > > [^1] I recognized that Janis Voigtlaender defines the type `ContT` > under the name `C` in Section 3 of his paper on "Asymptotic > Improvement of Computations over Free Monads" (available at > http://wwwtcs.inf.tu-dresden.de/~voigt/mpc08.pdf) and gives a monad > instance without constraints on the first parameter. > > _______________________________________________ > 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/20090408/2e419499/attachment.htm From ben.franksen at online.de Wed Apr 8 17:26:24 2009 From: ben.franksen at online.de (Ben Franksen) Date: Wed Apr 8 17:13:22 2009 Subject: [Haskell-cafe] Re: Trying to write 'safeFromInteger' References: <7fb8f82f0904080509t6677570dta762f3fd7d74c6b9@mail.gmail.com> <4c88418c0904080536o75c1d8f4gd9c87b5c77475e53@mail.gmail.com> <404396ef0904080555t4cc22c8et10dd0c2e021cafdc@mail.gmail.com> <4c88418c0904080926o2cff0b1t12a9d6a7d669fe9a@mail.gmail.com> Message-ID: Jason Dagit wrote: > On Wed, Apr 8, 2009 at 9:26 AM, david48 > wrote: >> >> >> On Wed, Apr 8, 2009 at 2:55 PM, Neil Mitchell >> wrote: >>> >>> That seems a really weird way to write it! Who decided all auxiliary >>> functions should be called go? (I think I'm blaming dons) - why not: >>> >>> sffi :: (Integral a,Num a) => Integer -> Maybe a >>> sffi n | toInteger n2 == n = Just n2 >>> | otherwise = Nothing >>> where n2 = fromInteger n >> >> I know I was too lazy to clean it up :-P >> ( I also blame Dons for 'go' ) > > I think the Common Lisp community tends to use 'foo-aux' instead of > 'go' for these sort of axillary functions. But, then in Haskell we > can't use hyphen as an identify character and underscore is not > popular. For this reason I started using fooAux in Haskell, but after > learning that a single quote is valid identifier character I started > using foo'. > > Other than using go and foo', what do people use in Haskell? You could combine Lisp and Haskell and say foo'aux :-) Cheers Ben From bugfact at gmail.com Wed Apr 8 18:28:35 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 8 18:15:26 2009 Subject: [Haskell-cafe] How to install HOpenGL to Windows? In-Reply-To: <49DD099E.5040101@libero.it> References: <49DC32C3.2040200@gmail.com> <49DD099E.5040101@libero.it> Message-ID: Yes I totally agree that it is overkill. Ideally I would like every package to install on Windows without requiring MinGW. But I was just explaining the situation as it is right now. On Wed, Apr 8, 2009 at 10:31 PM, Manlio Perillo wrote: > Peter Verswyvelen ha scritto: > >> 1) install "cabal-install". download this file < >> http://www.haskell.org/cabal/release/cabal-install-0.6.2/cabal.exe> and >> put it in a directory in your %PATH% >> >> 2) to compile most libraries on Hackage that link to C libraries via the >> FFI, you need to install MinGW and MSYS, as Jeff said explained here < >> http://netsuperbrain.com/blog/posts/freeglut-windows-hopengl-hglut/> >> (many thanks to David Sankel for taking the time to write this). After you >> installed this, you have UNIX like environment and the GNU C compiler suite. >> >> 3) start MSYS, and type "cabal install opengl". This will download, >> configure, build and install opengl from hackage. >> >> this works for me. >> >> > This is an overkill, really. > IMHO, there should be no need to install an UNIX like environment on > Windows. > > The problem, here, is that packages use autoconf. > This should be avoided; instead Cabal should support some simple features > for packages configuration. > > http://hackage.haskell.org/trac/hackage/ticket/530 > > Does HOpenGL really need all the features of autoconf? > > > [...] > > > Regards Manlio > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090409/e513273b/attachment.htm From dave at zednenem.com Wed Apr 8 18:58:45 2009 From: dave at zednenem.com (David Menendez) Date: Wed Apr 8 18:45:33 2009 Subject: [Haskell-cafe] Re: Monads from Functors In-Reply-To: References: Message-ID: <49a77b7a0904081558nd88edddkabfd67b87a4285af@mail.gmail.com> On Wed, Apr 8, 2009 at 5:20 PM, Ben Franksen wrote: > Sebastian Fischer wrote: >> ?> {-# LANGUAGE Rank2Types #-} >> >> Dear Haskellers, >> >> I just realized that we get instances of `Monad` from pointed functors >> and instances of `MonadPlus` from alternative functors. >> >> Is this folklore? >> >> ?> import Control.Monad >> ?> import Control.Applicative >> >> In fact, every unary type constructor gives rise to a monad by the >> continuation monad transformer. >> >> ?> newtype ContT t a = ContT { unContT :: forall r . (a -> t r) -> t r } >> ?> >> ?> instance Monad (ContT t) >> ?> ?where >> ?> ? return x = ContT ($x) >> ?> ? m >>= f ?= ContT (\k -> unContT m (\x -> unContT (f x) k)) >> >> Both the `mtl` package and the `transformers` package use the same >> `Monad` instance for their `ContT` type but require `t` to be an >> instance of `Monad`. Why? [^1] > > Maybe because this is needed to prove monad laws? > So, that wasn't the reason. It really is a monad. In general, ContT r m a is equivalent to Cont (m r) a, and their corresponding Monad instances are also equivalent. But Cont r is a monad for any r, which implies that ContT r m must be a monad for any r and m. -- Dave Menendez From lemming at henning-thielemann.de Wed Apr 8 19:13:58 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Apr 8 19:00:47 2009 Subject: [Haskell-cafe] PatternSignatures (rant) In-Reply-To: <49DC4E83.3060100@imn.htwk-leipzig.de> References: <49DC4E83.3060100@imn.htwk-leipzig.de> Message-ID: On Wed, 8 Apr 2009, Johannes Waldmann wrote: > Dear all, (this is a rant - please ignore) > > why has "PatternSignatures" > been renamed to "ScopedTypeVariables" (in ghc-6.10)? > > show me the alleged "type variable" in this code: > do x :: Int <- [ 1 .. 10 ] ; return $ x^2 > > and why on earth do I need to use a language extension at all > to get to the most basic thing of declarative programming: > to declare the type of an identifier? This would work: do x <- [ 1 .. 10 ] ; return $ (x::Int)^2 but I assume, that you want to declare the type on binding, right? From ben.franksen at online.de Wed Apr 8 19:24:19 2009 From: ben.franksen at online.de (Ben Franksen) Date: Wed Apr 8 19:11:22 2009 Subject: [Haskell-cafe] Re: Re: Monads from Functors References: <49a77b7a0904081558nd88edddkabfd67b87a4285af@mail.gmail.com> Message-ID: David Menendez wrote: > On Wed, Apr 8, 2009 at 5:20 PM, Ben Franksen > wrote: >> Sebastian Fischer wrote: >>> > {-# LANGUAGE Rank2Types #-} >>> >>> Dear Haskellers, >>> >>> I just realized that we get instances of `Monad` from pointed functors >>> and instances of `MonadPlus` from alternative functors. >>> >>> Is this folklore? >>> >>> > import Control.Monad >>> > import Control.Applicative >>> >>> In fact, every unary type constructor gives rise to a monad by the >>> continuation monad transformer. >>> >>> > newtype ContT t a = ContT { unContT :: forall r . (a -> t r) -> t r } >>> > >>> > instance Monad (ContT t) >>> > ?where >>> > ? return x = ContT ($x) >>> > ? m >>= f ?= ContT (\k -> unContT m (\x -> unContT (f x) k)) >>> >>> Both the `mtl` package and the `transformers` package use the same >>> `Monad` instance for their `ContT` type but require `t` to be an >>> instance of `Monad`. Why? [^1] >> >> Maybe because this is needed to prove monad laws? > > > >> So, that wasn't the reason. It really is a monad. > > In general, ContT r m a is equivalent to Cont (m r) a, and their > corresponding Monad instances are also equivalent. But Cont r is a > monad for any r, which implies that ContT r m must be a monad for any > r and m. But it was a nice little exercise, right? :-) BTW, is this (ContT t) somehow related to the 'free monad' over t? Cheers Ben From jonathanccast at fastmail.fm Wed Apr 8 19:37:23 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Wed Apr 8 19:24:13 2009 Subject: [Haskell-cafe] Re: Re: Monads from Functors In-Reply-To: References: <49a77b7a0904081558nd88edddkabfd67b87a4285af@mail.gmail.com> Message-ID: <1239233843.12998.41.camel@jcchost> On Thu, 2009-04-09 at 01:24 +0200, Ben Franksen wrote: > BTW, is this (ContT t) somehow related to the 'free monad' over t? The free monad over t is just data FreeMonad t a = Return a | JoinLift (t (FreeMonad t a)) instance Functor t => Monad (FreeMonad t) where return = Return Return x >>= f = f x JoinLift a >>= f = JoinLift ((>>= f) <$> a) lift :: Functor t => t a -> FreeMonad t a lift a = JoinLift (return <$> a) So they're obviously different. Here's what free monads are for: picking a functor f so that FreeMonad f becomes a randomly chosen monad :), we could define data IOStmt a = GetChar (Char -> a) | PutChar Char a instance Functor IOStmt where fmap f (GetChar g) = GetChar (f . g) fmap f (PutChar ch x) = PutChar ch (f x) getCharStmt :: IOStmt Char getCharStmt = GetChar id putCharStmt :: Char -> IOStmt () putCharStmt ch = PutChar ch () type IO = FreeMonad IOStmt getChar :: IO Char getChar = lift getCharStmt putChar :: Char -> IO () putChar = lift . putCharStmt jcc From ryani.spam at gmail.com Wed Apr 8 20:29:29 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Apr 8 20:16:16 2009 Subject: [Haskell-cafe] Monads from Functors In-Reply-To: References: Message-ID: <2f9b2d30904081729n604ce07as53c6e9f23d90f773@mail.gmail.com> On Wed, Apr 8, 2009 at 11:22 AM, Sebastian Fischer wrote: >> newtype ContT t a = ContT { unContT :: forall r . (a -> t r) -> t r } >> >> instance Monad (ContT t) >> ?where >> ? return x = ContT ($x) >> ? m >>= f ?= ContT (\k -> unContT m (\x -> unContT (f x) k)) > Both the `mtl` package and the `transformers` package use the same > `Monad` instance for their `ContT` type but require `t` to be an > instance of `Monad`. Why? [^1] You are missing one important piece of the puzzle for ContT: > lift :: Monad m => m a -> ContT m a > lift m = ContT $ \k -> m >>= k This >>= is the bind from the underlying monad. Without this operation, it's not very useful as a transformer! Without lift, it's quite difficult to get effects from the underlying Applicative *into* ContT. Similarily, your MonadPlus instance would be just as good replacing with the "free" alternative functor: data MPlus a = Zero | Pure a | Plus (MPlus a) (MPlus a) and then transforming MPlus into the desired type after runContT; it's the embedding of effects via lift that makes ContT useful. The CPS transfrom in ContT also has the nice property that it makes most applications of >>= in the underlying monad be right-associative. This is important for efficiency for some monads; especially free monads; the free monad discussed by jcc has an O(n^2) running cost for n left-associative applications of >>=. -- ryan From simon at joyful.com Thu Apr 9 04:10:53 2009 From: simon at joyful.com (Simon Michael) Date: Thu Apr 9 03:57:41 2009 Subject: [Haskell-cafe] OFX libs available ? Message-ID: <438C76F7-56FE-4019-88EC-5C4BC06D5889@joyful.com> Has anyone got code for OFX financial data handling they could share ? Best - Simon From martijn at van.steenbergen.nl Thu Apr 9 04:35:03 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Apr 9 04:21:51 2009 Subject: [Haskell-cafe] Ambiguous reified dictionaries Message-ID: <49DDB337.2050205@van.steenbergen.nl> Good morning, The [1]GHC user's guide, section 8.4.5 says: "The new feature is that pattern-matching on MkSet (as in the definition of insert) makes available an (Eq a) context. In implementation terms, the MkSet constructor has a hidden field that stores the (Eq a) dictionary that is passed to MkSet; so when pattern-matching that dictionary becomes available for the right-hand side of the match." But what happens if there are several dictionaries available? Consider these three modules: ReifyMonoid.hs: > {-# LANGUAGE GADTs #-} > > module ReifyMonoid where > > import Data.Monoid > > data MonoidInst a where > MkMonoidInst :: Monoid a => MonoidInst a ReifySum.hs: > module ReifySum where > > import ReifyMonoid > import Data.Monoid > > instance Monoid Int where > mempty = 0 > mappend = (+) > > intSum :: MonoidInst Int > intSum = MkMonoidInst ReifyProd.hs: > module ReifyProd where > > import ReifyMonoid > import Data.Monoid > > instance Monoid Int where > mempty = 1 > mappend = (*) > > intProd :: MonoidInst Int > intProd = MkMonoidInst Now a function > emp :: MonoidInst a -> a > emp MkMonoidInst = mempty works as you'd expect: *ReifySum ReifyProd> emp intSum 0 *ReifySum ReifyProd> emp intProd 1 But what about this function? > empAmb :: MonoidInst a -> MonoidInst a -> a > empAmb MkMonoidInst MkMonoidInst = mempty Now there are two dictionaries available. GHC consistently picks the one from the second argument: *ReifySum ReifyProd> empAmb intProd intSum 1 *ReifySum ReifyProd> empAmb intSum intProd 0 My questions are: 1) Shouldn't GHC reject this as being ambiguous? 2) Should class constraints only be available on existentially qualified type variables to prevent this from happening at all? 3) Is it possible to implement the following function? > mkMonoidInst :: a -> (a -> a -> a) -> MonoidInst a > mkMonoidInst mempty mappend = ... Thank you, Martijn. [1] http://www.haskell.org/ghc/docs/latest/html/users_guide/data-type-extensions.html#gadt-style From lennart at augustsson.net Thu Apr 9 04:54:13 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Thu Apr 9 04:41:00 2009 Subject: [Haskell-cafe] Ambiguous reified dictionaries In-Reply-To: <49DDB337.2050205@van.steenbergen.nl> References: <49DDB337.2050205@van.steenbergen.nl> Message-ID: That program is incorrect, it contains two instances for Monoid Int, and the compiler should flag it as illegal. -- Lennart On Thu, Apr 9, 2009 at 10:35 AM, Martijn van Steenbergen wrote: > Good morning, > > The [1]GHC user's guide, section 8.4.5 says: > > "The new feature is that pattern-matching on MkSet (as in the definition of > insert) makes available an (Eq a) context. In implementation terms, the > MkSet constructor has a hidden field that stores the (Eq a) dictionary that > is passed to MkSet; so when pattern-matching that dictionary becomes > available for the right-hand side of the match." > > But what happens if there are several dictionaries available? > > Consider these three modules: > > ReifyMonoid.hs: > >> {-# LANGUAGE GADTs #-} >> >> module ReifyMonoid where >> >> import Data.Monoid >> >> data MonoidInst a where >> ?MkMonoidInst :: Monoid a => MonoidInst a > > ReifySum.hs: > >> module ReifySum where >> >> import ReifyMonoid >> import Data.Monoid >> >> instance Monoid Int where >> ?mempty = 0 >> ?mappend = (+) >> >> intSum :: MonoidInst Int >> intSum = MkMonoidInst > > ReifyProd.hs: > >> module ReifyProd where >> >> import ReifyMonoid >> import Data.Monoid >> >> instance Monoid Int where >> ?mempty = 1 >> ?mappend = (*) >> >> intProd :: MonoidInst Int >> intProd = MkMonoidInst > > Now a function > >> emp :: MonoidInst a -> a >> emp MkMonoidInst = mempty > > works as you'd expect: > > *ReifySum ReifyProd> emp intSum > 0 > *ReifySum ReifyProd> emp intProd > 1 > > But what about this function? > >> empAmb :: MonoidInst a -> MonoidInst a -> a >> empAmb MkMonoidInst MkMonoidInst = mempty > > Now there are two dictionaries available. GHC consistently picks the one > from the second argument: > > *ReifySum ReifyProd> empAmb intProd intSum > 1 > *ReifySum ReifyProd> empAmb intSum intProd > 0 > > My questions are: > > 1) Shouldn't GHC reject this as being ambiguous? > 2) Should class constraints only be available on existentially qualified > type variables to prevent this from happening at all? > 3) Is it possible to implement the following function? > >> mkMonoidInst :: a -> (a -> a -> a) -> MonoidInst a >> mkMonoidInst mempty mappend = ... > > Thank you, > > Martijn. > > > > [1] > http://www.haskell.org/ghc/docs/latest/html/users_guide/data-type-extensions.html#gadt-style > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From martijn at van.steenbergen.nl Thu Apr 9 04:57:24 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Apr 9 04:44:10 2009 Subject: [Haskell-cafe] Ambiguous reified dictionaries In-Reply-To: References: <49DDB337.2050205@van.steenbergen.nl> Message-ID: <49DDB874.50804@van.steenbergen.nl> Lennart Augustsson wrote: > That program is incorrect, it contains two instances for Monoid Int, > and the compiler should flag it as illegal. Two simultaneous instances are okay as long as you don't use any of those instances, right? Just like two imported symbols with the same name are okay as long as you don't use them. Martijn. From ndmitchell at gmail.com Thu Apr 9 05:12:16 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Thu Apr 9 04:59:04 2009 Subject: [Haskell-cafe] Trying to write 'safeFromInteger' In-Reply-To: References: <7fb8f82f0904080509t6677570dta762f3fd7d74c6b9@mail.gmail.com> <4c88418c0904080536o75c1d8f4gd9c87b5c77475e53@mail.gmail.com> <404396ef0904080555t4cc22c8et10dd0c2e021cafdc@mail.gmail.com> <4c88418c0904080926o2cff0b1t12a9d6a7d669fe9a@mail.gmail.com> Message-ID: <404396ef0904090212t4981aa12u5b526900eb33cebe@mail.gmail.com> >>> That seems a really weird way to write it! Who decided all auxiliary >>> functions should be called go? (I think I'm blaming dons) - why not: >>> >>> sffi :: (Integral a,Num a) => Integer -> Maybe a >>> sffi n | toInteger n2 == n = Just n2 >>> ? ? ? ?| otherwise = Nothing >>> ? ? where n2 = fromInteger n >> >> I know I was too lazy to clean it up :-P >> ( I also blame Dons for 'go' ) > > I think the Common Lisp community tends to use 'foo-aux' instead of > 'go' for these sort of axillary functions. ?But, then in Haskell we > can't use hyphen as an identify character and underscore is not > popular. ?For this reason I started using fooAux in Haskell, but after > learning that a single quote is valid identifier character I started > using foo'. > > Other than using go and foo', what do people use in Haskell? I use f, if I need several auxiliary functions I start at f and work my way up alphabetically. I tend to go back to f2 if I go past h. Be grateful you don't have to maintain my code :-) Thanks Neil PS. Here is some code from the filepath library I wrote, illustrating how fantastic my naming scheme looks. (I think if I was writing it today I'd have used a list comprehension for validChars, eliminating f.) makeValid path = joinDrive drv $ validElements $ validChars pth where (drv,pth) = splitDrive path validChars x = map f x f x | x `elem` badCharacters = '_' | otherwise = x validElements x = joinPath $ map g $ splitPath x g x = h (reverse b) ++ reverse a where (a,b) = span isPathSeparator $ reverse x h x = if map toUpper a `elem` badElements then a ++ "_" <.> b else x where (a,b) = splitExtensions x From simonpj at microsoft.com Thu Apr 9 05:14:12 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Thu Apr 9 05:01:04 2009 Subject: [Haskell-cafe] Ambiguous reified dictionaries In-Reply-To: References: <49DDB337.2050205@van.steenbergen.nl> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C335081889AC@EA-EXMSG-C334.europe.corp.microsoft.com> Yes, Haskell says that in any program there should be only one instance for any particular type (here Monoid Int). GHC doesn't check that, but it should really do so. It's not necessary for soundness (ie no runtime crash) but it is necessary for coherence (ie when you run the program the answer you get doesn't depend on which dictionary the typechecker arbitrarily chose). [When type functions are involved, having a unique instance is necessary for soundness as well as coherence.] This isn't the only place there may be a choice of dictionaries. Consider class Eq a => C a where ... class Eq a => D a where ... f :: (C a, D a) => a -> ... f x = ....(x==x).... Here the type checker can get the Eq dictionary it needs for (x==x) from either the (C a) dictionary or the (D a) dictionary. | > 3) Is it possible to implement the following function? | > | >> mkMonoidInst :: a -> (a -> a -> a) -> MonoidInst a | >> mkMonoidInst mempty mappend = ... No it's not possible. And now you know why! Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On | Behalf Of Lennart Augustsson | Sent: 09 April 2009 09:54 | To: Martijn van Steenbergen | Cc: Haskell Cafe | Subject: Re: [Haskell-cafe] Ambiguous reified dictionaries | | That program is incorrect, it contains two instances for Monoid Int, | and the compiler should flag it as illegal. | | -- Lennart | | On Thu, Apr 9, 2009 at 10:35 AM, Martijn van Steenbergen | wrote: | > Good morning, | > | > The [1]GHC user's guide, section 8.4.5 says: | > | > "The new feature is that pattern-matching on MkSet (as in the definition of | > insert) makes available an (Eq a) context. In implementation terms, the | > MkSet constructor has a hidden field that stores the (Eq a) dictionary that | > is passed to MkSet; so when pattern-matching that dictionary becomes | > available for the right-hand side of the match." | > | > But what happens if there are several dictionaries available? | > | > Consider these three modules: | > | > ReifyMonoid.hs: | > | >> {-# LANGUAGE GADTs #-} | >> | >> module ReifyMonoid where | >> | >> import Data.Monoid | >> | >> data MonoidInst a where | >> MkMonoidInst :: Monoid a => MonoidInst a | > | > ReifySum.hs: | > | >> module ReifySum where | >> | >> import ReifyMonoid | >> import Data.Monoid | >> | >> instance Monoid Int where | >> mempty = 0 | >> mappend = (+) | >> | >> intSum :: MonoidInst Int | >> intSum = MkMonoidInst | > | > ReifyProd.hs: | > | >> module ReifyProd where | >> | >> import ReifyMonoid | >> import Data.Monoid | >> | >> instance Monoid Int where | >> mempty = 1 | >> mappend = (*) | >> | >> intProd :: MonoidInst Int | >> intProd = MkMonoidInst | > | > Now a function | > | >> emp :: MonoidInst a -> a | >> emp MkMonoidInst = mempty | > | > works as you'd expect: | > | > *ReifySum ReifyProd> emp intSum | > 0 | > *ReifySum ReifyProd> emp intProd | > 1 | > | > But what about this function? | > | >> empAmb :: MonoidInst a -> MonoidInst a -> a | >> empAmb MkMonoidInst MkMonoidInst = mempty | > | > Now there are two dictionaries available. GHC consistently picks the one | > from the second argument: | > | > *ReifySum ReifyProd> empAmb intProd intSum | > 1 | > *ReifySum ReifyProd> empAmb intSum intProd | > 0 | > | > My questions are: | > | > 1) Shouldn't GHC reject this as being ambiguous? | > 2) Should class constraints only be available on existentially qualified | > type variables to prevent this from happening at all? | > 3) Is it possible to implement the following function? | > | >> mkMonoidInst :: a -> (a -> a -> a) -> MonoidInst a | >> mkMonoidInst mempty mappend = ... | > | > Thank you, | > | > Martijn. | > | > | > | > [1] | > http://www.haskell.org/ghc/docs/latest/html/users_guide/data-type- | extensions.html#gadt-style | > _______________________________________________ | > 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 sebf at informatik.uni-kiel.de Thu Apr 9 05:22:54 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Thu Apr 9 05:09:51 2009 Subject: [Haskell-cafe] Monads from Functors In-Reply-To: <2f9b2d30904081729n604ce07as53c6e9f23d90f773@mail.gmail.com> References: <2f9b2d30904081729n604ce07as53c6e9f23d90f773@mail.gmail.com> Message-ID: <06CFEA36-F348-4BFD-B6C5-0D745FC07CBC@informatik.uni-kiel.de> Hi all, thanks for pointing me at the Codensity monad and for mentioning the lift operation! I'll try to sum up what I learned from this thread. In short: What I find interesting is 1. you can express the results of monadic computations using functors that do not themselves support the `>>=` operation. You only need an equivalent of `return`. and 2. a variety of *non-*monadic effects (e.g., non-determinism) can be lifted to this "monad for free", so you get, e.g., a non-determinism *monad* even if all you have is a non-determinism *functor*. Here is the long version: Because `ContT` makes a monad out of anything with kind `* -> *`, we also get instances for `Functor` and `Applicative` for free. We could use the `Monad` instance to get them for free by `Control.Applicative.WrappedMonad` but defining them from scratch might be insightful, so let's try. We could define an instance of `Functor` for `ContT t` as follows. instance Functor (ContT t) where fmap = liftM But let's see what we get if we inline this definition: fmap f a = liftM f a = a >>= return . f = ContT (\k -> unContT a (\x -> unContT (return (f x)) k)) = ContT (\k -> unContT a (\x -> unContT (ContT ($f x)) k)) = ContT (\k -> unContT a (\x -> k (f x))) That leads to the `Functor` instance described in the first post on Kan extensions by Edward Kmett. > instance Functor (ContT t) > where > fmap f a = ContT (\k -> unContT a (k.f)) We also get an Applicative instance for free: instance Applicative (ContT t) where pure = return (<*>) = ap If we inline `ap` we get f <*> a = f `ap` a = f >>= \g -> a >>= \x -> return (g x) = ContT (\k1 -> unContT f (\x1 -> unContT (a >>= \x -> return (x1 x)) k1)) = ... = ContT (\k -> unContT f (\g -> unContT a (\x -> k (g x)))) So, a direct Applicative` instance would be: > instance Applicative (ContT t) > where > pure x = ContT ($x) > f <*> a = ContT (\k -> unContT f (\g -> unContT a (\x -> k (g x)))) The more interesting bits are conversions between the original and the lifted types. As mentioned earlier, if `f` is a pointed functor, then we can convert values of type `ContT f a` to values of type `f a`. runContT :: Pointed f => ContT f a -> f a runContT a = unContT a point Ryan Ingram pointed in the other direction: > You are missing one important piece of the puzzle for ContT: > > ~~~ > lift :: Monad m => m a -> ContT m a > lift m = ContT $ \k -> m >>= k > ~~~ > > This >>= is the bind from the underlying monad. Without this > operation, it's not very useful as a transformer! That is a fine reason for the *class* declaration of `MonadTrans` to mention `Monad m` as a constraint for `lift`. But as `ContT t` is a monad for any `t :: * -> *`, a constraint `Monad t` on the *instance* declaration for `Monad (ContT t)` is moot. This constraint is not necessary to define `lift`. > instance MonadTrans ContT > where > lift m = ContT (m>>=) Ryan continues: > Without lift, it's quite difficult to get effects from the > underlying Applicative *into* ContT. Similarily, your MonadPlus > instance would be just as good replacing with the "free" > alternative functor: > > ~~~ > data MPlus a = Zero | Pure a | Plus (MPlus a) (MPlus a) > ~~~ > > and then transforming MPlus into the desired type after runContT; > it's the embedding of effects via lift that makes ContT useful. Let's see whether I got your point here. If we have a computation a :: Monad m => m a and we have a pointed functor `f`, then we can get the result of the computation `a` in our functor `f` because `runContT a :: f a`. If we now have a computation with additional monadic effects (I use non-determinism as a specific effect, but Edward Kmett shows in his second post on Kan extensions how to lift other effects like Reader, State, and IO) b :: MonadPlus m => m b then we have two possibilities to express the result using `f` if `f` is also an alternative functor. 1. If `f` is itself a monad (i.e. an instance of MonadPlus), then the expression `runContT (lift b)` has type `f b`. (Well, `b` itself has type `f b`..) 2. If `f` is *not* a monad, we can still get the result of `b` in our functor `f` (using the `MonadPlus` instance from my previous mail), because `runContT b` also has type `f b`. Clearly, `runContT (lift b)` (or `b` itself) and `runContT b` may behave differently (even if they both (can) have the type `f b`) because `ContT` 'overwrites' the definition for `>>=` of `f` if `f` has one. So it depends on the application which of those behaviours is desired. Ryan: > The CPS transfrom in ContT also has the nice property that it makes > most applications of >>= in the underlying monad be > right-associative. Do you have a specific reason to say *most* (rather than *all*) here? Because if we have a left-associative application of `>>=` in `ContT`, then we have: (a >>= f) >>= g = ContT (\k1 -> unContT (a >>= f) (\x1 -> unContT (g x1) k1)) = ContT (\k1 -> unContT (ContT (\k2 -> unContT a (\x2 -> unContT (f x2) k2))) (\x1 -> unContT (g x1) k1) = ContT (\k1 -> unContT a (\x2 -> unContT (f x2) (\x1 -> unContT (g x1) k1))) = ContT (\k1 -> unContT a (\x2 -> unContT (ContT (\k2 -> unContT (f x2) (\x1 -> unContT (g x1) k2))) k1)) = ContT (\k1 -> unContT a (\x2 -> unContT (f x2 >>= g) k1)) = a >>= (\x -> f x >>= g) Cheers, Sebastian From martijn at van.steenbergen.nl Thu Apr 9 05:26:00 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Apr 9 05:12:47 2009 Subject: [Haskell-cafe] Ambiguous reified dictionaries In-Reply-To: <49DDB874.50804@van.steenbergen.nl> References: <49DDB337.2050205@van.steenbergen.nl> <49DDB874.50804@van.steenbergen.nl> Message-ID: <49DDBF28.8050603@van.steenbergen.nl> Martijn van Steenbergen wrote: > Two simultaneous instances are okay as long as you don't use any of > those instances, right? Just like two imported symbols with the same > name are okay as long as you don't use them. This makes little sense. Sorry, my bad. I was thinking about instances available in the complete module instead of also those made available by pattern matching on constructors. Martijn. From v.dijk.bas at gmail.com Thu Apr 9 06:40:53 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Thu Apr 9 06:27:42 2009 Subject: [Haskell-cafe] How to define a common return and bind? Message-ID: Hello, Suppose you have defined a monad transformer such as: > newtype T1 m a = T1 { unT1 :: A1 m a } Where 'A1 m' is an arbitrary monad of your choosing. For this discussion we just take the identity: > type A1 m a = m a -- (can be any monad) If you want to define a Monad instance for 'T1 m' you generally do this: instance Monad m => Monad (T1 m) where return = T1 . return m >>= f = T1 $ unT1 m >>= unT1 . f (I know I can use the 'GeneralizedNewtypeDeriving' language extension to automatically derive a Monad but suppose that isn't available) Now when I define a new monad transformer: > newtype T2 m a = T2 { unT2 :: A2 m a } Where 'A2 m' is again an arbitrary monad of your choosing but for now just the identity: > type A2 m a = m a -- (can be any monad) The Monad instance for it is almost completely identical to the former: instance Monad m => Monad (T2 m) where return = T2 . return m >>= f = T2 $ unT2 m >>= unT2 . f Note that the only differences are: * a function to convert from the outer monad _to_ the inner monad: 'unT1' and 'unT2' * a function to convert _from_ the inner monad to the outer monad: 'T1' and 'T2' The common parts seem to be: liftReturn from = from . return liftBind from to m f = from $ to m >>= to . f My question is: can these be given suitable and general enough types so that they can be used to define Monad instances for monad transformers? In other words can I use them to write: instance Monad m => Monad (T1 m) where return = liftReturn T1 (>>=) = liftBind T1 unT1 and: instance Monad m => Monad (T2 m) where return = liftReturn T2 (>>=) = liftBind T2 unT2 Thanks, Bas From fft1976 at gmail.com Thu Apr 9 07:13:18 2009 From: fft1976 at gmail.com (FFT) Date: Thu Apr 9 07:00:04 2009 Subject: [Haskell-cafe] WX: linking to system libraries statically Message-ID: I noticed that even simple WX demos like "Layout" are linked dynamically against 59 libraries on Linux. This would make distributing the binaries a nightmare. Is there a simple way to make a (mostly) statically linked binary? From h.guenther at tu-bs.de Thu Apr 9 09:01:21 2009 From: h.guenther at tu-bs.de (Henning =?ISO-8859-1?Q?G=FCnther?=) Date: Thu Apr 9 08:48:16 2009 Subject: [Haskell-cafe] Debugging compile times (Template Haskell) Message-ID: <1239282081.5622.8.camel@localhost> Hi, as the author of the encoding package[1] I'm quite annoyed by the extreeme long time it takes to compile a certain module (JISX0208). This module uses template haskell to generate both a Map (Map Char (Word8,Word8)) and an Array (UArray (Word8,Word8) Int) for character conversion. The file has about 6000 entries and the generated array has 8649 entries. Generating the syntax for the array and map is very fast (under a second) but compiling the code seems to take forever. Is there any way to find out why that is the case? I've tried pinpointing the problem but couldn't... [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/encoding -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090409/89a961c6/attachment.bin From pkeir at dcs.gla.ac.uk Thu Apr 9 09:44:42 2009 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Thu Apr 9 09:31:32 2009 Subject: [Haskell-cafe] ghci *.hs Message-ID: <3CDFB8AFEA98E34CB599475AB11589C82C3D28@EX2.ad.dcs.gla.ac.uk> Hi all, I like to use ghci *.hs to start my session, but I then have to type :m +Main to bring the Main module into scope. Is there a command-line switch to control which modules are initially in scope with ghci? Thanks, Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090409/f4aa6f29/attachment.htm From bulat.ziganshin at gmail.com Thu Apr 9 09:45:12 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Apr 9 09:32:16 2009 Subject: [Haskell-cafe] Debugging compile times (Template Haskell) In-Reply-To: <1239282081.5622.8.camel@localhost> References: <1239282081.5622.8.camel@localhost> Message-ID: <1794173828.20090409174512@gmail.com> Hello Henning, Thursday, April 9, 2009, 5:01:21 PM, you wrote: i think that this case may be interesting for GHC developers > Hi, > as the author of the encoding package[1] I'm quite annoyed by the > extreeme long time it takes to compile a certain module (JISX0208). This > module uses template haskell to generate both a Map (Map Char > (Word8,Word8)) and an Array (UArray (Word8,Word8) Int) for character > conversion. The file has about 6000 entries and the generated array has > 8649 entries. Generating the syntax for the array and map is very fast > (under a second) but compiling the code seems to take forever. > Is there any way to find out why that is the case? I've tried > pinpointing the problem but couldn't... > [1] > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/encoding -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bugfact at gmail.com Thu Apr 9 10:16:50 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Apr 9 10:03:38 2009 Subject: [Haskell-cafe] GHC: compile using multiple cores? Message-ID: Is it possible to use all CPU cores when compiling with GHC and/or Cabal? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090409/dc875380/attachment.htm From rodrigo.bonifacio at uol.com.br Thu Apr 9 10:43:53 2009 From: rodrigo.bonifacio at uol.com.br (rodrigo.bonifacio) Date: Thu Apr 9 10:30:53 2009 Subject: [Haskell-cafe] Problems getting errors with HXT Message-ID: <49de09a91c342_61321555555879b46f8@weasel17.tmail> An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090409/60c4d373/attachment.htm From barsoap at web.de Thu Apr 9 10:51:53 2009 From: barsoap at web.de (Achim Schneider) Date: Thu Apr 9 10:38:54 2009 Subject: [Haskell-cafe] Re: GHC: compile using multiple cores? References: Message-ID: <20090409165153.552b0e99@solaris> Peter Verswyvelen wrote: > Is it possible to use all CPU cores when compiling with GHC and/or > Cabal? > Nope. Last thing I heard is that file-parallel compilation is low priority as not much would be gained anyway due to excessive cross-package stuff that's done and much stricter dependencies than say C (which you can compile in about any order you like). I guess if such a thing happens, it'd be most likely in the form of strategically placed `par`'s inside of compiler stages. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From ketil at malde.org Thu Apr 9 11:30:28 2009 From: ketil at malde.org (Ketil Malde) Date: Thu Apr 9 11:16:05 2009 Subject: [Haskell-cafe] Trying to write 'safeFromInteger' In-Reply-To: <404396ef0904090212t4981aa12u5b526900eb33cebe@mail.gmail.com> (Neil Mitchell's message of "Thu\, 9 Apr 2009 10\:12\:16 +0100") References: <7fb8f82f0904080509t6677570dta762f3fd7d74c6b9@mail.gmail.com> <4c88418c0904080536o75c1d8f4gd9c87b5c77475e53@mail.gmail.com> <404396ef0904080555t4cc22c8et10dd0c2e021cafdc@mail.gmail.com> <4c88418c0904080926o2cff0b1t12a9d6a7d669fe9a@mail.gmail.com> <404396ef0904090212t4981aa12u5b526900eb33cebe@mail.gmail.com> Message-ID: <87zlepn8tn.fsf@malde.org> Neil Mitchell writes: >> Other than using go and foo', what do people use in Haskell? I tend to use 'go' for recursive or iterative functions. Which I belive is the original dons idiom. I occasionally use foo', but it is all too easy to write foo when you mean foo', and, which is worse, it occasionally happens to compile. > I use f, if I need several auxiliary functions I start at f and work > my way up alphabetically. :-) > makeValid path = joinDrive drv $ validElements $ validChars pth > where > (drv,pth) = splitDrive path > > validChars x = map f x > f x | x `elem` badCharacters = '_' > | otherwise = x In cases like this, I use names like 'foo1', since it does 'foo' for one element. So here I'd name 'f' something like 'valid1'. -k -- If I haven't seen further, it is by standing in the footprints of giants From dons at galois.com Thu Apr 9 11:30:28 2009 From: dons at galois.com (Don Stewart) Date: Thu Apr 9 11:18:21 2009 Subject: [Haskell-cafe] Re: GHC: compile using multiple cores? In-Reply-To: <20090409165153.552b0e99@solaris> References: <20090409165153.552b0e99@solaris> Message-ID: <20090409153028.GB16775@whirlpool.galois.com> barsoap: > Peter Verswyvelen wrote: > > > Is it possible to use all CPU cores when compiling with GHC and/or > > Cabal? > > > Nope. Last thing I heard is that file-parallel compilation is low > priority as not much would be gained anyway due to excessive > cross-package stuff that's done and much stricter dependencies than say > C (which you can compile in about any order you like). I guess if such > a thing happens, it'd be most likely in the form of strategically > placed `par`'s inside of compiler stages. > Not with cabal, with GHC, yes: assuming you have enough modules. Use ghc -M to dump a makefile, and then make -j20 (or whatever you have) -- Don From mark.spezzano at chariot.net.au Thu Apr 9 11:47:08 2009 From: mark.spezzano at chariot.net.au (Mark Spezzano) Date: Thu Apr 9 11:34:23 2009 Subject: [Haskell-cafe] Referential Transparency and Monads Message-ID: <002501c9b92a$71e50810$55af1830$@spezzano@chariot.net.au> Hi, How exactly do monads “solve” the problem of referential transparency? I understand RT to be such that a function can be replaced with a actual value. Since a monad could potentially encapsulate any other value—say, data read from a keyboard—doesn’t that violate the assumption of RT on monads? Or does RT ignore the encapsulated data and just view the “action” performed by the monad as the “value” of the monad? Just curious as to the rationale behind referential transparency and how it applies to monads. Cheers, Mark Spezzano No virus found in this outgoing message. Checked by AVG. Version: 7.5.557 / Virus Database: 270.11.48/2048 - Release Date: 8/04/2009 7:02 PM -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090410/462a82c6/attachment.htm From ndmitchell at gmail.com Thu Apr 9 11:51:47 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Thu Apr 9 11:38:36 2009 Subject: [Haskell-cafe] Re: GHC: compile using multiple cores? In-Reply-To: <20090409153028.GB16775@whirlpool.galois.com> References: <20090409165153.552b0e99@solaris> <20090409153028.GB16775@whirlpool.galois.com> Message-ID: <404396ef0904090851k2288f0des9f6a8dc200b3c14b@mail.gmail.com> > Not with cabal, with GHC, yes: assuming you have enough modules. Use ghc > -M to dump a makefile, and then make -j20 (or whatever you have) There is a performance penalty to running ghc on separate files vs --make. If your number of core's is limited --make may be better. I'd love someone to figure out what the cross over point is :-) As a related question, how does GHC implement -j3? For my programs, if I want to run in parallel, I have to type +RTS -N3. Can I use the same trick as GHC? Thanks Neil From simonpj at microsoft.com Thu Apr 9 12:01:00 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Thu Apr 9 11:47:48 2009 Subject: [Haskell-cafe] Strange type error with associated type synonyms In-Reply-To: <3E3186D9A0F34311825C9D476DB9F1D9@cr3lt> References: <646230a00904061436x41af1055se39e8892eb4e3083@mail.gmail.com><4580278B-D5B6-4A4E-9233-415B57F60A3E@cse.unsw.edu.au><1bc51a990904070348p7e6fc849qeaa45b155279e435@mail.gmail.com> <9DC371FCEE914C19966965FB38881AC1@cr3lt> <638ABD0A29C8884A91BC5FB5C349B1C335080DECA1@EA-EXMSG-C334.europe.corp.microsoft.com> <3E3186D9A0F34311825C9D476DB9F1D9@cr3lt> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C33508188D5B@EA-EXMSG-C334.europe.corp.microsoft.com> | | -- f' :: forall d a. (Fun d) => Memo d a -> Memo d a | | f' = abst . (id :: (d->a)->(d->a)) . appl | | | | There is a perfectly valid type signature for f', as given in | | comment, but GHCi gives an incorrect one (the same as for f): | | | | *Main> :browse Main | | class Fun d where | | abst :: (d -> a) -> Memo d a | | appl :: Memo d a -> d -> a | | f :: (Fun d) => Memo d a -> Memo d a | | f' :: (Fun d) => Memo d a -> Memo d a | | >I'm missing something here. Those types are identical to the one given | >in your type signature for f' above, save that the forall is suppressed | >(because you are allowed to omit it, and GHC generally does when | >printing types). | | Not with ScopedTypeVariables, though, where explicit foralls have | been given an additional significance. Uncommenting the f' signature works, while | dropping the | 'forall d a' from it fails with | the usual match failure due to ambiguity "Couldn't match expected | type `Memo d1' against inferred type `Memo d'". Oh now i see what you mean: consider f' = abst . (id :: (d->a)->(d->a)) . appl which GHC understands to mean f' = abst . (id :: forall d a. (d->a)->(d->a)) . appl GHC infers the type f' :: (Fun d) => Memo d a -> Memo d a Now you are saying that GHC *could* have figured out that if it added the signature f' :: forall d a. (Fun d) => Memo d a -> Memo d a thereby *changing* the scoping of d,a in the buried signature for 'id', doing so would not change whether f' was typeable or not. Well maybe, but that is way beyond what I have any current plans to do. S From pkeir at dcs.gla.ac.uk Thu Apr 9 12:23:36 2009 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Thu Apr 9 12:12:26 2009 Subject: [Haskell-cafe] Referential Transparency and Monads References: Message-ID: <3CDFB8AFEA98E34CB599475AB11589C82C3D2A@EX2.ad.dcs.gla.ac.uk> I think this topic is covered in Andrew Gordon's dissertation/book: Functional programming and input/output by Andrew D. Gordon You can read it online. Cheers, Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090409/2b21b453/attachment.htm From allbery at ece.cmu.edu Thu Apr 9 12:31:13 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Apr 9 12:18:16 2009 Subject: [Haskell-cafe] Referential Transparency and Monads In-Reply-To: <002501c9b92a$71e50810$55af1830$@spezzano@chariot.net.au> References: <002501c9b92a$71e50810$55af1830$@spezzano@chariot.net.au> Message-ID: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@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/20090409/d220add3/PGP.bin From ryani.spam at gmail.com Thu Apr 9 12:59:22 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Apr 9 12:46:08 2009 Subject: [Haskell-cafe] Monads from Functors In-Reply-To: <06CFEA36-F348-4BFD-B6C5-0D745FC07CBC@informatik.uni-kiel.de> References: <2f9b2d30904081729n604ce07as53c6e9f23d90f773@mail.gmail.com> <06CFEA36-F348-4BFD-B6C5-0D745FC07CBC@informatik.uni-kiel.de> Message-ID: <2f9b2d30904090959q4511e161w85aa60bf04eb9465@mail.gmail.com> On Thu, Apr 9, 2009 at 2:22 AM, Sebastian Fischer wrote: > Let's see whether I got your point here. If we have a computation > > ? ?a :: Monad m => m a > > and we have a pointed functor `f`, then we can get the result of the > computation `a` in our functor `f` because `runContT a :: f a`. Sure, but you can also do the same much more simply: mkPointed :: Pointed f => forall f a. (forall m. Monad m => m a) -> f a mkPointed m = point $ runIdentity m > Clearly, `runContT (lift b)` (or `b` itself) and `runContT b` may > behave differently (even if they both (can) have the type `f b`) > because `ContT` 'overwrites' the definition for `>>=` of `f` if `f` > has one. So it depends on the application which of those behaviours is > desired. My point was slightly more general; what I was saying was there is not a huge use for the "generic" MonadPlus using Alternative, because without "lift", you have a hard time embedding any other effects from the applicative into the continuation use. You may as well do the following: > data MPlus a = Zero | Pure a | Plus (MPlus a) (MPlus a) > instance Monad MPlus where > return = Pure > Zero >>= k = Zero > Pure a >>= k = k a > Plus a b >>= k = Plus (a >>= k) (b >>= k) > instance MonadPlus MPlus where > mzero = Zero > mplus = Plus > mkAlternative :: forall f a. Alternative f => (forall m. MonadPlus m => m a) -> f a > mkAlternative m = convertPlus m where > convertPlus :: forall b. MPlus b -> f b > convertPlus Zero = empty > convertPlus (Pure a) = pure a > convertPlus (Plus a b) = convertPlus a <|> convertPlus b (all this code is really saying is that being polymorphic over MonadPlus is kind of dumb, because you aren't really using Monad at all) Without any way to lift other effects from the underlying functor into ContT, I don't really see how the "generic" ContT MonadPlus instance buys you much :) > Ryan: > ?> The CPS transfrom in ContT also has the nice property that it makes > ?> most applications of >>= in the underlying monad be > ?> right-associative. > > Do you have a specific reason to say *most* (rather than *all*) here? Yes, because > runContT ( (lift (a >>= f)) >>= g ) still has a left-associative >>=. Now of course that looks silly, but things aren't as simple as they seem; in particular I ran into this first when using Control.Monad.Prompt[1] (which is really just a sophisticated Cont monad with a nice interface) > data MPlus m a = Zero | Plus (m a) (m a) > > instance MonadPlus (RecPrompt MPlus) where > mzero = prompt Zero > mplus x y = prompt (Plus x y) > > runPlus :: forall a. RecPrompt MPlus r -> [r] > runPlus = runPromptC ret prm . unRecPrompt where > ret :: r -> [r] > ret x = [x] > > prm :: forall a. MPlus (RecPrompt MPlus) a -> (a -> [r]) -> [r] > prm Zero k = [] > prm (Plus a b) k = (runPlus a ++ runPlus b) >>= k > -- this >>= is in the list monad Now, consider runPlus ((mplus mzero (a >>= f)) >>= g), which uses the Plus "effect"; this will reduce to (runPlus (a >>= f)) >>= k where k is the continuation that runs g using "ret" and "prm" to convert to a list; the result still may have a left-associated >>= in it, depending on the value of "a" and "f". However, you're limited to at most one left associative bind per "recursive" lifted operation; the other binds will all be right-associative. I know this was a pretty in-depth example, so I hope I've made it clear :) -- ryan [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/MonadPrompt From ekmett at gmail.com Thu Apr 9 13:41:06 2009 From: ekmett at gmail.com (Edward Kmett) Date: Thu Apr 9 13:27:51 2009 Subject: [Haskell-cafe] Monads from Functors In-Reply-To: <06CFEA36-F348-4BFD-B6C5-0D745FC07CBC@informatik.uni-kiel.de> References: <2f9b2d30904081729n604ce07as53c6e9f23d90f773@mail.gmail.com> <06CFEA36-F348-4BFD-B6C5-0D745FC07CBC@informatik.uni-kiel.de> Message-ID: <7fb8f82f0904091041n36fa1739t8535322f75568554@mail.gmail.com> I think there is another way to view the ContT/Codensity/Monad generated by a functor, in terms of an accumulating parameter that may be informative. I kind of alluded to it in the post on Kan extensions. Take for a moment, Yoneda f given in: http://comonad.com/haskell/category-extras/src/Control/Functor/Yoneda.hs > newtype Yoneda f a = Yoneda { runYoneda :: forall b. (a -> b) -> f b } You can readily construct an instance of Functor for Yoneda without any concern for the underlying instance on f. > instance Functor (Yoneda f) where > fmap f m = Yoneda (\k -> runYoneda m (k . f)) > lowerYoneda :: Yoneda f a -> f a > lowerYoneda m = runYoneda m id Basically the operation of creating a value of type Yoneda f a requires you to use the fmap for the functor, so there is a Mendler-style encoding going on here, no magic dictionaries are required to use the resulting value. Now what I find interesting is that Yoneda is basically carrying around an accumulator for 'fmap' applications. Basically it enforces the fusion rule that fmap f . fmap g = fmap (f . g) by accumulating mappings and applying them in one go when you ask for the result. As an aside, when you extract a value out of (Yoneda f) uses the function it has accumulated so far, from pushing computations. And it has to use the secret valid version of fmap that you had to know to find a function that had the signature (forall a. (a -> b) -> f b) so no work is saved, its just fmap fusion. When you make a Monad out of Yoneda, that Monad can 'push' the map along to the next bind operation so it can come along for the ride, avoiding the need for an extra (>>=) to liftM the function you want to map. (It still has to appeal to the secret fmap you knew to make the Yoneda f a value!) Of course, this steps outside of the principles I'm espousing in this post by using a dictionary. > instance Monad f => Monad (Yoneda f) where > return a = Yoneda (\f -> return (f a)) > m >>= k = Yoneda (\f -> runYoneda m id >>= \a -> runYoneda (k a) f) When you look at the definition for Codensity f a, what it effectively supplies is a 'better accumulator', one which is large enough to encode (>>=). > newtype Codensity m a = Codensity { runCodensity :: forall b. (a -> m b) -> m b } > instance Monad (Codensity f) where > return x = Codensity (\k -> k x) > m >>= k = Codensity (\c -> runCodensity m (\a -> runCodensity (k a) c)) You then have to pass it a function of the type (a -> m b) to get the value out. Effectively you tell it how to return by injecting something. And since it can return and bind, you can define liftM thanks to the monad laws, giving an admissable implementation of Functor: > instance Functor (Codensity k) where > fmap f m = Codensity (\k -> runCodensity m (k . f)) Again no dictionaries were harmed in the encoding of this function and the type is no bigger than it needs to be to express these properties. The Codensity monad above can be seen as just an instance of enforced bind fusion, enforcing choice of association of (>>=). This consequence is logical because the result of a CPS transform is invariant under choice of reduction order. The reason I mention this is that this scenario is just an instance of a very general pattern of Mendler-style encoding. I have another example of Mendler-style encoding, this time for recursion schemes near the bottom of: http://knol.google.com/k/edward-kmett/catamorphisms/ I find this idiom to be rather effective when I want to enforce the equivalent of a rewrite rule or law about a type or work around the requirement that there can be only one instance of a particular typeclass. Yoneda doesn't care that f implements Functor, only that it satisfies the properties of a functor, and that fmap _could_ be defined for it. Codensity doesn't care that f is a monad. Well, it does if you want to do any computations with f, but you could have several different lifts to different monad/applicative 'instances' over f, as long as you lift into the codensity monad with a bind operation and lower back out with a return operation that agree. The dictionary for Monad m is irrelevant to the construction of Codensity m. > liftCodensity :: Monad m => m a -> Codensity m a > liftCodensity m = Codensity (m >>=) > lowerCodensity :: Monad m => Codensity m a -> m a > lowerCodensity a = runCodensity a return -Edward Kmett On Thu, Apr 9, 2009 at 5:22 AM, Sebastian Fischer < sebf@informatik.uni-kiel.de> wrote: > Hi all, > > thanks for pointing me at the Codensity monad and for mentioning the > lift operation! I'll try to sum up what I learned from this thread. > > In short: > > What I find interesting is > > 1. you can express the results of monadic computations using > functors that do not themselves support the `>>=` operation. You > only need an equivalent of `return`. > > and > > 2. a variety of *non-*monadic effects (e.g., non-determinism) can be > lifted to this "monad for free", so you get, e.g., a > non-determinism *monad* even if all you have is a non-determinism > *functor*. > > Here is the long version: > > Because `ContT` makes a monad out of anything with kind `* -> *`, we > also get instances for `Functor` and `Applicative` for free. We could > use the `Monad` instance to get them for free by > `Control.Applicative.WrappedMonad` but defining them from scratch > might be insightful, so let's try. > > We could define an instance of `Functor` for `ContT t` as follows. > > instance Functor (ContT t) > where > fmap = liftM > > But let's see what we get if we inline this definition: > > fmap f a > = liftM f a > = a >>= return . f > = ContT (\k -> unContT a (\x -> unContT (return (f x)) k)) > = ContT (\k -> unContT a (\x -> unContT (ContT ($f x)) k)) > = ContT (\k -> unContT a (\x -> k (f x))) > > That leads to the `Functor` instance described in the first post on > Kan extensions by Edward Kmett. > > > instance Functor (ContT t) > > where > > fmap f a = ContT (\k -> unContT a (k.f)) > > We also get an Applicative instance for free: > > instance Applicative (ContT t) > where > pure = return > (<*>) = ap > > If we inline `ap` we get > > f <*> a > = f `ap` a > = f >>= \g -> a >>= \x -> return (g x) > = ContT (\k1 -> unContT f (\x1 -> unContT (a >>= \x -> return (x1 x)) k1)) > = ... > = ContT (\k -> unContT f (\g -> unContT a (\x -> k (g x)))) > > So, a direct Applicative` instance would be: > > > instance Applicative (ContT t) > > where > > pure x = ContT ($x) > > f <*> a = ContT (\k -> unContT f (\g -> unContT a (\x -> k (g x)))) > > The more interesting bits are conversions between the original and the > lifted types. As mentioned earlier, if `f` is a pointed functor, then > we can convert values of type `ContT f a` to values of type `f a`. > > runContT :: Pointed f => ContT f a -> f a > runContT a = unContT a point > > Ryan Ingram pointed in the other direction: > > > You are missing one important piece of the puzzle for ContT: > > > > ~~~ > > lift :: Monad m => m a -> ContT m a > > lift m = ContT $ \k -> m >>= k > > ~~~ > > > > This >>= is the bind from the underlying monad. Without this > > operation, it's not very useful as a transformer! > > That is a fine reason for the *class* declaration of `MonadTrans` to > mention `Monad m` as a constraint for `lift`. But as `ContT t` is a > monad for any `t :: * -> *`, a constraint `Monad t` on the *instance* > declaration for `Monad (ContT t)` is moot. This constraint is not > necessary to define `lift`. > > > instance MonadTrans ContT > > where > > lift m = ContT (m>>=) > > Ryan continues: > > > Without lift, it's quite difficult to get effects from the > > underlying Applicative *into* ContT. Similarily, your MonadPlus > > instance would be just as good replacing with the "free" > > alternative functor: > > > > ~~~ > > data MPlus a = Zero | Pure a | Plus (MPlus a) (MPlus a) > > ~~~ > > > > and then transforming MPlus into the desired type after runContT; > > it's the embedding of effects via lift that makes ContT useful. > > Let's see whether I got your point here. If we have a computation > > a :: Monad m => m a > > and we have a pointed functor `f`, then we can get the result of the > computation `a` in our functor `f` because `runContT a :: f a`. > > If we now have a computation with additional monadic effects (I use > non-determinism as a specific effect, but Edward Kmett shows in his > second post on Kan extensions how to lift other effects like Reader, > State, and IO) > > b :: MonadPlus m => m b > > then we have two possibilities to express the result using `f` if `f` is > also an alternative functor. > > 1. If `f` is itself a monad (i.e. an instance of MonadPlus), then > the expression `runContT (lift b)` has type `f b`. (Well, `b` > itself has type `f b`..) > > 2. If `f` is *not* a monad, we can still get the result of `b` in > our functor `f` (using the `MonadPlus` instance from my previous > mail), because `runContT b` also has type `f b`. > > Clearly, `runContT (lift b)` (or `b` itself) and `runContT b` may > behave differently (even if they both (can) have the type `f b`) > because `ContT` 'overwrites' the definition for `>>=` of `f` if `f` > has one. So it depends on the application which of those behaviours is > desired. > > Ryan: > > > The CPS transfrom in ContT also has the nice property that it makes > > most applications of >>= in the underlying monad be > > right-associative. > > Do you have a specific reason to say *most* (rather than *all*) here? > Because if we have a left-associative application of `>>=` in `ContT`, > then we have: > > (a >>= f) >>= g > = ContT (\k1 -> unContT (a >>= f) (\x1 -> unContT (g x1) k1)) > = ContT (\k1 -> > unContT (ContT (\k2 -> unContT a (\x2 -> unContT (f x2) k2))) > (\x1 -> unContT (g x1) k1) > = ContT (\k1 -> unContT a (\x2 -> unContT (f x2) (\x1 -> unContT (g x1) > k1))) > = ContT (\k1 -> unContT a (\x2 -> > unContT (ContT (\k2 -> unContT (f x2) (\x1 -> unContT (g x1) k2))) > k1)) > = ContT (\k1 -> unContT a (\x2 -> unContT (f x2 >>= g) k1)) > = a >>= (\x -> f x >>= g) > > Cheers, > Sebastian > > > > _______________________________________________ > 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/20090409/3bf0f604/attachment.htm From lrpalmer at gmail.com Thu Apr 9 14:52:01 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Apr 9 14:38:46 2009 Subject: [Haskell-cafe] Referential Transparency and Monads In-Reply-To: <2346277719240711356@unknownmsgid> References: <2346277719240711356@unknownmsgid> Message-ID: <7ca3f0160904091152w60ea3e5dv9f33ca570402d70d@mail.gmail.com> 2009/4/9 Mark Spezzano > Or does RT ignore the encapsulated data and just view the ?action? > performed by the monad as the ?value? of the monad? > If I understand you right, this is more-or-less correct. You may as well think of IO as some sort of algebraic type that you are building and returning. A value of type "IO Integer" is not, itself, an integer. Thus: main = let r = print "hello" in return () Prints nothing. RT steps in in a similar scenario: main = let r = print "hello" in do { r; r } Replacing "r" with its definition: main = do { print "hello"; print "hello" } As expected. Luke > > Just curious as to the rationale behind referential transparency and how it > applies to monads. > > > > Cheers, > > > > Mark Spezzano > > > > No virus found in this outgoing message. > Checked by AVG. > Version: 7.5.557 / Virus Database: 270.11.48/2048 - Release Date: 8/04/2009 > 7:02 PM > > _______________________________________________ > 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/20090409/39bb8044/attachment.htm From jonathanccast at fastmail.fm Thu Apr 9 15:14:24 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Thu Apr 9 15:01:13 2009 Subject: [Haskell-cafe] Referential Transparency and Monads In-Reply-To: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> References: <002501c9b92a$71e50810$55af1830$@spezzano@chariot.net.au> <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> Message-ID: <1239304464.19297.26.camel@jcchost> On Thu, 2009-04-09 at 12:31 -0400, Brandon S. Allbery KF8NH wrote: > On 2009 Apr 9, at 11:47, Mark Spezzano wrote: > > How exactly do monads ?solve? the problem of referential > > transparency? I understand RT to be such that a function can be > > replaced with a actual value. > > > > Since a monad could potentially encapsulate any other value?say, > > data read from a keyboard?doesn?t that violate the assumption of RT > > on monads? > Monads provide a way to carry extra data or operations around with > their values. IO passes an opaque "world state" around in the > background, conceptually I/O operations modify the "world state" and > it is in fact always valid to replace the monadified version with the > unwrapped version --- ignoring IORefs, IO is just a simple state > monad. I'm not sure what you mean by that, but semantically IO is definitely *not* a state monad. Under any circumstances or any set of assumptions. GHC *implements* IO as a state monad, but not because it semantically is. Rather, GHC's back-end language (STG) is an *impure* lazy functional language, supplying primitive functions with (ultimate) result type (# State# s, alpha #) , for some alpha,[1] that are side-effectful. The intention is that the State# s component (which has almost no run-time representation) is used to ensure a strict sequencing of the evaluation of these expressions --- which intention can be violated by using the operations unsafePerformIO and unsafeInterleaveIO --- allowing the language to be both side-effectful and lazy without the programmer necessarily effectively losing the ability to control what the outcome of running the program will be. But that has nothing to do with referential transparency, because the language those tricks are used in is not referentially transparent. It's just an implementation technique for implementing a referentially transparent source language on a non-referentially transparent imperative stored-memory computer. jcc [1] As pointed out in another thread a couple of weeks ago, the order of these components is reversed: they should be (# alpha, State# s #) It's probably too late to change it now, though. From eric.kow at gmail.com Thu Apr 9 15:23:49 2009 From: eric.kow at gmail.com (Eric Kow) Date: Thu Apr 9 15:10:37 2009 Subject: [Haskell-cafe] Re: WX: linking to system libraries statically In-Reply-To: References: <20090409190126.D3A6F32469A@www.haskell.org> Message-ID: <20090409192349.GC15805@brighton.ac.uk> Hi FFT, I'm just CC'ing wxhaskell-users so they see this question. Thanks! On Thu, 9 Apr 2009 04:13:18 -0700, FFT wrote > I noticed that even simple WX demos like "Layout" are linked > dynamically against 59 libraries on Linux. This would make > distributing the binaries a nightmare. Is there a simple way to make a > (mostly) statically linked binary? -- Eric Kow PGP Key ID: 08AC04F9 -------------- 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/20090409/6e50b04f/attachment.bin From miguelimo38 at yandex.ru Thu Apr 9 15:33:03 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Thu Apr 9 15:20:03 2009 Subject: [Haskell-cafe] Referential Transparency and Monads In-Reply-To: <1239304464.19297.26.camel@jcchost> References: <002501c9b92a$71e50810$55af1830$@spezzano@chariot.net.au> <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> Message-ID: <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> > I'm not sure what you mean by that, but semantically IO is definitely > *not* a state monad. Under any circumstances or any set of > assumptions. Ehm? Why not? From ccshan at post.harvard.edu Thu Apr 9 15:55:23 2009 From: ccshan at post.harvard.edu (Chung-chieh Shan) Date: Thu Apr 9 15:47:21 2009 Subject: [Haskell-cafe] Re: Paper: Translating donotation to SQL, Leijden, Meijer References: Message-ID: G??nther Schmidt wrote in article in gmane.comp.lang.haskell.cafe: > is the paper "Translating donotation to SQL, Leijden, Meijer (1999)" > available anywhere? Seems to be here http://www.usenix.org/events/dsl99/full_papers/leijen/leijen_html/ no? -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig 100 Days to close Guantanamo and end torture http://100dayscampaign.org/ From lrpalmer at gmail.com Thu Apr 9 16:09:09 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Apr 9 15:55:55 2009 Subject: [Haskell-cafe] Referential Transparency and Monads In-Reply-To: <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> Message-ID: <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> On Thu, Apr 9, 2009 at 1:33 PM, Miguel Mitrofanov wrote: > I'm not sure what you mean by that, but semantically IO is definitely >> *not* a state monad. Under any circumstances or any set of assumptions. >> > > Ehm? Why not? Mainly forkIO. There may be other reasons. Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090409/85d35ee2/attachment.htm From hjgtuyl at chello.nl Thu Apr 9 16:12:34 2009 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Thu Apr 9 15:59:28 2009 Subject: [Haskell-cafe] ghci *.hs In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C82C3D28@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C82C3D28@EX2.ad.dcs.gla.ac.uk> Message-ID: On Thu, 09 Apr 2009 15:44:42 +0200, Paul Keir wrote: > Hi all, > > I like to use ghci *.hs to start my session, but I then have to type :m > +Main > to bring the Main module into scope. Is there a command-line switch to > control > which modules are initially in scope with ghci? > > Thanks, > Paul You only have load the main module like this: ghci Main.lhs (the name doesn't have to be Main.lhs or Main.hs), the rest follows automatically, provided the imported modules start with a line like: > module ImportModule2 where It is also possible to run the program immediately with the command: runhaskell Main.lhs -- Regards, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ -- From claus.reinke at talk21.com Thu Apr 9 17:27:44 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Thu Apr 9 17:14:49 2009 Subject: [Haskell-cafe] Strange type error with associated type synonyms References: <646230a00904061436x41af1055se39e8892eb4e3083@mail.gmail.com><4580278B-D5B6-4A4E-9233-415B57F60A3E@cse.unsw.edu.au><1bc51a990904070348p7e6fc849qeaa45b155279e435@mail.gmail.com><9DC371FCEE914C19966965FB38881AC1@cr3lt><638ABD0A29C8884A91BC5FB5C349B1C335080DECA1@EA-EXMSG-C334.europe.corp.microsoft.com><3E3186D9A0F34311825C9D476DB9F1D9@cr3lt> <638ABD0A29C8884A91BC5FB5C349B1C33508188D5B@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: |Oh now i see what you mean: consider | f' = abst . (id :: (d->a)->(d->a)) . appl |which GHC understands to mean | f' = abst . (id :: forall d a. (d->a)->(d->a)) . appl | |GHC infers the type | f' :: (Fun d) => Memo d a -> Memo d a |Now you are saying that GHC *could* have figured out that if it added the signature | f' :: forall d a. (Fun d) => Memo d a -> Memo d a |thereby *changing* the scoping of d,a in the buried signature for 'id', doing so would not change whether f' was |typeable or not. Well maybe, but that is way beyond what I have any current plans to do. Indeed!-) I didn't mean to suggest this as a course of action, it was just a way of representing the internal type inference intermediates at source level. Another aspect I would not like about this approach is that renamings of bound type variables would no longer be meaning- preserving (because the signature would be interpreted in the context of the source-code it belongs to) - not good. But the core part of my suggestion (which this example was meant to help explain) remains attractive, at least to me: somewhere during type inference, GHC *does* unify the *apparently free* 'd' with an internal type variable (lets call it 'd1, as in the type error message) that has no explicit counterpart in source code or type signature, so the inferred type should not be f' :: forall d. (Fun d) => Memo d a -> Memo d a -- (1) but rather f' :: forall d. (Fun d,d~d1) => Memo d a -> Memo d a -- (2) That way, the internal dependency would be made explicit in the printed representation of the inferred type signature, and the unknown 'd1' would appear explicitly in the inferred type, not just in the error message (the explicit foralls are needed here to make it clear that 'd1' and by implication, 'd', *cannot* be freely generalized - 'd' is qualified by the equation with the unknown 'd1'). To me, (2) makes more sense as an inferred type for f' than (1), especially as it represents an obviously unusable type signature (we don't know what 'd1' is, and we can't just unify it with anything), whereas (1) suggests a useable type signature, but one that will fail when used: Couldn't match expected type `Memo d1' against inferred type `Memo d'. All I'm suggesting is that the type *printed* by GHCi does not really represent the type *inferred* by GHCi (or else there should not be any attempt to match the *free* 'd' against some unknown 'd1', as the error message says), and that there might be ways to make the discrepancy explicit, by printing the inferred type differently. Claus From ekmett at gmail.com Thu Apr 9 18:42:54 2009 From: ekmett at gmail.com (Edward Kmett) Date: Thu Apr 9 18:29:40 2009 Subject: [Haskell-cafe] Ambiguous reified dictionaries In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C335081889AC@EA-EXMSG-C334.europe.corp.microsoft.com> References: <49DDB337.2050205@van.steenbergen.nl> <638ABD0A29C8884A91BC5FB5C349B1C335081889AC@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <7fb8f82f0904091542x16a6a093ue830305a3f2c6b2f@mail.gmail.com> On Thu, Apr 9, 2009 at 5:14 AM, Simon Peyton-Jones wrote: > | > 3) Is it possible to implement the following function? > | > > | >> mkMonoidInst :: a -> (a -> a -> a) -> MonoidInst a > | >> mkMonoidInst mempty mappend = ... > > No it's not possible. And now you know why! > > Simon > Simon, While we can't give him exactly what he asked for, we can approximate the construction using Oleg and CC Shan's Implicit Configurations and fulfill the spirit of the request. > {-# LANGUAGE ScopedTypeVariables, TypeOperators, MultiParamTypeClasses, FlexibleContexts, UndecidableInstances, Rank2Types, GeneralizedNewtypeDeriving #-} Please, pardon the gratuitous use of extensions. > import Data.Bits > import Data.Monoid > import Data.Reflection -- from package 'reflection' First define the concept of a dictionary for a monoid. > type M a = (a, a -> a -> a) Then provide a type level brand that indicates which dictionary you are going to use. > data (a `WithMonoid` s) = Mon { getWithMonoid :: a } deriving (Eq,Ord,Show) Use reflection to access the dictionary > instance (s `Reflects` M a) => Monoid (a `WithMonoid` s) where > mempty = Mon (fst (reflect (undefined :: s))) > Mon a `mappend` Mon b = Mon ((snd (reflect (undefined :: s))) a b) Reify a monoid dictionary for use within a universally quantified world, ala ST. > reifyMonoid :: a -> (a -> a -> a) -> (forall s. (s `Reflects` M a) => s -> w) -> w > reifyMonoid = curry reify Change the type of the above to avoid the spurious argument, and to automatically unwrap the result. > withMonoid :: a -> (a -> a -> a) -> (forall s. (s `Reflects` M a) => w `WithMonoid` s) -> w > withMonoid = withMonoid' undefined where > withMonoid' :: w -> a -> (a -> a -> a) -> (forall s. (s `Reflects` M a) => w `WithMonoid` s) -> w > withMonoid' (_::w) (i::a) f k = reifyMonoid i f (\(_::t) -> getWithMonoid (k :: w `WithMonoid` t)) And now we have some likely candidates to test: > test :: Int > test = withMonoid 0 (+) (mconcat [Mon 2,mempty,Mon 0]) > test2 :: Int > test2 = withMonoid 1 (*) (mconcat [Mon 3,mempty,Mon 2]) > test3 :: Integer > test3 = withMonoid 0 xor (mconcat [Mon 4,mempty,Mon 4]) *Main> test Loading package reflection-0.1.1 ... linking ... done. 2 *Main> test2 6 *Main> test3 0 There you have it, everything works out. Amusingly, I have a similar set of constructions for reifying other kinds of constructs in my 'monoids' library on Hackage, but I don't currently provide a reified Monoid type, mainly because the signature isn't enough to enforce its associativity. However, I do allow you to reify an arbitrary function into a 'Reducer' using this trick to enable you to uniformly inject values into a particular monoid. -Edward Kmett > | -----Original Message----- > | From: haskell-cafe-bounces@haskell.org [mailto: > haskell-cafe-bounces@haskell.org] On > | Behalf Of Lennart Augustsson > | Sent: 09 April 2009 09:54 > | To: Martijn van Steenbergen > | Cc: Haskell Cafe > | Subject: Re: [Haskell-cafe] Ambiguous reified dictionaries > | > | That program is incorrect, it contains two instances for Monoid Int, > | and the compiler should flag it as illegal. > | > | -- Lennart > | > | On Thu, Apr 9, 2009 at 10:35 AM, Martijn van Steenbergen > | wrote: > | > Good morning, > | > > | > The [1]GHC user's guide, section 8.4.5 says: > | > > | > "The new feature is that pattern-matching on MkSet (as in the > definition of > | > insert) makes available an (Eq a) context. In implementation terms, the > | > MkSet constructor has a hidden field that stores the (Eq a) dictionary > that > | > is passed to MkSet; so when pattern-matching that dictionary becomes > | > available for the right-hand side of the match." > | > > | > But what happens if there are several dictionaries available? > | > > | > Consider these three modules: > | > > | > ReifyMonoid.hs: > | > > | >> {-# LANGUAGE GADTs #-} > | >> > | >> module ReifyMonoid where > | >> > | >> import Data.Monoid > | >> > | >> data MonoidInst a where > | >> MkMonoidInst :: Monoid a => MonoidInst a > | > > | > ReifySum.hs: > | > > | >> module ReifySum where > | >> > | >> import ReifyMonoid > | >> import Data.Monoid > | >> > | >> instance Monoid Int where > | >> mempty = 0 > | >> mappend = (+) > | >> > | >> intSum :: MonoidInst Int > | >> intSum = MkMonoidInst > | > > | > ReifyProd.hs: > | > > | >> module ReifyProd where > | >> > | >> import ReifyMonoid > | >> import Data.Monoid > | >> > | >> instance Monoid Int where > | >> mempty = 1 > | >> mappend = (*) > | >> > | >> intProd :: MonoidInst Int > | >> intProd = MkMonoidInst > | > > | > Now a function > | > > | >> emp :: MonoidInst a -> a > | >> emp MkMonoidInst = mempty > | > > | > works as you'd expect: > | > > | > *ReifySum ReifyProd> emp intSum > | > 0 > | > *ReifySum ReifyProd> emp intProd > | > 1 > | > > | > But what about this function? > | > > | >> empAmb :: MonoidInst a -> MonoidInst a -> a > | >> empAmb MkMonoidInst MkMonoidInst = mempty > | > > | > Now there are two dictionaries available. GHC consistently picks the > one > | > from the second argument: > | > > | > *ReifySum ReifyProd> empAmb intProd intSum > | > 1 > | > *ReifySum ReifyProd> empAmb intSum intProd > | > 0 > | > > | > My questions are: > | > > | > 1) Shouldn't GHC reject this as being ambiguous? > | > 2) Should class constraints only be available on existentially > qualified > | > type variables to prevent this from happening at all? > | > 3) Is it possible to implement the following function? > | > > | >> mkMonoidInst :: a -> (a -> a -> a) -> MonoidInst a > | >> mkMonoidInst mempty mappend = ... > | > > | > Thank you, > | > > | > Martijn. > | > > | > > | > > | > [1] > | > http://www.haskell.org/ghc/docs/latest/html/users_guide/data-type- > | extensions.html#gadt-style > | > _______________________________________________ > | > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090409/7c106eec/attachment.htm From thomas.dubuisson at gmail.com Thu Apr 9 19:01:22 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Thu Apr 9 18:48:08 2009 Subject: [Haskell-cafe] ANN: network-bytestring 0.1.2 In-Reply-To: <90889fe70904050601n25512fdanee6263ff039860c7@mail.gmail.com> References: <90889fe70904050601n25512fdanee6263ff039860c7@mail.gmail.com> Message-ID: <4c44d90b0904091601n438251c2v7c9cd1c4a86567f0@mail.gmail.com> Johan, This doesn't build for me on ghc-6.10.2. It looks like an internal part of the network library changed, but I didn't give it much thought. Thomas [tom@Mavlo network-data]$ cabal install network-bytestring Resolving dependencies... [1 of 1] Compiling Main ( /tmp/network-bytestring-0.1.214361/network-bytestring-0.1.2/Setup.hs, /tmp/network-bytestring-0.1.214361/network-bytestring-0.1.2/dist/setup/Main.o ) Linking /tmp/network-bytestring-0.1.214361/network-bytestring-0.1.2/dist/setup/setup ... Configuring network-bytestring-0.1.2... Preprocessing library network-bytestring-0.1.2... Building network-bytestring-0.1.2... [1 of 5] Compiling Network.Socket.ByteString.IOVec ( dist/build/Network/Socket/ByteString/IOVec.hs, dist/build/Network/Socket/ByteString/IOVec.o ) [2 of 5] Compiling Network.Socket.ByteString.MsgHdr ( dist/build/Network/Socket/ByteString/MsgHdr.hs, dist/build/Network/Socket/ByteString/MsgHdr.o ) [3 of 5] Compiling Network.Socket.ByteString.Internal ( Network/Socket/ByteString/Internal.hs, dist/build/Network/Socket/ByteString/Internal.o ) [4 of 5] Compiling Network.Socket.ByteString ( Network/Socket/ByteString.hs, dist/build/Network/Socket/ByteString.o ) Network/Socket/ByteString.hs:66:32: Module `Network.Socket.Internal' does not export `throwSocketErrorIfMinus1RetryMayBlock' cabal: Error: some packages failed to install: network-bytestring-0.1.2 failed during the building phase. The exception was: exit: ExitFailure 1 [tom@Mavlo network-data]$ cabal install network-bytestring Resolving dependencies... [1 of 1] Compiling Main ( /tmp/network-bytestring-0.1.215107/network-bytestring-0.1.2/Setup.hs, /tmp/network-bytestring-0.1.215107/network-bytestring-0.1.2/dist/setup/Main.o ) Linking /tmp/network-bytestring-0.1.215107/network-bytestring-0.1.2/dist/setup/setup ... Configuring network-bytestring-0.1.2... Preprocessing library network-bytestring-0.1.2... Building network-bytestring-0.1.2... [1 of 5] Compiling Network.Socket.ByteString.IOVec ( dist/build/Network/Socket/ByteString/IOVec.hs, dist/build/Network/Socket/ByteString/IOVec.o ) [2 of 5] Compiling Network.Socket.ByteString.MsgHdr ( dist/build/Network/Socket/ByteString/MsgHdr.hs, dist/build/Network/Socket/ByteString/MsgHdr.o ) [3 of 5] Compiling Network.Socket.ByteString.Internal ( Network/Socket/ByteString/Internal.hs, dist/build/Network/Socket/ByteString/Internal.o ) [4 of 5] Compiling Network.Socket.ByteString ( Network/Socket/ByteString.hs, dist/build/Network/Socket/ByteString.o ) Network/Socket/ByteString.hs:66:32: Module `Network.Socket.Internal' does not export `throwSocketErrorIfMinus1RetryMayBlock' cabal: Error: some packages failed to install: network-bytestring-0.1.2 failed during the building phase. The exception was: exit: ExitFailure 1 [tom@Mavlo network-data]$ ghc-pkg --version GHC package manager version 6.10.2 [tom@Mavlo network-data]$ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.10.2 [tom@Mavlo network-data]$ ghc-pkg list /usr/local/lib/ghc-6.10.2/./package.conf: Cabal-1.6.0.3, HUnit-1.2.0.3, 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, 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, filepath-1.1.0.2, (ghc-6.10.2), 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, 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, unix-2.3.2.0, xhtml-3000.2.0.1 /home/tom/.ghc/x86_64-linux-6.10.2/package.conf: Control-Engine-0.0.4, binary-0.5, network-data-0.0.2, prettyclass-1.0.0.0, pureMD5-0.2.4, time-1.1.2.3 On Sun, Apr 5, 2009 at 6:01 AM, Johan Tibell wrote: > I am pleased to announce a new release of network-bytestring, a Haskell library > for fast socket I/O using ByteStrings. > > New in this release is support for scatter/gather I/O (also known as > vectored I/O). Scatter/gather I/O provides more efficient I/O by using > one system call to send several separate pieces of data and by > avoiding unnecessary copying. > > I would like to thank Brian Lewis, Bryan O'Sullivan, and Thomas > Schilling for contributing patches for this release. > > Get it: > > ? cabal install network-bytestring > > And on Hackage: > > ? http://hackage.haskell.org/cgi-bin/hackage-scripts/package/network-bytestring > > Windows hackers needed: > > ? I've made sure that the library builds on Windows but since I don't > use Windows myself I haven't implemented scatter/gather I/O support > for Windows. It should be straightforward to add and I'd be happy to > review the patches. > > Cheers, > > Johan > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From sanzhiyan at gmail.com Thu Apr 9 19:08:46 2009 From: sanzhiyan at gmail.com (Andrea Vezzosi) Date: Thu Apr 9 18:55:33 2009 Subject: [Haskell-cafe] Re: GHC: compile using multiple cores? In-Reply-To: <404396ef0904090851k2288f0des9f6a8dc200b3c14b@mail.gmail.com> References: <20090409165153.552b0e99@solaris> <20090409153028.GB16775@whirlpool.galois.com> <404396ef0904090851k2288f0des9f6a8dc200b3c14b@mail.gmail.com> Message-ID: <8625cd9c0904091608g50ecd6ckcbe5d20e48aeefa3@mail.gmail.com> The main bottleneck right now is that each ghc process has to read the package.conf, which afaiu is done with Read and it's awfully slow, especially if you have many packages installed. I've started seeing total time improvements when approaching ~300% CPU usage and only the extralibs installed. On Thu, Apr 9, 2009 at 5:51 PM, Neil Mitchell wrote: >> Not with cabal, with GHC, yes: assuming you have enough modules. Use ghc >> -M to dump a makefile, and then make -j20 (or whatever you have) > > There is a performance penalty to running ghc on separate files vs > --make. If your number of core's is limited --make may be better. I'd > love someone to figure out what the cross over point is :-) > > As a related question, how does GHC implement -j3? For my programs, if > I want to run in parallel, I have to type +RTS -N3. Can I use the same > trick as GHC? > > Thanks > > Neil > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bugfact at gmail.com Thu Apr 9 19:24:38 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Apr 9 19:11:23 2009 Subject: [Haskell-cafe] Re: GHC: compile using multiple cores? In-Reply-To: <8625cd9c0904091608g50ecd6ckcbe5d20e48aeefa3@mail.gmail.com> References: <20090409165153.552b0e99@solaris> <20090409153028.GB16775@whirlpool.galois.com> <404396ef0904090851k2288f0des9f6a8dc200b3c14b@mail.gmail.com> <8625cd9c0904091608g50ecd6ckcbe5d20e48aeefa3@mail.gmail.com> Message-ID: That should be fairly easy to optimize I guess? Maybe even using read-only shared memory to share the parsed database in native binary format? On Fri, Apr 10, 2009 at 1:08 AM, Andrea Vezzosi wrote: > The main bottleneck right now is that each ghc process has to read the > package.conf, which afaiu is done with Read and it's awfully slow, > especially if you have many packages installed. > I've started seeing total time improvements when approaching ~300% CPU > usage and only the extralibs installed. > > On Thu, Apr 9, 2009 at 5:51 PM, Neil Mitchell > wrote: > >> Not with cabal, with GHC, yes: assuming you have enough modules. Use ghc > >> -M to dump a makefile, and then make -j20 (or whatever you have) > > > > There is a performance penalty to running ghc on separate files vs > > --make. If your number of core's is limited --make may be better. I'd > > love someone to figure out what the cross over point is :-) > > > > As a related question, how does GHC implement -j3? For my programs, if > > I want to run in parallel, I have to type +RTS -N3. Can I use the same > > trick as GHC? > > > > Thanks > > > > Neil > > _______________________________________________ > > 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/20090410/fdff3ab0/attachment.htm From allbery at ece.cmu.edu Thu Apr 9 21:57:51 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Apr 9 21:44:53 2009 Subject: [Haskell-cafe] Referential Transparency and Monads In-Reply-To: <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> Message-ID: 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/20090409/e363c6e3/PGP.bin From jonathanccast at fastmail.fm Thu Apr 9 22:30:30 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Thu Apr 9 22:17:17 2009 Subject: [Haskell-cafe] Referential Transparency and Monads In-Reply-To: References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> Message-ID: <1239330630.6902.17.camel@jonathans-macbook> On Thu, 2009-04-09 at 21:57 -0400, Brandon S. Allbery KF8NH wrote: > On 2009 Apr 9, at 16:09, Luke Palmer wrote: > > On Thu, Apr 9, 2009 at 1:33 PM, Miguel Mitrofanov > > wrote: > > I'm not sure what you mean by that, but semantically > > IO is definitely > > *not* a state monad. Under any circumstances or any > > set of assumptions. > > > > > > Ehm? Why not? > > > > Mainly forkIO. There may be other reasons. > > > > > I thought I had excluded that stuff to simplify the question; the fact > that IO is Haskell's toxic waste dump is more or less irrelevant to > the core concept. Well, the `core concept' of IO includes the concept of a user who's watching and interacting with your program as it runs, no? Say I know that a file named `/my_file' exists and is readable and writeable and etc. Now consider the program do s <- readFile "/my_file" writeFile "/my_file" "Hello, world!\n" threadDelay 10000 -- If you don't like threadDelay, just substitute forcing -- an expensive thunk here writeFile "/my_file" s As a function from initial state to final state, this program is just the identity; but surely this program should be considered different than just threadDelay 10000 . To give a meaningful semantics to IO, you have to consider the intermediate state(s) the system goes through, where a state monad denotation for IO would discard them. jcc From allbery at ece.cmu.edu Thu Apr 9 22:47:46 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Apr 9 22:34:43 2009 Subject: [Haskell-cafe] Referential Transparency and Monads In-Reply-To: <1239330630.6902.17.camel@jonathans-macbook> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <1239330630.6902.17.camel@jonathans-macbook> Message-ID: <75DC4B3D-376C-4FCD-BDAF-7204E46AE64B@ece.cmu.edu> On 2009 Apr 9, at 22:30, Jonathan Cast wrote: > On Thu, 2009-04-09 at 21:57 -0400, Brandon S. Allbery KF8NH wrote: >> On 2009 Apr 9, at 16:09, Luke Palmer wrote: >>> On Thu, Apr 9, 2009 at 1:33 PM, Miguel Mitrofanov >>> wrote: >>> I'm not sure what you mean by that, but semantically >>> IO is definitely >>> *not* a state monad. Under any circumstances or any >>> set of assumptions. >>> >>> Ehm? Why not? >>> >>> Mainly forkIO. There may be other reasons. >> >> I thought I had excluded that stuff to simplify the question; the >> fact >> that IO is Haskell's toxic waste dump is more or less irrelevant to >> the core concept. > > Well, the `core concept' of IO includes the concept of a user who's > watching and interacting with your program as it runs, no? Yes. That's the opaque "real world"; an I/O operation conceptually modifies this state, which is how things get tied together. Ordinary user programs can't interact with the "real world" sate except via functions defined on IO, which are assumed to modify the state; that's exactly how non-RT actions are modeled via RT code. Stuff like forkIO and newIORef can also be understood that way, it's just a bit more complex to follow them around. Please note that ghc *does* implement IO (from Core up, at least) this way, modulo unboxed tuples, so claims that it is "wrong" are dubious at best. > s <- readFile "/my_file" > writeFile "/my_file" "Hello, world!\n" > threadDelay 10000 -- If you don't like threadDelay, just > substitute forcing > -- an expensive thunk here > writeFile "/my_file" s > > As a function from initial state to final state, this program is just > the identity; but surely this program should be considered different It is? > -- these implicitly are considered to return a modified RealWorld > readFile :: RealWorld -> (String,RealWorld) > writeFile :: RealWorld -> ((),RealWorld) > threadDelay :: RealWorld -> ((),RealWorld) > > main :: RealWorld -> ((),RealWorld) > main state = > case readFile state "/my_file" of > (s,state') -> > case writeFile state' "/my_file" "Hello, world!\n" of > (_,state'') -> > case threadDelay state'' 10000 of > (_,state'') -> writeFile "/my_file" s This is just the State monad, unwrapped. And the differences between this and the actual GHC implementation are the use of unboxed tuples and RealWorld actually being a type that can't be accessed by normal Haskell code. -- 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/20090409/bc27311a/PGP.bin From allbery at ece.cmu.edu Thu Apr 9 22:55:29 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Apr 9 22:42:18 2009 Subject: [Haskell-cafe] Referential Transparency and Monads In-Reply-To: <75DC4B3D-376C-4FCD-BDAF-7204E46AE64B@ece.cmu.edu> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <1239330630.6902.17.camel@jonathans-macbook> <75DC4B3D-376C-4FCD-BDAF-7204E46AE64B@ece.cmu.edu> Message-ID: On 2009 Apr 9, at 22:47, Brandon S. Allbery KF8NH wrote: > > -- these implicitly are considered to return a modified RealWorld > > readFile :: RealWorld -> (String,RealWorld) > > writeFile :: RealWorld -> ((),RealWorld) > > threadDelay :: RealWorld -> ((),RealWorld) > > > > main :: RealWorld -> ((),RealWorld) > > main state = > > case readFile state "/my_file" of > > (s,state') -> > > case writeFile state' "/my_file" "Hello, world!\n" of > > (_,state'') -> > > case threadDelay state'' 10000 of > > (_,state'') -> writeFile "/my_file" s Sorry, the last line should be: > (_,state''') -> writeFile state''' "/my_file" s This code is nothing more nor less than the translation of Jonathan Cast's code, using a presumptive > type IO a = State RealWorld a into "linear" de-monadified code. Clearly the state is threaded into main, through all the calls, and the final state returned; the state threading is what maintains the referentially transparent model. -- 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/20090409/7fce2d2b/PGP.bin From jonathanccast at fastmail.fm Thu Apr 9 23:16:40 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Thu Apr 9 23:03:26 2009 Subject: [Haskell-cafe] Referential Transparency and Monads In-Reply-To: <75DC4B3D-376C-4FCD-BDAF-7204E46AE64B@ece.cmu.edu> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <1239330630.6902.17.camel@jonathans-macbook> <75DC4B3D-376C-4FCD-BDAF-7204E46AE64B@ece.cmu.edu> Message-ID: <1239333400.6902.41.camel@jonathans-macbook> On Thu, 2009-04-09 at 22:47 -0400, Brandon S. Allbery KF8NH wrote: > On 2009 Apr 9, at 22:30, Jonathan Cast wrote: > > On Thu, 2009-04-09 at 21:57 -0400, Brandon S. Allbery KF8NH wrote: > >> On 2009 Apr 9, at 16:09, Luke Palmer wrote: > >>> On Thu, Apr 9, 2009 at 1:33 PM, Miguel Mitrofanov > >>> wrote: > >>> I'm not sure what you mean by that, but semantically > >>> IO is definitely > >>> *not* a state monad. Under any circumstances or any > >>> set of assumptions. > >>> > >>> Ehm? Why not? > >>> > >>> Mainly forkIO. There may be other reasons. > >> > >> I thought I had excluded that stuff to simplify the question; the > >> fact > >> that IO is Haskell's toxic waste dump is more or less irrelevant to > >> the core concept. > > > > Well, the `core concept' of IO includes the concept of a user who's > > watching and interacting with your program as it runs, no? > > Yes. That's the opaque "real world"; an I/O operation conceptually > modifies this state, Pedantic nit-pick: modification is not referentially transparent. You mean `returns a modified copy'. > which is how things get tied together. Ordinary > user programs can't interact with the "real world" sate except via > functions defined on IO, which are assumed to modify the state; that's > exactly how non-RT actions are modeled via RT code. > > Stuff like forkIO and newIORef can also be understood that way, it's > just a bit more complex to follow them around. > > Please note that ghc *does* implement IO (from Core up, at least) this > way, modulo unboxed tuples, so claims that it is "wrong" are dubious > at best. No, GHC implements IO using an internal side-effectful language. (Note that the `state' IO uses internally is an (un-boxed and un-pointed) 0-bit word! It certainly doesn't have enough semantic content to /actually/ contain the entire state of the computer.) The difference between GHC core and a truly referentially transparent language is that you can't implement unsafePerformIO unless your language has side effects. Oh, and I should have cited Tackling the Awkward Squad as the source of my dubious claim. > > s <- readFile "/my_file" > > writeFile "/my_file" "Hello, world!\n" > > threadDelay 10000 -- If you don't like threadDelay, just > > substitute forcing > > -- an expensive thunk here > > writeFile "/my_file" s > > > > As a function from initial state to final state, this program is just > > the identity; but surely this program should be considered different > > It is? > > > -- these implicitly are considered to return a modified RealWorld > > readFile :: RealWorld -> (String,RealWorld) > > writeFile :: RealWorld -> ((),RealWorld) > > threadDelay :: RealWorld -> ((),RealWorld) > > > > main :: RealWorld -> ((),RealWorld) > > main state = > > case readFile state "/my_file" of > > (s,state') -> > > case writeFile state' "/my_file" "Hello, world!\n" of > > (_,state'') -> > > case threadDelay state'' 10000 of > > (_,state'') -> writeFile "/my_file" s state'' (This has arguments very much in the wrong order throughout, of course.) > This is just the State monad, unwrapped. What on earth does that have to do with anything? If I change your last line to > (_,state''') -> case writeFile "/my_file" s state''' of > (x, state'''') -> (x, state'''') Then I can observe that state'''', if it really names the current state of the system as of the program's finish-point, is exactly equivalent to state (e.g., in both states every file has exactly the same contents). (The only difference, which I forgot, is that the current time is > 10sec later than in state. Doesn't affect the point.) Now, the *definition* you gave is, in form, different than the definition of threadDelay 10000 However, the point of referential transparency is that you can inline the definitions of readFile and writeFile into the scrutinees of your case statements, and then (possibly after something like a case-of-case transformation) you can eliminate the case expressions and intermediate states and get something like: \ (!state) -> let s = fileContents "/my_file" state in case threadDelay 10000 state of (_, state') -> ((), setFileContents "/my_file" s state') where, since threadDelay has no side effects but increasing the current time, fileContents "/my_file" state' == fileContents "/my_file" state so the above is equivalent to \ (!state) -> case threadDelay 10000 state of (_, state') -> ((), setFileContents "/my_file" (fileContents "/my_file" state') state') but obviously setFileContents fn (fileContents fn state') state' == state' so therefore the above is equivalent to \ (!state) -> case threadDelay 10000 state of (_, state') -> ((), state') which (since threadDelay is presumably strict in its state argument and always returns ()) is equivalent to threadDelay 10000 as claimed. And if you don't see that, I really don't think I can put it more clearly than that. > And the differences between > this and the actual GHC implementation Implementation != semantics, btw. And GHC's implementation is not referentially transparent! > are the use of unboxed tuples > and RealWorld actually being a type that can't be accessed by normal > Haskell code. Pedantic nit-pick: State# (not RealWorld!) *is* a type that can be accessed by normal Haskell code. It's just not portable to do so (you have to import one of the GHC.* modules). jcc From iavor.diatchki at gmail.com Thu Apr 9 23:19:06 2009 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Thu Apr 9 23:05:49 2009 Subject: [Haskell-cafe] How to define a common return and bind? In-Reply-To: References: Message-ID: <5ab17e790904092019p392b9cc5i85987963f44d0a32@mail.gmail.com> Hi, You can do things like that for "new" monads that are isomorphic to existing ones. Take a look at the MonadLib.Derive package from MonadLib (http://hackage.haskell.org/packages/archive/monadLib/3.5.2/doc/html/MonadLib-Derive.html). More specifically, the functions "derive_return" and "derive_bind" might be of interest. A more general property for monad transformers is that you can always define the "return" of the new monad in terms of the "return" of the underlying monad and "lift": return_new x = lift (return x) This works because, in general, "lift" should be a "monad morphism". Hope that this helps, Iavor On Thu, Apr 9, 2009 at 3:40 AM, Bas van Dijk wrote: > Hello, > > Suppose you have defined a monad transformer such as: > >> newtype T1 m a = T1 { unT1 :: A1 m a } > > Where 'A1 m' is an arbitrary monad of your choosing. > For this discussion we just take the identity: > >> type A1 m a = m a ? -- (can be any monad) > > If you want to define a Monad instance for 'T1 m' you generally do this: > > instance Monad m => Monad (T1 m) where > ? ?return ?= T1 . return > ? ?m >>= f = T1 $ unT1 m >>= unT1 . f > > (I know I can use the 'GeneralizedNewtypeDeriving' language extension > to automatically derive a Monad but suppose that isn't available) > > Now when I define a new monad transformer: > >> newtype T2 m a = T2 { unT2 :: A2 m a } > > Where 'A2 m' is again an arbitrary monad of your choosing but for now > just the identity: > >> type A2 m a = m a ? -- (can be any monad) > > The Monad instance for it is almost completely identical to the former: > > instance Monad m => Monad (T2 m) where > ? ?return ?= T2 . return > ? ?m >>= f = T2 $ unT2 m >>= unT2 . f > > Note that the only differences are: > > ?* a function to convert > ? from the outer monad _to_ the inner monad: > ? 'unT1' and 'unT2' > > ?* a function to convert > ? _from_ the inner monad to the outer monad: > ? 'T1' and 'T2' > > The common parts seem to be: > > liftReturn from = from . return > liftBind ? from to m f = from $ to m >>= to . f > > My question is: can these be given suitable and general enough types > so that they can be used to define Monad instances for monad > transformers? > > In other words can I use them to write: > > instance Monad m => Monad (T1 m) where > ? ?return = liftReturn T1 > ? ?(>>=) ?= liftBind ? T1 unT1 > > and: > > instance Monad m => Monad (T2 m) where > ? ?return = liftReturn T2 > ? ?(>>=) ?= liftBind ? T2 unT2 > > Thanks, > > Bas > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From miguelimo38 at yandex.ru Thu Apr 9 23:29:33 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Thu Apr 9 23:16:25 2009 Subject: [Haskell-cafe] Referential Transparency and Monads In-Reply-To: <1239330630.6902.17.camel@jonathans-macbook> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <1239330630.6902.17.camel@jonathans-macbook> Message-ID: <23AEEA07-B1E1-43D8-AA28-844643E49EAB@yandex.ru> On 10 Apr 2009, at 06:30, Jonathan Cast wrote: > do > s <- readFile "/my_file" > writeFile "/my_file" "Hello, world!\n" > threadDelay 10000 -- If you don't like threadDelay, just > substitute forcing > -- an expensive thunk here > writeFile "/my_file" s > > As a function from initial state to final state, this program is just > the identity; No, since world state includes the user state itself, not just files contents. From lrpalmer at gmail.com Fri Apr 10 00:14:15 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Apr 10 00:01:00 2009 Subject: [Haskell-cafe] Referential Transparency and Monads In-Reply-To: <75DC4B3D-376C-4FCD-BDAF-7204E46AE64B@ece.cmu.edu> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <1239330630.6902.17.camel@jonathans-macbook> <75DC4B3D-376C-4FCD-BDAF-7204E46AE64B@ece.cmu.edu> Message-ID: <7ca3f0160904092114m36d68a91l7bc7e168000c682a@mail.gmail.com> On Thu, Apr 9, 2009 at 8:47 PM, Brandon S. Allbery KF8NH < allbery@ece.cmu.edu> wrote: > Yes. That's the opaque "real world"; an I/O operation conceptually > modifies this state, which is how things get tied together. Ordinary user > programs can't interact with the "real world" sate except via functions > defined on IO, which are assumed to modify the state; that's exactly how > non-RT actions are modeled via RT code. > > Stuff like forkIO and newIORef can also be understood that way, it's just a > bit more complex to follow them around. newIORef is trivial: just keep a unique counter in the state. Have you tried forkIO? I used to think that "world passing" was an acceptable, if ugly, semantics for IO. However, after doing some formal modeling, I realized that forkIO breaks the model altogether. What happens to the end state of the forked thread? If it really is thought of that way, surely you will be able to create a pure IO simulator as a state monad (for an arbitrarily complex world) that handles only forkIO, threadDelay, and print (just using a write buffer). Think about that for a second. Luke > > > Please note that ghc *does* implement IO (from Core up, at least) this way, > modulo unboxed tuples, so claims that it is "wrong" are dubious at best. > >> s <- readFile "/my_file" >> writeFile "/my_file" "Hello, world!\n" >> threadDelay 10000 -- If you don't like threadDelay, just substitute >> forcing >> -- an expensive thunk here >> writeFile "/my_file" s >> >> As a function from initial state to final state, this program is just >> the identity; but surely this program should be considered different >> > > It is? > > > -- these implicitly are considered to return a modified RealWorld > > readFile :: RealWorld -> (String,RealWorld) > > writeFile :: RealWorld -> ((),RealWorld) > > threadDelay :: RealWorld -> ((),RealWorld) > > > > main :: RealWorld -> ((),RealWorld) > > main state = > > case readFile state "/my_file" of > > (s,state') -> > > case writeFile state' "/my_file" "Hello, world!\n" of > > (_,state'') -> > > case threadDelay state'' 10000 of > > (_,state'') -> writeFile "/my_file" s > > This is just the State monad, unwrapped. And the differences between this > and the actual GHC implementation are the use of unboxed tuples and > RealWorld actually being a type that can't be accessed by normal Haskell > code. > > -- > 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 -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090409/2a72bc04/attachment-0001.htm From allbery at ece.cmu.edu Fri Apr 10 00:28:59 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Apr 10 00:18:54 2009 Subject: [Haskell-cafe] Referential Transparency and Monads In-Reply-To: <7ca3f0160904092114m36d68a91l7bc7e168000c682a@mail.gmail.com> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <1239330630.6902.17.camel@jonathans-macbook> <75DC4B3D-376C-4FCD-BDAF-7204E46AE64B@ece.cmu.edu> <7ca3f0160904092114m36d68a91l7bc7e168000c682a@mail.gmail.com> Message-ID: <92493CDC-14C2-4E8D-B37A-D6E3CC68D99F@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/20090410/bdeeaa90/PGP.bin From apfelmus at quantentunnel.de Fri Apr 10 00:33:52 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Fri Apr 10 00:20:59 2009 Subject: [Haskell-cafe] Re: Referential Transparency and Monads In-Reply-To: <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> Message-ID: Luke Palmer wrote: > Miguel Mitrofanov wrote: > >> I'm not sure what you mean by that, but semantically IO is definitely >>> *not* a state monad. Under any circumstances or any set of assumptions. >>> >> Ehm? Why not? > > > Mainly forkIO. There may be other reasons. "Tackling the awkward squad" mentions that loop :: IO () loop = loop and loop' :: IO () loop' = putStr "o" >> loop' are indistinguishable in the IO a ~ World -> (a, World) semantics. Both expressions would be _|_. But clearly, the latter produces some output while the former just hangs. Regards, apfelmus -- http://apfelmus.nfshost.com From allbery at ece.cmu.edu Fri Apr 10 00:46:54 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Apr 10 00:33:55 2009 Subject: [Haskell-cafe] Re: Referential Transparency and Monads In-Reply-To: References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> Message-ID: <27F44BA4-FAA6-4719-B7AF-E15DDD7100FE@ece.cmu.edu> On 2009 Apr 10, at 0:33, Heinrich Apfelmus wrote: > Luke Palmer wrote: >> Miguel Mitrofanov wrote: >> >>> I'm not sure what you mean by that, but semantically IO is >>> definitely >>>> *not* a state monad. Under any circumstances or any set of >>>> assumptions. >>>> >>> Ehm? Why not? >> >> Mainly forkIO. There may be other reasons. > loop' :: IO () > loop' = putStr "o" >> loop' > > are indistinguishable in the > > IO a ~ World -> (a, World) I still don't understand this; we are passing a World and getting a World back, *conceptually* the returned World is modified by putStr. It's not in reality, but we get the same effects if we write to a buffer and observe that buffer with a debugger --- state threading constrains the program to the rules that must be followed for ordered I/O, which is what matters. -- 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/20090410/f83d133d/PGP.bin From jonathanccast at fastmail.fm Fri Apr 10 00:52:48 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Apr 10 00:39:34 2009 Subject: [Haskell-cafe] Re: Referential Transparency and Monads In-Reply-To: <27F44BA4-FAA6-4719-B7AF-E15DDD7100FE@ece.cmu.edu> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <27F44BA4-FAA6-4719-B7AF-E15DDD7100FE@ece.cmu.edu> Message-ID: <1239339168.6902.42.camel@jonathans-macbook> On Fri, 2009-04-10 at 00:46 -0400, Brandon S. Allbery KF8NH wrote: > On 2009 Apr 10, at 0:33, Heinrich Apfelmus wrote: > > Luke Palmer wrote: > >> Miguel Mitrofanov wrote: > >> > >>> I'm not sure what you mean by that, but semantically IO is > >>> definitely > >>>> *not* a state monad. Under any circumstances or any set of > >>>> assumptions. > >>>> > >>> Ehm? Why not? > >> > >> Mainly forkIO. There may be other reasons. > > loop' :: IO () > > loop' = putStr "o" >> loop' > > > > are indistinguishable in the > > > > IO a ~ World -> (a, World) > > > I still don't understand this; we are passing a World and getting a > World back, We are? Why do you think that? jcc From jonathanccast at fastmail.fm Fri Apr 10 01:00:45 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Apr 10 00:47:31 2009 Subject: [Haskell-cafe] Referential Transparency and Monads In-Reply-To: <23AEEA07-B1E1-43D8-AA28-844643E49EAB@yandex.ru> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <1239330630.6902.17.camel@jonathans-macbook> <23AEEA07-B1E1-43D8-AA28-844643E49EAB@yandex.ru> Message-ID: <1239339645.6902.43.camel@jonathans-macbook> On Fri, 2009-04-10 at 07:29 +0400, Miguel Mitrofanov wrote: > On 10 Apr 2009, at 06:30, Jonathan Cast wrote: > > do > > s <- readFile "/my_file" > > writeFile "/my_file" "Hello, world!\n" > > threadDelay 10000 -- If you don't like threadDelay, just > > substitute forcing > > -- an expensive thunk here > > writeFile "/my_file" s > > > > As a function from initial state to final state, this program is just > > the identity; > > No, since world state includes the user state itself, not just files > contents. My programs are passing me around inside a state token? jcc From allbery at ece.cmu.edu Fri Apr 10 01:03:36 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Apr 10 00:50:33 2009 Subject: [Haskell-cafe] Re: Referential Transparency and Monads In-Reply-To: <1239339168.6902.42.camel@jonathans-macbook> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <27F44BA4-FAA6-4719-B7AF-E15DDD7100FE@ece.cmu.edu> <1239339168.6902.42.camel@jonathans-macbook> Message-ID: On 2009 Apr 10, at 0:52, Jonathan Cast wrote: > On Fri, 2009-04-10 at 00:46 -0400, Brandon S. Allbery KF8NH wrote: >>> IO a ~ World -> (a, World) >> >> I still don't understand this; we are passing a World and getting a >> World back, > > We are? Why do you think that? Because that's what (World -> (a,World)) means, last I checked. -- 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/20090410/1151d742/PGP.bin From allbery at ece.cmu.edu Fri Apr 10 01:05:42 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Apr 10 00:52:29 2009 Subject: [Haskell-cafe] Referential Transparency and Monads In-Reply-To: <1239339645.6902.43.camel@jonathans-macbook> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <1239330630.6902.17.camel@jonathans-macbook> <23AEEA07-B1E1-43D8-AA28-844643E49EAB@yandex.ru> <1239339645.6902.43.camel@jonathans-macbook> Message-ID: On 2009 Apr 10, at 1:00, Jonathan Cast wrote: > On Fri, 2009-04-10 at 07:29 +0400, Miguel Mitrofanov wrote: >> On 10 Apr 2009, at 06:30, Jonathan Cast wrote: >>> do >>> s <- readFile "/my_file" >>> writeFile "/my_file" "Hello, world!\n" >>> threadDelay 10000 -- If you don't like threadDelay, just >>> substitute forcing >>> -- an expensive thunk here >>> writeFile "/my_file" s >>> >>> As a function from initial state to final state, this program is >>> just >>> the identity; >> >> No, since world state includes the user state itself, not just files >> contents. > > My programs are passing me around inside a state token? You seem to have redefined "conceptually" to mean "in absolute literalness". -- 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/20090410/ced465a0/PGP.bin From jonathanccast at fastmail.fm Fri Apr 10 01:09:24 2009 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Apr 10 00:56:16 2009 Subject: [Haskell-cafe] Re: Referential Transparency and Monads In-Reply-To: References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <27F44BA4-FAA6-4719-B7AF-E15DDD7100FE@ece.cmu.edu> <1239339168.6902.42.camel@jonathans-macbook> Message-ID: <1239340164.6902.45.camel@jonathans-macbook> On Fri, 2009-04-10 at 01:03 -0400, Brandon S. Allbery KF8NH wrote: > On 2009 Apr 10, at 0:52, Jonathan Cast wrote: > > On Fri, 2009-04-10 at 00:46 -0400, Brandon S. Allbery KF8NH wrote: > >>> IO a ~ World -> (a, World) > >> > >> I still don't understand this; we are passing a World and getting a > >> World back, > > > > We are? Why do you think that? > > Because that's what (World -> (a,World)) means, last I checked. Does undefined :: (a, World) contain a World? jcc From allbery at ece.cmu.edu Fri Apr 10 01:12:31 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Apr 10 00:59:24 2009 Subject: [Haskell-cafe] Re: Referential Transparency and Monads In-Reply-To: <1239340164.6902.45.camel@jonathans-macbook> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <27F44BA4-FAA6-4719-B7AF-E15DDD7100FE@ece.cmu.edu> <1239339168.6902.42.camel@jonathans-macbook> <1239340164.6902.45.camel@jonathans-macbook> Message-ID: On 2009 Apr 10, at 1:09, Jonathan Cast wrote: > On Fri, 2009-04-10 at 01:03 -0400, Brandon S. Allbery KF8NH wrote: >> On 2009 Apr 10, at 0:52, Jonathan Cast wrote: >>> On Fri, 2009-04-10 at 00:46 -0400, Brandon S. Allbery KF8NH wrote: >>>>> IO a ~ World -> (a, World) >>>> >>>> I still don't understand this; we are passing a World and getting a >>>> World back, >>> >>> We are? Why do you think that? >> >> Because that's what (World -> (a,World)) means, last I checked. > > Does > > undefined :: (a, World) > > contain a World? Does > undefined :: Sum Int contain an Int? Please use some common sense, your recent responses are increasingly incoherent. -- 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/20090410/2bf76b0d/PGP.bin From jason.dusek at gmail.com Fri Apr 10 01:17:29 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Apr 10 01:04:12 2009 Subject: [Haskell-cafe] Re: WX: linking to system libraries statically In-Reply-To: <20090409192349.GC15805@brighton.ac.uk> References: <20090409190126.D3A6F32469A@www.haskell.org> <20090409192349.GC15805@brighton.ac.uk> Message-ID: <42784f260904092217y4ca32d72h250161d64d050549@mail.gmail.com> 2009/04/09 FFT : > I noticed that even simple WX demos like "Layout" are linked > dynamically against 59 libraries on Linux. This would make > distributing the binaries a nightmare. Is there a simple way > to make a (mostly) statically linked binary? I have had mixed success with `-static -optl-static` (as recommended in "Practical Web Programming in Haskell" page, for example). On Macs, it's hard to get it to work (have never bothered); on Linux, I remember I had to remove it on once occasion to get things to work across Ubuntu and Gentoo (had to do with differences in libc, I believe, but I did not retain notes). Maybe passing in the specific libs to the linker with `-optl` is the best bet? -- Jason Dusek |...Practical Web Programming in Haskell...| http://www.haskell.org/haskellwiki/Practical_web_programming_in_Haskell#Compiling_and_running_web_applications From nowgate at yahoo.com Fri Apr 10 01:49:14 2009 From: nowgate at yahoo.com (michael rice) Date: Fri Apr 10 01:35:58 2009 Subject: [Haskell-cafe] Sequence differences Message-ID: <559390.3896.qm@web31105.mail.mud.yahoo.com> I have a Scheme function that calculates sequence differences, i.e., it returns a sequence that is the difference between the 2nd and the 1st element, the 3rd and the 2nd, the 4th and the 3rd, etc. (define s ? (lambda (f l) ??? (cond ((null? (cdr l)) '()) ????????? (else (cons (f (cadr l) (car l)) ????????????????????? (s f (cdr l))))))) where (s - '(0,1,3,6,10,15,21,28)) => (1,2,3,4,5,6,7) I'm thinking the same function in Haskell would be something like s :: s f [] = [] s f [x] = [x] s f l = [ a f b | (a,b) <- zip (init l) (tail l)] but can't figure out what the function typing would be. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090409/5bac288b/attachment.htm From jfredett at gmail.com Fri Apr 10 02:07:12 2009 From: jfredett at gmail.com (Joe Fredette) Date: Fri Apr 10 01:53:51 2009 Subject: [Haskell-cafe] Sequence differences In-Reply-To: <559390.3896.qm@web31105.mail.mud.yahoo.com> References: <559390.3896.qm@web31105.mail.mud.yahoo.com> Message-ID: <49DEE210.2030603@gmail.com> So, we can walk through it- > s f [] = [] > s f [x] = [x] > s f l = [ a f b | (a,b) <- zip (init l) (tail l)] First, we can write some of it to be a little more idiomatic, viz: s _ [] = [] s _ [x] = [x] s f ls = [f a b | (a,b) <- zip (init ls) (tail ls)] First, we have a function type, we can tell the variable f is a function because it's applied to arguments in the third case, since it's applied to two arguments, it's binary, so `s :: (a -> b -> c) -> ?` however, from the second case, we know that whatever the type of the second argument (a list of some type `a1`) is also the type of the return argument, since the `s` acts as the identity for lists of length less than 2, so s :: (a -> b -> a1) -> [a1] -> [a1] However, since the arguments for `f` are drawn from the same list, the argument types must _also_ be of type `a1`, leaving us with: s :: (a -> a -> a) -> [a] -> [a] This is, interestingly enough, precisely the type of foldr1. We can write your original function in another, cleaner way though, too, since zip will "zip" to the smaller of the two lengths, so you don't need to worry about doing the init and the tail, so `s` is really: s _ [] = [] s _ [x] = [x] s f ls = [f a b | (a,b) <- zip ls (tail ls)] but there is a function which does precisely what the third case does, called "zipWith" which takes a binary function and two lists and -- well -- does what that list comprehension does. In fact, it does what your whole function does... In fact, it _is_ your function, specialized a little, eg: yourZipWith f ls = zipWith f ls (tail ls) Hope that helps /Joe michael rice wrote: > I have a Scheme function that calculates sequence differences, i.e., > it returns a sequence that is the difference between the 2nd and the > 1st element, the 3rd and the 2nd, the 4th and the 3rd, etc. > > (define s > (lambda (f l) > (cond ((null? (cdr l)) '()) > (else (cons (f (cadr l) (car l)) > (s f (cdr l))))))) > > where > > (s - '(0,1,3,6,10,15,21,28)) => (1,2,3,4,5,6,7) > > > I'm thinking the same function in Haskell would be something like > > s :: > s f [] = [] > s f [x] = [x] > s f l = [ a f b | (a,b) <- zip (init l) (tail l)] > > > but can't figure out what the function typing would be. > > Michael > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- A non-text attachment was scrubbed... Name: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090410/020793dc/jfredett.vcf From apfelmus at quantentunnel.de Fri Apr 10 02:34:05 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Fri Apr 10 02:21:02 2009 Subject: [Haskell-cafe] Re: Referential Transparency and Monads In-Reply-To: <27F44BA4-FAA6-4719-B7AF-E15DDD7100FE@ece.cmu.edu> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <27F44BA4-FAA6-4719-B7AF-E15DDD7100FE@ece.cmu.edu> Message-ID: Brandon S. Allbery wrote: > Heinrich Apfelmus wrote: > >> loop' :: IO () >> loop' = putStr "o" >> loop' >> >> are indistinguishable in the >> >> IO a ~ World -> (a, World) > > > I still don't understand this; we are passing a World and getting a > World back, *conceptually* the returned World is modified by putStr. > It's not in reality, but we get the same effects if we write to a buffer > and observe that buffer with a debugger --- state threading constrains > the program to the rules that must be followed for ordered I/O, which is > what matters. Basically, the problem is that neither computation returns the final World because neither one terminates. More precisely, the goal of the IO a ~ World -> (a, World) semantics is to assign each expression of type IO a a pure function World -> (a, World) . For instance, the expression putChar 'c' would be assigned a function \world -> ((), world where 'c' has been printed) or similar. Now, the problem is that both loop and loop' are being assigned the same semantic function loop ~ \world -> _|_ loop' ~ \world -> _|_ We can't distinguish between a function that mutilates the world and then doesn't terminate and a function that is harmless but doesn't terminate either. After all, both return the same result (namely _|_) for the same input worlds. Regards, apfelmus -- http://apfelmus.nfshost.com From noteed at gmail.com Fri Apr 10 02:42:34 2009 From: noteed at gmail.com (minh thu) Date: Fri Apr 10 02:29:20 2009 Subject: [Haskell-cafe] Re: Referential Transparency and Monads In-Reply-To: References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <27F44BA4-FAA6-4719-B7AF-E15DDD7100FE@ece.cmu.edu> Message-ID: <40a414c20904092342r34e55ef2t190c9f4f1a92aae3@mail.gmail.com> 2009/4/10 Heinrich Apfelmus : > Brandon S. Allbery wrote: >> Heinrich Apfelmus wrote: >> >>> loop' :: IO () >>> loop' = putStr "o" >> loop' >>> >>> are indistinguishable in the >>> >>> IO a ~ World -> (a, World) >> >> >> I still don't understand this; we are passing a World and getting a >> World back, *conceptually* the returned World is modified by putStr. >> It's not in reality, but we get the same effects if we write to a buffer >> and observe that buffer with a debugger --- state threading constrains >> the program to the rules that must be followed for ordered I/O, which is >> what matters. > > Basically, the problem is that neither computation returns the final > World because neither one terminates. > > More precisely, the goal of the > > IO a ~ World -> (a, World) > > semantics is to assign each expression of type IO a a pure function > World -> (a, World) . For instance, the expression > > putChar 'c' > > would be assigned a function > > \world -> ((), world where 'c' has been printed) > > or similar. > > Now, the problem is that both loop and loop' are being assigned the > same semantic function > > loop ~ \world -> _|_ > loop' ~ \world -> _|_ > > We can't distinguish between a function that mutilates the world and > then doesn't terminate and a function that is harmless but doesn't > terminate either. After all, both return the same result (namely _|_) > for the same input worlds. I'm not sure I follow. > ones = 1:ones is similar to loop or loop' but I can 'take 5' from it. Even if loop or loop' do not terminate, some value is produced, isn't it ? Thu From apfelmus at quantentunnel.de Fri Apr 10 03:06:31 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Fri Apr 10 02:53:32 2009 Subject: [Haskell-cafe] Re: Referential Transparency and Monads In-Reply-To: <40a414c20904092342r34e55ef2t190c9f4f1a92aae3@mail.gmail.com> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <27F44BA4-FAA6-4719-B7AF-E15DDD7100FE@ece.cmu.edu> <40a414c20904092342r34e55ef2t190c9f4f1a92aae3@mail.gmail.com> Message-ID: minh thu wrote: > Heinrich Apfelmus wrote: > >> Basically, the problem is that neither computation returns the final >> World because neither one terminates. >> >> More precisely, the goal of the >> >> IO a ~ World -> (a, World) >> >> semantics is to assign each expression of type IO a a pure function >> World -> (a, World) . For instance, the expression >> >> putChar 'c' >> >> would be assigned a function >> >> \world -> ((), world where 'c' has been printed) >> >> or similar. >> >> Now, the problem is that both loop and loop' are being assigned the >> same semantic function >> >> loop ~ \world -> _|_ >> loop' ~ \world -> _|_ >> >> We can't distinguish between a function that mutilates the world and >> then doesn't terminate and a function that is harmless but doesn't >> terminate either. After all, both return the same result (namely _|_) >> for the same input worlds. > > I'm not sure I follow. > >> ones = 1:ones > > is similar to loop or loop' but I can 'take 5' from it. > > Even if loop or loop' do not terminate, some value is produced, isn't it ? No. Unlike loop and loop' which are both _|_ , ones is a proper value, namely it's an infinite list of 1 . Granted, saying that ones is "terminating" is a bit silly, but it's not "non-terminating" in the sense that it's not _|_. The fact that some recursive definition are _|_ and some are not is rather unsurprising when looking at functions. For instance, foo x = foo x -- is _|_ fac n = if n == 0 then 1 else n * fac (n-1) -- is not _|_ For more on the meaning of recursive definitions, see also http://en.wikibooks.org/wiki/Haskell/Denotational_semantics Here the detailed calculation of why both loop and loop' are _|_ : *loop* loop = fix f where f = \x -> x Hence, the iteration sequence for finding the fixed point reads _|_ f _|_ = (\x -> x) _|_ = _|_ and the sequence repeats already, so loop = _|_ . *loop'* loop' = fix f where f = \x -> putStr 'o' >> x Hence, the iteration sequence for finding the fixed point reads _|_ f _|_ = putStr 'o' >> _|_ = \w -> let (_,w') = putStr 'o' w in _|_ w' = _|_ Again, the sequence repeats already and we have loop' = _|_ . Regards, apfelmus -- http://apfelmus.nfshost.com From kscraja at gmail.com Fri Apr 10 03:11:07 2009 From: kscraja at gmail.com (Raja Koduru) Date: Fri Apr 10 02:57:53 2009 Subject: [Haskell-cafe] Crashing - First Graphics Program in Haskell School of Expression(HSOE) Message-ID: <1336aed20904100011n14e18765n9ff92aad7684bf81@mail.gmail.com> Hi, I am a beginner. Help me. Here is my "main.hs", sample code from the book HSOE. ---------------------------------------------------------------- module Main where import SOE main = runGraphics ( do w <- openWindow "My First Graphics Program" (300, 300) drawInWindow w (text (100, 100) "Hello Graphics World") k <- getKey w closeWindow w ) ------------------------------------------------------------------ When this is run, a window pops up but it immediately crashes. I call "main" function after loading the above src file (main.hs) in ghci I am on XP, using GHC-6.10.2. It crashed on GHC-6.10.1 also. I downloaded the HSOE code from here: http://haskell.org/soe/software1.htm Used cabal to install OpenGL(-2.2.1.1) and GLFW(0.3). ghc-pkg list output: d:/ghc/ghc-6.10.2\package.conf: Cabal-1.6.0.3, GLFW-0.3, HUnit-1.2.0.3, OpenGL-2.2.1.1, QuickCheck-1.2.0.0, Win32-2.2.0.0, array-0.2.0.0, base-3.0.3.1, base-4.1.0.0, bytestring-0.9.1.4, 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), filepath-1.1.0.2, (ghc-6.10.2), 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, 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, xhtml-3000.2.0.1 ----------------------------------------------------------------------------------------- regards, raja From ekirpichov at gmail.com Fri Apr 10 03:17:39 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Fri Apr 10 03:04:23 2009 Subject: [Haskell-cafe] Re: Referential Transparency and Monads In-Reply-To: References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <27F44BA4-FAA6-4719-B7AF-E15DDD7100FE@ece.cmu.edu> <40a414c20904092342r34e55ef2t190c9f4f1a92aae3@mail.gmail.com> Message-ID: <5e0214850904100017j7b595ef0k982a492f663a48e1@mail.gmail.com> 2009/4/10 Heinrich Apfelmus : > minh thu wrote: >> Heinrich Apfelmus wrote: >> >>> Basically, the problem is that neither computation returns the final >>> World because neither one terminates. >>> >>> More precisely, the goal of the >>> >>> ? ?IO a ?~ ?World -> (a, World) >>> >>> semantics is to assign each expression of type ?IO a ?a pure function >>> World -> (a, World) . For instance, the expression >>> >>> ? ?putChar 'c' >>> >>> would be assigned a function >>> >>> ? ?\world -> ((), world where 'c' has been printed) >>> >>> or similar. >>> >>> Now, the problem is that both ?loop ?and ?loop' ?are being assigned the >>> same semantic function >>> >>> ? ?loop ? ~ ?\world -> _|_ >>> ? ?loop' ?~ ?\world -> _|_ >>> >>> We can't distinguish between a function that mutilates the world and >>> then doesn't terminate and a function that is harmless but doesn't >>> terminate either. After all, both return the same result (namely _|_) >>> for the same input worlds. >> >> I'm not sure I follow. >> >>> ones = 1:ones >> >> is similar to loop or loop' but I can 'take 5' from it. >> >> Even if loop or loop' do not terminate, some value is produced, isn't it ? > > No. Unlike ?loop ?and ?loop' ?which are both ?_|_ , ?ones ?is a proper > value, namely it's an infinite list of 1 . Granted, saying that ?ones > is "terminating" is a bit silly, but it's not "non-terminating" in the > sense that it's not _|_. > > The fact that some recursive definition are _|_ and some are not is > rather unsurprising when looking at functions. For instance, > > ? foo x = foo x ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-- is _|_ > ? fac n = if n == 0 then 1 else n * fac (n-1) ?-- is not _|_ > > > For more on the meaning of recursive definitions, see also > > ? http://en.wikibooks.org/wiki/Haskell/Denotational_semantics > > > Here the detailed calculation of why both ?loop ?and ?loop' ?are _|_ : > > *loop* > > ? ? loop = fix f where f = \x -> x > > ? Hence, the iteration sequence for finding the fixed point reads > > ? ? _|_ > ? ? f _|_ = (\x -> x) _|_ = _|_ > > ? and the sequence repeats already, so ?loop = _|_ . > > *loop'* > > ? ? loop' = fix f where f = \x -> putStr 'o' >> x > > ? Hence, the iteration sequence for finding the fixed point reads > > ? ? _|_ > ? ? f _|_ = putStr 'o' >> _|_ > ? ? ? ? ? = \w -> let (_,w') = putStr 'o' w in _|_ w' > ? ? ? ? ? = _|_ > > ? Again, the sequence repeats already and we have ?loop' = _|_ . > Makes sense. The thing that is lacking to show difference between these two functions is that there is no way to 'erase' information from the world. T.i., even _|_ w' can't "really" be _|_, it must be a value that contains all the information from w'. _|_ w' /= _|_ is nonsense, thus a state monad does not suffice. I wonder what does... > > Regards, > apfelmus > > -- > http://apfelmus.nfshost.com > > _______________________________________________ > 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 Fri Apr 10 03:28:42 2009 From: noteed at gmail.com (minh thu) Date: Fri Apr 10 03:15:25 2009 Subject: [Haskell-cafe] compilation related questions Message-ID: <40a414c20904100028l1dfe57eckd04332683a2f6fbc@mail.gmail.com> Hi, There was a 'I want to write a compiler' thread recently. I wonder if there is such kind of pointers for compilation of strict functional languages (perhaps with lazy evaluation annotations) . Although GRIN is designed for lazy languages, would it be ok to use it for a strict one (and leverage its thunk representation for the lazy part of the language)? The 'whole program' optimization aspect is a plus. On a related note, I have another question. Say we have some data structure, for instance a list, some functions on this data structure (probably defined with some well known functions, such as map or fold), and a program using them. Is there any research trying to rewrite the program, and the data structure, to optimize them ? A contrived example is the length of a list : instead of traversing a list to know its length, the list can have an additional field which is incremented at each cons. Thanks, Thu From monnier at iro.umontreal.ca Fri Apr 10 03:30:34 2009 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Fri Apr 10 03:17:33 2009 Subject: [Haskell-cafe] Re: Referential Transparency and Monads References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <27F44BA4-FAA6-4719-B7AF-E15DDD7100FE@ece.cmu.edu> <1239339168.6902.42.camel@jonathans-macbook> Message-ID: >>>> IO a ~ World -> (a, World) >>> I still don't understand this; we are passing a World and getting a >>> World back, >> We are? Why do you think that? > Because that's what (World -> (a,World)) means, last I checked. No: Hasekll functions are partial, which means that "a -> b" means "takes an object of type `a' and if it terminates, it returns an object of type `b'". Note the "if it terminates". Since neither loop nor loop' terminate, their return type is actually meaningless. Stefan From ekirpichov at gmail.com Fri Apr 10 03:33:58 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Fri Apr 10 03:20:43 2009 Subject: [Haskell-cafe] Re: Referential Transparency and Monads In-Reply-To: References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <27F44BA4-FAA6-4719-B7AF-E15DDD7100FE@ece.cmu.edu> <1239339168.6902.42.camel@jonathans-macbook> Message-ID: <5e0214850904100033w1fd68ce8sc56159d38a2dce8e@mail.gmail.com> 2009/4/10 Stefan Monnier : >>>>> IO a ?~ ?World -> (a, World) >>>> I still don't understand this; we are passing a World and getting a >>>> World back, >>> We are? ?Why do you think that? >> Because that's what (World -> (a,World)) means, last I checked. > > No: Hasekll functions are partial, which means that "a -> b" means > "takes an object of type `a' and if it terminates, it returns an object > of type `b'". ?Note the "if it terminates". > > Since neither loop nor loop' terminate, their return type is > actually meaningless. > Why? They both return _|_, which is a quite legal value of that type. > > ? ? ? ?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 v.dijk.bas at gmail.com Fri Apr 10 04:28:56 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Fri Apr 10 04:15:44 2009 Subject: [Haskell-cafe] How to define a common return and bind? In-Reply-To: <5ab17e790904092019p392b9cc5i85987963f44d0a32@mail.gmail.com> References: <5ab17e790904092019p392b9cc5i85987963f44d0a32@mail.gmail.com> Message-ID: On Fri, Apr 10, 2009 at 5:19 AM, Iavor Diatchki wrote: > You can do things like that for "new" monads that are isomorphic to > existing ones. ?Take a look at the MonadLib.Derive package from > MonadLib Thanks! This is exactly what I want: ---------------------------------------- import MonadLib.Derive newtype T1 m a = T1 { unT1 :: A1 m a } type A1 m a = m a newtype T2 m a = T2 { unT2 :: A2 m a } type A2 m a = m a isoT1 = Iso T1 unT1 isoT2 = Iso T2 unT2 instance Monad m => Monad (T1 m) where return = derive_return isoT1 (>>=) = derive_bind isoT1 instance Monad m => Monad (T2 m) where return = derive_return isoT2 (>>=) = derive_bind isoT2 ---------------------------------------- Now I'm wondering if the derive_* functions can be overloaded using something like this. Note that the following doesn't typecheck: ---------------------------------------- {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE FlexibleInstances #-} ---------------------------------------- class Iso m n | m -> n, n -> m where close :: forall a. m a -> n a open :: forall a. n a -> m a deriveReturn :: (Monad m, Monad n, Iso m n) => a -> n a deriveReturn = close . return deriveBind :: (Monad m, Iso m n) => n a -> (a -> n b) -> n b deriveBind m k = close $ open m >>= open . k ---------------------------------------- newtype T1 m a = T1 { unT1 :: A1 m a } type A1 m a = m a instance Iso m (T1 m) where close = T1 open = unT1 instance Monad m => Monad (T1 m) where return = deriveReturn (>>=) = deriveBind ---------------------------------------- regards, Bas From nonowarn at gmail.com Fri Apr 10 05:15:17 2009 From: nonowarn at gmail.com (Yusaku Hashimoto) Date: Fri Apr 10 05:02:05 2009 Subject: [Haskell-cafe] How to define a common return and bind? In-Reply-To: References: <5ab17e790904092019p392b9cc5i85987963f44d0a32@mail.gmail.com> Message-ID: > Now I'm wondering if the derive_* functions can be overloaded using > something like this. Note that the following doesn't typecheck: > > ---------------------------------------- > > {-# LANGUAGE MultiParamTypeClasses #-} > {-# LANGUAGE RankNTypes #-} > {-# LANGUAGE FunctionalDependencies #-} > {-# LANGUAGE FlexibleInstances #-} > > ---------------------------------------- > > class Iso m n | m -> n, n -> m where > close :: forall a. m a -> n a > open :: forall a. n a -> m a > > deriveReturn :: (Monad m, Monad n, Iso m n) => a -> n a > deriveReturn = close . return > > deriveBind :: (Monad m, Iso m n) => n a -> (a -> n b) -> n b > deriveBind m k = close $ open m >>= open . k > > ---------------------------------------- > > newtype T1 m a = T1 { unT1 :: A1 m a } > type A1 m a = m a > > instance Iso m (T1 m) where > close = T1 > open = unT1 > > instance Monad m => Monad (T1 m) where > return = deriveReturn > (>>=) = deriveBind > > ---------------------------------------- Hi, I changed a line, It type checks. But I can't explain why your version does not type check. --- iso_orig.hs 2009-04-10 17:56:12.000000000 +0900 +++ iso.hs 2009-04-10 17:56:36.000000000 +0900 @@ -5,7 +5,7 @@ ---------------------------------------- -class Iso m n | m -> n, n -> m where +class Iso m n | n -> m where close :: forall a. m a -> n a open :: forall a. n a -> m a Thanks, Hashimoto From barsoap at web.de Fri Apr 10 06:54:56 2009 From: barsoap at web.de (Achim Schneider) Date: Fri Apr 10 06:42:00 2009 Subject: [Haskell-cafe] Re: Referential Transparency and Monads References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <1239330630.6902.17.camel@jonathans-macbook> <23AEEA07-B1E1-43D8-AA28-844643E49EAB@yandex.ru> <1239339645.6902.43.camel@jonathans-macbook> Message-ID: <20090410125456.5f1a0698@solaris> Jonathan Cast wrote: > On Fri, 2009-04-10 at 07:29 +0400, Miguel Mitrofanov wrote: > > On 10 Apr 2009, at 06:30, Jonathan Cast wrote: > > > do > > > s <- readFile "/my_file" > > > writeFile "/my_file" "Hello, world!\n" > > > threadDelay 10000 -- If you don't like threadDelay, just > > > substitute forcing > > > -- an expensive thunk here > > > writeFile "/my_file" s > > > > > > As a function from initial state to final state, this program is > > > just the identity; > > > > No, since world state includes the user state itself, not just > > files contents. > > My programs are passing me around inside a state token? > Sure. http://en.wikipedia.org/wiki/File:8-cell.gif Inside and outside become quite mindboggling when dealing with more dimensions than you expect... -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From barsoap at web.de Fri Apr 10 07:05:02 2009 From: barsoap at web.de (Achim Schneider) Date: Fri Apr 10 06:52:05 2009 Subject: [Haskell-cafe] Re: Crashing - First Graphics Program in Haskell School of Expression(HSOE) References: <1336aed20904100011n14e18765n9ff92aad7684bf81@mail.gmail.com> Message-ID: <20090410130502.6481e601@solaris> Raja Koduru wrote: > Hi, > > I am a beginner. Help me. > > Here is my "main.hs", sample code from the book HSOE. > ---------------------------------------------------------------- > module Main where > import SOE > > main = runGraphics ( > do w <- openWindow "My First Graphics Program" (300, 300) > drawInWindow w (text (100, 100) "Hello Graphics World") > k <- getKey w > closeWindow w > ) > > ------------------------------------------------------------------ > > When this is run, a window pops up but it immediately crashes. > I call "main" function after loading the above src file (main.hs) in > ghci > Does the same happen when you compile with "ghc --make" or use ":main" in ghci? ghc and ghci behaving different[1] wrt. ffi calls isn't unheard of. [1] meaning that ghci fails -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From barsoap at web.de Fri Apr 10 07:17:18 2009 From: barsoap at web.de (Achim Schneider) Date: Fri Apr 10 07:04:23 2009 Subject: [Haskell-cafe] Re: compilation related questions References: <40a414c20904100028l1dfe57eckd04332683a2f6fbc@mail.gmail.com> Message-ID: <20090410131718.47a34290@solaris> minh thu wrote: > On a related note, I have another question. Say we have some data > structure, for instance a list, some functions on this data structure > (probably defined with some well known functions, such as map or > fold), and a program using them. Is there any research trying to > rewrite the program, and the data structure, to optimize them ? > Yes. The most advanced approach that I know of is Dons' stream-fusion[1]. I guess the technique of transforming a program so that Y-combinators are at their outermost possible position (and fused, in the process) could be generalised. > A contrived example is the length of a list : instead of traversing a > list to know its length, the list can have an additional field which > is incremented at each cons. > Well, that's not a list anymore, at least not with some additional ingenuity to deal with infinite ones. Statically-lengthed lists can be done with some type trickery, see e.g. [2], if that helps. [1] http://www.cse.unsw.edu.au/~dons/papers/CLS07.html [2] http://article.gmane.org/gmane.comp.lang.haskell.general/13561 -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From v.dijk.bas at gmail.com Fri Apr 10 07:32:53 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Fri Apr 10 07:19:39 2009 Subject: [Haskell-cafe] How to define a common return and bind? In-Reply-To: References: <5ab17e790904092019p392b9cc5i85987963f44d0a32@mail.gmail.com> Message-ID: On Fri, Apr 10, 2009 at 11:15 AM, Yusaku Hashimoto wrote: > Hi, I changed a line, It type checks. > But I can't explain why your version does not type check. Thanks, I can't explain it either because I don't completely understand functional dependencies. So I rewrote it using type families which I find much easier to understand: ---------------------------------------- {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE FlexibleContexts #-} module Iso where class Iso m where type Inner m :: * -> * close :: forall a. Inner m a -> m a open :: forall a. m a -> Inner m a deriveReturn :: (Monad (Inner m), Iso m) => a -> m a deriveReturn = close . return deriveBind :: (Monad (Inner m), Iso m) => m a -> (a -> m b) -> m b deriveBind m k = close $ open m >>= open . k ---------------------------------------- newtype T1 m a = T1 { unT1 :: A1 m a } type A1 m a = m a instance Iso (T1 m) where type Inner (T1 m) = m close = T1 open = unT1 instance Monad m => Monad (T1 m) where return = deriveReturn (>>=) = deriveBind ---------------------------------------- You can also get a Monad instance "for free" if you aren't afraid of UndecidableInstances: ---------------------------------------- {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} instance (Monad (Inner m), Iso m) => Monad m where return = deriveReturn (>>=) = deriveBind ---------------------------------------- This seems useful. Does this exists somewhere on hackage? regards, Bas From noteed at gmail.com Fri Apr 10 08:03:55 2009 From: noteed at gmail.com (minh thu) Date: Fri Apr 10 07:50:39 2009 Subject: [Haskell-cafe] Re: compilation related questions In-Reply-To: <20090410131718.47a34290@solaris> References: <40a414c20904100028l1dfe57eckd04332683a2f6fbc@mail.gmail.com> <20090410131718.47a34290@solaris> Message-ID: <40a414c20904100503j18ea33eeofb2026121595c757@mail.gmail.com> 2009/4/10 Achim Schneider : > minh thu wrote: > >> On a related note, I have another question. Say we have some data >> structure, for instance a list, some functions on this data structure >> (probably defined with some well known functions, such as map or >> fold), and a program using them. Is there any research trying to >> rewrite the program, and the data structure, to optimize them ? >> > Yes. The most advanced approach that I know of is Dons' > stream-fusion[1]. I guess the technique of transforming a program so > that Y-combinators are at their outermost possible position (and fused, > in the process) could be generalised. > >> A contrived example is the length of a list : instead of traversing a >> list to know its length, the list can have an additional field which >> is incremented at each cons. >> > Well, that's not a list anymore, at least not with some additional > ingenuity to deal with infinite ones. Statically-lengthed lists can be > done with some type trickery, see e.g. [2], if that helps. Oh, that's not what I meant by my question. My question is more about the fact that the data structure can be augmented to include some information which is computed while constructing the structure, not afterward (to save an additional traversal). Say you have an AST, with just the information after a parsing pass. Then you compute 'derived' values at each node (maybe, I'm not sure if it would be practical, type, strictness, ...). To do that, you can have a function that, applied to any node, give the desired additional information. But for some functions, it can be seen clearly that such information could have been constructed at the same time that the data structure. So it is related to fusion techniques, but with the additional possibility of adding fields to the original data structure. Hope this makes sense, Thu From barsoap at web.de Fri Apr 10 08:40:00 2009 From: barsoap at web.de (Achim Schneider) Date: Fri Apr 10 08:26:55 2009 Subject: [Haskell-cafe] Re: compilation related questions References: <40a414c20904100028l1dfe57eckd04332683a2f6fbc@mail.gmail.com> <20090410131718.47a34290@solaris> <40a414c20904100503j18ea33eeofb2026121595c757@mail.gmail.com> Message-ID: <20090410144000.0385cc9c@solaris> minh thu wrote: > But for some functions, it can be seen clearly that such information > could have been constructed at the same time that the data structure. > > So it is related to fusion techniques, but with the additional > possibility of adding fields to the original data structure. > Well, the point fusion is about is _not_ to construct lists. consider naiveDropEnd xs = take (length xs - 1) xs , which, due to length being a catamorphism, traverses xs twice. It can be, in fact, reduced to the more sensible dropEnd (x:[]) = [] dropEnd (x:xs) = x:dropEnd xs , but that requires getting rid of the fold by replacing Integers with Peanos: length' = map (\_ -> ()) pred = tail succ = (():) zarroo = [] Now we can write notSoNaiveDropEnd xs = take' (pred $ length' xs) xs , which can be fused into a single y-combinator. Morale of the story: Folds are the bane of laziness. Having some magic in place than can choose a lazily constructed (and fused) Peano instance for Num in the right places would be awesomely cool. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From jason.dusek at gmail.com Fri Apr 10 08:48:47 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Apr 10 08:35:30 2009 Subject: [Haskell-cafe] Referential Transparency and Monads In-Reply-To: <2346277719240711356@unknownmsgid> References: <2346277719240711356@unknownmsgid> Message-ID: <42784f260904100548t512aa1acv39b1d501412bb577@mail.gmail.com> 2009/04/09 Mark Spezzano : > How exactly do monads ?solve? the problem of referential transparency? I > understand RT to be such that a function can be replaced with a actual > value. With referential transparency, an **expression** can be replaced with an evaluated variant of itself. When we choose to do the evaluation is not important. So we have some function: f :: SomeType -> SomeOther -> YetAnother -> SomethingElse One time, when we encounter `f a b c` and evaluate it to get `d`. Now whenever we see `f a b c` again, referential transparency tells us we can just stick the `d` right there and not bother about running the program that is inside `f`. What you have with the IO monad is things that look like the same expression but actually aren't; you also have rules of evaluation that force the reduction strategy to reduce things in order. Consider this: main = do c0 <- getChar c1 <- getChar print c1 At first glance, Pooh (or even Owl) might say, "The first `getChar` is just the same as the second.". Doesn't referential transparency say that we should just evaluate it one time and thus get only the first character in the stream? Well, no. Doesn't laziness say, we only need `c1` so we'll just read the first character off the stream? No again. The do notation is a great convenience; it is syntax transformed to this: main = getChar >>= (\c0 -> (getChar >>= (\c1 -> print c1))) We see right away that, in order to get at the second `getChar`, we need to provide an argument to the first lambda. Likewise, to get at the `print`, we need to provide an argument to the second lambda. The `>>=` is called "bind" and plays an essential role here. Each monad has its own bind -- bind is an integral part of its evaluation strategy. Let us consider a simplified implementation of the IO monad: data World = World ... data IO t = IO (World -> (t, World)) Every value of type `IO t` contains a function that takes us from `World` to a pair of `World` and `t`. The `World` is not important beyond the notion that no two are alike. Our implementation of `>>=` (also simplified compared to a real one): >>= :: IO a -> (a -> IO b) -> IO b IO act1 >>= f = IO (\w1 -> let { (t, w2) = act1 w1 ; IO act2 = f t } in act2 w2) Then we have `getChar` and `print`: getChar = IO charOp {- `charOp` is some unsafe operation that does the getting. -} print something = IO (printOp something) {- `printOp` is some unsafe operation that does the printing. -} Now let's substitute that into the above and see what we get: main = getChar >>= (\c0 -> (getChar >>= (\c1 -> print c1))) main = IO charOp >>= (\c0 -> (getChar >>= (\c1 -> print c1))) main = IO (\w1 -> let (c, w2) = charOp w1 IO act2 = (\c0 -> (getChar >>= (\c1 -> print c1))) c in act2 w2 ) main = IO (\w1 -> let (c, w2) = charOp w1 IO act2 = (getChar >>= (\c1 -> print c1)) in act2 w2 ) Let's work on just `act2`: IO act2 = (getChar >>= (\c1 -> print c1)) IO act2 = (IO charOp >>= (\c1 -> print c1)) IO act2 = IO (\w -> let (c', w3) = charOp w IO act3 = (\c1 -> print c1) c' in act3 w3 ) IO act2 = IO (\w -> let (c', w3) = charOp w IO act3 = print c' in act3 w3 ) IO act2 = IO (\w -> let (c', w3) = charOp w IO act3 = IO (printOp c') in act3 w3 ) IO act2 = IO (\w -> let (c', w3) = charOp w in (printOp c') w3 ) IO act2 = IO (\w -> let (c', w3) = charOp w in (printOp c') w3) Substituting: main = IO (\w1 -> let (c, w2) = charOp w1 IO act2 = IO (\w -> let (c', w3) = charOp w in (printOp c') w3) in act2 w2 ) main = IO (\w1 -> let (c, w2) = charOp w1 in (\w -> let (c', w3) = charOp w in (printOp c') w3) w2 ) main = IO (\w1 -> let (c, w2) = charOp w1 in let (c', w3) = charOp w2 in (printOp c') w3 ) So we let's review. Are the two `getChar`s the same expression? No -- one is called against one world, the other against another. Furthermore, they are ordered -- we need the world from the first one to get the world from the second. We need the second world to `print`. This is guaranteed by the semantics of "bind" in the IO monad. The expressions are not the same so referential transparency does not does not lead to dangerous elision; the data dependencies are explicit and so there is no way to re-order the evaluation of the expressions. Notice that these properties fall out of our rules for evaluation and not any "special sauce" for monads. > Just curious as to the rationale behind referential > transparency and how it applies to monads. That depends on the monad. -- Jason Dusek From nonowarn at gmail.com Fri Apr 10 08:54:28 2009 From: nonowarn at gmail.com (Yusaku Hashimoto) Date: Fri Apr 10 08:41:13 2009 Subject: [Haskell-cafe] How to define a common return and bind? In-Reply-To: References: <5ab17e790904092019p392b9cc5i85987963f44d0a32@mail.gmail.com> Message-ID: On 2009/04/10, at 20:32, Bas van Dijk wrote: > So I rewrote it using type families which I find much easier to > understand: Cool. Type family version is easier to read and understand for me. > This seems useful. Does this exists somewhere on hackage? I glanced at Monad category in package list, It seemed that There is no package like this. I hope you to upload your package! Thanks, Hashimoto From dev at mobileink.com Fri Apr 10 09:52:01 2009 From: dev at mobileink.com (Gregg Reynolds) Date: Fri Apr 10 09:38:46 2009 Subject: [Haskell-cafe] Re: Referential Transparency and Monads In-Reply-To: <27F44BA4-FAA6-4719-B7AF-E15DDD7100FE@ece.cmu.edu> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <1239304464.19297.26.camel@jcchost> <3161F8AF-4DD8-459F-8CD8-63B6374E8B16@yandex.ru> <7ca3f0160904091309m4a31440cmc4eb5ed022b715c5@mail.gmail.com> <27F44BA4-FAA6-4719-B7AF-E15DDD7100FE@ece.cmu.edu> Message-ID: <75cc17ac0904100652o3297a1dfy404a0e55f8bd6cd4@mail.gmail.com> On Thu, Apr 9, 2009 at 11:46 PM, Brandon S. Allbery KF8NH wrote: > > I still don't understand this; we are passing a World and getting a World > back, *conceptually* the returned World is modified by putStr. ?It's not in > reality, but we get the same effects if we write to a buffer and observe > that buffer with a debugger --- state threading constrains the program to > the rules that must be followed for ordered I/O, which is what matters. > You might find it useful to back up and think about the nature of computation. I did, anyway, when I was slogging through this stuff. Computability is all based on intuition about the *process* of calculating (see section 9 I think it is of Turing's original paper). IO "operations" - whatever one calls them - are by definition not computable. "Referentially transparent IO expressions" is an oxymoron, since the operations involved do not (cannot) correspond to any process that corresponds intuitively to computation and thus cannot refer transparently. So (going back to your original question) we can never get RT, but we can get the next best thing, which is manageability, which is what monads and other IO techniques are all about. YMMV, but for me the IO-as-state-transformer-operating-on-World is quite misleading. It's one possible method for dealing with IO conceptually but it's easy to get the incorrect impression that IO *is* some kind of state transformation, when in fact there is no essential connection between the two. There is no "state" nor "transformation" involved; an IO expression just references the result of some indeterminate non-computing process, just like a referentially transparent expression like '3+2' references the result of a determinate computing process. Monads etc. just allow us to use IO expressions as if they were computable even though they're not, by enforcing sequencing. Or to put it another way, what really counts is predictability, not referential transparency. -gregg From nowgate at yahoo.com Fri Apr 10 11:24:40 2009 From: nowgate at yahoo.com (michael rice) Date: Fri Apr 10 11:11:25 2009 Subject: [Haskell-cafe] Sequence differences Message-ID: <942657.66923.qm@web31102.mail.mud.yahoo.com> All very neat, and it works! Thanks. But I copied map :: (a -> b) -> [a] -> [b] ?? <==? I'm assuming this is correct from something called "A Tour of the Haskell Prelude" at http://undergraduate.csse.uwa.edu.au/units/CITS3211/lectureNotes/tourofprelude.html#all which I was looking at to try and roll my own typing. My next question: My function s f ls seems much like map f ls but instead looks like?? s :: (a -> a -> a) -> [a] -> [a] Clearly, there's more to the picture than meets the eye. Is there a good tutorial on types? Michael --- On Fri, 4/10/09, Joe Fredette wrote: From: Joe Fredette Subject: Re: [Haskell-cafe] Sequence differences To: "michael rice" , "haskell Cafe mailing list" Date: Friday, April 10, 2009, 2:07 AM So, we can walk through it- >? ???s f [] = [] >? ???s f [x] = [x] >? ???s f l = [ a f b | (a,b) <- zip (init l) (tail l)] First, we can write some of it to be a little more idiomatic, viz: s _ []? = [] s _ [x] = [x] s f ls? = [f a b | (a,b) <- zip (init ls) (tail ls)] First, we have a function type, we can tell the variable f is a function because it's applied to arguments in the third case, since it's applied to two arguments, it's binary, so `s :: (a -> b -> c) -> ?` however, from the second case, we know that whatever the type of the second argument (a list of some type `a1`) is also the type of the return argument, since the `s` acts as the identity for lists of length less than 2, so ???s :: (a -> b -> a1) -> [a1] -> [a1] However, since the arguments for `f` are drawn from the same list, the argument types must _also_ be of type `a1`, leaving us with: ???s :: (a -> a -> a) -> [a] -> [a] This is, interestingly enough, precisely the type of foldr1. We can write your original function in another, cleaner way though, too, since zip will "zip" to the smaller of the two lengths, so you don't need to worry about doing the init and the tail, so `s` is really: s _ []? = [] s _ [x] = [x] s f ls? = [f a b | (a,b) <- zip ls (tail ls)] but there is a function which does precisely what the third case does, called "zipWith" which takes a binary function and two lists and -- well -- does what that list comprehension does. In fact, it does what your whole function does... In fact, it _is_ your function, specialized a little, eg: yourZipWith f ls = zipWith f ls (tail ls) Hope that helps /Joe michael rice wrote: > I have a Scheme function that calculates sequence differences, i.e., it returns a sequence that is the difference between the 2nd and the 1st element, the 3rd and the 2nd, the 4th and the 3rd, etc. > > (define s >???(lambda (f l) >? ???(cond ((null? (cdr l)) '()) >? ? ? ? ???(else (cons (f (cadr l) (car l)) >? ? ? ? ? ? ? ? ? ? ???(s f (cdr l))))))) > > where > > (s - '(0,1,3,6,10,15,21,28)) => (1,2,3,4,5,6,7) > > > I'm thinking the same function in Haskell would be something like > > s :: > s f [] = [] > s f [x] = [x] > s f l = [ a f b | (a,b) <- zip (init l) (tail l)] > > > but can't figure out what the function typing would be. > > Michael > > > ------------------------------------------------------------------------ > > _______________________________________________ > 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/20090410/511f7757/attachment.htm From martijn at van.steenbergen.nl Fri Apr 10 11:38:04 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Apr 10 11:24:48 2009 Subject: [Haskell-cafe] Sequence differences In-Reply-To: <942657.66923.qm@web31102.mail.mud.yahoo.com> References: <942657.66923.qm@web31102.mail.mud.yahoo.com> Message-ID: <49DF67DC.3000702@van.steenbergen.nl> Hi Michael, michael rice wrote: > Clearly, there's more to the picture than meets the eye. Is there a good > tutorial on types? Have you seen Real World Haskell? http://book.realworldhaskell.org/read/ Chapter 2 already dives into types. Hope this helps, Martijn. From jfredett at gmail.com Fri Apr 10 11:39:43 2009 From: jfredett at gmail.com (Joe Fredette) Date: Fri Apr 10 11:26:33 2009 Subject: [Haskell-cafe] Sequence differences In-Reply-To: <942657.66923.qm@web31102.mail.mud.yahoo.com> References: <942657.66923.qm@web31102.mail.mud.yahoo.com> Message-ID: <49DF683F.1000104@gmail.com> You might try looking at Real World Haskell, it's not so much a tutorial on types, but a tutorial on Haskell in general. Theres also the Haskell-beginner's list, the backlogs of which are quite nice. Really the best way to learn is to just dive in, you can use Hoogle or Hayoo to search APIs. Just try to come up with a good idea, and start working on it! And of course, you can ask questions here or on Haskell-beginners. The rumors are true, we're awesome people. /Joe michael rice wrote: > All very neat, and it works! Thanks. > > But I copied > > map :: (a -> b) -> [a] -> [b] <== I'm assuming this is correct > > from something called "A Tour of the Haskell Prelude" at > > http://undergraduate.csse.uwa.edu.au/units/CITS3211/lectureNotes/tourofprelude.html#all > > which I was looking at to try and roll my own typing. > > > My next question: > > My function > > s f ls > > seems much like > > map f ls > > but instead looks like > > s :: (a -> a -> a) -> [a] -> [a] > > > Clearly, there's more to the picture than meets the eye. Is there a > good tutorial on types? > > Michael > > > --- On *Fri, 4/10/09, Joe Fredette //* wrote: > > > From: Joe Fredette > Subject: Re: [Haskell-cafe] Sequence differences > To: "michael rice" , "haskell Cafe mailing > list" > Date: Friday, April 10, 2009, 2:07 AM > > So, we can walk through it- > > > s f [] = [] > > s f [x] = [x] > > s f l = [ a f b | (a,b) <- zip (init l) (tail l)] > > First, we can write some of it to be a little more idiomatic, viz: > > s _ [] = [] > s _ [x] = [x] > s f ls = [f a b | (a,b) <- zip (init ls) (tail ls)] > > First, we have a function type, we can tell the variable f is a > function because it's applied to arguments in the third case, > since it's applied to two arguments, it's binary, so `s :: (a -> b > -> c) -> ?` however, from the > second case, we know that whatever the type of the second argument > (a list of some type `a1`) is also the type > of the return argument, since the `s` acts as the identity for > lists of length less than 2, so > > s :: (a -> b -> a1) -> [a1] -> [a1] > > However, since the arguments for `f` are drawn from the same list, > the argument types must _also_ be of type `a1`, leaving us with: > > s :: (a -> a -> a) -> [a] -> [a] > > This is, interestingly enough, precisely the type of foldr1. > > We can write your original function in another, cleaner way > though, too, since zip will "zip" to the smaller of the two > lengths, so you don't need to worry about doing the init and the > tail, so `s` is really: > > s _ [] = [] > s _ [x] = [x] > s f ls = [f a b | (a,b) <- zip ls (tail ls)] > > but there is a function which does precisely what the third case > does, called "zipWith" which takes a > binary function and two lists and -- well -- does what that list > comprehension does. In fact, it does > what your whole function does... In fact, it _is_ your function, > specialized a little, eg: > > yourZipWith f ls = zipWith f ls (tail ls) > > > Hope that helps > > /Joe > > michael rice wrote: > > I have a Scheme function that calculates sequence differences, > i.e., it returns a sequence that is the difference between the 2nd > and the 1st element, the 3rd and the 2nd, the 4th and the 3rd, etc. > > > > (define s > > (lambda (f l) > > (cond ((null? (cdr l)) '()) > > (else (cons (f (cadr l) (car l)) > > (s f (cdr l))))))) > > > > where > > > > (s - '(0,1,3,6,10,15,21,28)) => (1,2,3,4,5,6,7) > > > > > > I'm thinking the same function in Haskell would be something like > > > > s :: > > s f [] = [] > > s f [x] = [x] > > s f l = [ a f b | (a,b) <- zip (init l) (tail l)] > > > > > > but can't figure out what the function typing would be. > > > > Michael > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > -------------- next part -------------- A non-text attachment was scrubbed... Name: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090410/3ce51e1b/jfredett.vcf From chad.scherrer at pnl.gov Fri Apr 10 12:04:38 2009 From: chad.scherrer at pnl.gov (Chad Scherrer) Date: Fri Apr 10 11:51:40 2009 Subject: [Haskell-cafe] Re: Sequence differences References: <559390.3896.qm@web31105.mail.mud.yahoo.com> <49DEE210.2030603@gmail.com> Message-ID: Joe Fredette gmail.com> writes: > We can write your original function in another, cleaner way though, too, > since zip will "zip" to the smaller of the two lengths, so you don't > need to worry about doing the init and the tail, so `s` is really: > > s _ [] = [] > s _ [x] = [x] > s f ls = [f a b | (a,b) <- zip ls (tail ls)] > > but there is a function which does precisely what the third case does, > called "zipWith" which takes a > binary function and two lists and -- well -- does what that list > comprehension does. In fact, it does > what your whole function does... In fact, it _is_ your function, > specialized a little, eg: > > yourZipWith f ls = zipWith f ls (tail ls) A nice generalization of this that can be really useful is movingWindow :: Int -> [a] -> [[a]] movingWindow 1 xs = map (:[]) xs movingWindow n xs = zipWith (:) xs . tail $ movingWindow (n-1) xs So for example, > movingWindow 3 [1..10] [[1,2,3],[2,3,4],[3,4,5],[4,5,6],[5,6,7],[6,7,8],[7,8,9],[8,9,10]] Then you can write diff :: (Num a) => [a] -> [a] diff = map (\[x,y] -> y - x) . movingWindow 2 Hopefully the intermediate lists are optimized away, but I haven't done any performance testing. Chad From rmm-haskell at z.odi.ac Fri Apr 10 12:36:16 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Fri Apr 10 12:23:03 2009 Subject: [Haskell-cafe] Sequence differences In-Reply-To: <942657.66923.qm@web31102.mail.mud.yahoo.com> References: <942657.66923.qm@web31102.mail.mud.yahoo.com> Message-ID: Well, it is mapping, but take a look at the type of zip: zip :: [a] -> [b] -> [(a,b)] (that is, two lists in, list of tuples out) so you can use map, which has the type: map :: (a -> b) -> [a] -> [b] over a zipped list, e.g.: map f (zip a b) Because [a] is [(a,b)] (the result of zip), the type of map becomes ((a,b) -> c) -> [(a,b)] -> [c] Most binary functions such as (-) (subtract) do not take a tuple as an argument, they are curried, e.g. (-) :: Num a => a -> a -> a So you can use the uncurry function to transform these curried binary functions into unary functions that take tuples uncurry :: (a -> b -> c) -> (a,b) -> c so, uncurry (-) :: Num a => (a,a) -> a which you can use as the first argument to map map (uncurry (-)) :: Num a => [(a,a)] -> [a] and then pipe in the zip map (uncurry (-)) (zip as bs) :: [a] in your case, you want 'as' to be the second and subsequent elements of the list, tail, and 'bs' to be the first and subsequent elements of the list, so l :: [Int] l = [0,1,3,6,10,15,21,28] map (uncurry (-)) (zip (tail l) l) which you can generalize and wrap up in a function: s :: (a -> a -> b) -> [a] -> [b] s f l = map (uncurry f) (zip (tail l) l) there's also the list comprehension version, where you move the 'uncurry' behavior into a pattern match: s2 :: (a -> a -> b) -> [a] -> [b] s2 f l = [ f a b | (a,b) <- zip (tail l) l ] Hope that helps, -Ross On Apr 10, 2009, at 11:24 AM, michael rice wrote: > All very neat, and it works! Thanks. > > But I copied > > map :: (a -> b) -> [a] -> [b] <== I'm assuming this is correct > > from something called "A Tour of the Haskell Prelude" at > > http://undergraduate.csse.uwa.edu.au/units/CITS3211/lectureNotes/tourofprelude.html#all > > which I was looking at to try and roll my own typing. > > > My next question: > > My function > > s f ls > > seems much like > > map f ls > > but instead looks like > > s :: (a -> a -> a) -> [a] -> [a] > > > Clearly, there's more to the picture than meets the eye. Is there a > good tutorial on types? > > Michael > > > --- On Fri, 4/10/09, Joe Fredette wrote: > > From: Joe Fredette > Subject: Re: [Haskell-cafe] Sequence differences > To: "michael rice" , "haskell Cafe mailing list" > > Date: Friday, April 10, 2009, 2:07 AM > > So, we can walk through it- > > > s f [] = [] > > s f [x] = [x] > > s f l = [ a f b | (a,b) <- zip (init l) (tail l)] > > First, we can write some of it to be a little more idiomatic, viz: > > s _ [] = [] > s _ [x] = [x] > s f ls = [f a b | (a,b) <- zip (init ls) (tail ls)] > > First, we have a function type, we can tell the variable f is a > function because it's applied to arguments in the third case, since > it's applied to two arguments, it's binary, so `s :: (a -> b -> c) - > > ?` however, from the > second case, we know that whatever the type of the second argument > (a list of some type `a1`) is also the type > of the return argument, since the `s` acts as the identity for lists > of length less than 2, so > > s :: (a -> b -> a1) -> [a1] -> [a1] > > However, since the arguments for `f` are drawn from the same list, > the argument types must _also_ be of type `a1`, leaving us with: > > s :: (a -> a -> a) -> [a] -> [a] > > This is, interestingly enough, precisely the type of foldr1. > > We can write your original function in another, cleaner way though, > too, since zip will "zip" to the smaller of the two lengths, so you > don't need to worry about doing the init and the tail, so `s` is > really: > > s _ [] = [] > s _ [x] = [x] > s f ls = [f a b | (a,b) <- zip ls (tail ls)] > > but there is a function which does precisely what the third case > does, called "zipWith" which takes a > binary function and two lists and -- well -- does what that list > comprehension does. In fact, it does > what your whole function does... In fact, it _is_ your function, > specialized a little, eg: > > yourZipWith f ls = zipWith f ls (tail ls) > > > Hope that helps > > /Joe > > michael rice wrote: > > I have a Scheme function that calculates sequence differences, > i.e., it returns a sequence that is the difference between the 2nd > and the 1st element, the 3rd and the 2nd, the 4th and the 3rd, etc. > > > > (define s > > (lambda (f l) > > (cond ((null? (cdr l)) '()) > > (else (cons (f (cadr l) (car l)) > > (s f (cdr l))))))) > > > > where > > > > (s - '(0,1,3,6,10,15,21,28)) => (1,2,3,4,5,6,7) > > > > > > I'm thinking the same function in Haskell would be something like > > > > s :: > > s f [] = [] > > s f [x] = [x] > > s f l = [ a f b | (a,b) <- zip (init l) (tail l)] > > > > > > but can't figure out what the function typing would be. > > > > Michael > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > 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 patai_gergely at fastmail.fm Fri Apr 10 12:41:06 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Fri Apr 10 12:27:49 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library Message-ID: <1239381666.12202.1309941005@webmail.messagingengine.com> Hi everyone, I'm pleased to announce Elerea, aka "Eventless reactivity", a minimalistic FRP implementation that - comes with a convenient applicative interface (similar to Reactive) - supports recursive definition of signals - supports signals fed from outside by IO actions - supports dynamism in the signal structure (I think ;) - seems to play nice with resources, especially memory - is based on some unsafePerformIO dark magic (that might easily break depending on many factors) - might have some parallelisation potential - has absolutely no formal foundations, it's just the result of some furious hacking over the last few days! There are working examples to show off the current capabilities of the library, found in the separate elerea-examples package. Have fun playing with it! Gergely -- http://www.fastmail.fm - A no graphics, no pop-ups email service From jfredett at gmail.com Fri Apr 10 13:03:15 2009 From: jfredett at gmail.com (Joe Fredette) Date: Fri Apr 10 12:50:05 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: <1239381666.12202.1309941005@webmail.messagingengine.com> References: <1239381666.12202.1309941005@webmail.messagingengine.com> Message-ID: <49DF7BD3.3030509@gmail.com> I've seen alot of FRP libraries come up, and I'm always left with the question, "Where the heck are the FRP tutorials?" I'm talking about the bare-bones, "I've-never-even-touched-this-stuff-before" kind of tutorial. Something that explains the general theory and provides a few simple applications, maybe the start of a bigger one or something to mess around with and actually learn how to use FRP. The notion seems interesting, and perhaps I just haven't googled hard enough, but I can't really seem to find a good, newbie-level tutorial on it. Can anyone aim me in the right direction? Patai Gergely wrote: > Hi everyone, > > I'm pleased to announce Elerea, aka "Eventless reactivity", a > minimalistic FRP implementation that > > - comes with a convenient applicative interface (similar to Reactive) > - supports recursive definition of signals > - supports signals fed from outside by IO actions > - supports dynamism in the signal structure (I think ;) > - seems to play nice with resources, especially memory > - is based on some unsafePerformIO dark magic (that might easily break > depending on many factors) > - might have some parallelisation potential > - has absolutely no formal foundations, it's just the result of some > furious hacking over the last few days! > > There are working examples to show off the current capabilities of the > library, found in the separate elerea-examples package. Have fun playing > with it! > > Gergely > > -------------- next part -------------- A non-text attachment was scrubbed... Name: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090410/66c924bf/jfredett.vcf From gue.schmidt at web.de Fri Apr 10 13:15:45 2009 From: gue.schmidt at web.de (=?UTF-8?B?R8O8wp9udGhlciBTY2htaWR0?=) Date: Fri Apr 10 13:02:46 2009 Subject: [Haskell-cafe] Re: Paper: Translating donotation to SQL, Leijden, Meijer In-Reply-To: References: Message-ID: Hi Shan, thanks but the paper I'm looking for is actually the reference #13 from the document you're pointing me to. G?nther Chung-chieh Shan schrieb: > G??nther Schmidt wrote in article in gmane.comp.lang.haskell.cafe: >> is the paper "Translating donotation to SQL, Leijden, Meijer (1999)" >> available anywhere? > > Seems to be here > http://www.usenix.org/events/dsl99/full_papers/leijen/leijen_html/ > no? > From barsoap at web.de Fri Apr 10 13:32:06 2009 From: barsoap at web.de (Achim Schneider) Date: Fri Apr 10 13:19:05 2009 Subject: [Haskell-cafe] Re: ANN: Elerea, another FRP library References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> Message-ID: <20090410193206.3c585525@solaris> Joe Fredette wrote: > I've seen alot of FRP libraries come up, and I'm always left with the > question, "Where the heck are the FRP tutorials?" > > I'm talking about the bare-bones, > "I've-never-even-touched-this-stuff-before" kind of tutorial. > Something that explains the general theory and > provides a few simple applications, maybe the start of a bigger one > or something to mess around with and actually learn how to use FRP. > > The notion seems interesting, and perhaps I just haven't googled hard > enough, but I can't really seem to find a good, newbie-level tutorial > on it. > > Can anyone aim me in the right direction? > http://haskell.org/haskellwiki/Reactive/Tutorial/A_FPS_display Mind you, frp libraries differ quite a lot and using them might require knowledge of their innards, but the main thing to wrap your head around is looking at the points instead of the whole "update loop", as frp abstracts away the time. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From jfredett at gmail.com Fri Apr 10 13:48:56 2009 From: jfredett at gmail.com (Joe Fredette) Date: Fri Apr 10 13:35:44 2009 Subject: [Haskell-cafe] Re: ANN: Elerea, another FRP library In-Reply-To: <20090410193206.3c585525@solaris> References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> <20090410193206.3c585525@solaris> Message-ID: <49DF8688.7000603@gmail.com> Awesome, Sir, you are a gentleman and a scholar. Thanks. /Joe Achim Schneider wrote: > Joe Fredette wrote: > > >> I've seen alot of FRP libraries come up, and I'm always left with the >> question, "Where the heck are the FRP tutorials?" >> >> I'm talking about the bare-bones, >> "I've-never-even-touched-this-stuff-before" kind of tutorial. >> Something that explains the general theory and >> provides a few simple applications, maybe the start of a bigger one >> or something to mess around with and actually learn how to use FRP. >> >> The notion seems interesting, and perhaps I just haven't googled hard >> enough, but I can't really seem to find a good, newbie-level tutorial >> on it. >> >> Can anyone aim me in the right direction? >> >> > http://haskell.org/haskellwiki/Reactive/Tutorial/A_FPS_display > > Mind you, frp libraries differ quite a lot and using them might > require knowledge of their innards, but the main thing to wrap your head > around is looking at the points instead of the whole "update loop", as > frp abstracts away the time. > > -------------- next part -------------- A non-text attachment was scrubbed... Name: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090410/3980e499/jfredett.vcf From patai_gergely at fastmail.fm Fri Apr 10 14:21:13 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Fri Apr 10 14:07:56 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: <49DF7BD3.3030509@gmail.com> References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> Message-ID: <1239387673.2337.1309952317@webmail.messagingengine.com> > I've seen alot of FRP libraries come up, and I'm always left with the > question, "Where the heck are the FRP tutorials?" Writing a good tutorial takes a lot of time, but I made some example code precisely to show how the library can be used. The best way to learn is to start playing with them. The "chase" example is about as small as it gets, and the breakout one is generally a nice test case for such a library, as it exercises the code as well as provides a reasonably complex example for the user to study. The basic idea is indeed what Achim said: we refer to the whole lifetime of some time-varying quantity (what I call a signal, but the name behaviour is also often used for this concept in other systems) with a single name. For instance, mousePosition is a two-dimensional vector whose value follows the position of the mouse at any time. The applicative interface means that you can combine signals using ordinary point-wise functions by simple lifting. To keep with the example, something like drawUnitRectangle <$> mousePosition would result in a signal whose points are IO actions that draw the rectangle where the mouse is at the moment you sample them. The drawUnitRectangle function doesn't need to have anything reactive in it, it just takes an ordinary pair (or whatever you represent your vectors with) and does its job. In the end, a program working with signals looks very much like one calculating a snapshot of the system and the state changes at the given moment, except you need to insert <*>'s and lift values where applicable. Gergely -- http://www.fastmail.fm - mmm... Fastmail... From nowgate at yahoo.com Fri Apr 10 15:38:47 2009 From: nowgate at yahoo.com (michael rice) Date: Fri Apr 10 15:25:34 2009 Subject: [Haskell-cafe] Sequence differences Message-ID: <127259.27531.qm@web31104.mail.mud.yahoo.com> No, I was unaware of this, but it looks good. Thanks. Michael --- On Fri, 4/10/09, Martijn van Steenbergen wrote: From: Martijn van Steenbergen Subject: Re: [Haskell-cafe] Sequence differences To: "michael rice" Cc: "haskell Cafe mailing list" , "Joe Fredette" Date: Friday, April 10, 2009, 11:38 AM Hi Michael, michael rice wrote: > Clearly, there's more to the picture than meets the eye. Is there a good tutorial on types? Have you seen Real World Haskell? http://book.realworldhaskell.org/read/ Chapter 2 already dives into types. Hope this helps, Martijn. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090410/5649c94a/attachment.htm From ketil at malde.org Fri Apr 10 15:52:09 2009 From: ketil at malde.org (Ketil Malde) Date: Fri Apr 10 15:37:44 2009 Subject: [Haskell-cafe] Sequence differences In-Reply-To: <942657.66923.qm@web31102.mail.mud.yahoo.com> (michael rice's message of "Fri\, 10 Apr 2009 08\:24\:40 -0700 \(PDT\)") References: <942657.66923.qm@web31102.mail.mud.yahoo.com> Message-ID: <87vdpcmgly.fsf@malde.org> michael rice writes: > map :: (a -> b) -> [a] -> [b] ?? <==? I'm assuming this is correct This is the type of 'map', yes. Btw, ou can check types in GHCi with the :i command. > s f ls > > seems much like > > map f ls > > but instead looks like?? > > s :: (a -> a -> a) -> [a] -> [a] If you look at the definition: >> s f [] = [] >> s f [x] = [x] >> s f l = [ a f b | (a,b) <- zip (init l) (tail l)] You'll notice that the second clause, namely s f [x] = [x] produces the second parameter [x] (of type [a]) as its output, and thus the types must be the same as well. Also (assuming it is 'f a b' and not 'a f b' in the list comprehension), f is applied to two parameters, so it'll have to be of type (x -> y -> z), and since the two input parameters come from the originating list, x and y must be the same as a, and since we have seen the result list also has the same type, z must be the same as a, too. Thus f must have type (a -> a -> a). Unclear? Clear? Operating thetan? -k -- If I haven't seen further, it is by standing in the footprints of giants From nowgate at yahoo.com Fri Apr 10 15:55:07 2009 From: nowgate at yahoo.com (michael rice) Date: Fri Apr 10 15:41:50 2009 Subject: [Haskell-cafe] Re: Sequence differences Message-ID: <322904.57343.qm@web31101.mail.mud.yahoo.com> Yes, that is nice, and also useful for calculating moving averages. Thanks. Michael --- On Fri, 4/10/09, Chad Scherrer wrote: From: Chad Scherrer Subject: [Haskell-cafe] Re: Sequence differences To: haskell-cafe@haskell.org Date: Friday, April 10, 2009, 12:04 PM Joe Fredette gmail.com> writes: > We can write your original function in another, cleaner way though, too, > since zip will "zip" to the smaller of the two lengths, so you don't > need to worry about doing the init and the tail, so `s` is really: > > s _ []? = [] > s _ [x] = [x] > s f ls? = [f a b | (a,b) <- zip ls (tail ls)] > > but there is a function which does precisely what the third case does, > called "zipWith" which takes a > binary function and two lists and -- well -- does what that list > comprehension does. In fact, it does > what your whole function does... In fact, it _is_ your function, > specialized a little, eg: > > yourZipWith f ls = zipWith f ls (tail ls) A nice generalization of this that can be really useful is movingWindow :: Int -> [a] -> [[a]] movingWindow 1 xs = map (:[]) xs movingWindow n xs = zipWith (:) xs . tail $ movingWindow (n-1) xs So for example, > movingWindow 3 [1..10] [[1,2,3],[2,3,4],[3,4,5],[4,5,6],[5,6,7],[6,7,8],[7,8,9],[8,9,10]] Then you can write diff :: (Num a) => [a] -> [a] diff = map (\[x,y] -> y - x) . movingWindow 2 Hopefully the intermediate lists are optimized away, but I haven't done any performance testing. Chad _______________________________________________ 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/20090410/e3700fbf/attachment.htm From nowgate at yahoo.com Fri Apr 10 16:09:27 2009 From: nowgate at yahoo.com (michael rice) Date: Fri Apr 10 15:56:12 2009 Subject: [Haskell-cafe] Sequence differences Message-ID: <862265.68170.qm@web31101.mail.mud.yahoo.com> Clearly, I have some reading to do. Thanks, Michael --- On Fri, 4/10/09, Ketil Malde wrote: From: Ketil Malde Subject: Re: [Haskell-cafe] Sequence differences To: "michael rice" Cc: "haskell Cafe mailing list" , "Joe Fredette" Date: Friday, April 10, 2009, 3:52 PM michael rice writes: > map :: (a -> b) -> [a] -> [b] ?? <==? I'm assuming this is correct This is the type of 'map', yes.? Btw, ou can check types in GHCi with the :i command. > s f ls > > seems much like > > map f ls > > but instead looks like?? > > s :: (a -> a -> a) -> [a] -> [a] If you look at the definition: >> s f [] = [] >> s f [x] = [x] >> s f l = [ a f b | (a,b) <- zip (init l) (tail l)] You'll notice that the second clause, namely ???s f [x] = [x] produces the second parameter [x] (of type [a]) as its output, and thus the types must be the same as well. Also (assuming it is 'f a b' and not 'a f b' in the list comprehension), f is applied to two parameters, so it'll have to be of type (x -> y -> z), and since the two input parameters come from the originating list, x and y must be the same as a, and since we have seen the result list also has the same type, z must be the same as a, too.? Thus f must have type (a -> a -> a).? Unclear? Clear? Operating thetan? -k -- If I haven't seen further, it is by standing in the footprints of giants -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090410/a434ed41/attachment-0001.htm From aeyakovenko at gmail.com Fri Apr 10 16:36:03 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Fri Apr 10 16:22:47 2009 Subject: [Haskell-cafe] what does the hidden package error mean? Message-ID: I am trying to build ParseP on the latest ghc, and i am getting this error: Text/ParserCombinators/ParseP/Interface.hs:26:17: Could not find module `Data.ByteString.Char8': it is a member of package bytestring-0.9.1.4, which is hidden what does "hidden" mean? why does this work in ghci > import Data.ByteString > import Data.ByteString.Char8 > without any problems From jgbailey at gmail.com Fri Apr 10 16:37:29 2009 From: jgbailey at gmail.com (Justin Bailey) Date: Fri Apr 10 16:24:31 2009 Subject: [Haskell-cafe] Re: Paper: Translating donotation to SQL, Leijden, Meijer In-Reply-To: References: Message-ID: I suspect it was never written. They "reference" that paper as one yet to be written. On Fri, Apr 10, 2009 at 10:15 AM, G??nther Schmidt wrote: > Hi Shan, > > thanks but the paper I'm looking for is actually the reference #13 from the > document you're pointing me to. > > G?nther > > > > Chung-chieh Shan schrieb: >> >> G??nther Schmidt wrote in article >> in gmane.comp.lang.haskell.cafe: >>> >>> is the paper "Translating donotation to SQL, Leijden, Meijer (1999)" >>> available anywhere? >> >> Seems to be here >> http://www.usenix.org/events/dsl99/full_papers/leijen/leijen_html/ >> no? >> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From aeyakovenko at gmail.com Fri Apr 10 16:39:07 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Fri Apr 10 16:25:51 2009 Subject: [Haskell-cafe] Re: what does the hidden package error mean? In-Reply-To: References: Message-ID: Ah, bytestring was missing from the build-depends, what a confusing error message, can we change it to say "package Foo is missing from the MyPackage.cabal build-depends" would be a lot more obvious how to fix it. On Fri, Apr 10, 2009 at 1:36 PM, Anatoly Yakovenko wrote: > I am trying to build ParseP on the latest ghc, and i am getting this error: > > Text/ParserCombinators/ParseP/Interface.hs:26:17: > ? ?Could not find module `Data.ByteString.Char8': > ? ? ?it is a member of package bytestring-0.9.1.4, which is hidden > > what does "hidden" mean? ?why does this work in ghci > >> import Data.ByteString >> import Data.ByteString.Char8 >> > > without any problems > From rmm-haskell at z.odi.ac Fri Apr 10 16:39:32 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Fri Apr 10 16:26:21 2009 Subject: [Haskell-cafe] what does the hidden package error mean? In-Reply-To: References: Message-ID: <1C09092B-3F29-443F-B4E4-B4942AAFDF75@z.odi.ac> I assume you're using cabal, which hides all packages by default. Add "bytestring" or "bytestring >= 0.9.*" or something along those lines to Build-Depends in your .cabal file. If you're not using cabal, I'm not sure why it would be hidden, but you can unhide with -package bytestring to GHC. -Ross On Apr 10, 2009, at 4:36 PM, Anatoly Yakovenko wrote: > I am trying to build ParseP on the latest ghc, and i am getting this > error: > > Text/ParserCombinators/ParseP/Interface.hs:26:17: > Could not find module `Data.ByteString.Char8': > it is a member of package bytestring-0.9.1.4, which is hidden > > what does "hidden" mean? why does this work in ghci > >> import Data.ByteString >> import Data.ByteString.Char8 >> > > without any problems > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From wren at freegeek.org Fri Apr 10 17:19:04 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri Apr 10 17:05:47 2009 Subject: [Haskell-cafe] Re: compilation related questions In-Reply-To: <40a414c20904100503j18ea33eeofb2026121595c757@mail.gmail.com> References: <40a414c20904100028l1dfe57eckd04332683a2f6fbc@mail.gmail.com> <20090410131718.47a34290@solaris> <40a414c20904100503j18ea33eeofb2026121595c757@mail.gmail.com> Message-ID: <49DFB7C8.4060608@freegeek.org> minh thu wrote: > Say you have an AST, with just the information after a parsing pass. > Then you compute 'derived' values at each node (maybe, I'm not sure if > it would be practical, type, strictness, ...). To do that, you can > have a function that, applied to any node, give the desired additional > information. > > But for some functions, it can be seen clearly that such information > could have been constructed at the same time that the data structure. > > So it is related to fusion techniques, but with the additional > possibility of adding fields to the original data structure. The problem with doing this automatically is that you don't get that data for free. Storing the length of finite lists as you construct them means that getting the length is constant time, but it introduces a space overhead of one Integer per (:). If you call length often enough it may be worth it, but generally the book-keeping will be too expensive. We could use modified strategies where we have two different (:)s, one that stores the length and one that doesn't. Then we could apply some heuristic like exponential backoff to minimize the space overheads subject to some logarithmic bound on the asymptotic cost of calculating the length of the list until the first label. Or we could apply dynamic memoization techniques and switch a non-length-storing (:) into a length-storing (:) whenever we evaluate a call to length, so it'll be quicker next time. Or,... There're a lot of strategies here, but I doubt it's feasible to automatically choose a good strategy for a given program (since "good" may depend on the vagaries of runtime data). Automatically doing the transformations and suggesting them to the user is doable though. You may be interested in looking into attribute grammars[1] and finger trees[2] for more ideas along this route. [1] http://www.haskell.org/haskellwiki/The_Monad.Reader/Issue4/Why_Attribute_Grammars_Matter [2] http://apfelmus.nfshost.com/monoid-fingertree.html -- Live well, ~wren From bugfact at gmail.com Fri Apr 10 17:19:22 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Apr 10 17:06:07 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: <49DF7BD3.3030509@gmail.com> References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> Message-ID: If you're interested in the history of FRP (which I think isn't too bad) you could read - the book "Haskell School of Expression ", which contains a good introduction to classical FRP. - "The Yampa Arcade" paper, to get introduced to newer arrow-based FRP. - FRAG, a Quake-like game written in Yampa - "Genuinely Functional User Interfaces" to see how user interfaces could be made with arrow-based FRP The newest FRP approaches are Reactive and Grapefruit, but these don't have a lot of examples yet. For Reactive, besides the nice FRP tutorial that was mentioned, you might want to look at David's Sankel tutorials The examples for Grapefruit can be found in the darcs repos as mentioned here 2009/4/10 Joe Fredette > I've seen alot of FRP libraries come up, and I'm always left with the > question, "Where the heck are the FRP tutorials?" > > I'm talking about the bare-bones, > "I've-never-even-touched-this-stuff-before" kind of tutorial. Something that > explains the general theory and > provides a few simple applications, maybe the start of a bigger one or > something to mess around with and actually learn how to use FRP. > > The notion seems interesting, and perhaps I just haven't googled hard > enough, but I can't really seem to find a good, newbie-level tutorial on it. > > Can anyone aim me in the right direction? > > > Patai Gergely wrote: > >> Hi everyone, >> >> I'm pleased to announce Elerea, aka "Eventless reactivity", a >> minimalistic FRP implementation that >> >> - comes with a convenient applicative interface (similar to Reactive) >> - supports recursive definition of signals >> - supports signals fed from outside by IO actions >> - supports dynamism in the signal structure (I think ;) >> - seems to play nice with resources, especially memory >> - is based on some unsafePerformIO dark magic (that might easily break >> depending on many factors) >> - might have some parallelisation potential >> - has absolutely no formal foundations, it's just the result of some >> furious hacking over the last few days! >> >> There are working examples to show off the current capabilities of the >> library, found in the separate elerea-examples package. Have fun playing >> with it! >> >> Gergely >> >> >> > > _______________________________________________ > 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/20090410/4a46161e/attachment.htm From martijn at van.steenbergen.nl Fri Apr 10 17:57:42 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Apr 10 17:44:24 2009 Subject: [Haskell-cafe] Ann: Yogurt-0.4 Message-ID: <49DFC0D6.6050902@van.steenbergen.nl> Bonsoir caf?, It is my pleasure to announce version 0.4 of Yogurt, a functional MUD client. Version 0.4 makes Yogurt available as a standalone executable that is able to dynamically load and reload Yogurt scripts. Here is a small example of such a script: > module Minimal where > > import Network.Yogurt > > newmoon :: Session > newmoon = session > { hostName = "eclipse.cs.pdx.edu" > , portNumber = 7680 > , mudProgram = \reload -> do > mkCommand "reload" reload > } Valid scripts define at least one session which is used to connect to the MUD. mudProgram fields are provided with a reload action that when invoked reloads the script without interrupting the MUD connection. Of course, Yogurt also still offers hooks, timers, logging, variables and more. The executable is released as a separate package so that developers wishing to use just the "pure" machinery can do that without inheriting dependencies on the GHC API or readline library. To install the executable, run: $ cabal update $ cabal install Yogurt -freadline $ cabal install Yogurt-Standalone Yogurt's new home page can be found at: http://code.google.com/p/yogurt-mud/ And on hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Yogurt http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Yogurt-Standalone I would love to hear your feedback! Suggestions, complaints, comments, bug reports, experiences et cetera are all welcome. Kind regards, Martijn. From claus.reinke at talk21.com Fri Apr 10 18:12:41 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Fri Apr 10 17:59:27 2009 Subject: [Haskell-cafe] compilation related questions References: <40a414c20904100028l1dfe57eckd04332683a2f6fbc@mail.gmail.com> Message-ID: > On a related note, I have another question. Say we have some data > structure, for instance a list, some functions on this data structure > (probably defined with some well known functions, such as map or > fold), and a program using them. Is there any research trying to > rewrite the program, and the data structure, to optimize them ? Do you mean "computer science"?-) Much of this field could be rephrased as the search for better representations, to enable better implementations of algorithms (for some measure of "better"): do we represent programs as data structures to be interpreted, or as code to be executed? do we use sets, lists, arrays, ..? how do we represent sets/lists/arrays/..? do we recompute properties of data, or do we store them (and is one better always, or sometimes, and when? or do we need to optimize for the average or the most common case? how do we define "better", anyway?)? which are the options, for a particular application domain, or a general class of data structure/algorithm, and how do they compare? and so on.. But if you limit your question sufficiently, you might have some luck looking for papers that reference any of these: Automatic data structure selection: an example and overview, James R. Low, Communications of the ACM, 1978 http://portal.acm.org/citation.cfm?id=359488.359498 Techniques for the automatic selection of data structures Low, Rovner, 3rd POPL, 1976 http://portal.acm.org/citation.cfm?id=811540 Rovner, P. Automatic representation selection for associative data structures. Ph.D. Th., Harvard U., Cambridge, Mass; Tech. Rep. TR10, U. of Rochester, Rochester, N.Y., Sept. 1976. Claus From lemming at henning-thielemann.de Fri Apr 10 18:54:12 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Apr 10 18:40:55 2009 Subject: [Haskell-cafe] Trying to write 'safeFromInteger' In-Reply-To: <404396ef0904080555t4cc22c8et10dd0c2e021cafdc@mail.gmail.com> References: <7fb8f82f0904080509t6677570dta762f3fd7d74c6b9@mail.gmail.com> <4c88418c0904080536o75c1d8f4gd9c87b5c77475e53@mail.gmail.com> <404396ef0904080555t4cc22c8et10dd0c2e021cafdc@mail.gmail.com> Message-ID: On Wed, 8 Apr 2009, Neil Mitchell wrote: > That seems a really weird way to write it! Who decided all auxiliary > functions should be called go? (I think I'm blaming dons) - why not: > > sffi :: (Integral a,Num a) => Integer -> Maybe a > sffi n | toInteger n2 == n = Just n2 > | otherwise = Nothing > where n2 = fromInteger n I think it is a bug, that 'fromInteger' is defined for numbers outside the range of the target type. Why is it necessary to have, say fromInteger 1000 == (232 :: Word8) ? I would not rely on this behaviour and safeFromInteger should also work, when the fromInteger method yields undefined for some Integer input. From apfelmus at quantentunnel.de Fri Apr 10 18:54:33 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Fri Apr 10 18:41:29 2009 Subject: [Haskell-cafe] Re: Referential Transparency and Monads In-Reply-To: <39428.8900694393$1239292179@news.gmane.org> References: <39428.8900694393$1239292179@news.gmane.org> Message-ID: Mark Spezzano wrote: > How exactly do monads “solve” the problem of referential transparency? I > understand RT to be such that a function can be replaced with a actual > value. > > Since a monad could potentially encapsulate any other value—say, data read > from a keyboard—doesn’t that violate the assumption of RT on monads? > > Or does RT ignore the encapsulated data and just view the “action” performed > by the monad as the “value” of the monad? The term "referential transparency" refers to functions and means that "equal arguments give equal results". For instance, there cannot be a function getChar :: () -> Char that reads input from the keyboard because referential transparency demands that the character returned must always be the same. Similarly, a function putChar :: Char -> () that prints a character on the screen cannot exist because we could replace every say putChar 'a' with () which does not output anything. Both values are equal, after all. However, functions getChar :: () -> IO Char putChar :: Char -> IO () are entirely feasible; the side effect has been pushed into the IO type constructor. In other words, getChar () :: IO Char is always the same IO action (reading a character from the keyboard) and putChar 'c' :: IO () is always the same IO action (printing 'c' on the screen). In other words, we have decomposed "function with side effect" = "pure function" + "side effect" -> + IO Regards, apfelmus -- http://apfelmus.nfshost.com From lemming at henning-thielemann.de Fri Apr 10 19:01:50 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Apr 10 18:48:33 2009 Subject: [Haskell-cafe] Maybe off-topic -- Writing contracts or software specifications In-Reply-To: References: Message-ID: On Wed, 8 Apr 2009, Maur??cio wrote: > Hi, > > I'm an engineer, and as a programmer I'm just an amateur. > This easied things to me, since I could take decisions about > practices based on what made sense to me. But now I need > to take responsability for some formal programming tasks, > and I don't know which examples to follow. > > I need, for instance, to write a contract with a programmer > we are hiring for a task. But the only example I have of > such contracts seemed to me (as I said, an amateur. I may be > completely wrong) impractical. It was a 150 pages document > with every possible user action and every imaginable allowed > consequences. But it would be easier to me write the software > than such contract itself. I think such a contract won't help you, because after writing and using the software, you will always find things, that you now like to do different from what you wrote into the contract. I think the best to do is to divide the project into small pieces. If the programmer is not the right one, this should turn out after the first piece and you can try another one. I don't expect that you can turn an inappropriate programmer into a better one using a tight contract. From lemming at henning-thielemann.de Fri Apr 10 19:52:47 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Apr 10 19:39:30 2009 Subject: [Haskell-cafe] Re: Sequence differences In-Reply-To: References: <559390.3896.qm@web31105.mail.mud.yahoo.com> <49DEE210.2030603@gmail.com> Message-ID: On Fri, 10 Apr 2009, Chad Scherrer wrote: > A nice generalization of this that can be really useful is > > movingWindow :: Int -> [a] -> [[a]] > movingWindow 1 xs = map (:[]) xs > movingWindow n xs = zipWith (:) xs . tail $ movingWindow (n-1) xs > > So for example, > >> movingWindow 3 [1..10] > [[1,2,3],[2,3,4],[3,4,5],[4,5,6],[5,6,7],[6,7,8],[7,8,9],[8,9,10]] movingWindow n xs = take (length xs - n +1) $ map (take n) $ tails xs or more efficient using utility-ht package: movingWindow n xs = Data.List.Match.take (drop (n-1) xs) $ map (take n) $ tails xs > Then you can write > > diff :: (Num a) => [a] -> [a] > diff = map (\[x,y] -> y - x) . movingWindow 2 > > Hopefully the intermediate lists are optimized away, but I haven't done any > performance testing. I'm not sure. You are safer and more efficient when you restrict to pairs. Since I often need the function, I defined: http://hackage.haskell.org/packages/archive/utility-ht/0.0.4/doc/html/Data-List-HT.html#v%3AmapAdjacent Then diff = mapAdjacent subtract From asmith9983 at gmail.com Fri Apr 10 20:20:31 2009 From: asmith9983 at gmail.com (A Smith) Date: Fri Apr 10 20:07:14 2009 Subject: [Haskell-cafe] Maybe off-topic -- Writing contracts or software specifications In-Reply-To: References: Message-ID: <1e11fb0e0904101720j44a886f2ie06f0ed71d39de0c@mail.gmail.com> My 2cents on this is. Make sure you use the most appropriate programming language for the task you want to achieve, and hire a programmer who knows the language really well. Make sure they are productive. i.e. They can type at a fast rate. They know the editor really well. i.e. They know all the obscure features of ViM, such as abbreviations,functions,keyboard mappings. They know how to create a Make file. As they will know the language really well, they will be able to quickly interpret compile time errors. As they know the language well, they will be able to work with you creating a really good detailed design. e.g. Abstracting any required objects and their methods. as this is a Haskell list, functions structure. A program design always changes during the implementation as you go through the learning curve of needs. You, the programmer and the customer will have a fairly continuous dialog of questions. Write all these down in such a way you can ensure the programs being written encompass them. Things will go best if everyone has trust in each other and a commitment to producing a top quality product. -- Andrew in Edinburgh,Scotland 2009/4/11 Henning Thielemann > > On Wed, 8 Apr 2009, Maur??cio wrote: > > Hi, >> >> I'm an engineer, and as a programmer I'm just an amateur. >> This easied things to me, since I could take decisions about >> practices based on what made sense to me. But now I need >> to take responsability for some formal programming tasks, >> and I don't know which examples to follow. >> >> I need, for instance, to write a contract with a programmer >> we are hiring for a task. But the only example I have of >> such contracts seemed to me (as I said, an amateur. I may be >> completely wrong) impractical. It was a 150 pages document >> with every possible user action and every imaginable allowed >> consequences. But it would be easier to me write the software >> than such contract itself. >> > > I think such a contract won't help you, because after writing and using the > software, you will always find things, that you now like to do different > from what you wrote into the contract. I think the best to do is to divide > the project into small pieces. If the programmer is not the right one, this > should turn out after the first piece and you can try another one. I don't > expect that you can turn an inappropriate programmer into a better one using > a tight contract. > _______________________________________________ > 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/20090411/866bf065/attachment.htm From jason.dusek at gmail.com Fri Apr 10 20:42:40 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Apr 10 20:29:22 2009 Subject: [Haskell-cafe] Maybe off-topic -- Writing contracts or software specifications In-Reply-To: References: Message-ID: <42784f260904101742t46be266bg7f773019fc5cbe09@mail.gmail.com> I think it is important to have clear rules for how you'll handle adjustments to the project. It's important to set expectations clearly at the outset; however, things change and there needs to be respect for that. Nothing that is in writing should be allowed to remain incorrect unless it is specifically superceded. Especially for bright people, it is difficult to go through the motions of writing up one's little decisions after the fact. Can't we just move forward? Do we need all this bureaucracy? It's not just about covering your ass -- you also want to be sure that what you remember is what the other party remembers. The after-meeting write-up and review is a good exercize for that. -- Jason Dusek From dan.doel at gmail.com Fri Apr 10 21:07:34 2009 From: dan.doel at gmail.com (Dan Doel) Date: Fri Apr 10 20:54:21 2009 Subject: [Haskell-cafe] Re: Referential Transparency and Monads In-Reply-To: <5e0214850904100017j7b595ef0k982a492f663a48e1@mail.gmail.com> References: <544EDEC1-C0DD-4B16-99C5-192C73275F6B@ece.cmu.edu> <5e0214850904100017j7b595ef0k982a492f663a48e1@mail.gmail.com> Message-ID: <200904102107.35785.dan.doel@gmail.com> On Friday 10 April 2009 3:17:39 am Eugene Kirpichov wrote: > Makes sense. > The thing that is lacking to show difference between these two > functions is that there is no way to 'erase' information from the > world. > T.i., even _|_ w' can't "really" be _|_, it must be a value that > contains all the information from w'. > _|_ w' /= _|_ is nonsense, thus a state monad does not suffice. I > wonder what does... At the very least, you could probably default to a term algebra. Then, loop is still the value _|_, whereas loop' is more of a tree, like: loop' = PutStr "o" `Then` PutStr "o" `Then` PutStr "o" `Then` ... Which is a well defined value in the same way that 'fix (1:)' is. And, of course, the runtime interprets such trees to get the actual operation of your program (add conceptual constructors to the tree as you add functionality to the IO monad). It's possible a continuation passing implementation might do the trick, too, since loop' goes something like: f e k = putStr "o" $ \_ -> e k f _|_ = \k -> putStr "o" $ \_ -> _|_ k /= _|_ loop' = fix f = \k -> putStr "o" $ \_ -> loop' k although that is, perhaps, a naive implementation as far as the whole semantics of IO are concerned (but then, so is World -> a * World). I haven't thought hard about whether it's subject to similar problems. Cheers, -- Dan From briqueabraque at yahoo.com Fri Apr 10 21:40:38 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Fri Apr 10 21:27:36 2009 Subject: [Haskell-cafe] Re: Maybe off-topic -- Writing contracts or software specifications In-Reply-To: References: Message-ID: >> I'm an engineer, and as a programmer I'm just an amateur. >> This easied things to me, since I could take decisions about >> practices based on what made sense to me. But now I need >> to take responsability for some formal programming tasks, >> and I don't know which examples to follow. > I think such a contract won't help you, because after writing and using > the software, you will always find things, that you now like to do > different from what you wrote into the contract. I think the best to do > is to divide the project into small pieces. Thanks for all sugestions. I do agree with what you and others said, and that's what I would do. I already worked with others in my former office, and the result was pretty good with just some talk, a few pictures and around 5 points in source code saying "here the world state should be this" kind of comments. But I have an additional concern: to fit in burocracy. I need to write a contract that someone else, who understands just office applications, not software writing, will need to feel safe enough with to sign it. It's not that important to have a good contract, but actually to be able to say "someone else did it like this, and had no problems". Then I can save that contract and forget about it. I need something that won't hurt, more than something that will help development. (I do trust the programmer. Much to my surprise, he suggested Haskell as the better option for the job.) Thanks, Maur?cio From noteed at gmail.com Sat Apr 11 04:49:30 2009 From: noteed at gmail.com (minh thu) Date: Sat Apr 11 04:36:10 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> Message-ID: <40a414c20904110149o27d508c0u7b7efe0391ffa74d@mail.gmail.com> An other interesting approach to FRP is frtime (in Scheme): http://www.cs.brown.edu/~sk/Publications/Papers/Published/ck-frtime/ There should be a second paper than this one, I have just forget its reference. Thu 2009/4/10 Peter Verswyvelen : > If you're interested in the history of FRP (which I think isn't too bad) you > could read > - the book "Haskell School of Expression?", which contains a good > introduction to classical FRP. > - ?"The Yampa Arcade" paper, to get introduced to newer arrow-based FRP. > -?FRAG,?a Quake-like game written in Yampa > -?" > > Genuinely Functional User Interfaces > > " to see how user interfaces could be made with arrow-based FRP > The newest FRP approaches are Reactive and Grapefruit, but these don't ?have > a lot of examples yet. > For Reactive, besides the nice FRP tutorial that was mentioned, you might > want to look at David's Sankel tutorials > The examples for?Grapefruit can be found in the darcs repos as mentioned > here > > 2009/4/10 Joe Fredette >> >> I've seen alot of FRP libraries come up, and I'm always left with the >> question, "Where the heck are the FRP tutorials?" >> >> I'm talking about the bare-bones, >> "I've-never-even-touched-this-stuff-before" kind of tutorial. Something that >> explains the general theory and >> provides a few simple applications, maybe the start of a bigger one or >> something to mess around with and actually learn how to use FRP. >> >> The notion seems interesting, and perhaps I just haven't googled hard >> enough, but I can't really seem to find a good, newbie-level tutorial on it. >> >> Can anyone aim me in the right direction? >> >> Patai Gergely wrote: >>> >>> Hi everyone, >>> >>> I'm pleased to announce Elerea, aka "Eventless reactivity", a >>> minimalistic FRP implementation that >>> >>> - comes with a convenient applicative interface (similar to Reactive) >>> - supports recursive definition of signals >>> - supports signals fed from outside by IO actions >>> - supports dynamism in the signal structure (I think ;) >>> - seems to play nice with resources, especially memory >>> - is based on some unsafePerformIO dark magic (that might easily break >>> depending on many factors) >>> - might have some parallelisation potential >>> - has absolutely no formal foundations, it's just the result of some >>> furious hacking over the last few days! >>> >>> There are working examples to show off the current capabilities of the >>> library, found in the separate elerea-examples package. Have fun playing >>> with it! >>> >>> Gergely >>> >>> >> >> _______________________________________________ >> 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 leather at cs.uu.nl Sat Apr 11 04:53:13 2009 From: leather at cs.uu.nl (Sean Leather) Date: Sat Apr 11 04:40:09 2009 Subject: [Haskell-cafe] Hac5 is almost upon us! Message-ID: <3c6288ab0904110153y660c189fua5b909dcb127149a@mail.gmail.com> In six days, tens of crazy/obsessed, type-safe, functional programmers will be converging on Utrecht to commence execution of... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ???????????????????? The 5th Haskell Hackathon ??????????????????????? April 17 - 19, 2009 ???????????????????? Utrecht, The Netherlands ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The local organizing team welcomes you all and looks forward to all of the new developments that come out of everyone's undying quest to write more and better code. As always, you can find lots of useful information on the wiki: ? http://haskell.org/haskellwiki/Hac5 == Sponsors == We have sponsors! The following companies were very gracious to provide us with support during these tough economic times. * Galois - http://galois.com/ * Microsoft Research - http://research.microsoft.com/ * Tupil - http://tupil.com/ The organizers are incredibly grateful to Galois, MSR, and Tupil for helping to encourage and promote more Haskell hacking. == More To Come == Hopefully, you have already registered, booked your room, and bought your ticket. If not, don't forget that you can keep in touch with the attendees via IRC on Freenode: #haskell-hac5 All registered attendees will soon be receiving an email with more details. Let us know if you have any questions. Happy Hacking! == Organizers == Andres L?h, Utrecht University (UU) Jos? Pedro Magalh?es, UU Sean Leather, UU Eelco Lempsink, UU + Tupil Chris Eidhof, UU + Tupil ... and more ... From patai_gergely at fastmail.fm Sat Apr 11 06:10:01 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Sat Apr 11 05:56:41 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: <40a414c20904110149o27d508c0u7b7efe0391ffa74d@mail.gmail.com> References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> <40a414c20904110149o27d508c0u7b7efe0391ffa74d@mail.gmail.com> Message-ID: <1239444601.20625.1310024249@webmail.messagingengine.com> > An other interesting approach to FRP is frtime (in Scheme): > http://www.cs.brown.edu/~sk/Publications/Papers/Published/ck-frtime/ > There should be a second paper than this one, I have just forget its > reference. Elerea is a bit similar, since it also maintains the connections between signals explicitly. However, its evaluation is a backward chaining process starting from the top-level signal, only affecting the nodes it depends on transitively. Only stateful signals need to be mutated and reevaluated whenever the top level is sampled (to avoid time and space leaks). Constants, pure functions and function application nodes always stay the same, and they are lazily evaluated. Peripheral bound external signals are also static from the point of view of the evaluator, and it is the responsibility of the environment to update them. Gergely -- http://www.fastmail.fm - Accessible with your email software or over the web From mailing_list at istitutocolli.org Sat Apr 11 06:58:06 2009 From: mailing_list at istitutocolli.org (Andrea Rossato) Date: Sat Apr 11 06:44:47 2009 Subject: [Haskell-cafe] ANN xmobar-0.9.2 Message-ID: <20090411105806.GU7942@eeepc.nowhere.net> Hi, I'm glad to announce xmobar-0.9.2. What's new: - Norbert Zeh tracked and fixed a longstanding bug that made xmobar leak X resources. This alone makes it worth this release and its public announcement, with the advice to users to upgrade.[*] - Norbert also overhauled the template parser to allow nested color definitions; - Norbert, once again, added the possibility to add color definitions in the monitors' templates. Many thanks to Norbert!! I've read that xmobar lists in the top 25 most downloaded Hackage packages. This is very cool: thanks to all the xmobar users. Hope you'll enjoy. Andrea [*] I tend to believe the same issue affects xmonad, even though it should be visible only after a huge number of restarts. Things get far worse when it comes to the xmonad-contrib library, especially if you use fancy decorations in your layouts: if you see colors you are probably leaking them. From haskell at list.mightyreason.com Sat Apr 11 07:26:19 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Sat Apr 11 07:13:15 2009 Subject: [Haskell-cafe] ANN: MSem replacement for QSem Message-ID: <49E07E5B.70709@list.mightyreason.com> "Grasshopper, try to take the stone from my hand" Hello all, After looking at the code for QSem [1], I realize it is not exception safe. And it does more work than needed. I have a proposed replacement module MSem at http://haskell.org/haskellwiki/SafeConcurrent on the wiki. I claim this is a safer, more correct, and more efficient replacement for QSem. But I may be tragically wrong which is where you come in. Please try and find some strange concurrency bug that I have missed. Once there is reviewed replacement code I will propose changing the base package. Exception safe replacements for QSemN and SampleVar are also needed. The MSem code I have can be generalized into an "MSemN", but the semantics are be different from "QSemN". This MSemN only considers the needs of the first blocked waiter instead of all of them. The code MSemN is on the same wiki page, perhaps someone will find this variant useful. Cheers, Chris [1] http://www.haskell.org/ghc/docs/latest/html/libraries/base/src/Control-Concurrent-QSem.html From deniz.a.m.dogan at gmail.com Sat Apr 11 07:44:08 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Sat Apr 11 07:30:48 2009 Subject: [Haskell-cafe] Re: what does the hidden package error mean? In-Reply-To: References: Message-ID: <7b501d5c0904110444u44665d46v8486ba4006e54f21@mail.gmail.com> I agree, a better error message (or something less cryptic w.r.t. the new guy) would be very nice. --Deniz 2009/4/10 Anatoly Yakovenko : > Ah, bytestring was missing from the build-depends, > > what a confusing error message, can we change it to say > > "package Foo is missing from the MyPackage.cabal build-depends" > > would be a lot more obvious how to fix it. > > > On Fri, Apr 10, 2009 at 1:36 PM, Anatoly Yakovenko > wrote: >> I am trying to build ParseP on the latest ghc, and i am getting this error: >> >> Text/ParserCombinators/ParseP/Interface.hs:26:17: >> ? ?Could not find module `Data.ByteString.Char8': >> ? ? ?it is a member of package bytestring-0.9.1.4, which is hidden >> >> what does "hidden" mean? ?why does this work in ghci >> >>> import Data.ByteString >>> import Data.ByteString.Char8 >>> >> >> without any problems >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bugfact at gmail.com Sat Apr 11 08:47:01 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sat Apr 11 08:33:41 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: <1239444601.20625.1310024249@webmail.messagingengine.com> References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> <40a414c20904110149o27d508c0u7b7efe0391ffa74d@mail.gmail.com> <1239444601.20625.1310024249@webmail.messagingengine.com> Message-ID: Any idea how Elerea compares to Grapefruit? It's great to see a lot of competition in the FRP arena, but I hope in the end this results in a really usable and scalable FRP system for Haskell :-) 2009/4/11 Patai Gergely > > An other interesting approach to FRP is frtime (in Scheme): > > http://www.cs.brown.edu/~sk/Publications/Papers/Published/ck-frtime/ > > There should be a second paper than this one, I have just forget its > > reference. > Elerea is a bit similar, since it also maintains the connections between > signals explicitly. However, its evaluation is a backward chaining > process starting from the top-level signal, only affecting the nodes it > depends on transitively. Only stateful signals need to be mutated and > reevaluated whenever the top level is sampled (to avoid time and space > leaks). Constants, pure functions and function application nodes always > stay the same, and they are lazily evaluated. Peripheral bound external > signals are also static from the point of view of the evaluator, and it > is the responsibility of the environment to update them. > > Gergely > > -- > http://www.fastmail.fm - Accessible with your email software > or over the web > > _______________________________________________ > 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/20090411/2bcfa930/attachment.htm From barsoap at web.de Sat Apr 11 09:35:49 2009 From: barsoap at web.de (Achim Schneider) Date: Sat Apr 11 09:22:51 2009 Subject: [Haskell-cafe] Re: what does the hidden package error mean? References: Message-ID: <20090411153549.7a0ce264@solaris> Anatoly Yakovenko wrote: > On Fri, Apr 10, 2009 at 1:36 PM, Anatoly Yakovenko > wrote: > > I am trying to build ParseP on the latest ghc, and i am getting > > this error: > > > > Text/ParserCombinators/ParseP/Interface.hs:26:17: > > __ __Could not find module `Data.ByteString.Char8': > > __ __ __it is a member of package bytestring-0.9.1.4, which is hidden > > > > what does "hidden" mean? __why does this work in ghci > > > >> import Data.ByteString > >> import Data.ByteString.Char8 > >> > > > > without any problems > > > Ah, bytestring was missing from the build-depends, > > what a confusing error message, can we change it to say > > "package Foo is missing from the MyPackage.cabal build-depends" > > would be a lot more obvious how to fix it. > The problem is that ghc doesn't know that, and shouldn't[1]: All it sees is a -hide-all-packages on its command line, you can witness it by calling cabal with the -v flag. OTOH, having some cross-compiler, machine-readable format to describe errors would enable cabal to do some holding of hands, as well as save ide developers from having to write all these boring parsers. [1] For UNIX fundamentalists, like me, MUST NOT -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From patai_gergely at fastmail.fm Sat Apr 11 10:57:16 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Sat Apr 11 10:43:56 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> <40a414c20904110149o27d508c0u7b7efe0391ffa74d@mail.gmail.com> <1239444601.20625.1310024249@webmail.messagingengine.com> Message-ID: <1239461836.10283.1310044611@webmail.messagingengine.com> > Any idea how Elerea compares to Grapefruit? It's great to see a lot of > competition in the FRP arena, but I hope in the end this results in a > really usable and scalable FRP system for Haskell :-) I think Wolfgang can judge this better, because I don't really know the innards of Grapefruit, while the Elerea core is extremely simple, so anyone can easily see how it works. By the way, I was told that Haddock will be run in a day or two, so the online docs will appear soon. >From the user's point of view, Elerea is probably closest to Reactive, except that everything including reactivity is expressed with continuous functions. There are no reactive elements with side-effects (at least conceptually), unlike the circuits of Grapefruit. Also, Elerea is essentially pull-based. In general, we can say there's a lot less going on in it than in Reactive or Grapefruit. Gergely -- http://www.fastmail.fm - The way an email service should be From martijn at van.steenbergen.nl Sat Apr 11 10:58:40 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Sat Apr 11 10:45:21 2009 Subject: [Haskell-cafe] cabal haddock and Paths_Xxx In-Reply-To: <8625cd9c0904080221m6d0c644eg87f515b7d290c341@mail.gmail.com> References: <49DA4AD9.80704@van.steenbergen.nl> <8625cd9c0904080221m6d0c644eg87f515b7d290c341@mail.gmail.com> Message-ID: <49E0B020.7010301@van.steenbergen.nl> Andrea Vezzosi wrote: > Which version of Cabal are you using? > It should be fixed with Cabal-1.6.0.2, check cabal --version to make > sure it's not using an older one. You're absolutely right. Thanks! Martijn. From iavor.diatchki at gmail.com Sat Apr 11 11:12:37 2009 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Sat Apr 11 10:59:17 2009 Subject: [Haskell-cafe] How to define a common return and bind? In-Reply-To: References: <5ab17e790904092019p392b9cc5i85987963f44d0a32@mail.gmail.com> Message-ID: <5ab17e790904110812r65e3c39wd3b4ac7320eb5738@mail.gmail.com> Hi, On Fri, Apr 10, 2009 at 1:28 AM, Bas van Dijk wrote: > Now I'm wondering if the derive_* functions can be overloaded using > something like this. Note that the following doesn't typecheck: > > ---------------------------------------- > > {-# LANGUAGE MultiParamTypeClasses #-} > {-# LANGUAGE RankNTypes #-} > {-# LANGUAGE FunctionalDependencies #-} > {-# LANGUAGE FlexibleInstances #-} > > ---------------------------------------- > > class Iso m n | m -> n, n -> m where > ? ?close :: forall a. m a -> n a > ? ?open ?:: forall a. n a -> m a If the intention is to capture the idea of an isomorphism between monads, then the functional dependencies on the class are not correct. For example, they assert that a monad can be isomorphic to at most one other monad, which is not true. For example, you can have two different monads that ar implemented in the same way under the hood: newtype T1 a = T1 { unT1 :: MyMonad a } newtype T2 a = T2 { unT2 :: MyMonad a } instance Iso MyMonad T1 where ... instance Iso MyMonad T2 where ... This violates the first functional dependency that you wrote. On the other hand, for the task at hand, we know that if we know the "derived" monad, then we will always know its implementation exactly. So the following concept might be more appropriate: class DerivedM new old | new -> old where close :: old a -> new a open :: new a -> old a Now it certainly makes sense to define the following instances: instance DerivedM T1 MyMonad where ... instance DerivedM T2 MyMonad where ... Note that this is essentially what Yusaku did by removing the one functional dependency (although the arguments of DerivedM are in the opposite order from the arguments of Iso). This is also exactly what you did when you rewrote the example to use type families. I kind of like this idea because it removes the need to use the rank-2 type extension, so I might try to implement it in monadLib. Thanks! -Iavor PS: You said that you find type families easier to understand then functional dependencies. While I can certainly believe that, I would encourage you to try to understand the concept of a functional dependency (which in actuality is not that complicated at all). It is a single concept that is useful in many situations, even ones that go beyond Haskell programming (e.g., database design). It will also help you understand much better the multitude of related Haskell extensions (associated type synonyms, associated data types, type families). From claus.reinke at talk21.com Sat Apr 11 13:59:31 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Sat Apr 11 13:46:17 2009 Subject: [Haskell-cafe] Re: what does the hidden package error mean? References: <20090411153549.7a0ce264@solaris> Message-ID: <2DE913009D8E41219CD567DF1C7B37CD@cr3lt> >> what a confusing error message, can we change it to say >> "package Foo is missing from the MyPackage.cabal build-depends" >> would be a lot more obvious how to fix it. >> > The problem is that ghc doesn't know that, and shouldn't[1]: All it sees > is a -hide-all-packages on its command line, you can witness it by > calling cabal with the -v flag. Yes, but the user is calling cabal, not ghc - isn't it cabal's task to interpret any error messages from tools it uses internally and to present them (cabal knows that it has passed -hide-all-packages, and is therefore able to interpret ghc's error message; the user doesn't/shouldn't need to know about these internal details)? I once suggested an error-handling wrapper for this purpose http://www.haskell.org/pipermail/cabal-devel/2007-December/001498.html but in the absence of > OTOH, having some cross-compiler, machine-readable format to describe > errors would enable cabal to do some holding of hands, as well as > save ide developers from having to write all these boring parsers. Duncan seemed rather unhappy about the idea of doing a simple regexp-based error-message-pattern-to-cabal-level explanation;-) Mostly, he wanted to focus cabal hacking resources on less ad-hoc tasks, but I still think fleshing this out would make a helpful cabal feature.. Claus ps. there was a hacked-up sketch of such a script at the end of the thread, but it seems to have used the wrong encoding for the mailinglist archives. I think it was the wrapper code attached to this message (which matches for the kind of error message to check if there is a known suggestion for it - the rule set could have been extended whenever issues became faqs). -------------- next part -------------- A non-text attachment was scrubbed... Name: cabal-wrapper.hs Type: application/octet-stream Size: 2462 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090411/65ccf10a/cabal-wrapper.obj From aeyakovenko at gmail.com Sat Apr 11 14:44:10 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Sat Apr 11 14:30:48 2009 Subject: [Haskell-cafe] understanding generics Message-ID: i am trying to understand how data.data works. How would i traverse the subterms of one type and build another type out of them. something like this: > gmapQ (\a -> Right a) (Just "hello") :1:0: Inferred type is less polymorphic than expected Quantified type variable `d' escapes In the first argument of `gmapQ', namely `(\ a -> Right a)' In the expression: gmapQ (\ a -> Right a) (Just "hello") In the definition of `it': it = gmapQ (\ a -> Right a) (Just "hello") Thanks, Anatoly From bugfact at gmail.com Sat Apr 11 18:26:37 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sat Apr 11 18:13:17 2009 Subject: [Haskell-cafe] Bug in Data.Stream? Message-ID: Since I realized my code was always using infinite lists, I replaced it by Data.Stream. However, my code stopped working. The problem is with these functions: scan :: (a -> b -> a) -> a -> Stream b -> Stream ascan f z (Cons x xs) = z <:> scan f (f z x) xs-- | @scan'@ is a strict scan.scan' :: (a -> b -> a) -> a -> Stream b -> Stream ascan' f z (Cons x xs) = z <:> (scan' f $! (f z x)) xs They are too strict I think. My code works again when I add a lazy pattern match: scan f z ~(Cons x xs) = z <:> scan f (f z x) xs scan' f z ~(Cons x xs) = z <:> (scan' f $! (f z x)) xs This is justified since they then behave like scanl on lists. However it seems this package is used a lot, so maybe some code depends on this strictness. What to do? PS: Why does scanl' not exist in Data.List? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090412/a1dbc70d/attachment.htm From bit at mutantlemon.com Sat Apr 11 18:27:14 2009 From: bit at mutantlemon.com (Bit Connor) Date: Sat Apr 11 18:13:52 2009 Subject: [Haskell-cafe] How to get glyph outline from ttf font. In-Reply-To: <49D791E2.2010704@gmail.com> References: <49D791E2.2010704@gmail.com> Message-ID: <6205bd290904111527w5756c634vd9e2991b39673aee@mail.gmail.com> On Sat, Apr 4, 2009 at 6:59 PM, Dmitry V'yal wrote: > to get them out of font? As far as I know, freetype library is capable of > extracting outlines, but is there any haskell binding for it which supports > this functionality? > > ? ? ? ?Here [1] one such lib was mentioned, but it wasn't availible online > that time. Have situation changed today? Hello, I am Bit from the thread that you referenced. I have not yet uploaded the bindings to FreeType that I mentioned. I'll try to upload a darcs repository of what I have. The bindings are incomplete, but there is full support for loading fonts and extracting the outlines. What is missing is FreeType's functions for rendering glyphs to bitmaps. I even made a high level wrapper function to make extraction of glyph outlines easier: outlineDecompose2 :: FT.Outline -> IO OutlineDecomposition data OutlineContourStep = OutlineContourLineTo FT.Vector | OutlineContourConicTo FT.Vector FT.Vector | OutlineContourCubicTo FT.Vector FT.Vector FT.Vector deriving (Eq, Show) data OutlineContour = OutlineContour FT.Vector [OutlineContourStep] deriving (Eq, Show) data OutlineDecomposition = OutlineDecomposition [OutlineContour] deriving (Eq, Show) I also made an example that renders the outlines using OpenGL to verify that everything works. I will apply for an account on code.haskell.org and upload the current state of the bindings into a darcs repository there. P.S. Anyone know how to apply to get an account on code.haskell.org? From reiner.pope at gmail.com Sat Apr 11 21:27:31 2009 From: reiner.pope at gmail.com (Reiner Pope) Date: Sat Apr 11 21:14:09 2009 Subject: [Haskell-cafe] ANN: hmatrix-static: statically-sized linear algebra Message-ID: <4cf038ee0904111827h52cb5a38q84852cac0170ad30@mail.gmail.com> Hi everyone, I am pleased to announce hmatrix-static[1], a thin wrapper over Alberto Ruiz's excellent hmatrix library[2] for linear algebra. The main additions of hmatrix-static over hmatrix are: - vectors and matrices have their length encoded in their types - vectors and matrices may be constructed and destructed using view patterns, affording a clean, safe syntax. hmatrix-static includes statically-sized versions of hmatrix's linear algebra routines, including: - simple arithmetic (addition, multiplication, of matrices and vectors) - matrix inversion and least squares solutions - determinants / rank / condition number - computing eigensystems - factorisations: svd, qr, cholesky, hessenberg, schur, lu - exponents and sqrts of matrices - norms See http://code.haskell.org/hmatrix-static/examples/ for example code. Installation and requirements: Because of the use of type families and view patterns, hmatrix-static requires GHC 6.10 to build. The linear algebra routines are ultimately implemented by BLAS, GSL and LAPACK; see the hmatrix manual [3] for instructions on installing these, prior to installing hmatrix. Once this has been done, hmatrix-static can be installed by $ cabal install hmatrix-static I would be very interested in your feedback, so please try it out. Kind regards, Reiner Pope [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hmatrix-static [2] http://www.hmatrix.googlepages.com/ [3] http://www.hmatrix.googlepages.com/installation From xj2106 at columbia.edu Sat Apr 11 22:18:19 2009 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Sat Apr 11 22:05:05 2009 Subject: [Haskell-cafe] ANN: hmatrix-static: statically-sized linear algebra In-Reply-To: <4cf038ee0904111827h52cb5a38q84852cac0170ad30@mail.gmail.com> (Reiner Pope's message of "Sun, 12 Apr 2009 11:27:31 +1000") References: <4cf038ee0904111827h52cb5a38q84852cac0170ad30@mail.gmail.com> Message-ID: <87ab6m7gyc.fsf@columbia.edu> Reiner Pope writes: > Hi everyone, > > I am pleased to announce hmatrix-static[1], a thin wrapper over > Alberto Ruiz's excellent hmatrix library[2] for linear algebra. > > The main additions of hmatrix-static over hmatrix are: > - vectors and matrices have their length encoded in their types > - vectors and matrices may be constructed and destructed using view > patterns, affording a clean, safe syntax. > > hmatrix-static includes statically-sized versions of hmatrix's linear > algebra routines, including: > - simple arithmetic (addition, multiplication, of matrices and vectors) > - matrix inversion and least squares solutions > - determinants / rank / condition number > - computing eigensystems > - factorisations: svd, qr, cholesky, hessenberg, schur, lu > - exponents and sqrts of matrices > - norms > > See http://code.haskell.org/hmatrix-static/examples/ for example code. > This is quite interesting. I would like to know the performance penalty of such a wrapper. I'll test it by myself when I've got time. But can you give me some idea of how such a wrapper can be optimized by ghc in terms of space and time performance? -- c/* __o/* <\ * (__ */\ < From reiner.pope at gmail.com Sat Apr 11 22:52:42 2009 From: reiner.pope at gmail.com (Reiner Pope) Date: Sat Apr 11 22:39:35 2009 Subject: [Haskell-cafe] ANN: hmatrix-static: statically-sized linear algebra In-Reply-To: <87ab6m7gyc.fsf@columbia.edu> References: <4cf038ee0904111827h52cb5a38q84852cac0170ad30@mail.gmail.com> <87ab6m7gyc.fsf@columbia.edu> Message-ID: <4cf038ee0904111952r238acf8drd4736d484219df5d@mail.gmail.com> There should be essentially no performance penalty in going from hmatrix to hmatrix-static, for most functions. The Vector and Matrix types I define are just newtypes of hmatrix's Vector and Matrix types, so they will have the same runtime representation. There are a few cases where performance could potentially differ, described below. Reflecting and reifying Ints (i.e. converting between types and values): (The ideas for this come from the Implicit Configurations paper[1].) Some Int arguments in hmatrix have been written as types in hmatrix-static, such as the function "constant". hmatrix type: constant :: Element a => a -> Int -> Vector a hmatrix-static type: constant :: (Element a, PositiveT n) => a -> Vector n a The PositiveT constraint is essentially a way of passing the Int parameter as an implicit parameter. To demonstrate this, we use two library functions which allow us to convert from Ints to types with PositiveT constraints, and back: value :: PositiveT n => Proxy n -> Int -- type -> value reifyPositive :: Int -> (forall n. PositiveT n => n -> r) -> r -- value -> type. The use of these functions is nice in some cases, such as "constant" above, because it allows us to pass parameters implicitly. On the other hand, the conversion between types and values imposes an O(log n) cost, where n is the size of the number we are converting. In my experience, this cost has not been significant (although it was previously, when I used a naive O(n) reifyIntegral implementation!). Newtype conversion costs: Occasionally, unwrapping newtypes can actually have a runtime cost. For instance, the hmatrix-static function joinU :: Storable t => [Vector Unknown t] -> Vector Unknown t needs to do a conversion :: [Vector Unknown t] -> [HMatrix.Vector t]. Now, the conversion "unwrap :: Vector Unknown t -> HMatrix.Vector t" is a noop, as it unwraps a newtype. However, to get the list conversion, we need to do "map unwrap", which requires mapping a noop over a list. However, because of map's recursion, GHC may not be able to recognise that "map unwrap" is a noop, and traverse the list anyway, causing a performance loss. However, there aren't many recursive data structures used in hmatrix-static, so this problem mostly doesn't exist. Cheers, Reiner [1] http://okmij.org/ftp/Haskell/types.html#Prepose On Sun, Apr 12, 2009 at 12:18 PM, Xiao-Yong Jin wrote: > Reiner Pope writes: > >> Hi everyone, >> >> I am pleased to announce hmatrix-static[1], a thin wrapper over >> Alberto Ruiz's excellent hmatrix library[2] for linear algebra. >> >> The main additions of hmatrix-static over hmatrix are: >> ?- vectors and matrices have their length encoded in their types >> ?- vectors and matrices may be constructed and destructed using view >> patterns, affording a clean, safe syntax. >> >> hmatrix-static includes statically-sized versions of hmatrix's linear >> algebra routines, including: >> ?- simple arithmetic (addition, multiplication, of matrices and vectors) >> ?- matrix inversion and least squares solutions >> ?- determinants / rank / condition number >> ?- computing eigensystems >> ?- factorisations: svd, qr, cholesky, hessenberg, schur, lu >> ?- exponents and sqrts of matrices >> ?- norms >> >> See http://code.haskell.org/hmatrix-static/examples/ for example code. >> > > This is quite interesting. ?I would like to know the > performance penalty of such a wrapper. ?I'll test it by > myself when I've got time. ?But can you give me some idea of > how such a wrapper can be optimized by ghc in terms of space > and time performance? > -- > ? ?c/* ? ?__o/* > ? ?<\ ? ? * (__ > ? ?*/\ ? ? ?< > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From wss at cs.nott.ac.uk Sun Apr 12 06:25:59 2009 From: wss at cs.nott.ac.uk (Wouter Swierstra) Date: Sun Apr 12 06:12:38 2009 Subject: [Haskell-cafe] Bug in Data.Stream? In-Reply-To: References: Message-ID: Hi Peter, > However, my code stopped working. Could you send me a smallish example of what breaks, so I can get a better idea of what the problem is? I'd be happy to release a new version of Data.Stream that fixes your issues (the upcoming Hackathon might be a good opportunity to work on this). All the best, Wouter From bugfact at gmail.com Sun Apr 12 08:15:16 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Apr 12 08:01:54 2009 Subject: [Haskell-cafe] Bug in Data.Stream? In-Reply-To: References: Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: e.hs Type: application/octet-stream Size: 686 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090412/0bec3c86/e.obj From haskell at list.mightyreason.com Sun Apr 12 08:18:44 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Sun Apr 12 08:05:37 2009 Subject: [Haskell-cafe] Broken beyond repair: Control.Concurrent.SampleVar Message-ID: <49E1DC24.1070506@list.mightyreason.com> Hello all, The SampleVar module in base is not exception safe. I believe that there is no way to fix this module to be exception safe while retaining the current behavior. The problem with the current behavior is that the writeSampleVar pretends to know how many blocked reader threads are waiting on a value. In reality these blocked threads may have been killed. When writeSampleVar sees blocked threads it does a blocking putMVar and then decrements the blocked reader thread count. If any two of the blocked reader threads ever die then eventually you get a blocked writer. I can find no efficient way to retain the current behavior in the presence of exceptions. The logic of the current behavior is that the blocked readers mean that the previously written value should not be discarded, the previous value belongs to the next blocked reader. I propose that SampleVar be either removed, or replaced with a slightly different exception safe version. I propose not considering the previously written value to belong to a blocked reader, and to replace it with the new value. I will open a ticket about this when I get more time. -- Chris From patai_gergely at fastmail.fm Sun Apr 12 09:04:45 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Sun Apr 12 08:51:22 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> <40a414c20904110149o27d508c0u7b7efe0391ffa74d@mail.gmail.com> <1239444601.20625.1310024249@webmail.messagingengine.com> Message-ID: <1239541485.27252.1310127905@webmail.messagingengine.com> I uploaded a new version of the library. The biggest change is that transfer functions and latchers have no delay by default any more. Additionally, this version has a unique and rather shady feature: it inserts delays whenever it encounters a cyclic dependency involving stateful signals. If you don't like this behaviour, you can prevent it by adding the delays yourself wherever you want them. The change is quite spectacular if you compare the current behaviour of the breakout example with the previous one. Gergely -- http://www.fastmail.fm - Same, same, but different... From nowgate at yahoo.com Sun Apr 12 11:38:53 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Apr 12 11:25:30 2009 Subject: [Haskell-cafe] Functions that return functions Message-ID: <678716.3333.qm@web31101.mail.mud.yahoo.com> The following are exercises 5.10, and 5.11 from the Scheme text "Concrete Abstractions" by Max Hailperin, et al. The text at that point is about writing verifiers to check ID numbers such as ISBNs, credit card numbers, UPCs, etc. ====== Exercise 5.10 Write a predicate that takes a number and determines whether the sum of its digits is divisible by 17. Exercise 5.11 Write a procedure make-verifier, which takes f and m as its two arguments and returns a procedure capable of checking a number. The argument f is itself a procedure of course. Here is a particularly simple example of a verifier being made and used. (define check-isbn (make-verifier * 11)) (check-isbn 0262010771) #t The value #t is the "true" value; it indicates that the number is a valid ISBN. As we just saw, for ISBN numbers the divisor is 11 and the function is simply f(i,d(i)) = i * d(i). Other kinds of numbers use slightly more complicated functions, but you will still be able to use make-verifier to make a verifier much more easily than if you had to start from scratch. ======= Here's the Scheme check-verifier function I wrote, followed by my humble attempt at a Haskell function that does the same thing. Below that are some verifier functions created with the Scheme make-verifier. Admittedly, functions that return functions are Lispy, but perhaps there a Haskelly way to accomplish the same thing? Michael =============== ? (define (make-verifier f m) ;f is f(i,d) & m is divisor ? (lambda (n) ??? (let* ((d (digits n)) ?? ??? (i (index (length d))))?? ;(index 3) => (1 2 3) ????? (divides? m (reduce + 0 (map f i d)))))) #f makeVerifier :: (Int -> Int ->? Int) -> Int -> (Int -> Bool) makeVerifier f m = \n -> let d = digits n ???????????????????????????? i = [1..(length d)] ???????????????????????? in \n -> divides m (foldl (+) 0 (map2 f i d)) -- Note: Reduce is just foldl f 0 lst, but map2 is map2 :: (Int -> Int -> Int) -> [Int] -> [Int] -> [Int] map2 f m n = [ f i d | (i,d) <- zip m n] -- And here's my digits function digits :: Int -> [Int] digits 0 = [] digits n = rem n 10 : digits (quot n 10) -- And divides function divides :: Int -> Int -> Bool divides divisor n = 0 == rem n divisor ===== (define check-isbn ;book number ? (make-verifier ?? * ?? 11)) (define check-upc ;universal product code ? (make-verifier ?? (lambda (i d) (if (odd? i) d (* 3 d))) ?? 10)) (define check-cc ;credit card ? (make-verifier ?? (lambda (i d) (if (odd? i) d (if (< d 5) (* 2 d) (+ (* 2 d) 1)))) ?? 10)) (define check-usps ;postal money order ? (make-verifier ?? (lambda (i d) (if (= i 1) (- d) d)) ?? 9)) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090412/7295b4de/attachment.htm From barsoap at web.de Sun Apr 12 12:01:30 2009 From: barsoap at web.de (Achim Schneider) Date: Sun Apr 12 11:48:25 2009 Subject: [Haskell-cafe] Re: Functions that return functions References: <678716.3333.qm@web31101.mail.mud.yahoo.com> Message-ID: <20090412180130.799c3860@solaris> michael rice wrote: > makeVerifier :: (Int -> Int ->__ Int) -> Int -> (Int -> Bool) > > makeVerifier f m = \n -> let d = digits n > > ________________________________________________________ i = [1..(length d)] > > ________________________________________________ in \n -> divides m (foldl (+) 0 (map2 f i d)) > makeVerifier :: (Int -> Int ->__ Int) -> Int -> Int -> Bool makeVerifier f m n = divides m $ foldl (+) 0 $ map2 f i d where d = digits n i = [1..length d] ...looks way more like Haskell[1] to me, and is equivalent (modulo actually trying it out, and the strange fact that the second n is unused). From a scheme perspective, all Haskell functions only take one argument and are made into multiple-arg functions by stacking lambdas, hidden by syntactic sugar. The usual (define (foo a b) ...) would be written "foo (a,b) = ..." in Haskell. In other words, functions are curried by default. You might also want to use foldr or foldl' instead of foldl, there's some differences in behaviour between scheme and Haskell due to laziness: See http://www.haskell.org/haskellwiki/Fold as well as the referenced wiki page. Hope that helps. [1] There's some decent potential for point-free style there, but I don't feel like doing that right now -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From daniel.is.fischer at web.de Sun Apr 12 12:15:25 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Apr 12 12:02:13 2009 Subject: [Haskell-cafe] Functions that return functions In-Reply-To: <678716.3333.qm@web31101.mail.mud.yahoo.com> References: <678716.3333.qm@web31101.mail.mud.yahoo.com> Message-ID: <200904121815.25530.daniel.is.fischer@web.de> Am Sonntag 12 April 2009 17:38:53 schrieb michael rice: > The following are exercises 5.10, and 5.11 from the Scheme text "Concrete > Abstractions" by Max Hailperin, et al. The text at that point is about > writing verifiers to check ID numbers such as ISBNs, credit card numbers, > UPCs, etc. > > ====== > > Exercise 5.10 > Write a predicate that takes a number and determines whether the sum of its > digits is divisible by 17. > > Exercise 5.11 > Write a procedure make-verifier, which takes f and m as its two arguments > and returns a procedure capable of checking a number. The argument f is > itself a procedure of course. Here is a particularly simple example of a > verifier being made and used. > > (define check-isbn (make-verifier * 11)) > > (check-isbn 0262010771) > #t > > The value #t is the "true" value; it indicates that the number is a valid > ISBN. > > As we just saw, for ISBN numbers the divisor is 11 and the function is > simply f(i,d(i)) = i * d(i). Other kinds of numbers use slightly more > complicated functions, but you will still be able to use make-verifier to > make a verifier much more easily than if you had to start from scratch. > > ======= > > Here's the Scheme check-verifier function I wrote, followed by my humble > attempt at a Haskell function that does the same thing. Below that are some > verifier functions created with the Scheme make-verifier. Admittedly, > functions that return functions are Lispy, but perhaps there a Haskelly way > to accomplish the same thing? Functions returning functions are quite natural in Haskell. Since usually functions are written in curried form, a function returng a function corresponds to a function of multiple arguments applied to only some of them. > > Michael > > =============== ? > > > (define (make-verifier f m) ;f is f(i,d) & m is divisor > ? (lambda (n) > ??? (let* ((d (digits n)) > ?? ??? (i (index (length d))))?? ;(index 3) => (1 2 3) > ????? (divides? m (reduce + 0 (map f i d)))))) #f > > makeVerifier :: (Int -> Int ->? Int) -> Int -> (Int -> Bool) > > makeVerifier f m = \n -> let d = digits n > > ???????????????????????????? i = [1..(length d)] > > ???????????????????????? in \n -> divides m (foldl (+) 0 (map2 f i d)) > > makeVerifier f m n = divides m . foldl (+) 0 $ zipWith f [1 .. ] (digits n) just call makeVerifier f m to get your verification function :) If you don't want to name the last argument: makeVerifier f m = divides m . foldl (+) 0 . zipWith f [1 .. ] . digits more point-freeing would be obfuscation. Instead of foldl (+) 0, you could also just write sum. > > -- Note: Reduce is just foldl f 0 lst, but map2 is > map2 :: (Int -> Int -> Int) -> [Int] -> [Int] -> [Int] > map2 f m n = [ f i d | (i,d) <- zip m n] map2 is zipWith, already in the Prelude. > > -- And here's my digits function > digits :: Int -> [Int] > digits 0 = [] > digits n = rem n 10 : digits (quot n 10) Unless you are desperate for speed and sure you deal only with positive numbers (or know that you really want quot and rem), better use div and mod. Those give the commonly expected (unless your expectation has been ruined by the behaviour of % in C, Java...) results. > > -- And divides function > divides :: Int -> Int -> Bool > divides divisor n = 0 == rem n divisor > > ===== > > (define check-isbn ;book number > ? (make-verifier > ?? * > ?? 11)) > > (define check-upc ;universal product code > ? (make-verifier > ?? (lambda (i d) (if (odd? i) d (* 3 d))) > ?? 10)) > > (define check-cc ;credit card > ? (make-verifier > ?? (lambda (i d) (if (odd? i) d (if (< d 5) (* 2 d) (+ (* 2 d) 1)))) > ?? 10)) > > (define check-usps ;postal money order > ? (make-verifier > ?? (lambda (i d) (if (= i 1) (- d) d)) > ?? 9)) From nowgate at yahoo.com Sun Apr 12 13:50:49 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Apr 12 13:37:27 2009 Subject: [Haskell-cafe] Functions that return functions Message-ID: <213813.1423.qm@web31107.mail.mud.yahoo.com> Cool. I expected as much. My ISP seems to be swamped (Easter?) so maybe more later after I look at your remarks. Thanks. Michael --- On Sun, 4/12/09, Daniel Fischer wrote: From: Daniel Fischer Subject: Re: [Haskell-cafe] Functions that return functions To: haskell-cafe@haskell.org Cc: "michael rice" Date: Sunday, April 12, 2009, 12:15 PM Am Sonntag 12 April 2009 17:38:53 schrieb michael rice: > The following are exercises 5.10, and 5.11 from the Scheme text "Concrete > Abstractions" by Max Hailperin, et al. The text at that point is about > writing verifiers to check ID numbers such as ISBNs, credit card numbers, > UPCs, etc. > > ====== > > Exercise 5.10 > Write a predicate that takes a number and determines whether the sum of its > digits is divisible by 17. > > Exercise 5.11 > Write a procedure make-verifier, which takes f and m as its two arguments > and returns a procedure capable of checking a number. The argument f is > itself a procedure of course. Here is a particularly simple example of a > verifier being made and used. > > (define check-isbn (make-verifier * 11)) > > (check-isbn 0262010771) > #t > > The value #t is the "true" value; it indicates that the number is a valid > ISBN. > > As we just saw, for ISBN numbers the divisor is 11 and the function is > simply f(i,d(i)) = i * d(i). Other kinds of numbers use slightly more > complicated functions, but you will still be able to use make-verifier to > make a verifier much more easily than if you had to start from scratch. > > ======= > > Here's the Scheme check-verifier function I wrote, followed by my humble > attempt at a Haskell function that does the same thing. Below that are some > verifier functions created with the Scheme make-verifier. Admittedly, > functions that return functions are Lispy, but perhaps there a Haskelly way > to accomplish the same thing? Functions returning functions are quite natural in Haskell. Since usually functions are written in curried form, a function returng a function corresponds to a function of multiple arguments applied to only some of them. > > Michael > > =============== ? > > > (define (make-verifier f m) ;f is f(i,d) & m is divisor > ? (lambda (n) > ??? (let* ((d (digits n)) > ?? ??? (i (index (length d))))?? ;(index 3) => (1 2 3) > ????? (divides? m (reduce + 0 (map f i d)))))) #f > > makeVerifier :: (Int -> Int ->? Int) -> Int -> (Int -> Bool) > > makeVerifier f m = \n -> let d = digits n > > ???????????????????????????? i = [1..(length d)] > > ???????????????????????? in \n -> divides m (foldl (+) 0 (map2 f i d)) > > makeVerifier f m n = divides m . foldl (+) 0 $ zipWith f [1 .. ] (digits n) just call makeVerifier f m to get your verification function :) If you don't want to name the last argument: makeVerifier f m = divides m . foldl (+) 0 . zipWith f [1 .. ] . digits more point-freeing would be obfuscation. Instead of foldl (+) 0, you could also just write sum. > > -- Note: Reduce is just foldl f 0 lst, but map2 is > map2 :: (Int -> Int -> Int) -> [Int] -> [Int] -> [Int] > map2 f m n = [ f i d | (i,d) <- zip m n] map2 is zipWith, already in the Prelude. > > -- And here's my digits function > digits :: Int -> [Int] > digits 0 = [] > digits n = rem n 10 : digits (quot n 10) Unless you are desperate for speed and sure you deal only with positive numbers (or know that you really want quot and rem), better use div and mod. Those give the commonly expected (unless your expectation has been ruined by the behaviour of % in C, Java...) results. > > -- And divides function > divides :: Int -> Int -> Bool > divides divisor n = 0 == rem n divisor > > ===== > > (define check-isbn ;book number > ? (make-verifier > ?? * > ?? 11)) > > (define check-upc ;universal product code > ? (make-verifier > ?? (lambda (i d) (if (odd? i) d (* 3 d))) > ?? 10)) > > (define check-cc ;credit card > ? (make-verifier > ?? (lambda (i d) (if (odd? i) d (if (< d 5) (* 2 d) (+ (* 2 d) 1)))) > ?? 10)) > > (define check-usps ;postal money order > ? (make-verifier > ?? (lambda (i d) (if (= i 1) (- d) d)) > ?? 9)) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090412/7af054d5/attachment.htm From manlio_perillo at libero.it Sun Apr 12 14:40:39 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Apr 12 14:27:27 2009 Subject: [Haskell-cafe] GHC RTS bug: segmentation fault Message-ID: <49E235A7.2070708@libero.it> Hi. In a program I have experienced a segmentation fault; not only that but also: * tpp.c:63: __pthread_tpp_change_priority: Assertion `new_prio == -1 || (new_prio >= __sched_fifo_min_prio && new_prio <= __sched_fifo_max_prio)' failed. * internal error: removeThreadFromQueue: not found (GHC version 6.8.2 for i386_unknown_linux) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug I have managed to write a program that reproduces the problem: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3714 Compile with: $ghc --make -threaded -O2 main.hs Execute with: $./main +RTS -A128M -s -c -N4 -RTS 5000000 500 This should produce a segmentation fault (or one of the previous errors). I strongly suspect that the cause is an uncaught stack overflow. Executing the code with only 1 threads, there are no more problems. Increasing the thread stack size (-k1M), there are no more problems. If the problem is really an uncaught stack overflow, I'm rather sure that a more simple test can be written, to reproduce the problem. I'm on Linux Debian Etch i386; GHC 6.8.2. Some notes about the program: - when no segmentation fault occurs, the program requires about 1 GB of memory - there is no real parallelization, only 1 CPU is used - the mapReduce implementation is taken from Real World Haskell - the code is adapted from the code I'm using in a project Thanks Manlio Perillo From dons at galois.com Sun Apr 12 14:52:25 2009 From: dons at galois.com (Don Stewart) Date: Sun Apr 12 14:40:07 2009 Subject: [Haskell-cafe] GHC RTS bug: segmentation fault In-Reply-To: <49E235A7.2070708@libero.it> References: <49E235A7.2070708@libero.it> Message-ID: <20090412185225.GA30409@whirlpool.galois.com> The Haskell Cafe isn't the right forum for this. Please file a bug report here: http://hackage.haskell.org/trac/ghc/newticket?type=bug -- Don manlio_perillo: > Hi. > > In a program I have experienced a segmentation fault; > not only that but also: > > * tpp.c:63: __pthread_tpp_change_priority: Assertion `new_prio == -1 || > (new_prio >= __sched_fifo_min_prio && new_prio <= > __sched_fifo_max_prio)' failed. > > * internal error: removeThreadFromQueue: not found > (GHC version 6.8.2 for i386_unknown_linux) > Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug > > > I have managed to write a program that reproduces the problem: > http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3714 > > Compile with: $ghc --make -threaded -O2 main.hs > Execute with: $./main +RTS -A128M -s -c -N4 -RTS 5000000 500 > > This should produce a segmentation fault (or one of the previous errors). > > I strongly suspect that the cause is an uncaught stack overflow. > > Executing the code with only 1 threads, there are no more problems. > Increasing the thread stack size (-k1M), there are no more problems. > > > If the problem is really an uncaught stack overflow, I'm rather sure > that a more simple test can be written, to reproduce the problem. > > I'm on Linux Debian Etch i386; GHC 6.8.2. > > > Some notes about the program: > - when no segmentation fault occurs, the program requires about 1 GB of > memory > - there is no real parallelization, only 1 CPU is used > - the mapReduce implementation is taken from Real World Haskell > - the code is adapted from the code I'm using in a project > > > Thanks Manlio Perillo > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From aeyakovenko at gmail.com Sun Apr 12 15:42:35 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Sun Apr 12 15:29:11 2009 Subject: [Haskell-cafe] understanding typeable Message-ID: i am trying to figure out how typeable works, so i have this data type data Foo = FooC Int deriving (Data, Typeable, Show) So how come this works: > funResultTy (typeOf ((+) 1)) (typeOf 1) Just Integer but this doesnt: > funResultTy (typeOf FooC) (typeOf 1) Nothing FooC is of type t -> u and 1 is of type t so the result should be u? I don't think t and u need to be the same since > funResultTy (typeOf (\a -> a:[1])) (typeOf 1) Just [Integer] works fine. So given a constructor, how come i cant seem to construct a type out of it? From nowgate at yahoo.com Sun Apr 12 16:09:24 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Apr 12 15:56:01 2009 Subject: [Haskell-cafe] Functions that return functions Message-ID: <770838.14800.qm@web31102.mail.mud.yahoo.com> Thanks, guys! Boy, this bunch of complemented partially applied functions gives a whole new meaning to the term "thinking ahead." And the whole shebang is waiting on that input integer to set everything in motion. Pretty clever. To generalize, I changed the function to: makeVerifier :: ((Int,Int) -> Int) -> Int -> (Int -> Bool) makeVerifier f m = divides m . foldl (+) 0 . map f . zip [1 .. ] . digits so, in Haskell let checkIsbn = makeVerifier (\ (i,d) -> i * d) 11 let checkUpc = makeVerifier (\ (i,d) -> if odd i then d else 3*d) 10 let checkCc = makeVerifier (\ (i,d) -> if odd i then d else if d < 5 then 2*d else 2*d+1) 10 let checkUsps = makeVerifier (\ (i,d) -> if i == 1 then -d else d) 9 I think I'm catching on. Michael --- On Sun, 4/12/09, Daniel Fischer wrote: From: Daniel Fischer Subject: Re: [Haskell-cafe] Functions that return functions To: haskell-cafe@haskell.org Cc: "michael rice" Date: Sunday, April 12, 2009, 12:15 PM Am Sonntag 12 April 2009 17:38:53 schrieb michael rice: > The following are exercises 5.10, and 5.11 from the Scheme text "Concrete > Abstractions" by Max Hailperin, et al. The text at that point is about > writing verifiers to check ID numbers such as ISBNs, credit card numbers, > UPCs, etc. > > ====== > > Exercise 5.10 > Write a predicate that takes a number and determines whether the sum of its > digits is divisible by 17. > > Exercise 5.11 > Write a procedure make-verifier, which takes f and m as its two arguments > and returns a procedure capable of checking a number. The argument f is > itself a procedure of course. Here is a particularly simple example of a > verifier being made and used. > > (define check-isbn (make-verifier * 11)) > > (check-isbn 0262010771) > #t > > The value #t is the "true" value; it indicates that the number is a valid > ISBN. > > As we just saw, for ISBN numbers the divisor is 11 and the function is > simply f(i,d(i)) = i * d(i). Other kinds of numbers use slightly more > complicated functions, but you will still be able to use make-verifier to > make a verifier much more easily than if you had to start from scratch. > > ======= > > Here's the Scheme check-verifier function I wrote, followed by my humble > attempt at a Haskell function that does the same thing. Below that are some > verifier functions created with the Scheme make-verifier. Admittedly, > functions that return functions are Lispy, but perhaps there a Haskelly way > to accomplish the same thing? Functions returning functions are quite natural in Haskell. Since usually functions are written in curried form, a function returng a function corresponds to a function of multiple arguments applied to only some of them. > > Michael > > =============== ? > > > (define (make-verifier f m) ;f is f(i,d) & m is divisor > ? (lambda (n) > ??? (let* ((d (digits n)) > ?? ??? (i (index (length d))))?? ;(index 3) => (1 2 3) > ????? (divides? m (reduce + 0 (map f i d)))))) #f > > makeVerifier :: (Int -> Int ->? Int) -> Int -> (Int -> Bool) > > makeVerifier f m = \n -> let d = digits n > > ???????????????????????????? i = [1..(length d)] > > ???????????????????????? in \n -> divides m (foldl (+) 0 (map2 f i d)) > > makeVerifier f m n = divides m . foldl (+) 0 $ zipWith f [1 .. ] (digits n) just call makeVerifier f m to get your verification function :) If you don't want to name the last argument: makeVerifier f m = divides m . foldl (+) 0 . zipWith f [1 .. ] . digits more point-freeing would be obfuscation. Instead of foldl (+) 0, you could also just write sum. > > -- Note: Reduce is just foldl f 0 lst, but map2 is > map2 :: (Int -> Int -> Int) -> [Int] -> [Int] -> [Int] > map2 f m n = [ f i d | (i,d) <- zip m n] map2 is zipWith, already in the Prelude. > > -- And here's my digits function > digits :: Int -> [Int] > digits 0 = [] > digits n = rem n 10 : digits (quot n 10) Unless you are desperate for speed and sure you deal only with positive numbers (or know that you really want quot and rem), better use div and mod. Those give the commonly expected (unless your expectation has been ruined by the behaviour of % in C, Java...) results. > > -- And divides function > divides :: Int -> Int -> Bool > divides divisor n = 0 == rem n divisor > > ===== > > (define check-isbn ;book number > ? (make-verifier > ?? * > ?? 11)) > > (define check-upc ;universal product code > ? (make-verifier > ?? (lambda (i d) (if (odd? i) d (* 3 d))) > ?? 10)) > > (define check-cc ;credit card > ? (make-verifier > ?? (lambda (i d) (if (odd? i) d (if (< d 5) (* 2 d) (+ (* 2 d) 1)))) > ?? 10)) > > (define check-usps ;postal money order > ? (make-verifier > ?? (lambda (i d) (if (= i 1) (- d) d)) > ?? 9)) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090412/70cb79f9/attachment.htm From bugfact at gmail.com Sun Apr 12 17:24:35 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Apr 12 17:11:12 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: <1239541485.27252.1310127905@webmail.messagingengine.com> References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> <40a414c20904110149o27d508c0u7b7efe0391ffa74d@mail.gmail.com> <1239444601.20625.1310024249@webmail.messagingengine.com> <1239541485.27252.1310127905@webmail.messagingengine.com> Message-ID: That's rather amazing. Is this the first FRP lib that does this? 2009/4/12 Patai Gergely > I uploaded a new version of the library. The biggest change is that > transfer functions and latchers have no delay by default any more. > Additionally, this version has a unique and rather shady feature: it > inserts delays whenever it encounters a cyclic dependency involving > stateful signals. If you don't like this behaviour, you can prevent it > by adding the delays yourself wherever you want them. > > The change is quite spectacular if you compare the current behaviour of > the breakout example with the previous one. > > 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/20090412/4cb59eb0/attachment.htm From jake.mcarthur at gmail.com Sun Apr 12 17:45:28 2009 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Sun Apr 12 17:32:06 2009 Subject: [Haskell-cafe] Functions that return functions In-Reply-To: <678716.3333.qm@web31101.mail.mud.yahoo.com> References: <678716.3333.qm@web31101.mail.mud.yahoo.com> Message-ID: <49E260F8.2090005@gmail.com> michael rice wrote: > Admittedly, functions that return functions are Lispy, but perhaps there > a Haskelly way to accomplish the same thing? Actually, I think you will come to find that this way of thinking is more Haskelly than it is Lispy! import Control.Applicative ((<$), (<*>)) import Control.Arrow ((&&&)) import Control.Monad (guard) import Data.List (unfoldr) makeVerifier f m = (==0) . (`mod` m) . sum . zipWith f [1..] . unfoldr nextDigit where nextDigit = (<$) . (snd &&& fst) . (`divMod` 10) <*> guard . (/= 0) - Jake From asviraspossible at gmail.com Sun Apr 12 17:52:07 2009 From: asviraspossible at gmail.com (Victor Nazarov) Date: Sun Apr 12 17:38:41 2009 Subject: [Haskell-cafe] History data structure suggestion Message-ID: Hello, I have a gtk2hs application. I'd like to implement some kind of browser history for it. It should have Back and Forward buttons and a popup menu with radio items.History is a list of strings. There is a current position in this list, so you can move this position back and forward. Some kind of list zipper must be enough to implement this: data History a = Empty | Hist { histBefore :: [a], histCurrent :: a, histAfter :: [a] } back, forward:: History a -> History a back (Hist (b:bs) c as) = Hist bs b (c:as) forward (Hist bs c (a:as)) = Hist (c:bs) a as add :: a -> History a -> History a add x (Hist bs c _) = Hist (c:bs) x [] --- When you add something, future part of history becomes blank. add x Empty = Hist [] x [] start :: History a -> History a start (Hist bs c as) = Hist [] h (hs ++ [c] ++ as) where (h:hs) = reverse bs But there is another requirement. There must be some "points" in the history to store in popup menu. When you select any point the history sould be rolled to this point. For example. data HistPoint a = HP Int current :: History a -> HistPoint a current (Hist bs _ _) = HP (length bs) goTo :: HistPoint a -> History a -> History a goTo (HP n) = foldr1 (.) (replicate n forward) . start I wonder is there more effective, more easy to implement data structure to represent History and HistPoint -- Victor Nazarov -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090413/0e759800/attachment.htm From bugfact at gmail.com Sun Apr 12 18:07:10 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Apr 12 17:53:47 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> <40a414c20904110149o27d508c0u7b7efe0391ffa74d@mail.gmail.com> <1239444601.20625.1310024249@webmail.messagingengine.com> <1239541485.27252.1310127905@webmail.messagingengine.com> Message-ID: seems something is wrong with either your time sampling or performance, because I get rather jerky movement when playing the breakout or the chase demo. did you notice that too? at what rate are you sampling? if you are sampling at a lower rate as the video vsync, you might want to perform interpolation between two "logical frames" as jules bean did in his own reactive planets demo. On Sun, Apr 12, 2009 at 11:24 PM, Peter Verswyvelen wrote: > That's rather amazing. Is this the first FRP lib that does this? > > 2009/4/12 Patai Gergely > > I uploaded a new version of the library. The biggest change is that >> transfer functions and latchers have no delay by default any more. >> Additionally, this version has a unique and rather shady feature: it >> inserts delays whenever it encounters a cyclic dependency involving >> stateful signals. If you don't like this behaviour, you can prevent it >> by adding the delays yourself wherever you want them. >> >> The change is quite spectacular if you compare the current behaviour of >> the breakout example with the previous one. >> >> 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/20090413/45a76a99/attachment.htm From dan.doel at gmail.com Sun Apr 12 18:07:18 2009 From: dan.doel at gmail.com (Dan Doel) Date: Sun Apr 12 17:53:59 2009 Subject: [Haskell-cafe] understanding typeable In-Reply-To: References: Message-ID: <200904121807.19055.dan.doel@gmail.com> On Sunday 12 April 2009 3:42:35 pm Anatoly Yakovenko wrote: > i am trying to figure out how typeable works, so i have this data type > > data Foo = FooC Int > deriving (Data, Typeable, Show) > > So how come this works: > > funResultTy (typeOf ((+) 1)) (typeOf 1) > > Just Integer > > but this doesnt: > > funResultTy (typeOf FooC) (typeOf 1) > > Nothing > > FooC is of type t -> u and 1 is of type t so the result should be u? > I don't think t and u need to be the same since > > > funResultTy (typeOf (\a -> a:[1])) (typeOf 1) > > Just [Integer] > > works fine. So given a constructor, how come i cant seem to construct > a type out of it? Judging from the other types, 'typeOf 1' is defaulting to Integer. FooC, per your declaration, has type 'Int -> Foo'. So, you're probably asking it what happens when you apply an Int -> Foo to an Integer, which would be a type error, and explains the Nothing, I think. -- Dan From patai_gergely at fastmail.fm Sun Apr 12 18:17:14 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Sun Apr 12 18:03:49 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> <40a414c20904110149o27d508c0u7b7efe0391ffa74d@mail.gmail.com> <1239444601.20625.1310024249@webmail.messagingengine.com> <1239541485.27252.1310127905@webmail.messagingengine.com> Message-ID: <1239574634.2936.1310167891@webmail.messagingengine.com> > That's rather amazing. Is this the first FRP lib that does this? I can't be 100% certain, but it is very likely. It's nearly trivial to do with my approach, since every node of the network is a mutable variable, and I can simply mark the nodes I have already visited in the current superstep. It's not exactly the right thing to do from a theoretical standpoint, but as I said, you can avoid it at will, so I figured it won't do much harm in an experimental library. :) -- http://www.fastmail.fm - Access your email from home and the web From patai_gergely at fastmail.fm Sun Apr 12 18:28:09 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Sun Apr 12 18:14:44 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> <40a414c20904110149o27d508c0u7b7efe0391ffa74d@mail.gmail.com> <1239444601.20625.1310024249@webmail.messagingengine.com> <1239541485.27252.1310127905@webmail.messagingengine.com> Message-ID: <1239575289.5053.1310168171@webmail.messagingengine.com> > seems something is wrong with either your time sampling or performance, > because I get rather jerky movement when playing the breakout or the > chase demo. did you notice that too? No, it was always smooth for me. But I only tried it on 64-bit machines and only with ghc-6.10.2. > at what rate are you sampling? if you are sampling at a lower rate as the > video vsync, you might want to perform interpolation between two "logical > frames" as jules bean did in his own reactive planets demo. The breakout example has a zero threadDelay in its main loop, because that apparently causes a break with the length of a scheduler tick, essentially giving an 50 Hz sampling rate. The chase example has no delay added at all, and it goes over 2500 fps for me. -- http://www.fastmail.fm - Accessible with your email software or over the web From lennart at augustsson.net Sun Apr 12 18:59:24 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Sun Apr 12 18:46:02 2009 Subject: [Haskell-cafe] Functions that return functions In-Reply-To: <770838.14800.qm@web31102.mail.mud.yahoo.com> References: <770838.14800.qm@web31102.mail.mud.yahoo.com> Message-ID: You should use an curried function as f instead of a uncurried one. Uncurried functions are rarely used in Haskell. -- Lennart On Sun, Apr 12, 2009 at 10:09 PM, michael rice wrote: > Thanks, guys! > > Boy, this bunch of complemented partially applied functions gives a whole > new meaning to the term "thinking ahead." And the whole shebang is waiting > on that input integer to set everything in motion. Pretty clever. > > > To generalize, I changed the function to: > > makeVerifier :: ((Int,Int) -> Int) -> Int -> (Int -> Bool) > makeVerifier f m = divides m . foldl (+) 0 . map f . zip [1 .. ] . digits > > so, in Haskell > > let checkIsbn = makeVerifier (\ (i,d) -> i * d) 11 > > let checkUpc = makeVerifier (\ (i,d) -> if odd i then d else 3*d) 10 > > let checkCc = makeVerifier (\ (i,d) -> if odd i then d else if d < 5 then > 2*d else 2*d+1) 10 > > let checkUsps = makeVerifier (\ (i,d) -> if i == 1 then -d else d) 9 > > > I think I'm catching on. > > Michael > > > > --- On Sun, 4/12/09, Daniel Fischer wrote: > > From: Daniel Fischer > Subject: Re: [Haskell-cafe] Functions that return functions > To: haskell-cafe@haskell.org > Cc: "michael rice" > Date: Sunday, April 12, 2009, 12:15 PM > > Am Sonntag 12 April 2009 17:38:53 schrieb michael rice: >> The following are exercises 5.10, and 5.11 from the Scheme text "Concrete >> Abstractions" by Max Hailperin, et al. The text at that point is about >> writing verifiers to check ID numbers such as ISBNs, credit card numbers, >> UPCs, etc. >> >> ====== >> >> Exercise 5.10 >> Write a predicate that takes a number and determines whether the sum of >> its >> digits is divisible by 17. >> >> Exercise 5.11 >> Write a procedure make-verifier, which takes f and m as its two arguments >> and returns a procedure capable of checking a number. The argument f is >> itself a procedure of course. Here is a particularly simple example of a >> verifier being made and used. >> >> (define check-isbn (make-verifier * 11)) >> >> (check-isbn 0262010771) >> #t >> >> The value #t is the "true" value; it indicates that the number is a valid >> ISBN. >> >> As we just saw, for ISBN numbers the divisor is 11 and the function is >> simply f(i,d(i)) = i * d(i). Other kinds of numbers use slightly more >> complicated functions, but you will still be able to use make-verifier to >> make a verifier much more easily than if you had to start from scratch. >> >> ======= >> >> Here's the Scheme check-verifier function I wrote, followed by my humble >> attempt at a Haskell function that does the same thing. Below that are >> some >> verifier functions created with the Scheme make-verifier. Admittedly, >> functions that return functions are Lispy, but perhaps there a Haskelly >> way >> to accomplish the same thing? > > Functions returning functions are quite natural in Haskell. > Since usually functions are written in curried form, a function returng a > function > corresponds to a function of multiple arguments applied to only some of > them. > >> >> Michael >> >> =============== >> >> >> (define (make-verifier f m) ;f is f(i,d) & m is divisor >> ? (lambda (n) >> ??? (let* ((d (digits n)) >> ?? ??? (i (index (length d))))?? ;(index 3) => (1 2 3) >> ????? (divides? m (reduce + 0 (map f i d)))))) #f >> >> makeVerifier :: (Int -> Int ->? Int) -> Int -> (Int -> Bool) >> >> makeVerifier f m = \n -> let d = digits n >> >> ???????????????????????????? i = [1..(length d)] >> >> ???????????????????????? in \n -> divides m (foldl (+) 0 (map2 f i d)) >> >> > > makeVerifier f m n = divides m . foldl (+) 0 $ zipWith f [1 .. ] (digits n) > > just call makeVerifier f m to get your verification function :) > > If you don't want to name the last argument: > > makeVerifier f m = divides m . foldl (+) 0 . zipWith f [1 .. ] . digits > > more point-freeing would be obfuscation. > Instead of foldl (+) 0, you could also just write sum. > >> >> -- Note: Reduce is just foldl f 0 lst, but map2 is >> map2 :: (Int -> Int -> Int) -> [Int] -> [Int] -> [Int] >> map2 f m n = [ f i d | (i,d) <- zip m n] > > map2 is zipWith, already in the Prelude. > >> >> -- And here's my digits function >> digits :: Int -> [Int] >> digits 0 = [] >> digits n = rem n 10 : digits (quot n 10) > > Unless you are desperate for speed and sure you deal only with positive > numbers (or know > that you really want quot and rem), better use div and mod. Those give the > commonly > expected (unless your expectation has been ruined by the behaviour of % in > C, Java...) > results. > >> >> -- And divides function >> divides :: Int -> Int -> Bool >> divides divisor n = 0 == rem n divisor >> >> ===== >> >> (define check-isbn ;book number >> ? (make-verifier >> ?? * >> ?? 11)) >> >> (define check-upc ;universal product code >> ? (make-verifier >> ?? (lambda (i d) (if (odd? i) d (* 3 d))) >> ?? 10)) >> >> (define check-cc ;credit card >> ? (make-verifier >> ?? (lambda (i d) (if (odd? i) d (if (< d 5) (* 2 d) (+ (* 2 d) 1)))) >> ?? 10)) >> >> (define check-usps ;postal money order >> ? (make-verifier >> ?? (lambda (i d) (if (= i 1) (- d) d)) >> ?? 9)) > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From nowgate at yahoo.com Sun Apr 12 19:09:22 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Apr 12 18:55:58 2009 Subject: [Haskell-cafe] Functions that return functions Message-ID: <925531.6296.qm@web31106.mail.mud.yahoo.com> Example please. Michael --- On Sun, 4/12/09, Lennart Augustsson wrote: From: Lennart Augustsson Subject: Re: [Haskell-cafe] Functions that return functions To: "michael rice" Cc: haskell-cafe@haskell.org, "Daniel Fischer" Date: Sunday, April 12, 2009, 6:59 PM You should use an curried function as f instead of a uncurried one. Uncurried functions are rarely used in Haskell. ? -- Lennart On Sun, Apr 12, 2009 at 10:09 PM, michael rice wrote: > Thanks, guys! > > Boy, this bunch of complemented partially applied functions gives a whole > new meaning to the term "thinking ahead." And the whole shebang is waiting > on that input integer to set everything in motion. Pretty clever. > > > To generalize, I changed the function to: > > makeVerifier :: ((Int,Int) -> Int) -> Int -> (Int -> Bool) > makeVerifier f m = divides m . foldl (+) 0 . map f . zip [1 .. ] . digits > > so, in Haskell > > let checkIsbn = makeVerifier (\ (i,d) -> i * d) 11 > > let checkUpc = makeVerifier (\ (i,d) -> if odd i then d else 3*d) 10 > > let checkCc = makeVerifier (\ (i,d) -> if odd i then d else if d < 5 then > 2*d else 2*d+1) 10 > > let checkUsps = makeVerifier (\ (i,d) -> if i == 1 then -d else d) 9 > > > I think I'm catching on. > > Michael > > > > --- On Sun, 4/12/09, Daniel Fischer wrote: > > From: Daniel Fischer > Subject: Re: [Haskell-cafe] Functions that return functions > To: haskell-cafe@haskell.org > Cc: "michael rice" > Date: Sunday, April 12, 2009, 12:15 PM > > Am Sonntag 12 April 2009 17:38:53 schrieb michael rice: >> The following are exercises 5.10, and 5.11 from the Scheme text "Concrete >> Abstractions" by Max Hailperin, et al. The text at that point is about >> writing verifiers to check ID numbers such as ISBNs, credit card numbers, >> UPCs, etc. >> >> ====== >> >> Exercise 5.10 >> Write a predicate that takes a number and determines whether the sum of >> its >> digits is divisible by 17. >> >> Exercise 5.11 >> Write a procedure make-verifier, which takes f and m as its two arguments >> and returns a procedure capable of checking a number. The argument f is >> itself a procedure of course. Here is a particularly simple example of a >> verifier being made and used. >> >> (define check-isbn (make-verifier * 11)) >> >> (check-isbn 0262010771) >> #t >> >> The value #t is the "true" value; it indicates that the number is a valid >> ISBN. >> >> As we just saw, for ISBN numbers the divisor is 11 and the function is >> simply f(i,d(i)) = i * d(i). Other kinds of numbers use slightly more >> complicated functions, but you will still be able to use make-verifier to >> make a verifier much more easily than if you had to start from scratch. >> >> ======= >> >> Here's the Scheme check-verifier function I wrote, followed by my humble >> attempt at a Haskell function that does the same thing. Below that are >> some >> verifier functions created with the Scheme make-verifier. Admittedly, >> functions that return functions are Lispy, but perhaps there a Haskelly >> way >> to accomplish the same thing? > > Functions returning functions are quite natural in Haskell. > Since usually functions are written in curried form, a function returng a > function > corresponds to a function of multiple arguments applied to only some of > them. > >> >> Michael >> >> =============== >> >> >> (define (make-verifier f m) ;f is f(i,d) & m is divisor >> ? (lambda (n) >> ??? (let* ((d (digits n)) >> ?? ??? (i (index (length d))))?? ;(index 3) => (1 2 3) >> ????? (divides? m (reduce + 0 (map f i d)))))) #f >> >> makeVerifier :: (Int -> Int ->? Int) -> Int -> (Int -> Bool) >> >> makeVerifier f m = \n -> let d = digits n >> >> ???????????????????????????? i = [1..(length d)] >> >> ???????????????????????? in \n -> divides m (foldl (+) 0 (map2 f i d)) >> >> > > makeVerifier f m n = divides m . foldl (+) 0 $ zipWith f [1 .. ] (digits n) > > just call makeVerifier f m to get your verification function :) > > If you don't want to name the last argument: > > makeVerifier f m = divides m . foldl (+) 0 . zipWith f [1 .. ] . digits > > more point-freeing would be obfuscation. > Instead of foldl (+) 0, you could also just write sum. > >> >> -- Note: Reduce is just foldl f 0 lst, but map2 is >> map2 :: (Int -> Int -> Int) -> [Int] -> [Int] -> [Int] >> map2 f m n = [ f i d | (i,d) <- zip m n] > > map2 is zipWith, already in the Prelude. > >> >> -- And here's my digits function >> digits :: Int -> [Int] >> digits 0 = [] >> digits n = rem n 10 : digits (quot n 10) > > Unless you are desperate for speed and sure you deal only with positive > numbers (or know > that you really want quot and rem), better use div and mod. Those give the > commonly > expected (unless your expectation has been ruined by the behaviour of % in > C, Java...) > results. > >> >> -- And divides function >> divides :: Int -> Int -> Bool >> divides divisor n = 0 == rem n divisor >> >> ===== >> >> (define check-isbn ;book number >> ? (make-verifier >> ?? * >> ?? 11)) >> >> (define check-upc ;universal product code >> ? (make-verifier >> ?? (lambda (i d) (if (odd? i) d (* 3 d))) >> ?? 10)) >> >> (define check-cc ;credit card >> ? (make-verifier >> ?? (lambda (i d) (if (odd? i) d (if (< d 5) (* 2 d) (+ (* 2 d) 1)))) >> ?? 10)) >> >> (define check-usps ;postal money order >> ? (make-verifier >> ?? (lambda (i d) (if (= i 1) (- d) d)) >> ?? 9)) > > > > _______________________________________________ > 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/20090412/2aca7c2c/attachment.htm From nowgate at yahoo.com Sun Apr 12 19:11:28 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Apr 12 18:58:04 2009 Subject: [Haskell-cafe] Functions that return functions Message-ID: <842606.56787.qm@web31108.mail.mud.yahoo.com> You're getting ahead of me again. Michael --- On Sun, 4/12/09, Jake McArthur wrote: From: Jake McArthur Subject: Re: [Haskell-cafe] Functions that return functions To: "michael rice" Cc: haskell-cafe@haskell.org Date: Sunday, April 12, 2009, 5:45 PM michael rice wrote: > Admittedly, functions that return functions are Lispy, but perhaps there a Haskelly way to accomplish the same thing? Actually, I think you will come to find that this way of thinking is more Haskelly than it is Lispy! ? ? import Control.Applicative ((<$), (<*>)) ? ? import Control.Arrow? ? ???((&&&)) ? ? import Control.Monad? ? ???(guard) ? ? import Data.List? ? ? ? ???(unfoldr) ? ? makeVerifier f m = (==0) . (`mod` m) . sum . zipWith f [1..] . unfoldr nextDigit ? ? ? ? where nextDigit = (<$) . (snd &&& fst) . (`divMod` 10) <*> guard . (/= 0) - Jake -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090412/062157e6/attachment.htm From daniel.is.fischer at web.de Sun Apr 12 19:20:37 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Apr 12 19:07:24 2009 Subject: [Haskell-cafe] Functions that return functions In-Reply-To: <925531.6296.qm@web31106.mail.mud.yahoo.com> References: <925531.6296.qm@web31106.mail.mud.yahoo.com> Message-ID: <200904130120.38349.daniel.is.fischer@web.de> Am Montag 13 April 2009 01:09:22 schrieb michael rice: > Example please. > > Michael > Curried: f :: a -> b -> c amenable to partial application. Uncurried: g :: (a,b) -> c not easy to apply partially. The Prelude contains curry :: ((a,b) -> c) -> (a -> b -> c) uncurry :: (a -> b -> c) -> ((a,b) -> c) to convert if needed. From jake.mcarthur at gmail.com Sun Apr 12 19:27:51 2009 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Sun Apr 12 19:14:29 2009 Subject: [Haskell-cafe] Functions that return functions In-Reply-To: <842606.56787.qm@web31108.mail.mud.yahoo.com> References: <842606.56787.qm@web31108.mail.mud.yahoo.com> Message-ID: <49E278F7.1010606@gmail.com> michael rice wrote: > You're getting ahead of me again. I'm sorry. I didn't expect you to understand the whole thing. Rather, I'm just showing what is possible. Notice that there is no lambda abstraction in the function implementation. The entire thing is constructed with combinators, functions that take other functions as arguments. I was trying to emphasize that it is very Haskelly to accept and return functions as happily as normal values. - Jake From gue.schmidt at web.de Sun Apr 12 20:00:01 2009 From: gue.schmidt at web.de (=?UTF-8?B?R8O8wp9udGhlciBTY2htaWR0?=) Date: Sun Apr 12 19:46:51 2009 Subject: [Haskell-cafe] Re: History data structure suggestion In-Reply-To: References: Message-ID: Hi Victor, actually I think this might be the application domain of the "Zipper" data structure. I suggest you just google for it, but there's also a post in this list, a week or so back. G?nther From nowgate at yahoo.com Sun Apr 12 20:57:52 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Apr 12 20:44:29 2009 Subject: [Haskell-cafe] Functions that return functions Message-ID: <130203.61191.qm@web31101.mail.mud.yahoo.com> No sweat. My comment was meant humorously. I just forgot the emoticon. Any way you look at it, Haskell is very impressive, and I've just scratched the surface. Michael --- On Sun, 4/12/09, Jake McArthur wrote: From: Jake McArthur Subject: Re: [Haskell-cafe] Functions that return functions To: "michael rice" Cc: haskell-cafe@haskell.org Date: Sunday, April 12, 2009, 7:27 PM michael rice wrote: > You're getting ahead of me again. I'm sorry. I didn't expect you to understand the whole thing. Rather, I'm just showing what is possible. Notice that there is no lambda abstraction in the function implementation. The entire thing is constructed with combinators, functions that take other functions as arguments. I was trying to emphasize that it is very Haskelly to accept and return functions as happily as normal values. - Jake -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090412/9edf40c4/attachment.htm From nowgate at yahoo.com Sun Apr 12 21:09:38 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Apr 12 20:56:14 2009 Subject: [Haskell-cafe] Functions that return functions Message-ID: <651016.54442.qm@web31108.mail.mud.yahoo.com> My question was meant in the context of the makeVerifier function, which is passed a lambda expression. It's my understanding that Haskell lambda expressions can have only a single parameter, which is why I changed the function parameter to a pair, (i,d). How would it be done otherwise? Michael --- On Sun, 4/12/09, Daniel Fischer wrote: From: Daniel Fischer Subject: Re: [Haskell-cafe] Functions that return functions To: "michael rice" Cc: haskell-cafe@haskell.org Date: Sunday, April 12, 2009, 7:20 PM Am Montag 13 April 2009 01:09:22 schrieb michael rice: > Example please. > > Michael > Curried: f :: a -> b -> c amenable to partial application. Uncurried: g :: (a,b) -> c not easy to apply partially. The Prelude contains curry :: ((a,b) -> c) -> (a -> b -> c) uncurry :: (a -> b -> c) -> ((a,b) -> c) to convert if needed. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090412/073b1c7a/attachment.htm From rmm-haskell at z.odi.ac Sun Apr 12 21:23:34 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Sun Apr 12 21:10:15 2009 Subject: [Haskell-cafe] Functions that return functions In-Reply-To: <651016.54442.qm@web31108.mail.mud.yahoo.com> References: <651016.54442.qm@web31108.mail.mud.yahoo.com> Message-ID: <189F000B-87F2-426C-9FE8-7111133F0466@z.odi.ac> Under the covers of syntax they only have one parameter, but you can write curried lambdas or functions easily: \ a b -> a + b which is equivalent to \ a -> \ b -> a + b and also equivalent to the "normal" function syntax f a b = a + b or f a = \ b -> a + b -Ross On Apr 12, 2009, at 9:09 PM, michael rice wrote: > My question was meant in the context of the makeVerifier function, > which is passed a lambda expression. It's my understanding that > Haskell lambda expressions can have only a single parameter, which > is why I changed the function parameter to a pair, (i,d). > > How would it be done otherwise? > > Michael > > > --- On Sun, 4/12/09, Daniel Fischer wrote: > > From: Daniel Fischer > Subject: Re: [Haskell-cafe] Functions that return functions > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Sunday, April 12, 2009, 7:20 PM > > Am Montag 13 April 2009 01:09:22 schrieb michael rice: > > Example please. > > > > Michael > > > > Curried: > > f :: a -> b -> c > > amenable to partial application. > > Uncurried: > > g :: (a,b) -> c > > not easy to apply partially. > > The Prelude contains > > curry :: ((a,b) -> c) -> (a -> b -> c) > > uncurry :: (a -> b -> c) -> ((a,b) -> c) > > to convert if needed. > > _______________________________________________ > 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/20090412/b91f720a/attachment-0001.htm From iavor.diatchki at gmail.com Sun Apr 12 23:02:21 2009 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Sun Apr 12 22:48:55 2009 Subject: [Haskell-cafe] Cabal and WinHugs Message-ID: <5ab17e790904122002q1a0e141dw361cf795e903e08@mail.gmail.com> Hello, What is the preferred way to install a cabal package so that it works with winhugs? When I tried "cabal install --user --hugs" I got an error that it could not find "hugsffi". I managed to get things working by manually downloading the package, and extracting the appropriate source directories to the "packages" folder of winhugs (i.e., basically skipping cabal) but this is kind of clunky. So to summarize, here are my two questions: 1. Am I doing something wrong, or does "cabal" not support WinHugs?, and 2. Does WinHugs have a user specific "packages" folder (so that each user can have their own set of packages)? Thanks for any info that anyone might have, Iavor From nowgate at yahoo.com Sun Apr 12 23:50:38 2009 From: nowgate at yahoo.com (michael rice) Date: Sun Apr 12 23:37:13 2009 Subject: [Haskell-cafe] Functions that return functions Message-ID: <523976.52102.qm@web31103.mail.mud.yahoo.com> I'm not sure what you're trying to tell me, so let's try a specific case. Here's the makeVerifier function that expects its function f to have a single arg, a pair (i,d): makeVerifier :: ((Int,Int) -> Int) -> Int -> (Int -> Bool) makeVerifier f m = divides m . foldl (+) 0 . map f . zip [1 .. ] . digits And usage: let checkCc = makeVerifier (\ (i d) -> if odd i then d else if d < 5 then 2*d else 2*d + 1) 10 And here's the old makeVerifier function that expects its function f to have two integer arguments, i & d: makeVerifier :: (Int -> Int -> Int) -> Int -> (Int -> Bool) makeVerifier f m = divides m . foldl (+) 0 . zipWith f [1 .. ] . digits And usage: let checkCc = makeVerifier (\ ....??? <== Complete this? ) 10 Michael --- On Sun, 4/12/09, Ross Mellgren wrote: From: Ross Mellgren Subject: Re: [Haskell-cafe] Functions that return functions To: "michael rice" Cc: "Daniel Fischer" , haskell-cafe@haskell.org Date: Sunday, April 12, 2009, 9:23 PM Under the covers of syntax they only have one parameter, but you can write curried lambdas or functions easily: \ a b -> a + b which is equivalent to \ a -> \ b -> a + b and also equivalent to the "normal" function syntax f a b = a + b or f a = \ b -> a + b -Ross On Apr 12, 2009, at 9:09 PM, michael rice wrote: My question was meant in the context of the makeVerifier function, which is passed a lambda expression. It's my understanding that Haskell lambda expressions can have only a single parameter, which is why I changed the function parameter to a pair, (i,d). How would it be done otherwise? Michael --- On Sun, 4/12/09, Daniel Fischer wrote: From: Daniel Fischer Subject: Re: [Haskell-cafe] Functions that return functions To: "michael rice" Cc: haskell-cafe@haskell.org Date: Sunday, April 12, 2009, 7:20 PM Am Montag 13 April 2009 01:09:22 schrieb michael rice: > Example please. > > Michael > Curried: f :: a -> b -> c amenable to partial application. Uncurried: g :: (a,b) -> c not easy to apply partially. The Prelude contains curry :: ((a,b) -> c) -> (a -> b -> c) uncurry :: (a -> b -> c) -> ((a,b) -> c) to convert if needed. _______________________________________________ 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/20090412/79b00816/attachment.htm From rmm-haskell at z.odi.ac Sun Apr 12 23:59:21 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Sun Apr 12 23:46:01 2009 Subject: [Haskell-cafe] Functions that return functions In-Reply-To: <523976.52102.qm@web31103.mail.mud.yahoo.com> References: <523976.52102.qm@web31103.mail.mud.yahoo.com> Message-ID: On Apr 12, 2009, at 11:50 PM, michael rice wrote: > I'm not sure what you're trying to tell me, so let's try a specific > case. > > > Here's the makeVerifier function that expects its function f to have > a single arg, a pair (i,d): > > makeVerifier :: ((Int,Int) -> Int) -> Int -> (Int -> Bool) > makeVerifier f m = divides m . foldl (+) 0 . map f . zip [1 .. ] . > digits > > And usage: > let checkCc = makeVerifier (\ (i d) -> if odd i then d else if d < 5 > then 2*d else 2*d + 1) 10 > This looks like it has a typo -- did you mean \ (i, d) -> rather than \ (i d) -> ? > > > And here's the old makeVerifier function that expects its function f > to have two integer arguments, i & d: > > makeVerifier :: (Int -> Int -> Int) -> Int -> (Int -> Bool) > makeVerifier f m = divides m . foldl (+) 0 . zipWith f [1 .. ] . > digits > > And usage: > let checkCc = makeVerifier (\ .... <== Complete this ) 10 > let checkCc = makeVerifier (\ i d -> if odd i then d else if d < 5 then 2*d else 2*d + 1) 10 though I find it a bit nicer to expand it a bit for clarity: checkCc :: Int -> Bool checkCc = makeVerifier f 10 where f i d | odd i = d | d < 5 = 2*d | otherwise = 2*d + 1 -Ross > > --- On Sun, 4/12/09, Ross Mellgren wrote: > > From: Ross Mellgren > Subject: Re: [Haskell-cafe] Functions that return functions > To: "michael rice" > Cc: "Daniel Fischer" , haskell-cafe@haskell.org > Date: Sunday, April 12, 2009, 9:23 PM > > Under the covers of syntax they only have one parameter, but you can > write curried lambdas or functions easily: > > \ a b -> a + b > > which is equivalent to > > \ a -> \ b -> a + b > > and also equivalent to the "normal" function syntax > > f a b = a + b > > or > > f a = \ b -> a + b > > -Ross > > On Apr 12, 2009, at 9:09 PM, michael rice wrote: > >> My question was meant in the context of the makeVerifier function, >> which is passed a lambda expression. It's my understanding that >> Haskell lambda expressions can have only a single parameter, which >> is why I changed the function parameter to a pair, (i,d). >> >> How would it be done otherwise? >> >> Michael >> >> >> --- On Sun, 4/12/09, Daniel Fischer wrote: >> >> From: Daniel Fischer >> Subject: Re: [Haskell-cafe] Functions that return functions >> To: "michael rice" >> Cc: haskell-cafe@haskell.org >> Date: Sunday, April 12, 2009, 7:20 PM >> >> Am Montag 13 April 2009 01:09:22 schrieb michael rice: >> > Example please. >> > >> > Michael >> > >> >> Curried: >> >> f :: a -> b -> c >> >> amenable to partial application. >> >> Uncurried: >> >> g :: (a,b) -> c >> >> not easy to apply partially. >> >> The Prelude contains >> >> curry :: ((a,b) -> c) -> (a -> b -> c) >> >> uncurry :: (a -> b -> c) -> ((a,b) -> c) >> >> to convert if needed. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > From aeyakovenko at gmail.com Mon Apr 13 01:18:40 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Mon Apr 13 01:05:15 2009 Subject: [Haskell-cafe] understanding typeable In-Reply-To: <200904121807.19055.dan.doel@gmail.com> References: <200904121807.19055.dan.doel@gmail.com> Message-ID: ah, Int vs Integer, i didn't see that at all. Thats kind of weird, i thought 1 could be either one. This works > funResultTy (typeOf FooC) (typeOf (1::Int)) Just ParseG.Foo but > funResultTy (typeOf FooC) (typeOf $ fromIntegral 1) Nothing doesn't so, how do i actually do something with this? is there a way that i can pull out the computation? Like there is a -> TypeRep, is there a TypeRep -> a function? cast doesn't seem to do what i want > let a::Foo = fromJust $ cast $ fromJust $ funResultTy (typeOf FooC) (typeOf (1::Int)) > a *** Exception: Maybe.fromJust: Nothing From aeyakovenko at gmail.com Mon Apr 13 01:37:10 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Mon Apr 13 01:23:44 2009 Subject: [Haskell-cafe] understanding typeable In-Reply-To: References: <200904121807.19055.dan.doel@gmail.com> Message-ID: any idea why this is True data Foo = FooC Int ? ? ? ? | BarC Int ? ? ? ? deriving (Data, Typeable, Show) > fromJust $ funResultTy (typeOf FooC) (typeOf (1::Int)) Loading package syb ... linking ... done. ParseG.Foo > typeRepTyCon $ fromJust $ funResultTy (typeOf FooC) (typeOf (1::Int)) ParseG.Foo > let a = typeRepTyCon $ fromJust $ funResultTy (typeOf FooC) (typeOf (1::Int)) > :t a a :: TyCon > typeRepTyCon $ typeOf $ BarC 2 ParseG.Foo > let b = typeRepTyCon $ typeOf $ BarC 2 > a == b True I thought that TyCon can distinguish constructors. ?it seems no different then a typerep From dan.doel at gmail.com Mon Apr 13 01:48:36 2009 From: dan.doel at gmail.com (Dan Doel) Date: Mon Apr 13 01:35:14 2009 Subject: [Haskell-cafe] understanding typeable In-Reply-To: References: <200904121807.19055.dan.doel@gmail.com> Message-ID: <200904130148.37112.dan.doel@gmail.com> On Monday 13 April 2009 1:18:40 am Anatoly Yakovenko wrote: > ah, Int vs Integer, i didn't see that at all. Thats kind of weird, i > thought 1 could be either one. It can, but typeOf has to pick one instance to use. The default for Num is Integer, so that's what it chooses without any annotation making it choose otherwise. If there weren't any defaulting rules, you'd just get an error saying that "typeOf 1" is ambiguous, and you'd need to add an annotation to say which instance you want. > This works > > > funResultTy (typeOf FooC) (typeOf (1::Int)) Yep, this tells it to use Int explicitly. > but > > > funResultTy (typeOf FooC) (typeOf $ fromIntegral 1) > > Nothing > > doesn't fromIntegral 1 is the same as a literal 1, so this is not surprising. > so, how do i actually do something with this? is there a way that i > can pull out the computation? Like there is a -> TypeRep, is there a > TypeRep -> a function? cast doesn't seem to do what i want > > > let a::Foo = fromJust $ cast $ fromJust $ funResultTy (typeOf FooC) > > (typeOf (1::Int)) a > > *** Exception: Maybe.fromJust: Nothing I think you want Dynamics. TypeRep is just that, a value representing a type. There's no value of that type in it. The only reason typeOf takes a value of the given type is to specify what type you want a TypeRep of. So both: typeOf (undefined :: Int) typeOf (1 :: Int) return the same thing, a TypeRep representing Int. A Dynamic, on the other hand, can be looked at as a pair of a value and a TypeRep tag specifying its type, which sounds like what you want. Look at Data.Dynamic. As for your other question, a TyCon is a representation of a type constructor, not a data constructor. FooC and BarC are data constructors. Type constructors are more like Maybe, which take types to types. Although that TyCon type seems to take Foo (which would normally not be considered a type constructor proper, I think) as a type constructor too. Anyhow, both 'FooC 1' and 'BarC 2' have type Foo, so their type is Foo, and the 'constructor' part is Foo, according to the library. However, for instance: typeOf (Just ()) ==> Maybe () typeRepTyCon (typeOf (Just ())) ==> Maybe typeOf (Nothing :: Maybe ()) ==> Maybe () typeRepTyCon (typeOf (Nothing :: Maybe ())) ==> Maybe -- Dan From dave at zednenem.com Mon Apr 13 01:54:39 2009 From: dave at zednenem.com (David Menendez) Date: Mon Apr 13 01:41:13 2009 Subject: [Haskell-cafe] understanding typeable In-Reply-To: References: <200904121807.19055.dan.doel@gmail.com> Message-ID: <49a77b7a0904122254o5359a141i24c5e54c4e79010f@mail.gmail.com> On Mon, Apr 13, 2009 at 1:37 AM, Anatoly Yakovenko wrote: > any idea why this is True > > data Foo = FooC Int > ? ? ? ? | BarC Int > ? ? ? ? deriving (Data, Typeable, Show) > >> fromJust $ funResultTy (typeOf FooC) (typeOf (1::Int)) > Loading package syb ... linking ... done. > ParseG.Foo >> typeRepTyCon $ fromJust $ funResultTy (typeOf FooC) (typeOf (1::Int)) > ParseG.Foo >> let a = typeRepTyCon $ fromJust $ funResultTy (typeOf FooC) (typeOf (1::Int)) >> :t a > a :: TyCon >> typeRepTyCon $ typeOf $ BarC 2 > ParseG.Foo >> let b = typeRepTyCon $ typeOf $ BarC 2 >> a == b > True They're both representing Foo. > I thought that TyCon can distinguish constructors. ?it seems no > different then a typerep TyCon distinguishes *type* constructors, like [] and Maybe and (->). FooC and BarC are *data* constructors. Typeable can't distinguish them directly. You either need to cast to Foo and then pattern-match, or use Data. -- Dave Menendez From jac_legend_sas at hotmail.com Mon Apr 13 02:23:26 2009 From: jac_legend_sas at hotmail.com (Melanie_Green) Date: Mon Apr 13 02:10:00 2009 Subject: [Haskell-cafe] Best text editor Message-ID: <23018470.post@talk.nabble.com> Hi I would like to follow the crowd and find out what text editor everyone uses for haskell on windows. Thx in advanced -- View this message in context: http://www.nabble.com/Best-text-editor-tp23018470p23018470.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From mpm at alumni.caltech.edu Mon Apr 13 02:55:39 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Mon Apr 13 02:42:34 2009 Subject: [Haskell-cafe] Best text editor In-Reply-To: <23018470.post@talk.nabble.com> References: <23018470.post@talk.nabble.com> Message-ID: <49E2E1EB.3040100@alumni.caltech.edu> I'm a beginner, but I'll chime in and say I use Emacs with haskell-mode. It's auto-indentation is a bit complex in behavior which is unappealing (I feel like I never know what it's going to do when I hit tab), but I would be curious what someone with more experience feels about that. -Mike Melanie_Green wrote: > Hi I would like to follow the crowd and find out what text editor everyone > uses for haskell on windows. > > Thx in advanced From dav.vire+haskell at gmail.com Mon Apr 13 03:32:30 2009 From: dav.vire+haskell at gmail.com (david48) Date: Mon Apr 13 03:19:06 2009 Subject: [Haskell-cafe] Best text editor In-Reply-To: <49E2E1EB.3040100@alumni.caltech.edu> References: <23018470.post@talk.nabble.com> <49E2E1EB.3040100@alumni.caltech.edu> Message-ID: <4c88418c0904130032h7973da2cr6ff2e8d22c560247@mail.gmail.com> Notepad++ has syntax highlighting for Haskell. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090413/d386ffe5/attachment.htm From bugfact at gmail.com Mon Apr 13 03:45:05 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Apr 13 03:31:39 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: <1239575289.5053.1310168171@webmail.messagingengine.com> References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> <40a414c20904110149o27d508c0u7b7efe0391ffa74d@mail.gmail.com> <1239444601.20625.1310024249@webmail.messagingengine.com> <1239541485.27252.1310127905@webmail.messagingengine.com> <1239575289.5053.1310168171@webmail.messagingengine.com> Message-ID: Interesting. I'm testing it on Window though. You're using Linux? Maybe the scheduling is different. 2009/4/13 Patai Gergely > > seems something is wrong with either your time sampling or performance, > > because I get rather jerky movement when playing the breakout or the > > chase demo. did you notice that too? > No, it was always smooth for me. But I only tried it on 64-bit machines > and only with ghc-6.10.2. > > > at what rate are you sampling? if you are sampling at a lower rate as the > > video vsync, you might want to perform interpolation between two "logical > > frames" as jules bean did in his own reactive planets demo. > The breakout example has a zero threadDelay in its main loop, because > that apparently causes a break with the length of a scheduler tick, > essentially giving an 50 Hz sampling rate. The chase example has no > delay added at all, and it goes over 2500 fps for me. > > -- > http://www.fastmail.fm - Accessible with your email software > or over the web > > _______________________________________________ > 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/20090413/a0f7042c/attachment.htm From byorgey at seas.upenn.edu Mon Apr 13 03:51:35 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Mon Apr 13 03:38:12 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 113 - April 13, 2009 Message-ID: <20090413075135.GA14126@seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090413 Issue 113 - April 13, 2009 --------------------------------------------------------------------------- Welcome to issue 113 of HWN, a newsletter covering developments in the [1]Haskell community. Announcements xmobar-0.9.2. Andrea Rossato [2]announced the release of [3]xmobar-0.9.2, which features a fix for a longstanding resource leakage bug, new nested color definitions, and more. CFP Haskell Symposium 2009. Stephanie Weirich [4]reminded everyone that there are only 4 weeks until the submission deadline for the [5]2009 Haskell Symposium! hmatrix-static: statically-sized linear algebra. Reiner Pope [6]announced the release of [7]hmatrix-static, a thin wrapper over Alberto Ruiz's excellent [8]hmatrix library for linear algebra. The main additions of hmatrix-static over hmatrix are that vectors and matrices have their length encoded in their types, and vectors and matrices may be constructed and destructed using view patterns, affording a clean, safe syntax. haskellmode for Vim now at projects.haskell.org. Claus Reinke [9]announced that the Haskell mode plugins for Vim have just completed their move to their [10]new home, and took the opportunity to reiterate what they can do (quite a lot, it seems), and mention that some screencasts are available. MSem replacement for QSem. ChrisK [11]announced [12]MSem, a proposed replacement module for Control.Concurrent.QSem. Hac5 is almost upon us!. Sean Leather [13]reminded everyone that in six days, tens of crazy/obsessed, type-safe, functional programmers will be converging on Utrecht to commence execution of the [14]5th Haskell Hackathon, from April 17-19, 2009 in Utrecht, The Netherlands! The local organizing team welcomes you all and looks forward to all of the new developments that come out of everyone's undying quest to write more and better code. Yogurt-0.4. Martijn van Steenbergen [15]announced version 0.4 of [16]Yogurt, a functional MUD client. Version 0.4 makes Yogurt available as a standalone executable that is able to dynamically load and reload Yogurt scripts. Elerea, another FRP library. Patai Gergely [17]announced the release of [18]Elerea, aka "Eventless reactivity", a minimalistic FRP implementation that comes with a convenient applicative interface, supports recursive definition of signals and signals fed from outside by IO actions, plays nice with resources, and is the result of some furious hacking. There are working examples to show off the current capabilities of the library, found in the separate [19]elerea-examples package. tree-monad 0.2. Sebastian Fischer [20]announced version 0.2 of the [21]tree-monad package, which provides instances of MonadPlus that represent the search space of non- deterministic computations as a tree. Version 0.2 implements an optimized CPS version of the tree. HCard -- A library for implementing card-like structures.. Joe Fredette [22]announced the release of [23]HCard, a library which supports a card-like data structures and uses associated types to provide shuffling, dealing, and other facilities. It's general enough to support many different types of playing cards; it currently comes with the common "French Deck" (4-suit, 13 card deck that is very common in the US) implemented and an example cribbage scoring application. SVGFonts 0.1. Tillmann Vogt [24]announced his first Haskell library, [25]SVGFonts 0.1, which parses the relatively unknown SVG Font format to produce outlines of characters. The big advantage of this format is that it is XML, which means easy parsing and manipulating. network-bytestring 0.1.2. Johan Tibell [26]announced a new release of [27]network-bytestring, a Haskell library for fast socket I/O using ByteStrings. New in this release is support for scatter/gather I/O (also known as vectored I/O). Scatter/gather I/O provides more efficient I/O by using one system call to send several separate pieces of data and by avoiding unnecessary copying. Jobs Lecturer in Computer Science, University of Leicester. Roy L. Crole [28]announced an opening for a lectureship at the University of Leicester. The successful candidate will have a strong or promising research record in computer science, with a background in formal foundations (either algorithms and complexity, or semantics of programming or modelling languages), and will be able to contribute to undergraduate and postgraduate teaching and supervision in software engineering. Blog noise [29]Haskell news from the [30]blogosphere. * Mark Wassell: [31]Edge Detection in Haskell. * Sean Leather: [32]Latest on the incremental fold and attributes. * Sean Leather: [33]Haskell mode for Vim on a Mac. * Sean Leather: [34]Incremental attributes. * >>> Human Constraints: [35]Haskell Type Hackery. * LHC Team: [36]A new beginning.. * London Haskell Users Group: [37]Don Stewart: Engineering Large Projects in Haskell: A Decade of Haskell at Galois. * Ulisses Costa: [38]More Hylomorphisms in Haskell. * Ulisses Costa: [39]Anamorphisms in Haskell. * London Haskell Users Group: [40]Next Meeting: Don Stewart from Galois. * LHC Team: [41]Hello world!. * mightybyte: [42]Adding Authentication to the Blog App. * Leon Smith: [43]Polynomial multiplication. * Joe Fredette: [44]Card games, scorekeeping, and ... Associated Datatypes?. * mightybyte: [45]Basic Happstack Blog App. * mightybyte: [46]A Standalone Auth Framework for Happstack. * Mads Lindstr?m: [47]Introducing WxGeneric. * happstack.com: [48]2 new projects that use Happstack. * >>> Brant Carlson: [49]Lightning Modeling in Haskell. * Leon Smith: [50]Lloyd Allison's Corecursive Queues. About the Haskell Weekly News New editions are posted to [51]the Haskell mailing list as well as to [52]the Haskell Sequence and [53]Planet Haskell. [54]RSS is also available, and headlines appear on [55]haskell.org. To help create new editions of this newsletter, please see the information on [56]how to contribute. Send stories to byorgey at cis dot upenn dot edu. The darcs repository is available at darcs get [57]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://article.gmane.org/gmane.comp.lang.haskell.general/17080 3. http://code.haskell.org/~arossato/xmobar/ 4. http://article.gmane.org/gmane.comp.lang.haskell.general/17072 5. http://haskell.org/haskell-symposium/2009/ 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56772 7. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hmatrix-static 8. http://www.hmatrix.googlepages.com/ 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56495 10. http://projects.haskell.org/haskellmode-vim/ 11. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56761 12. http://haskell.org/haskellwiki/SafeConcurrent 13. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56758 14. http://haskell.org/haskellwiki/Hac5 15. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56747 16. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Yogurt 17. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56731 18. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/elerea 19. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/elerea-examples 20. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56639 21. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/tree%2Dmonad 22. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56573 23. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HCard 24. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56444 25. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SVGFonts 26. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56374 27. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/network-bytestring 28. http://article.gmane.org/gmane.comp.lang.haskell.general/17066 29. http://planet.haskell.org/ 30. http://haskell.org/haskellwiki/Blog_articles 31. http://www.poundstone.org/blog/?p=137 32. http://feedproxy.google.com/~r/splonderzoek/~3/KWqNCgsK1ww/latest-on-incremental-fold-and.html 33. http://feedproxy.google.com/~r/splonderzoek/~3/0QNaK4byWhg/haskell-mode-for-vim-on-mac.html 34. http://feedproxy.google.com/~r/splonderzoek/~3/4B0bHoeTCeQ/incremental-attributes.html 35. http://blog.human-constraints.com/?p=49 36. http://lhc-compiler.blogspot.com/2009/04/new-beginning.html 37. http://www.londonhug.net/2009/04/10/don-stewart-engineering-large-projects-in-haskell-a-decade-of-haskell-at-galois/ 38. http://ulissesaraujo.wordpress.com/2009/04/09/more-hylomorphisms-in-haskell/ 39. http://ulissesaraujo.wordpress.com/2009/04/08/anamorphisms-in-haskell/ 40. http://www.londonhug.net/2009/04/09/next-meeting-don-stewart-from-galois/ 41. http://lhc-compiler.blogspot.com/2009/04/hello-world.html 42. http://softwaresimply.blogspot.com/2009/04/adding-authentication-to-blog-app.html 43. http://blog.melding-monads.com/2009/04/07/polynomial-multiplication/ 44. http://lowlymath.net/2009/card-games-scorekeeping-and-associated-datatypes/ 45. http://softwaresimply.blogspot.com/2009/04/basic-happstack-blog-app.html 46. http://softwaresimply.blogspot.com/2009/04/standalone-auth-framework-for-happstack.html 47. http://lindstroem.wordpress.com/2008/05/03/introducing-wxgeneric/ 48. http://blog.happstack.com/2009/04/06/2-new-projects-that-use-happstack/ 49. http://bayern.stanford.edu/~brant/lightning/ 50. http://blog.melding-monads.com/2009/03/09/lloyd-allisons-corecursive-queues/ 51. http://www.haskell.org/mailman/listinfo/haskell 52. http://sequence.complete.org/ 53. http://planet.haskell.org/ 54. http://sequence.complete.org/node/feed 55. http://haskell.org/ 56. http://haskell.org/haskellwiki/HWN 57. http://code.haskell.org/~byorgey/code/hwn/ From patai_gergely at fastmail.fm Mon Apr 13 04:31:53 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Mon Apr 13 04:18:26 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> <40a414c20904110149o27d508c0u7b7efe0391ffa74d@mail.gmail.com> <1239444601.20625.1310024249@webmail.messagingengine.com> <1239541485.27252.1310127905@webmail.messagingengine.com> <1239575289.5053.1310168171@webmail.messagingengine.com> Message-ID: <1239611513.20776.1310211739@webmail.messagingengine.com> > Interesting. I'm testing it on Window though. You're using Linux? Maybe > the scheduling is different. I'm on Linux, yes. But I've no idea what could cause such a difference, since both the library and the examples are single threaded. GLFW might also be the culprit, since that's where the frame duration comes from. It might be a good idea to print the value of t in the readInput function. Under Linux, it's pretty uniform for both programs and always equal to the reciprocal of the frame rate as expected. -- http://www.fastmail.fm - Faster than the air-speed velocity of an unladen european swallow From barsoap at web.de Mon Apr 13 05:50:15 2009 From: barsoap at web.de (Achim Schneider) Date: Mon Apr 13 05:37:05 2009 Subject: [Haskell-cafe] Re: Best text editor References: <23018470.post@talk.nabble.com> Message-ID: <20090413115015.047d3ea0@solaris> Melanie_Green wrote: > > Hi I would like to follow the crowd and find out what text editor > everyone uses for haskell on windows. > I'd use vim, even on windoze. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From jason.dusek at gmail.com Mon Apr 13 06:15:15 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Mon Apr 13 06:01:47 2009 Subject: [Haskell-cafe] Control.Concurrent export/import weirdness Message-ID: <42784f260904130315n25a7a3cfu9626a6bd966a6846@mail.gmail.com> Why is this function exported then imported? foreign export ccall forkOS_entry :: StablePtr (IO ()) -> IO () foreign import ccall "forkOS_entry" forkOS_entry_reimported :: StablePtr (IO ()) -> IO () forkOS_entry :: StablePtr (IO ()) -> IO () forkOS_entry stableAction = do action <- deRefStablePtr stableAction action -- Jason Dusek From fmartini at gmail.com Mon Apr 13 06:23:54 2009 From: fmartini at gmail.com (Felix Martini) Date: Mon Apr 13 06:10:29 2009 Subject: [Haskell-cafe] Best text editor In-Reply-To: <23018470.post@talk.nabble.com> References: <23018470.post@talk.nabble.com> Message-ID: <6c0416190904130323i45ebcafajeeaecc7a18b92722@mail.gmail.com> I use Intype for Haskell editing on Windows. Although Intype is still in development it has the potential to be one of the best editors for Windows. A bundle with syntax highlighting and Textmate-like snippets is available at http://bitbucket.org/felixmar/haskell-itbundle/. From bertram.felgenhauer at googlemail.com Mon Apr 13 07:32:20 2009 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Mon Apr 13 07:18:59 2009 Subject: [Haskell-cafe] Control.Concurrent export/import weirdness In-Reply-To: <42784f260904130315n25a7a3cfu9626a6bd966a6846@mail.gmail.com> References: <42784f260904130315n25a7a3cfu9626a6bd966a6846@mail.gmail.com> Message-ID: <49e322c7.1ade660a.5126.ffff941e@mx.google.com> Jason Dusek wrote: > Why is this function exported then imported? It causes the RTS to create a bound thread to run code in: (reordering the code slightly) > foreign import ccall "forkOS_entry" forkOS_entry_reimported > :: StablePtr (IO ()) -> IO () This is a safe call, so it suspends the currently running RTS thread, and then calls the forkOS_entry foreign function. > foreign export ccall forkOS_entry > :: StablePtr (IO ()) -> IO () The generated stub creates a new, bound RTS thread, and then calls the forkOS_entry Haskell function. > forkOS_entry :: StablePtr (IO ()) -> IO () > forkOS_entry stableAction = do > action <- deRefStablePtr stableAction > action And this, finally, runs an action in the new thread. See also section 3.4 of the "Extending the Haskell FFI with Concurrency" paper, http://research.microsoft.com/en-us/um/people/simonpj/Papers/conc-ffi/index.htm (http://tinyurl.com/cocex7) HTH, Bertram From nowgate at yahoo.com Mon Apr 13 09:01:37 2009 From: nowgate at yahoo.com (michael rice) Date: Mon Apr 13 08:48:12 2009 Subject: [Haskell-cafe] Functions that return functions Message-ID: <136510.38293.qm@web31106.mail.mud.yahoo.com> Thank you. That's just what I needed. And your second version shows that I needn't use an anonymous function (lambda expression) at all, something that got lost in translation from Lisp to Haskell. First, yes, there was a typo. I couldn't find the original message so had to rewrite. Second, the reason I switched to a tuple argument in the first place is that I read somewhere, "Real World Haskell" I think, that Haskell anonymous functions could only have a single parameter (\ n -> ...). Maybe I didn't read far enough or Haskell has since been updated. Then, one poster didn't like the use of a (tuple) argument because it couldn't be partially applied, but the whole point of anonymous functions is for one off stuff, like these verifiers, where one doesn't want to create a named function that's used just once. In any case, the function we pass to makeVerifier, whether anonymous or in the WHERE of your clarified version, is a function that only appears in the definition of a particular verifier, so what difference can it possibly make whether or not it can be partially applied? That's what I can't get my head around. Thanks again. Michael --- On Sun, 4/12/09, Ross Mellgren wrote: From: Ross Mellgren Subject: Re: [Haskell-cafe] Functions that return functions To: "michael rice" Cc: "Daniel Fischer" , haskell-cafe@haskell.org Date: Sunday, April 12, 2009, 11:59 PM On Apr 12, 2009, at 11:50 PM, michael rice wrote: > I'm not sure what you're trying to tell me, so let's try a specific case. > > > Here's the makeVerifier function that expects its function f to have a single arg, a pair (i,d): > > makeVerifier :: ((Int,Int) -> Int) -> Int -> (Int -> Bool) > makeVerifier f m = divides m . foldl (+) 0 . map f . zip [1 .. ] . digits > > And usage: > let checkCc = makeVerifier (\ (i d) -> if odd i then d else if d < 5 then 2*d else 2*d + 1) 10 > This looks like it has a typo -- did you mean \ (i, d) -> rather than \ (i d) -> ? > > > And here's the old makeVerifier function that expects its function f to have two integer arguments, i & d: > > makeVerifier :: (Int -> Int -> Int) -> Int -> (Int -> Bool) > makeVerifier f m = divides m . foldl (+) 0 . zipWith f [1 .. ] . digits > > And usage: > let checkCc = makeVerifier (\ ....? ? <== Complete this? ) 10 > let checkCc = makeVerifier (\ i d -> if odd i then d else if d < 5 then 2*d else 2*d + 1) 10 though I find it a bit nicer to expand it a bit for clarity: checkCc :: Int -> Bool checkCc = makeVerifier f 10 ? ? where ? ? ? ? f i d | odd i? ???= d ? ? ? ? ? ? ? | d < 5? ???= 2*d ? ? ? ? ? ? ? | otherwise = 2*d + 1 -Ross > > --- On Sun, 4/12/09, Ross Mellgren wrote: > > From: Ross Mellgren > Subject: Re: [Haskell-cafe] Functions that return functions > To: "michael rice" > Cc: "Daniel Fischer" , haskell-cafe@haskell.org > Date: Sunday, April 12, 2009, 9:23 PM > > Under the covers of syntax they only have one parameter, but you can write curried lambdas or functions easily: > > \ a b -> a + b > > which is equivalent to > > \ a -> \ b -> a + b > > and also equivalent to the "normal" function syntax > > f a b = a + b > > or > > f a = \ b -> a + b > > -Ross > > On Apr 12, 2009, at 9:09 PM, michael rice wrote: > >> My question was meant in the context of the makeVerifier function, which is passed a lambda expression. It's my understanding that Haskell lambda expressions can have only a single parameter, which is why I changed the function parameter to a pair, (i,d). >> >> How would it be done otherwise? >> >> Michael >> >> >> --- On Sun, 4/12/09, Daniel Fischer wrote: >> >> From: Daniel Fischer >> Subject: Re: [Haskell-cafe] Functions that return functions >> To: "michael rice" >> Cc: haskell-cafe@haskell.org >> Date: Sunday, April 12, 2009, 7:20 PM >> >> Am Montag 13 April 2009 01:09:22 schrieb michael rice: >> > Example please. >> > >> > Michael >> > >> >> Curried: >> >> f :: a -> b -> c >> >> amenable to partial application. >> >> Uncurried: >> >> g :: (a,b) -> c >> >> not easy to apply partially. >> >> The Prelude contains >> >> curry :: ((a,b) -> c) -> (a -> b -> c) >> >> uncurry :: (a -> b -> c) -> ((a,b) -> c) >> >> to convert if needed. >> >> _______________________________________________ >> 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/20090413/cec1076f/attachment.htm From manlio_perillo at libero.it Mon Apr 13 09:10:45 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Mon Apr 13 08:57:26 2009 Subject: [Haskell-cafe] binary package: memory problem decoding an IntMap In-Reply-To: <1238965788-sup-7561@ausone.local> References: <49D48B5A.4080406@libero.it> <49D91795.1060808@libero.it> <1238965788-sup-7561@ausone.local> Message-ID: <49E339D5.3090908@libero.it> Nicolas Pouillard ha scritto: > Excerpts from Manlio Perillo's message of Sun Apr 05 22:41:57 +0200 2009: >> Manlio Perillo ha scritto: >>> Hi. >>> > [...] >> >> I have a: >> [(Word16, UArr (Word32 :*:* Word8))] >> >> This eats more memory than it should, since tuples are decoded lazily. > > Why not switch to [(Word16 :*: UArr (Word32 :*: Word8))] then? > I finally made some tests today, and I can confirm that using :*: reduces memory usage. Thanks Manlio From Chad.Scherrer at pnl.gov Mon Apr 13 09:52:04 2009 From: Chad.Scherrer at pnl.gov (Scherrer, Chad) Date: Mon Apr 13 09:38:40 2009 Subject: [Haskell-cafe] Re: Sequence differences In-Reply-To: References: <559390.3896.qm@web31105.mail.mud.yahoo.com> <49DEE210.2030603@gmail.com> Message-ID: <64F04C9398A52E43B208634452B7D00B0407B4BF@EMAIL01.pnl.gov> henning thielmann writes: > movingWindow n xs = > take (length xs - n +1) $ map (take n) $ tails xs > > or more efficient using utility-ht package: > > movingWindow n xs = > Data.List.Match.take (drop (n-1) xs) $ > map (take n) $ tails xs Oh, very nice. I was a little frustrated writing the recursion explicitly. I guess you could also write movingWindow n xs = zipWith const (map (take n) $ tails xs) $ drop (n-1) xs Hmm, maybe this is obvious, if Data.List.Match.take == zipWith (flip const) (I've never used it) > I'm not sure. You are safer and more efficient when you > restrict to pairs. > Since I often need the function, I defined: > > http://hackage.haskell.org/packages/archive/utility-ht/0.0.4/d oc/html/Data-List-HT.html#v%3AmapAdjacent > > Then > diff = mapAdjacent subtract Yes, I agree if you know you'll be using a binary operator, and not a more general n-ary function. Chad From barsoap at web.de Mon Apr 13 10:05:20 2009 From: barsoap at web.de (Achim Schneider) Date: Mon Apr 13 09:52:14 2009 Subject: [Haskell-cafe] Re: Functions that return functions References: <136510.38293.qm@web31106.mail.mud.yahoo.com> Message-ID: <20090413160520.2a485399@solaris> michael rice wrote: > In any case, the function we pass to makeVerifier, whether anonymous > or in the WHERE of your clarified version, is a function that only > appears in the definition of a particular verifier, so what > difference can it possibly make whether or not it can be partially > applied? That's what I can't get my head around. > In your case, none, except wasted keystrokes... after all, if you want to, you can also partially apply tuples. Semantically speaking, adding a tuple introduces another _|_... you can pass both undefined as well as (undefined,undefined) to an uncurried function, but I doubt that's going to bother you. Tuples are commonly used as return type though. The usual style is to write functions curried and use uncurry if you need to pass it tuples for some reason, like in zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] zipWith f = (map (uncurry f) .) . zip -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From lennart at augustsson.net Mon Apr 13 10:33:30 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Mon Apr 13 10:20:09 2009 Subject: [Haskell-cafe] Functions that return functions In-Reply-To: <925531.6296.qm@web31106.mail.mud.yahoo.com> References: <925531.6296.qm@web31106.mail.mud.yahoo.com> Message-ID: All I meant was a small change: > makeVerifier :: (Int -> Int -> Int) -> Int -> (Int -> Bool) > makeVerifier f m = divides m . foldl (+) 0 . zipWith f [1 .. ] . digits which make some things simpler: > let checkIsbn = makeVerifier (*) 11 BTW, here's a sneaky way do define digits: > digits :: Int -> [Int] > digits = map digitToInt . show So then you'd have: > makeVerifier :: (Int -> Int -> Int) -> Int -> Int -> Bool > makeVerifier f m = (== 0) . (`mod` m) . sum . zipWith f [1 .. ] . map digitToInt . show Which looks pretty nice, I think. -- Lennart On Mon, Apr 13, 2009 at 1:09 AM, michael rice wrote: > Example please. > > Michael > > --- On Sun, 4/12/09, Lennart Augustsson wrote: > > From: Lennart Augustsson > Subject: Re: [Haskell-cafe] Functions that return functions > To: "michael rice" > Cc: haskell-cafe@haskell.org, "Daniel Fischer" > Date: Sunday, April 12, 2009, 6:59 PM > > You should use an curried function as f instead of a uncurried one. > Uncurried functions are rarely used in Haskell. > > ? -- Lennart > > On Sun, Apr 12, 2009 at 10:09 PM, michael rice wrote: >> Thanks, guys! >> >> Boy, this bunch of complemented partially applied functions gives a whole >> new meaning to the term "thinking ahead." And the whole shebang is waiting >> on that input integer to set everything in motion. Pretty clever. >> >> >> To generalize, I changed the function to: >> >> makeVerifier :: ((Int,Int) -> Int) -> Int -> (Int -> Bool) >> makeVerifier f m = divides m . foldl (+) 0 . map f . zip [1 .. ] . digits >> >> so, in Haskell >> >> let checkIsbn = makeVerifier (\ (i,d) -> i * d) 11 >> >> let checkUpc = makeVerifier (\ (i,d) -> if odd i then d else 3*d) 10 >> >> let checkCc = makeVerifier (\ (i,d) -> if odd i then d else if d < 5 then >> 2*d else 2*d+1) 10 >> >> let checkUsps = makeVerifier (\ (i,d) -> if i == 1 then -d else d) 9 >> >> >> I think I'm catching on. >> >> Michael >> >> >> >> --- On Sun, 4/12/09, Daniel Fischer wrote: >> >> From: Daniel Fischer >> Subject: Re: [Haskell-cafe] Functions that return functions >> To: haskell-cafe@haskell.org >> Cc: "michael rice" >> Date: Sunday, April 12, 2009, 12:15 PM >> >> Am Sonntag 12 April 2009 17:38:53 schrieb michael rice: >>> The following are exercises 5.10, and 5.11 from the Scheme text "Concrete >>> Abstractions" by Max Hailperin, et al. The text at that point is about >>> writing verifiers to check ID numbers such as ISBNs, credit card numbers, >>> UPCs, etc. >>> >>> ====== >>> >>> Exercise 5.10 >>> Write a predicate that takes a number and determines whether the sum of >>> its >>> digits is divisible by 17. >>> >>> Exercise 5.11 >>> Write a procedure make-verifier, which takes f and m as its two arguments >>> and returns a procedure capable of checking a number. The argument f is >>> itself a procedure of course. Here is a particularly simple example of a >>> verifier being made and used. >>> >>> (define check-isbn (make-verifier * 11)) >>> >>> (check-isbn 0262010771) >>> #t >>> >>> The value #t is the "true" value; it indicates that the number is a valid >>> ISBN. >>> >>> As we just saw, for ISBN numbers the divisor is 11 and the function is >>> simply f(i,d(i)) = i * d(i). Other kinds of numbers use slightly more >>> complicated functions, but you will still be able to use make-verifier to >>> make a verifier much more easily than if you had to start from scratch. >>> >>> ======= >>> >>> Here's the Scheme check-verifier function I wrote, followed by my humble >>> attempt at a Haskell function that does the same thing. Below that are >>> some >>> verifier functions created with the Scheme make-verifier. Admittedly, >>> functions that return functions are Lispy, but perhaps there a Haskelly >>> way >>> to accomplish the same thing? >> >> Functions returning functions are quite natural in Haskell. >> Since usually functions are written in curried form, a function returng a >> function >> corresponds to a function of multiple arguments applied to only some of >> them. >> >>> >>> Michael >>> >>> =============== >>> >>> >>> (define (make-verifier f m) ;f is f(i,d) & m is divisor >>> ? (lambda (n) >>> ??? (let* ((d (digits n)) >>> ?? ??? (i (index (length d))))?? ;(index 3) => (1 2 3) >>> ????? (divides? m (reduce + 0 (map f i d)))))) #f >>> >>> makeVerifier :: (Int -> Int ->? Int) -> Int -> (Int -> Bool) >>> >>> makeVerifier f m = \n -> let d = digits n >>> >>> ???????????????????????????? i = [1..(length d)] >>> >>> ???????????????????????? in \n -> divides m (foldl (+) 0 (map2 f i d)) >>> >>> >> >> makeVerifier f m n = divides m . foldl (+) 0 $ zipWith f [1 .. ] (digits >> n) >> >> just call makeVerifier f m to get your verification function :) >> >> If you don't want to name the last argument: >> >> makeVerifier f m = divides m . foldl (+) 0 . zipWith f [1 .. ] . digits >> >> more point-freeing would be obfuscation. >> Instead of foldl (+) 0, you could also just write sum. >> >>> >>> -- Note: Reduce is just foldl f 0 lst, but map2 is >>> map2 :: (Int -> Int -> Int) -> [Int] -> [Int] -> [Int] >>> map2 f m n = [ f i d | (i,d) <- zip m n] >> >> map2 is zipWith, already in the Prelude. >> >>> >>> -- And here's my digits function >>> digits :: Int -> [Int] >>> digits 0 = [] >>> digits n = rem n 10 : digits (quot n 10) >> >> Unless you are desperate for speed and sure you deal only with positive >> numbers (or know >> that you really want quot and rem), better use div and mod. Those give the >> commonly >> expected (unless your expectation has been ruined by the behaviour of % in >> C, Java...) >> results. >> >>> >>> -- And divides function >>> divides :: Int -> Int -> Bool >>> divides divisor n = 0 == rem n divisor >>> >>> ===== >>> >>> (define check-isbn ;book number >>> ? (make-verifier >>> ?? * >>> ?? 11)) >>> >>> (define check-upc ;universal product code >>> ? (make-verifier >>> ?? (lambda (i d) (if (odd? i) d (* 3 d))) >>> ?? 10)) >>> >>> (define check-cc ;credit card >>> ? (make-verifier >>> ?? (lambda (i d) (if (odd? i) d (if (< d 5) (* 2 d) (+ (* 2 d) 1)))) >>> ?? 10)) >>> >>> (define check-usps ;postal money order >>> ? (make-verifier >>> ?? (lambda (i d) (if (= i 1) (- d) d)) >>> ?? 9)) >> >> >> >> _______________________________________________ >> 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 smithsnorth at gmail.com Mon Apr 13 11:42:33 2009 From: smithsnorth at gmail.com (John Smith) Date: Mon Apr 13 11:29:08 2009 Subject: [Haskell-cafe] Types and hashes of hashes, trouble for a Java-programmer... Message-ID: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> Hi, a java-programmer running into trouble while trying to learn Haskell. I try to make a hash containing hashes but can not getting a value out of the innermost hash - I keep running into type-trouble where IO and Maybe monad is getting mixed? My attempt: removeMaybeHash x = case x of Just ref -> ref Nothing -> HashTable.new (==) (\key -> key) test = do h <- HashTable.new (==) (\key -> key) h1 <- HashTable.new (==) (\key -> key) HashTable.insert h 3 h1 HashTable.insert h1 1 1000 maybeOuterHash <- HashTable.lookup h 3 res <- removeMaybe (removeMaybeHash maybeOuterHash) 1000 return res Any clues? In java this would be as simple as (pseudocode): h.lookup(3).lookup(1000) Cheers, Pedro -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090413/97ed79be/attachment.htm From john at n-brain.net Mon Apr 13 12:02:59 2009 From: john at n-brain.net (John A. De Goes) Date: Mon Apr 13 11:49:36 2009 Subject: [Haskell-cafe] Types and hashes of hashes, trouble for a Java-programmer... In-Reply-To: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> References: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> Message-ID: <2E9EFF53-A1BD-4AB0-A13A-8E96A786C0D6@n-brain.net> Why not use an ordered pair as the key? Regards, John A. De Goes N-BRAIN, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Apr 13, 2009, at 9:42 AM, John Smith wrote: > Hi, a java-programmer running into trouble while trying to learn > Haskell. > > I try to make a hash containing hashes but can not getting a value > out of the innermost hash - I keep running into type-trouble where > IO and Maybe monad is getting mixed? > > My attempt: > > > removeMaybeHash x = > case x of > Just ref -> ref > Nothing -> HashTable.new (==) (\key -> key) > > > test = do > h <- HashTable.new (==) (\key -> key) > h1 <- HashTable.new (==) (\key -> key) > HashTable.insert h 3 h1 > HashTable.insert h1 1 1000 > maybeOuterHash <- HashTable.lookup h 3 > res <- removeMaybe (removeMaybeHash maybeOuterHash) 1000 > return res > > Any clues? > > In java this would be as simple as (pseudocode): > h.lookup(3).lookup(1000) > > Cheers, > > Pedro > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From nowgate at yahoo.com Mon Apr 13 12:23:24 2009 From: nowgate at yahoo.com (michael rice) Date: Mon Apr 13 12:09:59 2009 Subject: [Haskell-cafe] Functions that return functions Message-ID: <829911.39566.qm@web31103.mail.mud.yahoo.com> All I meant was a small change: > makeVerifier :: (Int -> Int -> Int) -> Int -> (Int -> Bool) > makeVerifier f m = divides m . foldl (+) 0 . zipWith f [1 .. ] . digits which make some things simpler: > let checkIsbn = makeVerifier (*) 11?? <== I liked this syntax better too, and it's what I had ??????????????????????????????????????????? originally. BTW, here's a sneaky way do define digits: > digits :: Int -> [Int] > digits = map digitToInt . show??????? <== I haven't gotten to "show" yet. When needed? When not? So then you'd have: > makeVerifier :: (Int -> Int -> Int) -> Int -> Int -> Bool > makeVerifier f m = (== 0) . (`mod` m) . sum . zipWith f [1 .. ] . map digitToInt . show Which looks pretty nice, I think. ? -- Lennart ======== Very good. I've yet to replace the 'foldl' with 'sum', but will. Eliminating the 'divides' function is also a nice touch. With Haskell it seems there's always a way to make one's code ever briefer, and using built-ins is probably much faster than anything I'd cook up, but it takes time to learn these short-cuts. Thanks for your comments. Michael --- On Mon, 4/13/09, Lennart Augustsson wrote: From: Lennart Augustsson Subject: Re: [Haskell-cafe] Functions that return functions To: "michael rice" Cc: haskell-cafe@haskell.org Date: Monday, April 13, 2009, 10:33 AM All I meant was a small change: > makeVerifier :: (Int -> Int -> Int) -> Int -> (Int -> Bool) > makeVerifier f m = divides m . foldl (+) 0 . zipWith f [1 .. ] . digits which make some things simpler: > let checkIsbn = makeVerifier (*) 11 BTW, here's a sneaky way do define digits: > digits :: Int -> [Int] > digits = map digitToInt . show So then you'd have: > makeVerifier :: (Int -> Int -> Int) -> Int -> Int -> Bool > makeVerifier f m = (== 0) . (`mod` m) . sum . zipWith f [1 .. ] . map digitToInt . show Which looks pretty nice, I think. ? -- Lennart On Mon, Apr 13, 2009 at 1:09 AM, michael rice wrote: > Example please. > > Michael > > --- On Sun, 4/12/09, Lennart Augustsson wrote: > > From: Lennart Augustsson > Subject: Re: [Haskell-cafe] Functions that return functions > To: "michael rice" > Cc: haskell-cafe@haskell.org, "Daniel Fischer" > Date: Sunday, April 12, 2009, 6:59 PM > > You should use an curried function as f instead of a uncurried one. > Uncurried functions are rarely used in Haskell. > > ? -- Lennart > > On Sun, Apr 12, 2009 at 10:09 PM, michael rice wrote: >> Thanks, guys! >> >> Boy, this bunch of complemented partially applied functions gives a whole >> new meaning to the term "thinking ahead." And the whole shebang is waiting >> on that input integer to set everything in motion. Pretty clever. >> >> >> To generalize, I changed the function to: >> >> makeVerifier :: ((Int,Int) -> Int) -> Int -> (Int -> Bool) >> makeVerifier f m = divides m . foldl (+) 0 . map f . zip [1 .. ] . digits >> >> so, in Haskell >> >> let checkIsbn = makeVerifier (\ (i,d) -> i * d) 11 >> >> let checkUpc = makeVerifier (\ (i,d) -> if odd i then d else 3*d) 10 >> >> let checkCc = makeVerifier (\ (i,d) -> if odd i then d else if d < 5 then >> 2*d else 2*d+1) 10 >> >> let checkUsps = makeVerifier (\ (i,d) -> if i == 1 then -d else d) 9 >> >> >> I think I'm catching on. >> >> Michael >> >> >> >> --- On Sun, 4/12/09, Daniel Fischer wrote: >> >> From: Daniel Fischer >> Subject: Re: [Haskell-cafe] Functions that return functions >> To: haskell-cafe@haskell.org >> Cc: "michael rice" >> Date: Sunday, April 12, 2009, 12:15 PM >> >> Am Sonntag 12 April 2009 17:38:53 schrieb michael rice: >>> The following are exercises 5.10, and 5.11 from the Scheme text "Concrete >>> Abstractions" by Max Hailperin, et al. The text at that point is about >>> writing verifiers to check ID numbers such as ISBNs, credit card numbers, >>> UPCs, etc. >>> >>> ====== >>> >>> Exercise 5.10 >>> Write a predicate that takes a number and determines whether the sum of >>> its >>> digits is divisible by 17. >>> >>> Exercise 5.11 >>> Write a procedure make-verifier, which takes f and m as its two arguments >>> and returns a procedure capable of checking a number. The argument f is >>> itself a procedure of course. Here is a particularly simple example of a >>> verifier being made and used. >>> >>> (define check-isbn (make-verifier * 11)) >>> >>> (check-isbn 0262010771) >>> #t >>> >>> The value #t is the "true" value; it indicates that the number is a valid >>> ISBN. >>> >>> As we just saw, for ISBN numbers the divisor is 11 and the function is >>> simply f(i,d(i)) = i * d(i). Other kinds of numbers use slightly more >>> complicated functions, but you will still be able to use make-verifier to >>> make a verifier much more easily than if you had to start from scratch. >>> >>> ======= >>> >>> Here's the Scheme check-verifier function I wrote, followed by my humble >>> attempt at a Haskell function that does the same thing. Below that are >>> some >>> verifier functions created with the Scheme make-verifier. Admittedly, >>> functions that return functions are Lispy, but perhaps there a Haskelly >>> way >>> to accomplish the same thing? >> >> Functions returning functions are quite natural in Haskell. >> Since usually functions are written in curried form, a function returng a >> function >> corresponds to a function of multiple arguments applied to only some of >> them. >> >>> >>> Michael >>> >>> =============== >>> >>> >>> (define (make-verifier f m) ;f is f(i,d) & m is divisor >>> ? (lambda (n) >>> ??? (let* ((d (digits n)) >>> ?? ??? (i (index (length d))))?? ;(index 3) => (1 2 3) >>> ????? (divides? m (reduce + 0 (map f i d)))))) #f >>> >>> makeVerifier :: (Int -> Int ->? Int) -> Int -> (Int -> Bool) >>> >>> makeVerifier f m = \n -> let d = digits n >>> >>> ???????????????????????????? i = [1..(length d)] >>> >>> ???????????????????????? in \n -> divides m (foldl (+) 0 (map2 f i d)) >>> >>> >> >> makeVerifier f m n = divides m . foldl (+) 0 $ zipWith f [1 .. ] (digits >> n) >> >> just call makeVerifier f m to get your verification function :) >> >> If you don't want to name the last argument: >> >> makeVerifier f m = divides m . foldl (+) 0 . zipWith f [1 .. ] . digits >> >> more point-freeing would be obfuscation. >> Instead of foldl (+) 0, you could also just write sum. >> >>> >>> -- Note: Reduce is just foldl f 0 lst, but map2 is >>> map2 :: (Int -> Int -> Int) -> [Int] -> [Int] -> [Int] >>> map2 f m n = [ f i d | (i,d) <- zip m n] >> >> map2 is zipWith, already in the Prelude. >> >>> >>> -- And here's my digits function >>> digits :: Int -> [Int] >>> digits 0 = [] >>> digits n = rem n 10 : digits (quot n 10) >> >> Unless you are desperate for speed and sure you deal only with positive >> numbers (or know >> that you really want quot and rem), better use div and mod. Those give the >> commonly >> expected (unless your expectation has been ruined by the behaviour of % in >> C, Java...) >> results. >> >>> >>> -- And divides function >>> divides :: Int -> Int -> Bool >>> divides divisor n = 0 == rem n divisor >>> >>> ===== >>> >>> (define check-isbn ;book number >>> ? (make-verifier >>> ?? * >>> ?? 11)) >>> >>> (define check-upc ;universal product code >>> ? (make-verifier >>> ?? (lambda (i d) (if (odd? i) d (* 3 d))) >>> ?? 10)) >>> >>> (define check-cc ;credit card >>> ? (make-verifier >>> ?? (lambda (i d) (if (odd? i) d (if (< d 5) (* 2 d) (+ (* 2 d) 1)))) >>> ?? 10)) >>> >>> (define check-usps ;postal money order >>> ? (make-verifier >>> ?? (lambda (i d) (if (= i 1) (- d) d)) >>> ?? 9)) >> >> >> >> _______________________________________________ >> 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/20090413/711c0c72/attachment.htm From barsoap at web.de Mon Apr 13 12:25:57 2009 From: barsoap at web.de (Achim Schneider) Date: Mon Apr 13 12:12:45 2009 Subject: [Haskell-cafe] Re: Types and hashes of hashes, trouble for a Java-programmer... References: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> Message-ID: <20090413182557.11b5ee0e@solaris> John Smith wrote: > Hi, a java-programmer running into trouble while trying to learn > Haskell. > > I try to make a hash containing hashes but can not getting a value > out of the innermost hash - I keep running into type-trouble where IO > and Maybe monad is getting mixed? > > My attempt: > > removeMaybeHash x = > case x of > Just ref -> ref > Nothing -> HashTable.new (==) (\key -> key) > > test = do > h <- HashTable.new (==) (\key -> key) > h1 <- HashTable.new (==) (\key -> key) > HashTable.insert h 3 h1 > HashTable.insert h1 1 1000 > maybeOuterHash <- HashTable.lookup h 3 > res <- removeMaybe (removeMaybeHash maybeOuterHash) 1000 > return res > > Any clues? > Just don't use it, someone deserves to be disemboweled for implementing it via IO. Most likely, you don't want to have a hash in specific, but a key->value mapping in general, and the Haskell libs offer more than one algorithm to do that, the most basic one being Data.Map, and the rest having more or less the same interface (e.g. IntMap, or Trie). There are two possibilities to "nest" two maps: The first being indexing the map by a tuple of both lookup keys, the second one using two maps, one inside the other. Personally, I always use Data.Map unless I identify it as a bottleneck after completing the program. Using tuples should be straight forward, if you want to nest Maps, you will want to chain two lookup's together. The most straight-forward way to do this is using Maybe's monad instance, which looks like this: instance Monad Maybe where (Just x) >>= k = k x Nothing >>= _ = Nothing It "bypasses" the second argument of >>= in case the first argument is Nothing. Filling in the types, we get (>>=) :: Maybe a -> (a -> Maybe b) -> Maybe b . "a" is going to be the inner map, which the second lookup will take as second parameter, so you can write this: import Data.Map as M lookup' :: (Ord k, Ord l) => Map k (Map l v) -> k -> l -> Maybe v lookup' m k l = M.lookup k m >>= M.lookup l ...Somewhere, I once read that monads can be seen as some fancy way to do OOP's foo.bar().baz(), but I'm not supposed to tell you that: You should try your best to forget anything you know about programming if you come from an imperative language and want to learn haskell :) -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From smithsnorth at gmail.com Mon Apr 13 12:27:18 2009 From: smithsnorth at gmail.com (John Smith) Date: Mon Apr 13 12:13:52 2009 Subject: [Haskell-cafe] Types and hashes of hashes, trouble for a Java-programmer... In-Reply-To: <2E9EFF53-A1BD-4AB0-A13A-8E96A786C0D6@n-brain.net> References: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> <2E9EFF53-A1BD-4AB0-A13A-8E96A786C0D6@n-brain.net> Message-ID: <438d2de60904130927y70c8364ap6b384adf6f414f52@mail.gmail.com> If you mean using a non-destructive map where the IO-problem is absent, that is a doable thing. But it would be like cheating :-) What I try do do is something like: test = do ? h <- HashTable.new (==) (\key -> key) ? h1 <- HashTable.new (==) (\key -> key) ? HashTable.insert h 3 h1 ? HashTable.insert h1 1 1000 ? res <- case HashTable.lookup h 3 of ? ? ? Nothing -> Nothing ? ? ? Just outer -> HashTable.lookup outer 1000 ? return res From vanenkj at gmail.com Mon Apr 13 12:30:12 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon Apr 13 12:16:45 2009 Subject: [Haskell-cafe] Types and hashes of hashes, trouble for a Java-programmer... In-Reply-To: <438d2de60904130927y70c8364ap6b384adf6f414f52@mail.gmail.com> References: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> <2E9EFF53-A1BD-4AB0-A13A-8E96A786C0D6@n-brain.net> <438d2de60904130927y70c8364ap6b384adf6f414f52@mail.gmail.com> Message-ID: > But it would be like cheating :-) In this case, the IO method *is* cheating. /jve On Mon, Apr 13, 2009 at 12:27 PM, John Smith wrote: > If you mean using a non-destructive map where the IO-problem is > absent, that is a doable thing. But it would be like cheating :-) > > What I try do do is something like: > > test = do > h <- HashTable.new (==) (\key -> key) > h1 <- HashTable.new (==) (\key -> key) > HashTable.insert h 3 h1 > HashTable.insert h1 1 1000 > res <- case HashTable.lookup h 3 of > Nothing -> Nothing > Just outer -> HashTable.lookup outer 1000 > return res > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090413/c659a270/attachment.htm From barsoap at web.de Mon Apr 13 12:33:38 2009 From: barsoap at web.de (Achim Schneider) Date: Mon Apr 13 12:20:27 2009 Subject: [Haskell-cafe] Re: Types and hashes of hashes, trouble for a Java-programmer... References: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> <2E9EFF53-A1BD-4AB0-A13A-8E96A786C0D6@n-brain.net> Message-ID: <20090413183338.525018f4@solaris> "John A. De Goes" wrote: > Why not use an ordered pair as the key? > Well, that might be seriously less efficient, depending on the type and size of keys: By nesting, you might avoid computing the hash of a two-megabyte key in case the outer lookup failed. The same goes for any other Map implementation, of course, O(zarroo) is always faster than anything. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From smithsnorth at gmail.com Mon Apr 13 12:33:52 2009 From: smithsnorth at gmail.com (John Smith) Date: Mon Apr 13 12:20:34 2009 Subject: [Haskell-cafe] Types and hashes of hashes, trouble for a Java-programmer... In-Reply-To: References: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> <2E9EFF53-A1BD-4AB0-A13A-8E96A786C0D6@n-brain.net> <438d2de60904130927y70c8364ap6b384adf6f414f52@mail.gmail.com> Message-ID: <438d2de60904130933w31e76863h94acdbded1501714@mail.gmail.com> Yes, I see what you mean. But still wan't to know if it is possible :-) From smithsnorth at gmail.com Mon Apr 13 12:49:17 2009 From: smithsnorth at gmail.com (John Smith) Date: Mon Apr 13 12:35:53 2009 Subject: [Haskell-cafe] Re: Types and hashes of hashes, trouble for a Java-programmer... In-Reply-To: <20090413183338.525018f4@solaris> References: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> <2E9EFF53-A1BD-4AB0-A13A-8E96A786C0D6@n-brain.net> <20090413183338.525018f4@solaris> Message-ID: <438d2de60904130949i43613ecbv9b42dea369856714@mail.gmail.com> Yes, I see. Good points in both answers, but I still would like to see how to do it with the mutable hash, if possible... From lennart at augustsson.net Mon Apr 13 12:50:26 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Mon Apr 13 12:37:01 2009 Subject: [Haskell-cafe] Types and hashes of hashes, trouble for a Java-programmer... In-Reply-To: <438d2de60904130927y70c8364ap6b384adf6f414f52@mail.gmail.com> References: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> <2E9EFF53-A1BD-4AB0-A13A-8E96A786C0D6@n-brain.net> <438d2de60904130927y70c8364ap6b384adf6f414f52@mail.gmail.com> Message-ID: No, removing IO is the right way. There is no reason to involve IO for this. -- Lennart On Mon, Apr 13, 2009 at 6:27 PM, John Smith wrote: > If you mean using a non-destructive map where the IO-problem is > absent, that is a doable thing. But it would be like cheating :-) > > What I try do do is something like: > > test = do > ? h <- HashTable.new (==) (\key -> key) > ? h1 <- HashTable.new (==) (\key -> key) > ? HashTable.insert h 3 h1 > ? HashTable.insert h1 1 1000 > ? res <- case HashTable.lookup h 3 of > ? ? ? Nothing -> Nothing > ? ? ? Just outer -> HashTable.lookup outer 1000 > ? return res > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From smithsnorth at gmail.com Mon Apr 13 12:53:50 2009 From: smithsnorth at gmail.com (John Smith) Date: Mon Apr 13 12:40:24 2009 Subject: [Haskell-cafe] Types and hashes of hashes, trouble for a Java-programmer... In-Reply-To: References: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> <2E9EFF53-A1BD-4AB0-A13A-8E96A786C0D6@n-brain.net> <438d2de60904130927y70c8364ap6b384adf6f414f52@mail.gmail.com> Message-ID: <438d2de60904130953s78d580b1o99eb447e0fa42c1b@mail.gmail.com> Yes, got the point. But is it not possible to "wrap IO inside IO" at all? What would the program look like, just for the exercise? On Mon, Apr 13, 2009 at 6:50 PM, Lennart Augustsson wrote: > No, removing IO is the right way. ?There is no reason to involve IO for this. > > ?-- Lennart > > On Mon, Apr 13, 2009 at 6:27 PM, John Smith wrote: >> If you mean using a non-destructive map where the IO-problem is >> absent, that is a doable thing. But it would be like cheating :-) >> >> What I try do do is something like: >> >> test = do >> ? h <- HashTable.new (==) (\key -> key) >> ? h1 <- HashTable.new (==) (\key -> key) >> ? HashTable.insert h 3 h1 >> ? HashTable.insert h1 1 1000 >> ? res <- case HashTable.lookup h 3 of >> ? ? ? Nothing -> Nothing >> ? ? ? Just outer -> HashTable.lookup outer 1000 >> ? return res >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From dagit at codersbase.com Mon Apr 13 12:55:52 2009 From: dagit at codersbase.com (Jason Dagit) Date: Mon Apr 13 12:42:25 2009 Subject: [Haskell-cafe] Types and hashes of hashes, trouble for a Java-programmer... In-Reply-To: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> References: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> Message-ID: Others have provided help to answer your question but I'd like to provide a little bit different feedback. On Mon, Apr 13, 2009 at 8:42 AM, John Smith wrote: > Hi, a java-programmer running into trouble while trying to learn Haskell. > > I try to make a hash containing hashes but can not getting a value out of > the innermost hash - I keep running into type-trouble where IO and Maybe > monad is getting mixed? > > My attempt: > > removeMaybeHash x = > ? case x of > ? Just ref -> ref > ? Nothing -> HashTable.new (==) (\key -> key) When you see yourself writing a function like this, you could write it like this instead: removeMaybeHash (Just ref) = ref removeMaybeHash Nothing = HashTable.new (==) (\key -> key) Hopefully you agree this 2 line version is more clear. You could go further of course and use the function 'maybe' from the prelude, and pass the function 'id' instead of \key -> key, but I don't want to overwhelm you. Good luck, Jason From conal at conal.net Mon Apr 13 12:58:26 2009 From: conal at conal.net (Conal Elliott) Date: Mon Apr 13 12:45:00 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: <1239387673.2337.1309952317@webmail.messagingengine.com> References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> <1239387673.2337.1309952317@webmail.messagingengine.com> Message-ID: > > To keep with the example, > something like drawUnitRectangle <$> mousePosition would result in a > signal whose points are IO actions that draw the rectangle where the > mouse is at the moment you sample them. And just as IO is unnecessary for behavior (functions of time), it's also unnecessary for imagery (functions of space). Continuing with the functional (non-IO) theme, you can give a semantically precise, composable and simple type of images. - Conal 2009/4/10 Patai Gergely > > I've seen alot of FRP libraries come up, and I'm always left with the > > question, "Where the heck are the FRP tutorials?" > Writing a good tutorial takes a lot of time, but I made some example > code precisely to show how the library can be used. The best way to > learn is to start playing with them. The "chase" example is about as > small as it gets, and the breakout one is generally a nice test case for > such a library, as it exercises the code as well as provides a > reasonably complex example for the user to study. > > The basic idea is indeed what Achim said: we refer to the whole lifetime > of some time-varying quantity (what I call a signal, but the name > behaviour is also often used for this concept in other systems) with a > single name. For instance, mousePosition is a two-dimensional vector > whose value follows the position of the mouse at any time. The > applicative interface means that you can combine signals using ordinary > point-wise functions by simple lifting. To keep with the example, > something like drawUnitRectangle <$> mousePosition would result in a > signal whose points are IO actions that draw the rectangle where the > mouse is at the moment you sample them. The drawUnitRectangle function > doesn't need to have anything reactive in it, it just takes an ordinary > pair (or whatever you represent your vectors with) and does its job. > > In the end, a program working with signals looks very much like one > calculating a snapshot of the system and the state changes at the given > moment, except you need to insert <*>'s and lift values where > applicable. > > Gergely > > -- > http://www.fastmail.fm - mmm... Fastmail... > > _______________________________________________ > 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/20090413/0058797c/attachment.htm From smithsnorth at gmail.com Mon Apr 13 12:59:22 2009 From: smithsnorth at gmail.com (John Smith) Date: Mon Apr 13 12:45:56 2009 Subject: [Haskell-cafe] Types and hashes of hashes, trouble for a Java-programmer... In-Reply-To: References: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> Message-ID: <438d2de60904130959h76568bafgb7952e0f4174c539@mail.gmail.com> Yes, agreed. Got any clue on the original problem (except to use Data.Map)? On Mon, Apr 13, 2009 at 6:55 PM, Jason Dagit wrote: > Others have provided help to answer your question but I'd like to > provide a little bit different feedback. > > On Mon, Apr 13, 2009 at 8:42 AM, John Smith wrote: > > Hi, a java-programmer running into trouble while trying to learn Haskell. > > > > I try to make a hash containing hashes but can not getting a value out of > > the innermost hash - I keep running into type-trouble where IO and Maybe > > monad is getting mixed? > > > > My attempt: > > > > removeMaybeHash x = > > case x of > > Just ref -> ref > > Nothing -> HashTable.new (==) (\key -> key) > > When you see yourself writing a function like this, you could write it > like this instead: > removeMaybeHash (Just ref) = ref > removeMaybeHash Nothing = HashTable.new (==) (\key -> key) > > Hopefully you agree this 2 line version is more clear. You could go > further of course and use the function 'maybe' from the prelude, and > pass the function 'id' instead of \key -> key, but I don't want to > overwhelm you. > > Good luck, > Jason > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090413/eb99ea8d/attachment.htm From dagit at codersbase.com Mon Apr 13 13:22:24 2009 From: dagit at codersbase.com (Jason Dagit) Date: Mon Apr 13 13:08:58 2009 Subject: [Haskell-cafe] Types and hashes of hashes, trouble for a Java-programmer... In-Reply-To: <438d2de60904130959h76568bafgb7952e0f4174c539@mail.gmail.com> References: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> <438d2de60904130959h76568bafgb7952e0f4174c539@mail.gmail.com> Message-ID: On Mon, Apr 13, 2009 at 9:59 AM, John Smith wrote: > Yes, agreed. Got any clue on the original problem (except to use Data.Map)? Nope. Sorry but your question is not something I have experience with. I don't know why, but I rarely use hashtables (in any language). Jason From dan.doel at gmail.com Mon Apr 13 13:44:02 2009 From: dan.doel at gmail.com (Dan Doel) Date: Mon Apr 13 13:30:39 2009 Subject: [Haskell-cafe] Types and hashes of hashes, trouble for a Java-programmer... In-Reply-To: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> References: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> Message-ID: <200904131344.03530.dan.doel@gmail.com> On Monday 13 April 2009 11:42:33 am John Smith wrote: > Hi, a java-programmer running into trouble while trying to learn Haskell. > > I try to make a hash containing hashes but can not getting a value out of > the innermost hash - I keep running into type-trouble where IO and Maybe > monad is getting mixed? I don't know the type of all these things, but here's a try. > My attempt: > > removeMaybeHash x = > case x of > Just ref -> ref > Nothing -> HashTable.new (==) (\key -> key) 'HashTable.new ...' has type IO (HashTable k v). This means that the type of removeMaybeHash must be: Maybe (IO (HashTable k v)) -> IO (HashTable k v) because in the Just case, you're just using 'ref' as the result of the function. This is probably not what you want, so you should use 'return ref'. This will make it have type: Maybe (HashTable k v) -> IO (HashTable k v) > test = do > h <- HashTable.new (==) (\key -> key) > h1 <- HashTable.new (==) (\key -> key) > HashTable.insert h 3 h1 > HashTable.insert h1 1 1000 > maybeOuterHash <- HashTable.lookup h 3 > res <- removeMaybe (removeMaybeHash maybeOuterHash) 1000 I don't know what the type of removeMaybe is supposed to be, but as used in this expression, with the above note about the type of removeMaybeHash, it must have type: IO (HashTable k v) -> Int -> IO (something) which is an odd type for a function with name "removeMaybe". > return res > > Any clues? Hopefully those help. As an additional clue, I'd recommend you write some type signatures at the top level for what you expect the types of your functions to be. That might help point out more specifically where things aren't going as you expect. -- Dan From lennart at augustsson.net Mon Apr 13 13:45:25 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Mon Apr 13 13:31:59 2009 Subject: [Haskell-cafe] Types and hashes of hashes, trouble for a Java-programmer... In-Reply-To: <438d2de60904130959h76568bafgb7952e0f4174c539@mail.gmail.com> References: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> <438d2de60904130959h76568bafgb7952e0f4174c539@mail.gmail.com> Message-ID: res <- HashTable.lookup h 3 >>= maybe (return Nothing) (flip HashTable.lookup 1000) On Mon, Apr 13, 2009 at 6:59 PM, John Smith wrote: > Yes, agreed. Got any clue on the original problem (except to use Data.Map)? > > On Mon, Apr 13, 2009 at 6:55 PM, Jason Dagit wrote: >> >> Others have provided help to answer your question but I'd like to >> provide a little bit different feedback. >> >> On Mon, Apr 13, 2009 at 8:42 AM, John Smith wrote: >> > Hi, a java-programmer running into trouble while trying to learn >> > Haskell. >> > >> > I try to make a hash containing hashes but can not getting a value out >> > of >> > the innermost hash - I keep running into type-trouble where IO and Maybe >> > monad is getting mixed? >> > >> > My attempt: >> > >> > removeMaybeHash x = >> > ? case x of >> > ? Just ref -> ref >> > ? Nothing -> HashTable.new (==) (\key -> key) >> >> When you see yourself writing a function like this, you could write it >> like this instead: >> removeMaybeHash (Just ref) = ref >> removeMaybeHash Nothing = HashTable.new (==) (\key -> key) >> >> Hopefully you agree this 2 line version is more clear. ?You could go >> further of course and use the function 'maybe' from the prelude, and >> pass the function 'id' instead of \key -> key, but I don't want to >> overwhelm you. >> >> Good luck, >> Jason > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From barsoap at web.de Mon Apr 13 13:49:46 2009 From: barsoap at web.de (Achim Schneider) Date: Mon Apr 13 13:36:33 2009 Subject: [Haskell-cafe] Re: Types and hashes of hashes, trouble for a Java-programmer... References: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> <2E9EFF53-A1BD-4AB0-A13A-8E96A786C0D6@n-brain.net> <20090413183338.525018f4@solaris> <438d2de60904130949i43613ecbv9b42dea369856714@mail.gmail.com> Message-ID: <20090413194946.66229c65@solaris> John Smith wrote: > Yes, I see. Good points in both answers, but I still would like to see > how to do it with the mutable hash, if possible... > test = do h <- H.new (==) id h1 <- H.new (==) id H.insert h 3 h1 H.insert h1 1 1000 inner <- H.lookup h 3 case inner of Nothing -> return Nothing Just outer -> H.lookup outer 1000 you forgot to lift the Nothing into the IO monad. I like this one: lookup' :: key -> b -> HashTable key (HashTable b val) -> IO (Maybe val) lookup' k l h = H.lookup h k >>= maybe (return Nothing) ((flip H.lookup) l) test' = do h <- H.new (==) id h1 <- H.new (==) id H.insert h 3 h1 H.insert h1 1 1000 lookup' 3 1000 h -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From martijn at van.steenbergen.nl Mon Apr 13 14:26:10 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Mon Apr 13 14:12:46 2009 Subject: [Haskell-cafe] Types and hashes of hashes, trouble for a Java-programmer... In-Reply-To: References: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> Message-ID: <49E383C2.5010802@van.steenbergen.nl> Jason Dagit wrote: >> removeMaybeHash x = >> case x of >> Just ref -> ref >> Nothing -> HashTable.new (==) (\key -> key) > > When you see yourself writing a function like this, you could write it > like this instead: > removeMaybeHash (Just ref) = ref > removeMaybeHash Nothing = HashTable.new (==) (\key -> key) > > Hopefully you agree this 2 line version is more clear. Actually, I prefer the other one... (though not necessarily spread out over 4 lines) I think this is more a matter of taste rather than clarity. Martijn. From bugfact at gmail.com Mon Apr 13 14:35:33 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Apr 13 14:22:09 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] Why does forkIO also create native threads? In-Reply-To: <3dc20c830904130137s75eaca5bhe515ae9992db6280@mail.gmail.com> References: <3dc20c830904130137s75eaca5bhe515ae9992db6280@mail.gmail.com> Message-ID: It seems that it's not the forkIO that is creating native threads (using GHC 6.10.1, -O flag) For example, the following code only has 5 threads on my Windows box, while I fork 10 lightweight threads import System.IO import Control.Concurrent import Control.Monad entry :: Char -> IO() entry c = do forever $ putChar c main = do hSetBuffering stdout NoBuffering mapM_ (forkIO . entry) ['0'..'9'] putStrLn "all forked; press ENTER to quit" getLine However, things can get bizarre. When we change the entry function into entry :: Char -> IO() entry c = do putChar c threadDelay maxBound Then on my machine 13 native threads *are* created. This might make sense because its waiting forever, but native threads are also created for the following code: entry :: Char -> IO() entry c = do putChar c forever $ threadDelay 0 This feels like overkill, so it seems threadDelay always forks a new native thread, although this is not documented. We can also get into the dark corners of GHC's lightweight thread scheduling: a thread switch only happens when memory is allocated on the GC head (but this is documented in the API) So the following code will not work, the runtime seems to get stuck in an infinite loop after the first thread is created. entry :: Char -> IO() entry c = do putChar c forever $ return () In artificial cases like this you can use yield entry :: Char -> IO() entry c = do putChar c forever yield On Mon, Apr 13, 2009 at 10:37 AM, Lych wrote: > I wrote a simple ECHO server like this: > ---------------------------------------------------- > import Network > import System.IO > import Control.Concurrent > > service cs = do > ln <- hGetContents cs > hPutStr cs ln > service cs > > > acceptloop ls = do > (cs, host, port) <- accept ls > hSetBuffering cs LineBuffering > forkIO (service cs) > acceptloop ls > > main = do > ls <- listenOn (PortNumber 10061) > acceptloop ls > ---------------------------------------------------- > > And tested it with a client that initiates as many parallel > connections as possible. The number of connections can just reach to > 1000+ on my machine, but I thought it should be more, since forkIO > generates lightweight threads. I also examined the number of threads > in this process with some tool and it proved there was one native > thread per connection. When I replaced the 'forkIO' in the program > with 'forkOS', I got an exactly similar result. Have I thought > something wrong about forkIO? > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090413/12b5b9ba/attachment-0001.htm From jfredett at gmail.com Mon Apr 13 15:18:36 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Apr 13 15:05:21 2009 Subject: [Haskell-cafe] Re: [Haskell] Haskell Weekly News: Issue 113 - April 13, 2009 In-Reply-To: <20090413075135.GA14126@seas.upenn.edu> References: <20090413075135.GA14126@seas.upenn.edu> Message-ID: <49E3900C.8000108@gmail.com> He forgot the quotes, so I grabbed a few I thought were good. :) Aaron_Denney says: "Don't anthropomorphize computers. They hate it when you do that." BMeph says [to psygnisfive] In #haskell, you can't hardly be taken seriously w/o writing a monad tutorial... heatsink says: @pl (\y -> you y off) taruti says: damn GHC. I had a nice example for a pretty but inefficient way to compute things and now the new GHC optimizes it to be fast ._. Japsu says: segfault cat is watching you unsafeCoerce /Joe Brent Yorgey wrote: > --------------------------------------------------------------------------- > Haskell Weekly News > http://sequence.complete.org/hwn/20090413 > Issue 113 - April 13, 2009 > --------------------------------------------------------------------------- > > Welcome to issue 113 of HWN, a newsletter covering developments in the > [1]Haskell community. > > Announcements > > xmobar-0.9.2. Andrea Rossato [2]announced the release of > [3]xmobar-0.9.2, which features a fix for a longstanding resource > leakage bug, new nested color definitions, and more. > > CFP Haskell Symposium 2009. Stephanie Weirich [4]reminded everyone that > there are only 4 weeks until the submission deadline for the [5]2009 > Haskell Symposium! > > hmatrix-static: statically-sized linear algebra. Reiner Pope > [6]announced the release of [7]hmatrix-static, a thin wrapper over > Alberto Ruiz's excellent [8]hmatrix library for linear algebra. The > main additions of hmatrix-static over hmatrix are that vectors and > matrices have their length encoded in their types, and vectors and > matrices may be constructed and destructed using view patterns, > affording a clean, safe syntax. > > haskellmode for Vim now at projects.haskell.org. Claus Reinke > [9]announced that the Haskell mode plugins for Vim have just completed > their move to their [10]new home, and took the opportunity to reiterate > what they can do (quite a lot, it seems), and mention that some > screencasts are available. > > MSem replacement for QSem. ChrisK [11]announced [12]MSem, a proposed > replacement module for Control.Concurrent.QSem. > > Hac5 is almost upon us!. Sean Leather [13]reminded everyone that in six > days, tens of crazy/obsessed, type-safe, functional programmers will be > converging on Utrecht to commence execution of the [14]5th Haskell > Hackathon, from April 17-19, 2009 in Utrecht, The Netherlands! The > local organizing team welcomes you all and looks forward to all of the > new developments that come out of everyone's undying quest to write > more and better code. > > Yogurt-0.4. Martijn van Steenbergen [15]announced version 0.4 of > [16]Yogurt, a functional MUD client. Version 0.4 makes Yogurt available > as a standalone executable that is able to dynamically load and reload > Yogurt scripts. > > Elerea, another FRP library. Patai Gergely [17]announced the release of > [18]Elerea, aka "Eventless reactivity", a minimalistic FRP > implementation that comes with a convenient applicative interface, > supports recursive definition of signals and signals fed from outside > by IO actions, plays nice with resources, and is the result of some > furious hacking. There are working examples to show off the current > capabilities of the library, found in the separate [19]elerea-examples > package. > > tree-monad 0.2. Sebastian Fischer [20]announced version 0.2 of the > [21]tree-monad package, which provides instances of MonadPlus that > represent the search space of non- deterministic computations as a > tree. Version 0.2 implements an optimized CPS version of the tree. > > HCard -- A library for implementing card-like structures.. Joe Fredette > [22]announced the release of [23]HCard, a library which supports a > card-like data structures and uses associated types to provide > shuffling, dealing, and other facilities. It's general enough to > support many different types of playing cards; it currently comes with > the common "French Deck" (4-suit, 13 card deck that is very common in > the US) implemented and an example cribbage scoring application. > > SVGFonts 0.1. Tillmann Vogt [24]announced his first Haskell library, > [25]SVGFonts 0.1, which parses the relatively unknown SVG Font format > to produce outlines of characters. The big advantage of this format is > that it is XML, which means easy parsing and manipulating. > > network-bytestring 0.1.2. Johan Tibell [26]announced a new release of > [27]network-bytestring, a Haskell library for fast socket I/O using > ByteStrings. New in this release is support for scatter/gather I/O > (also known as vectored I/O). Scatter/gather I/O provides more > efficient I/O by using one system call to send several separate pieces > of data and by avoiding unnecessary copying. > > Jobs > > Lecturer in Computer Science, University of Leicester. Roy L. Crole > [28]announced an opening for a lectureship at the University of > Leicester. The successful candidate will have a strong or promising > research record in computer science, with a background in formal > foundations (either algorithms and complexity, or semantics of > programming or modelling languages), and will be able to contribute to > undergraduate and postgraduate teaching and supervision in software > engineering. > > Blog noise > > [29]Haskell news from the [30]blogosphere. > * Mark Wassell: [31]Edge Detection in Haskell. > * Sean Leather: [32]Latest on the incremental fold and attributes. > * Sean Leather: [33]Haskell mode for Vim on a Mac. > * Sean Leather: [34]Incremental attributes. > * >>> Human Constraints: [35]Haskell Type Hackery. > * LHC Team: [36]A new beginning.. > * London Haskell Users Group: [37]Don Stewart: Engineering Large > Projects in Haskell: A Decade of Haskell at Galois. > * Ulisses Costa: [38]More Hylomorphisms in Haskell. > * Ulisses Costa: [39]Anamorphisms in Haskell. > * London Haskell Users Group: [40]Next Meeting: Don Stewart from > Galois. > * LHC Team: [41]Hello world!. > * mightybyte: [42]Adding Authentication to the Blog App. > * Leon Smith: [43]Polynomial multiplication. > * Joe Fredette: [44]Card games, scorekeeping, and ... Associated > Datatypes?. > * mightybyte: [45]Basic Happstack Blog App. > * mightybyte: [46]A Standalone Auth Framework for Happstack. > * Mads Lindstr?m: [47]Introducing WxGeneric. > * happstack.com: [48]2 new projects that use Happstack. > * >>> Brant Carlson: [49]Lightning Modeling in Haskell. > * Leon Smith: [50]Lloyd Allison's Corecursive Queues. > > About the Haskell Weekly News > > New editions are posted to [51]the Haskell mailing list as well as to > [52]the Haskell Sequence and [53]Planet Haskell. [54]RSS is also > available, and headlines appear on [55]haskell.org. > > To help create new editions of this newsletter, please see the > information on [56]how to contribute. Send stories to byorgey at cis > dot upenn dot edu. The darcs repository is available at darcs get > [57]http://code.haskell.org/~byorgey/code/hwn/ . > > References > > 1. http://haskell.org/ > 2. http://article.gmane.org/gmane.comp.lang.haskell.general/17080 > 3. http://code.haskell.org/~arossato/xmobar/ > 4. http://article.gmane.org/gmane.comp.lang.haskell.general/17072 > 5. http://haskell.org/haskell-symposium/2009/ > 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56772 > 7. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hmatrix-static > 8. http://www.hmatrix.googlepages.com/ > 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56495 > 10. http://projects.haskell.org/haskellmode-vim/ > 11. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56761 > 12. http://haskell.org/haskellwiki/SafeConcurrent > 13. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56758 > 14. http://haskell.org/haskellwiki/Hac5 > 15. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56747 > 16. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Yogurt > 17. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56731 > 18. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/elerea > 19. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/elerea-examples > 20. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56639 > 21. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/tree%2Dmonad > 22. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56573 > 23. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HCard > 24. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56444 > 25. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SVGFonts > 26. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56374 > 27. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/network-bytestring > 28. http://article.gmane.org/gmane.comp.lang.haskell.general/17066 > 29. http://planet.haskell.org/ > 30. http://haskell.org/haskellwiki/Blog_articles > 31. http://www.poundstone.org/blog/?p=137 > 32. http://feedproxy.google.com/~r/splonderzoek/~3/KWqNCgsK1ww/latest-on-incremental-fold-and.html > 33. http://feedproxy.google.com/~r/splonderzoek/~3/0QNaK4byWhg/haskell-mode-for-vim-on-mac.html > 34. http://feedproxy.google.com/~r/splonderzoek/~3/4B0bHoeTCeQ/incremental-attributes.html > 35. http://blog.human-constraints.com/?p=49 > 36. http://lhc-compiler.blogspot.com/2009/04/new-beginning.html > 37. http://www.londonhug.net/2009/04/10/don-stewart-engineering-large-projects-in-haskell-a-decade-of-haskell-at-galois/ > 38. http://ulissesaraujo.wordpress.com/2009/04/09/more-hylomorphisms-in-haskell/ > 39. http://ulissesaraujo.wordpress.com/2009/04/08/anamorphisms-in-haskell/ > 40. http://www.londonhug.net/2009/04/09/next-meeting-don-stewart-from-galois/ > 41. http://lhc-compiler.blogspot.com/2009/04/hello-world.html > 42. http://softwaresimply.blogspot.com/2009/04/adding-authentication-to-blog-app.html > 43. http://blog.melding-monads.com/2009/04/07/polynomial-multiplication/ > 44. http://lowlymath.net/2009/card-games-scorekeeping-and-associated-datatypes/ > 45. http://softwaresimply.blogspot.com/2009/04/basic-happstack-blog-app.html > 46. http://softwaresimply.blogspot.com/2009/04/standalone-auth-framework-for-happstack.html > 47. http://lindstroem.wordpress.com/2008/05/03/introducing-wxgeneric/ > 48. http://blog.happstack.com/2009/04/06/2-new-projects-that-use-happstack/ > 49. http://bayern.stanford.edu/~brant/lightning/ > 50. http://blog.melding-monads.com/2009/03/09/lloyd-allisons-corecursive-queues/ > 51. http://www.haskell.org/mailman/listinfo/haskell > 52. http://sequence.complete.org/ > 53. http://planet.haskell.org/ > 54. http://sequence.complete.org/node/feed > 55. http://haskell.org/ > 56. http://haskell.org/haskellwiki/HWN > 57. http://code.haskell.org/~byorgey/code/hwn/ > _______________________________________________ > Haskell mailing list > Haskell@haskell.org > http://www.haskell.org/mailman/listinfo/haskell > > -------------- next part -------------- A non-text attachment was scrubbed... Name: jfredett.vcf Type: text/x-vcard Size: 296 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090413/4af7a72e/jfredett.vcf From ketil at malde.org Mon Apr 13 17:30:29 2009 From: ketil at malde.org (Ketil Malde) Date: Mon Apr 13 17:15:54 2009 Subject: [Haskell-cafe] Best text editor In-Reply-To: <49E2E1EB.3040100@alumni.caltech.edu> (Michael Mossey's message of "Sun\, 12 Apr 2009 23\:55\:39 -0700") References: <23018470.post@talk.nabble.com> <49E2E1EB.3040100@alumni.caltech.edu> Message-ID: <873acc2qdm.fsf@malde.org> Michael Mossey writes: > I'm a beginner, but I'll chime in and say I use Emacs with > haskell-mode. It's auto-indentation is a bit complex in behavior which > is unappealing (I feel like I never know what it's going to do when I > hit tab), but I would be curious what someone with more experience > feels about that. Just keep hitting tab until you have the indentation you want. -k -- If I haven't seen further, it is by standing in the footprints of giants From mpm at alumni.caltech.edu Mon Apr 13 18:06:46 2009 From: mpm at alumni.caltech.edu (Michael P Mossey) Date: Mon Apr 13 17:53:20 2009 Subject: [Haskell-cafe] Best text editor In-Reply-To: <873acc2qdm.fsf@malde.org> References: <23018470.post@talk.nabble.com> <49E2E1EB.3040100@alumni.caltech.edu> <873acc2qdm.fsf@malde.org> Message-ID: <49E3B776.6070800@alumni.caltech.edu> Ketil Malde wrote: > Michael Mossey writes: > >> I'm a beginner, but I'll chime in and say I use Emacs with >> haskell-mode. It's auto-indentation is a bit complex in behavior which >> is unappealing (I feel like I never know what it's going to do when I >> hit tab), but I would be curious what someone with more experience >> feels about that. > > Just keep hitting tab until you have the indentation you want. > > -k Well, that's a bit like driving a car and saying, "Keep turning the wheel back and forth until the car goes in the direction you want." Seriously, good user interfaces have simple, predictable behavior. Also, very often you never get the indentation you want no matter how many times you hit tab. Of course, I'm grateful to have a haskell-mode at all, and the syntax highlighting is helpful, so I don't want to complain too much. I tried switching to the "simple indentation mode" but I can't tell the difference. I would like a mode that advances to the right in a simple way (checks lines above for alignment positions, and advances one position at a time). Maybe I'll write one. I do have a bit of experience with emacs lisp. Thanks, Mike From relapse.dev at gmx.com Mon Apr 13 18:12:53 2009 From: relapse.dev at gmx.com (Neal Alexander) Date: Mon Apr 13 18:02:12 2009 Subject: [Haskell-cafe] Re: Best text editor In-Reply-To: <49E3B776.6070800@alumni.caltech.edu> References: <23018470.post@talk.nabble.com> <49E2E1EB.3040100@alumni.caltech.edu> <873acc2qdm.fsf@malde.org> <49E3B776.6070800@alumni.caltech.edu> Message-ID: Michael P Mossey wrote: > Ketil Malde wrote: >> Michael Mossey writes: >> >>> I'm a beginner, but I'll chime in and say I use Emacs with >>> haskell-mode. It's auto-indentation is a bit complex in behavior which >>> is unappealing (I feel like I never know what it's going to do when I >>> hit tab), but I would be curious what someone with more experience >>> feels about that. >> >> Just keep hitting tab until you have the indentation you want. >> >> -k > > Well, that's a bit like driving a car and saying, "Keep turning the > wheel back and forth until the car goes in the direction you want." > Seriously, good user interfaces have simple, predictable behavior. Also, > very often you never get the indentation you want no matter how many > times you hit tab. Of course, I'm grateful to have a haskell-mode at > all, and the syntax highlighting is helpful, so I don't want to complain > too much. I tried switching to the "simple indentation mode" but I can't > tell the difference. > > I would like a mode that advances to the right in a simple way (checks > lines above for alignment positions, and advances one position at a > time). Maybe I'll write one. I do have a bit of experience with emacs lisp. > > Thanks, > Mike I use console emacs in a Screen session over ssh. The haskell-mode tabbing annoyed me at first, but i learned to love it. From bugfact at gmail.com Mon Apr 13 18:22:22 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Apr 13 18:08:55 2009 Subject: [Haskell-cafe] Best text editor In-Reply-To: <49E3B776.6070800@alumni.caltech.edu> References: <23018470.post@talk.nabble.com> <49E2E1EB.3040100@alumni.caltech.edu> <873acc2qdm.fsf@malde.org> <49E3B776.6070800@alumni.caltech.edu> Message-ID: There used to be Visual Haskell - an extension to Visual Studio - but that never took off. Too bad, because these days you can download the freely available Visual Studio Shell , and Visual Haskell had some unique features (such as hovering tooltips showing types) that are now found in the F# editor, and should now be easier to implement with the recent GHC API (I guess). Maybe this is a good Google Summer Of Code project; getting Visual Haskell up and running again with Visual Studio Shell... On Tue, Apr 14, 2009 at 12:06 AM, Michael P Mossey wrote: > Ketil Malde wrote: > >> Michael Mossey writes: >> >> I'm a beginner, but I'll chime in and say I use Emacs with >>> haskell-mode. It's auto-indentation is a bit complex in behavior which >>> is unappealing (I feel like I never know what it's going to do when I >>> hit tab), but I would be curious what someone with more experience >>> feels about that. >>> >> >> Just keep hitting tab until you have the indentation you want. >> >> -k >> > > Well, that's a bit like driving a car and saying, "Keep turning the wheel > back and forth until the car goes in the direction you want." Seriously, > good user interfaces have simple, predictable behavior. Also, very often you > never get the indentation you want no matter how many times you hit tab. Of > course, I'm grateful to have a haskell-mode at all, and the syntax > highlighting is helpful, so I don't want to complain too much. I tried > switching to the "simple indentation mode" but I can't tell the difference. > > I would like a mode that advances to the right in a simple way (checks > lines above for alignment positions, and advances one position at a time). > Maybe I'll write one. I do have a bit of experience with emacs lisp. > > Thanks, > Mike > > > > _______________________________________________ > 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/20090414/9e9961e9/attachment.htm From vasyl.pasternak at gmail.com Mon Apr 13 18:37:42 2009 From: vasyl.pasternak at gmail.com (Vasyl Pasternak) Date: Mon Apr 13 18:24:15 2009 Subject: [Haskell-cafe] Language.Haskell.Parser and literate Haskell source Message-ID: <8feb08f70904131537v347cef1dw15b3b2cfbf925ba3@mail.gmail.com> Hello, Are there ability to parse literate haskell source with Language.Haskell.Parser, or maybe there is some tool, which converts .lhs files to .hs ? Thanks in advance. -- Best regards, Vasyl Pasternak From dagit at codersbase.com Mon Apr 13 18:46:20 2009 From: dagit at codersbase.com (Jason Dagit) Date: Mon Apr 13 18:32:53 2009 Subject: [Haskell-cafe] Language.Haskell.Parser and literate Haskell source In-Reply-To: <8feb08f70904131537v347cef1dw15b3b2cfbf925ba3@mail.gmail.com> References: <8feb08f70904131537v347cef1dw15b3b2cfbf925ba3@mail.gmail.com> Message-ID: On Mon, Apr 13, 2009 at 3:37 PM, Vasyl Pasternak wrote: > Hello, > > Are there ability to parse literate haskell source with > Language.Haskell.Parser, or maybe > there is some tool, which converts .lhs files to .hs ? You can ask GHC to remove the literate bits. I think the command is called 'unlit' but check the GHC manual to be sure. Jason From ok at cs.otago.ac.nz Mon Apr 13 18:48:42 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Mon Apr 13 18:35:19 2009 Subject: [Haskell-cafe] Re: Maybe off-topic -- Writing contracts or software specifications In-Reply-To: References: Message-ID: On 11 Apr 2009, at 1:40 pm, Maur? cio wrote: > But I have an additional concern: to fit in burocracy. I need > to write a contract that someone else, who understands just > office applications, not software writing, will need to feel > safe enough with to sign it. It's not that important to have > a good contract, but actually to be able to say "someone else > did it like this, and had no problems". Then I can save that > contract and forget about it. I need something that won't hurt, > more than something that will help development. So "contract" here means "legal document", not "specification". The really important thing here is the level of trust between the two parties. If you have a high level of trust, something along the lines of "You will do something nice for me and I will pay you a fair price and we'll keep in touch while this happens" on the back of a paper napkin will do fine. If you have a low level of trust, you'll need a great level of detail, and it still won't help. I suspect you're somewhere in the middle. In that case, what you really need to do is to agree on a process that will _build_ trust, step by step. Maybe you can't explain to each other what the final product should be like. Can you agree on a _first_ step, to be done in a couple of weeks, where neither of you has much to lose? Sign a contract for that. Because it is by intent a small step, where nobody has much to lose if you just abandon the whole thing, you shouldn't need a heavyweight legal document. Showing that you understand the other side's need to manage risk will help to build trust. I don't want to go into details, but heavyweight up-front agreements can come unpleasantly close to killing a company. From vasyl.pasternak at gmail.com Mon Apr 13 18:57:46 2009 From: vasyl.pasternak at gmail.com (Vasyl Pasternak) Date: Mon Apr 13 18:44:19 2009 Subject: [haskell-cafe] implementing multilingual interface with dynamic language switching Message-ID: <8feb08f70904131557w288595d0sd61fa5d9fde7c790@mail.gmail.com> Hello, Recently, I've tried to use hgettext to implement dynamic language switching and support of several languages simultaneously. All my tries I've described in blog article http://progandprog.blogspot.com/2009/04/multilingual-ui-and-dynamic-language.html . Comments and suggestions are welcome :) -- Best regards, Vasyl Pasternak From xj2106 at columbia.edu Mon Apr 13 18:58:08 2009 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Mon Apr 13 18:44:44 2009 Subject: [Haskell-cafe] Best text editor In-Reply-To: <49E3B776.6070800@alumni.caltech.edu> (Michael P. Mossey's message of "Mon, 13 Apr 2009 15:06:46 -0700") References: <23018470.post@talk.nabble.com> <49E2E1EB.3040100@alumni.caltech.edu> <873acc2qdm.fsf@malde.org> <49E3B776.6070800@alumni.caltech.edu> Message-ID: <874ows2mbj.fsf@columbia.edu> Michael P Mossey writes: > Ketil Malde wrote: >> Michael Mossey writes: >> >>> I'm a beginner, but I'll chime in and say I use Emacs with >>> haskell-mode. It's auto-indentation is a bit complex in behavior which >>> is unappealing (I feel like I never know what it's going to do when I >>> hit tab), but I would be curious what someone with more experience >>> feels about that. >> >> Just keep hitting tab until you have the indentation you want. >> >> -k > > Well, that's a bit like driving a car and saying, "Keep turning the > wheel back and forth until the car goes in the direction you want." > Seriously, good user interfaces have simple, predictable > behavior. Also, very often you never get the indentation you want no > matter how many times you hit tab. Of course, I'm grateful to have a > haskell-mode at all, and the syntax highlighting is helpful, so I > don't want to complain too much. I tried switching to the "simple > indentation mode" but I can't tell the difference. > > I would like a mode that advances to the right in a simple way (checks > lines above for alignment positions, and advances one position at a > time). Maybe I'll write one. I do have a bit of experience with emacs > lisp. Is there something we can learn from python-mode? I haven't written python code since I started using haskell. If memory serves, my impression is that the indentation in python-mode worked more natural. -- c/* __o/* <\ * (__ */\ < From niklas.broberg at gmail.com Mon Apr 13 19:08:38 2009 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Mon Apr 13 18:55:11 2009 Subject: [Haskell-cafe] Language.Haskell.Parser and literate Haskell source In-Reply-To: <8feb08f70904131537v347cef1dw15b3b2cfbf925ba3@mail.gmail.com> References: <8feb08f70904131537v347cef1dw15b3b2cfbf925ba3@mail.gmail.com> Message-ID: > Are there ability to parse literate haskell source with > Language.Haskell.Parser, or maybe > there is some tool, which converts .lhs files to .hs ? Use the haskell-src-exts package instead of haskell-src. The function parseFile in Language.Haskell.Exts will de-literate the file for you if the suffix is .lhs. Cheers, /Niklas From vasyl.pasternak at gmail.com Mon Apr 13 19:55:03 2009 From: vasyl.pasternak at gmail.com (Vasyl Pasternak) Date: Mon Apr 13 19:41:36 2009 Subject: [Haskell-cafe] Language.Haskell.Parser and literate Haskell source In-Reply-To: References: <8feb08f70904131537v347cef1dw15b3b2cfbf925ba3@mail.gmail.com> Message-ID: <8feb08f70904131655g6a85b534x5a936b7299857fd3@mail.gmail.com> Jason, Thank you for your answer. I haven't found unliterate capability in GHC, but I found unlit function in Distribution.Simple.PreProcess.Unlit, which do the things I needed. Best regards, Vasyl 2009/4/14 Jason Dagit : > On Mon, Apr 13, 2009 at 3:37 PM, Vasyl Pasternak > wrote: >> Hello, >> >> Are there ability to parse literate haskell source with >> Language.Haskell.Parser, or maybe >> there is some tool, which converts .lhs files to .hs ? > > You can ask GHC to remove the literate bits. I think the command is > called 'unlit' but check the GHC manual to be sure. > > Jason > From vasyl.pasternak at gmail.com Mon Apr 13 19:58:45 2009 From: vasyl.pasternak at gmail.com (Vasyl Pasternak) Date: Mon Apr 13 19:45:17 2009 Subject: [Haskell-cafe] Language.Haskell.Parser and literate Haskell source In-Reply-To: References: <8feb08f70904131537v347cef1dw15b3b2cfbf925ba3@mail.gmail.com> Message-ID: <8feb08f70904131658w2cd4e438wa880db52177ec211@mail.gmail.com> Niklas, I suspected that haskell-src-exts should have this function, but it was undocumented :) Thank you for the tip. Best regards, Vasyl 2009/4/14 Niklas Broberg : >> Are there ability to parse literate haskell source with >> Language.Haskell.Parser, or maybe >> there is some tool, which converts .lhs files to .hs ? > > Use the haskell-src-exts package instead of haskell-src. The function > parseFile in Language.Haskell.Exts will de-literate the file for you > if the suffix is .lhs. > > Cheers, > > /Niklas > From briqueabraque at yahoo.com Mon Apr 13 20:23:02 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Mon Apr 13 20:09:50 2009 Subject: [Haskell-cafe] Re: Best text editor In-Reply-To: <23018470.post@talk.nabble.com> References: <23018470.post@talk.nabble.com> Message-ID: > Hi I would like to follow the crowd and find out what text editor everyone > uses for haskell on windows. > > Thx in advanced I don't use editors with automatic indentation. Instead, I forget the layout rule (i.e., module Main (main) where {main = putStrLn Hi where {Hi="Hello World"}}). Then I send the result to a pretty printer. It's a lot easier to get code to make the parser happy without layout, and pretty printers do a really good job. Problem is, my pretty printer stoped working. There's 'hstidy' in hackage, but I'm not sure it's alive. Best, Maur?cio From mpm at alumni.caltech.edu Mon Apr 13 21:59:04 2009 From: mpm at alumni.caltech.edu (Michael P Mossey) Date: Mon Apr 13 21:45:48 2009 Subject: [Haskell-cafe] Best text editor In-Reply-To: <874ows2mbj.fsf@columbia.edu> References: <23018470.post@talk.nabble.com> <49E2E1EB.3040100@alumni.caltech.edu> <873acc2qdm.fsf@malde.org> <49E3B776.6070800@alumni.caltech.edu> <874ows2mbj.fsf@columbia.edu> Message-ID: <49E3EDE8.1070407@alumni.caltech.edu> Xiao-Yong Jin wrote: > Michael P Mossey writes: >> lines above for alignment positions, and advances one position at a >> time). Maybe I'll write one. I do have a bit of experience with emacs >> lisp. > > Is there something we can learn from python-mode? I haven't > written python code since I started using haskell. If > memory serves, my impression is that the indentation in > python-mode worked more natural. I like python-mode, but python layout is much simpler. Also, the behavior of the python-mode tab key is more predictable: it goes first to the rightmost stop that makes sense, then repeated clicks of the tab key move the cursor to the left one tab stop at a time. Again, I don't want to be too critical of haskell-mode because it is great to have it at all. I would prefer simpler behavior of the tab key, that's all. Maybe I can write it. -Mike From fft1976 at gmail.com Mon Apr 13 22:18:18 2009 From: fft1976 at gmail.com (FFT) Date: Mon Apr 13 22:04:51 2009 Subject: [Haskell-cafe] Best text editor In-Reply-To: <23018470.post@talk.nabble.com> References: <23018470.post@talk.nabble.com> Message-ID: Has anyone tried Yi? On Sun, Apr 12, 2009 at 11:23 PM, Melanie_Green wrote: > > Hi I would like to follow the crowd and find out what text editor everyone > uses for haskell on windows. > > Thx in advanced > -- > View this message in context: http://www.nabble.com/Best-text-editor-tp23018470p23018470.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 tonal.promsoft at gmail.com Mon Apr 13 22:37:38 2009 From: tonal.promsoft at gmail.com (Alexandr N. Zamaraev) Date: Mon Apr 13 22:24:41 2009 Subject: [Haskell-cafe] Best text editor In-Reply-To: <23018470.post@talk.nabble.com> References: <23018470.post@talk.nabble.com> Message-ID: <49E3F6F2.9020508@gmail.com> Melanie_Green wrote: > Hi I would like to follow the crowd and find out what text editor everyone > uses for haskell on windows. * Far Manager + Colorer plugin (http://www.farmanager.com/index.php?l=en) * HippoEdit (http://www.hippoedit.com/) From leimy2k at gmail.com Mon Apr 13 22:51:17 2009 From: leimy2k at gmail.com (David Leimbach) Date: Mon Apr 13 22:37:49 2009 Subject: [Haskell-cafe] Best text editor In-Reply-To: References: <23018470.post@talk.nabble.com> Message-ID: <3e1162e60904131951g608acdep1777bf7baf29ce0b@mail.gmail.com> On Mon, Apr 13, 2009 at 7:18 PM, FFT wrote: > Has anyone tried Yi? Yes... and I rather like it. > > > On Sun, Apr 12, 2009 at 11:23 PM, Melanie_Green > wrote: > > > > Hi I would like to follow the crowd and find out what text editor > everyone > > uses for haskell on windows. > > > > Thx in advanced > > -- > > View this message in context: > http://www.nabble.com/Best-text-editor-tp23018470p23018470.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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090413/d289a8b8/attachment.htm From asmith9983 at gmail.com Mon Apr 13 23:01:29 2009 From: asmith9983 at gmail.com (Andrew Smith) Date: Mon Apr 13 22:48:05 2009 Subject: [Haskell-cafe] Best text editor In-Reply-To: <49E3F6F2.9020508@gmail.com> References: <23018470.post@talk.nabble.com> <49E3F6F2.9020508@gmail.com> Message-ID: <49E3FC89.1090800@gmail.com> As a long time *NIX person, I would have to recommend gViM, regardless of the OS, The strongpoint being, learn one editor really well and use on all environments. Many years ago I did program my Emacs with Lisp to give it the indents I wanted, but I still stayed with ViM. -- Andrew in Edinburgh,Scotland. Alexandr N. Zamaraev wrote: > Melanie_Green wrote: >> Hi I would like to follow the crowd and find out what text editor >> everyone >> uses for haskell on windows. > * Far Manager + Colorer plugin > (http://www.farmanager.com/index.php?l=en) > * HippoEdit (http://www.hippoedit.com/) > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- -- Andrew From monnier at iro.umontreal.ca Mon Apr 13 23:20:04 2009 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Mon Apr 13 23:06:50 2009 Subject: [Haskell-cafe] Re: Best text editor References: <23018470.post@talk.nabble.com> <49E2E1EB.3040100@alumni.caltech.edu> Message-ID: > I'm a beginner, but I'll chime in and say I use Emacs with > haskell-mode. It's auto-indentation is a bit complex in behavior which is > unappealing (I feel like I never know what it's going to do when I hit tab), > but I would be curious what someone with more experience feels about that. I clearly recommend Emacs with haskell-mode, but I agree that the indentation is problematic. Note that the code in the CVS repository comes with a completely new indentation algorithm courtesy of Kristof Bastiaensen (so you can now choose between haskell-simple-indent, haskell-indent, and the new haskell-indentation). I haven't tried this new algorithm much, but people who dislike haskell-indent might want to give it a try. Stefan From jason.dusek at gmail.com Tue Apr 14 00:09:49 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Mon Apr 13 23:56:21 2009 Subject: [Haskell-cafe] Best text editor In-Reply-To: <23018470.post@talk.nabble.com> References: <23018470.post@talk.nabble.com> Message-ID: <42784f260904132109j7603a2efndd91bc678aa0d68f@mail.gmail.com> I recommend Vim highly; however, it can take a while to get used to it. There are versions of Vim that offer close integration with your GUI's native keybindings; on Windows I believe that setup is called Cream. In all fairness, I am not that knowledgeable about work on Windows -- on the one occasion where I have worked on Windows for an extended period of time, I installed Moka 5 and a Linux VM and did all my editing through that. -- Jason Dusek From kscraja at gmail.com Tue Apr 14 02:25:52 2009 From: kscraja at gmail.com (Raja Koduru) Date: Tue Apr 14 02:12:26 2009 Subject: [Haskell-cafe] glut installation using cabal failed Message-ID: <1336aed20904132325i6b765025oc20e99593dba3fbd@mail.gmail.com> hi, I am a beginner to haskell. I am trying to install glut using "cabal install glut" Pasting here a tail of the output --------------------------------------------------------------------- checking for unistd.h... yes checking windows.h usability... yes checking windows.h presence... yes checking for windows.h... yes checking GL/glut.h usability... no checking GL/glut.h presence... no checking for GL/glut.h... no checking for GLUT library... no checking for GL/glut.h... (cached) no checking GLUT/glut.h usability... no checking GLUT/glut.h presence... no checking for GLUT/glut.h... no configure: error: no GLUT header found, so this package cannot be built See `config.log' for more details. cabal: Error: some packages failed to install: GLUT-2.1.1.2 failed during the configure step. The exception was: exit: ExitFailure 1 --------------------------------------------------------------------------------- But I do have "glut.h" in my "D:\ghc\ghc-6.10.2\include\mingw\GL". Here is my `ghc-pkg list` -------------------------------------------------------------------------------- D:\ghc\ghc-6.10.2>ghc-pkg list d:/ghc/ghc-6.10.2\package.conf: Cabal-1.6.0.3, GLFW-0.3, HUnit-1.2.0.3, OpenGL-2.2.1.1, QuickCheck-1.2.0.0, Win32-2.2.0.0, array-0.2.0.0, base-3.0.3.1, base-4.1.0.0, bytestring-0.9.1.4, 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), filepath-1.1.0.2, (ghc-6.10.2), ghc-paths-0.1.0.5, 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, 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, xhtml-3000.2.0.1 -------------------------------------------------------------------------------- I am on windows XP using ghc-6.10.2 Please advice, regards, raja From sebf at informatik.uni-kiel.de Tue Apr 14 04:17:29 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Tue Apr 14 04:04:07 2009 Subject: [Haskell-cafe] Monads from Functors In-Reply-To: <2f9b2d30904090959q4511e161w85aa60bf04eb9465@mail.gmail.com> References: <2f9b2d30904081729n604ce07as53c6e9f23d90f773@mail.gmail.com> <06CFEA36-F348-4BFD-B6C5-0D745FC07CBC@informatik.uni-kiel.de> <2f9b2d30904090959q4511e161w85aa60bf04eb9465@mail.gmail.com> Message-ID: <8BCAA37C-F044-4CD8-9254-B92B6A3B7E87@informatik.uni-kiel.de> Edward Kmett wrote: > I think there is another way to view the ContT/Codensity/Monad > generated by a functor, in terms of an accumulating parameter that > may be informative. [...] > Now what I find interesting is that Yoneda is basically carrying > around an accumulator for 'fmap' applications. [...] > When you look at the definition for Codensity f a, what it > effectively supplies is a 'better accumulator', one which is large > enough to encode (>>=). Indeed an insightful perspective! Ryan Ingram wrote: >> If we have a computation >> >> a :: Monad m => m a >> >> and we have a pointed functor `f`, then we can get the result of the >> computation `a` in our functor `f` because `runContT a :: f a`. > > Sure, but you can also do the same much more simply: > > mkPointed :: Pointed f => forall f a. (forall m. Monad m => m a) -> > f a > mkPointed m = point $ runIdentity m Ha! Nice damper. So the interesting part is not that one gets a monad for free but that one gets a monad for free that can be combined with effects defined elsewhere. That seems closely related to your MonadPrompt. Thanks for the pointer. > You may as well do the following: > >> data MPlus a = Zero | Pure a | Plus (MPlus a) (MPlus a) >> instance Monad MPlus where ... >> instance MonadPlus MPlus where ... > >> mkAlternative :: forall f a. Alternative f => (forall m. MonadPlus >> m => m a) -> f a > > (all this code is really saying is that being polymorphic over > MonadPlus is kind of dumb, because you aren't really using Monad at > all) Well, you can use return, bind, mzero and mplus.. I'd consider this *really* monad. You are right, that your version is equivalent to the "generic" MonadPlus instance which (only) eliminates the intermediate data structure. > Without any way to lift other effects from the underlying functor into > ContT, I don't really see how the "generic" ContT MonadPlus instance > buys you much :) I'm not sure which other effects can be lifted without bind and which need lift. But anyway, there is a lift function that can be used if necessary. Non-determinism is one interesting effect that does not need lift. The generic MonadPlus (ContT t) instance buys you a lot, if you are interested in non-determinism and search. Inspired by all your replies I have applied ContT to a type for difference lists which resulted in the well known two-continuation model for depth first search -- refactoring it modularly into two different parts that are useful on their own. Replacing one of those parts lead to a CPS implementation of breadth-first search that I have not been aware of previously. Please tell me if you have seen this implementation before. I have written about it: http://www-ps.informatik.uni-kiel.de/~sebf/haskell/stealing-bind.html >> Ryan: >> > The CPS transfrom in ContT also has the nice property that it >> makes >> > most applications of >>= in the underlying monad be >> > right-associative. >> >> Do you have a specific reason to say *most* (rather than *all*) here? > > Yes, because >> runContT ( (lift (a >>= f)) >>= g ) > still has a left-associative >>=. > [...] > I know this was a pretty in-depth example, so I hope I've made it > clear :) Yes, thanks! Cheers, Sebastian From jules at jellybean.co.uk Tue Apr 14 04:24:11 2009 From: jules at jellybean.co.uk (Jules Bean) Date: Tue Apr 14 04:10:36 2009 Subject: [Haskell-cafe] Best text editor In-Reply-To: <49E2E1EB.3040100@alumni.caltech.edu> References: <23018470.post@talk.nabble.com> <49E2E1EB.3040100@alumni.caltech.edu> Message-ID: <49E4482B.70505@jellybean.co.uk> Michael Mossey wrote: > I'm a beginner, but I'll chime in and say I use Emacs with haskell-mode. > It's auto-indentation is a bit complex in behavior which is unappealing > (I feel like I never know what it's going to do when I hit tab), but I > would be curious what someone with more experience feels about that. Yes. Don't use it. Use this: http://kuribas.hcoop.net/haskell-indentation.el (The message from Stefan appears to suggest this will be bundled with the next haskell-mode release - that's excellent news). It is much more predictable - TAB always moves right to the next valid position, BACKSPACE always moves left. From temp.tsun at gmail.com Tue Apr 14 04:39:28 2009 From: temp.tsun at gmail.com (Tsunkiet Man) Date: Tue Apr 14 04:26:02 2009 Subject: [Haskell-cafe] How the following works Message-ID: Hello, I can hardly imagine how the following code works: cinits :: [a] -> [[a]] cinits [] = [[]] cinits (x:xs) = [] : map (x:) (cinits xs) can someone give me a good explaination? (I understand it a bit, but it's really hard for me to figure out how a map in a map function works.) Thank you for your time, Tsunkiet -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090414/2037f22b/attachment.htm From lennart at augustsson.net Tue Apr 14 04:52:30 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Tue Apr 14 04:39:05 2009 Subject: [Haskell-cafe] How the following works In-Reply-To: References: Message-ID: Why don't you hand execute it on an example, like cinits [1,2,3]? cinits [1,2,3] = cinits (1:2:3:[]) = [] : map (1:) (cinits (2:3:[]) = [] : map (1:) ([] : map (2:) (cinits (3:[])) = ... On Tue, Apr 14, 2009 at 10:39 AM, Tsunkiet Man wrote: > Hello, > > I can hardly imagine how the following code works: > > cinits :: [a] -> [[a]] > cinits [] = [[]] > cinits (x:xs) = [] : map (x:) (cinits xs) > > can someone give me a good explaination? > > (I understand it a bit, but it's really hard for me to figure out how a map > in a map function works.) > > Thank you for your time, > > Tsunkiet > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From daniel.is.fischer at web.de Tue Apr 14 05:00:34 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Apr 14 04:47:19 2009 Subject: [Haskell-cafe] How the following works In-Reply-To: References: Message-ID: <200904141100.34386.daniel.is.fischer@web.de> Am Dienstag 14 April 2009 10:39:28 schrieb Tsunkiet Man: > Hello, > > I can hardly imagine how the following code works: > > cinits :: [a] -> [[a]] > cinits [] = [[]] > cinits (x:xs) = [] : map (x:) (cinits xs) > > can someone give me a good explaination? Perhaps it's easier to follow as a list comprehension: cinits [] = [[]] cinits (hd:tl) = [] : [ hd : rest | rest <- cinits tl ] > > (I understand it a bit, but it's really hard for me to figure out how a map > in a map function works.) > > Thank you for your time, > > Tsunkiet From temp.tsun at gmail.com Tue Apr 14 05:16:39 2009 From: temp.tsun at gmail.com (Tsunkiet Man) Date: Tue Apr 14 05:03:10 2009 Subject: [Haskell-cafe] How the following works In-Reply-To: References: Message-ID: Let's see, if I execute it by hand: cinits :: [a] -> [[a]] cinits [] = [[]] cinits (x:xs) = [] : map (x:) (cinits xs) cinits [1,2,3] = [] : map (1:) ( [] : map (2:) ( [] : map (3:) ( [[]]) ) ) = [] : map (1:) ( [] : map (2:) ( [] : map (3:) [[]] ) ) = [] : map (1:) ( [] : map (2:) ( [] : [[3]] ) = [] : map (1:) ( [] : map (2:) ( [[], [3]] ) = [] : map (1:) ( [] : [[2], [2,3]]) = [] : map (1:) ( [[], [2], [2,3]]) = [[],[1], [1,2], [1,2,3]] Well, I understand this part. But isn't there an easier way to "see" the answer? Thank you for your help! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090414/fee7686b/attachment.htm From temp.tsun at gmail.com Tue Apr 14 05:21:14 2009 From: temp.tsun at gmail.com (Tsunkiet Man) Date: Tue Apr 14 05:07:45 2009 Subject: [Haskell-cafe] How the following works In-Reply-To: <200904141100.34386.daniel.is.fischer@web.de> References: <200904141100.34386.daniel.is.fischer@web.de> Message-ID: Let's see... cinits [] = [[]] cinits (hd:tl) = [] : [ hd : rest | rest <- cinits tl ] Well, ehm, I'm trying to understand "map" in "map" functions, however I do understand list comprehensions. But I don't think I can write "any" "map" in "map" function into a list comprehension can I? 2009/4/14 Daniel Fischer > Am Dienstag 14 April 2009 10:39:28 schrieb Tsunkiet Man: > > Hello, > > > > I can hardly imagine how the following code works: > > > > cinits :: [a] -> [[a]] > > cinits [] = [[]] > > cinits (x:xs) = [] : map (x:) (cinits xs) > > > > can someone give me a good explaination? > > Perhaps it's easier to follow as a list comprehension: > > cinits [] = [[]] > cinits (hd:tl) = [] : [ hd : rest | rest <- cinits tl ] > > > > > (I understand it a bit, but it's really hard for me to figure out how a > map > > in a map function works.) > > > > Thank you for your time, > > > > Tsunkiet > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090414/72ed094b/attachment.htm From barsoap at web.de Tue Apr 14 05:27:42 2009 From: barsoap at web.de (Achim Schneider) Date: Tue Apr 14 05:14:31 2009 Subject: [Haskell-cafe] Re: Maybe off-topic -- Writing contracts or software specifications References: Message-ID: <20090414112742.0ac94673@solaris> "Richard O'Keefe" wrote: > If you have a low level of trust, you'll need a great level of > detail, and it still won't help. > Heh. Keep your friends close, your enemies closer. Freelancing, I was always paid per hour, not per feature. From my experience, writing something like "The contractor will work closely with an employee designated by Foo to ensure formal and informal, known or yet to be discovered, specifications are implemented" is the best thing you can do. If you have it, mention your QA and its guidelines. If you don't have it, get both. [1] It's more than enough to boot a bad teamplayer out of his contract, doesn't induce frowns in top coders (SNAFU, as those are the ones you want to hire), does not risk mis-specifying requirements (which, with legal backing, is also SNAFU) and doesn't take longer and/or cost more to work out than the program itself (SNAFU, again). Be sure that not only bugs are fixed, but the reasons they appeared in the first place, too: That's the secret people writing space shuttle control software and similar use. [1] Even if it's just one guy working out things like "Every function must be documented" and me getting a bug report saying "Help text does not mention how to display help text". -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From lennart at augustsson.net Tue Apr 14 05:31:35 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Tue Apr 14 05:18:07 2009 Subject: [Haskell-cafe] How the following works In-Reply-To: References: Message-ID: Assuming you already think you know what cinits does, you can convince yourself using induction. On Tue, Apr 14, 2009 at 11:16 AM, Tsunkiet Man wrote: > Let's see, if I execute it by hand: > > cinits :: [a] -> [[a]] > cinits [] = [[]] > cinits (x:xs) = [] : map (x:) (cinits xs) > > cinits [1,2,3] = [] : map (1:) ( [] : map (2:) ( [] : map (3:) ( [[]]) ) ) > ?????????????????? = [] : map (1:)?( [] : map (2:) ( [] : map (3:) [[]] ) ) > ???????????????????= [] : map (1:) ( [] : map (2:) ( [] : [[3]] ) > ?????????????????? = [] : map (1:) ( [] : map (2:) ( [[], [3]] ) > ???????????????????= [] : map (1:) ( [] : [[2], [2,3]]) > ?????????????????? = [] : map (1:) ( [[], [2], [2,3]]) > ?????????????????? = [[],[1], [1,2], [1,2,3]] > > Well, I understand this part. But isn't there an easier way to "see" the > answer? > > Thank you for your help! > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From lennart at augustsson.net Tue Apr 14 05:32:02 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Tue Apr 14 05:18:33 2009 Subject: [Haskell-cafe] How the following works In-Reply-To: References: <200904141100.34386.daniel.is.fischer@web.de> Message-ID: map f xs = [ f x | x <- xs ] On Tue, Apr 14, 2009 at 11:21 AM, Tsunkiet Man wrote: > Let's see... > > cinits [] = [[]] > cinits (hd:tl) = [] : [ hd : rest | rest ?<- cinits tl ] > > Well, ehm, I'm trying to understand "map" in "map" functions, however I do > understand list comprehensions. But I don't think I can write "any" "map" in > "map" function into a list comprehension can I? > > 2009/4/14 Daniel Fischer >> >> Am Dienstag 14 April 2009 10:39:28 schrieb Tsunkiet Man: >> > Hello, >> > >> > I can hardly imagine how the following code works: >> > >> > cinits :: [a] -> [[a]] >> > cinits [] = [[]] >> > cinits (x:xs) = [] : map (x:) (cinits xs) >> > >> > can someone give me a good explaination? >> >> Perhaps it's easier to follow as a list comprehension: >> >> cinits [] = [[]] >> cinits (hd:tl) = [] : [ hd : rest | rest ?<- cinits tl ] >> >> > >> > (I understand it a bit, but it's really hard for me to figure out how a >> > map >> > in a map function works.) >> > >> > Thank you for your time, >> > >> > Tsunkiet >> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From patai_gergely at fastmail.fm Tue Apr 14 05:33:51 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Tue Apr 14 05:20:23 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> <1239387673.2337.1309952317@webmail.messagingengine.com> Message-ID: <1239701631.23451.1310384879@webmail.messagingengine.com> > And just as IO is unnecessary for behavior (functions of time), it's also > unnecessary for imagery (functions of space). Continuing with the > functional (non-IO) theme, you can give a semantically precise, > composable and simple type of images. Yes, that's a further separation of concerns. Instead of producing an IO action, you produce a data structure to be consumed by the framework. However, there's an interesting question of dealing with feedbacks, i.e. signals affected (or even created and destroyed) by the IO actions resulting from your output. It might sound like too low-level design if you have to rely on IO-bound feedback, but I don't see how it could be put behind a nice abstraction in general. For instance, if you have some large terrain to roam around, you'll have to keep most of it on the disk (static as well as dynamic objects), and it depends on your location and orientation which parts get loaded and discarded/archived at any time. While low-level caching and loading of resources is certainly not the responsibility of the reactive subsystem, it will still have to manage the life cycle of signals. And that's what I'm missing: a nice way to describe this kind of feedback. Grapefruit looks like a possible solution to this problem (assuming it can be made completely dynamic), and then the integration of a Grapefruit-like and a Reactive-like system could be the ultimate solution in the long run. Gergely -- http://www.fastmail.fm - IMAP accessible web-mail From barsoap at web.de Tue Apr 14 05:34:06 2009 From: barsoap at web.de (Achim Schneider) Date: Tue Apr 14 05:20:55 2009 Subject: [Haskell-cafe] Re: Best text editor References: <23018470.post@talk.nabble.com> Message-ID: <20090414113406.6b47c241@solaris> FFT wrote: > Has anyone tried Yi? > Yes, and I figured I'd have to edit the keymap to get productive. While it features a fully functional subset of vim that's more than enough to efficiently edit files, it's not the subset I use... and then I was too lazy to actually do it. Documentation is badly lacking, too, it's like trying to configure xmonad without xmonad-contrib and all the docs. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From bulat.ziganshin at gmail.com Tue Apr 14 06:31:28 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Apr 14 06:27:20 2009 Subject: [Haskell-cafe] Best text editor In-Reply-To: <49E3F6F2.9020508@gmail.com> References: <23018470.post@talk.nabble.com> <49E3F6F2.9020508@gmail.com> Message-ID: <1909493701.20090414143128@gmail.com> Hello Alexandr, Tuesday, April 14, 2009, 6:37:38 AM, you wrote: >> Hi I would like to follow the crowd and find out what text editor everyone >> uses for haskell on windows. > * HippoEdit (http://www.hippoedit.com/) i've tried HippoEdit and don't recommend it. it's work in progress so i immediately hit several bugs -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From patai_gergely at fastmail.fm Tue Apr 14 06:46:59 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Tue Apr 14 06:33:29 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> <40a414c20904110149o27d508c0u7b7efe0391ffa74d@mail.gmail.com> <1239444601.20625.1310024249@webmail.messagingengine.com> <1239541485.27252.1310127905@webmail.messagingengine.com> <1239575289.5053.1310168171@webmail.messagingengine.com> Message-ID: <1239706019.6858.1310393875@webmail.messagingengine.com> > Interesting. I'm testing it on Window though. You're using Linux? Maybe > the scheduling is different. Now I tried it on Windows in VirtualBox, and it still looks quite smooth to me (except that hardware acceleration doesn't seem to work properly through virtualisation, but it's okay as long as I keep the window small enough). However, unlike the Linux version, it does max out the CPU, so the trick with threadDelay 0 doesn't work. Apparently, I'll have to find a real Windows box somewhere, because I couldn't reproduce the jerkiness you're talking about. Gergely -- http://www.fastmail.fm - The way an email service should be From barsoap at web.de Tue Apr 14 06:52:25 2009 From: barsoap at web.de (Achim Schneider) Date: Tue Apr 14 06:39:11 2009 Subject: [Haskell-cafe] Re: Best text editor References: <23018470.post@talk.nabble.com> Message-ID: <20090414125225.0cb02317@solaris> Melanie_Green wrote: > > Hi I would like to follow the crowd and find out what text editor > everyone uses for haskell on windows. > Have you considered using leksah? While it doesn't focus on being an editor, it's still a darn fine way to edit Haskell. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From smithsnorth at gmail.com Tue Apr 14 06:56:04 2009 From: smithsnorth at gmail.com (John Smith) Date: Tue Apr 14 06:42:36 2009 Subject: [Haskell-cafe] Types and hashes of hashes, trouble for a Java-programmer... In-Reply-To: References: <438d2de60904130842q3a209a7ak92a7e234feb210ad@mail.gmail.com> <438d2de60904130959h76568bafgb7952e0f4174c539@mail.gmail.com> Message-ID: <438d2de60904140356t12b8d10ejcf6c83061f1e8eef@mail.gmail.com> Thanks, I was close, but the I was trying to use (something like) this statement without the return: maybe (return Nothing) (flip HashTable.lookup 1000) More or less like this: maybe (Nothing) (flip HashTable.lookup 1000) Which did't work... Guess the return is needed because we use a new monad (Maybe) inside another monad (IO). Petter On Mon, Apr 13, 2009 at 7:45 PM, Lennart Augustsson wrote: > res <- HashTable.lookup h 3 >>= maybe (return Nothing) (flip > HashTable.lookup 1000) > > On Mon, Apr 13, 2009 at 6:59 PM, John Smith wrote: >> Yes, agreed. Got any clue on the original problem (except to use Data.Map)? >> >> On Mon, Apr 13, 2009 at 6:55 PM, Jason Dagit wrote: >>> >>> Others have provided help to answer your question but I'd like to >>> provide a little bit different feedback. >>> >>> On Mon, Apr 13, 2009 at 8:42 AM, John Smith wrote: >>> > Hi, a java-programmer running into trouble while trying to learn >>> > Haskell. >>> > >>> > I try to make a hash containing hashes but can not getting a value out >>> > of >>> > the innermost hash - I keep running into type-trouble where IO and Maybe >>> > monad is getting mixed? >>> > >>> > My attempt: >>> > >>> > removeMaybeHash x = >>> > ? case x of >>> > ? Just ref -> ref >>> > ? Nothing -> HashTable.new (==) (\key -> key) >>> >>> When you see yourself writing a function like this, you could write it >>> like this instead: >>> removeMaybeHash (Just ref) = ref >>> removeMaybeHash Nothing = HashTable.new (==) (\key -> key) >>> >>> Hopefully you agree this 2 line version is more clear. ?You could go >>> further of course and use the function 'maybe' from the prelude, and >>> pass the function 'id' instead of \key -> key, but I don't want to >>> overwhelm you. >>> >>> Good luck, >>> Jason >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > From claus.reinke at talk21.com Tue Apr 14 08:07:33 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue Apr 14 07:54:11 2009 Subject: [Haskell-cafe] Non-atomic "atoms" for type-level programming Message-ID: The recent GHC trac ticket revision reminded me of the old open type-sharing problem with type tags and record labels: - if type-level tags (such as 'data TTrue'/'data TFalse') are declared repeatedly in separate modules, they represent separate types, preventing shared use (your type-level predicate doesn't return my version of 'TTrue'/'TFalse') - if record field labels (as used in your run-of-the-mill extensible record library) have to be declared, that is not only inconvenient, but prevents sharing of field labels over independent code bases (see the old Haskell' ticket #92 for discussion http://hackage.haskell.org/trac/haskell-prime/wiki/FirstClassLabels ; also http://hackage.haskell.org/trac/ghc/ticket/1872 for alternative extensible records libs) Since Haskell has no concept of type sharing, the only way to express this is to declare types in a common import. But there is no way for that common import to predict all possible future uses, and we can't just keep adding more labels/tags to it, forcing all dependencies to be updated and kept in sync. Using Template Haskell, and QuasiQuotes in particular, we can now at least work around this issue, by splitting the atoms:-) - 'undefined :: Tag' becomes 'undefined :: (TT :. Ta :. Tg)' - 'label :: Label' becomes '(Ll :< La :< Lb :< Le :< Ll) :: (Ll :< La :< Lb :< Le :< Ll)' - a common import, Data.Label, provides type letters and combinators: 'data La = La' and 'data a :< b = a :< b' 'data Ta' and 'data a :. b' .. - quasiquoting and Show instances, also provided by Data.Label, try to hide the internal structure of labels and tags, at least at expression level. Since there is no quasiquoting at type-level (why?), generating type synonyms seems the best we can do there.. - since record field labels are constructed from type letters, this would also provide a basis for - type-level numbers (type-level quasiquoting would help, though) - label ordering: http://hackage.haskell.org/trac/ghc/ticket/2104 http://hackage.haskell.org/trac/ghc/ticket/1894 In actual use, this is what tags and labels from Data.Label look like: ------------- -- the usual extensible-records-as-nested-pairs data label := value = label := value deriving Show data field :& record = field :& record deriving Show infixr :& -- no quasiquoting for types:-(, so generate type synonyms instead $(genTypeTag "TTrue") $(genTypeTag "TFalse") -- a type-level predicate, using shared tags TTrue/TFalse class HasField record label tbool | label record -> tbool instance HasField () label TFalse instance HasField ((label:=value):&record) label TTrue instance HasField record label tbool => HasField (field:&record) label tbool -- record field selection, driven by field label types class Select record label value where (!) :: record -> label -> value instance .. -- some example records -- no need to declare field labels, and they will be -- shared with other importers of Data.Label! a = ([$l|this|] := True) :&([$l|that|] := "hi") :&() b = ([$l|that|] := "there") :&([$l|x|] := 100) :&([$l|y|] := 200) :&() -- we don't even need label values for this, -- type tags are sufficient, as long as we don't -- evaluate the (undefined) values of tags c = ([$t|this|] := 'x') :&([$t|y|] := ()) :&() -- testing Show and record selection records = do print a print b print c print $ (a ! [$l|this|]) print $ (c ! [$t|this|]) print $ (a ! [$l|that|]) ++ ", " ++ (b ! [$l|that|]) ------------- *Main> [$l|label|] label *Main> :t [$l|label|] [$l|label|] :: Ll :< (La :< (Lb :< (Le :< Ll))) *Main> [$l|label|] `seq` () () *Main> [$t|label|] label *Main> :t [$t|label|] [$t|label|] :: Tl :. (Ta :. (Tb :. (Te :. Tl))) *Main> [$t|label|] `seq` () *** Exception: Prelude.undefined *Main> :t [$l|100|] [$l|100|] :: L1 :< (L0 :< L0) *Main> records (this := True) :& ((that := "hi") :& ()) (that := "there") :& ((x := 100) :& ((y := 200) :& ())) (this := 'x') :& ((y := ()) :& ()) True 'x' "hi, there" ------------- For example code, see http://community.haskell.org/~claus/misc/Data/Label.hs http://community.haskell.org/~claus/misc/Data/Label/TH.hs http://community.haskell.org/~claus/misc/labels.hs Claus From r.a.niemeijer at tue.nl Tue Apr 14 08:40:08 2009 From: r.a.niemeijer at tue.nl (Niemeijer, R.A.) Date: Tue Apr 14 08:26:43 2009 Subject: [Haskell-cafe] Looking for the fastest Haskell primes algorithm Message-ID: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> Today I happened to need a large list of prime numbers. Obviously this is a well-known problem, so I figured there would be something on Hackage that I could use. Surprisingly, there isn't, or if there is it's not easy to find. Searching for prime or primes on Hackage reveals nothing. Searching for primes on Hayoo gives Codec.Encryption.RSA.NumberTheory, but that uses the inefficient one-liner implementation. The HaskellWiki article on primes (http://www.haskell.org/haskellwiki/Prime_numbers) has a number of implementations, but the faster they get, the longer and uglier they become. Since it's such a common problem I'd say it would be a good idea to add a package to Hackage that exports primes :: [Integer] and hides the ugly implementation details. Data.Numbers.Primes seems a logical choice for the namespace, but I'm open to suggestions. The trick then is to find the most efficient implementation of primes. The Haskell wiki article mentions ONeillPrimes.hs as one of the fastest ones, but maybe there's a faster version. So my question is: does anybody know what the fastest Haskell algorithm for generating primes is? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090414/2ea6a3d3/attachment.htm From wagner.andrew at gmail.com Tue Apr 14 08:47:12 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Tue Apr 14 08:33:42 2009 Subject: [Haskell-cafe] Looking for the fastest Haskell primes algorithm In-Reply-To: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> References: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> Message-ID: Some other ideas for things to put in this package possibly: is_prime :: Int -> Bool nth_prime :: Int -> Int -- or Int -> Integer prime_factors :: Int -> [Int] I'm assuming there are faster ways of doing the first 2 than by just simply looking through all of primes. Someone should also look through Euler - I'm sure that will generate other ideas of things that could be useful in playing with primes. On Tue, Apr 14, 2009 at 8:40 AM, Niemeijer, R.A. wrote: > Today I happened to need a large list of prime numbers. Obviously this is > a well-known problem, so I figured there would be something on Hackage that > I could use. Surprisingly, there isn?t, or if there is it?s not easy to > find. Searching for prime or primes on Hackage reveals nothing. Searching > for primes on Hayoo gives Codec.Encryption.RSA.NumberTheory, but that uses > the inefficient one-liner implementation. The HaskellWiki article on primes > (http://www.haskell.org/haskellwiki/Prime_numbers) has a number of > implementations, but the faster they get, the longer and uglier they become. > > > > Since it?s such a common problem I?d say it would be a good idea to add a > package to Hackage that exports > > primes :: [Integer] > > and hides the ugly implementation details. Data.Numbers.Primes seems a > logical choice for the namespace, but I?m open to suggestions. > > > > The trick then is to find the most efficient implementation of primes. The > Haskell wiki article mentions ONeillPrimes.hs as one of the fastest ones, > but maybe there?s a faster version. So my question is: does anybody know > what the fastest Haskell algorithm for generating primes is? > > _______________________________________________ > 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/20090414/2ba0382c/attachment.htm From ekirpichov at gmail.com Tue Apr 14 08:57:29 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Tue Apr 14 08:44:00 2009 Subject: [Haskell-cafe] Looking for the fastest Haskell primes algorithm In-Reply-To: References: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> Message-ID: <5e0214850904140557i251935f8gf90402c65dfb470@mail.gmail.com> I'd suggest also primesFrom :: Integer -> [Integer] and probably a separate function nextPrime :: Integer -> Integer 2009/4/14 Andrew Wagner : > Some other ideas for things to put in this package possibly: > is_prime :: Int -> Bool > nth_prime :: Int -> Int -- or Int -> Integer > prime_factors :: Int -> [Int] > > I'm assuming there are faster ways of doing the first 2 than by just simply > looking through all of primes. Someone should also look through Euler - I'm > sure that will generate other ideas of things that could be useful in > playing with primes. > On Tue, Apr 14, 2009 at 8:40 AM, Niemeijer, R.A. > wrote: >> >> Today I happened to need a large list of prime numbers. Obviously this is >> a well-known problem, so I figured there would be something on Hackage that >> I could use. Surprisingly, there isn?t, or if there is it?s not easy to >> find. Searching for prime or primes on Hackage reveals nothing. Searching >> for primes on Hayoo gives Codec.Encryption.RSA.NumberTheory, but that uses >> the inefficient one-liner implementation. The HaskellWiki article on primes >> (http://www.haskell.org/haskellwiki/Prime_numbers) has a number of >> implementations, but the faster they get, the longer and uglier they become. >> >> >> >> Since it?s such a common problem I?d say it would be a good idea to add a >> package to Hackage that exports >> >> primes :: [Integer] >> >> and hides the ugly implementation details. Data.Numbers.Primes seems a >> logical choice for the namespace, but I?m open to suggestions. >> >> >> >> The trick then is to find the most efficient implementation of primes. The >> Haskell wiki article mentions ONeillPrimes.hs as one of the fastest ones, >> but maybe there?s a faster version. So my question is: does anybody know >> what the fastest Haskell algorithm for generating primes is? >> >> _______________________________________________ >> 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 > > -- Eugene Kirpichov Web IR developer, market.yandex.ru From magnicida at gmail.com Tue Apr 14 08:56:45 2009 From: magnicida at gmail.com (Juan Pedro Bolivar Puente) Date: Tue Apr 14 08:45:22 2009 Subject: [Haskell-cafe] Best text editor In-Reply-To: References: <23018470.post@talk.nabble.com> <49E2E1EB.3040100@alumni.caltech.edu> <873acc2qdm.fsf@malde.org> <49E3B776.6070800@alumni.caltech.edu> Message-ID: <49E4880D.7090200@gmail.com> > and Visual Haskell had some unique features (such as hovering tooltips > showing types) that are now found in the F# editor, and should now be easier > to implement with the recent GHC API (I guess). haskell-mode for Emacs does show the type signature of standard functions in the mini-buffer when the cursor is over them. JP From wss at cs.nott.ac.uk Tue Apr 14 09:01:11 2009 From: wss at cs.nott.ac.uk (Wouter Swierstra) Date: Tue Apr 14 08:47:45 2009 Subject: [Haskell-cafe] The Monad.Reader (14) - Call for copy Message-ID: <2EF3D210-765D-44AB-8C10-E61BDE74D37B@cs.nott.ac.uk> Call for Copy The Monad.Reader - Issue 14 Please consider writing something for the next issue of The Monad.Reader. The deadline for Issue 14 is: ** May 15, 2009 ** The Monad.Reader is a electronic magazine about all things Haskell. Check out the website and browse the previous editions to learn more: http://www.haskell.org/haskellwiki/The_Monad.Reader * Submission Details * Get in touch if you intend to submit something -- the sooner you let me know what you're up to, the better. Please submit articles for the next issue to me by e-mail (wouter at chalmers.se). Articles should be written according to the guidelines available from: http://www.haskell.org/haskellwiki/The_Monad.Reader Please submit your article in PDF, together with any source files you used. The sources will be released together with the magazine under a BSD license. Looking forward to your submission, Wouter From martijn at van.steenbergen.nl Tue Apr 14 09:01:54 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Tue Apr 14 08:48:26 2009 Subject: [Haskell-cafe] Looking for the fastest Haskell primes algorithm In-Reply-To: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> References: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> Message-ID: <49E48942.6040807@van.steenbergen.nl> Niemeijer, R.A. wrote: > Since it?s such a common problem I?d say it would be a good idea to add > a package to Hackage that exports > > primes :: [Integer] > > and hides the ugly implementation details. Data.Numbers.Primes seems a > logical choice for the namespace, but I?m open to suggestions. Excellent idea. Picking the most efficient implementation from the start isn't really necessary; if you find a faster implementation later you can just upload a new version. The API is unlikely to change in such a case anyway. Martijn. From ekmett at gmail.com Tue Apr 14 09:05:41 2009 From: ekmett at gmail.com (Edward Kmett) Date: Tue Apr 14 08:52:11 2009 Subject: [Haskell-cafe] Looking for the fastest Haskell primes algorithm In-Reply-To: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> References: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> Message-ID: <7fb8f82f0904140605k147e405dyf28060af003427c0@mail.gmail.com> You might want to start with the Sieve of Atkin: http://en.wikipedia.org/wiki/Sieve_of_Atkin -Edward On Tue, Apr 14, 2009 at 8:40 AM, Niemeijer, R.A. wrote: > Today I happened to need a large list of prime numbers. Obviously this is > a well-known problem, so I figured there would be something on Hackage that > I could use. Surprisingly, there isn?t, or if there is it?s not easy to > find. Searching for prime or primes on Hackage reveals nothing. Searching > for primes on Hayoo gives Codec.Encryption.RSA.NumberTheory, but that uses > the inefficient one-liner implementation. The HaskellWiki article on primes > (http://www.haskell.org/haskellwiki/Prime_numbers) has a number of > implementations, but the faster they get, the longer and uglier they become. > > > > Since it?s such a common problem I?d say it would be a good idea to add a > package to Hackage that exports > > primes :: [Integer] > > and hides the ugly implementation details. Data.Numbers.Primes seems a > logical choice for the namespace, but I?m open to suggestions. > > > > The trick then is to find the most efficient implementation of primes. The > Haskell wiki article mentions ONeillPrimes.hs as one of the fastest ones, > but maybe there?s a faster version. So my question is: does anybody know > what the fastest Haskell algorithm for generating primes is? > > _______________________________________________ > 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/20090414/39a8be23/attachment.htm From aruiz at um.es Tue Apr 14 09:10:42 2009 From: aruiz at um.es (Alberto Ruiz) Date: Tue Apr 14 08:57:18 2009 Subject: [Haskell-cafe] ANN: hmatrix-static: statically-sized linear algebra In-Reply-To: <4cf038ee0904111952r238acf8drd4736d484219df5d@mail.gmail.com> References: <4cf038ee0904111827h52cb5a38q84852cac0170ad30@mail.gmail.com> <87ab6m7gyc.fsf@columbia.edu> <4cf038ee0904111952r238acf8drd4736d484219df5d@mail.gmail.com> Message-ID: <49E48B52.3040401@um.es> Hi Reiner, Fantastic work! User-friendly static dimension checking is an essential feature for any decent linear algebra library. Your interface using quasiquotation and view patterns is very elegant and practical. I am happy that hmatrix is useful, but I'm afraid that its primitive dynamic interface will no longer be used :) Many thanks for your excellent work! Alberto Reiner Pope wrote: > There should be essentially no performance penalty in going from > hmatrix to hmatrix-static, for most functions. The Vector and Matrix > types I define are just newtypes of hmatrix's Vector and Matrix types, > so they will have the same runtime representation. > > There are a few cases where performance could potentially differ, > described below. > > Reflecting and reifying Ints (i.e. converting between types and values): > (The ideas for this come from the Implicit Configurations paper[1].) > Some Int arguments in hmatrix have been written as types in > hmatrix-static, such as the function "constant". > > hmatrix type: > constant :: Element a => a -> Int -> Vector a > hmatrix-static type: > constant :: (Element a, PositiveT n) => a -> Vector n a > > The PositiveT constraint is essentially a way of passing the Int > parameter as an implicit parameter. To demonstrate this, we use two > library functions which allow us to convert from Ints to types with > PositiveT constraints, and back: > > value :: PositiveT n => Proxy n -> Int -- type -> value > reifyPositive :: Int -> (forall n. PositiveT n => n -> r) -> r -- > value -> type. > > The use of these functions is nice in some cases, such as "constant" > above, because it allows us to pass parameters implicitly. On the > other hand, the conversion between types and values imposes an O(log > n) cost, where n is the size of the number we are converting. In my > experience, this cost has not been significant (although it was > previously, when I used a naive O(n) reifyIntegral implementation!). > > Newtype conversion costs: > Occasionally, unwrapping newtypes can actually have a runtime cost. > For instance, the hmatrix-static function > > joinU :: Storable t => [Vector Unknown t] -> Vector Unknown t > > needs to do a conversion :: [Vector Unknown t] -> [HMatrix.Vector t]. > Now, the conversion "unwrap :: Vector Unknown t -> HMatrix.Vector t" > is a noop, as it unwraps a newtype. However, to get the list > conversion, we need to do "map unwrap", which requires mapping a noop > over a list. However, because of map's recursion, GHC may not be able > to recognise that "map unwrap" is a noop, and traverse the list > anyway, causing a performance loss. > > However, there aren't many recursive data structures used in > hmatrix-static, so this problem mostly doesn't exist. > > Cheers, > Reiner > > [1] http://okmij.org/ftp/Haskell/types.html#Prepose > > On Sun, Apr 12, 2009 at 12:18 PM, Xiao-Yong Jin wrote: >> Reiner Pope writes: >> >>> Hi everyone, >>> >>> I am pleased to announce hmatrix-static[1], a thin wrapper over >>> Alberto Ruiz's excellent hmatrix library[2] for linear algebra. >>> >>> The main additions of hmatrix-static over hmatrix are: >>> - vectors and matrices have their length encoded in their types >>> - vectors and matrices may be constructed and destructed using view >>> patterns, affording a clean, safe syntax. >>> >>> hmatrix-static includes statically-sized versions of hmatrix's linear >>> algebra routines, including: >>> - simple arithmetic (addition, multiplication, of matrices and vectors) >>> - matrix inversion and least squares solutions >>> - determinants / rank / condition number >>> - computing eigensystems >>> - factorisations: svd, qr, cholesky, hessenberg, schur, lu >>> - exponents and sqrts of matrices >>> - norms >>> >>> See http://code.haskell.org/hmatrix-static/examples/ for example code. >>> >> This is quite interesting. I would like to know the >> performance penalty of such a wrapper. I'll test it by >> myself when I've got time. But can you give me some idea of >> how such a wrapper can be optimized by ghc in terms of space >> and time performance? >> -- >> c/* __o/* >> <\ * (__ >> */\ < >> _______________________________________________ >> 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 nowgate at yahoo.com Tue Apr 14 09:15:46 2009 From: nowgate at yahoo.com (michael rice) Date: Tue Apr 14 09:02:16 2009 Subject: [Haskell-cafe] Printing list of enum type Message-ID: <435878.49405.qm@web31107.mail.mud.yahoo.com> What do I need to add to this Color enum type to print a list of them? Michael =============== data Color ??? = Red ??? | Blue ??? | Green ??? | Yellow ??? | Orange ??? | Brown ??? | White ??? | Black instance Show Color where ??? show Red?? = "Red" ??? show Blue? = "Blue" ??? show Green = "Green" ??? show Yellow = "Yellow" ??? show Orange = "Orange" ??? show Brown = "Brown" ??? show White = "White" ??? show Black = "Black" ====================== Ok, modules loaded: Main. *Main> Red Red *Main> Black Black *Main> [Red Black White] :1:1: ??? Couldn't match expected type `Color -> Color -> t' ?????????? against inferred type `Color' ??? In the expression: Red Black White ??? In the expression: [Red Black White] ??? In the definition of `it': it = [Red Black White] -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090414/3d726dc9/attachment.htm From ekirpichov at gmail.com Tue Apr 14 09:18:34 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Tue Apr 14 09:05:06 2009 Subject: [Haskell-cafe] Printing list of enum type In-Reply-To: <435878.49405.qm@web31107.mail.mud.yahoo.com> References: <435878.49405.qm@web31107.mail.mud.yahoo.com> Message-ID: <5e0214850904140618q6afc624au44afd35a741740f4@mail.gmail.com> 1. data Color = Red | Green | Blue deriving (Show) 2. [Red,Black,White] 2009/4/14 michael rice : > What do I need to add to this Color enum type to print a list of them? > > Michael > > =============== > > data Color > ??? = Red > ??? | Blue > ??? | Green > ??? | Yellow > ??? | Orange > ??? | Brown > ??? | White > ??? | Black > > instance Show Color where > ??? show Red?? = "Red" > ??? show Blue? = "Blue" > ??? show Green = "Green" > ??? show Yellow = "Yellow" > ??? show Orange = "Orange" > ??? show Brown = "Brown" > ??? show White = "White" > ??? show Black = "Black" > > ====================== > > Ok, modules loaded: Main. > *Main> Red > Red > *Main> Black > Black > *Main> [Red Black White] > > :1:1: > ??? Couldn't match expected type `Color -> Color -> t' > ?????????? against inferred type `Color' > ??? In the expression: Red Black White > ??? In the expression: [Red Black White] > ??? In the definition of `it': it = [Red Black White] > > > > > > > > _______________________________________________ > 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 wagner.andrew at gmail.com Tue Apr 14 09:19:00 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Tue Apr 14 09:05:31 2009 Subject: [Haskell-cafe] Printing list of enum type In-Reply-To: <435878.49405.qm@web31107.mail.mud.yahoo.com> References: <435878.49405.qm@web31107.mail.mud.yahoo.com> Message-ID: You don't need to add anything, you just need to use list notation correctly. Try typing [Red, Black, White] in at the prompt instead. The commas are part of the list syntax. On Tue, Apr 14, 2009 at 9:15 AM, michael rice wrote: > What do I need to add to this Color enum type to print a list of them? > > Michael > > =============== > > data Color > = Red > | Blue > | Green > | Yellow > | Orange > | Brown > | White > | Black > > instance Show Color where > show Red = "Red" > show Blue = "Blue" > show Green = "Green" > show Yellow = "Yellow" > show Orange = "Orange" > show Brown = "Brown" > show White = "White" > show Black = "Black" > > ====================== > > Ok, modules loaded: Main. > *Main> Red > Red > *Main> Black > Black > *Main> [Red Black White] > > :1:1: > Couldn't match expected type `Color -> Color -> t' > against inferred type `Color' > In the expression: Red Black White > In the expression: [Red Black White] > In the definition of `it': it = [Red Black White] > > > > > > > > _______________________________________________ > 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/20090414/41ac9df7/attachment.htm From nowgate at yahoo.com Tue Apr 14 10:30:06 2009 From: nowgate at yahoo.com (michael rice) Date: Tue Apr 14 10:16:37 2009 Subject: [Haskell-cafe] Printing list of enum type Message-ID: <494030.79785.qm@web31106.mail.mud.yahoo.com> Dumb, dumb, dumb, dumb, DUMB!, he Lisped. Thanks. Michael --- On Tue, 4/14/09, Andrew Wagner wrote: From: Andrew Wagner Subject: Re: [Haskell-cafe] Printing list of enum type To: "michael rice" Cc: haskell-cafe@haskell.org Date: Tuesday, April 14, 2009, 9:19 AM You don't need to add anything, you just need to use list notation correctly. Try typing?[Red, Black, White] in at the prompt instead. The commas are part of the list syntax. On Tue, Apr 14, 2009 at 9:15 AM, michael rice wrote: What do I need to add to this Color enum type to print a list of them? Michael =============== data Color ??? = Red ??? | Blue ??? | Green ??? | Yellow ??? | Orange ??? | Brown ??? | White ??? | Black instance Show Color where ??? show Red?? = "Red" ??? show Blue? = "Blue" ??? show Green = "Green" ??? show Yellow = "Yellow" ??? show Orange = "Orange" ??? show Brown = "Brown" ??? show White = "White" ??? show Black = "Black" ====================== Ok, modules loaded: Main. *Main> Red Red *Main> Black Black *Main> [Red Black White] :1:1: ??? Couldn't match expected type `Color -> Color -> t' ?????????? against inferred type `Color' ??? In the expression: Red Black White ??? In the expression: [Red Black White] ??? In the definition of `it': it = [Red Black White] _______________________________________________ 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/20090414/b1dba852/attachment.htm From g9ks157k at acme.softbase.org Tue Apr 14 10:49:45 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Tue Apr 14 10:36:19 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: <1239381666.12202.1309941005@webmail.messagingengine.com> References: <1239381666.12202.1309941005@webmail.messagingengine.com> Message-ID: <200904141649.45601.g9ks157k@acme.softbase.org> Am Freitag, 10. April 2009 18:41 schrieb Patai Gergely: > is based on some unsafePerformIO dark magic (that might easily break > depending on many factors) I wonder if this breaks referential transparency. Say, you define a signal s and use s twice in some expression. s may be evaluated once and it maybe evaluated twice. Does this make a difference? In the Haddock docs, you say that repeated evaluation of the same value is prevented by caching. However, caching probably only works if the signal in question is only evaluated once. If it?s evaluated twice, the second ?instance? probably cannot reuse cached values of the first ?instance?. Is it possible that thereby the second ?instance? has different values than the first one? A well known FRP problem is that the values of a signal with internal state (an accumulating signal) depend on the time when the signal is started, i.e., when accumulation starts. When are your signals started? At evaluation time? If yes, doesn?t this mean that the meaning of a signal depends on evaluation time so that evaluating the same signal expression twice actually results in two different signals? Best wishes, Wolfgang From g9ks157k at acme.softbase.org Tue Apr 14 10:52:02 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Tue Apr 14 10:38:34 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: <1239701631.23451.1310384879@webmail.messagingengine.com> References: <1239381666.12202.1309941005@webmail.messagingengine.com> <1239701631.23451.1310384879@webmail.messagingengine.com> Message-ID: <200904141652.02560.g9ks157k@acme.softbase.org> Am Dienstag, 14. April 2009 11:33 schrieb Patai Gergely: > and then the integration of a Grapefruit-like and a Reactive-like system > could be the ultimate solution in the long run. What do you think, Grapefruit is lacking, compared to Reactive? Best wishes, Wolfgang From rodrigo.bonifacio at uol.com.br Tue Apr 14 10:54:07 2009 From: rodrigo.bonifacio at uol.com.br (rodrigo.bonifacio) Date: Tue Apr 14 10:40:44 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] Message-ID: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090414/72f608f7/attachment.htm From lrpalmer at gmail.com Tue Apr 14 11:01:37 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Apr 14 10:48:07 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> Message-ID: <7ca3f0160904140801s53645c62ob29f8ee19c80ff6a@mail.gmail.com> On Tue, Apr 14, 2009 at 8:54 AM, rodrigo.bonifacio < rodrigo.bonifacio@uol.com.br> wrote: > Dear Sirs, > > I guess this is a very simple question. How can I convert IO [XmlTree] to > just a list of XmlTree? > This is very important: you cannot. But you can still get your hands on one inside a do block. As in, if you have tree :: IO [XmlTree], then you can say, eg. printTree = do t <- tree print t Inside this block, t is an [XmlTree], and it is passed to print. Intutively, when you see x <- y inside a do block, if y :: IO a, for some type a, then x :: a. But there is no function that will get you from IO [XmlTree] -> [XmlTree], you have to use binding like this. Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090414/7fbef14b/attachment.htm From asandroq at gmail.com Tue Apr 14 11:01:57 2009 From: asandroq at gmail.com (Alex Queiroz) Date: Tue Apr 14 10:48:29 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> Message-ID: <54e12800904140801n6676c912le673537725a855f5@mail.gmail.com> Hallo, On 4/14/09, rodrigo.bonifacio wrote: > > > Dear Sirs, > > I guess this is a very simple question. How can I convert IO [XmlTree] to > just a list of XmlTree? > The short answer is: You cannot. The longer answer is: Only put things in the IO monad when you need to interact with the "outside", i. e., reading, displaying etc. Cheers, -- -alex http://www.ventonegro.org/ From frodo at theshire.org Tue Apr 14 11:01:51 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Apr 14 10:48:46 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> Message-ID: On Tue, Apr 14, 2009 at 4:54 PM, rodrigo.bonifacio wrote: > Dear Sirs, > > I guess this is a very simple question. How can I convert IO [XmlTree] to > just a list of XmlTree? Quick and dirty answer: unsafePerformIO. That's an easy finding on Hoogle: http://www.haskell.org/hoogle/?hoogle=IO+a+-%3E+a Anyhow, as the name suggest, the function is "unsafe", so you better know what you're doing. Bye, Cristiano From frodo at theshire.org Tue Apr 14 11:08:02 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Apr 14 10:54:52 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: <7ca3f0160904140801s53645c62ob29f8ee19c80ff6a@mail.gmail.com> References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> <7ca3f0160904140801s53645c62ob29f8ee19c80ff6a@mail.gmail.com> Message-ID: On Tue, Apr 14, 2009 at 5:01 PM, Luke Palmer wrote: > ... > This is very important: you cannot. I'd answer "You shouldn't, unless you know what you are doing". In some cases, not only is unsafePerformIO desirable but also necessary (I'm thinking of Debug.Trace). Cristiano From g9ks157k at acme.softbase.org Tue Apr 14 11:08:34 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Tue Apr 14 10:55:07 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: <1239461836.10283.1310044611@webmail.messagingengine.com> References: <1239381666.12202.1309941005@webmail.messagingengine.com> <1239461836.10283.1310044611@webmail.messagingengine.com> Message-ID: <200904141708.34479.g9ks157k@acme.softbase.org> Am Samstag, 11. April 2009 16:57 schrieb Patai Gergely: > > Any idea how Elerea compares to Grapefruit? It's great to see a lot of > > competition in the FRP arena, but I hope in the end this results in a > > really usable and scalable FRP system for Haskell :-) > > I think Wolfgang can judge this better, because I don't really know the > innards of Grapefruit, I didn?t have a deep look at Elerea so far but looked at the Haddock docs. If I understand correctly, Elerea?s signals construct mutable variables for caching their current values when they are evaluated. This happens using unsafePerformIO. Grapefruit?s DSignals and SSignals use a purely functional data structure to represent several possible future values of whom only the ones which are actually occuring are evaluated. This data structure is created using unsafeInterleaveIO. So Elerea seems to have to take special care to not break referential transparency. Grapefruit has to take care only with CSignals since only these are using unsafePerformIO internally. Since Grapefruit uses ordinary expression evaluation for evaluating signal values, it can probably make use of certain compiler optimizations. Elerea?s evaluation seems to be driven by hand-coded IO actions so that use of such compiler optimizations is certainly not possible. Both Grapefruit and Elerea probably need a way to fix a signal to a specific starting time. Grapefruit does this using era type parameters. Elerea doesn?t seem to do anything about this at the moment. Patai, could you please correct me where I?m wrong and clarify the points which are still unclear to me? Best wishes, Wolfgang From lrpalmer at gmail.com Tue Apr 14 11:09:15 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Apr 14 10:55:45 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> Message-ID: <7ca3f0160904140809y528e6282y12fc5c53f023509a@mail.gmail.com> On Tue, Apr 14, 2009 at 9:01 AM, Cristiano Paris wrote: > On Tue, Apr 14, 2009 at 4:54 PM, rodrigo.bonifacio > wrote: > > Dear Sirs, > > > > I guess this is a very simple question. How can I convert IO [XmlTree] to > > just a list of XmlTree? > > Quick and dirty answer: unsafePerformIO. Please don't say that. He's a beginner. You realize that the path of least resistance will be to use it, right? You see why that's not a good thing? Even experts don't use this function. (To the O.P.: don't use it) Luke > > > That's an easy finding on Hoogle: > > http://www.haskell.org/hoogle/?hoogle=IO+a+-%3E+a > > Anyhow, as the name suggest, the function is "unsafe", so you better > know what you're doing. > > Bye, > > Cristiano > _______________________________________________ > 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/20090414/d021d1d4/attachment.htm From wagner.andrew at gmail.com Tue Apr 14 11:12:02 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Tue Apr 14 10:58:33 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> Message-ID: Here's another way of looking at what others have already said. The only way you can do that is within the scope of another IO action. For example: outputXmlTrees :: IO () outputXmlTrees = do trees <- inputXmlTrees; let newTrees = transform trees; print . show $ newTrees Notice a few things: - First, the line "trees <- inputXmlTrees" effectively takes an IO [XmlTree] and turns it into a [XmlTrees]. That is, it runs the IO action inputXmlTrees, and gives you the resulting list of XmlTrees to work with. - You can then pass these off to a pure function which will monkey around with them in a pure (non-IO) context - You must do this in an IO action, however, and any monadic action gets its type from the last line. Thus, the last line must be of type IO something. In this case, it is simply the action that would print out the trees. - Thus, this gives you a way to glue together different IO actions and pure actions and combine them into larger IO actions Hope this clarifies On Tue, Apr 14, 2009 at 10:54 AM, rodrigo.bonifacio < rodrigo.bonifacio@uol.com.br> wrote: > Dear Sirs, > > I guess this is a very simple question. How can I convert IO [XmlTree] to > just a list of XmlTree? > > Regards, > > Rodrigo. > > > > _______________________________________________ > 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/20090414/53c52e79/attachment.htm From vanenkj at gmail.com Tue Apr 14 11:13:51 2009 From: vanenkj at gmail.com (John Van Enk) Date: Tue Apr 14 11:00:21 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> Message-ID: > Quick and dirty answer: unsafePerformIO. You can do a lot of cool things with a table saw if you take the blade guard off. On Tue, Apr 14, 2009 at 11:01 AM, Cristiano Paris wrote: > On Tue, Apr 14, 2009 at 4:54 PM, rodrigo.bonifacio > wrote: > > Dear Sirs, > > > > I guess this is a very simple question. How can I convert IO [XmlTree] to > > just a list of XmlTree? > > Quick and dirty answer: unsafePerformIO. > > That's an easy finding on Hoogle: > > http://www.haskell.org/hoogle/?hoogle=IO+a+-%3E+a > > Anyhow, as the name suggest, the function is "unsafe", so you better > know what you're doing. > > Bye, > > Cristiano > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090414/8075d70c/attachment.htm From bulat.ziganshin at gmail.com Tue Apr 14 11:18:33 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Apr 14 11:06:42 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> Message-ID: <1169720155.20090414191833@gmail.com> Hello rodrigo.bonifacio, Tuesday, April 14, 2009, 6:54:07 PM, you wrote: > I guess this is a very simple question. How can I convert IO > [XmlTree] to just a list of XmlTree? IO [XmlTree] is an action returning [XmlTree]. so to "convert" it to [XmlTree] you just need to execute it in IO monad: value <- action i suggest you to read http://haskell.org/haskellwiki/IO_inside in order to manage IO monad -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From frodo at theshire.org Tue Apr 14 11:24:40 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Apr 14 11:11:33 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: <7ca3f0160904140809y528e6282y12fc5c53f023509a@mail.gmail.com> References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> <7ca3f0160904140809y528e6282y12fc5c53f023509a@mail.gmail.com> Message-ID: On Tue, Apr 14, 2009 at 5:09 PM, Luke Palmer wrote: > ... > Please don't say that. ?He's a beginner. > You realize that the path of least resistance will be to use it, right? > You see why that's not a good thing? > Even experts don't use this function. > (To the O.P.: ?don't use it) Mmmh, sorry Luke but I don't understand this ostracism. unsafePerformIO is not "evil" by itself, it's there for a purpose and, as for anything else in the language, it's better to understand when to use it and when not rather than just knowing that is something that MUST not be used, without any further explanation. More, from my personal experience, knowing unsafePerformIO helped me understand better what Monads are and how they should be used. I wounder what so-called "experts" have to say about this. Cristiano From bulat.ziganshin at gmail.com Tue Apr 14 11:25:06 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Apr 14 11:11:49 2009 Subject: win64 ghc version Re[4]: [Haskell-cafe] GHC needs a 64 bit machine to be fast? In-Reply-To: References: <49DC5CD8.7080609@centrum.cz> <1611609764.20090408134751@gmail.com> Message-ID: <1332606133.20090414192506@gmail.com> Hello Peter, Wednesday, April 8, 2009, 2:42:24 PM, you wrote: if you need win64 ghc version - add yourself to CC list of http://hackage.haskell.org/trac/ghc/ticket/1884 > Well, make that 2! :-) > On Wed, Apr 8, 2009 at 11:47 AM, Bulat Ziganshin > wrote: > Hello Peter, > > Wednesday, April 8, 2009, 12:58:25 PM, you wrote: > > No. it seems that i'm only user asking GHC team for 64-bit version > >> Regarding that, is it possible to generate 64-bit code using GHC on Windows? > >> On Wed, Apr 8, 2009 at 10:17 AM, FFT wrote: >> >> On Wed, Apr 8, 2009 at 1:14 AM, Karel Gardas wrote: ?>>> ?>>> Hello, ?>>> ?>>> perhaps you are hit by following issue? ?>>> http://hackage.haskell.org/trac/ghc/ticket/594 >> >> >> The benchmark isn't using the native code generator, it compiles via >> ?C, as I understand. >> >> ?What are other people's timings on 32 bit Linux machines? >> >> _______________________________________________ >> ?Haskell-Cafe mailing list >> ?Haskell-Cafe@haskell.org >> ?http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > >> > > > > -- > Best regards, > ?Bulat ? ? ? ? ? ? ? ? ? ? ? ? ? ?mailto:Bulat.Ziganshin@gmail.com > > > -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From gwern0 at gmail.com Tue Apr 14 11:25:19 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Tue Apr 14 11:12:14 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> Message-ID: On Tue, Apr 14, 2009 at 10:54 AM, rodrigo.bonifacio wrote: > Dear Sirs, > > I guess this is a very simple question. How can I convert IO [XmlTree] to > just a list of XmlTree? > > Regards, > > Rodrigo. One good link on this topic is http://haskell.org/haskellwiki/Avoiding_IO Maybe there's no need for it be be IO [XmlTree], if you can write functions that instead produce/consume just [XmlTree]. They can always be turned later with liftM and whatnot into a IO [XmlTree] (but not the reverse). Doing as much as possible in pure code, and wrapping around it/calling it from a few short IO functions is the Haskell Way. Sometimes it looks hard to see, but XMonad is probably the best example here of how it can both be done where it looks infeasible ('What's a window manager but a bunch of IO?") and is rewarding (testability, etc. as exemplified by http://cgi.cse.unsw.edu.au/~dons/blog/2007/05/17) The best writeup on this seems to be http://www.cse.unsw.edu.au/~dons/talks/xmonad-hw07.pdf -- gwern From lrpalmer at gmail.com Tue Apr 14 11:42:57 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Apr 14 11:29:28 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> <7ca3f0160904140809y528e6282y12fc5c53f023509a@mail.gmail.com> Message-ID: <7ca3f0160904140842o21394db8r86ab9747c6a6c3d4@mail.gmail.com> On Tue, Apr 14, 2009 at 9:24 AM, Cristiano Paris wrote: > On Tue, Apr 14, 2009 at 5:09 PM, Luke Palmer wrote: > > ... > > Please don't say that. He's a beginner. > > You realize that the path of least resistance will be to use it, right? > > You see why that's not a good thing? > > Even experts don't use this function. > > (To the O.P.: don't use it) > > Mmmh, sorry Luke but I don't understand this ostracism. > > unsafePerformIO is not "evil" by itself, it's there for a purpose and, > as for anything else in the language, it's better to understand when > to use it and when not rather than just knowing that is something that > MUST not be used, without any further explanation. You have a point. I would like to avoid introducing unfounded authoritarian stigmas whenever possible. However, the way I see it is that unsafePerformIO *is* evil by itself, and it is only by the addition of Holy Water that it is benign to use. Ryan Ingram described it as a way to achieve "RTS extensions", which I think is a fine way to put it I consider Debug.Trace to be an instance of this: we are extending the RTS to provide execution traces. I guess it's a teaching style thing. Mostly, if someone sees "I have an IO [XmlTree] and I need an [XmlTree]", I want the "I'm asking the wrong question" synapse path to fire, rather than the "just use unsafePerformIO" one. Luke > > More, from my personal experience, knowing unsafePerformIO helped me > understand better what Monads are and how they should be used. > > I wounder what so-called "experts" have to say about this. > > Cristiano > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090414/461affad/attachment.htm From bulat.ziganshin at gmail.com Tue Apr 14 11:44:33 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Apr 14 11:31:19 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> <7ca3f0160904140809y528e6282y12fc5c53f023509a@mail.gmail.com> Message-ID: <194651328.20090414194433@gmail.com> Hello Cristiano, Tuesday, April 14, 2009, 7:24:40 PM, you wrote: > unsafePerformIO is not "evil" by itself, it's there for a purpose and, > as for anything else in the language, it's better to understand when > to use it we just think that author of original question don't yet have good knowledge of IO monad baiscs and it's what he actually want to know. if the question was how to perform IO action in pure code, unsafePerformIO may be a good answer -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From frodo at theshire.org Tue Apr 14 11:50:03 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Apr 14 11:36:55 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: <7ca3f0160904140842o21394db8r86ab9747c6a6c3d4@mail.gmail.com> References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> <7ca3f0160904140809y528e6282y12fc5c53f023509a@mail.gmail.com> <7ca3f0160904140842o21394db8r86ab9747c6a6c3d4@mail.gmail.com> Message-ID: On Tue, Apr 14, 2009 at 5:42 PM, Luke Palmer wrote: > > ... > However, the way I see it is that unsafePerformIO *is* evil by itself, and > it is only by the addition of Holy Water that it is benign to use. That's what I meant but your words are indeed more effective :) > Ryan Ingram described it as a way to achieve "RTS extensions", which I think > is a fine way to put it ? I consider Debug.Trace to be an instance of this: > we are extending the RTS to provide execution traces. > I guess it's a teaching style thing. ?Mostly, if someone sees "I have an IO > [XmlTree] and I need an [XmlTree]", I want the "I'm asking the wrong > question" synapse path to fire, rather than the "just use unsafePerformIO" > one. Yes, I think your analysis is correct. Perhaps I was a bit too dry in my original answer. Cristiano From jules at jellybean.co.uk Tue Apr 14 11:54:48 2009 From: jules at jellybean.co.uk (Jules Bean) Date: Tue Apr 14 11:41:56 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> <7ca3f0160904140809y528e6282y12fc5c53f023509a@mail.gmail.com> Message-ID: <49E4B1C8.7000704@jellybean.co.uk> Cristiano Paris wrote: > On Tue, Apr 14, 2009 at 5:09 PM, Luke Palmer wrote: >> ... >> Please don't say that. He's a beginner. >> You realize that the path of least resistance will be to use it, right? >> You see why that's not a good thing? >> Even experts don't use this function. >> (To the O.P.: don't use it) > > Mmmh, sorry Luke but I don't understand this ostracism. > > unsafePerformIO is not "evil" by itself, it's there for a purpose and, > as for anything else in the language, it's better to understand when > to use it and when not rather than just knowing that is something that > MUST not be used, without any further explanation. Sure, the explanation is there if people are interested in it. However, in context, your answer was wrong. It is like someone asking: "How do I get hold of a new phone" and the answer "Pull a gun on someone walking down the street and demand they give you their phone" ...that is, the answer was solving the wrong problem, or solving it in the wrong context. If you have IO [XmlTree], then you don't have an [XmlTree] at all - rather you have a description of an (IO-involving) action which you need to run to get one. You can run it many times, or once, or never. It will (in general) give different results depending exactly when you run it. Therefore you need to carefully decide when to run it - i.e. attach it indirectly or directly into your main action, as the various other answers have shown. unsafePerformIO is not part of the haskell language - it does not respect the type system. It is an extension mechanism which allows us to add hooks into the RTS; effectively a way to extend the language. This is a useful and powerful thing, but nothing in the questioner's question suggested that language extension was what they wanted. Jules From frodo at theshire.org Tue Apr 14 12:03:56 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Apr 14 11:50:46 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: <49E4B1C8.7000704@jellybean.co.uk> References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> <7ca3f0160904140809y528e6282y12fc5c53f023509a@mail.gmail.com> <49E4B1C8.7000704@jellybean.co.uk> Message-ID: On Tue, Apr 14, 2009 at 5:54 PM, Jules Bean wrote: > ... I'm convinced about what you say and perhaps I answered the way I did just because I'm convinced that, for a newbie, knowing about the existence of unsafePerformIO can't cause any harm. I was a bit surprised by the strong reaction about my citation of unsafePerformIO. Maybe it'd useful, for the future, to write a document explaining how to help newbies properly, maybe putting it in the mailing list charter. Cristiano From jake.mcarthur at gmail.com Tue Apr 14 12:11:50 2009 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Tue Apr 14 11:58:25 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> Message-ID: <49E4B5C6.8020601@gmail.com> rodrigo.bonifacio wrote: > I guess this is a very simple question. How can I convert IO [XmlTree] > to just a list of XmlTree? You can't, unless you use `unsafePeformIO`, as others have already pointed out. Yet others have, more "correctly," suggested that you use do notation to bind a variable with the type you expect. I want to go into a little more detail .I have a spontaneous Monad tutorial to throw out, I guess. How you can convert a value of type `IO [XmlTree]` is probably the wrong question. The right question is how you can convert a function of type `[XmlTree] -> A` into a function of type `IO [XmlTree] -> IO A`. The correct answer has many names: fmap, liftA, liftM, (<$>) :: Monad m => (a -> b) -> (m a -> m b) I will use `fmap` to mean any of the above names. In your case, applying fmap to a function foo: foo :: [XmlTree] -> A fmap foo :: IO [XmlTree] -> IO A So any time you need to pass an IO value to a pure function, this is one way to do it. Suppose that the function actually returns an IO value, though. Here, we will call the function `bar`: bar :: [XmlTree] -> IO A fmap bar :: IO [XmlTree] -> IO (IO A) Now we seem to be in a similar situation as before. We have an extra IO that we don't want. There is a function for this: join :: Monad m => m (m a) -> m a So, we can use `join` to transform an expression of type `IO (IO a)` to an expression of type `IO a`. Putting it all together: bar :: [XmlTree] -> IO A fmap bar :: IO [XmlTree] -> IO (IO A) join . fmap bar :: IO [XmlTree] -> IO A And we now have a sensible function again. Of course, this is a common pattern, using `join` and `fmap` together, so we have yet another function: (=<<) :: Monad m => (a -> m b) -> (m a -> m b) (Note that this has a different argument order than (>>=). I prefer this form since it emphasizes that it actually transforms a function.) So, now we have bar :: [XmlTree] -> IO A (bar =<<) :: IO [XmlTree] -> IO A Putting it all together, with a function that gives us the `IO [XmlTree]`: xmlTree :: IO [XmlTree] bar :: [XmlTree] -> IO A bar =<< XmlTree :: IO A And that last line is equivalent to this in do notation: do tree <- xmlTree bar tree If you have any questions, please do ask. I understand that it can appear quite dense to a beginner. I'm thinking about using this approach in a blog article, which would have more detail and examples, but I would like to be aware of potential stumbling blocks. - Jake From barsoap at web.de Tue Apr 14 12:13:49 2009 From: barsoap at web.de (Achim Schneider) Date: Tue Apr 14 12:00:39 2009 Subject: [Haskell-cafe] Re: Converting IO [XmlTree] to [XmlTree] References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> Message-ID: <20090414181349.0cf86c68@solaris> "rodrigo.bonifacio" wrote: > Dear Sirs, > > I guess this is a very simple question. How can I convert IO > [XmlTree] to just a list of XmlTree? > unsafeCoerce. Seriously, you just don't, you weld stuff together using >>=. It takes an 'IO a' and a function 'a -> IO b' and returns you an 'IO b', thus preventing you from launching nuclear missiles while you're standing in front of the exhaust jets. You don't want to be able to. do-notation is a convenient short-hand: foo >>= (\bar -> return $ baz bar) do bar <- foo return $ baz bar >>= doesn't only work with IO, but with any monad, that's why it's type, (>>=) :: Monad m => m a -> (a -> m b) -> m b might look intimidating, but actually isn't. For more info, have a look at Real World Haskell[1], and, after that, the Typeclassopedia[2]. As a final notice, don't listen to the others: Those are just desperate people, vainly trying to convince themselves they'd understand monads. If you see monads being compared to space suits, nuclear waste processing plants, or burritos, run far, run fast, but run. If you see them compared to applicative functors, get curious. [1]http://book.realworldhaskell.org/read/ [2]http://byorgey.wordpress.com/2009/02/16/the-typeclassopedia-request-for-feedback/ -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From barsoap at web.de Tue Apr 14 12:29:15 2009 From: barsoap at web.de (Achim Schneider) Date: Tue Apr 14 12:15:58 2009 Subject: [Haskell-cafe] Re: Converting IO [XmlTree] to [XmlTree] References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> <7ca3f0160904140809y528e6282y12fc5c53f023509a@mail.gmail.com> <49E4B1C8.7000704@jellybean.co.uk> Message-ID: <20090414182915.002f878e@solaris> Cristiano Paris wrote: > I was a bit surprised by the strong reaction about my citation of > unsafePerformIO. Maybe it'd useful, for the future, to write a > document explaining how to help newbies properly, maybe putting it in > the mailing list charter. > 1) Tell them about interact. 2) If they're not satisfied, or already spoiled by the functions they want to use, explain bind wrt. IO, then do-notation. You don't want them to get puzzled by missing returns, or think that it's a keyword. 3) Let them catch up on monads by themselves, there's no need to confuse people with explanations of things they already understand. In other words: 1) Explain Pointed 2) Explain Functor 3) Explain Applicative 4) Explain Monad -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From max.rabkin at gmail.com Tue Apr 14 12:35:19 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Tue Apr 14 12:22:04 2009 Subject: [Haskell-cafe] Looking for the fastest Haskell primes algorithm In-Reply-To: References: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> Message-ID: On Tue, Apr 14, 2009 at 2:47 PM, Andrew Wagner wrote: > Some other ideas for things to put in this package possibly: > is_prime :: Int -> Bool I'd also add isProbablePrime using a Miller-Rabin test or somesuch, for use with large numbers. It'd have to be in a monad which supplies randomness, of course. But to start with, I'd just package what I had and put it on Hackage. --Max From donn at avvanta.com Tue Apr 14 12:43:25 2009 From: donn at avvanta.com (Donn Cave) Date: Tue Apr 14 12:29:56 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> <7ca3f0160904140809y528e6282y12fc5c53f023509a@mail.gmail.com> <49E4B1C8.7000704@jellybean.co.uk> Message-ID: <20090414164325.D340393C84@mail.avvanta.com> Quoth Cristiano Paris , > I was a bit surprised by the strong reaction about my citation of > unsafePerformIO. Well, there might be a couple of things going on here. Part of it is how to guess the unstated context of a question - I'm fairly sure that given a more thorough presentation of the question, there would have been no controversy about the answer. The general problem is that people who are comfortable with extremely esoteric parts of Haskell and used to discussing such things here, fail to recognize when they're dealing with people who are at a point where their needs are much more basic. (And who knows, which one was the present case? Not really enough information to know absolutely for sure.) But as you have found, unsafePerformIO is not just an esoteric topic, it's an uncomfortable one. We read that it isn't even part of the language, one should never really have any use for it in computation, only as a sort of meta-programming RTS thing. Yet, you might never guess this from reading the GHC documentation, which only urges you to be careful. Or from encountering it in fairly widespread use as a way to implement top level program state with IORefs. This sort of unresolved tension between practice and theory rightly makes people uneasy, and in my opinion you shouldn't take it personally. It's a good thing to occasionally probe those sore spots, and maybe if it bothers us enough it will lead to improvements. Donn From jgoerzen at complete.org Tue Apr 14 12:44:12 2009 From: jgoerzen at complete.org (John Goerzen) Date: Tue Apr 14 12:30:44 2009 Subject: [Haskell-cafe] GHC including System.Time but not Data.Time? Message-ID: <20090414164412.GA18145@hustlerturf.com> Hi folks, Apologies in advance because this sounds rantish... So I went to my friendly API reference at http://www.haskell.org/ghc/docs/latest/html/libraries/index.html and noticed that I couldn't find Data.Time there anymore. Though it was still at http://www.haskell.org/ghc/docs/6.10.1/html/libraries/index.html After some checking on IRC, apparently this is on purpose. I find it *incredibly* annoying, and leaves us with the following unfortunate set of circumstances: 1) GHC ships with NO way to do date/time calculations in the preferred way (Data.Time) 2) GHC's docs reference only the obsolete (System.Time) way of doing things, with no reference to the preferred way. 3) I can't tell people to just install GHC and expect them to be able to perform date & time calculations the preferred way. Just about EVERY other language (C, Perl, Java, Python, etc.) come with this as part of the base install. 4) I can't update all my apps to use Data.Time without worrying about Yet Another Dependency. 5) Result: black eye on us. As I saw on IRC: the system isn't supposed to work out the box. the haskell platform is supposed to work out of the box. (shame it doesn't exist) Which is a fine goal, but until then, pretty please don't go dropping Data.Time out of GHC. I understand the goal of removing stuff from GHC, but the practical implications can be rather annoying. -- John From bulat.ziganshin at gmail.com Tue Apr 14 12:56:47 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Apr 14 12:51:23 2009 Subject: [Haskell-cafe] GHC including System.Time but not Data.Time? In-Reply-To: <20090414164412.GA18145@hustlerturf.com> References: <20090414164412.GA18145@hustlerturf.com> Message-ID: <1821198027.20090414205647@gmail.com> Hello John, Tuesday, April 14, 2009, 8:44:12 PM, you wrote: > I understand the goal of removing stuff from GHC, but the practical > implications can be rather annoying. i think that Haskell Platform will eventually replace what GHC was for a years, i.e. out-of-box solution for practical haskell usage. and ghc should be just what its name implies - bare compiler but i agree that stripping one package in minor 6.10.2 version, w/o Haskell Platform really available was an error -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From lennart at augustsson.net Tue Apr 14 13:17:05 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Tue Apr 14 13:03:36 2009 Subject: [Haskell-cafe] GHC including System.Time but not Data.Time? In-Reply-To: <1821198027.20090414205647@gmail.com> References: <20090414164412.GA18145@hustlerturf.com> <1821198027.20090414205647@gmail.com> Message-ID: Removing a package in a minor release is, to quote, an epic fail. I don't understand how that could be done. -- Lennart On Tue, Apr 14, 2009 at 6:56 PM, Bulat Ziganshin wrote: > Hello John, > > Tuesday, April 14, 2009, 8:44:12 PM, you wrote: > >> I understand the goal of removing stuff from GHC, but the practical >> implications can be rather annoying. > > i think that Haskell Platform will eventually replace what GHC was for > a years, i.e. out-of-box solution for practical haskell usage. and ghc > should be just what its name implies - bare compiler > > but i agree that stripping one package in minor 6.10.2 version, w/o > Haskell Platform really available was an error > > -- > 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 lennart at augustsson.net Tue Apr 14 13:19:54 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Tue Apr 14 13:06:26 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> Message-ID: Never answer such newbie questions with unsafePerformIO. That's the wrong answer 99.99% of the time, but giving it to a newbie they might follow your advice. On Tue, Apr 14, 2009 at 5:01 PM, Cristiano Paris wrote: > On Tue, Apr 14, 2009 at 4:54 PM, rodrigo.bonifacio > wrote: >> Dear Sirs, >> >> I guess this is a very simple question. How can I convert IO [XmlTree] to >> just a list of XmlTree? > > Quick and dirty answer: unsafePerformIO. > > That's an easy finding on Hoogle: > > http://www.haskell.org/hoogle/?hoogle=IO+a+-%3E+a > > Anyhow, as the name suggest, the function is "unsafe", so you better > know what you're doing. > > Bye, > > Cristiano > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From msmatsko at comcast.net Tue Apr 14 13:26:53 2009 From: msmatsko at comcast.net (Michael Matsko) Date: Tue Apr 14 13:13:23 2009 Subject: [Haskell-cafe] Looking for the fastest Haskell primes algorithm In-Reply-To: Message-ID: <1081325648.2007261239730013505.JavaMail.root@sz0055a.westchester.pa.mail.comcast.net> You might want to look at Pari/GP ( http://pari.math.u-bordeaux.fr/ ) for ideas of what kind of functions to supply. Also, as a source of ideas for algorithms. Mike Matsko ----- Original Message ----- From: "Max Rabkin" To: "Andrew Wagner" Cc: "R.A. Niemeijer" , haskell-cafe@haskell.org Sent: Tuesday, April 14, 2009 12:35:19 PM GMT -05:00 US/Canada Eastern Subject: Re: [Haskell-cafe] Looking for the fastest Haskell primes algorithm On Tue, Apr 14, 2009 at 2:47 PM, Andrew Wagner wrote: > Some other ideas for things to put in this package possibly: > is_prime :: Int -> Bool I'd also add isProbablePrime using a Miller-Rabin test or somesuch, for use with large numbers. It'd have to be in a monad which supplies randomness, of course. But to start with, I'd just package what I had and put it on Hackage. --Max _______________________________________________ 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/20090414/82c5141b/attachment.htm From rendel at cs.au.dk Tue Apr 14 14:01:58 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Tue Apr 14 13:48:22 2009 Subject: [Haskell-cafe] Non-atomic "atoms" for type-level programming In-Reply-To: References: Message-ID: <49E4CF96.5010402@cs.au.dk> > - if type-level tags (such as 'data TTrue'/'data TFalse') are declared > repeatedly in separate modules, they represent separate types, > preventing shared use (your type-level predicate doesn't return > my version of 'TTrue'/'TFalse') How is the need for a common import for 'data TTrue; data TFalse' different then the need for a common import for 'data Bool = True | False'? Clearly, the advent of type-level programming necessitates the design of a type-level standard library, which provides standard abstractions to enable interoperation of custom libraries. But I don't see why the module system should not scale to type-level programming. Tillmann From patai_gergely at fastmail.fm Tue Apr 14 14:41:29 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Tue Apr 14 14:27:59 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> <1239387673.2337.1309952317@webmail.messagingengine.com> Message-ID: <1239734489.27777.1310468547@webmail.messagingengine.com> > I wonder if this breaks referential transparency. Say, you define a signal > s and use s twice in some expression. s may be evaluated once and it > maybe evaluated twice. Does this make a difference? I'm not sure about the answer at the moment, but I believe we'd simply get two identically behaving signals in most cases, assuming they are evaluated in the same superstep. The automatic insertion of delays into cycles might cause problems here, as it depends on the current topology of the dataflow network what exactly happens. However, if all the cycles are broken with explicit delays, this is not an issue any more. It would break everything if IO-fed signals were created multiple times, but that can't happen, since their construction is explicitly marked by IO. > Is it possible that thereby the second “instance” has different values > than the first one? I can't exclude the possibility, unfortunately, especially with the delay magic. But this is a question that needs further investigation. > When are your signals started? At evaluation time? Yes. Evaluation returns an IORef holding the initial state of the signal, wrapped in some structure. The top-level network is traversed at the beginning, so its nodes are all evaluated just once. > If yes, doesn’t this mean that the meaning of a signal depends on > evaluation time so that evaluating the same signal expression twice > actually results in two different signals? That's exactly the case. The system heavily relies on sharing in order to work properly. In fact, the ability to keep track of sharing under a pure-looking interface was the main motivation to choose this particular implementation. As far as I can tell, it should be fine as long as no Elerea primitive (signal constructors defined in Internal) is inlined. But I don't like this either, and I'd love to hear how the same effect can be achieved without resorting to such fragile constructs. Unfortunately, all my previous attempts failed at one point or another... > So Elerea seems to have to take special care to not break > referential transparency. No matter how I look at it, that would make it a completely different library. One that's very close to Reactive, in fact. > Elerea’s evaluation seems to be driven by hand-coded IO actions > so that use of such compiler optimizations is certainly not possible. This is quite true. On the other hand, most calculation is happening in pure functions anyway, and reactive book-keeping probably constitutes only a small fragment of the runtime in a typical application, so this is less of a worry for me. In the end, I see FRP as an alternative way to manage entities, and entities surely can't be optimised away. I use applicative laws to unite pure parts as much as possible, although I don't expect the resulting functions to be as efficient as if they had been assembled at compile time. A JIT compiler surely wouldn't hurt. :) > Grapefruit does this using era type parameters. Elerea doesn’t > seem to do anything about this at the moment. Apart from counting on conditions mentioned above, no. The intended meaning is that new signals are created whenever a latcher asks for one, but there's no way to enforce that for the time being. > Patai, could you please correct me where I’m wrong and clarify the > points which are still unclear to me? It seems I can hardly say anything new, because you see all the issues perfectly. (By the way, Patai is my family name. Different endianness over here. ;) > What do you think, Grapefruit is lacking, compared to Reactive? Oh, it's just my subjective opinion that I find the interface of Reactive very easy to use and flexible. That's primarily what I wanted to replicate in Elerea, I just ended up getting rid of events altogether, as I didn't need them, and that gave me a simpler system to play with. Grapefruit looks like something that feels more natural when describing the system at a higher level. But I really need to play with it more to have a well-founded opinion. Gergely -- http://www.fastmail.fm - mmm... Fastmail... From brian at lorf.org Tue Apr 14 15:29:06 2009 From: brian at lorf.org (brian@lorf.org) Date: Tue Apr 14 15:15:41 2009 Subject: [Haskell-cafe] error handling (esp. IO/exceptions) Message-ID: <20090414192906.GG2534@doses.lan> I'm finding it hard to write robust code that isn't really ugly. Suppose I want to write > execute :: FilePath -> [String] -> IO (Either ExecuteError ExitCode) where 'ExecuteError' is a data type representing all the ways 'execute' could fail and that 'execute p args' is supposed to * ensure p exists * get p's permissions * ensure p is readable * ensure p is executable * execute p and return its exit code So 'ExecuteError' would have constructors corresponding to these ways to fail: * could not determine whether p exists * p does not exist * could not get p's permissions * p is not readable * p is not executable * could not execute p for some other reason So if I start to code it, I 'tryJust' 'doesFileExist'. If an exception is thrown, I convert it to Left $AppropriateExecuteError. If not, we know whether p exists. If it doesn't, convert it to Left. Otherwise, 'tryJust' 'getPermissions', etc. It's starting to staircase. I'm needing it to be easier to stop my computation and return specific things when exceptions are thrown or when certain requirements aren't met. Thanks for any help. From haskell at colquitt.org Tue Apr 14 15:33:00 2009 From: haskell at colquitt.org (John Dorsey) Date: Tue Apr 14 15:19:33 2009 Subject: [Haskell-cafe] Printing list of enum type In-Reply-To: <435878.49405.qm@web31107.mail.mud.yahoo.com> References: <435878.49405.qm@web31107.mail.mud.yahoo.com> Message-ID: <20090414193300.GA3278@colquitt.org> Michael, > What do I need to add to this Color enum type to print a list of them? You can also easily print a list of /all/ of them. Regards, John scratch$ cat color.hs data Color ??? = Red ??? | Blue ??? | Green ??? | Yellow ??? | Orange ??? | Brown ??? | White ??? | Black deriving (Show,Enum,Bounded) scratch$ ghci color.hs *Main> [minBound..maxBound] :: [Color] [Red,Blue,Green,Yellow,Orange,Brown,White,Black] From miguelimo38 at yandex.ru Tue Apr 14 15:36:06 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Tue Apr 14 15:22:51 2009 Subject: [Haskell-cafe] error handling (esp. IO/exceptions) In-Reply-To: <20090414192906.GG2534@doses.lan> References: <20090414192906.GG2534@doses.lan> Message-ID: What about ErrorT monad transformer? Well, if it's not what you really want, you can define your own one without ugly "Error" class, so it'd be something like execute :: FilePath -> [String] -> MyCoolErrorT ExecuteError IO ExitCode On 14 Apr 2009, at 23:29, brian@lorf.org wrote: > I'm finding it hard to write robust code that isn't really ugly. > Suppose > I want to write > >> execute :: FilePath -> [String] -> IO (Either ExecuteError ExitCode) > > where 'ExecuteError' is a data type representing all the ways > 'execute' > could fail and that 'execute p args' is supposed to > > * ensure p exists > * get p's permissions > * ensure p is readable > * ensure p is executable > * execute p and return its exit code > > So 'ExecuteError' would have constructors corresponding to these > ways to > fail: > * could not determine whether p exists > * p does not exist > * could not get p's permissions > * p is not readable > * p is not executable > * could not execute p for some other reason > > So if I start to code it, I 'tryJust' 'doesFileExist'. If an exception > is thrown, I convert it to Left $AppropriateExecuteError. If not, we > know whether p exists. If it doesn't, convert it to Left. Otherwise, > 'tryJust' 'getPermissions', etc. It's starting to staircase. > > I'm needing it to be easier to stop my computation and return specific > things when exceptions are thrown or when certain requirements aren't > met. Thanks for any help. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From brian at lorf.org Tue Apr 14 16:00:34 2009 From: brian at lorf.org (brian@lorf.org) Date: Tue Apr 14 15:47:06 2009 Subject: [Haskell-cafe] error handling (esp. IO/exceptions) In-Reply-To: References: <20090414192906.GG2534@doses.lan> Message-ID: <20090414200034.GH2534@doses.lan> On Tuesday, 14.04.09 at 23:36, Miguel Mitrofanov wrote: > What about ErrorT monad transformer? I don't see how it helps in my situation. ErrorT doesn't catch exceptions, for example. Suppose I did make something like ErrorT that catches exceptions and turn them into Lefts. Where would (>>=) get my specific error constructor? Maybe I need to make helper functions to use in runErrorT blocks that turn exceptions, Bools, Maybes, etc., into Eithers? Confused. From lennart at augustsson.net Tue Apr 14 16:13:24 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Tue Apr 14 15:59:55 2009 Subject: [Haskell-cafe] error handling (esp. IO/exceptions) In-Reply-To: <20090414192906.GG2534@doses.lan> References: <20090414192906.GG2534@doses.lan> Message-ID: There's no way to make all your tests atomically, e.g, between the test that p exists and executing p, some other process could removce p. So the right way to do this (like opening a file), is to try executing it and let the OS tell you if it failed. On Tue, Apr 14, 2009 at 9:29 PM, wrote: > I'm finding it hard to write robust code that isn't really ugly. Suppose > I want to write > >> execute :: FilePath -> [String] -> IO (Either ExecuteError ExitCode) > > where 'ExecuteError' is a data type representing all the ways 'execute' > could fail and that 'execute p args' is supposed to > > * ensure p exists > * get p's permissions > * ensure p is readable > * ensure p is executable > * execute p and return its exit code > > So 'ExecuteError' would have constructors corresponding to these ways to > fail: > * could not determine whether p exists > * p does not exist > * could not get p's permissions > * p is not readable > * p is not executable > * could not execute p for some other reason > > So if I start to code it, I 'tryJust' 'doesFileExist'. If an exception > is thrown, I convert it to Left $AppropriateExecuteError. If not, we > know whether p exists. If it doesn't, convert it to Left. Otherwise, > 'tryJust' 'getPermissions', etc. It's starting to staircase. > > I'm needing it to be easier to stop my computation and return specific > things when exceptions are thrown or when certain requirements aren't > met. Thanks for any help. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From lemming at henning-thielemann.de Tue Apr 14 16:14:28 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Apr 14 16:01:04 2009 Subject: [Haskell-cafe] error handling (esp. IO/exceptions) In-Reply-To: References: <20090414192906.GG2534@doses.lan> Message-ID: On Tue, 14 Apr 2009, Miguel Mitrofanov wrote: > What about ErrorT monad transformer? Well, if it's not what you really want, > you can define your own one without ugly "Error" class, so it'd be something > like > > execute :: FilePath -> [String] -> MyCoolErrorT ExecuteError IO ExitCode My MyCoolErrorT is named Control.Monad.Exception.Synchronous.ExceptionalT and can be found in the explicit-exception package. In contrast to ErrorT it puts no restrictions on the exception type. From lemming at henning-thielemann.de Tue Apr 14 16:16:40 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Apr 14 16:03:11 2009 Subject: [Haskell-cafe] error handling (esp. IO/exceptions) In-Reply-To: <20090414200034.GH2534@doses.lan> References: <20090414192906.GG2534@doses.lan> <20090414200034.GH2534@doses.lan> Message-ID: On Tue, 14 Apr 2009, brian@lorf.org wrote: > On Tuesday, 14.04.09 at 23:36, Miguel Mitrofanov wrote: >> What about ErrorT monad transformer? > > I don't see how it helps in my situation. ErrorT doesn't catch > exceptions, for example. Suppose I did make something like ErrorT that > catches exceptions and turn them into Lefts. Where would (>>=) get my > specific error constructor? With explicit-exception you would call Exc.fromEitherT $ try $ execute path options The package has some hidden modules, where I experiment with a special IO type that cannot throw exceptions. From brian at lorf.org Tue Apr 14 16:27:42 2009 From: brian at lorf.org (brian@lorf.org) Date: Tue Apr 14 16:14:14 2009 Subject: [Haskell-cafe] error handling (esp. IO/exceptions) In-Reply-To: References: <20090414192906.GG2534@doses.lan> Message-ID: <20090414202742.GI2534@doses.lan> On Tuesday, 14.04.09 at 22:13, Lennart Augustsson wrote: > So the right way to do this (like opening a file), is to try executing > it and let the OS tell you if it failed. I know, but the various functions that create processes don't help me know whether the program actually ran or not. For example, > createProcess (proc "nosuch" []) >>= \(_,_,_,ph) -> waitForProcess ph returns ExitCode 127. If I use the same code to run 'test', a C program that returns 127, I get the same thing. From bugfact at gmail.com Tue Apr 14 17:01:22 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Apr 14 16:47:52 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: <1239706019.6858.1310393875@webmail.messagingengine.com> References: <1239381666.12202.1309941005@webmail.messagingengine.com> <40a414c20904110149o27d508c0u7b7efe0391ffa74d@mail.gmail.com> <1239444601.20625.1310024249@webmail.messagingengine.com> <1239541485.27252.1310127905@webmail.messagingengine.com> <1239575289.5053.1310168171@webmail.messagingengine.com> <1239706019.6858.1310393875@webmail.messagingengine.com> Message-ID: I will test it on a couple of machines, desktops and laptops. I think the problem was my laptop going into power safe mode or something, since sometimes it runs smooth, sometimes it doesn't. This could indeed be a problem with GLFW's time attribute on windows (which uses the CPU tick frequency which gets trottled to safe energy), although I believe the Windows API should take care of this. I haven't seen this yet with my own frp experiments, which seem to run smooth all the time, but again I will do more testing. I have been thinking about your approach, using mutable variables to hold a signal's sample. This is exactly what I did with on old C# prototype, and it worked out nicely. If you take a look what Yampa does: it hides signals and only exposes signal functions. But that means that the FRP engine itself could indeed use mutable variables for its signals, as long as during the evaluation of the circuit at time T no side effects should occur; the side effects should take place when the simulation is advanced to T+dT, which is done after the circuit is fully evaluated at time T. If you want higher order integration, you would need to keep a buffer of more samples, but it would still work. So I think you approach is a very good pragmatic one! I'm only a bit worried about your automatic insertion of delays; this might break referential transparency at time T, since it depends on the order in which the nodes in the circuit are evaluated no? The latter could be problematic when doing evaluation in parallel on multiple cores I guess. 2009/4/14 Patai Gergely > > Interesting. I'm testing it on Window though. You're using Linux? Maybe > > the scheduling is different. > Now I tried it on Windows in VirtualBox, and it still looks quite smooth > to me (except that hardware acceleration doesn't seem to work properly > through virtualisation, but it's okay as long as I keep the window small > enough). However, unlike the Linux version, it does max out the CPU, so > the trick with threadDelay 0 doesn't work. Apparently, I'll have to find > a real Windows box somewhere, because I couldn't reproduce the jerkiness > you're talking about. > > Gergely > > -- > http://www.fastmail.fm - The way an email service should be > > _______________________________________________ > 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/20090414/41758457/attachment.htm From bugfact at gmail.com Tue Apr 14 17:04:03 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Apr 14 16:50:33 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <1239444601.20625.1310024249@webmail.messagingengine.com> <1239541485.27252.1310127905@webmail.messagingengine.com> <1239575289.5053.1310168171@webmail.messagingengine.com> <1239706019.6858.1310393875@webmail.messagingengine.com> Message-ID: Ouch, I did not see Wolfgang's email nor your reply, sorry for the noise (which I'm doing again with this email ;-) On Tue, Apr 14, 2009 at 11:01 PM, Peter Verswyvelen wrote: > I will test it on a couple of machines, desktops and laptops. I think the > problem was my laptop going into power safe mode or something, since > sometimes it runs smooth, sometimes it doesn't. This could indeed be a > problem with GLFW's time attribute on windows (which uses the CPU tick > frequency which gets trottled to safe energy), although I believe the > Windows API should take care of this. I haven't seen this yet with my own > frp experiments, which seem to run smooth all the time, but again I will do > more testing. > I have been thinking about your approach, using mutable variables to hold a > signal's sample. This is exactly what I did with on old C# prototype, and it > worked out nicely. If you take a look what Yampa does: it hides signals and > only exposes signal functions. But that means that the FRP engine itself > could indeed use mutable variables for its signals, as long as during the > evaluation of the circuit at time T no side effects should occur; the side > effects should take place when the simulation is advanced to T+dT, which is > done after the circuit is fully evaluated at time T. If you want higher > order integration, you would need to keep a buffer of more samples, but it > would still work. So I think you approach is a very good pragmatic one! I'm > only a bit worried about your automatic insertion of delays; this might > break referential transparency at time T, since it depends on the order in > which the nodes in the circuit are evaluated no? The latter could be > problematic when doing evaluation in parallel on multiple cores I guess. > > 2009/4/14 Patai Gergely > > > Interesting. I'm testing it on Window though. You're using Linux? Maybe >> > the scheduling is different. >> Now I tried it on Windows in VirtualBox, and it still looks quite smooth >> to me (except that hardware acceleration doesn't seem to work properly >> through virtualisation, but it's okay as long as I keep the window small >> enough). However, unlike the Linux version, it does max out the CPU, so >> the trick with threadDelay 0 doesn't work. Apparently, I'll have to find >> a real Windows box somewhere, because I couldn't reproduce the jerkiness >> you're talking about. >> >> Gergely >> >> -- >> http://www.fastmail.fm - The way an email service should be >> >> _______________________________________________ >> 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/20090414/79650639/attachment.htm From bugfact at gmail.com Tue Apr 14 17:05:13 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Apr 14 16:51:43 2009 Subject: win64 ghc version Re[4]: [Haskell-cafe] GHC needs a 64 bit machine to be fast? In-Reply-To: <1332606133.20090414192506@gmail.com> References: <49DC5CD8.7080609@centrum.cz> <1611609764.20090408134751@gmail.com> <1332606133.20090414192506@gmail.com> Message-ID: I will add myself a million times then :-) On Tue, Apr 14, 2009 at 5:25 PM, Bulat Ziganshin wrote: > Hello Peter, > > Wednesday, April 8, 2009, 2:42:24 PM, you wrote: > > if you need win64 ghc version - add yourself to CC list of > http://hackage.haskell.org/trac/ghc/ticket/1884 > > > Well, make that 2! :-) > > On Wed, Apr 8, 2009 at 11:47 AM, Bulat Ziganshin > > wrote: > > Hello Peter, > > > > Wednesday, April 8, 2009, 12:58:25 PM, you wrote: > > > > No. it seems that i'm only user asking GHC team for 64-bit version > > > > >> Regarding that, is it possible to generate 64-bit code using GHC on > Windows? > > > >> On Wed, Apr 8, 2009 at 10:17 AM, FFT wrote: > >> > >> On Wed, Apr 8, 2009 at 1:14 AM, Karel Gardas > wrote: > >>> > >>> Hello, > >>> > >>> perhaps you are hit by following issue? > >>> http://hackage.haskell.org/trac/ghc/ticket/594 > >> > >> > >> The benchmark isn't using the native code generator, it compiles via > >> C, as I understand. > >> > >> What are other people's timings on 32 bit Linux machines? > >> > >> _______________________________________________ > >> Haskell-Cafe mailing list > >> Haskell-Cafe@haskell.org > >> http://www.haskell.org/mailman/listinfo/haskell-cafe > >> > > > > > >> > > > > > > > > -- > > Best regards, > > Bulat mailto:Bulat.Ziganshin@gmail.com > > > > > > > > > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090414/eda340fd/attachment.htm From nowgate at yahoo.com Tue Apr 14 17:07:06 2009 From: nowgate at yahoo.com (michael rice) Date: Tue Apr 14 16:53:37 2009 Subject: [Haskell-cafe] Printing list of enum type Message-ID: <524779.96476.qm@web31104.mail.mud.yahoo.com> I didn't know that, but there's a lot I don't know about Haskell. It works great. Thanks! Michael --- On Tue, 4/14/09, John Dorsey wrote: From: John Dorsey Subject: Re: [Haskell-cafe] Printing list of enum type To: "michael rice" Cc: haskell-cafe@haskell.org Date: Tuesday, April 14, 2009, 3:33 PM Michael, > What do I need to add to this Color enum type to print a list of them? You can also easily print a list of /all/ of them. Regards, John scratch$ cat color.hs data Color ??? = Red ??? | Blue ??? | Green ??? | Yellow ??? | Orange ??? | Brown ??? | White ??? | Black ? deriving (Show,Enum,Bounded) scratch$ ghci color.hs *Main> [minBound..maxBound] :: [Color] [Red,Blue,Green,Yellow,Orange,Brown,White,Black] -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090414/29297cfa/attachment.htm From vasyl.pasternak at gmail.com Tue Apr 14 17:18:38 2009 From: vasyl.pasternak at gmail.com (Vasyl Pasternak) Date: Tue Apr 14 17:05:10 2009 Subject: [Haskell-cafe] [ANNOUNCE] hgettext 0.1.10 - last major release Message-ID: <8feb08f70904141418k3be64346xa0ddf52a33a5b816@mail.gmail.com> Hello, I've uploaded last (and latest) significant version on hgettext module. Currently it works fine, and has bindings to all gettext functions (from libintl.h). Next versions will be only bug fixes of this version. GNU GetText allows you only to create simple, standalone desktop applications for Linux, to make something complex you should use different trick, fortunately Haskell could do these tricks much easier than other languages (if you want to see, how to build Gtk application, which supports run time language switching, and shows information on two languages simultaneously you could download example from http://hgettext.googlecode.com/files/gtk-hello-0.0.2.tar.gz , or read about it from http://progandprog.blogspot.com/2009/04/multilingual-ui-and-dynamic-language.html) I don't see any strong reasons to write any combinators over this basic bindings. Haskell needs more powerful internationalization library, and I am plan to design it, but it will be completely different from gettext principles, so this library will be released with another name. CHANGELOG: * Added '--version' command line parameter to hgettext tool * Added support for literate haskell files to hgettext tool * Changed all functions to throw IOError when they fails instead of return Nothing * Added bindings for: ngettext, dgettext, dngettext, dcgettext and dcngettext functions -- Best regards, Vasyl Pasternak From lists at qseep.net Tue Apr 14 17:51:15 2009 From: lists at qseep.net (Lyle Kopnicky) Date: Tue Apr 14 17:37:45 2009 Subject: [Haskell-cafe] lift in TemplateHaskell? Message-ID: <670e468e0904141451j156644cevf1e8afcffb426de2@mail.gmail.com> Hi folks, I'm having trouble reading the TemplateHaskell docs and trying to do something that seems like it should be simple. In MetaML, there is a 'lift' function which does exactly what I want to do. Here's an example function: let double n = [| 2 * $( litE (integerL n) ) |] This works as intended, but instead of writing "litE (integerL n)" I just want to write "lift n", or something similar. I expect that would involve a type class called something like Liftable that would lift literals using the appropriate functions. Does this exist? Thanks, Lyle -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090414/6f346809/attachment.htm From lists at qseep.net Tue Apr 14 17:59:40 2009 From: lists at qseep.net (Lyle Kopnicky) Date: Tue Apr 14 17:46:10 2009 Subject: [Haskell-cafe] Re: lift in TemplateHaskell? In-Reply-To: <670e468e0904141451j156644cevf1e8afcffb426de2@mail.gmail.com> References: <670e468e0904141451j156644cevf1e8afcffb426de2@mail.gmail.com> Message-ID: <670e468e0904141459k6f6c6508n4766cecc07bff3da@mail.gmail.com> OK, I figured it out. The class is Language.Haskell.TH.Syntax.Lift. The function is Language.Haskell.TH.Syntax.lift. And I can rewrite my function as: let double n = [| 2 * n |] I wish this were explained in the TemplateHaskell documentation. - Lyle On Tue, Apr 14, 2009 at 2:51 PM, Lyle Kopnicky wrote: > Hi folks, > > I'm having trouble reading the TemplateHaskell docs and trying to do > something that seems like it should be simple. In MetaML, there is a 'lift' > function which does exactly what I want to do. Here's an example function: > > let double n = [| 2 * $( litE (integerL n) ) |] > > This works as intended, but instead of writing "litE (integerL n)" I just > want to write "lift n", or something similar. I expect that would involve a > type class called something like Liftable that would lift literals using the > appropriate functions. Does this exist? > > Thanks, > Lyle > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090414/ff9ce3ac/attachment-0001.htm From donn at avvanta.com Tue Apr 14 18:19:50 2009 From: donn at avvanta.com (Donn Cave) Date: Tue Apr 14 18:06:20 2009 Subject: [Haskell-cafe] error handling (esp. IO/exceptions) References: <20090414192906.GG2534@doses.lan> <20090414202742.GI2534@doses.lan> Message-ID: <20090414221950.D8800F3942@mail.avvanta.com> Quoth brian@lorf.org, > On Tuesday, 14.04.09 at 22:13, Lennart Augustsson wrote: >> So the right way to do this (like opening a file), is to try executing >> it and let the OS tell you if it failed. > > I know, but the various functions that create processes don't help me > know whether the program actually ran or not. For example, > >> createProcess (proc "nosuch" []) >>= \(_,_,_,ph) -> waitForProcess ph > > returns ExitCode 127. If I use the same code to run 'test', a C program > that returns 127, I get the same thing. Right, awkward problem. Don't know if it can be solved in a portable way, but you (as author of a createProcess-like function) can use a pipe from the forked process. The code demo I append works, given FFI support for the POSIX functions it uses, but may not be appropriate for use with GHC (I'm using nhc98.) Donn ------------ spawn file cmd env = do (e0, e1) <- pipe -- F_CLOEXEC: close fd on (sucessful) exec. fcntlSetFlag e1 F_CLOEXEC t <- fork (fex e0 e1) close e1 rx <- readFd e0 256 if null rx then return t else ioError (userError rx) where fex e0 e1 = do close e0 catch (execve file cmd env) (\ e -> writeFd e1 (ioeGetErrorString e)) From donn at avvanta.com Tue Apr 14 18:26:16 2009 From: donn at avvanta.com (Donn Cave) Date: Tue Apr 14 18:12:46 2009 Subject: [Haskell-cafe] error handling (esp. IO/exceptions) References: <20090414192906.GG2534@doses.lan> Message-ID: <20090414222616.24121276D4E@mail.avvanta.com> Quoth brian@lorf.org, >> execute :: FilePath -> [String] -> IO (Either ExecuteError ExitCode) > > where 'ExecuteError' is a data type representing all the ways 'execute' > could fail and that 'execute p args' is supposed to > > * ensure p exists > * get p's permissions > * ensure p is readable > * ensure p is executable * read UNIX "magic number" from first 2 bytes of p case number of "#!" -> interpret rest of line, start validation process over on interpreter file valid executable type for OS -> OK _ -> not OK > * execute p and return its exit code Donn From xj2106 at columbia.edu Tue Apr 14 18:37:58 2009 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Tue Apr 14 18:24:33 2009 Subject: [Haskell-cafe] Re: Best text editor In-Reply-To: (Stefan Monnier's message of "Mon, 13 Apr 2009 23:20:04 -0400") References: <23018470.post@talk.nabble.com> <49E2E1EB.3040100@alumni.caltech.edu> Message-ID: <87r5zu275l.fsf@columbia.edu> Stefan Monnier writes: >> I'm a beginner, but I'll chime in and say I use Emacs with >> haskell-mode. It's auto-indentation is a bit complex in behavior which is >> unappealing (I feel like I never know what it's going to do when I hit tab), >> but I would be curious what someone with more experience feels about that. > > I clearly recommend Emacs with haskell-mode, but I agree that the > indentation is problematic. Note that the code in the CVS repository > comes with a completely new indentation algorithm courtesy of Kristof > Bastiaensen (so you can now choose > between haskell-simple-indent, haskell-indent, and the new > haskell-indentation). I haven't tried this new algorithm much, but > people who dislike haskell-indent might want to give it a try. It works for me and I believe it indeed behaves much more rational. The doc in the file haskell-indentation.el is misleading. It states using function turn-on-haskell-indentation, which is removed according to Changelog. And the default definition of haskell-mode-hook in haskell-mode.el is somewhat offending, so I recommend remove the two autoload lines. Index: haskell-mode.el =================================================================== RCS file: /cvs/fptools/CONTRIB/haskell-modes/emacs/haskell-mode.el,v retrieving revision 1.32 diff -u -b -B -r1.32 haskell-mode.el --- haskell-mode.el 28 Feb 2008 22:23:36 -0000 1.32 +++ haskell-mode.el 14 Apr 2009 22:24:53 -0000 @@ -504,8 +504,6 @@ ;;;###autoload(add-to-list 'auto-mode-alist '("\\.\\(?:[gh]s\\|hi\\)\\'" . haskell-mode)) ;;;###autoload(add-to-list 'auto-mode-alist '("\\.l[gh]s\\'" . literate-haskell-mode)) -;;;###autoload(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) -;;;###autoload(add-hook 'haskell-mode-hook 'turn-on-haskell-indent) (defcustom haskell-hoogle-command (if (executable-find "hoogle") "hoogle") -- c/* __o/* <\ * (__ */\ < From jeff at nokrev.com Tue Apr 14 18:57:08 2009 From: jeff at nokrev.com (Jeff Wheeler) Date: Tue Apr 14 18:43:42 2009 Subject: [Haskell-cafe] Re: Best text editor In-Reply-To: <20090414113406.6b47c241@solaris> References: <23018470.post@talk.nabble.com> <20090414113406.6b47c241@solaris> Message-ID: <1239749828.9656.4.camel@ulysses> On Tue, 2009-04-14 at 11:34 +0200, Achim Schneider wrote: > Yes, and I figured I'd have to edit the keymap to get productive. While > it features a fully functional subset of vim that's more than enough to > efficiently edit files, it's not the subset I use... and then I was too > lazy to actually do it. As one of the Yi developers, I'd love to hear some more specific feedback on this. Do you remember any specific Vim features that were missing? > Documentation is badly lacking, too, it's like trying to configure > xmonad without xmonad-contrib and all the docs. This is slowly improving, and Yi's haddock documentation now builds fine. This should soon be available on Hackage also, when the Haddock there is upgraded. Jeff Wheeler From hjgtuyl at chello.nl Tue Apr 14 19:53:34 2009 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Tue Apr 14 19:40:31 2009 Subject: [Haskell-cafe] glut installation using cabal failed In-Reply-To: <1336aed20904132325i6b765025oc20e99593dba3fbd@mail.gmail.com> References: <1336aed20904132325i6b765025oc20e99593dba3fbd@mail.gmail.com> Message-ID: On Tue, 14 Apr 2009 08:25:52 +0200, Raja Koduru wrote: > hi, > > I am a beginner to haskell. > > I am trying to install glut using "cabal install glut" > Pasting here a tail of the output > --------------------------------------------------------------------- > checking for unistd.h... yes > checking windows.h usability... yes > checking windows.h presence... yes > checking for windows.h... yes > checking GL/glut.h usability... no > checking GL/glut.h presence... no > checking for GL/glut.h... no > checking for GLUT library... no > checking for GL/glut.h... (cached) no > checking GLUT/glut.h usability... no > checking GLUT/glut.h presence... no > checking for GLUT/glut.h... no > configure: error: no GLUT header found, so this package cannot be built > See `config.log' for more details. > cabal: Error: some packages failed to install: > GLUT-2.1.1.2 failed during the configure step. The exception was: > exit: ExitFailure 1 > --------------------------------------------------------------------------------- > > But I do have "glut.h" in my "D:\ghc\ghc-6.10.2\include\mingw\GL". > Define the environment variable: C_INCLUDE_PATH=D:\ghc\ghc-6.10.2\include\mingw (you can add more directories, separate them by ';') To let the linker find the libraries, define LIBRARY_PATH. -- Regards, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ -- From toby.hutton at gmail.com Tue Apr 14 23:00:16 2009 From: toby.hutton at gmail.com (Toby Hutton) Date: Tue Apr 14 22:46:59 2009 Subject: [Haskell-cafe] Re: Best text editor In-Reply-To: <1239749828.9656.4.camel@ulysses> References: <23018470.post@talk.nabble.com> <20090414113406.6b47c241@solaris> <1239749828.9656.4.camel@ulysses> Message-ID: <711894390904142000qafc26fi1cf7941534605d3a@mail.gmail.com> On Wed, Apr 15, 2009 at 8:57 AM, Jeff Wheeler wrote: > > As one of the Yi developers, I'd love to hear some more specific > feedback on this. Do you remember any specific Vim features that were > missing? My main gripe with the vi emulation in Yi was in vty mode[1] and how it was unable to tell that 'esc' wasn't always 'meta-'. e.g., If I leave insert mode with esc and hit j to go down a line too quickly it interpreted it as meta-j. Quite annoying. This was a little while ago though. Also, I remember the cursor would go beyond the last character in a line in command mode, which is very un-vi-ish. At the time I remember thinking I should try and fix these things myself... but.. umm... [1] vty Yi is the only one I would use--coding must always live inside a screen session :) I really dislike wrapping a GUI around vi(m). I don't want toolbars, tabs, scrollbars nor menus. I don't even want a titlebar. Absolute full screen terminal running screen is perfect. :) From barsoap at web.de Wed Apr 15 03:03:07 2009 From: barsoap at web.de (Achim Schneider) Date: Wed Apr 15 02:49:54 2009 Subject: [Haskell-cafe] Re: ANN: Elerea, another FRP library References: <1239381666.12202.1309941005@webmail.messagingengine.com> <49DF7BD3.3030509@gmail.com> <1239387673.2337.1309952317@webmail.messagingengine.com> <1239734489.27777.1310468547@webmail.messagingengine.com> Message-ID: <20090415090307.7153327e@solaris> "Patai Gergely" wrote: > ... > I don't think using dirty tricks to implement FRP deserves flak, at all, from my POV, it sounds like complaining that the IO monad is implemented using C... meaning that if you're that close to bare thunks, you have every right to use any means necessary to make them behave properly. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From barsoap at web.de Wed Apr 15 03:06:47 2009 From: barsoap at web.de (Achim Schneider) Date: Wed Apr 15 02:56:31 2009 Subject: [Haskell-cafe] Re: Best text editor References: <23018470.post@talk.nabble.com> <20090414113406.6b47c241@solaris> <1239749828.9656.4.camel@ulysses> Message-ID: <20090415090647.354d50e2@solaris> Jeff Wheeler wrote: > As one of the Yi developers, I'd love to hear some more specific > feedback on this. Do you remember any specific Vim features that were > missing? > Nope, but I'll be writing bug reports next time, at the very least. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From patai_gergely at fastmail.fm Wed Apr 15 03:42:07 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Wed Apr 15 03:28:35 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <1239444601.20625.1310024249@webmail.messagingengine.com> <1239541485.27252.1310127905@webmail.messagingengine.com> <1239575289.5053.1310168171@webmail.messagingengine.com> <1239706019.6858.1310393875@webmail.messagingengine.com> Message-ID: <1239781327.2103.1310566707@webmail.messagingengine.com> > I don't think using dirty tricks to implement FRP deserves > flak, at all, from my POV, it sounds like complaining that the > IO monad is implemented using C... meaning that if you're that > close to bare thunks, you have every right to use any means > necessary to make them behave properly. Dirtiness is not the problem, but the fact that it can leak out at the present moment. I want guarantees to exclude the possibility of undesired behaviour on the user side. Am I right thinking that the NOINLINE pragma on unsafeDupablePerformIO prevents the problem of multiple evaluation discussed yesterday? Or should I add NOINLINE to primitives in Elerea.Internal too? If that guaranteed sharing, it would certainly solve most of the problems we talked about. Apart from that, I'm still not sure that latching works the way intended all the time, but the fact that the breakout example works is an indication that at least it's not hopelessly broken. Gergely -- http://www.fastmail.fm - Access all of your messages and folders wherever you are From aeyakovenko at gmail.com Wed Apr 15 04:12:05 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Wed Apr 15 03:58:33 2009 Subject: [Haskell-cafe] understanding typeable In-Reply-To: <49a77b7a0904122254o5359a141i24c5e54c4e79010f@mail.gmail.com> References: <200904121807.19055.dan.doel@gmail.com> <49a77b7a0904122254o5359a141i24c5e54c4e79010f@mail.gmail.com> Message-ID: So I am getting a little further, but i am seeing this bizarre behaviour: I wrote a function that will fold over parameters and push them into a constructor if it can given this type: data Foo = FooC Int | BarC Int deriving (Data, Typeable, Show) i can do this: > let a::Maybe Foo = foldFunc (Just FooC) (params $ BarC 1) Loading package syb ... linking ... done. > a Just (FooC 1) here is the implementation data Child = forall a. (Typeable a, Data a) => Child a params::(Data a) => a -> [Child] params = gmapQ Child --foldFunc :: (Typeable x, Data y) => (Maybe x) -> [Child] -> Maybe y --foldFunc :: forall y1 y. (Typeable y1, Data y) => Maybe y1 -> [Child] -> Maybe y foldFunc (Just ff) (ch:[]) = applyCtor ff ch foldFunc (Just ff) (ch:tt) = foldFunc (applyFunc ff ch) tt foldFunc Nothing _ = Nothing foldFunc (Just ff) [] = castObj ff where castObj::(Typeable y, Data x) => y -> (Maybe x) castObj = cast applyCtor :: (Typeable x, Data y) => x -> Child -> Maybe y applyCtor ff (Child ch) = do func <- castFunc ff return $ func ch where castFunc::(Typeable y, Data x, Data z) => y -> (Maybe (x -> z)) castFunc = cast applyFunc :: (Typeable x, Typeable y) => x -> Child -> Maybe y applyFunc ff (Child ch) = do func <- castFunc ff return $ func ch where castFunc::(Typeable y, Data x, Typeable z) => y -> (Maybe (x -> z)) castFunc = cast now this is the weird part: --foldFunc :: (Typeable x, Data y) => (Maybe x) -> [Child] -> Maybe y --foldFunc :: forall y1 y. (Typeable y1, Data y) => Maybe y1 -> [Child] -> Maybe y if i uncomment either one of those, (shouldn't they be equivalent?), i get an error, the first one gives me ParseG.hs:44:39: Ambiguous type variable `x' in the constraint: `Typeable x' arising from a use of `applyFunc' at ParseG.hs:44:39-53 Probable fix: add a type signature that fixes these type variable(s) Failed, modules loaded: none. the second one gives me: ParseG.hs:46:24: Could not deduce (Data y1) from the context (Typeable y1, Data y) arising from a use of `castObj' at ParseG.hs:46:24-33 Possible fix: add (Data y1) to the context of the type signature for `foldFunc' In the expression: castObj ff In the definition of `foldFunc': foldFunc (Just ff) [] = castObj ff where castObj :: (Typeable y, Data x) => y -> (Maybe x) castObj = cast ParseG.hs:46:32: Couldn't match expected type `y' against inferred type `y1' `y' is a rigid type variable bound by the type signature for `foldFunc' at ParseG.hs:42:22 `y1' is a rigid type variable bound by the type signature for `foldFunc' at ParseG.hs:42:19 In the first argument of `castObj', namely `ff' In the expression: castObj ff In the definition of `foldFunc': foldFunc (Just ff) [] = castObj ff where castObj :: (Typeable y, Data x) => y -> (Maybe x) castObj = cast Failed, modules loaded: none. So they are not equivalent, so why is that so, and why is this the type signature of the function if i dont give one: > :t foldFunc foldFunc :: forall y1 y. (Typeable y1, Data y) => Maybe y1 -> [Child] -> Maybe y From patai_gergely at fastmail.fm Wed Apr 15 04:13:29 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Wed Apr 15 03:59:56 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <40a414c20904110149o27d508c0u7b7efe0391ffa74d@mail.gmail.com> <1239444601.20625.1310024249@webmail.messagingengine.com> <1239541485.27252.1310127905@webmail.messagingengine.com> <1239575289.5053.1310168171@webmail.messagingengine.com> <1239706019.6858.1310393875@webmail.messagingengine.com> Message-ID: <1239783209.8458.1310568619@webmail.messagingengine.com> > I will test it on a couple of machines, desktops and laptops. Try using a sensible nonzero value with threadDelay. Apparently it brings CPU usage down under Windows while retaining smoothness. However, increasing it from zero results in jerkiness under Linux... > If you take a look what Yampa does: it hides signals and only > exposes signal functions. But that means that the FRP engine > itself could indeed use mutable variables for its signals, as > long as during the evaluation of the circuit at time T no side > effects should occur; the side effects should take place when > the simulation is advanced to T+dT, which is done after the > circuit is fully evaluated at time T. Assuming that everything works as intended, Elerea is indeed free of side effects. As for the underlying engine, I was also considering the Hume language, but it has an unpleasant property that every box (analogous to the signal functions of Yampa) has an implicit delay. In fact, Elerea can be regarded as some kind of delayless Hume if we squint enough. > I'm only a bit worried about your automatic insertion of > delays; this might break referential transparency at time T, > since it depends on the order in which the nodes in the circuit > are evaluated no? The latter could be problematic when doing > evaluation in parallel on multiple cores I guess. Oh, it's problematic enough even on a single core. ;) If the network changes at one place, it might affect evaluation order in a way that delays can start wandering around in dependency cycles far away. It could be interesting to analyse the effects of this behaviour. Either way, this is just a convenience feature for applications where it makes little difference. I was also thinking about providing two versions of the library: one inserting delays, and another giving an error instead. By the way, it's also in the plans to visualise the network. Gergely -- http://www.fastmail.fm - IMAP accessible web-mail From barsoap at web.de Wed Apr 15 04:30:25 2009 From: barsoap at web.de (Achim Schneider) Date: Wed Apr 15 04:17:08 2009 Subject: [Haskell-cafe] Re: ANN: Elerea, another FRP library References: <1239381666.12202.1309941005@webmail.messagingengine.com> <1239444601.20625.1310024249@webmail.messagingengine.com> <1239541485.27252.1310127905@webmail.messagingengine.com> <1239575289.5053.1310168171@webmail.messagingengine.com> <1239706019.6858.1310393875@webmail.messagingengine.com> <1239781327.2103.1310566707@webmail.messagingengine.com> Message-ID: <20090415103025.27ec6954@solaris> "Patai Gergely" wrote: > Am I right thinking that the > NOINLINE pragma on unsafeDupablePerformIO prevents the problem of > multiple evaluation discussed yesterday? > From what I know and experienced, yes. Each individual unsafePerformIO only ever evaluates its action once, and if they are prevented from duplicating, things should work out as intended. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From wren at freegeek.org Wed Apr 15 05:30:30 2009 From: wren at freegeek.org (wren ng thornton) Date: Wed Apr 15 05:16:58 2009 Subject: [Haskell-cafe] Looking for the fastest Haskell primes algorithm In-Reply-To: <7fb8f82f0904140605k147e405dyf28060af003427c0@mail.gmail.com> References: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> <7fb8f82f0904140605k147e405dyf28060af003427c0@mail.gmail.com> Message-ID: <49E5A936.7030105@freegeek.org> Edward Kmett wrote: > You might want to start with the Sieve of Atkin: > > http://en.wikipedia.org/wiki/Sieve_of_Atkin Also worth reading _Lazy wheel sieves and spirals of primes_: http://www.cs.york.ac.uk/ftpdir/pub/colin/jfp97lw.ps.gz -- Live well, ~wren From waldmann at imn.htwk-leipzig.de Wed Apr 15 06:25:49 2009 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Wed Apr 15 06:12:23 2009 Subject: [Haskell-cafe] Re: Looking for the fastest Haskell primes algorithm Message-ID: <49E5B62D.5090400@imn.htwk-leipzig.de> for the API design, always check others before rolling your own. E.g. the (three) functions with "Prime" in their name from http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html I hope they are there for a reason. While we're at it - do we have modPow? modInverse? And of course check their implementation as well (should be straightforward, but you never know). J.W. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 257 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090415/48306b3a/signature.bin From sebf at informatik.uni-kiel.de Wed Apr 15 06:32:21 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Wed Apr 15 06:18:53 2009 Subject: [Haskell-cafe] Code Golf Message-ID: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> Fancy some Codegolf? I wrote the following function for list diagonalization: > diag l = foldr (.) id ((sel l . flip sel) ((:[]).(:))) [] > where > sel = foldr (\a b c -> id : mrg (a c) (b c)) (const []) . map (flip id) > > mrg [] ys = ys > mrg xs [] = xs > mrg (x:xs) (y:ys) = (x.y) : mrg xs ys Self explanatory, isn't it? Here is a test case: *Main> take 10 $ diag [[ (m,n) | n <- [1..]] | m <- [1..]] [(1,1),(1,2),(2,1),(1,3),(2,2),(3,1),(1,4),(2,3),(3,2),(4,1)] I was trying to golf it down [^1] but my brain explodes. If you succeed in reducing keystrokes, I'd be happy to know! Cheers, Sebastian [^1]: http://codegolf.com/ From miguelimo38 at yandex.ru Wed Apr 15 06:43:17 2009 From: miguelimo38 at yandex.ru (MigMit) Date: Wed Apr 15 06:30:08 2009 Subject: [Haskell-cafe] Code Golf In-Reply-To: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> References: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> Message-ID: <49E5BA45.9030002@yandex.ru> If I understand the problem correctly... Prelude> let diag = concat . diags where diags ((x:xs):xss) = [x] : zipWith (:) xs (diags xss) Prelude> take 10 $ diag [[ (m,n) | n <- [1..]] | m <- [1..]] [(1,1),(1,2),(2,1),(1,3),(2,2),(3,1),(1,4),(2,3),(3,2),(4,1)] Sebastian Fischer wrote on 15.04.2009 14:32: > Fancy some Codegolf? > > I wrote the following function for list diagonalization: > > > diag l = foldr (.) id ((sel l . flip sel) ((:[]).(:))) [] > > where > > sel = foldr (\a b c -> id : mrg (a c) (b c)) (const []) . map (flip > id) > > > > mrg [] ys = ys > > mrg xs [] = xs > > mrg (x:xs) (y:ys) = (x.y) : mrg xs ys > > Self explanatory, isn't it? Here is a test case: > > *Main> take 10 $ diag [[ (m,n) | n <- [1..]] | m <- [1..]] > [(1,1),(1,2),(2,1),(1,3),(2,2),(3,1),(1,4),(2,3),(3,2),(4,1)] > > I was trying to golf it down [^1] but my brain explodes. If you succeed > in reducing keystrokes, I'd be happy to know! > > Cheers, > Sebastian > > [^1]: http://codegolf.com/ > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From emax at chalmers.se Wed Apr 15 07:07:39 2009 From: emax at chalmers.se (Emil Axelsson) Date: Wed Apr 15 06:54:07 2009 Subject: [Haskell-cafe] Code Golf In-Reply-To: <49E5BA45.9030002@yandex.ru> References: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> <49E5BA45.9030002@yandex.ru> Message-ID: <49E5BFFB.1010208@chalmers.se> Why not: diag = [(x, sum-x) | sum <- [2..], x <- [1 .. sum-1]] / Emil MigMit skrev: > If I understand the problem correctly... > > Prelude> let diag = concat . diags where diags ((x:xs):xss) = [x] : > zipWith (:) xs (diags xss) > Prelude> take 10 $ diag [[ (m,n) | n <- [1..]] | m <- [1..]] > [(1,1),(1,2),(2,1),(1,3),(2,2),(3,1),(1,4),(2,3),(3,2),(4,1)] > > Sebastian Fischer wrote on 15.04.2009 14:32: >> Fancy some Codegolf? >> >> I wrote the following function for list diagonalization: >> >> > diag l = foldr (.) id ((sel l . flip sel) ((:[]).(:))) [] >> > where >> > sel = foldr (\a b c -> id : mrg (a c) (b c)) (const []) . map >> (flip id) >> > >> > mrg [] ys = ys >> > mrg xs [] = xs >> > mrg (x:xs) (y:ys) = (x.y) : mrg xs ys >> >> Self explanatory, isn't it? Here is a test case: >> >> *Main> take 10 $ diag [[ (m,n) | n <- [1..]] | m <- [1..]] >> [(1,1),(1,2),(2,1),(1,3),(2,2),(3,1),(1,4),(2,3),(3,2),(4,1)] >> >> I was trying to golf it down [^1] but my brain explodes. If you >> succeed in reducing keystrokes, I'd be happy to know! >> >> Cheers, >> Sebastian >> >> [^1]: http://codegolf.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 From lennart at augustsson.net Wed Apr 15 07:09:36 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Wed Apr 15 06:56:05 2009 Subject: [Haskell-cafe] Looking for the fastest Haskell primes algorithm In-Reply-To: <7fb8f82f0904140605k147e405dyf28060af003427c0@mail.gmail.com> References: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> <7fb8f82f0904140605k147e405dyf28060af003427c0@mail.gmail.com> Message-ID: For isPrime you might want to implement the AKS test, http://en.wikipedia.org/wiki/AKS_primality_test On Tue, Apr 14, 2009 at 3:05 PM, Edward Kmett wrote: > You might want to start?with the Sieve of Atkin: > > http://en.wikipedia.org/wiki/Sieve_of_Atkin > > -Edward > > On Tue, Apr 14, 2009 at 8:40 AM, Niemeijer, R.A. > wrote: >> >> Today I happened to need a large list of prime numbers. Obviously this is >> a well-known problem, so I figured there would be something on Hackage that >> I could use. Surprisingly, there isn?t, or if there is it?s not easy to >> find. Searching for prime or primes on Hackage reveals nothing. Searching >> for primes on Hayoo gives Codec.Encryption.RSA.NumberTheory, but that uses >> the inefficient one-liner implementation. The HaskellWiki article on primes >> (http://www.haskell.org/haskellwiki/Prime_numbers) has a number of >> implementations, but the faster they get, the longer and uglier they become. >> >> >> >> Since it?s such a common problem I?d say it would be a good idea to add a >> package to Hackage that exports >> >> primes :: [Integer] >> >> and hides the ugly implementation details. Data.Numbers.Primes seems a >> logical choice for the namespace, but I?m open to suggestions. >> >> >> >> The trick then is to find the most efficient implementation of primes. The >> Haskell wiki article mentions ONeillPrimes.hs as one of the fastest ones, >> but maybe there?s a faster version. So my question is: does anybody know >> what the fastest Haskell algorithm for generating primes is? >> >> _______________________________________________ >> 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 emax at chalmers.se Wed Apr 15 07:11:19 2009 From: emax at chalmers.se (Emil Axelsson) Date: Wed Apr 15 06:57:47 2009 Subject: [Haskell-cafe] Code Golf In-Reply-To: <49E5BFFB.1010208@chalmers.se> References: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> <49E5BA45.9030002@yandex.ru> <49E5BFFB.1010208@chalmers.se> Message-ID: <49E5C0D7.4030308@chalmers.se> Sorry, I misread the task :) / Emil Emil Axelsson skrev: > Why not: > > diag = [(x, sum-x) | sum <- [2..], x <- [1 .. sum-1]] > > / Emil > From david.m.carter at gmail.com Wed Apr 15 07:16:01 2009 From: david.m.carter at gmail.com (David Carter) Date: Wed Apr 15 07:02:30 2009 Subject: [Haskell-cafe] Data.ByteString woes Message-ID: <5a1362990904150416i258d3de5x76d8b8d9c231aa1b@mail.gmail.com> Hi, I am battling with Data.ByteString.Lazy.Char8, and currently losing. Any help gratefully received. Here's my code: import qualified Data.ByteString.Lazy.Char8 as B import Text.Regex.Posix ((=~)) test = B.pack "abc" =~ B.pack "b" :: Bool This works fine without the ".Lazy", and is also fine under GHC 6.8.1, but with GHC 6.10.1, it fails with: No instances for (Text.Regex.Base.RegexLike.RegexLike Text.Regex.Posix.Wrap.Regex B.ByteString, Text.Regex.Base.RegexLike.RegexMaker Text.Regex.Posix.Wrap.Regex Text.Regex.Posix.Wrap.CompOption Text.Regex.Posix.Wrap.ExecOption B.ByteString) I then thought I might work around the problem by converting lazy ByteStrings to strict ones in order to do the regex match. I discovered toChunks, which is advertised in the documentation as type ByteString -> [ByteString], but it actually appears to be of type toChunks :: ByteString -> [Data.ByteString.Internal.ByteString] and I can't see any way of converting a Data.ByteString.Internal.ByteString to a (strict) ByteString. Does anyone know whether this is (a) bug(s) in GHC, Data.ByteString, Text.Regex.Posix or (maybe most likely) my own limited understanding? And any ideas for fixes or workarounds (other than the obvious one of downgrading to GHC 6.8)? Thanks in advance David From g9ks157k at acme.softbase.org Wed Apr 15 07:21:15 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Wed Apr 15 07:07:45 2009 Subject: [Haskell-cafe] Re: ANN: Elerea, another FRP library In-Reply-To: <20090415090307.7153327e@solaris> References: <1239381666.12202.1309941005@webmail.messagingengine.com> <1239734489.27777.1310468547@webmail.messagingengine.com> <20090415090307.7153327e@solaris> Message-ID: <200904151321.15940.g9ks157k@acme.softbase.org> Am Mittwoch, 15. April 2009 09:03 schrieb Achim Schneider: > I don't think using dirty tricks to implement FRP deserves flak, at > all, from my POV, it sounds like complaining that the IO monad is > implemented using C... meaning that if you're that close to bare > thunks, you have every right to use any means necessary to make them > behave properly. It depends. Using unsafe stuff internally, might be acceptable and sometimes necessary. I also use unsafePerformIO in Grapefruit for implementing CSignals although I?m not very comfortable with this. On the other hand, breaking referential transparency in the external interface is a very bad idea, in my opinion. Actually, this means that the library user would have to turn certain compiler optimizations off to get the intended behavior. Just have a look at the Haddock docs of unsafePerformIO. In my earlier years of Haskell programming, I thought that unsafePerformIO is not too bad but I had to discover that it can quickly lead to a catastrophe. Best wishes, Wolfgang From sebf at informatik.uni-kiel.de Wed Apr 15 07:28:56 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Wed Apr 15 07:15:30 2009 Subject: [Haskell-cafe] Code Golf In-Reply-To: <49E5BA45.9030002@yandex.ru> References: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> <49E5BA45.9030002@yandex.ru> Message-ID: > Prelude> let diag = concat . diags where diags ((x:xs):xss) = [x] : > zipWith (:) xs (diags xss) this has a different semantics on finite lists, so I should add a test case: *Main> diag [[1,2,3],[4,5,6],[7,8,9]] [1,2,4,3,5,7,6,8,9] Your version yields [1,2,4,3,5,7]. Actually, there are a number of implementations that implement the same behaviour as the original version, e.g., diag = concat . foldr diags [] where diags [] ys = ys diags (x:xs) ys = [x] : merge xs ys merge [] ys = ys merge xs@(_:_) [] = map (:[]) xs merge (x:xs) (y:ys) = (x:y) : merge xs ys I'd be interested if one can *derive* from the original version a simpler version using clever pointfree combinators. Cheers, Sebastian From g9ks157k at acme.softbase.org Wed Apr 15 07:33:00 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Wed Apr 15 07:19:30 2009 Subject: [Haskell-cafe] Non-atomic "atoms" for type-level programming In-Reply-To: <49E4CF96.5010402@cs.au.dk> References: <49E4CF96.5010402@cs.au.dk> Message-ID: <200904151333.00972.g9ks157k@acme.softbase.org> Am Dienstag, 14. April 2009 20:01 schrieb Tillmann Rendel: > How is the need for a common import for 'data TTrue; data TFalse' > different then the need for a common import for 'data Bool = True | False'? Why not say data True data False, instead of data TTrue data TFalse? I don?t see the reason why we should insert the ?T?. Data constructors are in a different namespace than type constructors. By the way, the grapefruit-records package imports type-level, only to not define its own type-level booleans but to reuse ?common? types whereas I considered type-level as the standard type level programming library. Best wishes, Wolfgang From barsoap at web.de Wed Apr 15 07:39:00 2009 From: barsoap at web.de (Achim Schneider) Date: Wed Apr 15 07:25:47 2009 Subject: [Haskell-cafe] Re: Data.ByteString woes References: <5a1362990904150416i258d3de5x76d8b8d9c231aa1b@mail.gmail.com> Message-ID: <20090415133900.0b4b25e2@solaris> David Carter wrote: > I then thought I might work around the problem by converting lazy > ByteStrings to strict ones in order to do the regex match. > strictBS :: LB.ByteString -> B.ByteString strictBS = B.concat . LB.toChunks lazyBS :: B.ByteString -> LB.ByteString lazyBS = LB.fromChunks . pure -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From miguelimo38 at yandex.ru Wed Apr 15 07:42:57 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Wed Apr 15 07:29:30 2009 Subject: [Haskell-cafe] Code Golf In-Reply-To: References: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> <49E5BA45.9030002@yandex.ru> Message-ID: <49E5C841.3030500@yandex.ru> What about diag [[1,2,3],[4],[5,6,7]] ? What it should be? Sebastian Fischer wrote on 15.04.2009 15:28: >> Prelude> let diag = concat . diags where diags ((x:xs):xss) = [x] : >> zipWith (:) xs (diags xss) > > this has a different semantics on finite lists, so I should add a test > case: > > *Main> diag [[1,2,3],[4,5,6],[7,8,9]] > [1,2,4,3,5,7,6,8,9] > > Your version yields [1,2,4,3,5,7]. > > Actually, there are a number of implementations that implement the same > behaviour as the original version, e.g., > > diag = concat . foldr diags [] > where diags [] ys = ys > diags (x:xs) ys = [x] : merge xs ys > > merge [] ys = ys > merge xs@(_:_) [] = map (:[]) xs > merge (x:xs) (y:ys) = (x:y) : merge xs ys > > I'd be interested if one can *derive* from the original version a > simpler version using clever pointfree combinators. > > Cheers, > Sebastian > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jules at jellybean.co.uk Wed Apr 15 07:49:19 2009 From: jules at jellybean.co.uk (Jules Bean) Date: Wed Apr 15 07:35:49 2009 Subject: [Haskell-cafe] Ambiguous reified dictionaries In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C335081889AC@EA-EXMSG-C334.europe.corp.microsoft.com> References: <49DDB337.2050205@van.steenbergen.nl> <638ABD0A29C8884A91BC5FB5C349B1C335081889AC@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <49E5C9BF.3050008@jellybean.co.uk> Simon Peyton-Jones wrote: > Yes, Haskell says that in any program there should be only one > instance for any particular type (here Monoid Int). GHC > doesn't check that, but it should really do so. It's not > necessary for soundness (ie no runtime crash) but it is > necessary for coherence (ie when you run the program the answer > you get doesn't depend on which dictionary the typechecker > arbitrarily chose). Unless of course, your program implicitly depends on the coherence of dictionary choice for its own soundness, for example, a program using Data.Typeable to implement Dynamic or similar. Jules From sebf at informatik.uni-kiel.de Wed Apr 15 07:53:09 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Wed Apr 15 07:39:42 2009 Subject: [Haskell-cafe] Code Golf In-Reply-To: <49E5C841.3030500@yandex.ru> References: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> <49E5BA45.9030002@yandex.ru> <49E5C841.3030500@yandex.ru> Message-ID: > diag [[1,2,3],[4],[5,6,7]] > What it should be? *Main> diag [[1,2,3],[4],[5,6,7]] [1,2,4,3,5,6,7] it's basically just "skipping holes": 1 2 3 4 5 6 7 From claus.reinke at talk21.com Wed Apr 15 08:03:53 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Wed Apr 15 07:50:27 2009 Subject: [Haskell-cafe] Non-atomic "atoms" for type-level programming References: <49E4CF96.5010402@cs.au.dk> Message-ID: <4768685957FD41A8B4330D1E732BAC89@cr3lt> >> - if type-level tags (such as 'data TTrue'/'data TFalse') are declared >> repeatedly in separate modules, they represent separate types, >> preventing shared use (your type-level predicate doesn't return >> my version of 'TTrue'/'TFalse') > > How is the need for a common import for 'data TTrue; data TFalse' > different then the need for a common import for 'data Bool = True | False'? 'Bool' is hardcoded at the language level (if/then/else), not just standard library, not just implicitly imported Prelude, so that seems very stable - stable enough for a single common standard library import (unlike many type-level programming concepts, which still require experimentation and variation). But even that is considered too unflexible - some users want alternative Preludes (be it temporarily, to develop a better standard, or permanently, for personal preferences), most authors of embedded domain-specific languages have wanted to replace 'Bool' and associated syntax/classes/ operations with a variant matching their needs. Now you have several definitions of 'Bool', some of which may be compatible with each other (say, two variants of FRP libraries that both simply lift 'Bool' into 'Time->Bool'). How do you, as a library user, express that two compatible types from different sources are to be considered equivalent, without forcing the authors of the compatible definitions to collaborate on a common "standard" library for both their projects? It is not a question of possible-in-theory, it is a question of pragmatics. The need to go beyond common imports, temporarily (as systems evolve) or permanently (because tree-like hierarchies do not fit all modularization strategies), exists for 'Bool' as well as for 'TBool'. Standard ML's answer to that kind of issue is type sharing. Haskell has no equivalent. Haskell has further needs in going beyond plain hierarchical import structures, though - think of the proposals for class aliases, or the question of how to split up package dependencies without relying on orphan instances, how to depend on packages in specific configurations, etc. Again, the ML family of advanced module systems has some answers to offer (and, yes, we can encode much of those in Haskell's type system, but who does that when writing cabal packages?). Haskell'98, by design, had the simplest module system it could get away with. These days, additional layers have accumulated around this core, based on libraries and cabal packages. These layers run into all the problems of advanced module systems, only that these problems currently aren't acknowledged as language design problems, but are treated as issues to hack around whenever someone is available to do the hacking. > Clearly, the advent of type-level programming necessitates the design of > a type-level standard library, which provides standard abstractions to > enable interoperation of custom libraries. But I don't see why the > module system should not scale to type-level programming. Haskell's module system is an embarrassment ignoring decades of research, its one strong point being its simplicity. There has long been an implicit assumption that advances in modular programming would come either via the type class system, or via extensible records, and that these advanced would happen within modules, without having to evolve the module system beyond simple namespace management. In practice, cabal and hackage have changed all that, introducing a de-facto module configuration system on top of the existing modules, with an evolving design. My typed non-atomic atoms don't fix any of that, but they do seem to offer a workaround for a single issue that has been around for years, and has led to several trac tickets and type-level library awkwardnesses. For instance, it isn't necessary to pre-define hundreds of constant literals for a type-level numeric library if they can be generated in client code, nor is it necessary to hand-define or template-generate an ordering relation on constructors (which some type-level libraries depend on) if it can be defined once and for all. Non of this means that it wouldn't be good to have a standard library for type-level programming - in fact, I'd expect a revised Data.Label to become a small part of such standard!-) Claus ps. If you want to know more about my view on module systems for functional languages, have a look at chapter 4 of http://community.haskell.org/~claus/publications/phd.html , titled "Module Systems for Functional Languages". It is slightly dated by now -lots of things have happened in program (de-)composition research since 1997, when that was written-, but the basis for Haskell's module system is much more ancient that that, so it might be interesting for new Haskellers to see just how old some of Haskell's "advanced" ideas really are;-) From jac at informatik.uni-kiel.de Wed Apr 15 08:12:35 2009 From: jac at informatik.uni-kiel.de (Jan Christiansen) Date: Wed Apr 15 07:59:10 2009 Subject: [Haskell-cafe] Code Golf In-Reply-To: References: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> <49E5BA45.9030002@yandex.ru> Message-ID: Hi, On 15.04.2009, at 13:28, Sebastian Fischer wrote: > Actually, there are a number of implementations that implement the > same behaviour as the original version, e.g., > > diag = concat . foldr diags [] > where > diags [] ys = ys > diags (x:xs) ys = [x] : merge xs ys > > merge [] ys = ys > merge xs@(_:_) [] = map (:[]) xs > merge (x:xs) (y:ys) = (x:y) : merge xs ys I think your first implementation is a slightly unreadable : ) implementation of this version but uses functional lists instead of standard lists. If we replace some of the lists by functional lists we get the following diag :: [[a]] -> [a] diag = toList . concatFL . foldr diags2 [] where diags [] ys = ys diags (x:xs) ys = (x:) : merge xs ys merge [] ys = ys merge xs@(_:_) [] = map (:) xs merge (x:xs) (y:ys) = ((x:) . y) : merge xs ys with the following definitions concatFL :: [[a] -> [a]] -> [a] -> [a] concatFL = foldr (.) id toList :: ([a] -> [a]) -> [a] toList fl = fl [] Additionally we can move the 'map (:)' in merge to diags diag :: [[a]] -> [a] diag = toList . concatFL . foldr diags [] where diags [] ys = ys diags (x:xs) ys = (x:) : merge (map (:) xs) ys merge [] ys = ys merge xs@(_:_) [] = xs merge (x:xs) (y:ys) = (x . y) : merge xs ys If we now replace toList and concatFL by its definitions it looks very similar to the original implementation. diag :: [[a]] -> [a] diag = foldr (.) id (foldr diags []) [] where diags [] ys = ys diags (x:xs) ys = (x:) : merge (map (:) xs) ys merge [] ys = ys merge xs@(_:_) [] = xs merge (x:xs) (y:ys) = (x . y) : merge xs ys > diag l = foldr (.) id ((sel l . flip sel) ((:[]).(:))) [] > where > sel = foldr (\a b c -> id : mrg (a c) (b c)) (const []) . map (flip id) > > mrg [] ys = ys > mrg xs [] = xs > mrg (x:xs) (y:ys) = (x.y) : mrg xs ys I guess that we can inline diags and get the definition above but I am kind of stuck here. Cheers, Jan From bugfact at gmail.com Wed Apr 15 08:20:14 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 15 08:06:42 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: <1239781327.2103.1310566707@webmail.messagingengine.com> References: <1239381666.12202.1309941005@webmail.messagingengine.com> <1239541485.27252.1310127905@webmail.messagingengine.com> <1239575289.5053.1310168171@webmail.messagingengine.com> <1239706019.6858.1310393875@webmail.messagingengine.com> <1239781327.2103.1310566707@webmail.messagingengine.com> Message-ID: Well, a breakout game does *not* work (yet) in most other FRP implementations except Yampa, which do have firm theoretical foundations :-) 2009/4/15 Patai Gergely > > I don't think using dirty tricks to implement FRP deserves > > flak, at all, from my POV, it sounds like complaining that the > > IO monad is implemented using C... meaning that if you're that > > close to bare thunks, you have every right to use any means > > necessary to make them behave properly. > Dirtiness is not the problem, but the fact that it can leak out at the > present moment. I want guarantees to exclude the possibility of > undesired behaviour on the user side. Am I right thinking that the > NOINLINE pragma on unsafeDupablePerformIO prevents the problem of > multiple evaluation discussed yesterday? Or should I add NOINLINE to > primitives in Elerea.Internal too? If that guaranteed sharing, it would > certainly solve most of the problems we talked about. Apart from that, > I'm still not sure that latching works the way intended all the time, > but the fact that the breakout example works is an indication that at > least it's not hopelessly broken. > > Gergely > > -- > http://www.fastmail.fm - Access all of your messages and folders > wherever you are > > _______________________________________________ > 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/20090415/2e56900d/attachment.htm From jgoerzen at complete.org Wed Apr 15 09:35:00 2009 From: jgoerzen at complete.org (John Goerzen) Date: Wed Apr 15 09:21:33 2009 Subject: [Haskell-cafe] GHC including System.Time but not Data.Time? In-Reply-To: References: <20090414164412.GA18145@hustlerturf.com> <1821198027.20090414205647@gmail.com> Message-ID: <49E5E284.2080501@complete.org> Lennart Augustsson wrote: > Removing a package in a minor release is, to quote, an epic fail. > I don't understand how that could be done. I agree. Is there any chance of 6.10.3 reverting the change? -- John > > -- Lennart > > On Tue, Apr 14, 2009 at 6:56 PM, Bulat Ziganshin > wrote: >> Hello John, >> >> Tuesday, April 14, 2009, 8:44:12 PM, you wrote: >> >>> I understand the goal of removing stuff from GHC, but the practical >>> implications can be rather annoying. >> i think that Haskell Platform will eventually replace what GHC was for >> a years, i.e. out-of-box solution for practical haskell usage. and ghc >> should be just what its name implies - bare compiler >> >> but i agree that stripping one package in minor 6.10.2 version, w/o >> Haskell Platform really available was an error >> >> -- >> 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 Wed Apr 15 09:47:18 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Apr 15 09:34:05 2009 Subject: [Haskell-cafe] GHC including System.Time but not Data.Time? In-Reply-To: <49E5E284.2080501@complete.org> References: <20090414164412.GA18145@hustlerturf.com> <1821198027.20090414205647@gmail.com> <49E5E284.2080501@complete.org> Message-ID: <1231155101.20090415174718@gmail.com> Hello John, Wednesday, April 15, 2009, 5:35:00 PM, you wrote: > I agree. Is there any chance of 6.10.3 reverting the change? both 6.6 and 6.8 had last releases at spring, so i don't expect new 6.10.* at all -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From conor at strictlypositive.org Wed Apr 15 10:10:17 2009 From: conor at strictlypositive.org (Conor McBride) Date: Wed Apr 15 09:56:45 2009 Subject: [Haskell-cafe] types and braces Message-ID: <8F56CE9D-3551-4EC4-A18C-4B87BB3CEC16@strictlypositive.org> Hi folks In search of displacement activity, I'm trying to tweak Language.Haskell.Exts to support a few more perfidious Exts I have in mind -- they only need a preprocessor, but I do need to work on parsed programs, ideally. I was hoping to add a production to the grammar of types to admit expressions, delimited by braces: { exp } The idea is that instead of writing, (er, hi Claus), data True data False one just re-uses yer actual Bool (which becomes kind {Bool}) and writes {True} or {False}. The trouble is, the production I've added causes a reduce/reduce conflict in the grammar, but I don't get any more precise complaint than that. I guess what I'd like to know is whether I just need to debug my grammar extension, or whether the notation I'm proposing actually introduces a serious ambiguity that I'm too dim to notice. I'm mostly sending this in the hope that I have one of those "d'oh" moments you sometimes get when you articulate a stupid question in public. Put me out of my misery, please... Cheers Conor From florent.becker at ens-lyon.org Wed Apr 15 10:04:50 2009 From: florent.becker at ens-lyon.org (Florent Becker) Date: Wed Apr 15 10:01:30 2009 Subject: [Haskell-cafe] Re: [ANNOUNCE] hgettext 0.1.10 - last major release References: <8feb08f70904141418k3be64346xa0ddf52a33a5b816@mail.gmail.com> Message-ID: Vasyl Pasternak writes: > Hello, > > I've uploaded last (and latest) significant version on hgettext > module. Currently it works fine, and has bindings to all gettext > functions (from libintl.h). Next versions will be only bug fixes of > this version. > I don't see any strong reasons to write any combinators over this > basic bindings. Haskell needs more powerful internationalization > library, and I am plan to design it, but it will be completely > different from gettext principles, so this library will be released > with another name. > Does this means that the string files (if they exist at all) won't be in po format, or some approximation thereof? This could be a problem for translators. Florent From lennart at augustsson.net Wed Apr 15 11:01:54 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Wed Apr 15 10:48:22 2009 Subject: [Haskell-cafe] types and braces In-Reply-To: <8F56CE9D-3551-4EC4-A18C-4B87BB3CEC16@strictlypositive.org> References: <8F56CE9D-3551-4EC4-A18C-4B87BB3CEC16@strictlypositive.org> Message-ID: I'd suggest using some different kind of brackets to relieve the misery, like {| |}. On Wed, Apr 15, 2009 at 4:10 PM, Conor McBride wrote: > Hi folks > > In search of displacement activity, I'm trying to tweak > Language.Haskell.Exts to support a few more perfidious > Exts I have in mind -- they only need a preprocessor, > but I do need to work on parsed programs, ideally. > > I was hoping to add a production to the grammar of types > to admit expressions, delimited by braces: > > ?{ exp } > > The idea is that instead of writing, (er, hi Claus), > > data True > data False > > one just re-uses yer actual Bool (which becomes kind > {Bool}) and writes {True} or {False}. > > The trouble is, the production I've added causes a > reduce/reduce conflict in the grammar, but I don't get > any more precise complaint than that. > > I guess what I'd like to know is whether I just need to > debug my grammar extension, or whether the notation I'm > proposing actually introduces a serious ambiguity that > I'm too dim to notice. I'm mostly sending this in the > hope that I have one of those "d'oh" moments you > sometimes get when you articulate a stupid question in > public. > > Put me out of my misery, please... > > Cheers > > Conor > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From conor at strictlypositive.org Wed Apr 15 11:13:08 2009 From: conor at strictlypositive.org (Conor McBride) Date: Wed Apr 15 10:59:37 2009 Subject: [Haskell-cafe] types and braces In-Reply-To: References: <8F56CE9D-3551-4EC4-A18C-4B87BB3CEC16@strictlypositive.org> Message-ID: On 15 Apr 2009, at 16:01, Lennart Augustsson wrote: > I'd suggest using some different kind of brackets to relieve the > misery, like {| |}. That would speed up my tinkering, certainly. I did have a d'oh moment: you can write data Foo = Moo {goo :: Int} -- braces where a type goes and indeed, commenting out field declarations makes happy happy. However, these { exp } guys never stand as types of things, only as parameters of types, so it might be possible to resolve the problem without fat brackets. Whether it's worth it is another matter... Cheers Conor From d at vidplace.com Wed Apr 15 11:21:26 2009 From: d at vidplace.com (David F. Place) Date: Wed Apr 15 11:03:19 2009 Subject: [Haskell-cafe] cabal install vs. profiling Message-ID: <1239808886.3208.11.camel@Congo> Hi, Suppose I have installed a number of libraries and have written a program using them. Now, I want to profile my program. What is the best way to get the profiling versions of the libraries installed? Thanks, David From gwern0 at gmail.com Wed Apr 15 11:20:12 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Wed Apr 15 11:07:05 2009 Subject: [Haskell-cafe] cabal install vs. profiling In-Reply-To: <1239808886.3208.11.camel@Congo> Message-ID: On Wed, Apr 15, 2009 at 11:21 AM, David F. Place wrote: > Hi, > > Suppose I have installed a number of libraries and have written a > program using them. ?Now, I want to profile my program. ?What is the > best way to get the profiling versions of the libraries installed? > > Thanks, > David I'd chuck 'library-profiling: True' into my .cabal/config, and do 'cabal install --reinstall ' (being careful to exclude the core libraries like unix and process). -- gwern -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 270 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090415/40db4178/signature.bin From sebf at informatik.uni-kiel.de Wed Apr 15 11:27:14 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Wed Apr 15 11:13:46 2009 Subject: [Haskell-cafe] ANN: level-monad-0.3 Message-ID: I am pleased to announce version 0.3 of the package level-monad. This package implements breadth-first search directly as an instance of MonadPlus (without using an intermediate tree representation). In version 0.3 I have added a MonadPlus instance for iterative deepening inspired by Michael Spivey's paper on "Algebras for combinatorial search"[1]. The package is on Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/level-monad Sources are on Github: http://github.com/sebfisch/level-monad Cheers, Sebastian [1]: http://spivey.oriel.ox.ac.uk/mike/search-jfp.pdf From aneumann at inf.fu-berlin.de Wed Apr 15 11:27:08 2009 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Wed Apr 15 11:13:57 2009 Subject: [Haskell-cafe] Looking for the fastest Haskell primes algorithm In-Reply-To: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> References: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> Message-ID: <95E378AF-7DE7-4336-B733-7C8E689B9E93@inf.fu-berlin.de> I've just uploaded a package with some functions I had lying around. > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Numbers Am 14.04.2009 um 14:40 schrieb Niemeijer, R.A.: > Today I happened to need a large list of prime numbers. Obviously > this is a well-known problem, so I figured there would be something > on Hackage that I could use. Surprisingly, there isn?t, or if there > is it?s not easy to find. Searching for prime or primes on Hackage > reveals nothing. Searching for primes on Hayoo gives > Codec.Encryption.RSA.NumberTheory, but that uses the inefficient > one-liner implementation. The HaskellWiki article on primes (http:// > www.haskell.org/haskellwiki/Prime_numbers) has a number of > implementations, but the faster they get, the longer and uglier > they become. > > > > Since it?s such a common problem I?d say it would be a good idea to > add a package to Hackage that exports > > primes :: [Integer] > > and hides the ugly implementation details. Data.Numbers.Primes > seems a logical choice for the namespace, but I?m open to suggestions. > > > > The trick then is to find the most efficient implementation of > primes. The Haskell wiki article mentions ONeillPrimes.hs as one of > the fastest ones, but maybe there?s a faster version. So my > question is: does anybody know what the fastest Haskell algorithm > for generating primes is? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: Signierter Teil der Nachricht Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090415/c1e2840b/PGP.bin From mhenrion at gmail.com Wed Apr 15 11:40:42 2009 From: mhenrion at gmail.com (Maxime Henrion) Date: Wed Apr 15 11:27:12 2009 Subject: [Haskell-cafe] Fast mutable arrays of ByteString? Message-ID: <1239810042.70612.23.camel@localhost> Hello all, I have been rewriting a small utility program of mine from C to Haskell for fun. This tool reads lines from stdin or from files, shuffles them one or more times using the Fisher-Yates algorithm, and outputs the result to stdout. Since this algorithm is based on in-place updates, I've been storing my strings in a mutable array in the ST monad. Since it's holding strings I could not use an unboxed array. The resulting program works fine and seems to run at a decent speed, even though it is much slower than the original C version, slightly more so than I expected. While trying to optimize it using profiling, and playing with the number of shuffling passes, I noticed that this operation was responsible for a significant amount of the runtime, much more so than with the C version. I also noticed that the %GC time was around 56%. In order to do more tests, I wrote another version of this program which keeps the strings in a pure and immutable array, and stores the indices of this array in an unboxed mutable ST array. The shuffling is then done on this indices array instead of the strings array. This version runs much faster and only spends ~21% of its time in the garbage collector, at the cost of consuming more memory for the indices array. I'm attaching both versions of the code to this e-mail, and I'd be curious to hear about any possible improvements to it, and whether the performance of STArray of ByteString I'm observing corresponds to people's expectations. Thanks in advance, Maxime Henrion -------------- next part -------------- A non-text attachment was scrubbed... Name: Shuffle.hs Type: text/x-haskell Size: 2745 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090415/1e21db54/Shuffle.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: Shuffle2.hs Type: text/x-haskell Size: 2896 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090415/1e21db54/Shuffle2.bin From simonpj at microsoft.com Wed Apr 15 12:00:43 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Wed Apr 15 11:47:12 2009 Subject: [Haskell-cafe] Strange type error with associated type synonyms In-Reply-To: References: <646230a00904061436x41af1055se39e8892eb4e3083@mail.gmail.com><4580278B-D5B6-4A4E-9233-415B57F60A3E@cse.unsw.edu.au><1bc51a990904070348p7e6fc849qeaa45b155279e435@mail.gmail.com><9DC371FCEE914C19966965FB38881AC1@cr3lt><638ABD0A29C8884A91BC5FB5C349B1C335080DECA1@EA-EXMSG-C334.europe.corp.microsoft.com><3E3186D9A0F34311825C9D476DB9F1D9@cr3lt> <638ABD0A29C8884A91BC5FB5C349B1C33508188D5B@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C33751DDBD3A@EA-EXMSG-C334.europe.corp.microsoft.com> | But the core part of my suggestion (which this example was meant | to help explain) remains attractive, at least to me: somewhere during | type inference, GHC *does* unify the *apparently free* 'd' with an | internal type variable (lets call it 'd1, as in the type error message) You are speculating about the *algorithm*. I rather doubt that exposing more of the algorithm to users is going to be helpful; the whole point of a declarative description of the type system is that it specifies which programs are typeable without giving the nitty gritty of an algorithm. Even I, who implemented GHC's current algorithm, cannot follow your algorithmic explanation. | that has no explicit counterpart in source code or type signature, | so the inferred type should not be | | f' :: forall d. (Fun d) => Memo d a -> Memo d a -- (1) | | but rather | | f' :: forall d. (Fun d,d~d1) => Memo d a -> Memo d a -- (2) What is this d1? Where is it bound? | All I'm suggesting is that the type *printed* by GHCi does not | really represent the type *inferred* by GHCi (or else there should | not be any attempt to match the *free* 'd' against some unknown | 'd1', as the error message says), and that there might be ways to | make the discrepancy explicit, by printing the inferred type differently. I believe that it *does* really represent the type inferred by GHC, in fact. Simon From bugfact at gmail.com Wed Apr 15 12:21:51 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 15 12:08:19 2009 Subject: [Haskell-cafe] Re: Maybe off-topic -- Writing contracts or software specifications In-Reply-To: <20090414112742.0ac94673@solaris> References: <20090414112742.0ac94673@solaris> Message-ID: There's one sentence I remember from some Extreme Programming books I read: "the customer only knows what he wants when he gets it" :-) On Tue, Apr 14, 2009 at 11:27 AM, Achim Schneider wrote: > "Richard O'Keefe" wrote: > > > If you have a low level of trust, you'll need a great level of > > detail, and it still won't help. > > > Heh. Keep your friends close, your enemies closer. > > Freelancing, I was always paid per hour, not per feature. From my > experience, writing something like "The contractor will work closely > with an employee designated by Foo to ensure formal and informal, known > or yet to be discovered, specifications are implemented" is the best > thing you can do. If you have it, mention your QA and its guidelines. > If you don't have it, get both. [1] > > It's more than enough to boot a bad teamplayer out of his contract, > doesn't induce frowns in top coders (SNAFU, as those are the ones you > want to hire), does not risk mis-specifying requirements (which, with > legal backing, is also SNAFU) and doesn't take longer and/or cost more > to work out than the program itself (SNAFU, again). Be sure that not > only bugs are fixed, but the reasons they appeared in the first place, > too: That's the secret people writing space shuttle control software and > similar use. > > > [1] Even if it's just one guy working out things like "Every function > must be documented" and me getting a bug report saying "Help text > does not mention how to display help text". > -- > (c) this sig last receiving data processing entity. Inspect headers > for copyright history. All rights reserved. Copying, hiring, renting, > performance and/or quoting of this signature prohibited. > > > _______________________________________________ > 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/20090415/722c48f1/attachment.htm From claus.reinke at talk21.com Wed Apr 15 12:39:45 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Wed Apr 15 12:26:19 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library References: <1239381666.12202.1309941005@webmail.messagingengine.com><1239541485.27252.1310127905@webmail.messagingengine.com><1239575289.5053.1310168171@webmail.messagingengine.com><1239706019.6858.1310393875@webmail.messagingengine.com><1239781327.2103.1310566707@webmail.messagingengine.com> Message-ID: <2B9AE96A81BB4D45B8960B2B3536DEB5@cr3lt> >> but the fact that the breakout example works is an indication that at >> least it's not hopelessly broken. > Well, a breakout game does *not* work (yet) in most other FRP > implementations except Yampa, which do have firm theoretical foundations :-) While certainly more entertaining, the problem looks similar enough to the NLift example (a lift serving requests on n floors[0]) in FunWorlds (the 2002 OpenGL version[1], not the 2001 VRML version[2]), chosen to test some expressiveness aspects of the language: - a dynamically updated collection (requests in NLift, bricks in breakout) - an object moving in response to user input (lift/paddle+ball) - collection and object reacting to each other's relative positions (lift at floor levels/paddle ball brick collisions) In NLift, user input (keyboard) adds to the requests collection, and the lift reacts to the request collection and its own status, while in breakout, user input (mouse) directly controls the paddle, to which the ball reacts. The lift stopping at a floor directly removes a request there, while breakout bricks disappear when hit by the additional ball. In NLift, collisions and movement are one-dimensional, while breakout is two-dimensional. On the other hand, I hadn't got round to cleaning up the interface, let alone firming the theoretical foundations, so perhaps this isn't an exception to your rule?-) But I thought I'd mention it on the topic of "other FRP libraries", with variations of approach/concepts. Claus [0] http://community.haskell.org/~claus/FunWorlds/NLift.hs [1] http://community.haskell.org/~claus/FunWorlds/ [2] http://community.haskell.org/~claus/FunWorlds/VRML/ FunWorlds/OpenGL in brief: - a behaviour is a description of an experiment - a behaviour can be sampled (performing the experiment), yielding a current value and a residual behaviour (the latter replaces the original behaviour) - the results of measurements can be broadcast and observed via behavioural channels (a channel observer simply behaves as the channel source behaviour, with a slight delay) That's it! The is no special role for time at all. One can establish local clocks, one can even broadcast their ticking behaviours. But one cannot take an arbitrary absolute time and ask for the value of a behaviour at that time (other than actually running that behaviour forward or backward from "now"). Also, there is a natural distinction between describing and running a behaviour, with the ability to refer to either the description or to sample outcomes. And having the same behaviour description on both sides of an event in a stepper/until does not mean that nothing changes at the step: the second copy doesn't continue where the first left off, but starts from its own beginning (with no special tricks to achieve this). There are no separate events, and delays enter via behavioural channels. Well, there were lots of negatives as well (eg FunWorlds was an "engine-exposed" workbench rather than a user-directed library), but I thought I'd try to get you interested first!-) I'd love to have funding to work out the details and clean up/modernize the interface, but without funding, it'll just have to wait until I get round to it (or one of the newer FRP libraries renders it superfluous..). If you try the examples, you'll notice that some of them run too fast on modern machines (because they weren't tied to an external clock), so you'd have to slow them down (eg, Surface and Torus, in addition to the standard rotate/scale controls, also react to 't'/'T' for scaling time) but they are are still fun to watch in their naivete (try Boids for simplicity, Flock2 for chaos - you'll need to scale it 's'/'S'). From niklas.broberg at gmail.com Wed Apr 15 14:27:07 2009 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Wed Apr 15 14:13:34 2009 Subject: [Haskell-cafe] types and braces In-Reply-To: <8F56CE9D-3551-4EC4-A18C-4B87BB3CEC16@strictlypositive.org> References: <8F56CE9D-3551-4EC4-A18C-4B87BB3CEC16@strictlypositive.org> Message-ID: Hi Conor, Conor McBride: > The trouble is, the production I've added causes a > reduce/reduce conflict in the grammar, but I don't get > any more precise complaint than that. To get more precise complaints, you should give the -i flag to happy, that will cause happy to print the whole parser table into a file named Parser.info. It also tells you in which states the conflicts occur, allowing you to track 'em down. > I guess what I'd like to know is whether I just need to > debug my grammar extension, or whether the notation I'm > proposing actually introduces a serious ambiguity that > I'm too dim to notice. I'm mostly sending this in the > hope that I have one of those "d'oh" moments you > sometimes get when you articulate a stupid question in > public. I don't immediately see what the clash in that context would be - I *think* what you propose should be doable. I'd be interested to know what you come up with, or I might have a look at it myself when I find a few minutes to spare. Cheers, /Niklas From conor at strictlypositive.org Wed Apr 15 14:58:11 2009 From: conor at strictlypositive.org (Conor McBride) Date: Wed Apr 15 14:44:46 2009 Subject: [Haskell-cafe] types and braces In-Reply-To: References: <8F56CE9D-3551-4EC4-A18C-4B87BB3CEC16@strictlypositive.org> Message-ID: <61D885C2-990B-458F-83F6-1719AD6E627F@strictlypositive.org> Hi Niklas Good to hear from you, and thanks for providing such a useful starting point for my experiments. On 15 Apr 2009, at 19:27, Niklas Broberg wrote: > Hi Conor, > > Conor McBride: >> The trouble is, the production I've added causes a >> reduce/reduce conflict in the grammar, but I don't get >> any more precise complaint than that. > > To get more precise complaints, you should give the -i flag to happy, > that will cause happy to print the whole parser table into a file > named Parser.info. It also tells you in which states the conflicts > occur, allowing you to track 'em down. So that's how you do it! I was expecting that some such thing would exist. > > >> I guess what I'd like to know is whether I just need to >> debug my grammar extension, or whether the notation I'm >> proposing actually introduces a serious ambiguity that >> I'm too dim to notice. I'm mostly sending this in the >> hope that I have one of those "d'oh" moments you >> sometimes get when you articulate a stupid question in >> public. > > I don't immediately see what the clash in that context would be - I > *think* what you propose should be doable. I'd be interested to know > what you come up with, or I might have a look at it myself when I find > a few minutes to spare. I've found that I can add a production atype :: { Type } ... | '{' trueexp '}' if I remove the productions for record declarations constr1 :: { ConDecl } | con '{' '}' { RecDecl $1 [] } | con '{' fielddecls '}' { RecDecl $1 (reverse $3) } which suggests that it is indeed the syntax data Moo = Foo {goo :: Boo Hoo} which is in apparent conflict with my proposed extension. The current parser uses the type parser btype to parse the initial segment of constructor declarations, so my change causes trouble. Further trouble is in store from infix constructors data Noo = Foo {True} :*: Foo {False} should make sense, but you have to look quite far to distinguish that from a record. So I don't see that my proposed extension introduces a genuine ambiguity, but it does make the parser a bit knottier. I can use (|...|) as the brackets I need in the meantime, without even disturbing the lexer, but I'd much rather use {...} if I can learn a bit more happy hacking. My efforts so far have been clumsy and frustrating, but -i might help me see what I'm doing wrong. Subtle stuff Conor From nowgate at yahoo.com Wed Apr 15 15:13:12 2009 From: nowgate at yahoo.com (michael rice) Date: Wed Apr 15 14:59:46 2009 Subject: [Haskell-cafe] Enum to String, and back? Message-ID: <35770.75113.qm@web31107.mail.mud.yahoo.com> Hi, Using Show it is possible to establish a relationship between an enum type data Color ??? = Red ??? | Blue ??? | Green ??? | Yellow ??? | Orange ??? | Brown ??? | White ??? | Black ??? deriving (Show, Eq, Enum, Bounded) and a String type to display it. *Main> Red Red *Main> [Red,Green,Blue] [Red,Green,Blue] *Main> which is Red :: Color -> "Red" :: [Char] Can one as easily establish a reverse relationship, i.e., convert a String type like "Red" back to its corresponding Color type? So that "Red" :: [Char] -> Red :: Color Michael ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090415/f70b15d0/attachment.htm From martijn at van.steenbergen.nl Wed Apr 15 15:17:26 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed Apr 15 15:03:58 2009 Subject: [Haskell-cafe] Enum to String, and back? In-Reply-To: <35770.75113.qm@web31107.mail.mud.yahoo.com> References: <35770.75113.qm@web31107.mail.mud.yahoo.com> Message-ID: <49E632C6.1000307@van.steenbergen.nl> Hi Michael, michael rice wrote: > Can one as easily establish a reverse relationship, i.e., convert a > String type like "Red" back to its corresponding Color type? > > So that > > "Red" :: [Char] -> Red :: Color Yes, simply add Read to your list of to be derived type classes. Then you can say: > read "Red" :: Color HTH, Martijn. From rk at trie.org Wed Apr 15 15:20:18 2009 From: rk at trie.org (Rahul Kapoor) Date: Wed Apr 15 15:06:55 2009 Subject: [Haskell-cafe] Enum to String, and back? In-Reply-To: <35770.75113.qm@web31107.mail.mud.yahoo.com> References: <35770.75113.qm@web31107.mail.mud.yahoo.com> Message-ID: On Wed, Apr 15, 2009 at 3:13 PM, michael rice wrote: > Using Show it is possible to establish a relationship between an enum type > and a String type to display it. > Can one as easily establish a reverse relationship, i.e., convert a String > type like "Red" back to its corresponding Color type? > Make it an instance of the Read type class. http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t%3ARead That will allow you to write - read "Red" :: Color => Red HTH Rahul From bugfact at gmail.com Wed Apr 15 18:00:26 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Apr 15 17:46:55 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: <2B9AE96A81BB4D45B8960B2B3536DEB5@cr3lt> References: <1239381666.12202.1309941005@webmail.messagingengine.com> <1239575289.5053.1310168171@webmail.messagingengine.com> <1239706019.6858.1310393875@webmail.messagingengine.com> <1239781327.2103.1310566707@webmail.messagingengine.com> <2B9AE96A81BB4D45B8960B2B3536DEB5@cr3lt> Message-ID: I think it would be nice if we could make a "reactive benchmark" or something: some tiny examples that capture the essence of reactive systems, and a way to compare each solution's pros and cons. For example the "plugging a space leak with an arrow" papers reduces the recursive signal problem to e = integral 1 e Maybe the Nlift problem is a good example for dynamic collections, but I guess we'll need more examples. The reason why I'm talking about examples and not semantics is because the latter seems to be pretty hard to get right for FRP? On Wed, Apr 15, 2009 at 6:39 PM, Claus Reinke wrote: > but the fact that the breakout example works is an indication that at >>> least it's not hopelessly broken. >>> >> Well, a breakout game does *not* work (yet) in most other FRP >> implementations except Yampa, which do have firm theoretical foundations >> :-) >> > > While certainly more entertaining, the problem looks similar enough > to the NLift example (a lift serving requests on n floors[0]) in FunWorlds > (the 2002 OpenGL version[1], not the 2001 VRML version[2]), chosen > to test some expressiveness aspects of the language: > > - a dynamically updated collection (requests in NLift, bricks in breakout) > - an object moving in response to user input (lift/paddle+ball) > - collection and object reacting to each other's relative positions (lift > at floor levels/paddle ball brick collisions) > > In NLift, user input (keyboard) adds to the requests collection, and the > lift reacts to the request collection and its own status, while in > breakout, user input (mouse) directly controls the paddle, to which the ball > reacts. The lift stopping at a floor directly removes a request there, while > breakout bricks disappear when hit by the additional ball. In NLift, > collisions and movement are one-dimensional, while breakout is > two-dimensional. > > On the other hand, I hadn't got round to cleaning up the interface, let > alone firming the theoretical foundations, so perhaps this isn't an > exception to your rule?-) But I thought I'd mention it on the topic of > "other FRP libraries", with variations of approach/concepts. > > Claus > > [0] http://community.haskell.org/~claus/FunWorlds/NLift.hs > [1] http://community.haskell.org/~claus/FunWorlds/ > [2] http://community.haskell.org/~claus/FunWorlds/VRML/ > > FunWorlds/OpenGL in brief: > > - a behaviour is a description of an experiment > > - a behaviour can be sampled (performing the experiment), yielding a > current > value and a residual behaviour (the latter replaces the original behaviour) > > - the results of measurements can be broadcast and observed via behavioural > channels (a channel observer simply behaves as the channel source > behaviour, > with a slight delay) > > That's it! The is no special role for time at all. One can establish local > clocks, one can even broadcast their ticking behaviours. But one cannot > take an > arbitrary absolute time and ask for the value of a behaviour at that time > (other than actually running that behaviour forward or backward from > "now"). > > Also, there is a natural distinction between describing and running a > behaviour, with the ability to refer to either the description or to sample > outcomes. And having the same behaviour description on both sides of an > event > in a stepper/until does not mean that nothing changes at the step: the > second > copy doesn't continue where the first left off, but starts from its own > beginning (with no special tricks to achieve this). There are no separate > events, and delays enter via behavioural channels. > > Well, there were lots of negatives as well (eg FunWorlds was an > "engine-exposed" workbench rather than a user-directed library), but I > thought I'd try to get you interested first!-) I'd love to have funding to > work out the details and clean up/modernize the interface, but without > funding, it'll just have to wait until I get round to it (or one of the > newer > FRP libraries renders it superfluous..). > > If you try the examples, you'll notice that some of them run too fast on > modern machines (because they weren't tied to an external clock), so > you'd have to slow them down (eg, Surface and Torus, in addition to the > standard rotate/scale controls, also react to 't'/'T' for scaling time) but > they are are still fun to watch in their naivete (try Boids for simplicity, > Flock2 for chaos - you'll need to scale it 's'/'S'). > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090416/9d7bbc47/attachment.htm From vigalchin at gmail.com Wed Apr 15 18:17:49 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Wed Apr 15 18:04:19 2009 Subject: [Haskell-cafe] Mondrian and Haskell Message-ID: <5ae4f2ba0904151517h76553fe8m723630606589fd4e@mail.gmail.com> Hello, Several days ago I posted a question about retargeting GHC to generate CIL so that Haskell could be a .NET language. One objection was Haskell "lazy" nature didn't fit well with .NET's CLR. I found a couple publications .... http://www.ddj.com/windows/184404967;jsessionid=0AVCEATVAEGKMQSNDLOSKH0CJUNN2JVN?_requestid=33708 ... more popular presentation http://docs.msdnaa.net/ark_new/Webfiles/WhitePapers/ECOOP.pdf ... this paper seems to be saying that Mondrian's "lazy" nature fits in quite well Any opinions from Mondrian people "listening" in? What lessons were learned from the Mondrian experience that could speak to Haskell in particular GHC? Regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090415/333f196d/attachment-0001.htm From ajcg at CS.UCLA.EDU Wed Apr 15 19:06:45 2009 From: ajcg at CS.UCLA.EDU (Andrew Gallagher) Date: Wed Apr 15 18:53:11 2009 Subject: [Haskell-cafe] Brackets and Asynchronous Exceptions Message-ID: Hi, In a program I am writing, I have many locations where I acquire a resource, perform an operation with it, then release it. I have been using the 'bracket' function so that the "release" operation would be performed even if the operation threw an exception. This seems to work nicely. In the event of an asynchronous exception, however, is there a possible scenario where a release is not performed after an acquire? Looking at the example given in bracket documentation: bracket (openFile "filename" ReadMode) (hClose) (\fileHandle -> do { ... }) Is it possbile that an asynchronous exception could be raised in this thread after openFile executes but *before* the appropriate handlers are installed and the operation is run, preventing hClose from executing? If 'bracket' does not handle this case, should I be using the block/unblock functions to disable asynchronous exceptions: block (bracket (openFile "filename" ReadMode) (hClose) (\fileHandle -> do unblock ({ ... }))) Thanks, Andrew From dagit at codersbase.com Wed Apr 15 19:13:55 2009 From: dagit at codersbase.com (Jason Dagit) Date: Wed Apr 15 19:00:22 2009 Subject: [Haskell-cafe] Brackets and Asynchronous Exceptions In-Reply-To: References: Message-ID: On Wed, Apr 15, 2009 at 4:06 PM, Andrew Gallagher wrote: > Hi, > > In a program I am writing, I have many locations where I acquire a resource, > perform an operation with it, then release it. ?I have been using the > 'bracket' function so that the "release" operation would be performed even > if the operation threw an exception. ?This seems to work nicely. > > In the event of an asynchronous exception, however, is there a possible > scenario where a release is not performed after an acquire? > > Looking at the example given in bracket documentation: > > bracket > ? (openFile "filename" ReadMode) > ? (hClose) > ? (\fileHandle -> do { ... }) > > Is it possbile that an asynchronous exception could be raised in this thread > after openFile executes but *before* the appropriate handlers are installed > and the operation is run, preventing hClose from executing? > > If 'bracket' does not handle this case, should I be using the block/unblock > functions to disable asynchronous exceptions: > > block > ? (bracket > ? ? ?(openFile "filename" ReadMode) > ? ? ?(hClose) > ? ? ?(\fileHandle -> do > ? ? ? ? unblock > ? ? ? ? ({ ... }))) Does this answer your question? http://haskell.org/ghc/docs/latest/html/libraries/base/src/Control-Exception-Base.html#bracket If so, I found it by going to haskell.org/hoogle searching for bracket and then following the haddock "Source" to the definition. I hope that helps! Jason From barsoap at web.de Wed Apr 15 19:14:15 2009 From: barsoap at web.de (Achim Schneider) Date: Wed Apr 15 19:00:57 2009 Subject: [Haskell-cafe] Re: ANN: Elerea, another FRP library References: <1239381666.12202.1309941005@webmail.messagingengine.com> <1239575289.5053.1310168171@webmail.messagingengine.com> <1239706019.6858.1310393875@webmail.messagingengine.com> <1239781327.2103.1310566707@webmail.messagingengine.com> <2B9AE96A81BB4D45B8960B2B3536DEB5@cr3lt> Message-ID: <20090416011415.1fb6ea0d@solaris> Peter Verswyvelen wrote: > The reason why I'm talking about examples and not semantics is > because the latter seems to be pretty hard to get right for FRP? > There's a difference between those two? I've heard much, but never anyone complaining about specifications overlapping in a compatible way. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From ajcg at CS.UCLA.EDU Wed Apr 15 19:30:53 2009 From: ajcg at CS.UCLA.EDU (Andrew Gallagher) Date: Wed Apr 15 19:17:21 2009 Subject: [Haskell-cafe] Brackets and Asynchronous Exceptions In-Reply-To: References: Message-ID: Great. Thanks! This is exactly what I was looking for. Apparently this issue is also described in the paper Asynchronous Exception in Haskell. Thanks, Andrew On Wed, 15 Apr 2009, Jason Dagit wrote: > On Wed, Apr 15, 2009 at 4:06 PM, Andrew Gallagher wrote: >> Hi, >> >> In a program I am writing, I have many locations where I acquire a resource, >> perform an operation with it, then release it. ?I have been using the >> 'bracket' function so that the "release" operation would be performed even >> if the operation threw an exception. ?This seems to work nicely. >> >> In the event of an asynchronous exception, however, is there a possible >> scenario where a release is not performed after an acquire? >> >> Looking at the example given in bracket documentation: >> >> bracket >> ? (openFile "filename" ReadMode) >> ? (hClose) >> ? (\fileHandle -> do { ... }) >> >> Is it possbile that an asynchronous exception could be raised in this thread >> after openFile executes but *before* the appropriate handlers are installed >> and the operation is run, preventing hClose from executing? >> >> If 'bracket' does not handle this case, should I be using the block/unblock >> functions to disable asynchronous exceptions: >> >> block >> ? (bracket >> ? ? ?(openFile "filename" ReadMode) >> ? ? ?(hClose) >> ? ? ?(\fileHandle -> do >> ? ? ? ? unblock >> ? ? ? ? ({ ... }))) > > Does this answer your question? > http://haskell.org/ghc/docs/latest/html/libraries/base/src/Control-Exception-Base.html#bracket > > If so, I found it by going to haskell.org/hoogle searching for bracket > and then following the haddock "Source" to the definition. > > I hope that helps! > Jason > From jason.dusek at gmail.com Wed Apr 15 19:35:10 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Apr 15 19:21:36 2009 Subject: [Haskell-cafe] Data.ByteString woes In-Reply-To: <5a1362990904150416i258d3de5x76d8b8d9c231aa1b@mail.gmail.com> References: <5a1362990904150416i258d3de5x76d8b8d9c231aa1b@mail.gmail.com> Message-ID: <42784f260904151635x3ba2c18ar738823b48a477fd3@mail.gmail.com> Could you pastebin something that demoes the error? -- Jason Dusek From nowgate at yahoo.com Wed Apr 15 21:48:55 2009 From: nowgate at yahoo.com (michael rice) Date: Wed Apr 15 21:35:22 2009 Subject: [Haskell-cafe] Enum to String, and back? Message-ID: <811866.45096.qm@web31104.mail.mud.yahoo.com> Thanks guys. It works like a charm. Michael --- On Wed, 4/15/09, Rahul Kapoor wrote: From: Rahul Kapoor Subject: Re: [Haskell-cafe] Enum to String, and back? To: Cc: haskell-cafe@haskell.org Date: Wednesday, April 15, 2009, 3:20 PM On Wed, Apr 15, 2009 at 3:13 PM, michael rice wrote: > Using Show it is possible to establish a relationship between an enum type > and a String type to display it. > Can one as easily establish a reverse relationship, i.e., convert a String > type like "Red" back to its corresponding Color type? > Make it an instance of the Read type class. http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t%3ARead That will allow you to write - read "Red" :: Color => Red HTH Rahul _______________________________________________ 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/20090415/7febb915/attachment.htm From moonpatio at gmail.com Wed Apr 15 22:59:29 2009 From: moonpatio at gmail.com (Matt Morrow) Date: Wed Apr 15 22:45:56 2009 Subject: [Haskell-cafe] Code Golf In-Reply-To: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> References: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> Message-ID: <1bc51a990904151959k4cfc156fx682f4242ea78f56e@mail.gmail.com> I think this has the semantics you're looking for. (it would probably be somewhat prettier if "mappend" wasn't such an ugly identifier (compared to, say, (++)), but this is just me trying to sneak a shot in against the Monoid method's names ;) ghci> let diag = foldr (curry (prod mappend fst snd . uncurry (coprod mappend (splitAt 2) (splitAt 1)))) [] ghci> diag [[1,2,3],[4,5,6],[7,8,9]] [1,2,4,3,5,7,6,8,9] ghci> diag [[1,2,3],[4],[5,6,7]] [1,2,4,3,5,6,7] On Wed, Apr 15, 2009 at 5:32 AM, Sebastian Fischer < sebf@informatik.uni-kiel.de> wrote: > Fancy some Codegolf? > > I wrote the following function for list diagonalization: > > > diag l = foldr (.) id ((sel l . flip sel) ((:[]).(:))) [] > > where > > sel = foldr (\a b c -> id : mrg (a c) (b c)) (const []) . map (flip id) > > > > mrg [] ys = ys > > mrg xs [] = xs > > mrg (x:xs) (y:ys) = (x.y) : mrg xs ys > > Self explanatory, isn't it? Here is a test case: > > *Main> take 10 $ diag [[ (m,n) | n <- [1..]] | m <- [1..]] > [(1,1),(1,2),(2,1),(1,3),(2,2),(3,1),(1,4),(2,3),(3,2),(4,1)] > > I was trying to golf it down [^1] but my brain explodes. If you succeed in > reducing keystrokes, I'd be happy to know! > > Cheers, > Sebastian > > [^1]: http://codegolf.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/20090415/f6935c28/attachment.htm From moonpatio at gmail.com Wed Apr 15 23:02:15 2009 From: moonpatio at gmail.com (Matt Morrow) Date: Wed Apr 15 22:48:41 2009 Subject: [Haskell-cafe] Code Golf In-Reply-To: <1bc51a990904151959k4cfc156fx682f4242ea78f56e@mail.gmail.com> References: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> <1bc51a990904151959k4cfc156fx682f4242ea78f56e@mail.gmail.com> Message-ID: <1bc51a990904152002p168f5b96idb9b6e38bb44480b@mail.gmail.com> *..against Monoid's method names. On Wed, Apr 15, 2009 at 9:59 PM, Matt Morrow wrote: > ... against the Monoid method's names. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090415/ef954190/attachment.htm From moonpatio at gmail.com Wed Apr 15 23:08:07 2009 From: moonpatio at gmail.com (Matt Morrow) Date: Wed Apr 15 22:54:33 2009 Subject: [Haskell-cafe] Code Golf In-Reply-To: <1bc51a990904151959k4cfc156fx682f4242ea78f56e@mail.gmail.com> References: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> <1bc51a990904151959k4cfc156fx682f4242ea78f56e@mail.gmail.com> Message-ID: <1bc51a990904152008v2cfcb3f8oa20b92ff19d81381@mail.gmail.com> And i forgot to include the defs of (co)prod: coprod (<>) i1 i2 = (\a b -> i1 a <> i2 b) prod (><) p1 p2 = (\a -> p1 a >< p2 a) diag = foldr (curry (prod mappend fst snd . uncurry (coprod mappend (splitAt 2) (splitAt 1)))) [] Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090415/d03743a9/attachment.htm From dmehrtash at gmail.com Wed Apr 15 23:12:46 2009 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Wed Apr 15 22:59:11 2009 Subject: [Haskell-cafe] Issues with running Ghci from emacs Message-ID: I am having problem running GHCI with Haskell files that include imports. I am running emacs22 on Ubuntu, with haskell-mode-2.4 extensions. I load my file (Fal.lhs in this case) in emacs. Then try to run the Ghci by doing C-c C-l. The result is shown below. Ghci fails to find the Draw.lhs which is also on the same directory as the Fal.lhs. Note: If I go to the directory where Fal.lhs is and run Ghci directly it all works fine. Any idea how I can get the interepreter to work form emacs? GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. *Prelude> :cd ~/.cabal/ Prelude> :load "../Documents/haskell/SOE/src/Fal.lhs" * ../Documents/haskell/SOE/src/Fal.lhs:76:9: Could not find module `Draw': Use -v to see a list of the files searched for. Failed, modules loaded: none. Prelude> Thanks, Daryoush -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090415/eb96c012/attachment.htm From mpm at alumni.caltech.edu Thu Apr 16 02:31:50 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Thu Apr 16 02:18:21 2009 Subject: [Haskell-cafe] google-like "do you mean?" feature Message-ID: <49E6D0D6.5010702@alumni.caltech.edu> I'm thinking of writing a parser to load files that my customers have created. I'm a software requirements engineer; the data consists of the customers' thoughts in response to the latest release of the requirements doc. In fact, the files will probably be copies of the requirements doc itself, into which customers have entered their notes and made changes. The original requirements doc will have a format that can be parsed; probably something simple like lines marked with codes like //customer={customer name goes here} //requirement= {requirement text goes here} When I parse the documents that come back from the customers, they are likely to contain some errors. Field names may be mangled or misspelled. Customer names may be entered in unrecognizable variants (e.g. someone named "Michael" is indicated as "Mike") and so forth. I was thinking that it might be useful to have a Google-like "do you mean this?" feature. If the field name is //customer=, then the parser might recognize a huge list of variants like //ustomer=, //customor=, etc... that is, recognize them well enough to continue parsing and give a decent error message in context. Any ideas how to go about this? I don't think I would create a parser language that includes every variant, but instead the field names would be tokens that could be passed to another routine. The variants could be generated ahead of time. I would limit the number of variants to something manageable, like 10,000 for each field name. Thanks, Mike From andy.haskell at zambezi.org.uk Thu Apr 16 02:55:44 2009 From: andy.haskell at zambezi.org.uk (Andy Smith) Date: Thu Apr 16 02:42:10 2009 Subject: [Haskell-cafe] google-like "do you mean?" feature In-Reply-To: <49E6D0D6.5010702@alumni.caltech.edu> References: <49E6D0D6.5010702@alumni.caltech.edu> Message-ID: <5540a5470904152355y3edc8044p7846f56019f10d0@mail.gmail.com> 2009/4/16 Michael Mossey : > I was thinking that it might be useful to have a Google-like "do you mean > this?" feature. If the field name is //customer=, then the parser might > recognize a huge list of variants like //ustomer=, //customor=, etc... that > is, recognize them well enough to continue parsing and give a decent error > message in context. > > Any ideas how to go about this? To measure how similar two strings are, you can use a metric like Levenshtein distance, Damerau-Levenshtein distance, or Jaro-Winkler distance: http://en.wikipedia.org/wiki/Levenshtein_distance http://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance http://en.wikipedia.org/wiki/Jaro-Winkler_distance The first two basically count the number of mistakes that a user would have to make to get from the correct string to the one you read from the file. There's an 'edit-distance' package in Hackage that implements the first two: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/edit-distance When you find an unrecognised field name in the file, you could calculate the edit distance to each correct field name, and if there's one within a certain threshold, assume that's what the user meant (if there's more than one close match, maybe it's better to report an error than risk choosing the wrong one). I imagine this brute-force approach would be fast enough, but if not you could look at the techniques used by spell checkers to suggest corrections. Maybe even use a spell checking library, if such a thing exists (either pure Haskell or a binding to a library like aspell, although I couldn't see either from a quick search in Hackage). Andy From greenrd at greenrd.org Thu Apr 16 02:57:36 2009 From: greenrd at greenrd.org (Robin Green) Date: Thu Apr 16 02:44:04 2009 Subject: [Haskell-cafe] google-like "do you mean?" feature In-Reply-To: <49E6D0D6.5010702@alumni.caltech.edu> References: <49E6D0D6.5010702@alumni.caltech.edu> Message-ID: <20090416075736.33999dae@greenrd.org> On Wed, 15 Apr 2009 23:31:50 -0700 Michael Mossey wrote: > I was thinking that it might be useful to have a Google-like "do you > mean this?" feature. If the field name is //customer=, then the > parser might recognize a huge list of variants > like //ustomer=, //customor=, etc... You could reduce the probability of such errors by providing a standard template that could be copy-pasted in wherever necessary. -- Robin From patai_gergely at fastmail.fm Thu Apr 16 03:01:18 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Thu Apr 16 02:47:43 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: <2B9AE96A81BB4D45B8960B2B3536DEB5@cr3lt> References: <1239381666.12202.1309941005@webmail.messagingengine.com><1239541485.27252.1310127905@webmail.messagingengine.com><1239575289.5053.1310168171@webmail.messagingengine.com><1239706019.6858.1310393875@webmail.messagingengine.com><1239781327.2103.1310566707@webmail.messagingengine.com> <2B9AE96A81BB4D45B8960B2B3536DEB5@cr3lt> Message-ID: <1239865278.26932.1310756721@webmail.messagingengine.com> > On the other hand, I hadn't got round to cleaning up the interface, > let alone firming the theoretical foundations, so perhaps this isn't an > exception to your rule?-) But I thought I'd mention it on the topic of > "other FRP libraries", with variations of approach/concepts. Thanks for the pointers. I remember coming across this one earlier, but I forgot about it. Your description suggests that FunWorlds has a lot in common with Elerea. It's mostly the interface that looks different. Apparently I'll have to play with this one too. :) Gergely -- http://www.fastmail.fm - The professional email service From mpm at alumni.caltech.edu Thu Apr 16 03:04:43 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Thu Apr 16 02:51:29 2009 Subject: [Haskell-cafe] google-like "do you mean?" feature In-Reply-To: <20090416075736.33999dae@greenrd.org> References: <49E6D0D6.5010702@alumni.caltech.edu> <20090416075736.33999dae@greenrd.org> Message-ID: <49E6D88B.4070305@alumni.caltech.edu> Robin Green wrote: > On Wed, 15 Apr 2009 23:31:50 -0700 > Michael Mossey wrote: > >> I was thinking that it might be useful to have a Google-like "do you >> mean this?" feature. If the field name is //customer=, then the >> parser might recognize a huge list of variants >> like //ustomer=, //customor=, etc... > > You could reduce the probability of such errors by providing a standard > template that could be copy-pasted in wherever necessary. Yes, that will be there. My example is not so good because it seems concerned with the keywords only. I'm more concerned about errors in the data they enter... for example, names of people and references to document names. Thanks, Mike From batterseapower at hotmail.com Thu Apr 16 03:08:11 2009 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Thu Apr 16 02:54:37 2009 Subject: [Haskell-cafe] google-like "do you mean?" feature In-Reply-To: <49E6D0D6.5010702@alumni.caltech.edu> References: <49E6D0D6.5010702@alumni.caltech.edu> Message-ID: <9d4d38820904160008t1136826sb76c4c7646b955ad@mail.gmail.com> 2009/4/16 Michael Mossey : > I don't think I would create a parser language that includes every variant, > but instead the field names would be tokens that could be passed to another > routine. Right. > The variants could be generated ahead of time. I would limit the > number of variants to something manageable, like 10,000 for each field name. Generating variants ahead of time isn't necessary. Instead, you could just look at the edit distance between the token you get and each possible valid field name using something like http://hackage.haskell.org/cgi-bin/hackage-scripts/package/edit-distance. The token with the least edit distance is the one you should suggest. Cheers, Max From martijn at van.steenbergen.nl Thu Apr 16 03:20:41 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Apr 16 03:07:06 2009 Subject: [Haskell-cafe] Code Golf In-Reply-To: <1bc51a990904152008v2cfcb3f8oa20b92ff19d81381@mail.gmail.com> References: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> <1bc51a990904151959k4cfc156fx682f4242ea78f56e@mail.gmail.com> <1bc51a990904152008v2cfcb3f8oa20b92ff19d81381@mail.gmail.com> Message-ID: <49E6DC49.8020302@van.steenbergen.nl> Matt Morrow wrote: > And i forgot to include the defs of (co)prod: > > coprod (<>) i1 i2 = (\a b -> i1 a <> i2 b) lambdabot> pl \f i1 i2 -> (\a b -> i1 a `f` i2 b) (flip .) . (((.) .) .) . (.) Muhahaha. :-D Too bad the flip is still in there. :-) Martijn. From jac at informatik.uni-kiel.de Thu Apr 16 03:22:05 2009 From: jac at informatik.uni-kiel.de (Jan Christiansen) Date: Thu Apr 16 03:08:43 2009 Subject: [Haskell-cafe] Code Golf In-Reply-To: <1bc51a990904152008v2cfcb3f8oa20b92ff19d81381@mail.gmail.com> References: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> <1bc51a990904151959k4cfc156fx682f4242ea78f56e@mail.gmail.com> <1bc51a990904152008v2cfcb3f8oa20b92ff19d81381@mail.gmail.com> Message-ID: Hi, On 16.04.2009, at 05:08, Matt Morrow wrote: > And i forgot to include the defs of (co)prod: > > prod (><) p1 p2 = (\a -> p1 a >< p2 a) I think this one is liftM2 of the ((->) a) Monad instance. Cheers, Jan From duncan.coutts at worc.ox.ac.uk Thu Apr 16 03:23:32 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Apr 16 03:10:00 2009 Subject: [Haskell-cafe] Cabal and WinHugs In-Reply-To: <5ab17e790904122002q1a0e141dw361cf795e903e08@mail.gmail.com> References: <5ab17e790904122002q1a0e141dw361cf795e903e08@mail.gmail.com> Message-ID: <1239866612.6315.5.camel@lantern> On Sun, 2009-04-12 at 20:02 -0700, Iavor Diatchki wrote: > Hello, > What is the preferred way to install a cabal package so that it works > with winhugs? When I tried "cabal install --user --hugs" I got an > error that it could not find "hugsffi". I managed to get things > working by manually downloading the package, and extracting the > appropriate source directories to the "packages" folder of winhugs > (i.e., basically skipping cabal) but this is kind of clunky. So to > summarize, here are my two questions: > 1. Am I doing something wrong, or does "cabal" not support WinHugs?, and > 2. Does WinHugs have a user specific "packages" folder (so that each > user can have their own set of packages)? I've never tried with winhugs and to be honest we don't test much with hugs either. Don't take that as a discouragement though, it'd be great to have better support for hugs and winhugs in the cabal tool. All it needs is someone to pay it a little attention. For the specific issue, does winhugs come with the hugsffi tool? I expect that it should do though perhaps it's hidden away in some directory. I believe that by default hugs uses $HOME/lib/packages/* for per-user packages. I'm not quite sure what winhugs does. It'd be good to adjust the defaults to make this "just work". Duncan From sebf at informatik.uni-kiel.de Thu Apr 16 03:42:31 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Thu Apr 16 03:29:01 2009 Subject: [Haskell-cafe] Code Golf In-Reply-To: <1bc51a990904151959k4cfc156fx682f4242ea78f56e@mail.gmail.com> References: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> <1bc51a990904151959k4cfc156fx682f4242ea78f56e@mail.gmail.com> Message-ID: <34485EA1-D608-4174-8364-48BC185F4DDE@informatik.uni-kiel.de> > ghci> let diag = foldr (curry (prod mappend fst snd . uncurry > (coprod mappend (splitAt 2) (splitAt 1)))) [] nice :) thanks to the comments of Martijn and Jan we can replace prod and coprod by liftA2 and : > let diag = foldr (curry (liftA2 mappend fst snd.uncurry (((flip.). (((.).).).(.)) mappend (splitAt 2) (splitAt 1)))) [] It works for the finite tests but, unfortunately, not for the infinite one :( > take 10 $ diag [[ (m,n) | n <- [1..]] | m <- [1..]] *** Exception: stack overflow From duncan.coutts at worc.ox.ac.uk Thu Apr 16 03:44:44 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Apr 16 03:31:11 2009 Subject: [Haskell-cafe] glut installation using cabal failed In-Reply-To: References: <1336aed20904132325i6b765025oc20e99593dba3fbd@mail.gmail.com> Message-ID: <1239867884.6315.8.camel@lantern> On Wed, 2009-04-15 at 01:53 +0200, Henk-Jan van Tuyl wrote: > On Tue, 14 Apr 2009 08:25:52 +0200, Raja Koduru wrote: > > > hi, > > > > I am a beginner to haskell. > > > > I am trying to install glut using "cabal install glut" > > Pasting here a tail of the output > > checking for GLUT/glut.h... no > > configure: error: no GLUT header found, so this package cannot be built > > See `config.log' for more details. > > > > But I do have "glut.h" in my "D:\ghc\ghc-6.10.2\include\mingw\GL". > > > > Define the environment variable: > C_INCLUDE_PATH=D:\ghc\ghc-6.10.2\include\mingw > (you can add more directories, separate them by ';') > To let the linker find the libraries, define LIBRARY_PATH. Hmm, that is annoying. I've filed a tracker bug here: http://trac.haskell.org/haskell-platform/ticket/11 and also noted the issue here: http://hackage.haskell.org/trac/hackage/ticket/458#comment:2 Duncan From apfelmus at quantentunnel.de Thu Apr 16 03:58:43 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Thu Apr 16 03:45:22 2009 Subject: [Haskell-cafe] Re: Looking for the fastest Haskell primes algorithm In-Reply-To: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> References: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> Message-ID: Niemeijer, R.A. wrote: > Today I happened to need a large list of prime numbers. > Obviously this is a well-known problem, so I figured there would > be something on Hackage that I could use. Surprisingly, there isn't, > or if there is it's not easy to find. > > Since it's such a common problem I'd say it would be a good idea to > add a package to Hackage that exports > > primes :: [Integer] > > and hides the ugly implementation details. +1 except that exporting the potentially infinite list of primes is problematic in that it may become a memory leak. I'd suggest to export two versions primes :: [Integer] primes' :: () -> [Integer] for casual (i.e. throwaway program to solve a Project Euler problem) and for memory aware use respectively. Regards, apfelmus -- http://apfelmus.nfshost.com From patai_gergely at fastmail.fm Thu Apr 16 04:06:49 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Thu Apr 16 03:53:14 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <1239575289.5053.1310168171@webmail.messagingengine.com> <1239706019.6858.1310393875@webmail.messagingengine.com> <1239781327.2103.1310566707@webmail.messagingengine.com> <2B9AE96A81BB4D45B8960B2B3536DEB5@cr3lt> Message-ID: <1239869209.7657.1310757441@webmail.messagingengine.com> > On the other hand, breaking referential transparency in the > external interface is a very bad idea, in my opinion. Actually, > this means that the library user would have to turn certain > compiler optimizations off to get the intended behavior. However, in practice you can compile Elerea with -O2 without ill effects. In fact, that's what happens if you install it with cabal. > Just have a look at the Haddock docs of unsafePerformIO. Yes, I did that too, and came up with the following checklist: - the order of side effects doesn't matter much, since the resulting networks are equivalent if we don't rely on the automatic delay feature (applicative optimisations can be different, but still with the same net effect) - unsafePerformIO is apparently never inlined, i.e. each instance is executed once, so sharing works as desired - let-floating is no problem, because all instances of unsafePerformIO rely on surrounding function arguments - CSE is no problem either, it even helps if it's performed (and it is with optimisations turned on), since it results in smaller equivalent networks I think we can expect it to be fairly well-behaving, because the 'side effect' of Elerea primitives is basically the same as that of pure values in general: upon evaluation a value is created in the memory and we get a reference to it. We only have an extra constraint for the compiler: never duplicate these values. Merging identical ones is okay, and in fact desirable. The following code demonstrates this if you compile it with and without optimisations: import Control.Applicative import Control.Monad import FRP.Elerea import System.IO.Unsafe cint a b = unsafePerformIO (putStrLn "!") `seq` transfer 0 (\dt x x0 -> x0+x*dt) b mysig = (latcher 0 (b >@ 0.3) (const (cint a b) <$> cint a b)) + (cint a b) + (cint a b) + a where a = pure 4 b = stateful 0 (+) main = replicateM 10 (superstep mysig 0.1) >>= print I'd like to see an example where optimisation does make a difference, because I'm still unsure about the consequences of 'unsafeness'. Gergely -- http://www.fastmail.fm - Or how I learned to stop worrying and love email again From semanticphilosopher at googlemail.com Thu Apr 16 04:08:51 2009 From: semanticphilosopher at googlemail.com (Neil Davies) Date: Thu Apr 16 03:55:21 2009 Subject: [Haskell-cafe] Issues with running Ghci from emacs In-Reply-To: References: Message-ID: <75FF60BD-966F-4ACC-945C-AAF4777664B2@gmail.com> I end up doing :set -i../Documents/haskell/SOE/src To set the search directory so that ghci can find the source. I've not been how to tailor that 'cd' which is run at start up (but I've not looked to hard) Neil On 16 Apr 2009, at 04:12, Daryoush Mehrtash wrote: > > I am having problem running GHCI with Haskell files that include > imports. I am running emacs22 on Ubuntu, with haskell-mode-2.4 > extensions. > > I load my file (Fal.lhs in this case) in emacs. Then try to run the > Ghci by doing C-c C-l. The result is shown below. Ghci fails > to find the Draw.lhs which is also on the same directory as the > Fal.lhs. Note: If I go to the directory where Fal.lhs is and run > Ghci directly it all works fine. Any idea how I can get the > interepreter to work form emacs? > > GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > Prelude> :cd ~/.cabal/ > Prelude> :load "../Documents/haskell/SOE/src/Fal.lhs" > > ../Documents/haskell/SOE/src/Fal.lhs:76:9: > Could not find module `Draw': > Use -v to see a list of the files searched for. > Failed, modules loaded: none. > Prelude> > > Thanks, > > Daryoush > > _______________________________________________ > 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/20090416/6a5a7508/attachment.htm From lennart at augustsson.net Thu Apr 16 04:18:47 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Thu Apr 16 04:05:17 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: <1239869209.7657.1310757441@webmail.messagingengine.com> References: <1239381666.12202.1309941005@webmail.messagingengine.com> <1239706019.6858.1310393875@webmail.messagingengine.com> <1239781327.2103.1310566707@webmail.messagingengine.com> <2B9AE96A81BB4D45B8960B2B3536DEB5@cr3lt> <1239869209.7657.1310757441@webmail.messagingengine.com> Message-ID: There's no guarantee about unsafePerformIO not being inlined, that's just how ghc treats it. 2009/4/16 Patai Gergely : >> On the other hand, breaking referential transparency in the >> external interface is a very bad idea, in my opinion. Actually, >> this means that the library user would have to turn certain >> compiler optimizations off to get the intended behavior. > However, in practice you can compile Elerea with -O2 without ill > effects. In fact, that's what happens if you install it with cabal. > >> Just have a look at the Haddock docs of unsafePerformIO. > Yes, I did that too, and came up with the following checklist: > > - the order of side effects doesn't matter much, since the resulting > networks are equivalent if we don't rely on the automatic delay feature > (applicative optimisations can be different, but still with the same net > effect) > - unsafePerformIO is apparently never inlined, i.e. each instance is > executed once, so sharing works as desired > - let-floating is no problem, because all instances of unsafePerformIO > rely on surrounding function arguments > - CSE is no problem either, it even helps if it's performed (and it is > with optimisations turned on), since it results in smaller equivalent > networks > > I think we can expect it to be fairly well-behaving, because the 'side > effect' of Elerea primitives is basically the same as that of pure > values in general: upon evaluation a value is created in the memory and > we get a reference to it. We only have an extra constraint for the > compiler: never duplicate these values. Merging identical ones is okay, > and in fact desirable. The following code demonstrates this if you > compile it with and without optimisations: > > import Control.Applicative > import Control.Monad > import FRP.Elerea > import System.IO.Unsafe > > cint a b = unsafePerformIO (putStrLn "!") `seq` > ? ? ? ? ? transfer 0 (\dt x x0 -> x0+x*dt) b > > mysig = (latcher 0 (b >@ 0.3) (const (cint a b) <$> cint a b)) + > ? ? ? ?(cint a b) + (cint a b) + a > ? ?where a = pure 4 > ? ? ? ? ?b = stateful 0 (+) > > main = replicateM 10 (superstep mysig 0.1) >>= print > > I'd like to see an example where optimisation does make a difference, > because I'm still unsure about the consequences of 'unsafeness'. > > Gergely > > -- > http://www.fastmail.fm - Or how I learned to stop worrying and > ? ? ? ? ? ? ? ? ? ? ? ? ?love email again > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From patai_gergely at fastmail.fm Thu Apr 16 04:20:50 2009 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Thu Apr 16 04:07:18 2009 Subject: [Haskell-cafe] Issues with running Ghci from emacs Message-ID: <1239870050.9584.1310764949@webmail.messagingengine.com> > I end up doing > > :set -i../Documents/haskell/SOE/src > > To set the search directory so that ghci can find the source. > > I've not been how to tailor that 'cd' which is run at start > up (but I've not looked to hard) It is looking for the closest ancestor directory with a file ending in .cabal, and that's where cd goes. Probably the simplest way to trick it without chaniging any setting is to create an empty dummy.cabal in the directory of your program. Gergely -- http://www.fastmail.fm - Send your email first class From bugfact at gmail.com Thu Apr 16 04:29:41 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Apr 16 04:16:13 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <1239706019.6858.1310393875@webmail.messagingengine.com> <1239781327.2103.1310566707@webmail.messagingengine.com> <2B9AE96A81BB4D45B8960B2B3536DEB5@cr3lt> <1239869209.7657.1310757441@webmail.messagingengine.com> Message-ID: Well, the documentation says: Use {-# NOINLINE foo #-} as a pragma on any function foo that calls unsafePerformIO. If the call is inlined, the I/O may be performed more than once. So you claim this does not prevent GHC to inline it anyway? That feels like a bug then, both in the documentation and NOINLINE On Thu, Apr 16, 2009 at 10:18 AM, Lennart Augustsson wrote: > There's no guarantee about unsafePerformIO not being inlined, that's > just how ghc treats it. > > 2009/4/16 Patai Gergely : > >> On the other hand, breaking referential transparency in the > >> external interface is a very bad idea, in my opinion. Actually, > >> this means that the library user would have to turn certain > >> compiler optimizations off to get the intended behavior. > > However, in practice you can compile Elerea with -O2 without ill > > effects. In fact, that's what happens if you install it with cabal. > > > >> Just have a look at the Haddock docs of unsafePerformIO. > > Yes, I did that too, and came up with the following checklist: > > > > - the order of side effects doesn't matter much, since the resulting > > networks are equivalent if we don't rely on the automatic delay feature > > (applicative optimisations can be different, but still with the same net > > effect) > > - unsafePerformIO is apparently never inlined, i.e. each instance is > > executed once, so sharing works as desired > > - let-floating is no problem, because all instances of unsafePerformIO > > rely on surrounding function arguments > > - CSE is no problem either, it even helps if it's performed (and it is > > with optimisations turned on), since it results in smaller equivalent > > networks > > > > I think we can expect it to be fairly well-behaving, because the 'side > > effect' of Elerea primitives is basically the same as that of pure > > values in general: upon evaluation a value is created in the memory and > > we get a reference to it. We only have an extra constraint for the > > compiler: never duplicate these values. Merging identical ones is okay, > > and in fact desirable. The following code demonstrates this if you > > compile it with and without optimisations: > > > > import Control.Applicative > > import Control.Monad > > import FRP.Elerea > > import System.IO.Unsafe > > > > cint a b = unsafePerformIO (putStrLn "!") `seq` > > transfer 0 (\dt x x0 -> x0+x*dt) b > > > > mysig = (latcher 0 (b >@ 0.3) (const (cint a b) <$> cint a b)) + > > (cint a b) + (cint a b) + a > > where a = pure 4 > > b = stateful 0 (+) > > > > main = replicateM 10 (superstep mysig 0.1) >>= print > > > > I'd like to see an example where optimisation does make a difference, > > because I'm still unsure about the consequences of 'unsafeness'. > > > > Gergely > > > > -- > > http://www.fastmail.fm - Or how I learned to stop worrying and > > love email again > > > > _______________________________________________ > > 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/20090416/5cb71dda/attachment-0001.htm From dmehrtash at gmail.com Thu Apr 16 04:36:20 2009 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Thu Apr 16 04:22:45 2009 Subject: [Haskell-cafe] Issues with running Ghci from emacs In-Reply-To: <1239870050.9584.1310764949@webmail.messagingengine.com> References: <1239870050.9584.1310764949@webmail.messagingengine.com> Message-ID: Thanks, that does the trick. Daryoush 2009/4/16 Patai Gergely > > I end up doing > > > > :set -i../Documents/haskell/SOE/src > > > > To set the search directory so that ghci can find the source. > > > > I've not been how to tailor that 'cd' which is run at start > > up (but I've not looked to hard) > > It is looking for the closest ancestor directory with a file ending in > .cabal, and that's where cd goes. Probably the simplest way to trick it > without chaniging any setting is to create an empty dummy.cabal in the > directory of your program. > > Gergely > > -- > http://www.fastmail.fm - Send your email first class > > _______________________________________________ > 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/20090416/0ce606c0/attachment.htm From r.a.niemeijer at tue.nl Thu Apr 16 04:41:43 2009 From: r.a.niemeijer at tue.nl (Niemeijer, R.A.) Date: Thu Apr 16 04:28:16 2009 Subject: [Haskell-cafe] Re: Looking for the fastest Haskell primes In-Reply-To: <20090416081641.B900A324AC9@www.haskell.org> References: <20090416081641.B900A324AC9@www.haskell.org> Message-ID: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AECF0@EXCHANGE10.campus.tue.nl> Heinrich Apfelmus wrote: > +1 except that exporting the potentially infinite list of primes is > problematic in that it may become a memory leak. > > I'd suggest to export two versions > > primes :: [Integer] > primes' :: () -> [Integer] > > for casual (i.e. throwaway program to solve a Project Euler problem) and > for memory aware use respectively. I'm afraid I don't quite follow. Would you mind explaining what the first parameter is for and how it would solve the memory leak? From ekirpichov at gmail.com Thu Apr 16 04:57:14 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Thu Apr 16 04:43:39 2009 Subject: [Haskell-cafe] Re: Looking for the fastest Haskell primes In-Reply-To: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AECF0@EXCHANGE10.campus.tue.nl> References: <20090416081641.B900A324AC9@www.haskell.org> <9BEB5EF43B5A4042B60C0D8179782DB3D6942AECF0@EXCHANGE10.campus.tue.nl> Message-ID: <5e0214850904160157g202464fcm166f8980e4bbb965@mail.gmail.com> The parameterless version is a top-level definition and won't get garbage-collected, IIRC. So, if you evaluate primes!!10000000, you'll end up with a 10000000-element list hanging in memory forever. If you evaluate (primes' ()) !! 10000000, you won't. 2009/4/16 Niemeijer, R.A. : > Heinrich Apfelmus wrote: >> +1 except that exporting the potentially infinite list of primes is >> problematic in that it may become a memory leak. >> >> I'd suggest to export two versions >> >> ? primes ?:: [Integer] >> ? primes' :: () -> [Integer] >> >> for casual (i.e. throwaway program to solve a Project Euler problem) and >> for memory aware use respectively. > > I'm afraid I don't quite follow. Would you mind explaining what the first parameter is for and how it would solve the memory leak? > _______________________________________________ > 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 daniel.is.fischer at web.de Thu Apr 16 05:05:53 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Apr 16 04:52:43 2009 Subject: [Haskell-cafe] Re: Looking for the fastest Haskell primes In-Reply-To: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AECF0@EXCHANGE10.campus.tue.nl> References: <20090416081641.B900A324AC9@www.haskell.org> <9BEB5EF43B5A4042B60C0D8179782DB3D6942AECF0@EXCHANGE10.campus.tue.nl> Message-ID: <200904161105.54188.daniel.is.fischer@web.de> Am Donnerstag 16 April 2009 10:41:43 schrieb Niemeijer, R.A.: > Heinrich Apfelmus wrote: > > +1 except that exporting the potentially infinite list of primes is > > problematic in that it may become a memory leak. > > > > I'd suggest to export two versions > > > > primes :: [Integer] > > primes' :: () -> [Integer] > > > > for casual (i.e. throwaway program to solve a Project Euler problem) and > > for memory aware use respectively. > > I'm afraid I don't quite follow. Would you mind explaining what the first > parameter is for and how it would solve the memory leak? If your programme uses primes some time early and again at the end, the list of primes (calculated so far) is kept in memory, because it's a top level constant (CAF). If you don't need the primes in between, calculate many of them at the start and use only a few at the end, that's a terrible memory-waste. If you don't use primes later, it *may* be that they're garbage-collected, but I wouldn't count on it. primes' is a function, so the list of primes is calculated anew every time you use primes' () in your programme and garbage collected when the programme leaves that use site. Which behaviour is desired depends of course on the programme. From barsoap at web.de Thu Apr 16 05:07:00 2009 From: barsoap at web.de (Achim Schneider) Date: Thu Apr 16 04:53:47 2009 Subject: [Haskell-cafe] Re: Looking for the fastest Haskell primes References: <20090416081641.B900A324AC9@www.haskell.org> <9BEB5EF43B5A4042B60C0D8179782DB3D6942AECF0@EXCHANGE10.campus.tue.nl> <5e0214850904160157g202464fcm166f8980e4bbb965@mail.gmail.com> Message-ID: <20090416110700.262c3e89@solaris> Eugene Kirpichov wrote: > The parameterless version is a top-level definition and won't get > garbage-collected, IIRC. > So, if you evaluate primes!!10000000, you'll end up with a > 10000000-element list hanging in memory forever. > If you evaluate (primes' ()) !! 10000000, you won't. > > {-# CAF foo #-} {-# NOCAF foo #-} -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From apfelmus at quantentunnel.de Thu Apr 16 05:21:31 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Thu Apr 16 05:08:11 2009 Subject: [Haskell-cafe] Re: Looking for the fastest Haskell primes In-Reply-To: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AECF0@EXCHANGE10.campus.tue.nl> References: <20090416081641.B900A324AC9@www.haskell.org> <9BEB5EF43B5A4042B60C0D8179782DB3D6942AECF0@EXCHANGE10.campus.tue.nl> Message-ID: Niemeijer, R.A. wrote: > Heinrich Apfelmus wrote: >> +1 except that exporting the potentially infinite list of primes is >> problematic in that it may become a memory leak. >> >> I'd suggest to export two versions >> >> primes :: [Integer] >> primes' :: () -> [Integer] >> >> for casual (i.e. throwaway program to solve a Project Euler problem) and >> for memory aware use respectively. > > I'm afraid I don't quite follow. Would you mind explaining what the > first parameter is for and how it would solve the memory leak? Sure. Lazy evaluation means that values, once evaluated, are stored in memory until garbage collections reclaims them because it is clear that they won't be used anymore. A memory leak happens when the programmer knows that values won't be used anymore while this knowledge is not available to the garbage collector. More specifically, consider the following example main = do print (primes !! 100) print (primes !! 20) This program will calculate the first 100 primes, and then print the 100th and the 1st prime. Now, after having printed the 100th prime, the 21th to 100th prime won't be used anymore and could thus be safely reclaimed by garbage collection. But since they are part of the primes list and this list is still in use for printing the 20th prime, this won't happen; we have a memory leak. The memory leak above can be avoided at the expense of recalculating the list. Using a function primes' with a dummy argument ensures^1 that the list of primes will be recalculated and garbage collected each time it is used: main = do print (primes' () !! 100) print (primes' () !! 20) Here, the first 100 primes are calculated, garbage collected and then the first 20 primes are (re-)calculated and garbage collected. We can fine control memory usage with the dummy argument version by using let statements or where clauses main = do let ps = primes' () in do print (ps !! 101) print (ps !! 100) -- no recalculation of ps print (primes' () !! 20) -- recalculates first 20 primes ^1: Compiler optimizations may interfere with that behavior. Generally, consensus is that the compiler should preserve sharing meticulously, but this is not guaranteed. See also: "full laziness transform". The above is folklore and should be written down properly at someplace prominent. The wiki page http://www.haskell.org/haskellwiki/Memory_leak is a start, but I think the explanation there is currently a bit murky. Feel free to incorporate my writings above. Regards, apfelmus -- http://apfelmus.nfshost.com From lennart at augustsson.net Thu Apr 16 05:28:52 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Thu Apr 16 05:15:18 2009 Subject: [Haskell-cafe] Re: Looking for the fastest Haskell primes In-Reply-To: References: <20090416081641.B900A324AC9@www.haskell.org> <9BEB5EF43B5A4042B60C0D8179782DB3D6942AECF0@EXCHANGE10.campus.tue.nl> Message-ID: But things are a little more complicated than that. If the () argument to primes' is not used in calculating the primes then ghc might decide to lift the computed list of primes into a top level CAF, and so you will have a memory leak anyway. If ghc does so or not depends, e.g., on the optimization level. -- Lennart On Thu, Apr 16, 2009 at 11:21 AM, Heinrich Apfelmus wrote: > Niemeijer, R.A. wrote: >> Heinrich Apfelmus wrote: >>> +1 except that exporting the potentially infinite list of primes is >>> problematic in that it may become a memory leak. >>> >>> I'd suggest to export two versions >>> >>> ? primes ?:: [Integer] >>> ? primes' :: () -> [Integer] >>> >>> for casual (i.e. throwaway program to solve a Project Euler problem) and >>> for memory aware use respectively. >> >> I'm afraid I don't quite follow. Would you mind explaining what the >> first parameter is for and how it would solve the memory leak? > > Sure. > > Lazy evaluation means that values, once evaluated, are stored in memory > until garbage collections reclaims them because it is clear that they > won't be used anymore. A ?memory leak ?happens when the programmer knows > that values won't be used anymore while this knowledge is not available > to the garbage collector. > > More specifically, consider the following example > > ?main = do > ? ? ?print (primes !! 100) > ? ? ?print (primes !! 20) > > This program will calculate the first 100 primes, and then print the > 100th and the 1st prime. Now, after having printed the 100th prime, the > 21th to 100th prime won't be used anymore and could thus be safely > reclaimed by garbage collection. But since they are part of the ?primes > ?list and this list is still in use for printing the 20th prime, this > won't happen; we have a memory leak. > > The memory leak above can be avoided at the expense of recalculating the > list. Using a function ?primes' ?with a dummy argument ensures^1 that > the list of primes will be recalculated and garbage collected each time > it is used: > > ?main = do > ? ? ?print (primes' () !! 100) > ? ? ?print (primes' () !! 20) > > Here, the first 100 primes are calculated, garbage collected and then > the first 20 primes are (re-)calculated and garbage collected. > > We can fine control memory usage with the dummy argument version by > using ?let ?statements or ?where ?clauses > > ?main = do > ? ? ?let ps = primes' () in do > ? ? ? ?print (ps !! 101) > ? ? ? ?print (ps !! 100) ? ? ? ?-- no recalculation of ps > ? ? ?print (primes' () !! 20) ? -- recalculates first 20 primes > > > ^1: Compiler optimizations may interfere with that behavior. Generally, > consensus is that the compiler should preserve sharing meticulously, but > this is not guaranteed. See also: "full laziness transform". > > > > The above is folklore and should be written down properly at someplace > prominent. The wiki page > > ? http://www.haskell.org/haskellwiki/Memory_leak > > is a start, but I think the explanation there is currently a bit murky. > Feel free to incorporate my writings above. > > > Regards, > apfelmus > > -- > http://apfelmus.nfshost.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jason.dusek at gmail.com Thu Apr 16 05:29:11 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Thu Apr 16 05:15:36 2009 Subject: [Haskell-cafe] Re: Looking for the fastest Haskell primes In-Reply-To: <20090416110700.262c3e89@solaris> References: <20090416081641.B900A324AC9@www.haskell.org> <9BEB5EF43B5A4042B60C0D8179782DB3D6942AECF0@EXCHANGE10.campus.tue.nl> <5e0214850904160157g202464fcm166f8980e4bbb965@mail.gmail.com> <20090416110700.262c3e89@solaris> Message-ID: <42784f260904160229h4eea3404gbb6d966423f9bfbf@mail.gmail.com> 2009/04/16 Achim Schneider : > {-# CAF foo #-} > {-# NOCAF foo #-} Where do I find docs for these pragmas? -- Jason Dusek From barsoap at web.de Thu Apr 16 06:04:39 2009 From: barsoap at web.de (Achim Schneider) Date: Thu Apr 16 05:51:29 2009 Subject: [Haskell-cafe] Re: Looking for the fastest Haskell primes References: <20090416081641.B900A324AC9@www.haskell.org> <9BEB5EF43B5A4042B60C0D8179782DB3D6942AECF0@EXCHANGE10.campus.tue.nl> <5e0214850904160157g202464fcm166f8980e4bbb965@mail.gmail.com> <20090416110700.262c3e89@solaris> <42784f260904160229h4eea3404gbb6d966423f9bfbf@mail.gmail.com> Message-ID: <20090416120439.6529cc05@solaris> Jason Dusek wrote: > 2009/04/16 Achim Schneider : > > {-# CAF foo #-} > > {-# NOCAF foo #-} > > Where do I find docs for these pragmas? > ...in your friendly bug tracker, under the label "missing feature" -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From bulat.ziganshin at gmail.com Thu Apr 16 06:14:39 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Apr 16 06:03:54 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <1239706019.6858.1310393875@webmail.messagingengine.com> <1239781327.2103.1310566707@webmail.messagingengine.com> <2B9AE96A81BB4D45B8960B2B3536DEB5@cr3lt> <1239869209.7657.1310757441@webmail.messagingengine.com> Message-ID: <15010596464.20090416141439@gmail.com> Hello Peter, Thursday, April 16, 2009, 12:29:41 PM, you wrote: Lennart (and Patai) said about unsafePerformIO, you - about NOINLINE > Well, the documentation says: > Use?{-# NOINLINE foo #-}?as a pragma on any function?foo?that calls > unsafePerformIO. If the call is inlined, the I/O may be performed more than once. > > So you claim this does not prevent GHC to inline it anyway? That > feels like a bug then, both in the documentation and NOINLINE? > On Thu, Apr 16, 2009 at 10:18 AM, Lennart Augustsson wrote: > > There's no guarantee about unsafePerformIO not being inlined, that's > just how ghc treats it. > > 2009/4/16 Patai Gergely : > >>> On the other hand, breaking referential transparency in the >>> external interface is a very bad idea, in my opinion. Actually, >>> this means that the library user would have to turn certain >>> compiler optimizations off to get the intended behavior. >> However, in practice you can compile Elerea with -O2 without ill >> effects. In fact, that's what happens if you install it with cabal. >> >>> Just have a look at the Haddock docs of unsafePerformIO. >> Yes, I did that too, and came up with the following checklist: >> >> - the order of side effects doesn't matter much, since the resulting >> networks are equivalent if we don't rely on the automatic delay feature >> (applicative optimisations can be different, but still with the same net >> effect) >> - unsafePerformIO is apparently never inlined, i.e. each instance is >> executed once, so sharing works as desired >> - let-floating is no problem, because all instances of unsafePerformIO >> rely on surrounding function arguments >> - CSE is no problem either, it even helps if it's performed (and it is >> with optimisations turned on), since it results in smaller equivalent >> networks >> >> I think we can expect it to be fairly well-behaving, because the 'side >> effect' of Elerea primitives is basically the same as that of pure >> values in general: upon evaluation a value is created in the memory and >> we get a reference to it. We only have an extra constraint for the >> compiler: never duplicate these values. Merging identical ones is okay, >> and in fact desirable. The following code demonstrates this if you >> compile it with and without optimisations: >> >> import Control.Applicative >> import Control.Monad >> import FRP.Elerea >> import System.IO.Unsafe >> >> cint a b = unsafePerformIO (putStrLn "!") `seq` >> ? ? ? ? ? transfer 0 (\dt x x0 -> x0+x*dt) b >> >> mysig = (latcher 0 (b >@ 0.3) (const (cint a b) <$> cint a b)) + >> ? ? ? ?(cint a b) + (cint a b) + a >> ? ?where a = pure 4 >> ? ? ? ? ?b = stateful 0 (+) >> >> main = replicateM 10 (superstep mysig 0.1) >>= print >> >> I'd like to see an example where optimisation does make a difference, >> because I'm still unsure about the consequences of 'unsafeness'. >> >> Gergely >> >> -- >> http://www.fastmail.fm - Or how I learned to stop worrying and >> ? ? ? ? ? ? ? ? ? ? ? ? ?love email again >> >> _______________________________________________ >> 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 > > -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From lennart at augustsson.net Thu Apr 16 06:40:50 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Thu Apr 16 06:27:16 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <1239781327.2103.1310566707@webmail.messagingengine.com> <2B9AE96A81BB4D45B8960B2B3536DEB5@cr3lt> <1239869209.7657.1310757441@webmail.messagingengine.com> Message-ID: With NOINLINE you should be safe, but you never mentioned that originally. :) On Thu, Apr 16, 2009 at 10:29 AM, Peter Verswyvelen wrote: > Well, the documentation says: > Use?{-# NOINLINE foo #-}?as a pragma on any function?foo?that > calls?unsafePerformIO. If the call is inlined, the I/O may be performed more > than once. > So you claim this does not prevent GHC to inline it anyway? That feels like > a bug then, both in the documentation and NOINLINE > On Thu, Apr 16, 2009 at 10:18 AM, Lennart Augustsson > wrote: >> >> There's no guarantee about unsafePerformIO not being inlined, that's >> just how ghc treats it. >> >> 2009/4/16 Patai Gergely : >> >> On the other hand, breaking referential transparency in the >> >> external interface is a very bad idea, in my opinion. Actually, >> >> this means that the library user would have to turn certain >> >> compiler optimizations off to get the intended behavior. >> > However, in practice you can compile Elerea with -O2 without ill >> > effects. In fact, that's what happens if you install it with cabal. >> > >> >> Just have a look at the Haddock docs of unsafePerformIO. >> > Yes, I did that too, and came up with the following checklist: >> > >> > - the order of side effects doesn't matter much, since the resulting >> > networks are equivalent if we don't rely on the automatic delay feature >> > (applicative optimisations can be different, but still with the same net >> > effect) >> > - unsafePerformIO is apparently never inlined, i.e. each instance is >> > executed once, so sharing works as desired >> > - let-floating is no problem, because all instances of unsafePerformIO >> > rely on surrounding function arguments >> > - CSE is no problem either, it even helps if it's performed (and it is >> > with optimisations turned on), since it results in smaller equivalent >> > networks >> > >> > I think we can expect it to be fairly well-behaving, because the 'side >> > effect' of Elerea primitives is basically the same as that of pure >> > values in general: upon evaluation a value is created in the memory and >> > we get a reference to it. We only have an extra constraint for the >> > compiler: never duplicate these values. Merging identical ones is okay, >> > and in fact desirable. The following code demonstrates this if you >> > compile it with and without optimisations: >> > >> > import Control.Applicative >> > import Control.Monad >> > import FRP.Elerea >> > import System.IO.Unsafe >> > >> > cint a b = unsafePerformIO (putStrLn "!") `seq` >> > ? ? ? ? ? transfer 0 (\dt x x0 -> x0+x*dt) b >> > >> > mysig = (latcher 0 (b >@ 0.3) (const (cint a b) <$> cint a b)) + >> > ? ? ? ?(cint a b) + (cint a b) + a >> > ? ?where a = pure 4 >> > ? ? ? ? ?b = stateful 0 (+) >> > >> > main = replicateM 10 (superstep mysig 0.1) >>= print >> > >> > I'd like to see an example where optimisation does make a difference, >> > because I'm still unsure about the consequences of 'unsafeness'. >> > >> > Gergely >> > >> > -- >> > http://www.fastmail.fm - Or how I learned to stop worrying and >> > ? ? ? ? ? ? ? ? ? ? ? ? ?love email again >> > >> > _______________________________________________ >> > 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 Thu Apr 16 07:11:01 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Thu Apr 16 06:57:27 2009 Subject: [Haskell-cafe] Re: Looking for the fastest Haskell primes In-Reply-To: <5e0214850904160157g202464fcm166f8980e4bbb965@mail.gmail.com> References: <20090416081641.B900A324AC9@www.haskell.org> <9BEB5EF43B5A4042B60C0D8179782DB3D6942AECF0@EXCHANGE10.campus.tue.nl> <5e0214850904160157g202464fcm166f8980e4bbb965@mail.gmail.com> Message-ID: I vaguely remember someone (maybe Duncan Coutts?) saying that this was a commonly held misconception, and that GHC did indeed GC CAFs when optimization is enabled. If I am remembering incorrectly, does anyone have a reference to a ticket outlining this non-GC'ed CAF behavior? Thanks, Dan On Thu, Apr 16, 2009 at 4:57 AM, Eugene Kirpichov wrote: > The parameterless version is a top-level definition and won't get > garbage-collected, IIRC. > So, if you evaluate primes!!10000000, you'll end up with a > 10000000-element list hanging in memory forever. > If you evaluate (primes' ()) !! 10000000, you won't. > > 2009/4/16 Niemeijer, R.A. : >> Heinrich Apfelmus wrote: >>> +1 except that exporting the potentially infinite list of primes is >>> problematic in that it may become a memory leak. >>> >>> I'd suggest to export two versions >>> >>> ? primes ?:: [Integer] >>> ? primes' :: () -> [Integer] >>> >>> for casual (i.e. throwaway program to solve a Project Euler problem) and >>> for memory aware use respectively. >> >> I'm afraid I don't quite follow. Would you mind explaining what the first parameter is for and how it would solve the memory leak? >> _______________________________________________ >> 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 jules at jellybean.co.uk Thu Apr 16 07:23:51 2009 From: jules at jellybean.co.uk (Jules Bean) Date: Thu Apr 16 07:10:17 2009 Subject: [Haskell-cafe] Re: Looking for the fastest Haskell primes In-Reply-To: <5e0214850904160157g202464fcm166f8980e4bbb965@mail.gmail.com> References: <20090416081641.B900A324AC9@www.haskell.org> <9BEB5EF43B5A4042B60C0D8179782DB3D6942AECF0@EXCHANGE10.campus.tue.nl> <5e0214850904160157g202464fcm166f8980e4bbb965@mail.gmail.com> Message-ID: <49E71547.9070708@jellybean.co.uk> Eugene Kirpichov wrote: > The parameterless version is a top-level definition and won't get > garbage-collected, IIRC. This has not-much to do with CAFs and is really just about scope + values + liveness. live values (those which a program still refers to, e.g. from a function which might get called in the future) don't get GCed. CAFs are just in the top-most scope and particularly likely to get held live in this fashion. As Lennart points out, optimisations occasionally increase sharing, although GHC tries fairly hard not to do this. Jules From bugfact at gmail.com Thu Apr 16 07:32:57 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Apr 16 07:19:22 2009 Subject: [Haskell-cafe] ANN: Elerea, another FRP library In-Reply-To: References: <1239381666.12202.1309941005@webmail.messagingengine.com> <1239781327.2103.1310566707@webmail.messagingengine.com> <2B9AE96A81BB4D45B8960B2B3536DEB5@cr3lt> <1239869209.7657.1310757441@webmail.messagingengine.com> Message-ID: Oh I see. Gergely did mention it in a previous email: Am I right thinking that the NOINLINE pragma on unsafeDupablePerformIO prevents the problem of multiple evaluation discussed yesterday? Or should I add NOINLINE to primitives in Elerea.Internal too? If that guaranteed sharing, it would So I got confused, mixing up several emails here. Mea culpa. On Thu, Apr 16, 2009 at 12:40 PM, Lennart Augustsson wrote: > With NOINLINE you should be safe, but you never mentioned that originally. > :) > > On Thu, Apr 16, 2009 at 10:29 AM, Peter Verswyvelen > wrote: > > Well, the documentation says: > > Use {-# NOINLINE foo #-} as a pragma on any function foo that > > calls unsafePerformIO. If the call is inlined, the I/O may be performed > more > > than once. > > So you claim this does not prevent GHC to inline it anyway? That feels > like > > a bug then, both in the documentation and NOINLINE > > On Thu, Apr 16, 2009 at 10:18 AM, Lennart Augustsson > > wrote: > >> > >> There's no guarantee about unsafePerformIO not being inlined, that's > >> just how ghc treats it. > >> > >> 2009/4/16 Patai Gergely : > >> >> On the other hand, breaking referential transparency in the > >> >> external interface is a very bad idea, in my opinion. Actually, > >> >> this means that the library user would have to turn certain > >> >> compiler optimizations off to get the intended behavior. > >> > However, in practice you can compile Elerea with -O2 without ill > >> > effects. In fact, that's what happens if you install it with cabal. > >> > > >> >> Just have a look at the Haddock docs of unsafePerformIO. > >> > Yes, I did that too, and came up with the following checklist: > >> > > >> > - the order of side effects doesn't matter much, since the resulting > >> > networks are equivalent if we don't rely on the automatic delay > feature > >> > (applicative optimisations can be different, but still with the same > net > >> > effect) > >> > - unsafePerformIO is apparently never inlined, i.e. each instance is > >> > executed once, so sharing works as desired > >> > - let-floating is no problem, because all instances of unsafePerformIO > >> > rely on surrounding function arguments > >> > - CSE is no problem either, it even helps if it's performed (and it is > >> > with optimisations turned on), since it results in smaller equivalent > >> > networks > >> > > >> > I think we can expect it to be fairly well-behaving, because the 'side > >> > effect' of Elerea primitives is basically the same as that of pure > >> > values in general: upon evaluation a value is created in the memory > and > >> > we get a reference to it. We only have an extra constraint for the > >> > compiler: never duplicate these values. Merging identical ones is > okay, > >> > and in fact desirable. The following code demonstrates this if you > >> > compile it with and without optimisations: > >> > > >> > import Control.Applicative > >> > import Control.Monad > >> > import FRP.Elerea > >> > import System.IO.Unsafe > >> > > >> > cint a b = unsafePerformIO (putStrLn "!") `seq` > >> > transfer 0 (\dt x x0 -> x0+x*dt) b > >> > > >> > mysig = (latcher 0 (b >@ 0.3) (const (cint a b) <$> cint a b)) + > >> > (cint a b) + (cint a b) + a > >> > where a = pure 4 > >> > b = stateful 0 (+) > >> > > >> > main = replicateM 10 (superstep mysig 0.1) >>= print > >> > > >> > I'd like to see an example where optimisation does make a difference, > >> > because I'm still unsure about the consequences of 'unsafeness'. > >> > > >> > Gergely > >> > > >> > -- > >> > http://www.fastmail.fm - Or how I learned to stop worrying and > >> > love email again > >> > > >> > _______________________________________________ > >> > 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/20090416/95096efb/attachment.htm From david.m.carter at gmail.com Thu Apr 16 07:49:19 2009 From: david.m.carter at gmail.com (David Carter) Date: Thu Apr 16 07:35:45 2009 Subject: [Haskell-cafe] Data.ByteString woes In-Reply-To: <42784f260904151635x3ba2c18ar738823b48a477fd3@mail.gmail.com> References: <5a1362990904150416i258d3de5x76d8b8d9c231aa1b@mail.gmail.com> <42784f260904151635x3ba2c18ar738823b48a477fd3@mail.gmail.com> Message-ID: <5a1362990904160449v343ce08erff461444ab56238f@mail.gmail.com> http://pastebin.com/m88c7dc It works fine if you delete the ".Lazy". Enjoy, and thanks... David On Thu, Apr 16, 2009 at 12:35 AM, Jason Dusek wrote: > Could you pastebin something that demoes the error? > > -- > Jason Dusek > From duncan.coutts at worc.ox.ac.uk Thu Apr 16 07:58:40 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Apr 16 07:45:07 2009 Subject: [Haskell-cafe] how to upgrade? In-Reply-To: <49D5E943.2020005@imn.htwk-leipzig.de> References: <49D5E943.2020005@imn.htwk-leipzig.de> Message-ID: <1239883120.6315.27.camel@lantern> On Fri, 2009-04-03 at 12:47 +0200, Johannes Waldmann wrote: > Is there a nice way of upgrading ghc: > I mean does cabal-upgrade know to install > exactly the packages that I had with the previous ghc version? There will be soon! http://hackage.haskell.org/trac/hackage/ticket/199 There's a patch waiting for me (or anyone else) to review and integrate into cabal-install. Duncan From duncan.coutts at worc.ox.ac.uk Thu Apr 16 08:00:54 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Apr 16 07:47:18 2009 Subject: [Haskell-cafe] Data.ByteString woes In-Reply-To: <5a1362990904160449v343ce08erff461444ab56238f@mail.gmail.com> References: <5a1362990904150416i258d3de5x76d8b8d9c231aa1b@mail.gmail.com> <42784f260904151635x3ba2c18ar738823b48a477fd3@mail.gmail.com> <5a1362990904160449v343ce08erff461444ab56238f@mail.gmail.com> Message-ID: <1239883254.6315.30.camel@lantern> On Thu, 2009-04-16 at 12:49 +0100, David Carter wrote: > http://pastebin.com/m88c7dc > > It works fine if you delete the ".Lazy". > > Enjoy, and thanks... This will be because the version of the regex lib you're using does not have an instance for lazy ByteStrings. Do you know what versions of the regex libs you were using in each case? They're not necessarily related to your ghc version if you installed the regex libs via cabal-install. Duncan From duncan.coutts at worc.ox.ac.uk Thu Apr 16 08:06:35 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Apr 16 07:53:02 2009 Subject: [Haskell-cafe] Re: Looking for the fastest Haskell primes In-Reply-To: References: <20090416081641.B900A324AC9@www.haskell.org> <9BEB5EF43B5A4042B60C0D8179782DB3D6942AECF0@EXCHANGE10.campus.tue.nl> <5e0214850904160157g202464fcm166f8980e4bbb965@mail.gmail.com> Message-ID: <1239883595.6315.34.camel@lantern> On Thu, 2009-04-16 at 07:11 -0400, Daniel Peebles wrote: > I vaguely remember someone (maybe Duncan Coutts?) saying that this was > a commonly held misconception, and that GHC did indeed GC CAFs when > optimization is enabled. If I am remembering incorrectly, does anyone > have a reference to a ticket outlining this non-GC'ed CAF behavior? It was Simon Marlow. I quote: "FUD! CAFs are definitely garbage collected" http://haskell.org/pipermail/haskell-cafe/2009-February/055525.html Duncan From claus.reinke at talk21.com Thu Apr 16 08:11:25 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Thu Apr 16 07:57:57 2009 Subject: [Haskell-cafe] Strange type error with associated type synonyms References: <646230a00904061436x41af1055se39e8892eb4e3083@mail.gmail.com><4580278B-D5B6-4A4E-9233-415B57F60A3E@cse.unsw.edu.au><1bc51a990904070348p7e6fc849qeaa45b155279e435@mail.gmail.com><9DC371FCEE914C19966965FB38881AC1@cr3lt><638ABD0A29C8884A91BC5FB5C349B1C335080DECA1@EA-EXMSG-C334.europe.corp.microsoft.com><3E3186D9A0F34311825C9D476DB9F1D9@cr3lt><638ABD0A29C8884A91BC5FB5C349B1C33508188D5B@EA-EXMSG-C334.europe.corp.microsoft.com> <638ABD0A29C8884A91BC5FB5C349B1C33751DDBD3A@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <447BE93976BD42759565418F9AE5E964@cr3lt> | But the core part of my suggestion (which this example was meant | to help explain) remains attractive, at least to me: somewhere during | type inference, GHC *does* unify the *apparently free* 'd' with an | internal type variable (lets call it 'd1, as in the type error message) >You are speculating about the *algorithm*. There is no need to reason about the algorithm, only about its observable results ('d1' appeared in the error message, but not in the inferred type). But I've finally figured out what had me confused - sadly something that has come up before, I just had forgotten to apply it here. First, the code again: {-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE TypeFamilies #-} class Fun d where type Memo d :: * -> * abst :: (d -> a) -> Memo d a appl :: Memo d a -> (d -> a) -- f :: (Fun d) => Memo d a -> Memo d a -- (1) f = abst . appl (1) is the type inferred by GHCi. If we uncomment it, we get this error: D:\home\Haskell\tmp\desktop\types.hs:11:11: Couldn't match expected type `Memo d1' against inferred type `Memo d' In the second argument of `(.)', namely `appl' In the expression: abst . appl In the definition of `f': f = abst . appl My _erroneous_ reasoning was that some unknown 'd1' was being unified with the 'd' from the signature. So I wanted that 'd1' to be represented in the signature inferred by GHCi. Of course, the error message really says something quite different, and if I had recalled that 'Memo' is a type synonym, I would have noticed that. If GHC ever provides an option to bracket fully applied type synonyms, I'd probably switch it on by default. (what one actually wants is a way to distinguish type-level general functions from type-level constructors that can be decomposed during unification, similar to what Haskell does with capitalization at the expression level, to distinguish general functions from constructors that can be decomposed during matching). With such an option, the inferred type would look like this (er, hi Conor): f :: (Fun d) => {Memo d} a -> {Memo d} a The first parameter of 'Memo' is not directly available for unification, so this signature is ambiguous as it stands, as you tried to point out (with no way to pin down 'd', 'Memo d' can never unify with anything other than itself, identically). Apart from bracketing fully applied type synonyms, the error message could be improved by providing the missing bit of information about 'Memo': D:\home\Haskell\tmp\desktop\types.hs:11:11: Couldn't match expected type `Memo d1' against inferred type `Memo d' (type Memo d :: * -> *) In the second argument of `(.)', namely `appl' In the expression: abst . appl In the definition of `f': f = abst . appl Sorry about letting myself get confused again by this known issue. Claus PS. I thought I'd try this alternative signature, to make the ambiguity explicit: f :: (Memo d~md,Fun d) => md a -> md a -- (2) but the error message is even less helpful: D:\home\Haskell\tmp\desktop\types.hs:11:11: Couldn't match expected type `Memo d' against inferred type `md' `md' is a rigid type variable bound by the type signature for `f' at D:\home\Haskell\tmp\desktop\types.hs:10:14 In the second argument of `(.)', namely `appl' In the expression: abst . appl In the definition of `f': f = abst . appl Shouldn't the inferred type still be 'Memo d1'? Why is part of the _declared_ type "expected" ('Memo d'), the other "inferred" ('md')? Could GHC perhaps be more detailed about 'expected', 'inferred', and 'declared', and use these terms from a user perspective? Even in the original error message, shouldn't 'expected' and 'inferred' be the other way round? And if we add the missing contexts for the types mentioned in the message, the error message could really be: D:\home\Haskell\tmp\desktop\types.hs:11:11: Couldn't match inferred type `Memo d1' (f :: (Fun d1) => {Memo d1} a -> {Memo d1} a) against declared type `Memo d' (f :: (Fun d) => {Memo d} a -> {Memo d} a) (type {Memo d} :: * -> *) In the second argument of `(.)', namely `appl' In the expression: abst . appl In the definition of `f': f = abst . appl Perhaps then I would have seen what was going on?-) From jpm at cs.uu.nl Thu Apr 16 08:12:57 2009 From: jpm at cs.uu.nl (=?ISO-8859-1?Q?Jos=E9_Pedro_Magalh=E3es?=) Date: Thu Apr 16 07:59:36 2009 Subject: [Haskell-cafe] understanding generics In-Reply-To: References: Message-ID: <52f14b210904160512o72b4acb8iccc687f9c175517c@mail.gmail.com> Hello Anatoly, On Sat, Apr 11, 2009 at 20:44, Anatoly Yakovenko wrote: > i am trying to understand how data.data works. How would i traverse > the subterms of one type and build another type out of them. > something like this: > > > gmapQ (\a -> Right a) (Just "hello") I am not sure I understand what you're trying to do here. However, in general, 'gmapQ' is used in combination with 'mkQ' or 'extQ'. Those are not in Data.Data: you can import Data.Generics to get everything syb-related. Cheers, Pedro > > > :1:0: > Inferred type is less polymorphic than expected > Quantified type variable `d' escapes > In the first argument of `gmapQ', namely `(\ a -> Right a)' > In the expression: gmapQ (\ a -> Right a) (Just "hello") > In the definition of `it': > it = gmapQ (\ a -> Right a) (Just "hello") > > > Thanks, > Anatoly > _______________________________________________ > 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/20090416/d7bae0ad/attachment.htm From sebf at informatik.uni-kiel.de Thu Apr 16 09:30:20 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Thu Apr 16 09:16:49 2009 Subject: [Haskell-cafe] Looking for the fastest Haskell primes algorithm In-Reply-To: <95E378AF-7DE7-4336-B733-7C8E689B9E93@inf.fu-berlin.de> References: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> <95E378AF-7DE7-4336-B733-7C8E689B9E93@inf.fu-berlin.de> Message-ID: <41D57468-D72C-4349-A8C0-8BEF576B228E@informatik.uni-kiel.de> On Apr 15, 2009, at 5:27 PM, Adrian Neumann wrote: > I've just uploaded a package with some functions I had lying around. > > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Numbers This package seems to be missing the source file Data/Numbers/ Primes.hs so I couldn't compare it to my own implementation (see separate announcement). Cheers, Sebastian From sebf at informatik.uni-kiel.de Thu Apr 16 09:30:36 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Thu Apr 16 09:17:05 2009 Subject: [Haskell-cafe] [Announce] primes Message-ID: I am pleased to announce the package 'primes' that implements lazy wheel sieves for efficient, purely functional generation of prime numbers in Haskell. Following the current discussion about primes in Haskell, I packaged up an implementation inspired by the papers "Lazy wheel sieves and spirals of primes" by Colin Runciman and "The Genuine Sieve of Eratosthenes" by Melissa O'Neil. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/primes The package does not implement all that was wished for in the mentioned discussion. It only exports two operations: The global constant primes :: [Integer] is an infinite list of primes and wheelSieve :: Int -> [Integer] is the function used to build this list. If you are worried about the memory requirements of using a global constant, you can use `wheelSieve 6` instead of `primes`. The implementation is reasonably efficient. The query > primes !! 1000000 15485867 answers after a few seconds. Feel free to contribute more functionality to this package. The sources are on Github: http://github.com/sebfisch/primes If you fork my project, I'll be happy to merge your changes. Cheers, Sebastian From monnier at iro.umontreal.ca Thu Apr 16 10:00:30 2009 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Thu Apr 16 09:47:16 2009 Subject: [Haskell-cafe] Re: Issues with running Ghci from emacs References: <1239870050.9584.1310764949@webmail.messagingengine.com> Message-ID: > It is looking for the closest ancestor directory with a file ending in > .cabal, and that's where cd goes. Probably the simplest way to trick it > without chaniging any setting is to create an empty dummy.cabal in the > directory of your program. The haskell-mode code in the CVS repository has a fix for that problem. Stefan From r.a.niemeijer at tue.nl Thu Apr 16 10:45:59 2009 From: r.a.niemeijer at tue.nl (Niemeijer, R.A.) Date: Thu Apr 16 10:32:28 2009 Subject: [Haskell-cafe] RE: [Announce] primes In-Reply-To: <20090416134724.242DB32471B@www.haskell.org> References: <20090416134724.242DB32471B@www.haskell.org> Message-ID: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AEDFE@EXCHANGE10.campus.tue.nl> Sebastian Fischer wrote: > I am pleased to announce the package 'primes' that implements lazy > wheel sieves for efficient, purely functional generation of prime > numbers in Haskell. > > The implementation is reasonably efficient. The query > > > primes !! 1000000 > 15485867 > > answers after a few seconds. > > Feel free to contribute more functionality to this package. The > sources are on Github: > > http://github.com/sebfisch/primes > > If you fork my project, I'll be happy to merge your changes. I have just finished benchmarking all the implementations provided in http://www.cs.hmc.edu/~oneill/code/haskell-primes.zip (the zip file linked to from the Haskell wiki article on primes). NaurPrimes.hs is by far the fastest version, and at least 2 or 3 times faster than your current implementation. I'm pretty sure it also uses less memory. I want to find efficient algorithms for the other proposed functions before forking, but I figured I'd let you know in the meantime. From sebf at informatik.uni-kiel.de Thu Apr 16 11:22:08 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Thu Apr 16 11:08:35 2009 Subject: [Haskell-cafe] Re: [Announce] primes In-Reply-To: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AEDFE@EXCHANGE10.campus.tue.nl> References: <20090416134724.242DB32471B@www.haskell.org> <9BEB5EF43B5A4042B60C0D8179782DB3D6942AEDFE@EXCHANGE10.campus.tue.nl> Message-ID: <5CE9D4BD-44A6-43B5-AB3E-5E147E0B8F8C@informatik.uni-kiel.de> > I have just finished benchmarking all the implementations provided > in http://www.cs.hmc.edu/~oneill/code/haskell-primes.zip (the zip > file linked to from the Haskell wiki article on primes). > > NaurPrimes.hs is by far the fastest version, and at least 2 or 3 > times faster than your current implementation. Thanks for the benchmarks! > I'm pretty sure it also uses less memory. Do you understand the memory requirements of my implementation? I'm not sure if I do. Is it only that the queue of multiples gets larger and larger the more primes we query? > I want to find efficient algorithms for the other proposed functions > before forking, but I figured I'd let you know in the meantime. Thanks! Feel free to incorporate ideas from NaurPrimes.hs. I don't understand them yet. Cheers, Sebastian From simon at joyful.com Thu Apr 16 12:10:28 2009 From: simon at joyful.com (Simon Michael) Date: Thu Apr 16 11:57:06 2009 Subject: [Haskell-cafe] Re: google-like "do you mean?" feature In-Reply-To: <5540a5470904152355y3edc8044p7846f56019f10d0@mail.gmail.com> References: <49E6D0D6.5010702@alumni.caltech.edu> <5540a5470904152355y3edc8044p7846f56019f10d0@mail.gmail.com> Message-ID: > To measure how similar two strings are, you can use a metric like > Levenshtein distance, Damerau-Levenshtein distance, or Jaro-Winkler I tried some of those just the other day, and in my app this worked much better: http://www.catalysoft.com/articles/StrikeAMatch.html From daniel.is.fischer at web.de Thu Apr 16 12:39:07 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Apr 16 12:25:47 2009 Subject: [Haskell-cafe] RE: [Announce] primes In-Reply-To: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AEDFE@EXCHANGE10.campus.tue.nl> References: <20090416134724.242DB32471B@www.haskell.org> <9BEB5EF43B5A4042B60C0D8179782DB3D6942AEDFE@EXCHANGE10.campus.tue.nl> Message-ID: <200904161839.07710.daniel.is.fischer@web.de> Am Donnerstag 16 April 2009 16:45:59 schrieb Niemeijer, R.A.: > Sebastian Fischer wrote: > > I am pleased to announce the package 'primes' that implements lazy > > wheel sieves for efficient, purely functional generation of prime > > numbers in Haskell. > > > > The implementation is reasonably efficient. The query > > > > > primes !! 1000000 > > > > 15485867 > > > > answers after a few seconds. > > > > Feel free to contribute more functionality to this package. The > > sources are on Github: > > > > http://github.com/sebfisch/primes > > > > If you fork my project, I'll be happy to merge your changes. > > I have just finished benchmarking all the implementations provided in > http://www.cs.hmc.edu/~oneill/code/haskell-primes.zip (the zip file linked > to from the Haskell wiki article on primes). > > NaurPrimes.hs is by far the fastest version, and at least 2 or 3 times > faster than your current implementation. I'm pretty sure it also uses less > memory. I want to find efficient algorithms for the other proposed > functions before forking, but I figured I'd let you know in the meantime. Nevertheless, a bitsieve is much faster: Prelude NaurPrimes> length $ primesToLimit (10^8) 5761455 (26.50 secs, 5734921092 bytes) Prelude NaurPrimes> :l Ok, modules loaded: none. (0.00 secs, 0 bytes) Prelude> :m +Euler.Primes Prelude Euler.Primes> length $ primesUpTo (10^8) Loading package base-3.0.3.0 ... linking ... done. Loading package euler-0.1 ... linking ... done. 5761455 (2.14 secs, 573050276 bytes) The problems for a bitsieve are a) you don't easily get the small primes before sieving is complete b) how to proceed after the sieving bound From irving at naml.us Thu Apr 16 12:57:08 2009 From: irving at naml.us (Geoffrey Irving) Date: Thu Apr 16 12:43:48 2009 Subject: [Haskell-cafe] RE: [Announce] primes In-Reply-To: <200904161839.07710.daniel.is.fischer@web.de> References: <20090416134724.242DB32471B@www.haskell.org> <9BEB5EF43B5A4042B60C0D8179782DB3D6942AEDFE@EXCHANGE10.campus.tue.nl> <200904161839.07710.daniel.is.fischer@web.de> Message-ID: <7f9d599f0904160957w4bf271fwa14cb18397f7d926@mail.gmail.com> On Thu, Apr 16, 2009 at 12:39 PM, Daniel Fischer wrote: > Am Donnerstag 16 April 2009 16:45:59 schrieb Niemeijer, R.A.: >> Sebastian Fischer wrote: >> > I am pleased to announce the package 'primes' that implements lazy >> > wheel sieves for efficient, purely functional generation of prime >> > numbers in Haskell. >> > >> > The implementation is reasonably efficient. The query >> > >> > ?> primes !! 1000000 >> > >> > 15485867 >> > >> > answers after a few seconds. >> > >> > Feel free to contribute more functionality to this package. The >> > sources are on Github: >> > >> > ? ? ?http://github.com/sebfisch/primes >> > >> > If you fork my project, I'll be happy to merge your changes. >> >> I have just finished benchmarking all the implementations provided in >> http://www.cs.hmc.edu/~oneill/code/haskell-primes.zip (the zip file linked >> to from the Haskell wiki article on primes). >> >> NaurPrimes.hs is by far the fastest version, and at least 2 or 3 times >> faster than your current implementation. I'm pretty sure it also uses less >> memory. I want to find efficient algorithms for the other proposed >> functions before forking, but I figured I'd let you know in the meantime. > > Nevertheless, a bitsieve is much faster: > > Prelude NaurPrimes> length $ primesToLimit (10^8) > 5761455 > (26.50 secs, 5734921092 bytes) > Prelude NaurPrimes> :l > Ok, modules loaded: none. > (0.00 secs, 0 bytes) > Prelude> :m +Euler.Primes > Prelude Euler.Primes> length $ primesUpTo (10^8) > Loading package base-3.0.3.0 ... linking ... done. > Loading package euler-0.1 ... linking ... done. > 5761455 > (2.14 secs, 573050276 bytes) > > The problems for a bitsieve are > a) you don't easily get the small primes before sieving is complete > b) how to proceed after the sieving bound You can solve both of these by always sieving up to powers of 2. If you've sieved up to 2^n you can extend it to 2^(n+1) by restarting the sieve and using the fact that you don't need to recheck the first half of the range. The result shouldn't be much slower than a full sieve, and can probably be written entirely with unboxed array monads (no unsafePerformIO) if desired. Geoffrey From magnicida at gmail.com Thu Apr 16 15:17:16 2009 From: magnicida at gmail.com (Juan Pedro Bolivar Puente) Date: Thu Apr 16 15:11:27 2009 Subject: [Haskell-cafe] Re: How the following works In-Reply-To: References: Message-ID: I find it easier to understand when looking at the declarative meaning of the definition. There is the trivial case of the empty list, but for the non-empty list: The possible inits of the list is the empty list and the inits of the "rest of the list" with the "head" element it their front. The execution would look like this: 1. The recurrsion would get to the tail of the list and calculate its inits, [[]]. 2. Then the recursion would go back, add the (n-th) element at the front of all the previously calculated inits [[x_n]], and add the empty list, we get [[],[x_n]]. 3. The same applies for the element n-1 and we get, [x, [x_(n-1)], [x_(n-1), n]] ... I hope this helped :p JP Tsunkiet Man wrote: > Hello, > > I can hardly imagine how the following code works: > > cinits :: [a] -> [[a]] > cinits [] = [[]] > cinits (x:xs) = [] : map (x:) (cinits xs) > > can someone give me a good explaination? > > (I understand it a bit, but it's really hard for me to figure out how a map > in a map function works.) > > Thank you for your time, > > Tsunkiet > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From magnicida at gmail.com Thu Apr 16 15:37:08 2009 From: magnicida at gmail.com (Juan Pedro Bolivar Puente) Date: Thu Apr 16 15:25:33 2009 Subject: [Haskell-cafe] Re: How the following works In-Reply-To: References: Message-ID: I don't know if the following explanation seems too basic or redundant to you, I'm sorry if that is the case, but it might help if you don't understand high order functions very well: In my description of the declarative meaning of the definition I understood this: "map (x:) (cinits xs)" as add the element 'x' in the front of every element (int this case, the elements are lists) of the list returned by (cinit xs) Thing of (:) as a function: (:) :: a -> [a] -> [a] That appends its first argument in the front of the list given as a second argument. Then (x:) is a function with type: (x:) :: [a] -> [a] It is a function that appends to a fixed element x to a given list. As "map f list" returns a new list that is the result of applying f to every element of "list", assuming "list" is a list of lists, "map (x:) list" returns a new list that has 'x' in the front of every element. An example: map (1:) [[2], [3], [4]] Prelude> map (1:) [[2], [3], [4]] [[1,2],[1,3],[1,4]] Because: map f [[2], [3], [4]] = [f [2], f [3], f [4]] So let f = (x:) then: map f [[2], [3], [4]] = [(1:) [2], (1:) [3], (1:) [4]] = [[1, 2], [1, 3], [1, 4]] JP Juan Pedro Bolivar Puente wrote: > I find it easier to understand when looking at the declarative meaning > of the definition. There is the trivial case of the empty list, but for > the non-empty list: > > The possible inits of the list is the empty list and the inits of the > "rest of the list" with the "head" element it their front. > > The execution would look like this: > 1. The recurrsion would get to the tail of the list and calculate its > inits, [[]]. > 2. Then the recursion would go back, add the (n-th) element at the > front of all the previously calculated inits [[x_n]], and add the empty > list, we get [[],[x_n]]. > 3. The same applies for the element n-1 and we get, [x, [x_(n-1)], > [x_(n-1), n]] > ... > > I hope this helped :p > > JP > > > Tsunkiet Man wrote: >> Hello, >> >> I can hardly imagine how the following code works: >> >> cinits :: [a] -> [[a]] >> cinits [] = [[]] >> cinits (x:xs) = [] : map (x:) (cinits xs) >> >> can someone give me a good explaination? >> >> (I understand it a bit, but it's really hard for me to figure out how a map >> in a map function works.) >> >> Thank you for your time, >> >> Tsunkiet >> >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe From nowgate at yahoo.com Thu Apr 16 16:13:31 2009 From: nowgate at yahoo.com (michael rice) Date: Thu Apr 16 16:00:11 2009 Subject: [Haskell-cafe] RE: [Announce] primes Message-ID: <753695.70840.qm@web31105.mail.mud.yahoo.com> Just curious, what kind of super-cooled processor is this guy running on? I got the same answer but it took almost three minutes (2:43:15). Michael --- On Thu, 4/16/09, Geoffrey Irving wrote: From: Geoffrey Irving Subject: Re: [Haskell-cafe] RE: [Announce] primes To: "Daniel Fischer" Cc: haskell-cafe@haskell.org Date: Thursday, April 16, 2009, 12:57 PM >> > The implementation is reasonably efficient. The query >> > >> > ?> primes !! 1000000 >> > >> > 15485867 >> > >> > answers after a few seconds. >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090416/b2fe1cbb/attachment.htm From nicolas.pouillard at gmail.com Thu Apr 16 16:32:16 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Thu Apr 16 16:19:50 2009 Subject: [Haskell-cafe] Re: Best text editor In-Reply-To: <711894390904142000qafc26fi1cf7941534605d3a@mail.gmail.com> References: <23018470.post@talk.nabble.com> <20090414113406.6b47c241@solaris> <1239749828.9656.4.camel@ulysses> <711894390904142000qafc26fi1cf7941534605d3a@mail.gmail.com> Message-ID: <1239913761-sup-4605@ausone> Excerpts from Toby Hutton's message of Wed Apr 15 05:00:16 +0200 2009: > On Wed, Apr 15, 2009 at 8:57 AM, Jeff Wheeler wrote: > > > > As one of the Yi developers, I'd love to hear some more specific > > feedback on this. Do you remember any specific Vim features that were > > missing? > > My main gripe with the vi emulation in Yi was in vty mode[1] and how > it was unable to tell that 'esc' wasn't always 'meta-'. e.g., If I > leave insert mode with esc and hit j to go down a line too quickly it > interpreted it as meta-j. Quite annoying. This was a little while > ago though. I think this one is fixed, at least I cannot reproduce it. > Also, I remember the cursor would go beyond the last character in a > line in command mode, which is very un-vi-ish. At the time I remember > thinking I should try and fix these things myself... but.. umm... This one have been fixed too. > [1] vty Yi is the only one I would use--coding must always live inside > a screen session :) I really dislike wrapping a GUI around vi(m). I > don't want toolbars, tabs, scrollbars nor menus. I don't even want a > titlebar. Absolute full screen terminal running screen is perfect. :) +1 -- Nicolas Pouillard From jake.mcarthur at gmail.com Thu Apr 16 16:36:50 2009 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Thu Apr 16 16:23:29 2009 Subject: [Haskell-cafe] RE: [Announce] primes In-Reply-To: <753695.70840.qm@web31105.mail.mud.yahoo.com> References: <753695.70840.qm@web31105.mail.mud.yahoo.com> Message-ID: <49E796E2.6080405@gmail.com> michael rice wrote: > Just curious, what kind of super-cooled processor is this guy running > on? I got the same answer but it took almost three minutes (2:43:15). Only took a few seconds on my machine (Core 2 Duo 2.53GHz). - Jake From andrewcoppin at btinternet.com Thu Apr 16 16:38:51 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Apr 16 16:25:12 2009 Subject: [Haskell-cafe] RE: [Announce] primes In-Reply-To: <49E796E2.6080405@gmail.com> References: <753695.70840.qm@web31105.mail.mud.yahoo.com> <49E796E2.6080405@gmail.com> Message-ID: <49E7975B.6070104@btinternet.com> Jake McArthur wrote: > michael rice wrote: >> Just curious, what kind of super-cooled processor is this guy running >> on? I got the same answer but it took almost three minutes (2:43:15). > > Only took a few seconds on my machine (Core 2 Duo 2.53GHz). Maybe it's the version of GHC that matters? From leimy2k at gmail.com Thu Apr 16 16:40:18 2009 From: leimy2k at gmail.com (David Leimbach) Date: Thu Apr 16 16:26:43 2009 Subject: [Haskell-cafe] Re: Best text editor In-Reply-To: <1239913761-sup-4605@ausone> References: <23018470.post@talk.nabble.com> <20090414113406.6b47c241@solaris> <1239749828.9656.4.camel@ulysses> <711894390904142000qafc26fi1cf7941534605d3a@mail.gmail.com> <1239913761-sup-4605@ausone> Message-ID: <3e1162e60904161340p2e42a7d8q5fdb1fe9ca8dd5d2@mail.gmail.com> On Thu, Apr 16, 2009 at 1:32 PM, Nicolas Pouillard < nicolas.pouillard@gmail.com> wrote: > Excerpts from Toby Hutton's message of Wed Apr 15 05:00:16 +0200 2009: > > On Wed, Apr 15, 2009 at 8:57 AM, Jeff Wheeler wrote: > > > > > > As one of the Yi developers, I'd love to hear some more specific > > > feedback on this. Do you remember any specific Vim features that were > > > missing? > > > > My main gripe with the vi emulation in Yi was in vty mode[1] and how > > it was unable to tell that 'esc' wasn't always 'meta-'. e.g., If I > > leave insert mode with esc and hit j to go down a line too quickly it > > interpreted it as meta-j. Quite annoying. This was a little while > > ago though. > > I think this one is fixed, at least I cannot reproduce it. > > > Also, I remember the cursor would go beyond the last character in a > > line in command mode, which is very un-vi-ish. At the time I remember > > thinking I should try and fix these things myself... but.. umm... > > This one have been fixed too. > > > [1] vty Yi is the only one I would use--coding must always live inside > > a screen session :) I really dislike wrapping a GUI around vi(m). I > > don't want toolbars, tabs, scrollbars nor menus. I don't even want a > > titlebar. Absolute full screen terminal running screen is perfect. :) > > +1 Can/Does yi integrate ghci somehow? That'd be most outstanding, but I've not seen it done. I use yi sometimes for SVN commits :-) Dave > > > -- > Nicolas Pouillard > _______________________________________________ > 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/20090416/a7ca02bd/attachment.htm From lemming at henning-thielemann.de Thu Apr 16 17:38:53 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Apr 16 17:25:40 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> Message-ID: On Tue, 14 Apr 2009, rodrigo.bonifacio wrote: > I guess this is a very simple question. How can I convert IO [XmlTree] to just a list of > XmlTree? The old Wiki had: http://www.haskell.org/wikisnapshot/ThatAnnoyingIoType.html Should be ported to the new Wiki since it is a FAQ ... From temp.tsun at gmail.com Thu Apr 16 17:53:33 2009 From: temp.tsun at gmail.com (Tsunkiet Man) Date: Thu Apr 16 17:39:59 2009 Subject: [Haskell-cafe] wxHaskell not in scope Message-ID: Hello, I'm trying to create a GUI by using wxHaskell. However I get the weird error message of "Not in scope "dt"", well so I sorted them so that my so called "dt" was in scope, however it failed. Can someone please tell me how I can solve this error? ... A lot of code that is not relevant in my opinion, if I'm wrong please correct me and I will post my full code --Debug text -- dt <- staticText f [text := "Hello world!"] imagePanel <- panel f [position := Point 2 2, clientSize := Size 100 100, tooltip := "This is a drawPanel", bgcolor := rgb 255 255 255] set f [ clientSize := Size 700 500, menuBar := [mFile, mHelp], visible := True, on (menu exit) := close f, on (menu open) := onOpen f vFile ] return () where onOpen :: Frame a -> Var b -> IO () onOpen frame var = do file <- fileOpenDialog frame False True "Open File" [("PGM bestanden (*.pgm)",["*.pgm"]),("Alle bestanden (*.*)",["*.*"])] "" "" case file of Nothing -> return () Just file -> set dt [text := "HELLO"] return () Thank you for your help, I really owe haskell-cafe. Greetings Tsunkiet Man -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090416/82708a4a/attachment.htm From lennart at augustsson.net Thu Apr 16 18:11:17 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Thu Apr 16 17:57:41 2009 Subject: [Haskell-cafe] wxHaskell not in scope In-Reply-To: References: Message-ID: Variables bound in the do block are not in scope in the where. Use a let inside the do for onOpen instead. On Thu, Apr 16, 2009 at 11:53 PM, Tsunkiet Man wrote: > Hello, > > I'm trying to create a GUI by using wxHaskell. However I get the weird error > message of "Not in scope "dt"", well so I sorted them so that my so called > "dt" was in scope, however it failed. Can someone please tell me how I can > solve this error? > > ?????????? ... A lot of code that is not relevant in my opinion, if I'm > wrong please correct me and I will post my full code > > ??????????? --Debug text -- > ??????????? dt <- staticText f [text := "Hello world!"] > > ??????????? imagePanel <- panel f [position := Point 2 2, clientSize := Size > 100 100, tooltip := "This is a drawPanel", bgcolor := rgb 255 255 255] > ??????????? set f [ clientSize := Size 700 500, > ??????????????????? menuBar := [mFile, mHelp], > ??????????????????? visible := True, > ??????????????????? on (menu exit) := close f, > ??????????????????? on (menu open) := onOpen f vFile ] > > > ??????????? return () > > ??????????? where > ??????????????? onOpen :: Frame a -> Var b -> IO () > ??????????????? onOpen frame var = do?? file <- fileOpenDialog frame False > True "Open File" [("PGM bestanden (*.pgm)",["*.pgm"]),("Alle bestanden > (*.*)",["*.*"])] "" "" > ??????????????????????????????????????? case file of > ??????????????????????????????????????????? Nothing ->????? return () > ??????????????????????????????????????????? Just file ->??? set dt [text := > "HELLO"] > ??????????????????????????????????????????????????????????? return () > > Thank you for your help, I really owe haskell-cafe. > > Greetings Tsunkiet Man > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From jake.mcarthur at gmail.com Thu Apr 16 18:36:56 2009 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Thu Apr 16 18:23:21 2009 Subject: [Haskell-cafe] RE: [Announce] primes In-Reply-To: <49E7975B.6070104@btinternet.com> References: <753695.70840.qm@web31105.mail.mud.yahoo.com> <49E796E2.6080405@gmail.com> <49E7975B.6070104@btinternet.com> Message-ID: <49E7B308.8060303@gmail.com> Andrew Coppin wrote: > Jake McArthur wrote: >> michael rice wrote: >>> Just curious, what kind of super-cooled processor is this guy running >>> on? I got the same answer but it took almost three minutes (2:43:15). >> >> Only took a few seconds on my machine (Core 2 Duo 2.53GHz). > > Maybe it's the version of GHC that matters? 6.10.1 here. From temp.tsun at gmail.com Thu Apr 16 18:43:18 2009 From: temp.tsun at gmail.com (Tsunkiet Man) Date: Thu Apr 16 18:29:41 2009 Subject: [Haskell-cafe] wxHaskell not in scope In-Reply-To: References: Message-ID: Thank you for your response, however if I can't do that, why can the example of wxHaskell do that? I refer to the following code inside http://darcs.haskell.org/wxhaskell/samples/wx/ (ImageViewer.hs) Line 99 untill 110 openImage sw vbitmap mclose status fname = do -- load the new bitmap bm <- bitmapCreateFromFile fname -- can fail with exception closeImage vbitmap set vbitmap [value := Just bm] set mclose [enabled := True] set status [text := fname] -- reset the scrollbars bmsize <- get bm size set sw [virtualSize := bmsize] repaint sw `catch` \err -> repaint sw if I'm correct the openImage is also defined in the where clause. Therefor by what I think it should not be possible, but it is. Thanks for everything. 2009/4/17 Lennart Augustsson > Variables bound in the do block are not in scope in the where. > Use a let inside the do for onOpen instead. > > On Thu, Apr 16, 2009 at 11:53 PM, Tsunkiet Man > wrote: > > Hello, > > > > I'm trying to create a GUI by using wxHaskell. However I get the weird > error > > message of "Not in scope "dt"", well so I sorted them so that my so > called > > "dt" was in scope, however it failed. Can someone please tell me how I > can > > solve this error? > > > > ... A lot of code that is not relevant in my opinion, if I'm > > wrong please correct me and I will post my full code > > > > --Debug text -- > > dt <- staticText f [text := "Hello world!"] > > > > imagePanel <- panel f [position := Point 2 2, clientSize := > Size > > 100 100, tooltip := "This is a drawPanel", bgcolor := rgb 255 255 255] > > set f [ clientSize := Size 700 500, > > menuBar := [mFile, mHelp], > > visible := True, > > on (menu exit) := close f, > > on (menu open) := onOpen f vFile ] > > > > > > return () > > > > where > > onOpen :: Frame a -> Var b -> IO () > > onOpen frame var = do file <- fileOpenDialog frame > False > > True "Open File" [("PGM bestanden (*.pgm)",["*.pgm"]),("Alle bestanden > > (*.*)",["*.*"])] "" "" > > case file of > > Nothing -> return () > > Just file -> set dt [text > := > > "HELLO"] > > return () > > > > Thank you for your help, I really owe haskell-cafe. > > > > Greetings Tsunkiet Man > > _______________________________________________ > > 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/20090417/ef3455c8/attachment.htm From lennart at augustsson.net Thu Apr 16 18:54:04 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Thu Apr 16 18:40:28 2009 Subject: [Haskell-cafe] wxHaskell not in scope In-Reply-To: References: Message-ID: The names defined in the where clause are in scope in the do block, but not vice versa. On Fri, Apr 17, 2009 at 12:43 AM, Tsunkiet Man wrote: > Thank you for your response, however if I can't do that, why can the example > of wxHaskell do that? > > I refer to the following code inside > http://darcs.haskell.org/wxhaskell/samples/wx/?(ImageViewer.hs) > > Line 99 untill 110 > > ??? openImage sw vbitmap mclose status fname > ????? = do -- load the new bitmap > ?????????? bm <- bitmapCreateFromFile fname? -- can fail with exception > ?????????? closeImage vbitmap > ?????????? set vbitmap [value := Just bm] > ?????????? set mclose [enabled := True] > ?????????? set status [text := fname] > ?????????? -- reset the scrollbars > ?????????? bmsize <- get bm size > ?????????? set sw [virtualSize := bmsize] > ?????????? repaint sw > ?????? `catch` \err -> repaint sw > > if I'm correct the openImage is also defined in the where clause. Therefor > by what I think it should not be possible, but it is. > > Thanks for everything. > > > > > 2009/4/17 Lennart Augustsson >> >> Variables bound in the do block are not in scope in the where. >> Use a let inside the do for onOpen instead. >> >> On Thu, Apr 16, 2009 at 11:53 PM, Tsunkiet Man >> wrote: >> > Hello, >> > >> > I'm trying to create a GUI by using wxHaskell. However I get the weird >> > error >> > message of "Not in scope "dt"", well so I sorted them so that my so >> > called >> > "dt" was in scope, however it failed. Can someone please tell me how I >> > can >> > solve this error? >> > >> > ?????????? ... A lot of code that is not relevant in my opinion, if I'm >> > wrong please correct me and I will post my full code >> > >> > ??????????? --Debug text -- >> > ??????????? dt <- staticText f [text := "Hello world!"] >> > >> > ??????????? imagePanel <- panel f [position := Point 2 2, clientSize := >> > Size >> > 100 100, tooltip := "This is a drawPanel", bgcolor := rgb 255 255 255] >> > ??????????? set f [ clientSize := Size 700 500, >> > ??????????????????? menuBar := [mFile, mHelp], >> > ??????????????????? visible := True, >> > ??????????????????? on (menu exit) := close f, >> > ??????????????????? on (menu open) := onOpen f vFile ] >> > >> > >> > ??????????? return () >> > >> > ??????????? where >> > ??????????????? onOpen :: Frame a -> Var b -> IO () >> > ??????????????? onOpen frame var = do?? file <- fileOpenDialog frame >> > False >> > True "Open File" [("PGM bestanden (*.pgm)",["*.pgm"]),("Alle bestanden >> > (*.*)",["*.*"])] "" "" >> > ??????????????????????????????????????? case file of >> > ??????????????????????????????????????????? Nothing ->????? return () >> > ??????????????????????????????????????????? Just file ->??? set dt [text >> > := >> > "HELLO"] >> > ??????????????????????????????????????????????????????????? return () >> > >> > Thank you for your help, I really owe haskell-cafe. >> > >> > Greetings Tsunkiet Man >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > Haskell-Cafe@haskell.org >> > http://www.haskell.org/mailman/listinfo/haskell-cafe >> > >> > > > From temp.tsun at gmail.com Thu Apr 16 18:54:39 2009 From: temp.tsun at gmail.com (Tsunkiet Man) Date: Thu Apr 16 18:41:04 2009 Subject: [Haskell-cafe] Re: wxHaskell not in scope (Source available) Message-ID: Note: the source can be found here: http://www.students.cs.uu.nl/~jtkman/Application.hs (It's my own work, please tell me what I did wrong) 2009/4/16 Tsunkiet Man > Hello, > > I'm trying to create a GUI by using wxHaskell. However I get the weird > error message of "Not in scope "dt"", well so I sorted them so that my so > called "dt" was in scope, however it failed. Can someone please tell me how > I can solve this error? > > ... A lot of code that is not relevant in my opinion, if I'm > wrong please correct me and I will post my full code > > --Debug text -- > dt <- staticText f [text := "Hello world!"] > > imagePanel <- panel f [position := Point 2 2, clientSize := > Size 100 100, tooltip := "This is a drawPanel", bgcolor := rgb 255 255 255] > set f [ clientSize := Size 700 500, > menuBar := [mFile, mHelp], > visible := True, > on (menu exit) := close f, > on (menu open) := onOpen f vFile ] > > > return () > > where > onOpen :: Frame a -> Var b -> IO () > onOpen frame var = do file <- fileOpenDialog frame False > True "Open File" [("PGM bestanden (*.pgm)",["*.pgm"]),("Alle bestanden > (*.*)",["*.*"])] "" "" > case file of > Nothing -> return () > Just file -> set dt [text := > "HELLO"] > return () > > Thank you for your help, I really owe haskell-cafe. > > Greetings Tsunkiet Man > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090417/6b7f135b/attachment.htm From temp.tsun at gmail.com Thu Apr 16 18:57:02 2009 From: temp.tsun at gmail.com (Tsunkiet Man) Date: Thu Apr 16 18:43:26 2009 Subject: [Haskell-cafe] wxHaskell not in scope In-Reply-To: References: Message-ID: PS: a small note, sorry for multiple mails. After doing the let ... in function it did not work. =( It gave the error that 'do' has to end with some result. I did: do let in and it still didn't work =(. I'm doing something wrong I think. Thanks for your help. 2009/4/17 Tsunkiet Man > Thank you for your response, however if I can't do that, why can the > example of wxHaskell do that? > > I refer to the following code inside > http://darcs.haskell.org/wxhaskell/samples/wx/ (ImageViewer.hs) > > Line 99 untill 110 > > openImage sw vbitmap mclose status fname > = do -- load the new bitmap > bm <- bitmapCreateFromFile fname -- can fail with exception > closeImage vbitmap > set vbitmap [value := Just bm] > set mclose [enabled := True] > set status [text := fname] > -- reset the scrollbars > bmsize <- get bm size > set sw [virtualSize := bmsize] > repaint sw > `catch` \err -> repaint sw > > if I'm correct the openImage is also defined in the where clause. Therefor > by what I think it should not be possible, but it is. > > Thanks for everything. > > > > > > 2009/4/17 Lennart Augustsson > > Variables bound in the do block are not in scope in the where. >> Use a let inside the do for onOpen instead. >> >> On Thu, Apr 16, 2009 at 11:53 PM, Tsunkiet Man >> wrote: >> > Hello, >> > >> > I'm trying to create a GUI by using wxHaskell. However I get the weird >> error >> > message of "Not in scope "dt"", well so I sorted them so that my so >> called >> > "dt" was in scope, however it failed. Can someone please tell me how I >> can >> > solve this error? >> > >> > ... A lot of code that is not relevant in my opinion, if I'm >> > wrong please correct me and I will post my full code >> > >> > --Debug text -- >> > dt <- staticText f [text := "Hello world!"] >> > >> > imagePanel <- panel f [position := Point 2 2, clientSize := >> Size >> > 100 100, tooltip := "This is a drawPanel", bgcolor := rgb 255 255 255] >> > set f [ clientSize := Size 700 500, >> > menuBar := [mFile, mHelp], >> > visible := True, >> > on (menu exit) := close f, >> > on (menu open) := onOpen f vFile ] >> > >> > >> > return () >> > >> > where >> > onOpen :: Frame a -> Var b -> IO () >> > onOpen frame var = do file <- fileOpenDialog frame >> False >> > True "Open File" [("PGM bestanden (*.pgm)",["*.pgm"]),("Alle bestanden >> > (*.*)",["*.*"])] "" "" >> > case file of >> > Nothing -> return () >> > Just file -> set dt [text >> := >> > "HELLO"] >> > return () >> > >> > Thank you for your help, I really owe haskell-cafe. >> > >> > Greetings Tsunkiet Man >> > _______________________________________________ >> > 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/20090417/90cefcfd/attachment-0001.htm From daniel.is.fischer at web.de Thu Apr 16 18:58:57 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Apr 16 18:45:37 2009 Subject: [Haskell-cafe] wxHaskell not in scope In-Reply-To: References: Message-ID: <200904170058.58237.daniel.is.fischer@web.de> Am Freitag 17 April 2009 00:43:18 schrieb Tsunkiet Man: > Thank you for your response, however if I can't do that, why can the > example of wxHaskell do that? > > I refer to the following code inside > http://darcs.haskell.org/wxhaskell/samples/wx/ (ImageViewer.hs) > > Line 99 untill 110 > > openImage sw vbitmap mclose status fname > = do -- load the new bitmap > bm <- bitmapCreateFromFile fname -- can fail with exception > closeImage vbitmap > set vbitmap [value := Just bm] > set mclose [enabled := True] > set status [text := fname] > -- reset the scrollbars > bmsize <- get bm size > set sw [virtualSize := bmsize] > repaint sw > `catch` \err -> repaint sw > > if I'm correct the openImage is also defined in the where clause. Therefor > by what I think it should not be possible, but it is. > > Thanks for everything. In your code, the variable dt was bound in the do-block, and you tried to reference it in the definition of onOpen in the where clause, where it is not in scope. The definition of openImage in ImageViewer.hs does not reference any variables bound in the do-block of imageViewer, only its parameters and the bitmap bm bound in its own body. As an alternative to defining onOpen in your main do-block, you could also pass the debug- text dt as a parameter. From lennart at augustsson.net Thu Apr 16 19:05:39 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Thu Apr 16 18:52:03 2009 Subject: [Haskell-cafe] wxHaskell not in scope In-Reply-To: References: Message-ID: Take a look at the syntax for 'let' inside a 'do'. On Fri, Apr 17, 2009 at 12:57 AM, Tsunkiet Man wrote: > PS: a small note, sorry for multiple mails. > > After doing the let ... in function it did not work. =( It gave the error > that 'do' has to end with some result. I did: > > do let in > > and it still didn't work =(. I'm doing something wrong I think. > > Thanks for your help. > > 2009/4/17 Tsunkiet Man >> >> Thank you for your response, however if I can't do that, why can the >> example of wxHaskell do that? >> >> I refer to the following code inside >> http://darcs.haskell.org/wxhaskell/samples/wx/?(ImageViewer.hs) >> >> Line 99 untill 110 >> >> ??? openImage sw vbitmap mclose status fname >> ????? = do -- load the new bitmap >> ?????????? bm <- bitmapCreateFromFile fname? -- can fail with exception >> ?????????? closeImage vbitmap >> ?????????? set vbitmap [value := Just bm] >> ?????????? set mclose [enabled := True] >> ?????????? set status [text := fname] >> ?????????? -- reset the scrollbars >> ?????????? bmsize <- get bm size >> ?????????? set sw [virtualSize := bmsize] >> ?????????? repaint sw >> ?????? `catch` \err -> repaint sw >> >> if I'm correct the openImage is also defined in the where clause. Therefor >> by what I think it should not be possible, but it is. >> >> Thanks for everything. >> >> >> >> >> 2009/4/17 Lennart Augustsson >>> >>> Variables bound in the do block are not in scope in the where. >>> Use a let inside the do for onOpen instead. >>> >>> On Thu, Apr 16, 2009 at 11:53 PM, Tsunkiet Man >>> wrote: >>> > Hello, >>> > >>> > I'm trying to create a GUI by using wxHaskell. However I get the weird >>> > error >>> > message of "Not in scope "dt"", well so I sorted them so that my so >>> > called >>> > "dt" was in scope, however it failed. Can someone please tell me how I >>> > can >>> > solve this error? >>> > >>> > ?????????? ... A lot of code that is not relevant in my opinion, if I'm >>> > wrong please correct me and I will post my full code >>> > >>> > ??????????? --Debug text -- >>> > ??????????? dt <- staticText f [text := "Hello world!"] >>> > >>> > ??????????? imagePanel <- panel f [position := Point 2 2, clientSize := >>> > Size >>> > 100 100, tooltip := "This is a drawPanel", bgcolor := rgb 255 255 255] >>> > ??????????? set f [ clientSize := Size 700 500, >>> > ??????????????????? menuBar := [mFile, mHelp], >>> > ??????????????????? visible := True, >>> > ??????????????????? on (menu exit) := close f, >>> > ??????????????????? on (menu open) := onOpen f vFile ] >>> > >>> > >>> > ??????????? return () >>> > >>> > ??????????? where >>> > ??????????????? onOpen :: Frame a -> Var b -> IO () >>> > ??????????????? onOpen frame var = do?? file <- fileOpenDialog frame >>> > False >>> > True "Open File" [("PGM bestanden (*.pgm)",["*.pgm"]),("Alle bestanden >>> > (*.*)",["*.*"])] "" "" >>> > ??????????????????????????????????????? case file of >>> > ??????????????????????????????????????????? Nothing ->????? return () >>> > ??????????????????????????????????????????? Just file ->??? set dt >>> > [text := >>> > "HELLO"] >>> > ??????????????????????????????????????????????????????????? return () >>> > >>> > Thank you for your help, I really owe haskell-cafe. >>> > >>> > Greetings Tsunkiet Man >>> > _______________________________________________ >>> > Haskell-Cafe mailing list >>> > Haskell-Cafe@haskell.org >>> > http://www.haskell.org/mailman/listinfo/haskell-cafe >>> > >>> > >> > > From temp.tsun at gmail.com Thu Apr 16 19:37:25 2009 From: temp.tsun at gmail.com (Tsunkiet Man) Date: Thu Apr 16 19:23:50 2009 Subject: [Haskell-cafe] wxHaskell not in scope In-Reply-To: References: Message-ID: Hello, what you suggested worked! Im very happy with it. However another error suddenly came up. It sais the last statement in a 'do' must be an expression, he is refering to line 41:45 I change my code to this: on (menu exit) := close f, on (menu open) := onOpen f dt vFile ] return () where onOpen :: Frame a -> staticText c -> Var b -> IO () onOpen frame stat var = do file <- fileOpenDialog frame False True "Open File" [("PGM bestanden (*.pgm)",["*.pgm"]),("Alle bestanden (*.*)",["*.*"])] "" "" case file of Nothing -> return () Just file -> set stat [text := "HELLO"] return () As far as I can tell, if the file is nothing it will return something of IO () and if the file is something it will return something of IO (). So that error is kind of strange in my opinion. Do you know what caused it? Thanks for your help! 2009/4/17 Lennart Augustsson > Take a look at the syntax for 'let' inside a 'do'. > > On Fri, Apr 17, 2009 at 12:57 AM, Tsunkiet Man > wrote: > > PS: a small note, sorry for multiple mails. > > > > After doing the let ... in function it did not work. =( It gave the error > > that 'do' has to end with some result. I did: > > > > do let in > > > > and it still didn't work =(. I'm doing something wrong I think. > > > > Thanks for your help. > > > > 2009/4/17 Tsunkiet Man > >> > >> Thank you for your response, however if I can't do that, why can the > >> example of wxHaskell do that? > >> > >> I refer to the following code inside > >> http://darcs.haskell.org/wxhaskell/samples/wx/ (ImageViewer.hs) > >> > >> Line 99 untill 110 > >> > >> openImage sw vbitmap mclose status fname > >> = do -- load the new bitmap > >> bm <- bitmapCreateFromFile fname -- can fail with exception > >> closeImage vbitmap > >> set vbitmap [value := Just bm] > >> set mclose [enabled := True] > >> set status [text := fname] > >> -- reset the scrollbars > >> bmsize <- get bm size > >> set sw [virtualSize := bmsize] > >> repaint sw > >> `catch` \err -> repaint sw > >> > >> if I'm correct the openImage is also defined in the where clause. > Therefor > >> by what I think it should not be possible, but it is. > >> > >> Thanks for everything. > >> > >> > >> > >> > >> 2009/4/17 Lennart Augustsson > >>> > >>> Variables bound in the do block are not in scope in the where. > >>> Use a let inside the do for onOpen instead. > >>> > >>> On Thu, Apr 16, 2009 at 11:53 PM, Tsunkiet Man > >>> wrote: > >>> > Hello, > >>> > > >>> > I'm trying to create a GUI by using wxHaskell. However I get the > weird > >>> > error > >>> > message of "Not in scope "dt"", well so I sorted them so that my so > >>> > called > >>> > "dt" was in scope, however it failed. Can someone please tell me how > I > >>> > can > >>> > solve this error? > >>> > > >>> > ... A lot of code that is not relevant in my opinion, if > I'm > >>> > wrong please correct me and I will post my full code > >>> > > >>> > --Debug text -- > >>> > dt <- staticText f [text := "Hello world!"] > >>> > > >>> > imagePanel <- panel f [position := Point 2 2, clientSize > := > >>> > Size > >>> > 100 100, tooltip := "This is a drawPanel", bgcolor := rgb 255 255 > 255] > >>> > set f [ clientSize := Size 700 500, > >>> > menuBar := [mFile, mHelp], > >>> > visible := True, > >>> > on (menu exit) := close f, > >>> > on (menu open) := onOpen f vFile ] > >>> > > >>> > > >>> > return () > >>> > > >>> > where > >>> > onOpen :: Frame a -> Var b -> IO () > >>> > onOpen frame var = do file <- fileOpenDialog frame > >>> > False > >>> > True "Open File" [("PGM bestanden (*.pgm)",["*.pgm"]),("Alle > bestanden > >>> > (*.*)",["*.*"])] "" "" > >>> > case file of > >>> > Nothing -> return () > >>> > Just file -> set dt > >>> > [text := > >>> > "HELLO"] > >>> > return () > >>> > > >>> > Thank you for your help, I really owe haskell-cafe. > >>> > > >>> > Greetings Tsunkiet Man > >>> > _______________________________________________ > >>> > 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/20090417/793e9972/attachment.htm From temp.tsun at gmail.com Thu Apr 16 19:38:05 2009 From: temp.tsun at gmail.com (Tsunkiet Man) Date: Thu Apr 16 19:24:29 2009 Subject: [Haskell-cafe] wxHaskell not in scope In-Reply-To: References: Message-ID: PS: if the indents are wrong, that's because of gmail copy and past, Im so sorry. 2009/4/17 Tsunkiet Man > Hello, > > what you suggested worked! Im very happy with it. However another error > suddenly came up. It sais the last statement in a 'do' must be an > expression, he is refering to line 41:45 > > I change my code to this: > > on (menu exit) := close f, > on (menu open) := onOpen f dt vFile ] > > return () > > where > onOpen :: Frame a -> staticText c -> Var b -> IO () > onOpen frame stat var = do file <- fileOpenDialog frame > False True "Open File" [("PGM bestanden (*.pgm)",["*.pgm"]),("Alle bestanden > (*.*)",["*.*"])] "" "" > case file of > Nothing -> return () > Just file -> set stat [text > := "HELLO"] > return () > > As far as I can tell, if the file is nothing it will return something of IO > () and if the file is something it will return something of IO (). So that > error is kind of strange in my opinion. Do you know what caused it? > > Thanks for your help! > > 2009/4/17 Lennart Augustsson > >> Take a look at the syntax for 'let' inside a 'do'. >> >> On Fri, Apr 17, 2009 at 12:57 AM, Tsunkiet Man >> wrote: >> > PS: a small note, sorry for multiple mails. >> > >> > After doing the let ... in function it did not work. =( It gave the >> error >> > that 'do' has to end with some result. I did: >> > >> > do let in >> > >> > and it still didn't work =(. I'm doing something wrong I think. >> > >> > Thanks for your help. >> > >> > 2009/4/17 Tsunkiet Man >> >> >> >> Thank you for your response, however if I can't do that, why can the >> >> example of wxHaskell do that? >> >> >> >> I refer to the following code inside >> >> http://darcs.haskell.org/wxhaskell/samples/wx/ (ImageViewer.hs) >> >> >> >> Line 99 untill 110 >> >> >> >> openImage sw vbitmap mclose status fname >> >> = do -- load the new bitmap >> >> bm <- bitmapCreateFromFile fname -- can fail with exception >> >> closeImage vbitmap >> >> set vbitmap [value := Just bm] >> >> set mclose [enabled := True] >> >> set status [text := fname] >> >> -- reset the scrollbars >> >> bmsize <- get bm size >> >> set sw [virtualSize := bmsize] >> >> repaint sw >> >> `catch` \err -> repaint sw >> >> >> >> if I'm correct the openImage is also defined in the where clause. >> Therefor >> >> by what I think it should not be possible, but it is. >> >> >> >> Thanks for everything. >> >> >> >> >> >> >> >> >> >> 2009/4/17 Lennart Augustsson >> >>> >> >>> Variables bound in the do block are not in scope in the where. >> >>> Use a let inside the do for onOpen instead. >> >>> >> >>> On Thu, Apr 16, 2009 at 11:53 PM, Tsunkiet Man >> >>> wrote: >> >>> > Hello, >> >>> > >> >>> > I'm trying to create a GUI by using wxHaskell. However I get the >> weird >> >>> > error >> >>> > message of "Not in scope "dt"", well so I sorted them so that my so >> >>> > called >> >>> > "dt" was in scope, however it failed. Can someone please tell me how >> I >> >>> > can >> >>> > solve this error? >> >>> > >> >>> > ... A lot of code that is not relevant in my opinion, if >> I'm >> >>> > wrong please correct me and I will post my full code >> >>> > >> >>> > --Debug text -- >> >>> > dt <- staticText f [text := "Hello world!"] >> >>> > >> >>> > imagePanel <- panel f [position := Point 2 2, clientSize >> := >> >>> > Size >> >>> > 100 100, tooltip := "This is a drawPanel", bgcolor := rgb 255 255 >> 255] >> >>> > set f [ clientSize := Size 700 500, >> >>> > menuBar := [mFile, mHelp], >> >>> > visible := True, >> >>> > on (menu exit) := close f, >> >>> > on (menu open) := onOpen f vFile ] >> >>> > >> >>> > >> >>> > return () >> >>> > >> >>> > where >> >>> > onOpen :: Frame a -> Var b -> IO () >> >>> > onOpen frame var = do file <- fileOpenDialog frame >> >>> > False >> >>> > True "Open File" [("PGM bestanden (*.pgm)",["*.pgm"]),("Alle >> bestanden >> >>> > (*.*)",["*.*"])] "" "" >> >>> > case file of >> >>> > Nothing -> return >> () >> >>> > Just file -> set dt >> >>> > [text := >> >>> > "HELLO"] >> >>> > return >> () >> >>> > >> >>> > Thank you for your help, I really owe haskell-cafe. >> >>> > >> >>> > Greetings Tsunkiet Man >> >>> > _______________________________________________ >> >>> > 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/20090417/6fd74ba9/attachment.htm From nowgate at yahoo.com Thu Apr 16 20:02:53 2009 From: nowgate at yahoo.com (michael rice) Date: Thu Apr 16 19:49:17 2009 Subject: [Haskell-cafe] RE: [Announce] primes Message-ID: <539969.32840.qm@web31106.mail.mud.yahoo.com> Oh, I just remembered, I'm using ghci. I'll bet that's why I'm so slow. Thanks. Michael --- On Thu, 4/16/09, Andrew Coppin wrote: From: Andrew Coppin Subject: Re: [Haskell-cafe] RE: [Announce] primes To: haskell-cafe@haskell.org Date: Thursday, April 16, 2009, 4:38 PM Jake McArthur wrote: > michael rice wrote: >> Just curious, what kind of super-cooled processor is this guy running on? I got the same answer but it took almost three minutes (2:43:15). > > Only took a few seconds on my machine (Core 2 Duo 2.53GHz). Maybe it's the version of GHC that matters? _______________________________________________ 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/20090416/41ea8f8e/attachment.htm From moonpatio at gmail.com Thu Apr 16 20:04:43 2009 From: moonpatio at gmail.com (Matt Morrow) Date: Thu Apr 16 19:51:07 2009 Subject: [Haskell-cafe] "O LANGUAGE DESIGNER, REMEMBER THE POOR USER"" Message-ID: <1bc51a990904161704ic0e7252tf8728ba447f1f6ea@mail.gmail.com> This is interesting (and from 1990): http://groups.google.co.uk/group/comp.lang.functional/msg/655bb7bbd0fd8586 (Not sure if this is well-known. It seems like it either is, or it should be. Either way, I just stumbled across it.) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090416/5b5aa5c5/attachment.htm From moonpatio at gmail.com Thu Apr 16 20:21:19 2009 From: moonpatio at gmail.com (Matt Morrow) Date: Thu Apr 16 20:07:43 2009 Subject: [Haskell-cafe] Re: "O LANGUAGE DESIGNER, REMEMBER THE POOR USER"" In-Reply-To: <1bc51a990904161704ic0e7252tf8728ba447f1f6ea@mail.gmail.com> References: <1bc51a990904161704ic0e7252tf8728ba447f1f6ea@mail.gmail.com> Message-ID: <1bc51a990904161721k34a05345xf65cb9c8a2ba5e38@mail.gmail.com> Here are some choice-quotes that are one of {insightful, controversial, arguable}: Starting with my favorite quote ;): "The ability to operate on the program as data is basic to the provision of many desirable utilities, e.g. the Boyer-Moore theorem prover, and the program transformation work that was based on Hope, not to mention a compiler. It seems unfortunate that recent functional languages are heteroousian in the sense that they are defined in the usual computer scientist's way of specifying a syntax, and not specifying a representation of a program as a data-structure. This is a manifestation of the besetting vice of computer scientists - they will insist in locking up goodies in a black box..." On Lisp: "There is a danger that this perspective will adversely affect the design of a language from the user's point of view. The most extreme case is that of LISP, which may be seen as a very flawed implementation of the Lambda Calculus, which preserves the notation rather closely." On Haskell syntax: "However, if the use of upper case is not permitted for ordinary variables a conflict arises between the language conventions and the conventions of mathematics,...." "Haskell is also in conflict with established programming conventions in that it it uses double colon to denote membership of a type (e.g. x::Int) rather than the single colon that those millions of existing programmers will be familiar with,.." On Haskell arrays: "The Haskell array operation is a related construct, from which a instances of the application of the POP-11 newarray could be implemented - it does however suffer from one practical draw-back, namely it takes an association list as argument, which makes it inefficient as a means of memoising a function, unless a very smart compiler is used." On purity: "I want a language that is not purely functional because functional languages do not reflect the basic structure of computers. If you want to write a matrix inversion algorithm it will be hard to do it efficiently without assignment." Matt On Thu, Apr 16, 2009 at 7:04 PM, Matt Morrow wrote: > This is interesting (and from 1990): > > http://groups.google.co.uk/group/comp.lang.functional/msg/655bb7bbd0fd8586 > > (Not sure if this is well-known. It seems like it either is, or it should > be. Either way, I just stumbled across it.) > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090416/d1ce9214/attachment.htm From ajb at spamcop.net Thu Apr 16 22:16:01 2009 From: ajb at spamcop.net (ajb@spamcop.net) Date: Thu Apr 16 22:02:45 2009 Subject: [Haskell-cafe] Looking for the fastest Haskell primes algorithm In-Reply-To: <5e0214850904140557i251935f8gf90402c65dfb470@mail.gmail.com> References: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> <5e0214850904140557i251935f8gf90402c65dfb470@mail.gmail.com> Message-ID: <20090416221601.hr9z3fbhckksckg8-nwo@webmail.spamcop.net> G'day all. Quoting Eugene Kirpichov : > I'd suggest also > > primesFrom :: Integer -> [Integer] This: primes :: [Integer] isn't as useful as you might think for a library, because it must, by definition, leak an uncontrolled amount of memory. This: primesUpTo :: Integer -> [Integer] is a better interface in that respect. For the number theory library, I went overboard with a bunch of type classes. I don't have the code handy, but this was the sort of thing: class TestableProperty s a | s -> a where is :: s -> a -> Bool data Prime = Prime class TestableProperty Prime Integer where is Prime n = {- ... -} Then you could add instances for Fibonacci or whatever you wanted. Cheers, Andrew Bromage From westondan at imageworks.com Thu Apr 16 22:42:36 2009 From: westondan at imageworks.com (Dan Weston) Date: Thu Apr 16 22:29:03 2009 Subject: [Haskell-cafe] Looking for the fastest Haskell primes algorithm In-Reply-To: <20090416221601.hr9z3fbhckksckg8-nwo@webmail.spamcop.net> References: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> <5e0214850904140557i251935f8gf90402c65dfb470@mail.gmail.com> <20090416221601.hr9z3fbhckksckg8-nwo@webmail.spamcop.net> Message-ID: <49E7EC9C.4070205@imageworks.com> Unless primesUpTo n goes from highest to lowest prime (ending in 2), I don't see how sharing is possible (in either space or time) between primesUpTo for different n. Is it intended that the primes should therefore be listed in descending order? ajb@spamcop.net wrote: > primes :: [Integer] > > isn't as useful as you might think for a library, because it must, by > definition, leak an uncontrolled amount of memory. This: > > primesUpTo :: Integer -> [Integer] > > is a better interface in that respect. From gwern0 at gmail.com Thu Apr 16 22:44:45 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Thu Apr 16 22:31:09 2009 Subject: [Haskell-cafe] Re: Best text editor In-Reply-To: <3e1162e60904161340p2e42a7d8q5fdb1fe9ca8dd5d2@mail.gmail.com> References: <23018470.post@talk.nabble.com> <20090414113406.6b47c241@solaris> <1239749828.9656.4.camel@ulysses> <711894390904142000qafc26fi1cf7941534605d3a@mail.gmail.com> <1239913761-sup-4605@ausone> <3e1162e60904161340p2e42a7d8q5fdb1fe9ca8dd5d2@mail.gmail.com> Message-ID: On Thu, Apr 16, 2009 at 4:40 PM, David Leimbach wrote: > > > On Thu, Apr 16, 2009 at 1:32 PM, Nicolas Pouillard > wrote: >> >> Excerpts from Toby Hutton's message of Wed Apr 15 05:00:16 +0200 2009: >> > On Wed, Apr 15, 2009 at 8:57 AM, Jeff Wheeler wrote: >> > > >> > > As one of the Yi developers, I'd love to hear some more specific >> > > feedback on this. Do you remember any specific Vim features that were >> > > missing? >> > >> > My main gripe with the vi emulation in Yi was in vty mode[1] and how >> > it was unable to tell that 'esc' wasn't always 'meta-'. ?e.g., If I >> > leave insert mode with esc and hit j to go down a line too quickly it >> > interpreted it as meta-j. ?Quite annoying. ?This was a little while >> > ago though. >> >> I think this one is fixed, at least I cannot reproduce it. >> >> > Also, I remember the cursor would go beyond the last character in a >> > line in command mode, which is very un-vi-ish. ?At the time I remember >> > thinking I should try and fix these things myself... but.. umm... >> >> This one have been fixed too. >> >> > [1] vty Yi is the only one I would use--coding must always live inside >> > a screen session :) ?I really dislike wrapping a GUI around vi(m). ?I >> > don't want toolbars, tabs, scrollbars nor menus. ?I don't even want a >> > titlebar. ?Absolute full screen terminal running screen is perfect. :) >> >> +1 > > Can/Does yi integrate ghci somehow? ?That'd be most outstanding, but I've > not seen it done. > I use yi sometimes for SVN commits :-) > Dave There is GHC API usage of sorts if you enable shim. But it doesn't do anything very impressive currently; the most impressive thing I've used it for in Yi is to insert the typesig of the top-level function at point. -- gwern From mpm at alumni.caltech.edu Thu Apr 16 23:29:58 2009 From: mpm at alumni.caltech.edu (Michael P Mossey) Date: Thu Apr 16 23:16:22 2009 Subject: [Haskell-cafe] Parsec question Message-ID: <49E7F7B6.7020506@alumni.caltech.edu> I want to write a parser that can read a file with this format: the file has sections which are demarcated by keywords. Keywords always begin with two forward slashes and consist of letters, digits, and underscore. The text can be anything, including special characters. For instance: //keyword some text and more text //another_keyword and) some { more text //ya_keyword $$ -- text I'm not sure how to write a parser that considers anything but a double slash to be a valid part of the text. Thanks, Mike From voigt at tcs.inf.tu-dresden.de Fri Apr 17 01:28:59 2009 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Fri Apr 17 01:15:22 2009 Subject: [Haskell-cafe] REMINDER: Haskell Communities and Activities Report Message-ID: <49E8139B.9030204@tcs.inf.tu-dresden.de> Dear Haskellers, The deadline for the May 2009 edition of the Haskell Communities and Activities Report is only two weeks away. If you haven't already, please write an entry for your new project, or update your old entry. Please mail your entries to hcar@haskell.org in LaTeX format. More information can be found in the original Call for Contributions at: http://www.haskell.org/pipermail/haskell/2009-April/021180.html I look forward to receiving your contributions. Thanks a lot, Janis (current editor) -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From noteed at gmail.com Fri Apr 17 02:42:20 2009 From: noteed at gmail.com (minh thu) Date: Fri Apr 17 02:28:48 2009 Subject: [Haskell-cafe] wxHaskell not in scope In-Reply-To: References: Message-ID: <40a414c20904162342j6dde0dd7gabfee0c8480531de@mail.gmail.com> Hi, you can use http://hpaste.org/ to overcome this problem. Cheers, Thu 2009/4/17 Tsunkiet Man : > PS: if the indents are wrong, that's because of gmail copy and past, Im so > sorry. > > 2009/4/17 Tsunkiet Man >> >> Hello, >> >> what you suggested worked! Im very happy with it. However another error >> suddenly came up. It sais the last statement in a 'do' must be an >> expression, he is refering to line 41:45 >> >> I change my code to this: >> >> on (menu exit) := close f, >> on (menu open) := onOpen f dt vFile ] >> >> return () >> >> where >> onOpen :: Frame a -> staticText c -> Var b -> IO () >> onOpen frame stat var = do file <- fileOpenDialog frame >> False True "Open File" [("PGM bestanden (*.pgm)",["*.pgm"]),("Alle bestanden >> (*.*)",["*.*"])] "" "" >> case file of >> Nothing -> return () >> Just file -> set stat [text >> := "HELLO"] >> return () >> >> As far as I can tell, if the file is nothing it will return something of >> IO () and if the file is something it will return something of IO (). So >> that error is kind of strange in my opinion. Do you know what caused it? >> >> Thanks for your help! >> >> 2009/4/17 Lennart Augustsson >>> >>> Take a look at the syntax for 'let' inside a 'do'. >>> >>> On Fri, Apr 17, 2009 at 12:57 AM, Tsunkiet Man >>> wrote: >>> > PS: a small note, sorry for multiple mails. >>> > >>> > After doing the let ... in function it did not work. =( It gave the >>> > error >>> > that 'do' has to end with some result. I did: >>> > >>> > do let in >>> > >>> > and it still didn't work =(. I'm doing something wrong I think. >>> > >>> > Thanks for your help. >>> > >>> > 2009/4/17 Tsunkiet Man >>> >> >>> >> Thank you for your response, however if I can't do that, why can the >>> >> example of wxHaskell do that? >>> >> >>> >> I refer to the following code inside >>> >> http://darcs.haskell.org/wxhaskell/samples/wx/ (ImageViewer.hs) >>> >> >>> >> Line 99 untill 110 >>> >> >>> >> openImage sw vbitmap mclose status fname >>> >> = do -- load the new bitmap >>> >> bm <- bitmapCreateFromFile fname -- can fail with >>> >> exception >>> >> closeImage vbitmap >>> >> set vbitmap [value := Just bm] >>> >> set mclose [enabled := True] >>> >> set status [text := fname] >>> >> -- reset the scrollbars >>> >> bmsize <- get bm size >>> >> set sw [virtualSize := bmsize] >>> >> repaint sw >>> >> `catch` \err -> repaint sw >>> >> >>> >> if I'm correct the openImage is also defined in the where clause. >>> >> Therefor >>> >> by what I think it should not be possible, but it is. >>> >> >>> >> Thanks for everything. >>> >> >>> >> >>> >> >>> >> >>> >> 2009/4/17 Lennart Augustsson >>> >>> >>> >>> Variables bound in the do block are not in scope in the where. >>> >>> Use a let inside the do for onOpen instead. >>> >>> >>> >>> On Thu, Apr 16, 2009 at 11:53 PM, Tsunkiet Man >>> >>> wrote: >>> >>> > Hello, >>> >>> > >>> >>> > I'm trying to create a GUI by using wxHaskell. However I get the >>> >>> > weird >>> >>> > error >>> >>> > message of "Not in scope "dt"", well so I sorted them so that my so >>> >>> > called >>> >>> > "dt" was in scope, however it failed. Can someone please tell me >>> >>> > how I >>> >>> > can >>> >>> > solve this error? >>> >>> > >>> >>> > ... A lot of code that is not relevant in my opinion, if >>> >>> > I'm >>> >>> > wrong please correct me and I will post my full code >>> >>> > >>> >>> > --Debug text -- >>> >>> > dt <- staticText f [text := "Hello world!"] >>> >>> > >>> >>> > imagePanel <- panel f [position := Point 2 2, >>> >>> > clientSize := >>> >>> > Size >>> >>> > 100 100, tooltip := "This is a drawPanel", bgcolor := rgb 255 255 >>> >>> > 255] >>> >>> > set f [ clientSize := Size 700 500, >>> >>> > menuBar := [mFile, mHelp], >>> >>> > visible := True, >>> >>> > on (menu exit) := close f, >>> >>> > on (menu open) := onOpen f vFile ] >>> >>> > >>> >>> > >>> >>> > return () >>> >>> > >>> >>> > where >>> >>> > onOpen :: Frame a -> Var b -> IO () >>> >>> > onOpen frame var = do file <- fileOpenDialog >>> >>> > frame >>> >>> > False >>> >>> > True "Open File" [("PGM bestanden (*.pgm)",["*.pgm"]),("Alle >>> >>> > bestanden >>> >>> > (*.*)",["*.*"])] "" "" >>> >>> > case file of >>> >>> > Nothing -> return >>> >>> > () >>> >>> > Just file -> set dt >>> >>> > [text := >>> >>> > "HELLO"] >>> >>> > return >>> >>> > () >>> >>> > >>> >>> > Thank you for your help, I really owe haskell-cafe. >>> >>> > >>> >>> > Greetings Tsunkiet Man >>> >>> > _______________________________________________ >>> >>> > 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 noteed at gmail.com Fri Apr 17 02:47:45 2009 From: noteed at gmail.com (minh thu) Date: Fri Apr 17 02:34:15 2009 Subject: [Haskell-cafe] Parsec question In-Reply-To: <49E7F7B6.7020506@alumni.caltech.edu> References: <49E7F7B6.7020506@alumni.caltech.edu> Message-ID: <40a414c20904162347l650eb9c6x448cf7eeffc1da25@mail.gmail.com> 2009/4/17 Michael P Mossey : > I want to write a parser that can read a file with this format: the file has > sections which are demarcated by keywords. Keywords always begin with two > forward slashes and consist of letters, digits, and underscore. The text can > be anything, including special characters. For instance: > > > //keyword some text > and more text //another_keyword and) some { more text > //ya_keyword $$ > -- text > > > I'm not sure how to write a parser that considers anything but a double > slash to be a valid part of the text. Maybe you can use a combination of 'many', 'noneOf' or 'manyTill' ? Cheers, Thu From DekuDekuplex at Yahoo.com Fri Apr 17 03:09:22 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Fri Apr 17 02:56:03 2009 Subject: [Haskell-cafe] Re: "O LANGUAGE DESIGNER, REMEMBER THE POOR USER"" References: <1bc51a990904161704ic0e7252tf8728ba447f1f6ea@mail.gmail.com> Message-ID: On Thu, 16 Apr 2009 19:04:43 -0500, Matt Morrow wrote: >This is interesting (and from 1990): > >http://groups.google.co.uk/group/comp.lang.functional/msg/655bb7bbd0fd8586 > >(Not sure if this is well-known. It seems like it either is, or it should >be. Either way, I just stumbled across it.) Regarding the following quoted portion: >USERS OF FUNCTIONAL LANGUAGES WILL HAVE SOME STRONG PRECONCEPTIONS ABOUT HOW >COMPUTATIONS ARE EXPRESSED. > >... Since, if a functional language is to be successful, the great >body of its users can be expected to be drawn from the millions who have some >expierience of Ada, C or Pascal, the conventions pertaining in those languages >should have weight in the forms chosen for any functional language where they >do not conflict with the essential attributes of the functional language. Sorry, but I do not agree with this view. Essentially, this means that new functional languages should in some way syntactically resemble Ada, C or Pascal. However, many newcomers to such functional languages as Haskell come from other languages (I myself come from Scheme and T), and requiring Haskell to resemble Ada, C or Pascal would risk alienating such other users. Besides, regarding the premise of "if a functional language is to be succesful," why is it so important that "a functional language ... be successful" in the first place? Both Simon Peyton Jones and Alan Perlis have disagreed on this issue. According to [2] (see http://research.microsoft.com/en-us/um/people/simonpj/papers/history-of-haskell/history.pdf) (see page 10), there are definite reasons for striving to "avoid success at all costs," as follows: >The fact that Haskell has, thus far, managed the tension between >these two strands of development [as a mature language, and as a >laboratory in which to explore advanced language design ideas] is >perhaps due to an accidental virtue: Haskell has not become too >successful. The trouble with runaway success, such as that of Java, >is that you get too many users, and the language becomes bogged >down in standards, user groups, and legacy issues. In contrast, the >Haskell community is small enough, and agile enough, that it usually >not only absorbs language changes but positively welcomes them: >it?s like throwing red meat to hyenas. Furthermore, to quote [1] below (see the dedication of SICP at http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-3.html), isn't our role supposed to be to "keep fun in computing?" >``I think that it's extraordinarily important that we in computer science >keep fun in computing. When it started out, it was an awful lot of fun. Of >course, the paying customers got shafted every now and then, and after >a while we began to take their complaints seriously. We began to feel as if >we really were responsible for the successful, error-free perfect use of >these machines. I don't think we are. I think we're responsible for stretching >them, setting them off in new directions, and keeping fun in the house. I >hope the field of computer science never loses its sense of fun. Above all, I >hope we don't become missionaries. Don't feel as if you're Bible salesmen. >The world has too many of those already. What you know about computing >other people will learn. Don't feel as if the key to successful computing is only >in your hands. What's in your hands, I think and hope, is intelligence: the >ability to see the machine as more than when you were first led up to it, that >you can make it more.'' > >Alan J. Perlis (April 1, 1922-February 7, 1990) I had always thought that part of the advantage of Haskell was the ability of being agile enough to experiment. Robbing Haskell of that advantage would seem to kick the fun out of the house. -- Benjamin L. Russell References [1] Abelson, Harold and Sussman, Gerald Jay with Sussman, Julie. _Structure and Interpretation of Computer Programs, Second Edition._ Cambridge, MA: The MIT Press and New York: McGraw-Hill, 1996. [2] Hudak, Paul, Hughes, John, Peyton Jones, Simon, and Wadler, Philip. "A History of Haskell: Being Lazy With Class." San Diego, California: _The Third ACM SIGPLAN History of Programming Languages Conference (HOPL-III)_ (2007): 12-1 - 12-55, 2007. -- 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 mpm at alumni.caltech.edu Fri Apr 17 03:52:55 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Fri Apr 17 03:39:26 2009 Subject: [Haskell-cafe] Parsec question In-Reply-To: <40a414c20904162347l650eb9c6x448cf7eeffc1da25@mail.gmail.com> References: <49E7F7B6.7020506@alumni.caltech.edu> <40a414c20904162347l650eb9c6x448cf7eeffc1da25@mail.gmail.com> Message-ID: <49E83557.8000002@alumni.caltech.edu> Here's what I've got so far. -- Text is considered everything up to //. However, the problem -- is that this consumes the //. parseText = manyTill anyChar (try (string "//")) -- Because the // is already consumed, parseKeyword just grabs -- the available letters. parseKeyword :: Parser String parseKeyword = many1 letter -- Test function. parseSome = do t1 <- parseText k1 <- parseKeyword t2 <- parseText return (t1,k1,t2) On "some text//keyword more text//" this gives ("some text","keyword"," more text") On "some text//keyword more text" this gives the error "expecting //" I wonder how I can get the manyTill to be happy with eof before finding the //? I tried parseText = manyTill anyChar (try (string "//") <|> eof) but got a type error. minh thu wrote: > 2009/4/17 Michael P Mossey : >> I want to write a parser that can read a file with this format: the file has >> sections which are demarcated by keywords. Keywords always begin with two >> forward slashes and consist of letters, digits, and underscore. The text can >> be anything, including special characters. For instance: >> >> >> //keyword some text >> and more text //another_keyword and) some { more text >> //ya_keyword $$ >> -- text >> >> >> I'm not sure how to write a parser that considers anything but a double >> slash to be a valid part of the text. > > Maybe you can use a combination of 'many', 'noneOf' or 'manyTill' ? > > Cheers, > Thu From sebf at informatik.uni-kiel.de Fri Apr 17 04:03:36 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Fri Apr 17 03:50:09 2009 Subject: [Haskell-cafe] RE: [Announce] primes In-Reply-To: <539969.32840.qm@web31106.mail.mud.yahoo.com> References: <539969.32840.qm@web31106.mail.mud.yahoo.com> Message-ID: <7FD04DD8-BC14-4AEB-8690-6C9B7E54C494@informatik.uni-kiel.de> > Oh, I just remembered, I'm using ghci. I'll bet that's why I'm so > slow. I also did, but after installing the package using cabal. IIRC, cabal compiles with -O2 by default. But if you downloaded the tarball and then loaded the module in ghci without installing it, this is probably the reason for the slow response. Cheers, Sebastian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090417/314e520b/attachment-0001.htm From noteed at gmail.com Fri Apr 17 04:06:10 2009 From: noteed at gmail.com (minh thu) Date: Fri Apr 17 03:52:38 2009 Subject: [Haskell-cafe] Parsec question In-Reply-To: <49E83557.8000002@alumni.caltech.edu> References: <49E7F7B6.7020506@alumni.caltech.edu> <40a414c20904162347l650eb9c6x448cf7eeffc1da25@mail.gmail.com> <49E83557.8000002@alumni.caltech.edu> Message-ID: <40a414c20904170106g542bc933k148563d1f2a00443@mail.gmail.com> You can use 'notFollowedBy' (probably with 'many1' and 'try'). Something like (untested): notFollowedBy (try $ string "//") Thu 2009/4/17 Michael Mossey : > Here's what I've got so far. > > -- Text is considered everything up to //. However, the problem > -- is that this consumes the //. > parseText = manyTill anyChar (try (string "//")) > > -- Because the // is already consumed, parseKeyword just grabs > -- the available letters. > parseKeyword :: Parser String > parseKeyword = many1 letter > > > > > -- Test function. > parseSome = do t1 <- parseText > k1 <- parseKeyword > t2 <- parseText > return (t1,k1,t2) > > On "some text//keyword more text//" this gives > > ("some text","keyword"," more text") > > On "some text//keyword more text" > > this gives the error "expecting //" > > I wonder how I can get the manyTill to be happy with eof before finding the > //? I tried > > parseText = manyTill anyChar (try (string "//") <|> eof) > > but got a type error. > > > minh thu wrote: >> >> 2009/4/17 Michael P Mossey : >>> >>> I want to write a parser that can read a file with this format: the file >>> has >>> sections which are demarcated by keywords. Keywords always begin with two >>> forward slashes and consist of letters, digits, and underscore. The text >>> can >>> be anything, including special characters. For instance: >>> >>> >>> //keyword some text >>> and more text //another_keyword and) some { more text >>> //ya_keyword $$ >>> -- text >>> >>> >>> I'm not sure how to write a parser that considers anything but a double >>> slash to be a valid part of the text. >> >> Maybe you can use a combination of 'many', 'noneOf' or 'manyTill' ? >> >> Cheers, >> Thu > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From mpm at alumni.caltech.edu Fri Apr 17 05:15:13 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Fri Apr 17 05:01:50 2009 Subject: [Haskell-cafe] Parsec question In-Reply-To: <40a414c20904170106g542bc933k148563d1f2a00443@mail.gmail.com> References: <49E7F7B6.7020506@alumni.caltech.edu> <40a414c20904162347l650eb9c6x448cf7eeffc1da25@mail.gmail.com> <49E83557.8000002@alumni.caltech.edu> <40a414c20904170106g542bc933k148563d1f2a00443@mail.gmail.com> Message-ID: <49E848A1.7080301@alumni.caltech.edu> My confusion is that text is by definition followed by // or eof. minh thu wrote: > You can use 'notFollowedBy' (probably with 'many1' and 'try'). > Something like (untested): > > notFollowedBy (try $ string "//") > > Thu > > 2009/4/17 Michael Mossey : >> Here's what I've got so far. >> >> -- Text is considered everything up to //. However, the problem >> -- is that this consumes the //. >> parseText = manyTill anyChar (try (string "//")) >> >> -- Because the // is already consumed, parseKeyword just grabs >> -- the available letters. >> parseKeyword :: Parser String >> parseKeyword = many1 letter >> >> >> >> >> -- Test function. >> parseSome = do t1 <- parseText >> k1 <- parseKeyword >> t2 <- parseText >> return (t1,k1,t2) >> >> On "some text//keyword more text//" this gives >> >> ("some text","keyword"," more text") >> >> On "some text//keyword more text" >> >> this gives the error "expecting //" >> >> I wonder how I can get the manyTill to be happy with eof before finding the >> //? I tried >> >> parseText = manyTill anyChar (try (string "//") <|> eof) >> >> but got a type error. >> >> >> minh thu wrote: >>> 2009/4/17 Michael P Mossey : >>>> I want to write a parser that can read a file with this format: the file >>>> has >>>> sections which are demarcated by keywords. Keywords always begin with two >>>> forward slashes and consist of letters, digits, and underscore. The text >>>> can >>>> be anything, including special characters. For instance: >>>> >>>> >>>> //keyword some text >>>> and more text //another_keyword and) some { more text >>>> //ya_keyword $$ >>>> -- text >>>> >>>> >>>> I'm not sure how to write a parser that considers anything but a double >>>> slash to be a valid part of the text. >>> Maybe you can use a combination of 'many', 'noneOf' or 'manyTill' ? >>> >>> Cheers, >>> Thu >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> From jason.dusek at gmail.com Fri Apr 17 06:55:54 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Apr 17 06:42:15 2009 Subject: [Haskell-cafe] Parsec question In-Reply-To: <40a414c20904170106g542bc933k148563d1f2a00443@mail.gmail.com> References: <49E7F7B6.7020506@alumni.caltech.edu> <40a414c20904162347l650eb9c6x448cf7eeffc1da25@mail.gmail.com> <49E83557.8000002@alumni.caltech.edu> <40a414c20904170106g542bc933k148563d1f2a00443@mail.gmail.com> Message-ID: <42784f260904170355w7144b9b8w56873135f4efc429@mail.gmail.com> 2009/04/17 minh thu : > 2009/04/17 Michael Mossey : >> I wonder how I can get the manyTill to be happy with eof >> before finding the //? I tried >> >> parseText = manyTill anyChar (try (string "//") <|> eof) >> >> but got a type error. > > You can use 'notFollowedBy' [...] You get a type error because `string "//"` parses to a `String` while `eof` parses to a `()`. Instead you might use: parseText = manyTill anyChar (try (string "//" >> return ()) <|> eof) -- Jason Dusek From byorgey at seas.upenn.edu Fri Apr 17 07:46:25 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Fri Apr 17 07:32:48 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 114 - April 17, 2009 Message-ID: <20090417114624.GA22541@seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090417 Issue 114 - April 17, 2009 --------------------------------------------------------------------------- Welcome to issue 114 of HWN, a newsletter covering developments in the [1]Haskell community. The [2]5th Haskell Hackathon is underway in Utrecht! Happy Haskell hacking! An early HWN this week since I will be traveling this weekend (but not, unfortunately, to the Hackathon). Announcements Reminder: Haskell Communities and Activities Report. Janis Voigtlaender [3]reminded everyone that the deadline for the [4]May 2009 edition of the Haskell Communities and Activities Report is only two weeks away. If you haven't already, please write an entry for your new project, or update your old entry. primes. Sebastian Fischer [5]announced the release of the [6]primes package, which implements lazy wheel sieves for efficient, purely functional generation of prime numbers in Haskell. level-monad-0.3. Sebastian Fischer [7]announced version 0.3 of the package [8]level-monad, which implements breadth-first search directly as an instance of MonadPlus (without using an intermediate tree representation). Version 0.3 adds a MonadPlus instance for iterative deepening inspired by Michael Spivey's paper on [9]Algebras for combinatorial search. hgettext 0.1.10. Vasyl Pasternak [10]announced a new release of the [11]hgettext package, which now has bindings to all gettext functions. Haskell logo in TeX. Philip H?lzenspies [12]announced a version of the new [13]Haskell logo design prepared using TikZ, for inclusion in LaTeX documents. The Monad.Reader (14) - Call for copy. Wouter Swierstra [14]issued a call for copy for Issue 14 of [15]The Monad.Reader. The deadline for submissions is May 15, 2009. Let Wouter know if you intend to submit something -- the sooner, the better. time 1.1.2.4. Ashley Yakeley [16]announced the release of [17]time 1.1.2.4, which should now compile on Windows. Discussion Code Golf. Sebastian Fischer [18]started a lively round of code golf with his code for list diagonalization. Converting IO [XmlTree] to [XmlTree]. rodrigo.bonifacio [19]asked how to convert an IO [XmlTree] into an [XmlTree], leading to a discussion of Haskell pedagogy. Blog noise [21]Haskell news from the [22]blogosphere. * Roman Cheplyaka: [23]Fun in Utrecht. * Roman Cheplyaka: [24]Utrecht: first impressions. * >>> Daniel van den Eijkel: [25]Hommage: Haskell Offline Music Manipulation And Generation EDSL. * >>> Brandon Simmons: [26]Some initial tests of Tries. * Christopher Lane Hinson: [27]Trends in Profiling Haskell. * >>> Larry O'Brien: [28]Windows & .NET Watch: Haskell: It's like Klingon, but with math!. * Sean Escriva: [29]Why Haskell is a joy to learn. * GHC / OpenSPARC Project: [30]Instruction counts on x86 vs SPARC. * Sebastian Fischer: [31]Barefaced pilferage of monadic bind. * Benjamin L. Russell: [32]Climbing the Towers of Hanoi with Haskell-style Curry from a Monadic Container (While Sparing the Sugar!). Quotes of the Week * Gracenotes: And then the type system goes all crazy and demands that x and 1 are both Word32s! * mauke: data What a = No; instance Monad What where { return _ = No; No >>= _ = No } * pumpkin: makes the next internet hit video, 2 natural transformations, 1 functor * mmorrow: a functor is like an analogy between two analogies * FliPPeh: @faq Can Conficker be rewritten in Haskell? : parse error on input `:' * HairyDude: The Haskell Type System is a Harsh Mistress.. there ain't no such thing as a free theorem. * LeCamarade: Now, let's say the set is {Haskell, SML, Ruby, Tomatoes, Human, Cabbage, Noise, IRC}. * pjdelport: YO DAWG I HERD YOU LIKE CARS SO WE PUT A PAIR IN YO CAR SO YOU CAN CAR WHILE YOU CAR * Babelfish: And there you travel: a beam tracer! Naturally, there are many things that ought to be amend. 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 byorgey at cis dot upenn dot edu. The darcs repository is available at darcs get [39]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://haskell.org/haskellwiki/Hac5 3. http://article.gmane.org/gmane.comp.lang.haskell.cafe/57075 4. http://www.haskell.org/pipermail/haskell/2009-April/021180.html 5. http://article.gmane.org/gmane.comp.lang.haskell.cafe/57042 6. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/primes 7. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56981 8. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/level-monad 9. http://spivey.oriel.ox.ac.uk/mike/search-jfp.pdf 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/56940 11. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hgettext 12. http://article.gmane.org/gmane.comp.lang.haskell.general/17094 13. http://www.cs.utwente.nl/~holzensp/haskelllogo.sty 14. http://article.gmane.org/gmane.comp.lang.haskell.general/17090 15. http://haskell.org/haskellwiki/The_Monad.Reader 16. http://article.gmane.org/gmane.comp.lang.haskell.libraries/10921 17. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/time 18. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/56957 19. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/56898 21. http://planet.haskell.org/ 22. http://haskell.org/haskellwiki/Blog_articles 23. http://ro-che.blogspot.com/2009/04/fun-in-utrecht.html 24. http://ro-che.blogspot.com/2009/04/utrecht-first-impressions.html 25. http://substitut-fuer-feinmotorik.net/projects/haskellommage/introduction 26. http://coder.bsimmons.name/blog/2009/04/some-initial-tests-of-tries/ 27. http://blog.downstairspeople.org/2009/04/16/trends-in-profiling-haskell/ 28. http://www.sdtimes.com/content/article.aspx?ArticleID=33399 29. http://www.webframp.com/2009/04/15/why-haskell-is-a-joy-to-learn/ 30. http://ghcsparc.blogspot.com/2009/04/instruction-counts-on-x86-vs-sparc.html 31. http://www-ps.informatik.uni-kiel.de/~sebf/haskell/stealing-bind.html 32. http://dekudekuplex.wordpress.com/2009/04/13/climbing-the-towers-of-hanoi-with-haskell-style-curry-from-a-monadic-container-while-sparing-the-sugar/ 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://code.haskell.org/~byorgey/code/hwn/ From daniel.is.fischer at web.de Fri Apr 17 08:16:58 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Apr 17 08:03:36 2009 Subject: [Haskell-cafe] wxHaskell not in scope In-Reply-To: References: Message-ID: <200904171416.58617.daniel.is.fischer@web.de> Am Freitag 17 April 2009 01:37:25 schrieb Tsunkiet Man: > Hello, > > what you suggested worked! Im very happy with it. However another error > suddenly came up. It sais the last statement in a 'do' must be an > expression, he is refering to line 41:45 > > I change my code to this: > > on (menu exit) := close f, > on (menu open) := onOpen f dt vFile ] > > return () > > where > onOpen :: Frame a -> staticText c -> Var b -> IO () > onOpen frame stat var = do file <- fileOpenDialog frame > False True "Open File" [("PGM bestanden (*.pgm)",["*.pgm"]),("Alle > bestanden (*.*)",["*.*"])] "" "" > case file of > Nothing -> return () > Just file -> set stat [text > > := "HELLO"] > > return () In the "Just file" case, you want to have two IO-actions. If you don't use (>>=) or (>>) to chain them together, you must put them in a do-block, so case file of Nothing -> return () Just file -> do set stat [text := "HELLO"] return () But I think you can omit the return () in that branch anyway, set foo bar should have the correct type already. > > As far as I can tell, if the file is nothing it will return something of IO > () and if the file is something it will return something of IO (). So that > error is kind of strange in my opinion. Do you know what caused it? > > Thanks for your help! > From nowgate at yahoo.com Fri Apr 17 10:26:33 2009 From: nowgate at yahoo.com (michael rice) Date: Fri Apr 17 10:12:55 2009 Subject: [Haskell-cafe] RE: [Announce] primes Message-ID: <564902.5241.qm@web31101.mail.mud.yahoo.com> You're right. Since I'm not familiar with Cabal, I didn't use it. Is there a good tutorial? Docs? Also, I'm running a 32-bit Linux OS. Does one get a significant speed increase by switching to a 64-bit OS? Thanks for the feedback. Michael --- On Fri, 4/17/09, Sebastian Fischer wrote: From: Sebastian Fischer Subject: Re: [Haskell-cafe] RE: [Announce] primes To: "Haskell Cafe mailing list" Date: Friday, April 17, 2009, 4:03 AM Oh, I just remembered, I'm using ghci. I'll bet that's why I'm so slow. I also did, but after installing the package using cabal. IIRC, cabal compiles with -O2 by default. But if you downloaded the tarball and then loaded the module in ghci without installing it, this is probably the reason for the slow response. Cheers,Sebastian -----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/20090417/a153d3b0/attachment.htm From josef.svenningsson at gmail.com Fri Apr 17 10:46:06 2009 From: josef.svenningsson at gmail.com (Josef Svenningsson) Date: Fri Apr 17 10:32:30 2009 Subject: [Haskell-cafe] types and braces In-Reply-To: <61D885C2-990B-458F-83F6-1719AD6E627F@strictlypositive.org> References: <8F56CE9D-3551-4EC4-A18C-4B87BB3CEC16@strictlypositive.org> <61D885C2-990B-458F-83F6-1719AD6E627F@strictlypositive.org> Message-ID: <8dde104f0904170746y2fca8090ufae9e768f74f2769@mail.gmail.com> Conor, I'd like to point out a few things that may help you on the way. On Wed, Apr 15, 2009 at 8:58 PM, Conor McBride wrote: >> I don't immediately see what the clash in that context would be - I >> *think* what you propose should be doable. I'd be interested to know >> what you come up with, or I might have a look at it myself when I find >> a few minutes to spare. > > I've found that I can add a production > > atype :: { Type } > ?... > ?| '{' trueexp '}' > > if I remove the productions for record declarations > > constr1 :: { ConDecl } > ? ? ?| con '{' '}' ? ? ? ? ? ? ? ? ? { RecDecl $1 [] } > ? ? ?| con '{' fielddecls '}' ? ? ? ?{ RecDecl $1 (reverse $3) } > > which suggests that it is indeed the syntax > > ?data Moo = Foo {goo :: Boo Hoo} > > which is in apparent conflict with my proposed extension. > The current parser uses the type parser btype to parse the > initial segment of constructor declarations, so my change > causes trouble. > > Further trouble is in store from infix constructors > > ?data Noo = Foo {True} :*: Foo {False} > > should make sense, but you have to look quite far to > distinguish that from a record. > > So I don't see that my proposed extension introduces a > genuine ambiguity, but it does make the parser a bit > knottier. > Remember that even though your parser in unambiguous that doesn't mean that happy will be able to handle it. Happy deals with LALR grammars and you have to confine yourself to that restriction in order to make happy happy. Also, your example above suggests that your grammar might require an infinite lookahead, something which happy doesn't deal with. Having said all this, there is a magic flag which you can give to happy which will make all these headaches go away. The incantation is --glr which makes happy produce generalized lr parsers which can deal even with ambiguous grammars. I've never used this myself so I can't give you any further advice than to point you in the general direction. The happy manual is your friend. Happy happy hacking. Josef From hjgtuyl at chello.nl Fri Apr 17 10:46:17 2009 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Fri Apr 17 10:32:46 2009 Subject: [Haskell-cafe] glut installation using cabal failed In-Reply-To: <1239867884.6315.8.camel@lantern> References: <1336aed20904132325i6b765025oc20e99593dba3fbd@mail.gmail.com> <1239867884.6315.8.camel@lantern> Message-ID: On Thu, 16 Apr 2009 09:44:44 +0200, Duncan Coutts wrote: > On Wed, 2009-04-15 at 01:53 +0200, Henk-Jan van Tuyl wrote: >> On Tue, 14 Apr 2009 08:25:52 +0200, Raja Koduru >> wrote: >> >> > hi, >> > >> > I am a beginner to haskell. >> > >> > I am trying to install glut using "cabal install glut" >> > Pasting here a tail of the output > >> > checking for GLUT/glut.h... no >> > configure: error: no GLUT header found, so this package cannot be >> built >> > See `config.log' for more details. > >> > >> > But I do have "glut.h" in my "D:\ghc\ghc-6.10.2\include\mingw\GL". >> > >> >> Define the environment variable: >> C_INCLUDE_PATH=D:\ghc\ghc-6.10.2\include\mingw >> (you can add more directories, separate them by ';') >> To let the linker find the libraries, define LIBRARY_PATH. > > Hmm, that is annoying. > > I've filed a tracker bug here: > http://trac.haskell.org/haskell-platform/ticket/11 > > and also noted the issue here: > http://hackage.haskell.org/trac/hackage/ticket/458#comment:2 > > Duncan > I am not absolutely sure, that you need to set these environment vars in this case, but I needed it for most packages with headers and external libs; this is what Raja wrote to me: > Thank you. > Actually I have already set C_INCLUDE_PATH environment variable with > the right set of directories. > Even after that error trace was occurring. > I was suggested that I launch cabal from msys instead of launching via > window's cmd.exe. > That worked. I have no explanation for that behavior. > regards, > raja -- Regards, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ -- From simonpj at microsoft.com Fri Apr 17 11:52:52 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Fri Apr 17 11:39:16 2009 Subject: [Haskell-cafe] types and braces In-Reply-To: References: <8F56CE9D-3551-4EC4-A18C-4B87BB3CEC16@strictlypositive.org> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C337AD8AAAA1@EA-EXMSG-C334.europe.corp.microsoft.com> Conor See this, which I've just written for you: http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/Parser (Others: please do add to this new Commentary page.) In any case, my guess is that adding atype ::= '{' qcon '}' ought not to introduce ambiguities. You don't want all of 'exp' (yet) do you? Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On | Behalf Of Conor McBride | Sent: 15 April 2009 16:13 | To: Lennart Augustsson | Cc: Haskell Cafe | Subject: Re: [Haskell-cafe] types and braces | | | On 15 Apr 2009, at 16:01, Lennart Augustsson wrote: | | > I'd suggest using some different kind of brackets to relieve the | > misery, like {| |}. | | That would speed up my tinkering, certainly. | | I did have a d'oh moment: you can write | | data Foo = Moo {goo :: Int} -- braces where a type goes | | and indeed, commenting out field declarations makes happy | happy. However, these { exp } guys never stand as types of | things, only as parameters of types, so it might be possible | to resolve the problem without fat brackets. Whether it's | worth it is another matter... | | Cheers | | Conor | | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe From mpm at alumni.caltech.edu Fri Apr 17 12:23:43 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Fri Apr 17 12:10:11 2009 Subject: [Haskell-cafe] Parsec question In-Reply-To: <42784f260904170355w7144b9b8w56873135f4efc429@mail.gmail.com> References: <49E7F7B6.7020506@alumni.caltech.edu> <40a414c20904162347l650eb9c6x448cf7eeffc1da25@mail.gmail.com> <49E83557.8000002@alumni.caltech.edu> <40a414c20904170106g542bc933k148563d1f2a00443@mail.gmail.com> <42784f260904170355w7144b9b8w56873135f4efc429@mail.gmail.com> Message-ID: <49E8AD0F.9020803@alumni.caltech.edu> Jason Dusek wrote: > 2009/04/17 minh thu : >> 2009/04/17 Michael Mossey : >>> I wonder how I can get the manyTill to be happy with eof >>> before finding the //? I tried >>> >>> parseText = manyTill anyChar (try (string "//") <|> eof) >>> >>> but got a type error. >> You can use 'notFollowedBy' [...] > > You get a type error because `string "//"` parses to a > `String` while `eof` parses to a `()`. Instead you might use: > > parseText = manyTill anyChar (try (string "//" >> return ()) <|> eof) > > -- > Jason Dusek Ah.. I think I get it... in the function manyTill, the second argument type doesn't matter.. doesn't have to match the first argument type. Here's what I have so far. It works, but it's a bit weird to consume the // as part of the text rather than the keyword. That happens because the try( string "//" ), which is part of the end arg to manyTill, consumes the // when it succeeds. But maybe it is the most natural way to express the problem. parseKeyword :: Parser String parseKeyword = many1 (alphaNum <|> char '_') parseText :: Parser String parseText = manyTill anyChar ((try (string "//") >> return ()) <|> eof) parsePair :: Parser (String,String) parsePair = do k <- parseKeyword t <- parseText return (k,t) parseFile :: Parser [(String,String)] parseFile = do _ <- parseText -- to skip any text at beginning and 'sync up' p <- many parsePair return p From bulat.ziganshin at gmail.com Fri Apr 17 12:29:17 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Apr 17 12:15:50 2009 Subject: [Haskell-cafe] RE: [Announce] primes In-Reply-To: <564902.5241.qm@web31101.mail.mud.yahoo.com> References: <564902.5241.qm@web31101.mail.mud.yahoo.com> Message-ID: <1706891571.20090417202917@gmail.com> Hello michael, Friday, April 17, 2009, 6:26:33 PM, you wrote: http://haskell.org/cabal/ > You're right. Since I'm not familiar with Cabal, I didn't use it. Is there a good tutorial? Docs? > Also, I'm running a 32-bit Linux OS. Does one get a significant speed increase by > switching to a 64-bit OS? > Thanks for the feedback. > Michael > --- On Fri, 4/17/09, Sebastian Fischer > wrote: > From: Sebastian Fischer > Subject: Re: [Haskell-cafe] RE: [Announce] primes > To: "Haskell Cafe mailing list" > Date: Friday, April 17, 2009, 4:03 AM > Oh, I just remembered, I'm using ghci. I'll bet that's why I'm so slow. > I also did, but after installing the package using cabal. IIRC, > cabal compiles with -O2 by default. But if you downloaded the > tarball and then loaded the module in ghci without installing it, > this is probably the reason for the slow response. > Cheers, > Sebastian > -----Inline Attachment Follows----- > _______________________________________________ > 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 Christian.Maeder at dfki.de Fri Apr 17 12:43:10 2009 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Fri Apr 17 12:29:30 2009 Subject: [Haskell-cafe] Re: Parsec question In-Reply-To: <49E8AD0F.9020803@alumni.caltech.edu> References: <49E7F7B6.7020506@alumni.caltech.edu> <40a414c20904162347l650eb9c6x448cf7eeffc1da25@mail.gmail.com> <49E83557.8000002@alumni.caltech.edu> <40a414c20904170106g542bc933k148563d1f2a00443@mail.gmail.com> <42784f260904170355w7144b9b8w56873135f4efc429@mail.gmail.com> <49E8AD0F.9020803@alumni.caltech.edu> Message-ID: <49E8B19E.90002@dfki.de> Michael Mossey wrote: > Here's what I have so far. It works, but it's a bit weird to consume the > // as part of the text rather than the keyword. That happens because the > try( string "//" ), which is part of the end arg to manyTill, consumes > the // when it succeeds. But maybe it is the most natural way to express > the problem. use lookAhead! > parseKeyword :: Parser String > parseKeyword = many1 (alphaNum <|> char '_') parseKeyword = string "//" >> many1 (alphaNum <|> char '_') > parseText :: Parser String > parseText = manyTill anyChar ((try (string "//") >> return ()) > <|> eof) parseText = manyTill anyChar $ (lookAhead (try $ string "//") >> return ()) <|> eof (untested) C. From martijn at van.steenbergen.nl Fri Apr 17 14:49:24 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Apr 17 14:36:01 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 114 - April 17, 2009 In-Reply-To: <20090417114624.GA22541@seas.upenn.edu> References: <20090417114624.GA22541@seas.upenn.edu> Message-ID: <49E8CF34.9040506@van.steenbergen.nl> Brent Yorgey wrote: > The [2]5th Haskell Hackathon is underway in Utrecht! Happy Haskell > hacking! An early HWN this week since I will be traveling this weekend > (but not, unfortunately, to the Hackathon). Yes! It's been a good day so far; there are lots of projects being worked on. You can follow the [1]latest news on Twitter; there are also [2]some pictures online already. [1] http://search.twitter.com/search?q=%23hac5 [2] http://martijn.van.steenbergen.nl/journal/hac5-pt-1/ Groetjes from Utrecht, Martijn. From dagit at codersbase.com Fri Apr 17 17:41:18 2009 From: dagit at codersbase.com (Jason Dagit) Date: Fri Apr 17 17:27:39 2009 Subject: [Haskell-cafe] Computing a sorted list of products lazily Message-ID: Hello, A colleague of mine recently asked if I knew of a lazy way to solve the following problem: Given two sets of sorted floating point numbers, can we lazily generate a sorted list of the products from their Cartesian product? The algorithm should return the same result as: sortProduct a b = sort [ x * y | x <- a, y <- b ] But, my friend is not satisfied with the strictness of sort. In particular, he doesn't want to have to hold the whole list in memory to sort it. He would like to compute the results one product at a time and in the correct order. Is there an existing algorithm for this problem? We searched but we don't seem to know the right search terms. Additionally, my friend is not writing this in Haskell, but a Haskell solution is fine because we should be able to transform it into a Java solution by hand. We think we know an algorithm that will produce the right result but it's a bit messy and we doubt we're the first to tackle this problem. Any help would be greatly appreciated. Thanks in advance! Jason From porges at porg.es Fri Apr 17 18:08:51 2009 From: porges at porg.es (porges@porg.es) Date: Fri Apr 17 17:55:27 2009 Subject: [Haskell-cafe] Computing a sorted list of products lazily In-Reply-To: Message-ID: I did something similar a while ago to solve a problem posted on StackOverflow: http://porg.es/blog/sorted-sums-of-a-sorted-list Henry Laxen generalized my code a little bit so you can pass in any monotonic function (see the comments). I'm not sure of the laziness properties of this, but it might be lazy enough... you may need to swap for a boxed array. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 270 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090418/1d8f971e/signature.bin From bulat.ziganshin at gmail.com Fri Apr 17 18:17:20 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Apr 17 18:05:35 2009 Subject: [Haskell-cafe] Computing a sorted list of products lazily In-Reply-To: References: Message-ID: <247099209.20090418021720@gmail.com> Hello Jason, Saturday, April 18, 2009, 1:41:18 AM, you wrote: > The algorithm should return the same result as: > sortProduct a b = sort [ x * y | x <- a, y <- b ] i think it's well-known problem. you should write a function merging infinite list of sorted lists. in assumption that lists are ordered by their first element this should be doable -- Function that merge finite lists (kidnapped from Data.List): merge_lists :: (a -> a -> Ordering) -> [[a]] -> [a] merge_lists cmp [] = [] merge_lists cmp [xs] = xs merge_lists cmp xss = merge_lists cmp (merge_pairs cmp xss) merge_pairs :: (a -> a -> Ordering) -> [[a]] -> [[a]] merge_pairs cmp [] = [] merge_pairs cmp [xs] = [xs] merge_pairs cmp (xs:ys:xss) = merge cmp xs ys : merge_pairs cmp xss merge :: (a -> a -> Ordering) -> [a] -> [a] -> [a] merge cmp xs [] = xs merge cmp [] ys = ys merge cmp (x:xs) (y:ys) = case x `cmp` y of GT -> y : merge cmp (x:xs) ys _ -> x : merge cmp xs (y:ys) this function merges lists in pairs. rewriting it to make incremental merging, using "sorted by first element" property and omitting finite lists support, we get just: -- Merging infinite sorted lists merge_lists :: (Ord a) => [[a]] -> [a] merge_lists ((x:xs):xss) = x : merge xs (merge_lists xss) merge :: (Ord a) => [a] -> [a] -> [a] merge (x:xs) (y:ys) = case x > y of True -> y : merge (x:xs) ys _ -> x : merge xs (y:ys) works for me with test script: main = putStr (unlines$ map show$ merge_lists [[x*y | x<-[1..]] | y<-[1..]]) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From daniel.is.fischer at web.de Fri Apr 17 18:19:31 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Apr 17 18:06:07 2009 Subject: [Haskell-cafe] Computing a sorted list of products lazily In-Reply-To: References: Message-ID: <200904180019.31725.daniel.is.fischer@web.de> Am Freitag 17 April 2009 23:41:18 schrieb Jason Dagit: > Hello, > > A colleague of mine recently asked if I knew of a lazy way to solve > the following problem: > Given two sets of sorted floating point numbers, can we lazily > generate a sorted list of the products from their Cartesian product? If the numbers are nonnegative, you could use sortedProducts xs ys = foldr merge1 [] [map (*x) ys | x <- xs] merge1 (x:xs) ys = x:merge xs ys merge1 [] ys = ys merge xs@(x:xt) ys@(y:yt) | x < y = x:merge xt ys | otherwise = y:merge xs yt (or remove duplicates, if you wish) Since the lists are sorted and the numbers nonnegative, each (map (*x) ys) is sorted and the heads of these are sorted, too, therefore we can use merge1, which makes the fold lazy enough to work even on infinite lists (it is not very fast, though, if speed is crucial, you might be better off to sort in chunks). > > The algorithm should return the same result as: > sortProduct a b = sort [ x * y | x <- a, y <- b ] > > But, my friend is not satisfied with the strictness of sort. In > particular, he doesn't want to have to hold the whole list in memory > to sort it. He would like to compute the results one product at a > time and in the correct order. > > Is there an existing algorithm for this problem? We searched but we > don't seem to know the right search terms. Additionally, my friend is > not writing this in Haskell, but a Haskell solution is fine because we > should be able to transform it into a Java solution by hand. > > We think we know an algorithm that will produce the right result but > it's a bit messy and we doubt we're the first to tackle this problem. > Any help would be greatly appreciated. Thanks in advance! > > Jason From martijn at van.steenbergen.nl Fri Apr 17 18:31:50 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Apr 17 18:18:11 2009 Subject: [Haskell-cafe] Computing a sorted list of products lazily In-Reply-To: <200904180019.31725.daniel.is.fischer@web.de> References: <200904180019.31725.daniel.is.fischer@web.de> Message-ID: <49E90356.1000505@van.steenbergen.nl> Hi Daniel, I love your solution. Very elegant. Daniel Fischer wrote: > sortedProducts xs ys = foldr merge1 [] [map (*x) ys | x <- xs] > > merge1 (x:xs) ys = x:merge xs ys > merge1 [] ys = ys > > merge xs@(x:xt) ys@(y:yt) > | x < y = x:merge xt ys > | otherwise = y:merge xs yt > (or remove duplicates, if you wish) Small addition: if you want this to run on finite input as well, add this case: > merge xs ys = xs ++ ys Martijn. From daniel.is.fischer at web.de Fri Apr 17 18:38:11 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Apr 17 18:24:45 2009 Subject: [Haskell-cafe] Computing a sorted list of products lazily In-Reply-To: <49E90356.1000505@van.steenbergen.nl> References: <200904180019.31725.daniel.is.fischer@web.de> <49E90356.1000505@van.steenbergen.nl> Message-ID: <200904180038.11429.daniel.is.fischer@web.de> Am Samstag 18 April 2009 00:31:50 schrieb Martijn van Steenbergen: > Hi Daniel, > > I love your solution. Very elegant. > > Daniel Fischer wrote: > > sortedProducts xs ys = foldr merge1 [] [map (*x) ys | x <- xs] > > > > merge1 (x:xs) ys = x:merge xs ys > > merge1 [] ys = ys > > > > merge xs@(x:xt) ys@(y:yt) > > > > | x < y = x:merge xt ys > > | otherwise = y:merge xs yt > > > > (or remove duplicates, if you wish) > > Small addition: if you want this to run on finite input as well, add > > this case: > > merge xs ys = xs ++ ys Argh! When typing the foldr, I thought I mustn't forget the case for an empty list in merge1 and merge. Well, at least I remembered half of it :( > > Martijn. From rendel at cs.au.dk Fri Apr 17 18:45:31 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Fri Apr 17 18:32:13 2009 Subject: [Haskell-cafe] Computing a sorted list of products lazily In-Reply-To: References: Message-ID: <49E9068B.9070901@cs.au.dk> Jason Dagit wrote: > A colleague of mine recently asked if I knew of a lazy way to solve > the following problem: > Given two sets of sorted floating point numbers, can we lazily > generate a sorted list of the products from their Cartesian product? > > The algorithm should return the same result as: > sortProduct a b = sort [ x * y | x <- a, y <- b ] First create a matrix of all the products, represented as a list of non-empty lists such that the inner lists are sorted, and the outer list is sorted by the first elements of the inner lists. Then repeatedly remove the first element of the first list, and reorder the list-of-lists. > module SortProduct where > > import Data.List (insertBy) > import Data.Function (on) > > products a b = [[x * y | x <- a] | y <- b] > > toList [] = [] > toList ([x] : rest) = x : toList rest > toList ((x : xs) : rest) > = x : toList (insertBy (compare `on` head) xs rest) > > sortProduct a b = toList (products a b) Tillmann From dbueno at gmail.com Fri Apr 17 19:03:18 2009 From: dbueno at gmail.com (Denis Bueno) Date: Fri Apr 17 18:49:43 2009 Subject: [Haskell-cafe] Announce: funsat-0.6 Message-ID: <6dbd4d000904171603va21b9abkfd783cb4acb1bfee@mail.gmail.com> Hello haskell-cafe, funsat is a modern, DPLL-style SAT solver written in Haskell. Funsat solves formulas in conjunctive normal form and produces a total variable assignment for satisfiable problems. Funsat is intended to be reasonably efficient for practical problems and convenient to use as a constraint-solving backend in other software. Version 0.6 is available from Hackage: * http://hackage.haskell.org/cgi-bin/hackage-scripts/package/funsat New in 0.6: * A representation for logical circuits (and, or, not, onlyif, iff, if-then-else) supporting efficient conversion to CNF (for solving) has been added. * Now uses the BSD3 license. Please report any bugs to the github page linked from hackage. Denis From mpm at alumni.caltech.edu Fri Apr 17 19:33:44 2009 From: mpm at alumni.caltech.edu (Michael P Mossey) Date: Fri Apr 17 19:20:21 2009 Subject: [Haskell-cafe] Parsec question In-Reply-To: <49E8AD0F.9020803@alumni.caltech.edu> References: <49E7F7B6.7020506@alumni.caltech.edu> <40a414c20904162347l650eb9c6x448cf7eeffc1da25@mail.gmail.com> <49E83557.8000002@alumni.caltech.edu> <40a414c20904170106g542bc933k148563d1f2a00443@mail.gmail.com> <42784f260904170355w7144b9b8w56873135f4efc429@mail.gmail.com> <49E8AD0F.9020803@alumni.caltech.edu> Message-ID: <49E911D8.2080806@alumni.caltech.edu> I've just about got this parser working, but wondering about something. Turns out I need "try" inside the "lookahead" here. parseText :: Parser String parseText = manyTill anyChar $ lookAhead (try (string "//")) Without try, if I give it an input with a single slash, like "some/text" It stops with the error "unexpected t; expecting //" I'm curious why that happens when lookAhead is used with manyTill like this. I was under the impression that if the end parser given to manyTill failed, then manyTill would just continue with the main parser. Apparently there are two ways to fail: in some contexts, failing means that manyTill will just continue. In other contexts, such as the one above, there is some sense in which 'string' demands the entire string to be present. Can anyone explain? Thanks, Mike From sjoerd at w3future.com Fri Apr 17 20:48:51 2009 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Fri Apr 17 20:35:18 2009 Subject: [Haskell-cafe] Code Golf In-Reply-To: <34485EA1-D608-4174-8364-48BC185F4DDE@informatik.uni-kiel.de> References: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> <1bc51a990904151959k4cfc156fx682f4242ea78f56e@mail.gmail.com> <34485EA1-D608-4174-8364-48BC185F4DDE@informatik.uni-kiel.de> Message-ID: Hi, This one works for all 3 examples you gave: diag = concat . takeWhile (not.null) . foldr1 (flip $ zipWith (flip (++)) . ([]:)) . map ((++ repeat []) . map (:[])) or, using Matt Hellige's pointless fun http://matt.immute.net/content/pointless-fun diag = foldr1 (zipWith (++) $. id ~> ([]:) ~> id) $. map (++ repeat []) ~> takeWhile (not.null) $. (map.map) (:[]) ~> concat I think the second one is quite readable, thanks to Matt's notation. The essential part is up front, and the pre- and post-transformations that belong to each other can be grouped. greetings, -- Sjoerd Visscher sjoerd@w3future.com From daniel.is.fischer at web.de Fri Apr 17 20:50:33 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Apr 17 20:37:08 2009 Subject: [Haskell-cafe] Parsec question In-Reply-To: <49E911D8.2080806@alumni.caltech.edu> References: <49E7F7B6.7020506@alumni.caltech.edu> <49E8AD0F.9020803@alumni.caltech.edu> <49E911D8.2080806@alumni.caltech.edu> Message-ID: <200904180250.33428.daniel.is.fischer@web.de> Am Samstag 18 April 2009 01:33:44 schrieb Michael P Mossey: > I've just about got this parser working, but wondering about something. > Turns out I need "try" inside the "lookahead" here. > > parseText :: Parser String > parseText = manyTill anyChar $ lookAhead (try (string "//")) > > Without try, if I give it an input with a single slash, like > > "some/text" > > It stops with the error "unexpected t; expecting //" > > > I'm curious why that happens when lookAhead is used with manyTill like > this. I was under the impression that if the end parser given to manyTill > failed, then manyTill would just continue with the main parser. Apparently > there are two ways to fail: in some contexts, failing means that manyTill > will just continue. In other contexts, such as the one above, there is some > sense in which 'string' demands the entire string to be present. Can anyone > explain? > Looking at the source: manyTill :: GenParser tok st a -> GenParser tok st end -> GenParser tok st [a] manyTill p end = scan where scan = do{ end; return [] } <|> do{ x <- p; xs <- scan; return (x:xs) } if end fails after consuming some input, manyTill p end fails. lookAhead :: GenParser tok st a -> GenParser tok st a lookAhead p = do{ state <- getParserState ; x <- p ; setParserState state ; return x } lookAhead fails if p fails, but if p fails, the state is not reset, so if p fails after consuming some input, like in your example "some/text", where lookAhead (string "//") consumes the slash and fails because the second expected slash is missing, that is not put back and since something is consumed, the second branch of scan in manyTill isn't tried. You could also have keyword = try $ do string "//" kw <- many1 keywordChar return (Keyword kw) parseText = manyTill anyChar (lookAhead keyword) Seems cleaner to have the slashes in keyword. > Thanks, > Mike > Cheers, Daniel From dbueno at gmail.com Fri Apr 17 22:38:54 2009 From: dbueno at gmail.com (Denis Bueno) Date: Fri Apr 17 22:25:14 2009 Subject: [Haskell-cafe] Synchronising cabal package version with self-reported version Message-ID: <6dbd4d000904171938o942a9f6ia9b92d63950909ad@mail.gmail.com> Hi all, In a command-line app of mine I want to have a --version flag, like many GNU apps do to report their version. The only way I know to provide the version number is to hardcode it in the source code somewhere. That means I have the version number in two places: the .cabal file and the source code. I just know that one day they'll get unsynchronised, and --version will be wrong. Is there any way to put the version number in _one_ place, and have both the .cabal and source refer to it? Or even any easier way to synchronise both version numbers? Thanks, Denis From dons at galois.com Fri Apr 17 22:41:47 2009 From: dons at galois.com (Don Stewart) Date: Fri Apr 17 22:29:17 2009 Subject: [Haskell-cafe] Synchronising cabal package version with self-reported version In-Reply-To: <6dbd4d000904171938o942a9f6ia9b92d63950909ad@mail.gmail.com> References: <6dbd4d000904171938o942a9f6ia9b92d63950909ad@mail.gmail.com> Message-ID: <20090418024147.GL22360@whirlpool.galois.com> dbueno: > Hi all, > > In a command-line app of mine I want to have a --version flag, like > many GNU apps do to report their version. The only way I know to > provide the version number is to hardcode it in the source code > somewhere. That means I have the version number in two places: the > .cabal file and the source code. I just know that one day they'll get > unsynchronised, and --version will be wrong. > > Is there any way to put the version number in _one_ place, and have > both the .cabal and source refer to it? Or even any easier way to > synchronise both version numbers? Yes, cabal provides support for this. Here's how we do that in xmonad. In your program, import the magic module Paths_$progname: import Paths_xmonad (version) ["--version"] -> putStrLn ("xmonad " ++ showVersion version) which provides many fields from the .cabal file used to compile the program. In your .cabal file , have something like: name: xmonad version: 0.8.1 Problem solved :) Look in $ vim dist/build/autogen/Paths_xmonad.hs to see what you get to play with: module Paths_xmonad ( version, getBinDir, getLibDir, getDataDir, getLibexecDir, getDataFileName ) where import Data.Version (Version(..)) import System.Environment (getEnv) version :: Version version = Version {versionBranch = [0,8,1], versionTags = []} bindir, libdir, datadir, libexecdir :: FilePath bindir = "/home/dons/.cabal/bin" libdir = "/home/dons/.cabal/lib/xmonad-0.8.1/ghc-6.10.1" datadir = "/home/dons/.cabal/share/xmonad-0.8.1" libexecdir = "/home/dons/.cabal/libexec" getBinDir, getLibDir, getDataDir, getLibexecDir :: IO FilePath getBinDir = catch (getEnv "xmonad_bindir") (\_ -> return bindir) getLibDir = catch (getEnv "xmonad_libdir") (\_ -> return libdir) getDataDir = catch (getEnv "xmonad_datadir") (\_ -> return datadir) getLibexecDir = catch (getEnv "xmonad_libexecdir") (\_ -> return libexecdir) getDataFileName :: FilePath -> IO FilePath getDataFileName name = do dir <- getDataDir return (dir ++ "/" ++ name) -- Don From gue.schmidt at web.de Fri Apr 17 22:51:05 2009 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FC=3Fnther_Schmidt?=) Date: Fri Apr 17 22:37:36 2009 Subject: [Haskell-cafe] Debugging a RecSel Error Message-ID: Hi all, I'm trying to find the spot in my source code that triggered a RecSel Exception ("No match in record selector From dbueno at gmail.com Fri Apr 17 23:08:16 2009 From: dbueno at gmail.com (Denis Bueno) Date: Fri Apr 17 22:54:35 2009 Subject: [Haskell-cafe] Synchronising cabal package version with self-reported version In-Reply-To: <20090418024147.GL22360@whirlpool.galois.com> References: <6dbd4d000904171938o942a9f6ia9b92d63950909ad@mail.gmail.com> <20090418024147.GL22360@whirlpool.galois.com> Message-ID: <6dbd4d000904172008w170322c3xce3b73be2e3d759c@mail.gmail.com> On Fri, Apr 17, 2009 at 20:41, Don Stewart wrote: > dbueno: >> Hi all, >> >> In a command-line app of mine I want to have a --version flag, like >> many GNU apps do to report their version. ?The only way I know to >> provide the version number is to hardcode it in the source code >> somewhere. ?That means I have the version number in two places: the >> .cabal file and the source code. ?I just know that one day they'll get >> unsynchronised, and --version will be wrong. >> >> Is there any way to put the version number in _one_ place, and have >> both the .cabal and source refer to it? ?Or even any easier way to >> synchronise both version numbers? > > Yes, cabal provides support for this. Here's how we do that in xmonad. > > In your program, import the magic module Paths_$progname: > > ? ?import Paths_xmonad (version) > > ? ? ? ?["--version"] ? ? ? ? -> putStrLn ("xmonad " ++ showVersion version) > > which provides many fields from the .cabal file used to compile the > program. Awesome! Thanks. This is exactly what I was hoping for. Denis From wren at freegeek.org Fri Apr 17 23:20:56 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri Apr 17 23:07:16 2009 Subject: [Haskell-cafe] Computing a sorted list of products lazily In-Reply-To: References: Message-ID: <49E94718.9080102@freegeek.org> Jason Dagit wrote: > Hello, > > A colleague of mine recently asked if I knew of a lazy way to solve > the following problem: > Given two sets of sorted floating point numbers, can we lazily > generate a sorted list of the products from their Cartesian product? > > The algorithm should return the same result as: > sortProduct a b = sort [ x * y | x <- a, y <- b ] > > But, my friend is not satisfied with the strictness of sort. In > particular, he doesn't want to have to hold the whole list in memory > to sort it. He would like to compute the results one product at a > time and in the correct order. The algorithm you're looking for is called "(lazy) cube pruning" and is quite common in machine translation. If you're willing to slog through MT papers, this one[1] gives a decent introduction as I recall. The algorithm works for any monotone combination function. The basic idea is to do a frontier search on the cartesian grid. We know a priori that the first elements of each list will give the "best" combination value. We return that value as the first of our new list, and mark it off on the grid (not really), we then look at the next element for each list and compute the combination values for each of the new fringe cells, and store them in a heap. Pick the best value out of the heap and return it as the next element of the list, 'mark it off' on the grid and explore the new fringe. Because the combination function is monotone, this search strategy guarantees you'll encounter every combination values in the right order to return them with minimal delay. The only downside is that you need to maintain the heap of seen values that aren't ready to be returned yet (which can grow quite large in the worst case). For MT systems where this can really be a problem, the cube search strategy is often integrated with beam search (i.e. if the heap grows larger than some size limit then the "worst" values start dropping out of the bottom)--- hence the name cube *pruning*. If you don't feel encumbered by the LGPL, we have a Java implementation of the full algorithm already. Your use case is much simpler than the variant necessary for MT, but the reference implementation can be quite helpful. Feel free to contact me off-list if you're interested, I can point you to our repository and where the algorithm is in the morass of code. [1] http://www.cis.upenn.edu/~lhuang3/acl-cube.pdf -- Live well, ~wren From atze at cs.uu.nl Sat Apr 18 10:03:52 2009 From: atze at cs.uu.nl (atze@cs.uu.nl) Date: Sat Apr 18 09:50:10 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release Message-ID: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> Utrecht Haskell Compiler -- first release, version 1.0.0 ======================================================== The UHC team is happy to announce the first public release of the Utrecht Haskell Compiler (UHC). UHC supports almost all Haskell98 features plus many experimental extensions. The compiler runs on MacOSX, Windows (cygwin), and various Unix flavors. Features: * Multiple backends, including a bytecode interpreter backend and a GRIN based, full program analysing backend, both via C. * Experimental language extensions, some of which have not been implemented before. * Implementation via attribute grammars and other high-level tools. * Ease of experimentation with language variants, thanks to an aspect-oriented internal organisation. Getting started & Download -------------------------- UHC is available for download as source distribution via the UHC home page: http://www.cs.uu.nl/wiki/UHC Here you will also find instructions to get started. Status of the implementation ---------------------------- Like any university project UHC is very much work in progress. We feel that it is mature and stable enough to offer to the public, but much work still needs to be done; hence we welcome contributions by others. UHC grew out of our Haskell compiler project (called Essential Haskell Compiler, or EHC) over the past 5 years. UHC internally is organised as a combination of separate aspects, which makes UHC very suitable to experiment with; it is relatively easy to build compilers for sublanguages, or to generate related tools such as documentation generators, all from the same code base. Extensions to the language can be described separately, and be switched on or of as need arises. Warning ------- Although we think that the compiler is stable enough to compile subtantial Haskell programs, we do not recommend yet to use it for any serious development work in Haskell. We ourselves use the GHC as a development platform! We think however that it provides a great platform for experimenting with language implementations, language extensions, etc. Mailing lists ------------- For UHC users and developers respectively: http://mail.cs.uu.nl/mailman/listinfo/uhc-users http://mail.cs.uu.nl/mailman/listinfo/uhc-developers Bug reporting ------------- Please report bugs at: http://code.google.com/p/uhc/issues/list The UHC Team -- Atze Dijkstra, Department of Information and Computing Sciences. /|\ Utrecht University, PO Box 80089, 3508 TB Utrecht, Netherlands. / | \ Tel.: +31-30-2534118/1454 | WWW : http://www.cs.uu.nl/~atze . /--| \ Fax : +31-30-2513971 .... | Email: atze@cs.uu.nl ............ / |___\ From nowgate at yahoo.com Sat Apr 18 10:56:20 2009 From: nowgate at yahoo.com (michael rice) Date: Sat Apr 18 10:42:39 2009 Subject: [Haskell-cafe] General function to count list elements? Message-ID: <709909.74044.qm@web31107.mail.mud.yahoo.com> Is there a general function to count list elements. I'm trying this count :: a -> [a] -> Int count x ys = length (filter (== x) ys) with this error upon loading ============= [michael@localhost ~]$ ghci count GHCi, version 6.10.1: 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???????????? ( count.hs, interpreted ) count.hs:2:29: ??? Could not deduce (Eq a) from the context () ????? arising from a use of `==' at count.hs:2:29-32 ??? Possible fix: ????? add (Eq a) to the context of the type signature for `count' ??? In the first argument of `filter', namely `(== x)' ??? In the first argument of `length', namely `(filter (== x) ys)' ??? In the expression: length (filter (== x) ys) Failed, modules loaded: none. Prelude> ============= Not sure what it's trying to tell me other than I need an (Eq a) somewhere. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090418/e5669273/attachment.htm From ekirpichov at gmail.com Sat Apr 18 11:03:44 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sat Apr 18 10:50:02 2009 Subject: [Haskell-cafe] General function to count list elements? In-Reply-To: <709909.74044.qm@web31107.mail.mud.yahoo.com> References: <709909.74044.qm@web31107.mail.mud.yahoo.com> Message-ID: <5e0214850904180803v281bc042t519dfd3e92e0e0ca@mail.gmail.com> What should count (\x -> x) (replicate 10 (\y -> if 1==1 then y else undefined)) return? 2009/4/18 michael rice : > Is there a general function to count list elements. I'm trying this > > count :: a -> [a] -> Int > count x ys = length (filter (== x) ys) > > with this error upon loading > > ============= > > [michael@localhost ~]$ ghci count > GHCi, version 6.10.1: 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???????????? ( count.hs, interpreted ) > > count.hs:2:29: > ??? Could not deduce (Eq a) from the context () > ????? arising from a use of `==' at count.hs:2:29-32 > ??? Possible fix: > ????? add (Eq a) to the context of the type signature for `count' > ??? In the first argument of `filter', namely `(== x)' > ??? In the first argument of `length', namely `(filter (== x) ys)' > ??? In the expression: length (filter (== x) ys) > Failed, modules loaded: none. > Prelude> > > ============= > > Not sure what it's trying to tell me other than I need an (Eq a) somewhere. > > Michael > > > > > _______________________________________________ > 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 bulat.ziganshin at gmail.com Sat Apr 18 11:08:29 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Apr 18 10:54:59 2009 Subject: [Haskell-cafe] General function to count list elements? In-Reply-To: <709909.74044.qm@web31107.mail.mud.yahoo.com> References: <709909.74044.qm@web31107.mail.mud.yahoo.com> Message-ID: <958861961.20090418190829@gmail.com> Hello michael, Saturday, April 18, 2009, 6:56:20 PM, you wrote: > Is there a general function to count list elements. I'm trying this you should add Eq restriction to type declaration since "==" operation belomngs to Eq class and your function may work only with types supporting comparision: count :: (Eq a) => a -> [a] -> Int -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From nowgate at yahoo.com Sat Apr 18 11:30:04 2009 From: nowgate at yahoo.com (michael rice) Date: Sat Apr 18 11:16:23 2009 Subject: [Haskell-cafe] General function to count list elements? Message-ID: <736016.58929.qm@web31106.mail.mud.yahoo.com> Though I haven't tried it out, it's trying to use my function to count functions. The first argument is the identity function. The second argument is a list of a different form of the identity function. Though the two identity functions, given the same input, would produce the same output, I doubt they would be equal. So my guess at an answer would be zero. Michael --- On Sat, 4/18/09, Eugene Kirpichov wrote: From: Eugene Kirpichov Subject: Re: [Haskell-cafe] General function to count list elements? To: "michael rice" Cc: haskell-cafe@haskell.org Date: Saturday, April 18, 2009, 11:03 AM What should count (\x -> x) (replicate 10 (\y -> if 1==1 then y else undefined)) return? 2009/4/18 michael rice : > Is there a general function to count list elements. I'm trying this > > count :: a -> [a] -> Int > count x ys = length (filter (== x) ys) > > with this error upon loading > > ============= > > [michael@localhost ~]$ ghci count > GHCi, version 6.10.1: 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???????????? ( count.hs, interpreted ) > > count.hs:2:29: > ??? Could not deduce (Eq a) from the context () > ????? arising from a use of `==' at count.hs:2:29-32 > ??? Possible fix: > ????? add (Eq a) to the context of the type signature for `count' > ??? In the first argument of `filter', namely `(== x)' > ??? In the first argument of `length', namely `(filter (== x) ys)' > ??? In the expression: length (filter (== x) ys) > Failed, modules loaded: none. > Prelude> > > ============= > > Not sure what it's trying to tell me other than I need an (Eq a) somewhere. > > Michael > > > > > _______________________________________________ > 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/20090418/c87f3589/attachment.htm From ekirpichov at gmail.com Sat Apr 18 11:39:41 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sat Apr 18 11:26:00 2009 Subject: [Haskell-cafe] General function to count list elements? In-Reply-To: <736016.58929.qm@web31106.mail.mud.yahoo.com> References: <736016.58929.qm@web31106.mail.mud.yahoo.com> Message-ID: <5e0214850904180839w452394f8vcc78dcf2d606db52@mail.gmail.com> Could you then provide an example of two functions that *are* equal, or, even better, a definition of equality for arbitrary functions? Since Haskell may be compiled into C, this must be a definition that is implementable in C. 2009/4/18 michael rice : > Though I haven't tried it out, it's trying to use my function to count > functions. > > The first argument is the identity function. > > The second argument is a list of a different form of the identity function. > > Though the two identity functions, given the same input, would produce the > same output, I doubt they would be equal. > > So my guess at an answer would be zero. > > Michael > > --- On Sat, 4/18/09, Eugene Kirpichov wrote: > > From: Eugene Kirpichov > Subject: Re: [Haskell-cafe] General function to count list elements? > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Saturday, April 18, 2009, 11:03 AM > > What should > > count (\x -> x) (replicate 10 (\y -> if 1==1 then y else undefined)) > > return? > > 2009/4/18 michael rice : >> Is there a general function to count list elements. I'm trying this >> >> count :: a -> [a] -> Int >> count x ys = length (filter (== x) ys) >> >> with this error upon loading >> >> ============= >> >> [michael@localhost ~]$ ghci count >> GHCi, version 6.10.1: 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???????????? ( count.hs, interpreted ) >> >> count.hs:2:29: >> ??? Could not deduce (Eq a) from the context () >> ????? arising from a use of `==' at count.hs:2:29-32 >> ??? Possible fix: >> ????? add (Eq a) to the context of the type signature for `count' >> ??? In the first argument of `filter', namely `(== x)' >> ??? In the first argument of `length', namely `(filter (== x) ys)' >> ??? In the expression: length (filter (== x) ys) >> Failed, modules loaded: none. >> Prelude> >> >> ============= >> >> Not sure what it's trying to tell me other than I need an (Eq a) >> somewhere. >> >> Michael >> >> >> >> >> _______________________________________________ >> 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 john at n-brain.net Sat Apr 18 12:02:51 2009 From: john at n-brain.net (John A. De Goes) Date: Sat Apr 18 11:49:12 2009 Subject: [Haskell-cafe] General function to count list elements? In-Reply-To: <5e0214850904180839w452394f8vcc78dcf2d606db52@mail.gmail.com> References: <736016.58929.qm@web31106.mail.mud.yahoo.com> <5e0214850904180839w452394f8vcc78dcf2d606db52@mail.gmail.com> Message-ID: Two functions are equal iff they have the same domain and range and the same outputs for the same inputs. Simple to state, but extremely difficult to implement in a useful way, and impossible to implement in a perfect way. If you had a compiler or algorithm capable of determining function equality, you could use it to prove or disprove arbitrary theorems in mathematics. Regards, John A. De Goes N-BRAIN, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Apr 18, 2009, at 9:39 AM, Eugene Kirpichov wrote: > Could you then provide an example of two functions that *are* equal, > or, even better, a definition of equality for arbitrary functions? > Since Haskell may be compiled into C, this must be a definition that > is implementable in C. > > 2009/4/18 michael rice : >> Though I haven't tried it out, it's trying to use my function to >> count >> functions. >> >> The first argument is the identity function. >> >> The second argument is a list of a different form of the identity >> function. >> >> Though the two identity functions, given the same input, would >> produce the >> same output, I doubt they would be equal. >> >> So my guess at an answer would be zero. >> >> Michael >> >> --- On Sat, 4/18/09, Eugene Kirpichov wrote: >> >> From: Eugene Kirpichov >> Subject: Re: [Haskell-cafe] General function to count list elements? >> To: "michael rice" >> Cc: haskell-cafe@haskell.org >> Date: Saturday, April 18, 2009, 11:03 AM >> >> What should >> >> count (\x -> x) (replicate 10 (\y -> if 1==1 then y else undefined)) >> >> return? >> >> 2009/4/18 michael rice : >>> Is there a general function to count list elements. I'm trying this >>> >>> count :: a -> [a] -> Int >>> count x ys = length (filter (== x) ys) >>> >>> with this error upon loading >>> >>> ============= >>> >>> [michael@localhost ~]$ ghci count >>> GHCi, version 6.10.1: 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 ( count.hs, interpreted ) >>> >>> count.hs:2:29: >>> Could not deduce (Eq a) from the context () >>> arising from a use of `==' at count.hs:2:29-32 >>> Possible fix: >>> add (Eq a) to the context of the type signature for `count' >>> In the first argument of `filter', namely `(== x)' >>> In the first argument of `length', namely `(filter (== x) ys)' >>> In the expression: length (filter (== x) ys) >>> Failed, modules loaded: none. >>> Prelude> >>> >>> ============= >>> >>> Not sure what it's trying to tell me other than I need an (Eq a) >>> somewhere. >>> >>> Michael >>> >>> >>> >>> >>> _______________________________________________ >>> 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 > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ekirpichov at gmail.com Sat Apr 18 12:21:20 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sat Apr 18 12:07:39 2009 Subject: [Haskell-cafe] General function to count list elements? In-Reply-To: References: <736016.58929.qm@web31106.mail.mud.yahoo.com> <5e0214850904180839w452394f8vcc78dcf2d606db52@mail.gmail.com> Message-ID: <5e0214850904180921w72b70095j42c1259109dcf09@mail.gmail.com> Well, this definition, although correct, contradicts the OP's claim that \x->x /= \y->if 1==1 then y else undefined :) I'm leading the OP to the thought that necessity Eq constraint and lack of an Eq instance for functions (and thus non-existence of a universally polymorphic 'count' function) is something dictated by the nature of the world, not by the nature of Haskell. 2009/4/18 John A. De Goes : > > Two functions are equal iff they have the same domain and range and the same > outputs for the same inputs. Simple to state, but extremely difficult to > implement in a useful way, and impossible to implement in a perfect way. > > If you had a compiler or algorithm capable of determining function equality, > you could use it to prove or disprove arbitrary theorems in mathematics. > > Regards, > > John A. De Goes > N-BRAIN, Inc. > The Evolution of Collaboration > > http://www.n-brain.net ? ?| ? ?877-376-2724 x 101 > > On Apr 18, 2009, at 9:39 AM, Eugene Kirpichov wrote: > >> Could you then provide an example of two functions that *are* equal, >> or, even better, a definition of equality for arbitrary functions? >> Since Haskell may be compiled into C, this must be a definition that >> is implementable in C. >> >> 2009/4/18 michael rice : >>> >>> Though I haven't tried it out, it's trying to use my function to count >>> functions. >>> >>> The first argument is the identity function. >>> >>> The second argument is a list of a different form of the identity >>> function. >>> >>> Though the two identity functions, given the same input, would produce >>> the >>> same output, I doubt they would be equal. >>> >>> So my guess at an answer would be zero. >>> >>> Michael >>> >>> --- On Sat, 4/18/09, Eugene Kirpichov wrote: >>> >>> From: Eugene Kirpichov >>> Subject: Re: [Haskell-cafe] General function to count list elements? >>> To: "michael rice" >>> Cc: haskell-cafe@haskell.org >>> Date: Saturday, April 18, 2009, 11:03 AM >>> >>> What should >>> >>> count (\x -> x) (replicate 10 (\y -> if 1==1 then y else undefined)) >>> >>> return? >>> >>> 2009/4/18 michael rice : >>>> >>>> Is there a general function to count list elements. I'm trying this >>>> >>>> count :: a -> [a] -> Int >>>> count x ys = length (filter (== x) ys) >>>> >>>> with this error upon loading >>>> >>>> ============= >>>> >>>> [michael@localhost ~]$ ghci count >>>> GHCi, version 6.10.1: 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 ? ? ? ? ? ? ( count.hs, interpreted ) >>>> >>>> count.hs:2:29: >>>> ? ?Could not deduce (Eq a) from the context () >>>> ? ? ?arising from a use of `==' at count.hs:2:29-32 >>>> ? ?Possible fix: >>>> ? ? ?add (Eq a) to the context of the type signature for `count' >>>> ? ?In the first argument of `filter', namely `(== x)' >>>> ? ?In the first argument of `length', namely `(filter (== x) ys)' >>>> ? ?In the expression: length (filter (== x) ys) >>>> Failed, modules loaded: none. >>>> Prelude> >>>> >>>> ============= >>>> >>>> Not sure what it's trying to tell me other than I need an (Eq a) >>>> somewhere. >>>> >>>> Michael >>>> >>>> >>>> >>>> >>>> _______________________________________________ >>>> 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 >> _______________________________________________ >> 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 > -- Eugene Kirpichov Web IR developer, market.yandex.ru From nowgate at yahoo.com Sat Apr 18 12:27:45 2009 From: nowgate at yahoo.com (michael rice) Date: Sat Apr 18 12:14:04 2009 Subject: [Haskell-cafe] General function to count list elements? Message-ID: <858747.3995.qm@web31106.mail.mud.yahoo.com> I know functions can be compared in Scheme Welcome to DrScheme, version 4.1 [3m]. Language: Swindle; memory limit: 128 megabytes. > (equal? equal? equal?) #t > but apparently not in Haskell [michael@localhost ~]$ ghci GHCi, version 6.10.1: http://www.haskell.org/ghc/? :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude> (==) (==) (==) :1:0: ??? No instance for (Eq (a -> a -> Bool)) ????? arising from a use of `==' at :1:0-13 ??? Possible fix: add an instance declaration for (Eq (a -> a -> Bool)) ??? In the expression: (==) (==) (==) ??? In the definition of `it': it = (==) (==) (==) Prelude> though I'm new at Haskell and may not be posing the question properly. I would think a language with 1st-class support for functions would certainly include comparing them. To compare two functions in C, I would compare their machine addresses. Michael --- On Sat, 4/18/09, Eugene Kirpichov wrote: From: Eugene Kirpichov Subject: Re: [Haskell-cafe] General function to count list elements? To: "michael rice" Cc: haskell-cafe@haskell.org Date: Saturday, April 18, 2009, 11:39 AM Could you then provide an example of two functions that *are* equal, or, even better, a definition of equality for arbitrary functions? Since Haskell may be compiled into C, this must be a definition that is implementable in C. 2009/4/18 michael rice : > Though I haven't tried it out, it's trying to use my function to count > functions. > > The first argument is the identity function. > > The second argument is a list of a different form of the identity function. > > Though the two identity functions, given the same input, would produce the > same output, I doubt they would be equal. > > So my guess at an answer would be zero. > > Michael > > --- On Sat, 4/18/09, Eugene Kirpichov wrote: > > From: Eugene Kirpichov > Subject: Re: [Haskell-cafe] General function to count list elements? > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Saturday, April 18, 2009, 11:03 AM > > What should > > count (\x -> x) (replicate 10 (\y -> if 1==1 then y else undefined)) > > return? > > 2009/4/18 michael rice : >> Is there a general function to count list elements. I'm trying this >> >> count :: a -> [a] -> Int >> count x ys = length (filter (== x) ys) >> >> with this error upon loading >> >> ============= >> >> [michael@localhost ~]$ ghci count >> GHCi, version 6.10.1: 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???????????? ( count.hs, interpreted ) >> >> count.hs:2:29: >> ??? Could not deduce (Eq a) from the context () >> ????? arising from a use of `==' at count.hs:2:29-32 >> ??? Possible fix: >> ????? add (Eq a) to the context of the type signature for `count' >> ??? In the first argument of `filter', namely `(== x)' >> ??? In the first argument of `length', namely `(filter (== x) ys)' >> ??? In the expression: length (filter (== x) ys) >> Failed, modules loaded: none. >> Prelude> >> >> ============= >> >> Not sure what it's trying to tell me other than I need an (Eq a) >> somewhere. >> >> Michael >> >> >> >> >> _______________________________________________ >> 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090418/03241f34/attachment.htm From ekirpichov at gmail.com Sat Apr 18 12:39:29 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sat Apr 18 12:25:48 2009 Subject: [Haskell-cafe] General function to count list elements? In-Reply-To: <858747.3995.qm@web31106.mail.mud.yahoo.com> References: <858747.3995.qm@web31106.mail.mud.yahoo.com> Message-ID: <5e0214850904180939t4104854bwa1fc57de0c831d20@mail.gmail.com> 2009/4/18 michael rice : > I know functions can be compared in Scheme > > Welcome to DrScheme, version 4.1 [3m]. > Language: Swindle; memory limit: 128 megabytes. >> (equal? equal? equal?) > #t >> > That's not the functions being compared, but the memory addresses of the code implementing them. If your goal is comparing functions to answer a question "Are these two values indistinguishable?", equal? doesn't help you, because it may answer 'false' even if these two values are indistinguishable from a mathematical point of view. > > but apparently not in Haskell > > [michael@localhost ~]$ ghci > GHCi, version 6.10.1: http://www.haskell.org/ghc/? :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > Prelude> (==) (==) (==) > > :1:0: > ??? No instance for (Eq (a -> a -> Bool)) > ????? arising from a use of `==' at :1:0-13 > ??? Possible fix: add an instance declaration for (Eq (a -> a -> Bool)) > ??? In the expression: (==) (==) (==) > ??? In the definition of `it': it = (==) (==) (==) > Prelude> > > though I'm new at Haskell and may not be posing the question properly. > > I would think a language with 1st-class support for functions would > certainly include comparing them. > Again, this is first-class support for memory addresses of code representing functions. > To compare two functions in C, I would compare their machine addresses. > Why would you need that at all? > Michael > > > --- On Sat, 4/18/09, Eugene Kirpichov wrote: > > From: Eugene Kirpichov > Subject: Re: [Haskell-cafe] General function to count list elements? > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Saturday, April 18, 2009, 11:39 AM > > Could you then provide an example of two functions that *are* equal, > or, even better, a definition of equality for arbitrary functions? > Since Haskell may be compiled into C, this must be a definition that > is implementable in C. > > 2009/4/18 michael rice : >> Though I haven't tried it out, it's trying to use my function to count >> functions. >> >> The first argument is the identity function. >> >> The second argument is a list of a different form of the identity >> function. >> >> Though the two identity functions, given the same input, would produce the >> same output, I doubt they would be equal. >> >> So my guess at an answer would be zero. >> >> Michael >> >> --- On Sat, 4/18/09, Eugene Kirpichov wrote: >> >> From: Eugene Kirpichov >> Subject: Re: [Haskell-cafe] General function to count list elements? >> To: "michael rice" >> Cc: haskell-cafe@haskell.org >> Date: Saturday, April 18, 2009, 11:03 AM >> >> What should >> >> count (\x -> x) (replicate 10 (\y -> if 1==1 then y else undefined)) >> >> return? >> >> 2009/4/18 michael rice : >>> Is there a general function to count list elements. I'm trying this >>> >>> count :: a -> [a] -> Int >>> count x ys = length (filter (== x) ys) >>> >>> with this error upon loading >>> >>> ============= >>> >>> [michael@localhost ~]$ ghci count >>> GHCi, version 6.10.1: 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???????????? ( count.hs, interpreted ) >>> >>> count.hs:2:29: >>> ??? Could not deduce (Eq a) from the context () >>> ????? arising from a use of `==' at count.hs:2:29-32 >>> ??? Possible fix: >>> ????? add (Eq a) to the context of the type signature for `count' >>> ??? In the first argument of `filter', namely `(== x)' >>> ??? In the first argument of `length', namely `(filter (== x) ys)' >>> ??? In the expression: length (filter (== x) ys) >>> Failed, modules loaded: none. >>> Prelude> >>> >>> ============= >>> >>> Not sure what it's trying to tell me other than I need an (Eq a) >>> somewhere. >>> >>> Michael >>> >>> >>> >>> >>> _______________________________________________ >>> 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 > > -- Eugene Kirpichov Web IR developer, market.yandex.ru From magnicida at gmail.com Sat Apr 18 12:45:12 2009 From: magnicida at gmail.com (Juan Pedro Bolivar Puente) Date: Sat Apr 18 12:33:27 2009 Subject: [Haskell-cafe] Re: General function to count list elements? In-Reply-To: <709909.74044.qm@web31107.mail.mud.yahoo.com> References: <709909.74044.qm@web31107.mail.mud.yahoo.com> Message-ID: The problem is that you must note in the type signature the fact that 'a' must be a member of typeclass Eq in order to be able to use == count :: (Eq a) => a -> [a] -> Int count x ys = length (filter (== x) ys) JP michael rice wrote: > Is there a general function to count list elements. I'm trying this > > count :: a -> [a] -> Int > count x ys = length (filter (== x) ys) > > with this error upon loading > > ============= > > [michael@localhost ~]$ ghci count > GHCi, version 6.10.1: 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 ( count.hs, interpreted ) > > count.hs:2:29: > Could not deduce (Eq a) from the context () > arising from a use of `==' at count.hs:2:29-32 > Possible fix: > add (Eq a) to the context of the type signature for `count' > In the first argument of `filter', namely `(== x)' > In the first argument of `length', namely `(filter (== x) ys)' > In the expression: length (filter (== x) ys) > Failed, modules loaded: none. > Prelude> > > ============= > > Not sure what it's trying to tell me other than I need an (Eq a) somewhere. > > Michael > > > > > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ekirpichov at gmail.com Sat Apr 18 12:48:26 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sat Apr 18 12:34:45 2009 Subject: [Haskell-cafe] General function to count list elements? In-Reply-To: <858747.3995.qm@web31106.mail.mud.yahoo.com> References: <858747.3995.qm@web31106.mail.mud.yahoo.com> Message-ID: <5e0214850904180948l114c5936xd850125624476283@mail.gmail.com> Also, having such an equality test will introduce ambiguity and unsoundness, prevent the compiler from certain optimizations etc. For example, should "(+5)==(+5)" be true or false? What about "let f=(+5) in f==f"? If you are declaring the first equality to be true, then you are implying that the compiler must implement extensional equality, which is impossible. Consider let x=5 in (+x)==(+x). If you are declaring it to be false, then you are breaking referential transparency: you can't anymore safely substitute "let x=v in E" with E[x:=v]. C doesn't have these problems because it never declared that it has any form of referential transparency or mathematical soundness; neither does it have closures and currying. Scheme explicitly declares that the result of equal? on functions can't be relied upon. Haskell takes the mathematically sound path: it simply outlaws ambiguities. 2009/4/18 michael rice : > I know functions can be compared in Scheme > > Welcome to DrScheme, version 4.1 [3m]. > Language: Swindle; memory limit: 128 megabytes. >> (equal? equal? equal?) > #t >> > > > but apparently not in Haskell > > [michael@localhost ~]$ ghci > GHCi, version 6.10.1: http://www.haskell.org/ghc/? :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > Prelude> (==) (==) (==) > > :1:0: > ??? No instance for (Eq (a -> a -> Bool)) > ????? arising from a use of `==' at :1:0-13 > ??? Possible fix: add an instance declaration for (Eq (a -> a -> Bool)) > ??? In the expression: (==) (==) (==) > ??? In the definition of `it': it = (==) (==) (==) > Prelude> > > though I'm new at Haskell and may not be posing the question properly. > > I would think a language with 1st-class support for functions would > certainly include comparing them. > > To compare two functions in C, I would compare their machine addresses. > > Michael > > > --- On Sat, 4/18/09, Eugene Kirpichov wrote: > > From: Eugene Kirpichov > Subject: Re: [Haskell-cafe] General function to count list elements? > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Saturday, April 18, 2009, 11:39 AM > > Could you then provide an example of two functions that *are* equal, > or, even better, a definition of equality for arbitrary functions? > Since Haskell may be compiled into C, this must be a definition that > is implementable in C. > > 2009/4/18 michael rice : >> Though I haven't tried it out, it's trying to use my function to count >> functions. >> >> The first argument is the identity function. >> >> The second argument is a list of a different form of the identity >> function. >> >> Though the two identity functions, given the same input, would produce the >> same output, I doubt they would be equal. >> >> So my guess at an answer would be zero. >> >> Michael >> >> --- On Sat, 4/18/09, Eugene Kirpichov wrote: >> >> From: Eugene Kirpichov >> Subject: Re: [Haskell-cafe] General function to count list elements? >> To: "michael rice" >> Cc: haskell-cafe@haskell.org >> Date: Saturday, April 18, 2009, 11:03 AM >> >> What should >> >> count (\x -> x) (replicate 10 (\y -> if 1==1 then y else undefined)) >> >> return? >> >> 2009/4/18 michael rice : >>> Is there a general function to count list elements. I'm trying this >>> >>> count :: a -> [a] -> Int >>> count x ys = length (filter (== x) ys) >>> >>> with this error upon loading >>> >>> ============= >>> >>> [michael@localhost ~]$ ghci count >>> GHCi, version 6.10.1: 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???????????? ( count.hs, interpreted ) >>> >>> count.hs:2:29: >>> ??? Could not deduce (Eq a) from the context () >>> ????? arising from a use of `==' at count.hs:2:29-32 >>> ??? Possible fix: >>> ????? add (Eq a) to the context of the type signature for `count' >>> ??? In the first argument of `filter', namely `(== x)' >>> ??? In the first argument of `length', namely `(filter (== x) ys)' >>> ??? In the expression: length (filter (== x) ys) >>> Failed, modules loaded: none. >>> Prelude> >>> >>> ============= >>> >>> Not sure what it's trying to tell me other than I need an (Eq a) >>> somewhere. >>> >>> Michael >>> >>> >>> >>> >>> _______________________________________________ >>> 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 > > -- Eugene Kirpichov Web IR developer, market.yandex.ru From bulat.ziganshin at gmail.com Sat Apr 18 12:41:41 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Apr 18 12:35:14 2009 Subject: [Haskell-cafe] General function to count list elements? In-Reply-To: <858747.3995.qm@web31106.mail.mud.yahoo.com> References: <858747.3995.qm@web31106.mail.mud.yahoo.com> Message-ID: <1297448770.20090418204141@gmail.com> Hello michael, Saturday, April 18, 2009, 8:27:45 PM, you wrote: so you can use Scheme to derive theorem proofs. useful for exams! :) > I know functions can be compared in Scheme > Welcome to DrScheme, version 4.1 [3m]. > Language: Swindle; memory limit: 128 megabytes. >> (equal? equal? equal?) > #t >> > but apparently not in Haskell > [michael@localhost ~]$ ghci > GHCi, version 6.10.1: http://www.haskell.org/ghc/? :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. Prelude>> (==) (==) (==) > :1:0: > ??? No instance for (Eq (a -> a -> Bool)) > ????? arising from a use of `==' at :1:0-13 > ??? Possible fix: add an instance declaration for (Eq (a -> a -> Bool)) > ??? In the expression: (==) (==) (==) > ??? In the definition of `it': it = (==) (==) (==) Prelude>> > though I'm new at Haskell and may not be posing the question properly. > I would think a language with 1st-class support for functions would > certainly include comparing them. > To compare two functions in C, I would compare their machine addresses. > Michael > --- On Sat, 4/18/09, Eugene Kirpichov wrote: > From: Eugene Kirpichov > Subject: Re: [Haskell-cafe] General function to count list elements? > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Saturday, April 18, 2009, 11:39 AM > Could you then provide an example of two functions that *are* equal, > or, even better, a definition of equality for arbitrary functions? > Since Haskell may be compiled into C, this must be a definition that > is implementable in C. > 2009/4/18 michael rice : >> Though I haven't tried it out, it's trying to use my function to count >> functions. >> >> The first argument is the identity function. >> >> The second argument is a list of a different form of the identity function. >> >> Though the two identity functions, given the same input, would produce the >> same output, I doubt they would be equal. >> >> So my guess at an answer would be zero. >> >> Michael >> >> --- On Sat, 4/18/09, Eugene Kirpichov wrote: >> >> From: Eugene Kirpichov >> Subject: Re: [Haskell-cafe] General function to count list elements? >> To: "michael rice" >> Cc: haskell-cafe@haskell.org >> Date: Saturday, April 18, 2009, 11:03 AM >> >> What should >> >> count (\x -> x) (replicate 10 (\y -> if 1==1 then y else undefined)) >> >> return? >> >> 2009/4/18 michael rice : >>> Is there a general function to count list elements. I'm trying this >>> >>> count :: a -> [a] -> Int >>> count x ys = length (filter (== x) ys) >>> >>> with this error upon loading >>> >>> ============= >>> >>> [michael@localhost ~]$ ghci count >>> GHCi, version 6.10.1: 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???????????? ( count.hs, interpreted ) >>> >>> count.hs:2:29: >>> ??? Could not deduce (Eq a) from the context () >>> ????? arising from a use of `==' at count.hs:2:29-32 >>> ??? Possible fix: >>> ????? add (Eq a) to the context of the type signature for `count' >>> ??? In the first argument of `filter', namely `(== x)' >>> ??? In the first argument of `length', namely `(filter (== x) ys)' >>> ??? In the expression: length (filter (== x) ys) >>> Failed, modules loaded: none. >>> Prelude> >>> >>> ============= >>> >>> Not sure what it's trying to tell me other than I need an (Eq a) >>> somewhere. >>> >>> Michael >>> >>> >>> >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> >> >> >> >> -- >> Eugene Kirpichov >> Web IR developer, market.yandex.ru >> >> -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ryani.spam at gmail.com Sat Apr 18 12:51:46 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sat Apr 18 12:38:04 2009 Subject: [Haskell-cafe] General function to count list elements? In-Reply-To: <858747.3995.qm@web31106.mail.mud.yahoo.com> References: <858747.3995.qm@web31106.mail.mud.yahoo.com> Message-ID: <2f9b2d30904180951u5355b3day5b0b1932f3488296@mail.gmail.com> Haskell is referentially transparent. This enables a whole host of program reasoning and compiler optimization techniques that you can't get in languages without this property; it's hard to explain why it is good until you've been bitten by code that *isn't*. One big consequence of referential transparency is that a whole host of complicated optimizations in other languages are replaced with simple inlining. So one question is, what does this program do? > main = print (count id [id]) The compiler might decide to inline the first id: > main = print (count (\x -> x) [id]) which then, if we are comparing "machine addresses", means they are not equal. I am sure you agree that code that stops working depending on the optimization settings of the compiler is a scary thing! In scheme, which is not referentially transparent, there are several equality primitives. One checks "object identity", whereas another goes into the depths of any structure it is passed and compares the innards. In Haskell, there is *no* concept of "object identity. It just doesn't exist! This means there is no observable difference between 1 and (length [ "hello" ]). There's no observable difference between const and (\x y -> x). In order to make this work, but still be able to use == (which everyone wants), == requires its arguments to be of a type that is comparable for equality; that's what the error message from ghci is saying: On Sat, Apr 18, 2009 at 9:27 AM, michael rice wrote: > ??? No instance for (Eq (a -> a -> Bool)) > ????? arising from a use of `==' at :1:0-13 -- ryan From nowgate at yahoo.com Sat Apr 18 13:11:02 2009 From: nowgate at yahoo.com (michael rice) Date: Sat Apr 18 12:57:22 2009 Subject: [Haskell-cafe] General function to count list elements? Message-ID: <154076.41502.qm@web31106.mail.mud.yahoo.com> > To compare two functions in C, I would compare their machine addresses. > Why would you need that at all? How would *you* do it? Michael ================ --- On Sat, 4/18/09, Eugene Kirpichov wrote: From: Eugene Kirpichov Subject: Re: [Haskell-cafe] General function to count list elements? To: "michael rice" Cc: haskell-cafe@haskell.org Date: Saturday, April 18, 2009, 12:39 PM 2009/4/18 michael rice : > I know functions can be compared in Scheme > > Welcome to DrScheme, version 4.1 [3m]. > Language: Swindle; memory limit: 128 megabytes. >> (equal? equal? equal?) > #t >> > That's not the functions being compared, but the memory addresses of the code implementing them. If your goal is comparing functions to answer a question "Are these two values indistinguishable?", equal? doesn't help you, because it may answer 'false' even if these two values are indistinguishable from a mathematical point of view. > > but apparently not in Haskell > > [michael@localhost ~]$ ghci > GHCi, version 6.10.1: http://www.haskell.org/ghc/? :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > Prelude> (==) (==) (==) > > :1:0: > ??? No instance for (Eq (a -> a -> Bool)) > ????? arising from a use of `==' at :1:0-13 > ??? Possible fix: add an instance declaration for (Eq (a -> a -> Bool)) > ??? In the expression: (==) (==) (==) > ??? In the definition of `it': it = (==) (==) (==) > Prelude> > > though I'm new at Haskell and may not be posing the question properly. > > I would think a language with 1st-class support for functions would > certainly include comparing them. > Again, this is first-class support for memory addresses of code representing functions. > To compare two functions in C, I would compare their machine addresses. > Why would you need that at all? > Michael > > > --- On Sat, 4/18/09, Eugene Kirpichov wrote: > > From: Eugene Kirpichov > Subject: Re: [Haskell-cafe] General function to count list elements? > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Saturday, April 18, 2009, 11:39 AM > > Could you then provide an example of two functions that *are* equal, > or, even better, a definition of equality for arbitrary functions? > Since Haskell may be compiled into C, this must be a definition that > is implementable in C. > > 2009/4/18 michael rice : >> Though I haven't tried it out, it's trying to use my function to count >> functions. >> >> The first argument is the identity function. >> >> The second argument is a list of a different form of the identity >> function. >> >> Though the two identity functions, given the same input, would produce the >> same output, I doubt they would be equal. >> >> So my guess at an answer would be zero. >> >> Michael >> >> --- On Sat, 4/18/09, Eugene Kirpichov wrote: >> >> From: Eugene Kirpichov >> Subject: Re: [Haskell-cafe] General function to count list elements? >> To: "michael rice" >> Cc: haskell-cafe@haskell.org >> Date: Saturday, April 18, 2009, 11:03 AM >> >> What should >> >> count (\x -> x) (replicate 10 (\y -> if 1==1 then y else undefined)) >> >> return? >> >> 2009/4/18 michael rice : >>> Is there a general function to count list elements. I'm trying this >>> >>> count :: a -> [a] -> Int >>> count x ys = length (filter (== x) ys) >>> >>> with this error upon loading >>> >>> ============= >>> >>> [michael@localhost ~]$ ghci count >>> GHCi, version 6.10.1: 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???????????? ( count.hs, interpreted ) >>> >>> count.hs:2:29: >>> ??? Could not deduce (Eq a) from the context () >>> ????? arising from a use of `==' at count.hs:2:29-32 >>> ??? Possible fix: >>> ????? add (Eq a) to the context of the type signature for `count' >>> ??? In the first argument of `filter', namely `(== x)' >>> ??? In the first argument of `length', namely `(filter (== x) ys)' >>> ??? In the expression: length (filter (== x) ys) >>> Failed, modules loaded: none. >>> Prelude> >>> >>> ============= >>> >>> Not sure what it's trying to tell me other than I need an (Eq a) >>> somewhere. >>> >>> Michael >>> >>> >>> >>> >>> _______________________________________________ >>> 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 > > -- Eugene Kirpichov Web IR developer, market.yandex.ru -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090418/bcad90d7/attachment-0001.htm From ekirpichov at gmail.com Sat Apr 18 13:18:25 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sat Apr 18 13:04:42 2009 Subject: [Haskell-cafe] General function to count list elements? In-Reply-To: <154076.41502.qm@web31106.mail.mud.yahoo.com> References: <154076.41502.qm@web31106.mail.mud.yahoo.com> Message-ID: <5e0214850904181018j5e1536cdp315db7722227b352@mail.gmail.com> 2009/4/18 michael rice : >> To compare two functions in C, I would compare their machine addresses. >> > > Why would you need that at all? > > How would *you* do it? Do what? As for comparing functions, I would not do it at all, because comparing functions makes no sense: one way of comparison (extensional equality) is not implementable, whereas the other (object identity) breaks referential transparency and is impossible to reason about and generally doesn't have a single reason to work correctly at all. Object identity has no reason to exist in a language without mutable objects, like Haskell. That's probably the key. As for implementing the count function, I would implement it in the way that people already suggested to you: by putting a constraint onto its type, namely a constraint that makes it polymorphic *over types whose values can be compared for equality*, t.i. over members of the Eq class. This is perfectly correct and does not cause any mathematical unsoundness. > > Michael > > ================ > > --- On Sat, 4/18/09, Eugene Kirpichov wrote: > > From: Eugene Kirpichov > Subject: Re: [Haskell-cafe] General function to count list elements? > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Saturday, April 18, 2009, 12:39 PM > > 2009/4/18 michael rice : >> I know functions can be compared in Scheme >> >> Welcome to DrScheme, version 4.1 [3m]. >> Language: Swindle; memory limit: 128 megabytes. >>> (equal? equal? equal?) >> #t >>> >> > > That's not the functions being compared, but the memory addresses of > the code implementing them. If your goal is comparing functions to > answer a question "Are these two values indistinguishable?", equal? > doesn't help you, because it may answer 'false' even if these two > values are indistinguishable from a mathematical point of view. > >> >> but apparently not in Haskell >> >> [michael@localhost ~]$ ghci >> GHCi, version 6.10.1: http://www.haskell.org/ghc/? :? for help >> Loading package ghc-prim ... linking ... done. >> Loading package integer ... linking ... done. >> Loading package base ... linking ... done. >> Prelude> (==) (==) (==) >> >> :1:0: >> ??? No instance for (Eq (a -> a -> Bool)) >> ????? arising from a use of `==' at :1:0-13 >> ??? Possible fix: add an instance declaration for (Eq (a -> a -> Bool)) >> ??? In the expression: (==) (==) (==) >> ??? In the definition of `it': it = (==) (==) (==) >> Prelude> >> >> though I'm new at Haskell and may not be posing the question properly. >> >> I would think a language with 1st-class support for functions would >> certainly include comparing them. >> > > Again, this is first-class support for memory addresses of code > representing functions. > >> To compare two functions in C, I would compare their machine addresses. >> > > Why would you need that at all? > >> Michael >> >> >> --- On Sat, 4/18/09, Eugene Kirpichov wrote: >> >> From: Eugene Kirpichov >> Subject: Re: [Haskell-cafe] General function to count list elements? >> To: "michael rice" >> Cc: haskell-cafe@haskell.org >> Date: Saturday, April 18, 2009, 11:39 AM >> >> Could you then provide an example of two functions that *are* equal, >> or, even better, a definition of equality for arbitrary functions? >> Since Haskell may be compiled into C, this must be a definition that >> is implementable in C. >> >> 2009/4/18 michael rice : >>> Though I haven't tried it out, it's trying to use my function to count >>> functions. >>> >>> The first argument is the identity function. >>> >>> The second argument is a list of a different form of the identity >>> function. >>> >>> Though the two identity functions, given the same input, would produce >>> the >>> same output, I doubt they would be equal. >>> >>> So my guess at an answer would be zero. >>> >>> Michael >>> >>> --- On Sat, 4/18/09, Eugene Kirpichov wrote: >>> >>> From: Eugene Kirpichov >>> Subject: Re: [Haskell-cafe] General function to count list elements? >>> To: "michael rice" >>> Cc: haskell-cafe@haskell.org >>> Date: Saturday, April 18, 2009, 11:03 AM >>> >>> What should >>> >>> count (\x -> x) (replicate 10 (\y -> if 1==1 then y else undefined)) >>> >>> return? >>> >>> 2009/4/18 michael rice : >>>> Is there a general function to count list elements. I'm trying this >>>> >>>> count :: a -> [a] -> Int >>>> count x ys = length (filter (== x) ys) >>>> >>>> with this error upon loading >>>> >>>> ============= >>>> >>>> [michael@localhost ~]$ ghci count >>>> GHCi, version 6.10.1: 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???????????? ( count.hs, interpreted ) >>>> >>>> count.hs:2:29: >>>> ??? Could not deduce (Eq a) from the context () >>>> ????? arising from a use of `==' at count.hs:2:29-32 >>>> ??? Possible fix: >>>> ????? add (Eq a) to the context of the type signature for `count' >>>> ??? In the first argument of `filter', namely `(== x)' >>>> ??? In the first argument of `length', namely `(filter (== x) ys)' >>>> ??? In the expression: length (filter (== x) ys) >>>> Failed, modules loaded: none. >>>> Prelude> >>>> >>>> ============= >>>> >>>> Not sure what it's trying to tell me other than I need an (Eq a) >>>> somewhere. >>>> >>>> Michael >>>> >>>> >>>> >>>> >>>> _______________________________________________ >>>> 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 >> >> > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru > > -- Eugene Kirpichov Web IR developer, market.yandex.ru From lrpalmer at gmail.com Sat Apr 18 13:20:17 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Sat Apr 18 13:06:34 2009 Subject: [Haskell-cafe] General function to count list elements? In-Reply-To: <154076.41502.qm@web31106.mail.mud.yahoo.com> References: <154076.41502.qm@web31106.mail.mud.yahoo.com> Message-ID: <7ca3f0160904181020m4f6ae846m8a2a2c981826271b@mail.gmail.com> On Sat, Apr 18, 2009 at 11:11 AM, michael rice wrote: > > To compare two functions in C, I would compare their machine addresses. > > > > Why would you need that at all? > > How would *you* do it? Do what? What is the problem? No, I don't mean "comparing two functions". I rather mean, why are you comparing these functions? What question is the comparison answering, and how are you using that answer? Is address comparison really what your code wants, or do you want some stronger property? Luke > > > Michael > > ================ > > --- On *Sat, 4/18/09, Eugene Kirpichov * wrote: > > > From: Eugene Kirpichov > Subject: Re: [Haskell-cafe] General function to count list elements? > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Saturday, April 18, 2009, 12:39 PM > > 2009/4/18 michael rice > >: > > I know functions can be compared in Scheme > > > > Welcome to DrScheme, version 4.1 [3m]. > > Language: Swindle; memory limit: 128 megabytes. > >> (equal? equal? equal?) > > #t > >> > > > > That's not the functions being compared, but the memory addresses of > the code implementing them. If your goal is comparing functions to > answer a question "Are these two values indistinguishable?", equal? > doesn't help you, because it may answer 'false' even if these two > values are indistinguishable from a mathematical point of view. > > > > > but apparently not in Haskell > > > > [michael@localhost ~]$ ghci > > GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help > > Loading package ghc-prim ... linking ... done. > > Loading package integer ... linking ... done. > > Loading package base ... linking ... done. > > Prelude> (==) (==) (==) > > > > :1:0: > > No instance for (Eq (a -> a -> Bool)) > > arising from a use of `==' at :1:0-13 > > Possible fix: add an instance declaration for (Eq (a -> a -> Bool)) > > In the expression: (==) (==) (==) > > In the definition of `it': it = (==) (==) (==) > > Prelude> > > > > though I'm new at Haskell and may not be posing the question properly. > > > > I would think a language with 1st-class support for functions would > > certainly include comparing them. > > > > Again, this is first-class support for memory addresses of code > representing functions. > > > To compare two functions in C, I would compare their machine addresses. > > > > Why would you need that at all? > > > Michael > > > > > > --- On Sat, 4/18/09, Eugene Kirpichov > > wrote: > > > > From: Eugene Kirpichov > > > > Subject: Re: [Haskell-cafe] General function to count list elements? > > To: "michael rice" > > > > Cc: haskell-cafe@haskell.org > > Date: Saturday, April 18, 2009, 11:39 AM > > > > Could you then provide an example of two functions that *are* equal, > > or, even better, a definition of equality for arbitrary functions? > > Since Haskell may be compiled into C, this must be a definition that > > is implementable in C. > > > > 2009/4/18 michael rice > >: > >> Though I haven't tried it out, it's trying to use my function to count > >> functions. > >> > >> The first argument is the identity function. > >> > >> The second argument is a list of a different form of the identity > >> function. > >> > >> Though the two identity functions, given the same input, would produce > the > >> same output, I doubt they would be equal. > >> > >> So my guess at an answer would be zero. > >> > >> Michael > >> > >> --- On Sat, 4/18/09, Eugene Kirpichov > > wrote: > >> > >> From: Eugene Kirpichov > > > >> Subject: Re: [Haskell-cafe] General function to count list elements? > >> To: "michael rice" > > > >> Cc: haskell-cafe@haskell.org > >> Date: Saturday, April 18, 2009, 11:03 AM > >> > >> What should > >> > >> count (\x -> x) (replicate 10 (\y -> if 1==1 then y else undefined)) > >> > >> return? > >> > >> 2009/4/18 michael rice > >: > >>> Is there a general function to count list elements. I'm trying this > >>> > >>> count :: a -> [a] -> Int > >>> count x ys = length (filter (== x) ys) > >>> > >>> with this error upon loading > >>> > >>> ============= > >>> > >>> [michael@localhost ~]$ ghci count > >>> GHCi, version 6.10.1: 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 ( count.hs, interpreted ) > >>> > >>> count.hs:2:29: > >>> Could not deduce (Eq a) from the context () > >>> arising from a use of `==' at count.hs:2:29-32 > >>> Possible fix: > >>> add (Eq a) to the context of the type signature for `count' > >>> In the first argument of `filter', namely `(== x)' > >>> In the first argument of `length', namely `(filter (== x) ys)' > >>> In the expression: length (filter (== x) ys) > >>> Failed, modules loaded: none. > >>> Prelude> > >>> > >>> ============= > >>> > >>> Not sure what it's trying to tell me other than I need an (Eq a) > >>> somewhere. > >>> > >>> Michael > >>> > >>> > >>> > >>> > >>> _______________________________________________ > >>> 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 > > > > > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru > > > > _______________________________________________ > 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/20090418/091b07e9/attachment.htm From nowgate at yahoo.com Sat Apr 18 13:46:19 2009 From: nowgate at yahoo.com (michael rice) Date: Sat Apr 18 13:32:37 2009 Subject: [Haskell-cafe] General function to count list elements? Message-ID: <842644.44242.qm@web31105.mail.mud.yahoo.com> I wasn't comparing functions, you were. I was just trying to answer your questions. I had a count function that worked fine for an enum type, but thought why not go polymorphic with it. So I changed it and got the error I originally inquired about. Thanks. Michael --- On Sat, 4/18/09, Eugene Kirpichov wrote: From: Eugene Kirpichov Subject: Re: [Haskell-cafe] General function to count list elements? To: "michael rice" Cc: haskell-cafe@haskell.org Date: Saturday, April 18, 2009, 1:18 PM 2009/4/18 michael rice : >> To compare two functions in C, I would compare their machine addresses. >> > > Why would you need that at all? > > How would *you* do it? Do what? As for comparing functions, I would not do it at all, because comparing functions makes no sense: one way of comparison (extensional equality) is not implementable, whereas the other (object identity) breaks referential transparency and is impossible to reason about and generally doesn't have a single reason to work correctly at all. Object identity has no reason to exist in a language without mutable objects, like Haskell. That's probably the key. As for implementing the count function, I would implement it in the way that people already suggested to you: by putting a constraint onto its type, namely a constraint that makes it polymorphic *over types whose values can be compared for equality*, t.i. over members of the Eq class. This is perfectly correct and does not cause any mathematical unsoundness. > > Michael > > ================ > > --- On Sat, 4/18/09, Eugene Kirpichov wrote: > > From: Eugene Kirpichov > Subject: Re: [Haskell-cafe] General function to count list elements? > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Saturday, April 18, 2009, 12:39 PM > > 2009/4/18 michael rice : >> I know functions can be compared in Scheme >> >> Welcome to DrScheme, version 4.1 [3m]. >> Language: Swindle; memory limit: 128 megabytes. >>> (equal? equal? equal?) >> #t >>> >> > > That's not the functions being compared, but the memory addresses of > the code implementing them. If your goal is comparing functions to > answer a question "Are these two values indistinguishable?", equal? > doesn't help you, because it may answer 'false' even if these two > values are indistinguishable from a mathematical point of view. > >> >> but apparently not in Haskell >> >> [michael@localhost ~]$ ghci >> GHCi, version 6.10.1: http://www.haskell.org/ghc/? :? for help >> Loading package ghc-prim ... linking ... done. >> Loading package integer ... linking ... done. >> Loading package base ... linking ... done. >> Prelude> (==) (==) (==) >> >> :1:0: >> ??? No instance for (Eq (a -> a -> Bool)) >> ????? arising from a use of `==' at :1:0-13 >> ??? Possible fix: add an instance declaration for (Eq (a -> a -> Bool)) >> ??? In the expression: (==) (==) (==) >> ??? In the definition of `it': it = (==) (==) (==) >> Prelude> >> >> though I'm new at Haskell and may not be posing the question properly. >> >> I would think a language with 1st-class support for functions would >> certainly include comparing them. >> > > Again, this is first-class support for memory addresses of code > representing functions. > >> To compare two functions in C, I would compare their machine addresses. >> > > Why would you need that at all? > >> Michael >> >> >> --- On Sat, 4/18/09, Eugene Kirpichov wrote: >> >> From: Eugene Kirpichov >> Subject: Re: [Haskell-cafe] General function to count list elements? >> To: "michael rice" >> Cc: haskell-cafe@haskell.org >> Date: Saturday, April 18, 2009, 11:39 AM >> >> Could you then provide an example of two functions that *are* equal, >> or, even better, a definition of equality for arbitrary functions? >> Since Haskell may be compiled into C, this must be a definition that >> is implementable in C. >> >> 2009/4/18 michael rice : >>> Though I haven't tried it out, it's trying to use my function to count >>> functions. >>> >>> The first argument is the identity function. >>> >>> The second argument is a list of a different form of the identity >>> function. >>> >>> Though the two identity functions, given the same input, would produce >>> the >>> same output, I doubt they would be equal. >>> >>> So my guess at an answer would be zero. >>> >>> Michael >>> >>> --- On Sat, 4/18/09, Eugene Kirpichov wrote: >>> >>> From: Eugene Kirpichov >>> Subject: Re: [Haskell-cafe] General function to count list elements? >>> To: "michael rice" >>> Cc: haskell-cafe@haskell.org >>> Date: Saturday, April 18, 2009, 11:03 AM >>> >>> What should >>> >>> count (\x -> x) (replicate 10 (\y -> if 1==1 then y else undefined)) >>> >>> return? >>> >>> 2009/4/18 michael rice : >>>> Is there a general function to count list elements. I'm trying this >>>> >>>> count :: a -> [a] -> Int >>>> count x ys = length (filter (== x) ys) >>>> >>>> with this error upon loading >>>> >>>> ============= >>>> >>>> [michael@localhost ~]$ ghci count >>>> GHCi, version 6.10.1: 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???????????? ( count.hs, interpreted ) >>>> >>>> count.hs:2:29: >>>> ??? Could not deduce (Eq a) from the context () >>>> ????? arising from a use of `==' at count.hs:2:29-32 >>>> ??? Possible fix: >>>> ????? add (Eq a) to the context of the type signature for `count' >>>> ??? In the first argument of `filter', namely `(== x)' >>>> ??? In the first argument of `length', namely `(filter (== x) ys)' >>>> ??? In the expression: length (filter (== x) ys) >>>> Failed, modules loaded: none. >>>> Prelude> >>>> >>>> ============= >>>> >>>> Not sure what it's trying to tell me other than I need an (Eq a) >>>> somewhere. >>>> >>>> Michael >>>> >>>> >>>> >>>> >>>> _______________________________________________ >>>> 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 >> >> > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru > > -- Eugene Kirpichov Web IR developer, market.yandex.ru -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090418/09fffa91/attachment.htm From haskell at colquitt.org Sat Apr 18 14:36:07 2009 From: haskell at colquitt.org (John Dorsey) Date: Sat Apr 18 14:22:28 2009 Subject: [Haskell-cafe] General function to count list elements? In-Reply-To: <842644.44242.qm@web31105.mail.mud.yahoo.com> References: <842644.44242.qm@web31105.mail.mud.yahoo.com> Message-ID: <20090418183607.GB3278@colquitt.org> Michael, > I had a count function that worked fine for an enum type, but thought > why not go polymorphic with it. So I changed it and got the error I > originally inquired about. For variety, I'll go a slightly different direction. If you generalize count to use any predicate, instead of always equality... gcount :: (a -> a -> Bool) -> a -> [a] -> Int gcount pred x0 xs = length (filter (pred x0) xs) count = gcount (==) This will work with any type that you can write a predicate for with the type (a -> a -> Bool). I can even use this with functions, if I'm careful. ghci> gcount (\f g -> True) (*2) [id,(const 1),(*3)] 3 ghci> gcount (\f g -> f 1 == g 1) (^2) [id,(const 1),(*3)] 2 By the way, do you see why everyone's bothing you about comparing functions? The type you gave count, which didn't have an Eq constraint, was an assertion that you could compare two values of *any* type. If there's a type that's not comparable, then count's type was wrong. Functions are the canonical example of an incomparable type. When you're bored some time, read a bit about the Curry-Howard correspondence. It's interesting, even if (like me) you don't grok all of its implications. Regards, John From nowgate at yahoo.com Sat Apr 18 15:30:26 2009 From: nowgate at yahoo.com (nowgate@yahoo.com) Date: Sat Apr 18 15:16:44 2009 Subject: [Haskell-cafe] General function to count list elements? Message-ID: <902810.3141.qm@web31107.mail.mud.yahoo.com> Hi John, Yes, I see now what the hullabaloo was about. I've only been hacking Haskell for a few weeks, so I'm still seeing the "forest" rather than the "trees". But I'm coming along. Thanks. Michael --- On Sat, 4/18/09, John Dorsey wrote: From: John Dorsey Subject: Re: [Haskell-cafe] General function to count list elements? To: "michael rice" Cc: haskell-cafe@haskell.org Date: Saturday, April 18, 2009, 2:36 PM Michael, > I had a count function that worked fine for an enum type, but thought > why not go polymorphic with it. So I changed it and got the error I > originally inquired about. For variety, I'll go a slightly different direction. If you generalize count to use any predicate, instead of always equality... ??? gcount :: (a -> a -> Bool) -> a -> [a] -> Int ??? gcount pred x0 xs = length (filter (pred x0) xs) ??? count = gcount (==) This will work with any type that you can write a predicate for with the type (a -> a -> Bool).? I can even use this with functions, if I'm careful. ??? ghci> gcount (\f g -> True)? ? ???(*2) [id,(const 1),(*3)] ??? 3 ??? ghci> gcount (\f g -> f 1 == g 1) (^2) [id,(const 1),(*3)] ??? 2 By the way, do you see why everyone's bothing you about comparing functions?? The type you gave count, which didn't have an Eq constraint, was an assertion that you could compare two values of *any* type.? If there's a type that's not comparable, then count's type was wrong. Functions are the canonical example of an incomparable type. When you're bored some time, read a bit about the Curry-Howard correspondence.? It's interesting, even if (like me) you don't grok all of its implications. Regards, John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090418/a0e460a3/attachment.htm From aslatter at gmail.com Sat Apr 18 16:44:20 2009 From: aslatter at gmail.com (Antoine Latter) Date: Sat Apr 18 16:30:39 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> Message-ID: <694519c50904181344s7846869md5f7646f8eb3b5c7@mail.gmail.com> On Sat, Apr 18, 2009 at 9:03 AM, wrote: > ? ? ? ? ? ?Utrecht Haskell Compiler -- first release, version 1.0.0 > ? ? ? ? ? ?======================================================== > > > The UHC team is happy to announce the first public release of the > Utrecht Haskell Compiler (UHC). UHC supports almost all Haskell98 > features plus many experimental extensions. The compiler runs on MacOSX, > Windows (cygwin), and various Unix flavors. > > Features: > > ?* Multiple backends, including a bytecode interpreter backend and a > ? ?GRIN based, full program analysing backend, both via C. > > ?* Experimental language extensions, some of which have not been > ? ?implemented before. > > ?* Implementation via attribute grammars and other high-level tools. > > ?* Ease of experimentation with language variants, thanks to an > ? ?aspect-oriented internal organisation. > > > Getting started & Download > -------------------------- > > UHC is available for download as source distribution via the UHC home > page: > > ? ? ? ?http://www.cs.uu.nl/wiki/UHC > > Here you will also find instructions to get started. > > > Status of the implementation > ---------------------------- > > Like any university project UHC is very much work in progress. We feel > that it is mature and stable enough to offer to the public, but much > work still needs to be done; hence we welcome contributions by others. > > UHC grew out of our Haskell compiler project (called Essential Haskell > Compiler, or EHC) over the past 5 years. UHC internally is organised as > a combination of separate aspects, which makes UHC very suitable to > experiment with; it is relatively easy to build compilers for > sublanguages, or to generate related tools such as documentation > generators, all from the same code base. Extensions to the language can > be described separately, and be switched on or of as need arises. > > > Warning > ------- > > Although we think ?that the compiler is stable enough to compile > subtantial Haskell programs, we do not recommend yet to use it for any > serious development work in Haskell. We ourselves use the GHC as a > development platform! We think however that it provides a great platform > for experimenting with language implementations, language extensions, > etc. > > > Mailing lists > ------------- > > For UHC users and developers respectively: > > ? ? ? ?http://mail.cs.uu.nl/mailman/listinfo/uhc-users > ? ? ? ?http://mail.cs.uu.nl/mailman/listinfo/uhc-developers > > > Bug reporting > ------------- > > Please report bugs at: > > ? ? ? ?http://code.google.com/p/uhc/issues/list > > > The UHC Team > > > -- > Atze Dijkstra, Department of Information and Computing Sciences. /|\ > Utrecht University, PO Box 80089, 3508 TB Utrecht, Netherlands. / | \ > Tel.: +31-30-2534118/1454 | WWW ?: http://www.cs.uu.nl/~atze . /--| ?\ > Fax : +31-30-2513971 .... | Email: atze@cs.uu.nl ............ / ? |___\ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > After running "./configure" on my Intel Mac (running OS 10.5.6 with GHC 6.10), I try to run "make uhc" and get the following: >>>>> $ make uhc src/ruler2/files.mk:34: build/ruler2/files-ag-d-dep.mk: No such file or directory src/ruler2/files.mk:35: build/ruler2/files-ag-s-dep.mk: No such file or directory mkdir -p build/shuffle ; \ --module=CDoc -dr -Psrc/shuffle/ -o build/shuffle/CDoc.hs src/shuffle/CDoc.ag /bin/sh: --module=CDoc: command not found make: Failed to remake makefile `build/ruler2/files-ag-s-dep.mk'. make: Failed to remake makefile `build/ruler2/files-ag-d-dep.mk'. make EHC_VARIANT=`echo install/101/bin/ehc | sed -n -e 's+install/\([0-9_]*\)/bin/ehc.*+\1+p'` ehc-variant src/ruler2/files.mk:34: build/ruler2/files-ag-d-dep.mk: No such file or directory src/ruler2/files.mk:35: build/ruler2/files-ag-s-dep.mk: No such file or directory mkdir -p build/shuffle ; \ --module=CDoc -dr -Psrc/shuffle/ -o build/shuffle/CDoc.hs src/shuffle/CDoc.ag /bin/sh: --module=CDoc: command not found make[1]: Failed to remake makefile `build/ruler2/files-ag-s-dep.mk'. make[1]: Failed to remake makefile `build/ruler2/files-ag-d-dep.mk'. make EHC_VARIANT_RULER_SEL="((101=HS)).(expr.base patexpr.base tyexpr.base decl.base).(e.int e.char e.var e.con e.str p.str)" \ ehc-variant-dflt src/ruler2/files.mk:34: build/ruler2/files-ag-d-dep.mk: No such file or directory src/ruler2/files.mk:35: build/ruler2/files-ag-s-dep.mk: No such file or directory mkdir -p build/shuffle ; \ --module=CDoc -dr -Psrc/shuffle/ -o build/shuffle/CDoc.hs src/shuffle/CDoc.ag /bin/sh: --module=CDoc: command not found make[2]: Failed to remake makefile `build/ruler2/files-ag-s-dep.mk'. make[2]: Failed to remake makefile `build/ruler2/files-ag-d-dep.mk'. make[1]: *** [ehc-variant] Error 2 make: *** [install/101/bin/ehc] Error 2 <<<<< This is fairly bewildering. Am I the only one seeing errors like this? Thanks, Antoine Also: >>>>> $ make --version GNU Make 3.81 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This program built for powerpc-apple-darwin9.0 <<<<< >>>>> $ sh --version GNU bash, version 3.2.17(1)-release (i386-apple-darwin9.0) Copyright (C) 2005 Free Software Foundation, Inc. <<<<< From sigbjorn.finne at gmail.com Sat Apr 18 16:44:41 2009 From: sigbjorn.finne at gmail.com (Sigbjorn Finne) Date: Sat Apr 18 16:31:04 2009 Subject: [Haskell-cafe] Announce: A pragmatic Haskell .NET interop layer, 0.4.0 Message-ID: <49EA3BB9.5050304@gmail.com> A new version of a Haskell .NET interop layer, hs-dotnet, has just been released and is now available for download, http://haskell.forkIO.com/dotnet It lets you access .NET functionality from Haskell and vice versa. Tool support is included in this release to aid such interop. The new version includes development done since the start of the year. Apart from rewriting the internals completely to put it all on a sounder footing, this release includes proper support for .NET generic types (classes and interfaces), mapping them naturally on to Haskell parameterized types. The support for generics enables for instance mixed Haskell-.NET LINQ programming; see the distribution for examples of this along with some other interesting applications of the hs-dotnet interop layer. enjoy --sigbjorn From gue.schmidt at web.de Sat Apr 18 17:09:47 2009 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FC=3Fnther_Schmidt?=) Date: Sat Apr 18 16:56:20 2009 Subject: [Haskell-cafe] Zippers for gui elements? Message-ID: Hi all, I need to control some gui elements, ie. stuff like when dis button is clicked make dat one inactive. Some time ago, wish I'd remember where, I read about using Zippers for that sort of thing. Does anybody know where I might have read that? G?nther From tom.davie at gmail.com Sat Apr 18 17:38:25 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Sat Apr 18 17:24:51 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <694519c50904181344s7846869md5f7646f8eb3b5c7@mail.gmail.com> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <694519c50904181344s7846869md5f7646f8eb3b5c7@mail.gmail.com> Message-ID: <2FC7F375-0A9E-4629-A083-3094C86E5848@gmail.com> On 18 Apr 2009, at 22:44, Antoine Latter wrote: > On Sat, Apr 18, 2009 at 9:03 AM, wrote: >> Utrecht Haskell Compiler -- first release, version 1.0.0 >> ======================================================== >> >> >> The UHC team is happy to announce the first public release of the >> Utrecht Haskell Compiler (UHC). UHC supports almost all Haskell98 >> features plus many experimental extensions. The compiler runs on >> MacOSX, >> Windows (cygwin), and various Unix flavors. >> >> Features: >> >> * Multiple backends, including a bytecode interpreter backend and a >> GRIN based, full program analysing backend, both via C. >> >> * Experimental language extensions, some of which have not been >> implemented before. >> >> * Implementation via attribute grammars and other high-level tools. >> >> * Ease of experimentation with language variants, thanks to an >> aspect-oriented internal organisation. >> >> >> Getting started & Download >> -------------------------- >> >> UHC is available for download as source distribution via the UHC home >> page: >> >> http://www.cs.uu.nl/wiki/UHC >> >> Here you will also find instructions to get started. >> >> >> Status of the implementation >> ---------------------------- >> >> Like any university project UHC is very much work in progress. We >> feel >> that it is mature and stable enough to offer to the public, but much >> work still needs to be done; hence we welcome contributions by >> others. >> >> UHC grew out of our Haskell compiler project (called Essential >> Haskell >> Compiler, or EHC) over the past 5 years. UHC internally is >> organised as >> a combination of separate aspects, which makes UHC very suitable to >> experiment with; it is relatively easy to build compilers for >> sublanguages, or to generate related tools such as documentation >> generators, all from the same code base. Extensions to the language >> can >> be described separately, and be switched on or of as need arises. >> >> >> Warning >> ------- >> >> Although we think that the compiler is stable enough to compile >> subtantial Haskell programs, we do not recommend yet to use it for >> any >> serious development work in Haskell. We ourselves use the GHC as a >> development platform! We think however that it provides a great >> platform >> for experimenting with language implementations, language extensions, >> etc. >> >> >> Mailing lists >> ------------- >> >> For UHC users and developers respectively: >> >> http://mail.cs.uu.nl/mailman/listinfo/uhc-users >> http://mail.cs.uu.nl/mailman/listinfo/uhc-developers >> >> >> Bug reporting >> ------------- >> >> Please report bugs at: >> >> http://code.google.com/p/uhc/issues/list >> >> >> The UHC Team >> >> >> -- >> Atze Dijkstra, Department of Information and Computing Sciences. /|\ >> Utrecht University, PO Box 80089, 3508 TB Utrecht, Netherlands. / | \ >> Tel.: +31-30-2534118/1454 | WWW : http://www.cs.uu.nl/ >> ~atze . /--| \ >> Fax : +31-30-2513971 .... | Email: atze@cs.uu.nl ............ / | >> ___\ >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > After running "./configure" on my Intel Mac (running OS 10.5.6 with > GHC 6.10), I try to run "make uhc" and get the following: > >>>>>> > $ make uhc > src/ruler2/files.mk:34: build/ruler2/files-ag-d-dep.mk: No such file > or directory > src/ruler2/files.mk:35: build/ruler2/files-ag-s-dep.mk: No such file > or directory > mkdir -p build/shuffle ; \ > --module=CDoc -dr -Psrc/shuffle/ -o build/shuffle/CDoc.hs src/ > shuffle/CDoc.ag > /bin/sh: --module=CDoc: command not found > make: Failed to remake makefile `build/ruler2/files-ag-s-dep.mk'. > make: Failed to remake makefile `build/ruler2/files-ag-d-dep.mk'. > make EHC_VARIANT=`echo install/101/bin/ehc | sed -n -e > 's+install/\([0-9_]*\)/bin/ehc.*+\1+p'` ehc-variant > src/ruler2/files.mk:34: build/ruler2/files-ag-d-dep.mk: No such file > or directory > src/ruler2/files.mk:35: build/ruler2/files-ag-s-dep.mk: No such file > or directory > mkdir -p build/shuffle ; \ > --module=CDoc -dr -Psrc/shuffle/ -o build/shuffle/CDoc.hs src/ > shuffle/CDoc.ag > /bin/sh: --module=CDoc: command not found > make[1]: Failed to remake makefile `build/ruler2/files-ag-s-dep.mk'. > make[1]: Failed to remake makefile `build/ruler2/files-ag-d-dep.mk'. > make EHC_VARIANT_RULER_SEL="((101=HS)).(expr.base patexpr.base > tyexpr.base decl.base).(e.int e.char e.var e.con e.str p.str)" \ > ehc-variant-dflt > src/ruler2/files.mk:34: build/ruler2/files-ag-d-dep.mk: No such file > or directory > src/ruler2/files.mk:35: build/ruler2/files-ag-s-dep.mk: No such file > or directory > mkdir -p build/shuffle ; \ > --module=CDoc -dr -Psrc/shuffle/ -o build/shuffle/CDoc.hs src/ > shuffle/CDoc.ag > /bin/sh: --module=CDoc: command not found > make[2]: Failed to remake makefile `build/ruler2/files-ag-s-dep.mk'. > make[2]: Failed to remake makefile `build/ruler2/files-ag-d-dep.mk'. > make[1]: *** [ehc-variant] Error 2 > make: *** [install/101/bin/ehc] Error 2 > <<<<< > > This is fairly bewildering. Am I the only one seeing errors like > this? This looks like the same error I got ? see bug report 1 in the bug database ? the configure script reports that you have uuagc even if you don't ? cabal install it, reconfigure, and you should be on your way. Second thing to watch for ? it depends on fgl, but this isn't caught by the configure script. Thanks Bob From aslatter at gmail.com Sat Apr 18 18:31:45 2009 From: aslatter at gmail.com (Antoine Latter) Date: Sat Apr 18 18:18:03 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <2FC7F375-0A9E-4629-A083-3094C86E5848@gmail.com> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <694519c50904181344s7846869md5f7646f8eb3b5c7@mail.gmail.com> <2FC7F375-0A9E-4629-A083-3094C86E5848@gmail.com> Message-ID: <694519c50904181531v26fbde6ft615689a539d2f5e5@mail.gmail.com> On Sat, Apr 18, 2009 at 4:38 PM, Thomas Davie wrote: > > This looks like the same error I got ? see bug report 1 in the bug database > ? the configure script reports that you have uuagc even if you don't ? cabal > install it, reconfigure, and you should be on your way. > > Second thing to watch for ? it depends on fgl, but this isn't caught by the > configure script. > Apparently a "user" install of uuagc and fgl isn't good enough. Fun to know. Antoine From barsoap at web.de Sat Apr 18 18:40:08 2009 From: barsoap at web.de (Achim Schneider) Date: Sat Apr 18 18:26:53 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <694519c50904181344s7846869md5f7646f8eb3b5c7@mail.gmail.com> <2FC7F375-0A9E-4629-A083-3094C86E5848@gmail.com> <694519c50904181531v26fbde6ft615689a539d2f5e5@mail.gmail.com> Message-ID: <20090419004008.0f04e1c5@solaris> Antoine Latter wrote: > On Sat, Apr 18, 2009 at 4:38 PM, Thomas Davie > wrote: > > > > This looks like the same error I got ___ see bug report 1 in the bug > > database ___ the configure script reports that you have uuagc even if > > you don't ___ cabal install it, reconfigure, and you should be on > > your way. > > > > Second thing to watch for ___ it depends on fgl, but this isn't > > caught by the configure script. > > > > Apparently a "user" install of uuagc and fgl isn't good enough. Fun > to know. > Do you have your $PATH set to include $HOME/.cabal/bin ? -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From tom.davie at gmail.com Sat Apr 18 18:41:15 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Sat Apr 18 18:27:34 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <694519c50904181531v26fbde6ft615689a539d2f5e5@mail.gmail.com> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <694519c50904181344s7846869md5f7646f8eb3b5c7@mail.gmail.com> <2FC7F375-0A9E-4629-A083-3094C86E5848@gmail.com> <694519c50904181531v26fbde6ft615689a539d2f5e5@mail.gmail.com> Message-ID: <5ABFAA75-120E-4459-BA92-FDE4624A1399@gmail.com> On 19 Apr 2009, at 00:31, Antoine Latter wrote: > On Sat, Apr 18, 2009 at 4:38 PM, Thomas Davie > wrote: >> >> This looks like the same error I got ? see bug report 1 in the bug >> database >> ? the configure script reports that you have uuagc even if you >> don't ? cabal >> install it, reconfigure, and you should be on your way. >> >> Second thing to watch for ? it depends on fgl, but this isn't >> caught by the >> configure script. >> > > Apparently a "user" install of uuagc and fgl isn't good enough. Fun > to know. I've found user installs don't work at all on OS X, various people in #haskell were rather surprised to discover this, so apparently it's not the default behavior on other platforms. It really rather makes "cabal install" rather odd ? because it doesn't actually install anything you can use without providing extra options! Bob From lennart at augustsson.net Sat Apr 18 19:00:55 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Sat Apr 18 18:47:13 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <5ABFAA75-120E-4459-BA92-FDE4624A1399@gmail.com> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <694519c50904181344s7846869md5f7646f8eb3b5c7@mail.gmail.com> <2FC7F375-0A9E-4629-A083-3094C86E5848@gmail.com> <694519c50904181531v26fbde6ft615689a539d2f5e5@mail.gmail.com> <5ABFAA75-120E-4459-BA92-FDE4624A1399@gmail.com> Message-ID: I've learnt (the hard way) not to trust user installs at all. On Sun, Apr 19, 2009 at 12:41 AM, Thomas Davie wrote: > > On 19 Apr 2009, at 00:31, Antoine Latter wrote: > >> On Sat, Apr 18, 2009 at 4:38 PM, Thomas Davie wrote: >>> >>> This looks like the same error I got ? see bug report 1 in the bug >>> database >>> ? the configure script reports that you have uuagc even if you don't ? >>> cabal >>> install it, reconfigure, and you should be on your way. >>> >>> Second thing to watch for ? it depends on fgl, but this isn't caught by >>> the >>> configure script. >>> >> >> Apparently a "user" install of uuagc and fgl isn't good enough. ?Fun to >> know. > > I've found user installs don't work at all on OS X, various people in > #haskell were rather surprised to discover this, so apparently it's not the > default behavior on other platforms. > > It really rather makes "cabal install" rather odd ? because it doesn't > actually install anything you can use without providing extra options! > > Bob_______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From martijn at van.steenbergen.nl Sun Apr 19 03:45:54 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Sun Apr 19 03:32:12 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <5ABFAA75-120E-4459-BA92-FDE4624A1399@gmail.com> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <694519c50904181344s7846869md5f7646f8eb3b5c7@mail.gmail.com> <2FC7F375-0A9E-4629-A083-3094C86E5848@gmail.com> <694519c50904181531v26fbde6ft615689a539d2f5e5@mail.gmail.com> <5ABFAA75-120E-4459-BA92-FDE4624A1399@gmail.com> Message-ID: <49EAD6B2.1000602@van.steenbergen.nl> Thomas Davie wrote: > I've found user installs don't work at all on OS X, various people in > #haskell were rather surprised to discover this, so apparently it's not > the default behavior on other platforms. > > It really rather makes "cabal install" rather odd ? because it doesn't > actually install anything you can use without providing extra options! I'm on OS X and I've always used 'cabal install xyz' without any extra options, installing packages in my home directory instead of globally. I've never had any trouble with it yet. Martijn. From duncan.coutts at worc.ox.ac.uk Sun Apr 19 03:52:51 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Apr 19 03:39:09 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <5ABFAA75-120E-4459-BA92-FDE4624A1399@gmail.com> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <694519c50904181344s7846869md5f7646f8eb3b5c7@mail.gmail.com> <2FC7F375-0A9E-4629-A083-3094C86E5848@gmail.com> <694519c50904181531v26fbde6ft615689a539d2f5e5@mail.gmail.com> <5ABFAA75-120E-4459-BA92-FDE4624A1399@gmail.com> Message-ID: <1240127571.6315.92.camel@lantern> On Sun, 2009-04-19 at 00:41 +0200, Thomas Davie wrote: > > Apparently a "user" install of uuagc and fgl isn't good enough. Fun > > to know. > > I've found user installs don't work at all on OS X, various people in > #haskell were rather surprised to discover this, so apparently it's > not the default behavior on other platforms. Currently, user installs are the default on all platforms except Windows. > It really rather makes "cabal install" rather odd ? because it doesn't > actually install anything you can use without providing extra options! It should work fine, you'll need to give more details. Duncan From tom.davie at gmail.com Sun Apr 19 04:02:25 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Sun Apr 19 03:48:46 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <1240127571.6315.92.camel@lantern> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <694519c50904181344s7846869md5f7646f8eb3b5c7@mail.gmail.com> <2FC7F375-0A9E-4629-A083-3094C86E5848@gmail.com> <694519c50904181531v26fbde6ft615689a539d2f5e5@mail.gmail.com> <5ABFAA75-120E-4459-BA92-FDE4624A1399@gmail.com> <1240127571.6315.92.camel@lantern> Message-ID: On 19 Apr 2009, at 09:52, Duncan Coutts wrote: > On Sun, 2009-04-19 at 00:41 +0200, Thomas Davie wrote: > >>> Apparently a "user" install of uuagc and fgl isn't good enough. Fun >>> to know. >> >> I've found user installs don't work at all on OS X, various people in >> #haskell were rather surprised to discover this, so apparently it's >> not the default behavior on other platforms. > > Currently, user installs are the default on all platforms except > Windows. > >> It really rather makes "cabal install" rather odd ? because it >> doesn't >> actually install anything you can use without providing extra >> options! > > It should work fine, you'll need to give more details. This has been the result, at least every time I've installed ghc: $ cabal install xyz $ runhaskell Setup.hs configure -- where abc depends on xyz Configuring abc-0.0... Setup.lhs: At least the following dependencies are missing: xyz -any $ sudo cabal install --global xyz $ runhaskell Setup.hs configure Configuring abc-0.0... $ runhaskell Setup.hs build ... Bob From duncan.coutts at worc.ox.ac.uk Sun Apr 19 05:10:55 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Apr 19 04:57:15 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <694519c50904181344s7846869md5f7646f8eb3b5c7@mail.gmail.com> <2FC7F375-0A9E-4629-A083-3094C86E5848@gmail.com> <694519c50904181531v26fbde6ft615689a539d2f5e5@mail.gmail.com> <5ABFAA75-120E-4459-BA92-FDE4624A1399@gmail.com> <1240127571.6315.92.camel@lantern> Message-ID: <1240132255.6315.103.camel@lantern> On Sun, 2009-04-19 at 10:02 +0200, Thomas Davie wrote: > >> It really rather makes "cabal install" rather odd ? because it > >> doesn't actually install anything you can use without providing extra > >> options! > > > > It should work fine, you'll need to give more details. > > This has been the result, at least every time I've installed ghc: > > $ cabal install xyz So this does a per-user install. > $ runhaskell Setup.hs configure -- where abc depends on xyz This does a global install. Global packages cannot depend on user packages. You have two choices: $ cabal configure because the cabal program does --user installs by default or use $ runhaskell Setup.hs configure --user which explicitly does a --user install. The reason for this confusion is because the original runghc Setup interface started with global installs and we can't easily change that default. On the other hand, per-user installs are much more convenient so that's the sensible default for the 'cabal' command line program. Personally I just always use the 'cabal' program and never use the runghc Setup interface. There's almost never any need to use the runghc Setup interface. Duncan From jon.fairbairn at cl.cam.ac.uk Sun Apr 19 05:45:28 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Sun Apr 19 05:31:58 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> Message-ID: atze@cs.uu.nl writes: > Utrecht Haskell Compiler -- first release, version 1.0.0 > ======================================================== > > > The UHC team is happy to announce the first public release of the > Utrecht Haskell Compiler (UHC). UHC supports almost all Haskell98 > features Why? Is there something about Haskell 98 that's hard to implement? > plus many experimental extensions. fair enough, but it always puzzles my why implementations of compilers almost never start with a complete standard language. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (updated 2009-01-31) From cetin.sert at gmail.com Sun Apr 19 05:53:43 2009 From: cetin.sert at gmail.com (Cetin Sert) Date: Sun Apr 19 05:39:59 2009 Subject: [Haskell-cafe] Matrices Message-ID: <1ff5dedc0904190253x11a2a51dx56dc3a0eefc08eb2@mail.gmail.com> http://ccnmtl.columbia.edu/projects/qmss/the_chisquare_test/about_the_chisquare_test.html given two matrices, Prelude Data.Matrix.Dense Data.Vector.Dense> m listMatrix (2,2) [46.0,37.0,71.0,83.0] Prelude Data.Matrix.Dense Data.Vector.Dense> es listMatrix (2,2) [40.9746835443038,42.0253164556962,76.0253164556962,77.9746835443038] how can I flatten them to do: [ (o-e)^2 / e | o <- m, e <- es ] or use a function that will apply a given function to every corresponding elements of 2 or n matrices and create a result matrix? If I should use a different matrix type or library altogether, please specify which one and how ^__^" Best Regards, Cetin Sert From tom.davie at gmail.com Sun Apr 19 06:23:21 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Sun Apr 19 06:09:45 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <1240132255.6315.103.camel@lantern> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <694519c50904181344s7846869md5f7646f8eb3b5c7@mail.gmail.com> <2FC7F375-0A9E-4629-A083-3094C86E5848@gmail.com> <694519c50904181531v26fbde6ft615689a539d2f5e5@mail.gmail.com> <5ABFAA75-120E-4459-BA92-FDE4624A1399@gmail.com> <1240127571.6315.92.camel@lantern> <1240132255.6315.103.camel@lantern> Message-ID: On 19 Apr 2009, at 11:10, Duncan Coutts wrote: > On Sun, 2009-04-19 at 10:02 +0200, Thomas Davie wrote: > >>>> It really rather makes "cabal install" rather odd ? because it >>>> doesn't actually install anything you can use without providing >>>> extra >>>> options! >>> >>> It should work fine, you'll need to give more details. >> >> This has been the result, at least every time I've installed ghc: >> >> $ cabal install xyz > > So this does a per-user install. > >> $ runhaskell Setup.hs configure -- where abc depends on xyz > > This does a global install. Global packages cannot depend on user > packages. You have two choices: > > $ cabal configure > > because the cabal program does --user installs by default > or use > > $ runhaskell Setup.hs configure --user > > which explicitly does a --user install. > > The reason for this confusion is because the original runghc Setup > interface started with global installs and we can't easily change that > default. On the other hand, per-user installs are much more convenient > so that's the sensible default for the 'cabal' command line program. I don't understand what makes user installs more convenient. Certainly, my preference would be for global all the time ? I expect something that says it's going to "install" something to install it onto my computer, like any other installation program does. What is it that makes user installs more convenient in this situation? Bob From dons at galois.com Sun Apr 19 06:24:28 2009 From: dons at galois.com (Don Stewart) Date: Sun Apr 19 06:12:00 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <694519c50904181344s7846869md5f7646f8eb3b5c7@mail.gmail.com> <2FC7F375-0A9E-4629-A083-3094C86E5848@gmail.com> <694519c50904181531v26fbde6ft615689a539d2f5e5@mail.gmail.com> <5ABFAA75-120E-4459-BA92-FDE4624A1399@gmail.com> <1240127571.6315.92.camel@lantern> <1240132255.6315.103.camel@lantern> Message-ID: <20090419102428.GI29457@whirlpool.galois.com> tom.davie: > > On 19 Apr 2009, at 11:10, Duncan Coutts wrote: > >> On Sun, 2009-04-19 at 10:02 +0200, Thomas Davie wrote: >> >>>>> It really rather makes "cabal install" rather odd ? because it >>>>> doesn't actually install anything you can use without providing >>>>> extra >>>>> options! >>>> >>>> It should work fine, you'll need to give more details. >>> >>> This has been the result, at least every time I've installed ghc: >>> >>> $ cabal install xyz >> >> So this does a per-user install. >> >>> $ runhaskell Setup.hs configure -- where abc depends on xyz >> >> This does a global install. Global packages cannot depend on user >> packages. You have two choices: >> >> $ cabal configure >> >> because the cabal program does --user installs by default >> or use >> >> $ runhaskell Setup.hs configure --user >> >> which explicitly does a --user install. >> >> The reason for this confusion is because the original runghc Setup >> interface started with global installs and we can't easily change that >> default. On the other hand, per-user installs are much more convenient >> so that's the sensible default for the 'cabal' command line program. > > I don't understand what makes user installs more convenient. Certainly, > my preference would be for global all the time ? I expect something that > says it's going to "install" something to install it onto my computer, > like any other installation program does. What is it that makes user > installs more convenient in this situation? You don't need 'sudo' access for user installs. This means that 'cabal install' works out of the box on every system, without needing admin/root privs (esp. important for students). -- Don From benjovi at gmx.net Sun Apr 19 06:56:39 2009 From: benjovi at gmx.net (Benedikt Huber) Date: Sun Apr 19 06:43:04 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <5ABFAA75-120E-4459-BA92-FDE4624A1399@gmail.com> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <694519c50904181344s7846869md5f7646f8eb3b5c7@mail.gmail.com> <2FC7F375-0A9E-4629-A083-3094C86E5848@gmail.com> <694519c50904181531v26fbde6ft615689a539d2f5e5@mail.gmail.com> <5ABFAA75-120E-4459-BA92-FDE4624A1399@gmail.com> Message-ID: <49EB0367.4020802@gmx.net> Thomas Davie schrieb: > > On 19 Apr 2009, at 00:31, Antoine Latter wrote: > >> ... >> Apparently a "user" install of uuagc and fgl isn't good enough. Fun >> to know. > > I've found user installs don't work at all on OS X, various people in > #haskell were rather surprised to discover this, so apparently it's > not the default behavior on other platforms. Why do user installs 'not work at all' on OS X ?? I'm on OS X 10.5, I always use cabal install (user), and never encountered any problems. The only caveat duncan mentioned is to pass --user to 'runhaskell Setup.hs' (which I never use, because there's cabal). For me, following 'cabal install fgl uulib uuagc', uhc compiled without any problems. There is a small issue (5) with 'make install' though: The 'bin' directory is not created if neccessary. benedikt From aruiz at um.es Sun Apr 19 07:03:26 2009 From: aruiz at um.es (Alberto Ruiz) Date: Sun Apr 19 06:49:45 2009 Subject: [Haskell-cafe] Matrices In-Reply-To: <1ff5dedc0904190253x11a2a51dx56dc3a0eefc08eb2@mail.gmail.com> References: <1ff5dedc0904190253x11a2a51dx56dc3a0eefc08eb2@mail.gmail.com> Message-ID: <49EB04FE.7070900@um.es> Using hmatrix-static: import Numeric.LinearAlgebra.Static m = [$mat| 46.0,37.0; 71.0,83.0 |] es = [$mat| 40.9746835443038,42.0253164556962; 76.0253164556962,77.9746835443038 |] chisquare = sum . toList . flatten $ (m - es)^2 / es ::Double -- > 1.8732940252518542 Cetin Sert wrote: > http://ccnmtl.columbia.edu/projects/qmss/the_chisquare_test/about_the_chisquare_test.html > > given two matrices, > > Prelude Data.Matrix.Dense Data.Vector.Dense> m > listMatrix (2,2) [46.0,37.0,71.0,83.0] > Prelude Data.Matrix.Dense Data.Vector.Dense> es > listMatrix (2,2) > [40.9746835443038,42.0253164556962,76.0253164556962,77.9746835443038] > > how can I flatten them to do: > [ (o-e)^2 / e | o <- m, e <- es ] > > or use a function that will apply a given function to every > corresponding elements of 2 or n matrices and create a result matrix? > > If I should use a different matrix type or library altogether, please > specify which one and how ^__^" > > Best Regards, > Cetin Sert > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From tom.davie at gmail.com Sun Apr 19 07:09:17 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Sun Apr 19 06:55:35 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <20090419102428.GI29457@whirlpool.galois.com> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <694519c50904181344s7846869md5f7646f8eb3b5c7@mail.gmail.com> <2FC7F375-0A9E-4629-A083-3094C86E5848@gmail.com> <694519c50904181531v26fbde6ft615689a539d2f5e5@mail.gmail.com> <5ABFAA75-120E-4459-BA92-FDE4624A1399@gmail.com> <1240127571.6315.92.camel@lantern> <1240132255.6315.103.camel@lantern> <20090419102428.GI29457@whirlpool.galois.com> Message-ID: <5242580B-2239-435F-9889-E79D03C9DEB5@gmail.com> >> >> I don't understand what makes user installs more convenient. >> Certainly, >> my preference would be for global all the time ? I expect something >> that >> says it's going to "install" something to install it onto my >> computer, >> like any other installation program does. What is it that makes user >> installs more convenient in this situation? > > You don't need 'sudo' access for user installs. This means that 'cabal > install' works out of the box on every system, without needing > admin/root privs (esp. important for students). But students will be used to needing to configure this ? in every other installation system out there they need to tell it to install in their user directory. Personally ? I find it more convenient to have the "install" program do what it says it does! Install it! This would save confusion about old tools that do things globally, and not confuse students, because they're all already used to giving extra flags to make install not install things system wide. Bob From benjovi at gmx.net Sun Apr 19 07:34:02 2009 From: benjovi at gmx.net (Benedikt Huber) Date: Sun Apr 19 07:20:19 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> Message-ID: <49EB0C2A.5090504@gmx.net> atze@cs.uu.nl schrieb: > Utrecht Haskell Compiler -- first release, version 1.0.0 > ======================================================== > > > The UHC team is happy to announce the first public release of the > Utrecht Haskell Compiler (UHC). Great to see another haskell compiler ! > Features: > > * Experimental language extensions, some of which have not been > implemented before. Maybe you could add a section 'Differences to GHC 6.10' to the manual ? From a quick look, partial type signatures and local instances seem to be 'novel features', and there are some differences with respect to type / kind inference. Section 4.2 (Proposed in haskell prime but not in UHC) and Section 4.3 (Available in UHC but not in Haskell98 or Haskell prime) are a little bit confusing (and imho superfluous): - Many language extensions have been 'proposed' for haskell prime (http://hackage.haskell.org/trac/haskell-prime/wiki/Status). - MPTCs are accepted for haskell prime - 'Existential Quantification' is accepted for haskell prime, but different from 'Existential Types' described in the manual - Functional Dependencies are not available in UHC ;) best regards, benedikt From daniel.is.fischer at web.de Sun Apr 19 08:34:52 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Apr 19 08:21:10 2009 Subject: =?iso-8859-15?Q?Re:_[Haskell-cafe]_ANNOUNCE:_Utrecht_Haskell_Compiler_?= =?iso-8859-15?Q?(UHC)_--_first_release?= Message-ID: <948097907@web.de> Am Sonntag 19 April 2009 13:09:17 schrieb Thomas Davie: > >> I don't understand what makes user installs more convenient. > >> Certainly, > >> my preference would be for global all the time ? I expect something > >> that > >> says it's going to "install" something to install it onto my > >> computer, > >> like any other installation program does. What is it that makes user > >> installs more convenient in this situation? > > > > You don't need 'sudo' access for user installs. This means that 'cabal > > install' works out of the box on every system, without needing > > admin/root privs (esp. important for students). > > But students will be used to needing to configure this ? in every > other installation system out there they need to tell it to install in > their user directory. Personally ? I find it more convenient to have > the "install" program do what it says it does! Install it! But it does install it, only not where you want it. Just for the record, I (no student, my own computer, sole user) prefer user-installs and cabal's default behaviour. Makes it so much easier to get rid of things I don't want anymore without any fear of buggering my system because something depends on it. > > This would save confusion about old tools that do things globally, and > not confuse students, because they're all already used to giving extra > flags to make install not install things system wide. Yes, it is bad that the runhaskell Setup interface has a different default. But, as Duncan said, too late to change it now. > > Bob From barsoap at web.de Sun Apr 19 08:49:30 2009 From: barsoap at web.de (Achim Schneider) Date: Sun Apr 19 08:37:24 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <694519c50904181344s7846869md5f7646f8eb3b5c7@mail.gmail.com> <2FC7F375-0A9E-4629-A083-3094C86E5848@gmail.com> <694519c50904181531v26fbde6ft615689a539d2f5e5@mail.gmail.com> <5ABFAA75-120E-4459-BA92-FDE4624A1399@gmail.com> <1240127571.6315.92.camel@lantern> <1240132255.6315.103.camel@lantern> <20090419102428.GI29457@whirlpool.galois.com> Message-ID: <20090419144930.0597700c@solaris> Don Stewart wrote: > This means that 'cabal > install' works out of the box on every system, without needing > admin/root privs (esp. important for students). > ...and people who were bitten by sanity and thus never, ever touch /usr manually, only through their distribution's package manager. Then there's those that work in an environment with network-mounted home directories, and even if the admins judged you responsible and skillful enough to award you local root rights, you still want your working environment to be available on any machine you log on. In short: If you don't need the package available for _every_ user, or your distribution comes with a pre-packaged version, don't even think to install it globally: it's an abomination to UNIX. Deal with it, OSX users aren't running a graphic shell on steroids, any more, and, yes, even Windoze users stopped running on top of that hacked-up program loader named DOS. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From barsoap at web.de Sun Apr 19 08:52:26 2009 From: barsoap at web.de (Achim Schneider) Date: Sun Apr 19 08:41:17 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> Message-ID: <20090419145226.70c4e3c9@solaris> Jon Fairbairn wrote: > atze@cs.uu.nl writes: > > > Utrecht Haskell Compiler -- first release, version 1.0.0 > > ======================================================== > > > > > > The UHC team is happy to announce the first public release of the > > Utrecht Haskell Compiler (UHC). UHC supports almost all Haskell98 > > features > > Why? Is there something about Haskell 98 that's hard to > implement? > Insanity. I doubt anyone is going to miss n+k patterns: http://www.cs.uu.nl/wiki/bin/view/Ehc/LanguageFeatures -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From dons at galois.com Sun Apr 19 09:56:47 2009 From: dons at galois.com (Don Stewart) Date: Sun Apr 19 09:44:16 2009 Subject: [Haskell-cafe] Matrices In-Reply-To: <49EB04FE.7070900@um.es> References: <1ff5dedc0904190253x11a2a51dx56dc3a0eefc08eb2@mail.gmail.com> <49EB04FE.7070900@um.es> Message-ID: <20090419135647.GA30851@whirlpool.galois.com> Very cool! We need an hmatrix-static tutorial! aruiz: > Using hmatrix-static: > > import Numeric.LinearAlgebra.Static > > m = [$mat| 46.0,37.0; > 71.0,83.0 |] > > es = [$mat| 40.9746835443038,42.0253164556962; > 76.0253164556962,77.9746835443038 |] > > chisquare = sum . toList . flatten $ (m - es)^2 / es ::Double > -- > 1.8732940252518542 > > Cetin Sert wrote: >> http://ccnmtl.columbia.edu/projects/qmss/the_chisquare_test/about_the_chisquare_test.html >> >> given two matrices, >> >> Prelude Data.Matrix.Dense Data.Vector.Dense> m >> listMatrix (2,2) [46.0,37.0,71.0,83.0] >> Prelude Data.Matrix.Dense Data.Vector.Dense> es >> listMatrix (2,2) >> [40.9746835443038,42.0253164556962,76.0253164556962,77.9746835443038] >> >> how can I flatten them to do: >> [ (o-e)^2 / e | o <- m, e <- es ] >> >> or use a function that will apply a given function to every >> corresponding elements of 2 or n matrices and create a result matrix? >> >> If I should use a different matrix type or library altogether, please >> specify which one and how ^__^" >> >> Best Regards, >> Cetin Sert >> _______________________________________________ >> 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 bugfact at gmail.com Sun Apr 19 10:32:35 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Apr 19 10:18:51 2009 Subject: [Haskell-cafe] Using GHC as an arrows preprocessor? Message-ID: I'm making some custom arrows and I'm getting bugs when using the GHC preprocessor, but not when using the old standalone preprocessor. In order to debug this, it would be nice to use GHC as an arrows preprocessor (so converting the arrow notation into plain Haskell and outputting the converted source code); is this possible? I also noticed that GHC's builtin preprocessor generates far more intermediate combinators than the old preprocessor. The benchmark in this paper seems to confirm this. Is this a known issue? Thanks, Peter -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090419/1b4aa093/attachment.htm From ross at soi.city.ac.uk Sun Apr 19 10:59:30 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Sun Apr 19 10:45:48 2009 Subject: [Haskell-cafe] Using GHC as an arrows preprocessor? In-Reply-To: References: Message-ID: <20090419145930.GA3889@soi.city.ac.uk> On Sun, Apr 19, 2009 at 04:32:35PM +0200, Peter Verswyvelen wrote: > I'm making some custom arrows and I'm getting bugs when using the GHC > preprocessor, but not when using the old standalone preprocessor. > > In order to debug this, it would be nice to use GHC as an arrows preprocessor > (so converting the arrow notation into plain Haskell and outputting the > converted source code); is this possible? It isn't: the desugaring in GHC maps type-annotated Haskell into GHC's Core language. I'd be very interested in tracking down any behavioural differences between the standalone preprocessor and the GHC implementation. Are these strictness bugs, or something else? Note that both of these translators assume that your combinators satisfy the arrow laws. > I also noticed that GHC's builtin preprocessor generates far more intermediate > combinators than the old preprocessor. The benchmark in this paper seems to > confirm this. Is this a known issue? I've heard of this, but not seen a simple clear test case. From manlio_perillo at libero.it Sun Apr 19 11:48:00 2009 From: manlio_perillo at libero.it (Manlio Perillo) Date: Sun Apr 19 11:34:31 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> Message-ID: <49EB47B0.2060400@libero.it> Henning Thielemann ha scritto: > > On Tue, 14 Apr 2009, rodrigo.bonifacio wrote: > >> I guess this is a very simple question. How can I convert IO [XmlTree] >> to just a list of >> XmlTree? > > The old Wiki had: > http://www.haskell.org/wikisnapshot/ThatAnnoyingIoType.html > > Should be ported to the new Wiki since it is a FAQ ... Note that it is not always possible to separate IO from pure code. As an example, consider an HTTP 1.1 server that read a request body containing a number for each line, and return a response body containing the sum of the numbers. Here, you can not really separate IO from pure computation. And you can not use lazy IO, if you want your server to support HTTP 1.1 pipelining. Regards Manlio Perillo From simon at joyful.com Sun Apr 19 12:28:18 2009 From: simon at joyful.com (Simon Michael) Date: Sun Apr 19 12:14:47 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <948097907@web.de> References: <948097907@web.de> Message-ID: > Yes, it is bad that the runhaskell Setup interface has a different default. But, as Duncan > said, too late to change it now. Why, especially as it seems something you would now rarely use directly ? (When would you want it ?) From daniel.is.fischer at web.de Sun Apr 19 14:00:42 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Apr 19 13:47:14 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: References: <948097907@web.de> Message-ID: <200904192000.42570.daniel.is.fischer@web.de> Am Sonntag 19 April 2009 18:28:18 schrieb Simon Michael: > > Yes, it is bad that the runhaskell Setup interface has a different > > default. But, as Duncan said, too late to change it now. > > Why, especially as it seems something you would now rarely use directly ? > (When would you want it ?) > Because the two interfaces to the Cabal library having different default behaviours can easily confuse people using both or switching to cabal. It's not a show-stopper, just an annoyance. From simon at joyful.com Sun Apr 19 14:47:30 2009 From: simon at joyful.com (Simon Michael) Date: Sun Apr 19 14:33:59 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <200904192000.42570.daniel.is.fischer@web.de> References: <948097907@web.de> <200904192000.42570.daniel.is.fischer@web.de> Message-ID: I meant, why is it too late to change the Setup interface to match cabal's --user by default behaviour ? From uhollerbach at gmail.com Sun Apr 19 15:21:07 2009 From: uhollerbach at gmail.com (Uwe Hollerbach) Date: Sun Apr 19 15:07:22 2009 Subject: [Haskell-cafe] ANNOUNCE: Runge-Kutta library -- solve ODEs Message-ID: <65d7a7e0904191221r21926100sabbb2e2f7f421020@mail.gmail.com> Hello, all, I'm pleased to announce a small Runge-Kutta library for numerically solving ordinary differential equations, which I'm hereby unleashing upon an unsuspecting world. The README is as follows: This is a small module collecting about a dozen Runge-Kutta methods of different orders, along with a couple of programs to exercise them. Build and run testrk, volterra, volterra2, and arenstorf: o testrk exercises all of the methods in a non-adaptive way, solving a test problem with a known analytic solution, to check convergence. (This was what first indicated that there was a problem with the Fehlberg 7(8) listing in HNW.) o volterra uses a non-adaptive method to solve the Lotka-Volterra equations from t=0 to t=40: either from a built-in starting point, or from a starting point specified on the command line. o volterra2 does the same, except it uses an adaptive solver o arenstorf solves the restricted 3-body problem (earth+moon+satellite) using an adaptive solver with some specific initial conditions which yield periodic orbits The volterra2 and arenstorf examples use an "oracle" function to decide what is a good step size. Right now that oracle function is in each test file; arguably it should be in the RungeKutta module. Eventually it will be, but I haven't spent much time yet on making that oracle especially good. I have so far only tested it with ghc 6.8.3 on MacOS 10.3.9 (powerPC), but I know of no reason why it wouldn't work with other versions and OSs. It's BSD licensed, in fact I stole the LICENSE file from ghc (and filed off the serial numbers). I'm afraid I haven't messed with cabal much yet, so it's not cabalized; neither is it uploaded to hackage, as I have no account there. If someone wants to do either of those, please feel entirely free to do so. In addition to attaching a tarball to this message, I'm also putting this onto my (sadly neglected) web site: it will live at http://www.korgwal.com/software/rk-1.0.0.tar.gz. Enjoy! Uwe -------------- next part -------------- A non-text attachment was scrubbed... Name: rk-1.0.0.tar.gz Type: application/x-gzip Size: 9010 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090419/96a64fde/rk-1.0.0.tar.bin From lrpalmer at gmail.com Sun Apr 19 15:24:59 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun Apr 19 15:11:15 2009 Subject: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree] In-Reply-To: <49EB47B0.2060400@libero.it> References: <49e4a38f870a9_4de11555555879b421f9@weasel11.tmail> <49EB47B0.2060400@libero.it> Message-ID: <7ca3f0160904191224p1d8b7ab0icfc261517062b386@mail.gmail.com> On Sun, Apr 19, 2009 at 9:48 AM, Manlio Perillo wrote: > Henning Thielemann ha scritto: > > > > On Tue, 14 Apr 2009, rodrigo.bonifacio wrote: > > > >> I guess this is a very simple question. How can I convert IO [XmlTree] > >> to just a list of > >> XmlTree? > > > > The old Wiki had: > > http://www.haskell.org/wikisnapshot/ThatAnnoyingIoType.html > > > > Should be ported to the new Wiki since it is a FAQ ... > > Note that it is not always possible to separate IO from pure code. > As an example, consider an HTTP 1.1 server that read a request body > containing a number for each line, and return a response body containing > the sum of the numbers. What? sumRequest :: String -> String -- strips header, sums numbers, returns response sumServer :: IO () -- reads from socket, writes sumRequest to socket And many other permutations, with differing degrees of laziness and parametericity. Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090419/d4e4599e/attachment.htm From r.a.niemeijer at tue.nl Sun Apr 19 15:46:53 2009 From: r.a.niemeijer at tue.nl (Niemeijer, R.A.) Date: Sun Apr 19 15:33:12 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release Message-ID: <9BEB5EF43B5A4042B60C0D8179782DB3D693F5C9F7@EXCHANGE10.campus.tue.nl> > * Experimental language extensions, some of which have not been > implemented before. Does anybody know if there are any plans to incorporate some of these extensions into GHC - specifically the existential typing ? I would love to be able to use existential typing without having to give up the robustness of GHC. From bulat.ziganshin at gmail.com Sun Apr 19 16:07:03 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun Apr 19 15:53:36 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <9BEB5EF43B5A4042B60C0D8179782DB3D693F5C9F7@EXCHANGE10.campus.tue.nl> References: <9BEB5EF43B5A4042B60C0D8179782DB3D693F5C9F7@EXCHANGE10.campus.tue.nl> Message-ID: <11277450.20090420000703@gmail.com> Hello R.A., Sunday, April 19, 2009, 11:46:53 PM, you wrote: > Does anybody know if there are any plans to incorporate some of > these extensions into GHC - specifically the existential typing ? it is already here, but you should use "forall" keyword instead odf "exists" -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bugfact at gmail.com Sun Apr 19 16:07:37 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Apr 19 15:53:57 2009 Subject: [Haskell-cafe] Using GHC as an arrows preprocessor? In-Reply-To: <20090419145930.GA3889@soi.city.ac.uk> References: <20090419145930.GA3889@soi.city.ac.uk> Message-ID: On Sun, Apr 19, 2009 at 4:59 PM, Ross Paterson wrote: > On Sun, Apr 19, 2009 at 04:32:35PM +0200, Peter Verswyvelen wrote: > > I'm making some custom arrows and I'm getting bugs when using the GHC > > preprocessor, but not when using the old standalone preprocessor. > > > > In order to debug this, it would be nice to use GHC as an arrows > preprocessor > > (so converting the arrow notation into plain Haskell and outputting the > > converted source code); is this possible? > > It isn't: the desugaring in GHC maps type-annotated Haskell into GHC's > Core language. > > I'd be very interested in tracking down any behavioural differences between > the standalone preprocessor and the GHC implementation. Are these > strictness > bugs, or something else? Note that both of these translators assume that > your combinators satisfy the arrow laws. No it was a bug in my code, but it is much easier to track down this bug by inspecting the generated Haskell code. Yes I could have tried to prove the arrow laws but my code is rather complex, so I delayed the prove :-) It just happened that the arrow preprocessor generated different and more compact Haskell source code that did not reveal the bug I got with GHC's builtin arrow translator. Regarding arrow laws, it would be nice to have an arrow processor that makes use of extended arrow laws as described in the paper of Hai (Paul) Liu, Paul Hudak (Causal Commutative Arrows). Some of their optimizations are very impressive! Actually I learned arrows via Yampa, and I never realized that arrows are *not* commutative, so I got the wrong picture of arrows (actually a more beautiful picture...). E.g. - if I understand it correctly - f *** g does not have to be equal to g *** f according to the standard arrows laws, but FRP systems like Yampa actually do have this law (f *** g == g *** f). -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090419/11d71e3a/attachment-0001.htm From bugfact at gmail.com Sun Apr 19 16:27:38 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Apr 19 16:14:05 2009 Subject: [Haskell-cafe] Announce: A pragmatic Haskell .NET interop layer, 0.4.0 In-Reply-To: <49EA3BB9.5050304@gmail.com> References: <49EA3BB9.5050304@gmail.com> Message-ID: Cool. Slightly annoying is that your interop is weak typed, and performance might suffer because it will be using .NET reflection all the time I guess. Do you know the Salsa binding for .NET? This aims to do strong typing. Maybe both efforts could be combined. On Sat, Apr 18, 2009 at 10:44 PM, Sigbjorn Finne wrote: > > A new version of a Haskell .NET interop layer, hs-dotnet, has just been > released > and is now available for download, > > http://haskell.forkIO.com/dotnet > > It lets you access .NET functionality from Haskell and vice versa. Tool > support > is included in this release to aid such interop. > The new version includes development done since the start of the year. > Apart > from rewriting the internals completely to put it all on a sounder footing, > this > release includes proper support for .NET generic types (classes and > interfaces), > mapping them naturally on to Haskell parameterized types. > > The support for generics enables for instance mixed Haskell-.NET LINQ > programming; > see the distribution for examples of this along with some other interesting > applications of > the hs-dotnet interop layer. > > enjoy > --sigbjorn > > _______________________________________________ > 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/20090419/562d8e8d/attachment.htm From bugfact at gmail.com Sun Apr 19 16:43:34 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Apr 19 16:29:48 2009 Subject: [Haskell-cafe] General function to count list elements? In-Reply-To: References: <736016.58929.qm@web31106.mail.mud.yahoo.com> <5e0214850904180839w452394f8vcc78dcf2d606db52@mail.gmail.com> Message-ID: Sometimes I do miss the pragmatic C solution:- two function pointers that are equal surely represent the same functions (although in C nothing is really sure ;) - two function pointers that are different, might or might not represent that same functions. But this weak equality can sometimes be handy. For example, suppose you have a predicate a -> Bool, and a list of these predicates [a -> Bool], but you want to remove all functions that are obviously equal in the C way from the list for optimization... Okay big hack, and one could do this already with reallyUnsafePtrEquality# I guess... On Sat, Apr 18, 2009 at 6:02 PM, John A. De Goes wrote: > > Two functions are equal iff they have the same domain and range and the > same outputs for the same inputs. Simple to state, but extremely difficult > to implement in a useful way, and impossible to implement in a perfect way. > > If you had a compiler or algorithm capable of determining function > equality, you could use it to prove or disprove arbitrary theorems in > mathematics. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090419/8ec1a1a5/attachment.htm From wren at freegeek.org Sun Apr 19 16:56:29 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun Apr 19 16:42:44 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <11277450.20090420000703@gmail.com> References: <9BEB5EF43B5A4042B60C0D8179782DB3D693F5C9F7@EXCHANGE10.campus.tue.nl> <11277450.20090420000703@gmail.com> Message-ID: <49EB8FFD.2030600@freegeek.org> Bulat Ziganshin wrote: > Hello R.A., > > Sunday, April 19, 2009, 11:46:53 PM, you wrote: > >> Does anybody know if there are any plans to incorporate some of >> these extensions into GHC - specifically the existential typing ? > > it is already here, but you should use "forall" keyword instead odf > "exists" More particularly, enable Rank2Types and then for any type lambda F and for any type Y which does not capture @a@: (x :: exists a. F a) ==> (x :: forall a. F a) (f :: exists a. (F a -> Y)) ==> (f :: (forall a. F a) -> Y) -- Live well, ~wren From martijn at van.steenbergen.nl Sun Apr 19 17:19:07 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Sun Apr 19 17:05:22 2009 Subject: [Haskell-cafe] ANNOUNCE: Runge-Kutta library -- solve ODEs In-Reply-To: <65d7a7e0904191221r21926100sabbb2e2f7f421020@mail.gmail.com> References: <65d7a7e0904191221r21926100sabbb2e2f7f421020@mail.gmail.com> Message-ID: <49EB954B.20109@van.steenbergen.nl> Hi Uwe, Uwe Hollerbach wrote: > I have so far only tested it with ghc 6.8.3 on MacOS 10.3.9 (powerPC), > but I know of no reason why it wouldn't work with other versions and > OSs. It works fine on 6.10.1 on Leopard Intel as well. > I'm afraid I haven't messed with cabal much yet, so it's not > cabalized; neither is it uploaded to hackage, as I have no account > there. If someone wants to do either of those, please feel entirely > free to do so. It's really easy to do this, and I strongly suggest you do. To save you some work, here's a cabal file you can use that directly allows you to 'cabal install' your package: (filename: rungekutta.cabal) > Name: rungekutta > Version: 0.1 > > Cabal-Version: >= 1.2 > Build-Type: Simple > License: BSD3 > License-File: LICENSE > > Library > Build-Depends: base < 5 > Exposed-Modules: RungeKutta All you need to do is find a nice category for it (with matching module name), change the cabal file accordingly, create an account at hackage (see http://hackage.haskell.org/packages/accounts.html) and upload it. Hope this helps, Martijn. From barsoap at web.de Sun Apr 19 17:21:18 2009 From: barsoap at web.de (Achim Schneider) Date: Sun Apr 19 17:07:59 2009 Subject: [Haskell-cafe] Re: General function to count list elements? References: <736016.58929.qm@web31106.mail.mud.yahoo.com> <5e0214850904180839w452394f8vcc78dcf2d606db52@mail.gmail.com> Message-ID: <20090419232118.43df919c@solaris> Peter Verswyvelen wrote: > Sometimes I do miss the pragmatic C solution:- two function pointers > that are equal surely represent the same functions (although in C > nothing is really sure ;) > In haskell, they would, but C doesn't give you the same guarantee: int evil = 0; int wicked( int i_dare_you ) { return i_dare_you + (++evil); } Clearly, wicked and wicked are the same function, but they surely aren't indistinguishable, at least if you happen to call them. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From konrad at tylerc.org Sun Apr 19 17:39:05 2009 From: konrad at tylerc.org (Conrad Meyer) Date: Sun Apr 19 17:25:23 2009 Subject: [Haskell-cafe] Re: [Haskell] Helpful libraries to implement a board game? In-Reply-To: <2AE8F0A6-684C-494F-8831-D2DE77B9987A@rosemeier.info> References: <2AE8F0A6-684C-494F-8831-D2DE77B9987A@rosemeier.info> Message-ID: <200904191439.05180.konrad@tylerc.org> On Sunday 19 April 2009 01:39:40 pm Frank Rosemeier wrote: > Dear Haskellers, > > I would like to implement a board game for a single player in Haskell. > The pieces may be moved one step in any direction if there is no > piece next to it, > and the goal is to rearrange the pieces to their home positions. > The Haskell program should find an optimal solution (with minimal > number of moves). > > Can anybody recommend some helpful libraries for this task? > Any hints are very welcome! > > > Frank Rosemeier (This should probably be on haskell-cafe, so I'm moving it there, CC-ing the author.) Hi, If you're interested in gametree search (i.e. game AI), which it sounds like you are, then the game-tree library on Hackage may interest you[0]. [0]: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/game-tree Regards, -- Conrad Meyer From dan.doel at gmail.com Sun Apr 19 17:39:31 2009 From: dan.doel at gmail.com (Dan Doel) Date: Sun Apr 19 17:25:50 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) =?iso-8859-1?q?--=09first?= release In-Reply-To: <49EB8FFD.2030600@freegeek.org> References: <9BEB5EF43B5A4042B60C0D8179782DB3D693F5C9F7@EXCHANGE10.campus.tue.nl> <11277450.20090420000703@gmail.com> <49EB8FFD.2030600@freegeek.org> Message-ID: <200904191739.32711.dan.doel@gmail.com> On Sunday 19 April 2009 4:56:29 pm wren ng thornton wrote: > Bulat Ziganshin wrote: > > Hello R.A., > > > > Sunday, April 19, 2009, 11:46:53 PM, you wrote: > >> Does anybody know if there are any plans to incorporate some of > >> these extensions into GHC - specifically the existential typing ? > > > > it is already here, but you should use "forall" keyword instead odf > > "exists" > > More particularly, enable Rank2Types and then for any type lambda F and > for any type Y which does not capture @a@: > > (x :: exists a. F a) ==> (x :: forall a. F a) > > (f :: exists a. (F a -> Y)) ==> (f :: (forall a. F a) -> Y) Eh? I don't think this is right, at least not precisely. The first is certainly not correct, because exists a. F a is F A for some hidden A, whereas forall a. F a can be instantiated to any concrete F A. A higher rank encoding of this existential would be: forall r. (forall a. F a -> r) -> r encoding the existential as its universal eliminator, similar to encoding an inductive type by its corresponding fold. These two are (roughly?) isomorphic, because you can pass the function: f :: forall a. F a -> (exists a. F a) f x = x to the eliminator and get back a value with the existential type. What you can do in GHC is create existentially quantified data types, like so: data E f = forall a. E (f a) Then E F is roughly equivalent to (exists a. F a). And you can also make a type: data E f y = forall a. E (f a -> y) where E F Y is the same as (exists a. F a -> Y). But here you'd find that you can write: from :: (E f y) -> ((forall a. f a) -> y) from (E f) fa = f fa but not: to :: ((forall a. f a) -> y) -> (E f y) to f = E (\fa -> f fa) so these two are not equivalent, either. Rather: exists a. (F a -> Y) ~ forall r. (forall a. (f a -> y) -> r) -> r where we have: from :: E f y -> (forall r. (forall a. (f a -> y) -> r) -> r) from (E f) k = k f to :: (forall r. (forall a. (f a -> y) -> r) -> r) -> E f y to k = k E Similarly, you can encode universals as higher-rank existential eliminators. Of course, there are some cases where things reduce more nicely, like: (exists a. F a) -> Y ==> forall a. (F a -> Y) In any case, despite being able to encode existentials in this way, or use existentially quantified data types, it might be nice to have first-class existential types like UHC. But, I seem to recall this being investigated for GHC in the past, and it was decided that it added too much complexity with the rest of GHC's type system. My information is sketchy and third hand, though, and perhaps things have changed since then. -- Dan From duncan.coutts at worc.ox.ac.uk Sun Apr 19 17:46:26 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Apr 19 17:32:41 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: References: <948097907@web.de> <200904192000.42570.daniel.is.fischer@web.de> Message-ID: <1240177586.6315.108.camel@lantern> On Sun, 2009-04-19 at 11:47 -0700, Simon Michael wrote: > I meant, why is it too late to change the Setup interface to match > cabal's --user by default behaviour ? All the distro packages etc use the Setup.hs interface without explicitly specifying --global. Duncan From r.a.niemeijer at tue.nl Sun Apr 19 17:46:48 2009 From: r.a.niemeijer at tue.nl (Niemeijer, R.A.) Date: Sun Apr 19 17:33:04 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release Message-ID: <9BEB5EF43B5A4042B60C0D8179782DB3D693F5C9F8@EXCHANGE10.campus.tue.nl> If only it were that easy. Sadly, it's not. Let's look at the following example: data Test = Test { foo :: Int, bar :: Char, baz :: Bool } smallPrint t = concatMap (\f -> show $ f t) [foo, bar, baz] In this code the list [foo, bar, baz] should have the type [exists a. Show a => Test -> a]. If we explicitly specify the type, replacing the exists with a forall, then GHC complains about not being able to match Int, Char and Bool against type a. Forall is not the same as exists and GHC only implements the former. ________________________________________ From: Bulat Ziganshin [bulat.ziganshin@gmail.com] Sent: 19 April 2009 22:07 To: Niemeijer, R.A. Cc: haskell-cafe@haskell.org Subject: Re[2]: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release Hello R.A., Sunday, April 19, 2009, 11:46:53 PM, you wrote: > Does anybody know if there are any plans to incorporate some of > these extensions into GHC - specifically the existential typing ? it is already here, but you should use "forall" keyword instead odf "exists" -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From uhollerbach at gmail.com Sun Apr 19 17:58:29 2009 From: uhollerbach at gmail.com (Uwe Hollerbach) Date: Sun Apr 19 17:44:58 2009 Subject: [Haskell-cafe] ANNOUNCE: Runge-Kutta library -- solve ODEs In-Reply-To: <49EB954B.20109@van.steenbergen.nl> References: <65d7a7e0904191221r21926100sabbb2e2f7f421020@mail.gmail.com> <49EB954B.20109@van.steenbergen.nl> Message-ID: <65d7a7e0904191458h185fe397w3c6b965472ede35f@mail.gmail.com> Thanks, Martijn, glad to hear it's working for you too. I'll see what I can do about cabal+hackage... Uwe On 4/19/09, Martijn van Steenbergen wrote: > Hi Uwe, > > Uwe Hollerbach wrote: >> I have so far only tested it with ghc 6.8.3 on MacOS 10.3.9 (powerPC), >> but I know of no reason why it wouldn't work with other versions and >> OSs. > > It works fine on 6.10.1 on Leopard Intel as well. > >> I'm afraid I haven't messed with cabal much yet, so it's not >> cabalized; neither is it uploaded to hackage, as I have no account >> there. If someone wants to do either of those, please feel entirely >> free to do so. > > It's really easy to do this, and I strongly suggest you do. To save you > some work, here's a cabal file you can use that directly allows you to > 'cabal install' your package: > > (filename: rungekutta.cabal) > >> Name: rungekutta >> Version: 0.1 >> >> Cabal-Version: >= 1.2 >> Build-Type: Simple >> License: BSD3 >> License-File: LICENSE >> >> Library >> Build-Depends: base < 5 >> Exposed-Modules: RungeKutta > > All you need to do is find a nice category for it (with matching module > name), change the cabal file accordingly, create an account at hackage > (see http://hackage.haskell.org/packages/accounts.html) and upload it. > > Hope this helps, > > Martijn. > From alexey.skladnoy at gmail.com Sun Apr 19 18:32:05 2009 From: alexey.skladnoy at gmail.com (Alexey Khudyakov) Date: Sun Apr 19 18:18:19 2009 Subject: [Haskell-cafe] ANNOUNCE: Runge-Kutta library -- solve ODEs In-Reply-To: <65d7a7e0904191221r21926100sabbb2e2f7f421020@mail.gmail.com> References: <65d7a7e0904191221r21926100sabbb2e2f7f421020@mail.gmail.com> Message-ID: <8425cc0e0904191532i665a5332wb3253445aaab073a@mail.gmail.com> > I have so far only tested it with ghc 6.8.3 on MacOS 10.3.9 (powerPC), > but I know of no reason why it wouldn't work with other versions and > OSs. > It breaks on Linux (and all unices) because name of file in tarball is 'rungekutta.hs' not 'RungeKutta.hs' as required. In other words: god blame case-insensitive file systems. After renaming everything works just fine. From claus.reinke at talk21.com Sun Apr 19 18:37:43 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Sun Apr 19 18:24:00 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) --first release References: <9BEB5EF43B5A4042B60C0D8179782DB3D693F5C9F8@EXCHANGE10.campus.tue.nl> Message-ID: |data Test = Test { foo :: Int, bar :: Char, baz :: Bool } |smallPrint t = concatMap (\f -> show $ f t) [foo, bar, baz] |In this code the list [foo, bar, baz] should have the type [exists a. Show a => Test -> a]. {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ExistentialQuantification #-} data EShow = forall a. Show a => EShow a smallPrint t = concatMap (\f-> case f t of EShow a -> show a) [EShow . foo, EShow . bar, EShow . baz] data Test = Test { foo :: Int, bar :: Char, baz :: Bool } Apart from the extra wrapping, this hardcodes the class. So perhaps you'd prefer something like data E t = forall a. E (a->t) a smallPrint' t = concatMap (\f-> case f t of E show a -> show a) [E show . foo, E show . bar, E show . baz] GHC does have existentials (Hugs has them, too, and HBC had them as well?), but is more conservative about their use than UHC seems to be. Claus PS there's also the old standby of applying the functions in the interface and letting non-strict evaluation taking care of the rest (keeping the intermediate type implicit, instead of explicitly hidden): smallPrint_ t = concatMap (\f-> f t) [show . foo, show . bar, show . baz] From agocorona at gmail.com Sun Apr 19 18:38:39 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Sun Apr 19 18:24:54 2009 Subject: [Haskell-cafe] Re: [Haskell] ANN: persistent-map-0.0.0 In-Reply-To: References: Message-ID: Interesting. It seems similar to TCache. However the design is different. persistent-map store different finite maps whenever any of them are modified transactionally, while TCache handles a single hashTable of object of type "a" and from time to time store all the transactionally modified objects and rearange the hashTable size. 2009/4/19 Peter Robinson : > The persistent-map package [1] provides a thread-safe (STM) frontend > for finite map types together with a backend interface for persistent > storage. The TMap data type is thread-safe, since all access functions > run inside an STM monad . Any type that is an instance of > Data.Edison.Assoc.FiniteMapX (see EdisonAPI) can be used as a map > type. > > If a TMap is modified within an STM transaction, a corresponding > backend IO-request is added using the onCommit hook (cf. stm-io-hooks > package). To ensure consistency, the (Adv)STM monad runs these > requests iff the transaction commits. Additional backends (e.g. HDBC) > can be added by instantiating class Backend. > > Cheers, > Peter > > [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/persistent-map > _______________________________________________ > Haskell mailing list > Haskell@haskell.org > http://www.haskell.org/mailman/listinfo/haskell > From lennart at augustsson.net Sun Apr 19 18:45:29 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Sun Apr 19 18:31:44 2009 Subject: [Haskell-cafe] General function to count list elements? In-Reply-To: References: <736016.58929.qm@web31106.mail.mud.yahoo.com> <5e0214850904180839w452394f8vcc78dcf2d606db52@mail.gmail.com> Message-ID: And when the need gets big enough you pull out StablePtr and use that. :) On Sun, Apr 19, 2009 at 10:43 PM, Peter Verswyvelen wrote: > Sometimes I do miss the pragmatic C solution: > - two function pointers that are equal surely represent the same functions > (although in C nothing is really sure ;) > - two function pointers that are different, might or might not represent > that same functions. > But this weak equality can sometimes be handy. > For example, suppose you have a predicate a -> Bool, and a list of these > predicates [a -> Bool], but you want to remove all functions that are > obviously equal in the C way from the list for optimization... Okay big > hack, and one could do this already with reallyUnsafePtrEquality# I guess... > On Sat, Apr 18, 2009 at 6:02 PM, John A. De Goes wrote: >> >> Two functions are equal iff they have the same domain and range and the >> same outputs for the same inputs. Simple to state, but extremely difficult >> to implement in a useful way, and impossible to implement in a perfect way. >> >> If you had a compiler or algorithm capable of determining function >> equality, you could use it to prove or disprove arbitrary theorems in >> mathematics. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From bugfact at gmail.com Sun Apr 19 19:00:19 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Apr 19 18:46:33 2009 Subject: [Haskell-cafe] General function to count list elements? In-Reply-To: References: <736016.58929.qm@web31106.mail.mud.yahoo.com> <5e0214850904180839w452394f8vcc78dcf2d606db52@mail.gmail.com> Message-ID: Or a StableName? I guess StablePtr prevents the GC to move the Haskell object, so for just doing ugly comparing StableName would be better? On Mon, Apr 20, 2009 at 12:45 AM, Lennart Augustsson wrote: > And when the need gets big enough you pull out StablePtr and use that. :) > > On Sun, Apr 19, 2009 at 10:43 PM, Peter Verswyvelen > wrote: > > Sometimes I do miss the pragmatic C solution: > > - two function pointers that are equal surely represent the same > functions > > (although in C nothing is really sure ;) > > - two function pointers that are different, might or might not represent > > that same functions. > > But this weak equality can sometimes be handy. > > For example, suppose you have a predicate a -> Bool, and a list of these > > predicates [a -> Bool], but you want to remove all functions that are > > obviously equal in the C way from the list for optimization... Okay big > > hack, and one could do this already with reallyUnsafePtrEquality# I > guess... > > On Sat, Apr 18, 2009 at 6:02 PM, John A. De Goes > wrote: > >> > >> Two functions are equal iff they have the same domain and range and the > >> same outputs for the same inputs. Simple to state, but extremely > difficult > >> to implement in a useful way, and impossible to implement in a perfect > way. > >> > >> If you had a compiler or algorithm capable of determining function > >> equality, you could use it to prove or disprove arbitrary theorems in > >> mathematics. > > > > _______________________________________________ > > 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/20090420/ba85a752/attachment.htm From uhollerbach at gmail.com Sun Apr 19 19:04:00 2009 From: uhollerbach at gmail.com (Uwe Hollerbach) Date: Sun Apr 19 18:51:38 2009 Subject: [Haskell-cafe] ANNOUNCE: Runge-Kutta library -- solve ODEs In-Reply-To: <8425cc0e0904191532i665a5332wb3253445aaab073a@mail.gmail.com> References: <65d7a7e0904191221r21926100sabbb2e2f7f421020@mail.gmail.com> <8425cc0e0904191532i665a5332wb3253445aaab073a@mail.gmail.com> Message-ID: <65d7a7e0904191604l770bb3d1jc273b4d8792419c4@mail.gmail.com> Damn, I never thought of that. Sorry! Guess I've only been haskell-hacking on my little old iMac... A new version is attached, with the version number bumped up by 0.0.1 and rungekutta.hs renamed to RungeKutta.hs. Hopefully it should work out-of-the-box now. Off to patch my repository... Uwe On 4/19/09, Alexey Khudyakov wrote: >> I have so far only tested it with ghc 6.8.3 on MacOS 10.3.9 (powerPC), >> but I know of no reason why it wouldn't work with other versions and >> OSs. >> > It breaks on Linux (and all unices) because name of file in tarball is > 'rungekutta.hs' not > 'RungeKutta.hs' as required. In other words: god blame > case-insensitive file systems. > > After renaming everything works just fine. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- A non-text attachment was scrubbed... Name: rk-1.0.1.tar.gz Type: application/x-gzip Size: 9019 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090419/dea683b1/rk-1.0.1.tar.bin From agocorona at gmail.com Sun Apr 19 19:06:25 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Sun Apr 19 18:52:40 2009 Subject: Fwd: [Haskell-cafe] General function to count list elements? In-Reply-To: References: <902810.3141.qm@web31107.mail.mud.yahoo.com> Message-ID: here goes a test of ?pointer equality (valid for functions too): samepointer :: a -> a -> IO Bool samepointer f1 f2 = do ? ? ? p1<- varHash f1 ? ? ? p2<- varHash f2 ? ? ? return $ ?p1 == p2 ? where ? ?varHash x= ?do ? ? ? sn <- makeStableName x ? ? ? return ?$ hashStableName sn 2009/4/18 ?: > Hi John, > > Yes, I see now what the hullabaloo was about. > > I've only been hacking Haskell for a few weeks, so I'm still seeing the > "forest" rather than the "trees". But I'm coming along. > > Thanks. > > Michael > > --- On Sat, 4/18/09, John Dorsey wrote: > > From: John Dorsey > Subject: Re: [Haskell-cafe] General function to count list elements? > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Saturday, April 18, 2009, 2:36 PM > > Michael, > >> I had a count function that worked fine for an enum type, but thought >> why not go polymorphic with it. So I changed it and got the error I >> originally inquired about. > > For variety, I'll go a slightly different direction. > > If you generalize count to use any predicate, instead of always > equality... > > ??? gcount :: (a -> a -> Bool) -> a -> [a] -> Int > ??? gcount pred x0 xs = length (filter (pred x0) xs) > > ??? count = gcount (==) > > This will work with any type that you can write a predicate for with the > type (a -> a -> Bool).? I can even use this with functions, if I'm > careful. > > ??? ghci> gcount (\f g -> True)? ? ???(*2) [id,(const 1),(*3)] > ??? 3 > ??? ghci> gcount (\f g -> f 1 == g 1) (^2) [id,(const 1),(*3)] > ??? 2 > > By the way, do you see why everyone's bothing you about comparing > functions?? The type you gave count, which didn't have an Eq constraint, > was an assertion that you could compare two values of *any* type.? If > there's a type that's not comparable, then count's type was wrong. > Functions are the canonical example of an incomparable type. > > When you're bored some time, read a bit about the Curry-Howard > correspondence.? It's interesting, even if (like me) you don't grok all > of its implications. > > Regards, > John > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From wren at freegeek.org Sun Apr 19 19:11:51 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun Apr 19 18:58:06 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <200904191739.32711.dan.doel@gmail.com> References: <9BEB5EF43B5A4042B60C0D8179782DB3D693F5C9F7@EXCHANGE10.campus.tue.nl> <11277450.20090420000703@gmail.com> <49EB8FFD.2030600@freegeek.org> <200904191739.32711.dan.doel@gmail.com> Message-ID: <49EBAFB7.5070506@freegeek.org> Dan Doel wrote: > On Sunday 19 April 2009 4:56:29 pm wren ng thornton wrote: > > Bulat Ziganshin wrote: > > > Hello R.A., > > > > > > Sunday, April 19, 2009, 11:46:53 PM, you wrote: > > > > Does anybody know if there are any plans to incorporate some of > > > > these extensions into GHC - specifically the existential typing ? > > > > > > it is already here, but you should use "forall" keyword instead odf > > > "exists" > > > > More particularly, enable Rank2Types and then for any type lambda F and > > for any type Y which does not capture @a@: > > > > (x :: exists a. F a) ==> (x :: forall a. F a) > > > > (f :: exists a. (F a -> Y)) ==> (f :: (forall a. F a) -> Y) > > Eh? I don't think this is right, at least not precisely. The first is > certainly not correct, because > > exists a. F a > > is F A for some hidden A, whereas > > forall a. F a > > can be instantiated to any concrete F A. Yes, however, because consumers (e.g. @f@) demand that their arguments remain polymorphic, anything which reduces the polymorphism of @a@ in @x@ will make it ineligible for being passed to consumers. Maybe not precise, but it works. Another take is to use (x :: forall a. () -> F a) and then once you pass () in then the return value is "for some @a@". It's easy to see that this is the same as the version above. > A higher rank encoding of this > existential would be: > > forall r. (forall a. F a -> r) -> r > > encoding the existential as its universal eliminator, similar to encoding an > inductive type by its corresponding fold. Exactly. Whether you pass a polymorphic function to an eliminator (as I had), or pass the universal eliminator to an applicator (as you're suggesting) isn't really important, it's just type lifting: (x :: forall a. F a) ==> (x :: forall r. (forall a. F a -> r) -> r) (f :: (forall a. F a) -> Y) ==> (f :: ((forall a. F a -> Y) -> Y) -> Y)) The type lifted version is more precise in the sense that it distinguishes polymorphic values from existential values (rather than overloading the sense of polymorphism), but I don't think it's more correct in any deep way. > What you can do in GHC is create existentially quantified data types, like so: > > data E f = forall a. E (f a) > > Then E F is roughly equivalent to (exists a. F a). But only roughly. E F has extra bottoms which distinguish it from (exists a. F a), which can be of real interest. -- Live well, ~wren From lennart at augustsson.net Sun Apr 19 19:25:07 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Sun Apr 19 19:11:21 2009 Subject: [Haskell-cafe] General function to count list elements? In-Reply-To: References: <736016.58929.qm@web31106.mail.mud.yahoo.com> <5e0214850904180839w452394f8vcc78dcf2d606db52@mail.gmail.com> Message-ID: Sorry, I meant StableName. On Mon, Apr 20, 2009 at 1:00 AM, Peter Verswyvelen wrote: > Or a StableName? I guess StablePtr prevents the GC to move the Haskell > object, so for just doing ugly comparing StableName would be better? > > On Mon, Apr 20, 2009 at 12:45 AM, Lennart Augustsson > wrote: >> >> And when the need gets big enough you pull out StablePtr and use that. :) >> >> On Sun, Apr 19, 2009 at 10:43 PM, Peter Verswyvelen >> wrote: >> > Sometimes I do miss the pragmatic C solution: >> > - two function pointers that are equal surely represent the same >> > functions >> > (although in C nothing is really sure ;) >> > - two function pointers that are different, might or might not represent >> > that same functions. >> > But this weak equality can sometimes be handy. >> > For example, suppose you have a predicate a -> Bool, and a list of these >> > predicates [a -> Bool], but you want to remove all functions that are >> > obviously equal in the C way from the list for optimization... Okay big >> > hack, and one could do this already with reallyUnsafePtrEquality# I >> > guess... >> > On Sat, Apr 18, 2009 at 6:02 PM, John A. De Goes >> > wrote: >> >> >> >> Two functions are equal iff they have the same domain and range and the >> >> same outputs for the same inputs. Simple to state, but extremely >> >> difficult >> >> to implement in a useful way, and impossible to implement in a perfect >> >> way. >> >> >> >> If you had a compiler or algorithm capable of determining function >> >> equality, you could use it to prove or disprove arbitrary theorems in >> >> mathematics. >> > >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > Haskell-Cafe@haskell.org >> > http://www.haskell.org/mailman/listinfo/haskell-cafe >> > >> > > > From ajb at spamcop.net Sun Apr 19 20:29:29 2009 From: ajb at spamcop.net (ajb@spamcop.net) Date: Sun Apr 19 20:15:43 2009 Subject: [Haskell-cafe] Looking for the fastest Haskell primes algorithm In-Reply-To: <49E7EC9C.4070205@imageworks.com> References: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AE99C@EXCHANGE10.campus.tue.nl> <5e0214850904140557i251935f8gf90402c65dfb470@mail.gmail.com> <20090416221601.hr9z3fbhckksckg8-nwo@webmail.spamcop.net> <49E7EC9C.4070205@imageworks.com> Message-ID: <20090419202929.x9g45jipnkk448cs-nwo@webmail.spamcop.net> G'day all. Quoting Dan Weston : > Unless primesUpTo n goes from highest to lowest prime (ending in 2), I > don't see how sharing is possible (in either space or time) between > primesUpTo for different n. Given that it's a mistake for a library to leak memory, there are essentially three possibilities: Make the implementation impure, move responsibility onto the application, or only retain a finite number of primes between calls. This library: http://andrew.bromage.org/darcs/numbertheory/ only retains primes up to product [2,3,5,7,11,13,17], for several reasons: - It's convenient for the wheel algorithm to store all primes up to the product of the first k primes for some k. - It's ultra-convenient if the stored primes can fit in machine words. - For the types of numbers that we typically care about, it's useful to store at least all primes up to 2^(w/2) where w is the machine word size. - Storing more than a million seemed wrong. Cheers, Andrew Bromage From dan.doel at gmail.com Sun Apr 19 20:46:10 2009 From: dan.doel at gmail.com (Dan Doel) Date: Sun Apr 19 20:32:30 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <49EBAFB7.5070506@freegeek.org> References: <9BEB5EF43B5A4042B60C0D8179782DB3D693F5C9F7@EXCHANGE10.campus.tue.nl> <200904191739.32711.dan.doel@gmail.com> <49EBAFB7.5070506@freegeek.org> Message-ID: <200904192046.11158.dan.doel@gmail.com> On Sunday 19 April 2009 7:11:51 pm wren ng thornton wrote: > Yes, however, because consumers (e.g. @f@) demand that their arguments > remain polymorphic, anything which reduces the polymorphism of @a@ in > @x@ will make it ineligible for being passed to consumers. Maybe not > precise, but it works. > > Another take is to use (x :: forall a. () -> F a) and then once you pass > () in then the return value is "for some @a@". It's easy to see that > this is the same as the version above. No, I'm relatively sure this doesn't work. Take, for instance, F a = a for simplicity. Then we can say: i :: Int i = 5 ei :: exists a. a ei = i Because ei's type, exists a. a, means "this expression has some unknown type." And certainly, the value i does have some type; it's Int. By contrast, you won't be writing: ei' :: forall a. a ei' = i and similarly: ei'' :: forall a. () -> a ei'' () = i is not a correct type, because i is not a value that belongs to every type. However, we can write: ei''' :: forall r. (forall a. a -> r) -> r ei''' k = k i as well as translations between types like it and the existential: toE :: (forall r. (forall a. a -> r) -> r) -> (exists a. a) toE f = f (\x -> x) toU :: (exists a. a) -> (forall r. (forall a. a -> r) -> r) toU e k = k e 'forall' in GHC means universal quantification. It's doesn't work as both universal and existential quantification. The only way it's involved with existential quantification is when you're defining an existential datatype, where: data T = forall a. C ... is used because the type of the constructor: C :: forall a. ... -> T is equivalent to the: C :: (exists a. ...) -> T you'd get if the syntax were instead: data T = C (exists a. ...) Which is somewhat confusing, but forall is standing for universal quantification even here. > Exactly. Whether you pass a polymorphic function to an eliminator (as I > had), or pass the universal eliminator to an applicator (as you're > suggesting) isn't really important, it's just type lifting: > > (x :: forall a. F a) ==> (x :: forall r. (forall a. F a -> r) -> r) > > (f :: (forall a. F a) -> Y) ==> (f :: ((forall a. F a -> Y) -> Y) -> Y)) > > > The type lifted version is more precise in the sense that it > distinguishes polymorphic values from existential values (rather than > overloading the sense of polymorphism), but I don't think it's more > correct in any deep way. I don't really understand what you mean by "type lifting". But although you might be able to write functions with types similar to what you've listed above (for instance, of course you can write a function: foo :: (forall a. F a) -> (forall r. (forall a. F a -> r) -> r) foo x k = k x simply because this is essentially a function with type (forall a. F a) -> (exists a. F a) and you can do that by instantiating the argument to any type, and then hiding it in an existential), this does not mean the types above are isomorphic, which they aren't in general. > But only roughly. E F has extra bottoms which distinguish it from > (exists a. F a), which can be of real interest. Well, you can get rid of the extra bottom with data E f = forall a. E !(f a) but first-class existentials are still desirable because introducing a new type for every existential is annoying. It's comparable to having to write a new class for every combination of argument and result types to mimic first class functions in Java (aside from first class functions being more ubiquitous in their usefulness, although perhaps it only appears that way because we don't have easy use of existential types). -- Dan From patperry at stanford.edu Sun Apr 19 21:14:53 2009 From: patperry at stanford.edu (Patrick Perry) Date: Sun Apr 19 21:01:07 2009 Subject: [Haskell-cafe] Re: Matrices Message-ID: <4B019755-D95E-4B8E-B685-4C1D84DD1594@stanford.edu> Hi Cetin, This is probably the easiest way: > (m - es)^2/es listMatrix (2,2) [0.6163270413689804,0.600918865334756,0.33217626255600896,0.3238718559921087 ] This will create 2 temporary arrays. Alternatively, > let res = listMatrix (shape m) [ (o-e)^2 / e | o <- colElems m | e <- colElems es ] where colElems = concatMap elems . cols > res listMatrix (2,2) [0.6163270413689804,0.600918865334756,0.33217626255600896,0.3238718559921087 ] In a later version of the library, "colElems" will probably be built- in. This version has the disadvantage that it doesn't use BLAS calls. If you *really* want to get tricky and eliminate temporary arrays: > runSTMatrix $ do res <- newCopyMatrix m subMatrix res es modifyWith (^2) res divMatrix res es return res Now, to get the sum: > sumAbs $ vectorFromMatrix res 1.8732940252518542 or > sum $ elems res 1.8732940252518542 The first version will usually be more efficient, since it calls the BLAS1 function "dasum". Patrick From derek.a.elkins at gmail.com Sun Apr 19 21:31:27 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sun Apr 19 21:17:46 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <200904192046.11158.dan.doel@gmail.com> References: <9BEB5EF43B5A4042B60C0D8179782DB3D693F5C9F7@EXCHANGE10.campus.tue.nl> <200904191739.32711.dan.doel@gmail.com> <49EBAFB7.5070506@freegeek.org> <200904192046.11158.dan.doel@gmail.com> Message-ID: <1240191087.5990.16.camel@derek-laptop> On Sun, 2009-04-19 at 20:46 -0400, Dan Doel wrote: > On Sunday 19 April 2009 7:11:51 pm wren ng thornton wrote: > > Yes, however, because consumers (e.g. @f@) demand that their arguments > > remain polymorphic, anything which reduces the polymorphism of @a@ in > > @x@ will make it ineligible for being passed to consumers. Maybe not > > precise, but it works. > > > > Another take is to use (x :: forall a. () -> F a) and then once you pass > > () in then the return value is "for some @a@". It's easy to see that > > this is the same as the version above. > > No, I'm relatively sure this doesn't work. Take, for instance, F a = a for > simplicity. Then we can say: > > i :: Int > i = 5 > > ei :: exists a. a > ei = i > > Because ei's type, exists a. a, means "this expression has some unknown type." > And certainly, the value i does have some type; it's Int. > > By contrast, you won't be writing: > > ei' :: forall a. a > ei' = i > > and similarly: > > ei'' :: forall a. () -> a > ei'' () = i > > is not a correct type, because i is not a value that belongs to every type. > However, we can write: > > ei''' :: forall r. (forall a. a -> r) -> r > ei''' k = k i > > as well as translations between types like it and the existential: > > toE :: (forall r. (forall a. a -> r) -> r) -> (exists a. a) > toE f = f (\x -> x) > > toU :: (exists a. a) -> (forall r. (forall a. a -> r) -> r) > toU e k = k e > You can build a framework around this encoding, pack :: f a -> (forall a. f a -> r) -> r pack x f = f x open :: (forall r.(forall a. f a -> r) -> r) -> (forall a. f a -> r) -> r open package k = package k Unfortunately, pack is mostly useless without impredicativity and lacking type lambdas requires a motley of data types to be made for f. > 'forall' in GHC means universal quantification. It's doesn't work as both > universal and existential quantification. The only way it's involved with > existential quantification is when you're defining an existential datatype, > where: > > data T = forall a. C ... > > is used because the type of the constructor: > > C :: forall a. ... -> T > > is equivalent to the: > > C :: (exists a. ...) -> T > > you'd get if the syntax were instead: > > data T = C (exists a. ...) > > Which is somewhat confusing, but forall is standing for universal > quantification even here. > > > Exactly. Whether you pass a polymorphic function to an eliminator (as I > > had), or pass the universal eliminator to an applicator (as you're > > suggesting) isn't really important, it's just type lifting: > > > > (x :: forall a. F a) ==> (x :: forall r. (forall a. F a -> r) -> r) > > > > (f :: (forall a. F a) -> Y) ==> (f :: ((forall a. F a -> Y) -> Y) -> Y)) > > > > > > The type lifted version is more precise in the sense that it > > distinguishes polymorphic values from existential values (rather than > > overloading the sense of polymorphism), but I don't think it's more > > correct in any deep way. > > I don't really understand what you mean by "type lifting". But although you > might be able to write functions with types similar to what you've listed > above (for instance, of course you can write a function: > > foo :: (forall a. F a) -> (forall r. (forall a. F a -> r) -> r) > foo x k = k x > > simply because this is essentially a function with type > > (forall a. F a) -> (exists a. F a) > > and you can do that by instantiating the argument to any type, and then hiding > it in an existential), You can do this by using undefined, but without using undefined what if F a = Void ? From dan.doel at gmail.com Sun Apr 19 22:04:44 2009 From: dan.doel at gmail.com (Dan Doel) Date: Sun Apr 19 21:51:01 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <1240191087.5990.16.camel@derek-laptop> References: <9BEB5EF43B5A4042B60C0D8179782DB3D693F5C9F7@EXCHANGE10.campus.tue.nl> <200904192046.11158.dan.doel@gmail.com> <1240191087.5990.16.camel@derek-laptop> Message-ID: <200904192204.44965.dan.doel@gmail.com> On Sunday 19 April 2009 9:31:27 pm Derek Elkins wrote: > > simply because this is essentially a function with type > > > > (forall a. F a) -> (exists a. F a) > > > > and you can do that by instantiating the argument to any type, and then > > hiding it in an existential), > > You can do this by using undefined, but without using undefined what if > F a = Void ? If it is, then you're giving me a Void, and I'm putting it in a box. Apparently I've not installed Agda since I installed GHC 6.10.2, but I'd expect something like the following to work: data VoidF (t : Set) : Set where data Unit : Set where unit : Unit data ? (f : Set -> Set) : Set1 where box : {t : Set} -> f t -> ? f box-it : (forall t -> VoidF t) -> ? VoidF box-it void = box (void Unit) It's just going to be difficult to get a value with type forall t -> VoidF t in the first place. -- Dan From ok at cs.otago.ac.nz Sun Apr 19 22:08:33 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Sun Apr 19 21:54:50 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <20090419145226.70c4e3c9@solaris> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <20090419145226.70c4e3c9@solaris> Message-ID: <573331E6-A9FE-45D4-AA5B-3329973D6C6B@cs.otago.ac.nz> On 20 Apr 2009, at 12:52 am, Achim Schneider wrote: >> Why? Is there something about Haskell 98 that's hard to >> implement? >> > Insanity. I doubt anyone is going to miss n+k patterns: They are one of my favourite features. They express briefly and neatly what would otherwise take several separate steps to express. From ok at cs.otago.ac.nz Sun Apr 19 23:26:19 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Sun Apr 19 23:12:38 2009 Subject: [Haskell-cafe] General function to count list elements? In-Reply-To: <858747.3995.qm@web31106.mail.mud.yahoo.com> References: <858747.3995.qm@web31106.mail.mud.yahoo.com> Message-ID: On 19 Apr 2009, at 4:27 am, michael rice wrote: > I know functions can be compared in Scheme > > Welcome to DrScheme, version 4.1 [3m]. > Language: Swindle; memory limit: 128 megabytes. > > (equal? equal? equal?) > #t > > > > but apparently not in Haskell I have a copy of R6RS somewhere, but I'll refer to R5RS. Section 6.1 says there are three equality predicates: eq? eqv? equal? (eqv? obj1 obj2) returns #t if "obj1 nd obj2 are procedures whose location-tags are equal", it returns #f if they "are procedures that would behave differently ... for some arguments." Section 4.1.4 says "Each procedure created as the result of evaluating a lambda expression is (conceptually) tagged with a storage location in order to make eqv? and eq? work on procedures." What this boils down to is that (let ((F (lambda (X) (list X X)))) (eqv? F F)) is defined to answer true and (let ((F (lambda (X) (list X X))) (G (lambda (X) (cons X X)))) (eqv? F G)) is defined to answer false. But the Scheme reports are very very careful to leave (let ((F (lambda (X) (list X X))) (G (lambda (X) (list X X)))) (eqv? F G)) *UN*defined except that it is some Boolean value. Applied to procedures, eq? and equal? are the same as eqv?. Scheme equality of procedures is not the same thing as mathematical equality of functions. Two mathematically equal functions may or may not compare equal in Scheme. And Scheme implementations may differ. For example, (let ((F (lambda (X) (list X X))) (G (lambda (X) (list X X)))) (eqv? F G)) *might* be optimised to #t, but then again, it *might* be optimised to #f, and both answers are "right" by R5RS. Haskell tries to be a little more defined than that (:-). From r.a.niemeijer at tue.nl Mon Apr 20 03:27:05 2009 From: r.a.niemeijer at tue.nl (Niemeijer, R.A.) Date: Mon Apr 20 03:13:24 2009 Subject: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <20090420010123.80CD9324652@www.haskell.org> References: <20090420010123.80CD9324652@www.haskell.org> Message-ID: <9BEB5EF43B5A4042B60C0D8179782DB3D6942AF0BC@EXCHANGE10.campus.tue.nl> > data EShow = forall a. Show a => EShow a > > data E t = forall a. E (a->t) a > > smallPrint_ t = concatMap (\f-> f t) [show . foo, show . bar, show . baz] Yeah, I am aware of these solutions, but like Dan says: > but first-class existentials are still desirable because introducing a new > type for every existential is annoying. It's comparable to having to write a > new class for every combination of argument and result types to mimic first > class functions in Java (aside from first class functions being more > ubiquitous in their usefulness, although perhaps it only appears that way > because we don't have easy use of existential types). I've personally always looked at the extra data type or repeated functions as ugly hacks around the fact that GHC doesn't have real existential typing. Since Haskell is otherwise virtually free of ugly hacks (at least at the level I work at, which doesn't require things like unsafePerformIO and unboxed arrays) this has always annoyed me a bit. So I figured that since we now have a working implementation it would be worth a shot to ask if this language wart can be removed from GHC. From bugfact at gmail.com Mon Apr 20 03:41:17 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Apr 20 03:27:31 2009 Subject: [Haskell-cafe] Optimizing unamb by determining the "state" of a thunk? Message-ID: I was wandering if it would be possible to optimize unamb by checking if a value is already evaluated to head normal form. So f `unamb` g would then be extremely fast if either f or g is already evaluated to head normal form. Maybe using some vacuum tricks? This function would need to be in IO since it is of course not referentially transparent. Although threads are lightweight in Haskell, forking/waiting/killing surely must have more overhead than just checking the thunk of an expression? Of course one could also make unamb a primitive :-) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090420/7d56629d/attachment.htm From tom.davie at gmail.com Mon Apr 20 04:23:27 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Mon Apr 20 04:09:46 2009 Subject: [Haskell-cafe] Optimizing unamb by determining the "state" of a thunk? In-Reply-To: References: Message-ID: <517AA469-4A57-4ADE-89E5-9C7D91C93EFD@gmail.com> On 20 Apr 2009, at 09:41, Peter Verswyvelen wrote: > I was wandering if it would be possible to optimize unamb by > checking if a value is already evaluated to head normal form. > > So > > f `unamb` g > > would then be extremely fast if either f or g is already evaluated > to head normal form. > > Maybe using some vacuum tricks? > > This function would need to be in IO since it is of course not > referentially transparent. Really? Is it any less referentially transparent than unamb already is - i.e. it's referentially transparent, as long as the two values really are equal. > Although threads are lightweight in Haskell, forking/waiting/killing > surely must have more overhead than just checking the thunk of an > expression? > > Of course one could also make unamb a primitive :-) That would be a lovely solution for me. Bob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090420/daf56ac8/attachment.htm From bugfact at gmail.com Mon Apr 20 04:57:46 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Apr 20 04:44:00 2009 Subject: [Haskell-cafe] Optimizing unamb by determining the "state" of a thunk? In-Reply-To: <517AA469-4A57-4ADE-89E5-9C7D91C93EFD@gmail.com> References: <517AA469-4A57-4ADE-89E5-9C7D91C93EFD@gmail.com> Message-ID: On Mon, Apr 20, 2009 at 10:23 AM, Thomas Davie wrote: > Really? Is it any less referentially transparent than unamb already is - > i.e. it's referentially transparent, as long as the two values really are > equal. > I think it is. Suppose we call the function hnf :: a -> Bool. hnf might return a different result for the same argument, since the evaluation of the argument might be happening on a different thread, so the result of hnf depends on the time when it is evaluated. Or am I missing something here? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090420/5eaff57c/attachment.htm From tom.davie at gmail.com Mon Apr 20 05:19:14 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Mon Apr 20 05:05:29 2009 Subject: [Haskell-cafe] Optimizing unamb by determining the "state" of a thunk? In-Reply-To: References: <517AA469-4A57-4ADE-89E5-9C7D91C93EFD@gmail.com> Message-ID: <166C1634-5CC9-4B89-AE27-66C67A2D6ABD@gmail.com> On 20 Apr 2009, at 10:57, Peter Verswyvelen wrote: > On Mon, Apr 20, 2009 at 10:23 AM, Thomas Davie > wrote: > Really? Is it any less referentially transparent than unamb already > is - i.e. it's referentially transparent, as long as the two values > really are equal. > > I think it is. Suppose we call the function hnf :: a -> Bool. hnf > might return a different result for the same argument, since the > evaluation of the argument might be happening on a different thread, > so the result of hnf depends on the time when it is evaluated. Or > am I missing something here? Sure, so hnf would give us a non-determined result, but I don't think that makes unamb any less referentially transparent ? the same value is always returned, and always reduced at least to hnf. Bob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090420/bc032b89/attachment.htm From jon.fairbairn at cl.cam.ac.uk Mon Apr 20 05:59:07 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Mon Apr 20 05:45:35 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <20090419145226.70c4e3c9@solaris> Message-ID: Achim Schneider writes: > Jon Fairbairn wrote: > >> atze@cs.uu.nl writes: >> >> > Utrecht Haskell Compiler -- first release, version 1.0.0 >> > ======================================================== >> > >> > >> > The UHC team is happy to announce the first public release of the >> > Utrecht Haskell Compiler (UHC). UHC supports almost all Haskell98 >> > features >> >> Why? Is there something about Haskell 98 that's hard to >> implement? >> > Insanity. I doubt anyone is going to miss n+k patterns: That (taken with the followup from Richard O'Keefe saying he does use them) underlines my point, really. What follows is specific to Haskell, but the general point applies to most languages I've encountered. I have no love for n+k patterns, but they are part of Haskell98 -- and were the subject of protracted arguments for and against them before the Report was finished (I was against them, if I remember correctly). Any implementation claiming to be of Haskell98 should have them, whether or not the implementor likes them, because otherwise someone will come along with a valid Haskell98 programme and it won't compile, so they'll have to hack it around. This sort of thing (and resulting #ifdef all over the place) wastes far more programmer time in the end (assuming the compiler becomes popular) than it would take to implement the feature. It's not an implementor's place to make such decisions -- they can legitimately say "this feature sucks" and tell the next Haskell committee so. If they care enough about it, they can lobby or get on that next committee, but the arguments for n+k patterns /in Haskell98/ were done long ago. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (updated 2009-01-31) From miguelimo38 at yandex.ru Mon Apr 20 06:12:14 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon Apr 20 05:59:00 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <20090419145226.70c4e3c9@solaris> Message-ID: <49EC4A7E.30400@yandex.ru> I disagree. First of all, UHC states explicitly that some features are not supported (and probably never would be). Secondly, it seems like almost nobody uses (n+k)-patterns, and when they are used, they make the code less readable; so it's good NOT to support them, in order to make programmers avoid them as much as possible. I don't think #ifdef's would be really "all over the place"; it's more likely that a minor refactoring would take place so that (n+k)-patterns would disappear. Jon Fairbairn wrote on 20.04.2009 13:59: > Achim Schneider writes: > >> Jon Fairbairn wrote: >> >>> atze@cs.uu.nl writes: >>> >>>> Utrecht Haskell Compiler -- first release, version 1.0.0 >>>> ======================================================== >>>> >>>> >>>> The UHC team is happy to announce the first public release of the >>>> Utrecht Haskell Compiler (UHC). UHC supports almost all Haskell98 >>>> features >>> Why? Is there something about Haskell 98 that's hard to >>> implement? >>> >> Insanity. I doubt anyone is going to miss n+k patterns: > > That (taken with the followup from Richard O'Keefe saying he > does use them) underlines my point, really. What follows is > specific to Haskell, but the general point applies to most > languages I've encountered. > > I have no love for n+k patterns, but they are part of > Haskell98 -- and were the subject of protracted arguments > for and against them before the Report was finished (I was > against them, if I remember correctly). Any implementation > claiming to be of Haskell98 should have them, whether or not > the implementor likes them, because otherwise someone will > come along with a valid Haskell98 programme and it won't > compile, so they'll have to hack it around. This sort of > thing (and resulting #ifdef all over the place) wastes far > more programmer time in the end (assuming the compiler > becomes popular) than it would take to implement the > feature. > > It's not an implementor's place to make such decisions -- > they can legitimately say "this feature sucks" and tell the > next Haskell committee so. If they care enough about it, > they can lobby or get on that next committee, but the > arguments for n+k patterns /in Haskell98/ were done long > ago. > > From ganesh.sittampalam at credit-suisse.com Mon Apr 20 06:20:17 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Mon Apr 20 06:07:21 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) --first release In-Reply-To: <49EC4A7E.30400@yandex.ru> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl><20090419145226.70c4e3c9@solaris> <49EC4A7E.30400@yandex.ru> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B01ABAA45@ELON17P32001A.csfb.cs-group.com> Miguel Mitrofanov wrote: > Jon Fairbairn wrote on 20.04.2009 13:59: >> Achim Schneider writes: >> >>> Jon Fairbairn wrote: >>> >>>> atze@cs.uu.nl writes: >>>> >>>>> Utrecht Haskell Compiler -- first release, version 1.0.0 >>>>> ======================================================== >>>>> >>>>> >>>>> The UHC team is happy to announce the first public release of the >>>>> Utrecht Haskell Compiler (UHC). UHC supports almost all Haskell98 >>>>> features >>>> Why? Is there something about Haskell 98 that's hard to implement? >>>> >>> Insanity. I doubt anyone is going to miss n+k patterns: >> >> That (taken with the followup from Richard O'Keefe saying he does use >> them) underlines my point, really. What follows is specific to >> Haskell, but the general point applies to most languages I've >> encountered. >> >> I have no love for n+k patterns, but they are part of >> Haskell98 -- and were the subject of protracted arguments for and >> against them before the Report was finished (I was against them, if I >> remember correctly). Any implementation claiming to be of Haskell98 >> should have them, whether or not the implementor likes them, because >> otherwise someone will come along with a valid Haskell98 programme >> and it won't compile, so they'll have to hack it around. This sort of >> thing (and resulting #ifdef all over the place) wastes far more >> programmer time in the end (assuming the compiler becomes popular) >> than it would take to implement the feature. >> >> It's not an implementor's place to make such decisions -- they can >> legitimately say "this feature sucks" and tell the next Haskell >> committee so. If they care enough about it, they can lobby or get on >> that next committee, but the arguments for n+k patterns /in >> Haskell98/ were done long ago. >> >> > I disagree. First of all, UHC states explicitly that some features > are not supported (and probably never would be). Secondly, it seems > like almost nobody uses (n+k)-patterns, and when they are used, they > make the code less readable; so it's good NOT to support them, in > order to make programmers avoid them as much as possible. I don't > think #ifdef's would be really "all over the place"; it's more likely > that a minor refactoring would take place so that (n+k)-patterns > would disappear. In addition, (n+k) patterns will be removed from the standard as soon as the Haskell prime process produces a new one, so people who want to make their code support that new standard should be removing them right now. Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From jules at jellybean.co.uk Mon Apr 20 06:27:17 2009 From: jules at jellybean.co.uk (Jules Bean) Date: Mon Apr 20 06:13:31 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <20090419144930.0597700c@solaris> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <694519c50904181344s7846869md5f7646f8eb3b5c7@mail.gmail.com> <2FC7F375-0A9E-4629-A083-3094C86E5848@gmail.com> <694519c50904181531v26fbde6ft615689a539d2f5e5@mail.gmail.com> <5ABFAA75-120E-4459-BA92-FDE4624A1399@gmail.com> <1240127571.6315.92.camel@lantern> <1240132255.6315.103.camel@lantern> <20090419102428.GI29457@whirlpool.galois.com> <20090419144930.0597700c@solaris> Message-ID: <49EC4E05.2060901@jellybean.co.uk> Achim Schneider wrote: > Don Stewart wrote: > >> This means that 'cabal >> install' works out of the box on every system, without needing >> admin/root privs (esp. important for students). >> > ...and people who were bitten by sanity and thus never, ever touch /usr > manually, only through their distribution's package manager. This is good advice (/usr/local is fine though). However, the point here is surely that the de-facto default for all other downloaded programs - standard makefile setups, automake, autoconf, perl package, python packages, graphic installers like firefox - is do to what cabal calls a 'global' install by default. This makes cabal's inversion of default a violation of least surprise, however easy it may be to justify that user installs are better. From lennart at augustsson.net Mon Apr 20 06:52:30 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Mon Apr 20 06:38:44 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <20090419145226.70c4e3c9@solaris> Message-ID: I agree in principle; you should really implement the full Haskell98 if you claim to be a Haskell implementation. In the particular case of n+k I don't care, since I never use them and they are slated for removal in Hakell'. -- Lennart On Mon, Apr 20, 2009 at 11:59 AM, Jon Fairbairn wrote: > Achim Schneider writes: > >> Jon Fairbairn wrote: >> >>> atze@cs.uu.nl writes: >>> >>> > ? ? ? ?Utrecht Haskell Compiler -- first release, version 1.0.0 >>> > ? ? ? ?======================================================== >>> > >>> > >>> > The UHC team is happy to announce the first public release of the >>> > Utrecht Haskell Compiler (UHC). UHC supports almost all Haskell98 >>> > features >>> >>> Why? Is there something about Haskell 98 that's hard to >>> implement? >>> >> Insanity. I doubt anyone is going to miss n+k patterns: > > That (taken with the followup from Richard O'Keefe saying he > does use them) underlines my point, really. What follows is > specific to Haskell, but the general point applies to most > languages I've encountered. > > I have no love for n+k patterns, but they are part of > Haskell98 -- and were the subject of protracted arguments > for and against them before the Report was finished (I was > against them, if I remember correctly). Any implementation > claiming to be of Haskell98 should have them, whether or not > the implementor likes them, because otherwise someone will > come along with a valid Haskell98 programme and it won't > compile, so they'll have to hack it around. This sort of > thing (and resulting #ifdef all over the place) wastes far > more programmer time in the end (assuming the compiler > becomes popular) than it would take to implement the > feature. > > It's not an implementor's place to make such decisions -- > they can legitimately say "this feature sucks" and tell the > next Haskell committee so. If they care enough about it, > they can lobby or get on that next committee, but the > arguments for n+k patterns /in Haskell98/ were done long > ago. > > > -- > J?n Fairbairn ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Jon.Fairbairn@cl.cam.ac.uk > http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html ?(updated 2009-01-31) > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bulat.ziganshin at gmail.com Mon Apr 20 07:02:46 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Apr 20 06:54:05 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <20090419145226.70c4e3c9@solaris> Message-ID: <995500650.20090420150246@gmail.com> Hello Jon, Monday, April 20, 2009, 1:59:07 PM, you wrote: > It's not an implementor's place to make such decisions -- > they can legitimately say "this feature sucks" and tell the > next Haskell committee so. If they care enough about it, > they can lobby or get on that next committee, but the > arguments for n+k patterns /in Haskell98/ were done long > ago. if you really believe in that you said, you can spend your own time adding its support :) i never seen n+k patterns in real code so i understand developers that don't want to waste time just to compliant standard even if their efforts will be never really used -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From lennart at augustsson.net Mon Apr 20 07:17:13 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Mon Apr 20 07:03:28 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <995500650.20090420150246@gmail.com> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <20090419145226.70c4e3c9@solaris> <995500650.20090420150246@gmail.com> Message-ID: If every implementor got to choose what subset of the standard to implement that all code would have have to written in the implemented intersection. I think that's a terrible idea. The Haskell98 standard was set so there would be a baseline that people could rely on. When I implemented Haskell (both times) there were odds and ends that I really hated (some of those feelings have changed), but I did it anyway. -- Lennart On Mon, Apr 20, 2009 at 1:02 PM, Bulat Ziganshin wrote: > Hello Jon, > > Monday, April 20, 2009, 1:59:07 PM, you wrote: > >> It's not an implementor's place to make such decisions -- >> they can legitimately say "this feature sucks" and tell the >> next Haskell committee so. If they care enough about it, >> they can lobby or get on that next committee, but the >> arguments for n+k patterns /in Haskell98/ were done long >> ago. > > if you really believe in that you said, you can spend your own time > adding its support :) ?i never seen n+k patterns in real code so i > understand developers that don't want to waste time just to compliant > standard even if their efforts will be never really used > > > > -- > 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 miguelimo38 at yandex.ru Mon Apr 20 07:23:07 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon Apr 20 07:10:04 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <20090419145226.70c4e3c9@solaris> <995500650.20090420150246@gmail.com> Message-ID: <49EC5B1B.9000006@yandex.ru> Well, the problem is that every implementor does choose a subset of standart to implement. It's much worse in JavaScript - essential features working differently in Internet Explorer, Firefox, Opera, and Safari, and sometimes they even differ between versions; Web programmers still manage. (n+k)-patterns are nothing compared to that. Lennart Augustsson wrote on 20.04.2009 15:17: > If every implementor got to choose what subset of the standard to > implement that all code would have have to written in the implemented > intersection. I think that's a terrible idea. > The Haskell98 standard was set so there would be a baseline that > people could rely on. > > When I implemented Haskell (both times) there were odds and ends that > I really hated (some of those feelings have changed), but I did it > anyway. > > -- Lennart > > On Mon, Apr 20, 2009 at 1:02 PM, Bulat Ziganshin > wrote: >> Hello Jon, >> >> Monday, April 20, 2009, 1:59:07 PM, you wrote: >> >>> It's not an implementor's place to make such decisions -- >>> they can legitimately say "this feature sucks" and tell the >>> next Haskell committee so. If they care enough about it, >>> they can lobby or get on that next committee, but the >>> arguments for n+k patterns /in Haskell98/ were done long >>> ago. >> if you really believe in that you said, you can spend your own time >> adding its support :) i never seen n+k patterns in real code so i >> understand developers that don't want to waste time just to compliant >> standard even if their efforts will be never really used >> >> >> >> -- >> Best regards, >> Bulat mailto:Bulat.Ziganshin@gmail.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 > From lennart at augustsson.net Mon Apr 20 07:31:11 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Mon Apr 20 07:17:24 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <49EC5B1B.9000006@yandex.ru> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <20090419145226.70c4e3c9@solaris> <995500650.20090420150246@gmail.com> <49EC5B1B.9000006@yandex.ru> Message-ID: I don't think that other languages failing should be an excuse for Haskell to be equally bad. On Mon, Apr 20, 2009 at 1:23 PM, Miguel Mitrofanov wrote: > Well, the problem is that every implementor does choose a subset of standart > to implement. > > It's much worse in JavaScript - essential features working differently in > Internet Explorer, Firefox, Opera, and Safari, and sometimes they even > differ between versions; Web programmers still manage. (n+k)-patterns are > nothing compared to that. > > Lennart Augustsson wrote on 20.04.2009 15:17: >> >> If every implementor got to choose what subset of the standard to >> implement that all code would have have to written in the implemented >> intersection. ?I think that's a terrible idea. >> The Haskell98 standard was set so there would be a baseline that >> people could rely on. >> >> When I implemented Haskell (both times) there were odds and ends that >> I really hated (some of those feelings have changed), but I did it >> anyway. >> >> ?-- Lennart >> >> On Mon, Apr 20, 2009 at 1:02 PM, Bulat Ziganshin >> wrote: >>> >>> Hello Jon, >>> >>> Monday, April 20, 2009, 1:59:07 PM, you wrote: >>> >>>> It's not an implementor's place to make such decisions -- >>>> they can legitimately say "this feature sucks" and tell the >>>> next Haskell committee so. If they care enough about it, >>>> they can lobby or get on that next committee, but the >>>> arguments for n+k patterns /in Haskell98/ were done long >>>> ago. >>> >>> if you really believe in that you said, you can spend your own time >>> adding its support :) ?i never seen n+k patterns in real code so i >>> understand developers that don't want to waste time just to compliant >>> standard even if their efforts will be never really used >>> >>> >>> >>> -- >>> Best regards, >>> ?Bulat ? ? ? ? ? ? ? ? ? ? ? ? ? ?mailto:Bulat.Ziganshin@gmail.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 >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From miguelimo38 at yandex.ru Mon Apr 20 07:35:47 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon Apr 20 07:22:25 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <20090419145226.70c4e3c9@solaris> <995500650.20090420150246@gmail.com> <49EC5B1B.9000006@yandex.ru> Message-ID: <49EC5E13.8030400@yandex.ru> Me neither; there were actually two points: 1) It's not bad; at least, it's not bad for reasons you provide. 2) It would be here whether we like it or not. Lennart Augustsson wrote on 20.04.2009 15:31: > I don't think that other languages failing should be an excuse for > Haskell to be equally bad. > > On Mon, Apr 20, 2009 at 1:23 PM, Miguel Mitrofanov > wrote: >> Well, the problem is that every implementor does choose a subset of standart >> to implement. >> >> It's much worse in JavaScript - essential features working differently in >> Internet Explorer, Firefox, Opera, and Safari, and sometimes they even >> differ between versions; Web programmers still manage. (n+k)-patterns are >> nothing compared to that. >> >> Lennart Augustsson wrote on 20.04.2009 15:17: >>> If every implementor got to choose what subset of the standard to >>> implement that all code would have have to written in the implemented >>> intersection. I think that's a terrible idea. >>> The Haskell98 standard was set so there would be a baseline that >>> people could rely on. >>> >>> When I implemented Haskell (both times) there were odds and ends that >>> I really hated (some of those feelings have changed), but I did it >>> anyway. >>> >>> -- Lennart >>> >>> On Mon, Apr 20, 2009 at 1:02 PM, Bulat Ziganshin >>> wrote: >>>> Hello Jon, >>>> >>>> Monday, April 20, 2009, 1:59:07 PM, you wrote: >>>> >>>>> It's not an implementor's place to make such decisions -- >>>>> they can legitimately say "this feature sucks" and tell the >>>>> next Haskell committee so. If they care enough about it, >>>>> they can lobby or get on that next committee, but the >>>>> arguments for n+k patterns /in Haskell98/ were done long >>>>> ago. >>>> if you really believe in that you said, you can spend your own time >>>> adding its support :) i never seen n+k patterns in real code so i >>>> understand developers that don't want to waste time just to compliant >>>> standard even if their efforts will be never really used >>>> >>>> >>>> >>>> -- >>>> Best regards, >>>> Bulat mailto:Bulat.Ziganshin@gmail.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 >>> >> _______________________________________________ >> 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 sebf at informatik.uni-kiel.de Mon Apr 20 07:48:37 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Mon Apr 20 07:34:53 2009 Subject: [Haskell-cafe] Code Golf In-Reply-To: References: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> <1bc51a990904151959k4cfc156fx682f4242ea78f56e@mail.gmail.com> <34485EA1-D608-4174-8364-48BC185F4DDE@informatik.uni-kiel.de> Message-ID: <184454C6-DE1F-473A-BF3D-67B8213A8E4A@informatik.uni-kiel.de> On Apr 18, 2009, at 2:48 AM, Sjoerd Visscher wrote: > using Matt Hellige's pointless fun > http://matt.immute.net/content/pointless-fun > > diag = foldr1 (zipWith (++) $. id ~> ([]:) ~> id) > $. map (++ repeat []) ~> takeWhile (not.null) > $. (map.map) (:[]) ~> concat pretty! Those seem to be exactly the combinators that I was looking for. Unfortunately, I still don't manage to mimic my version that uses functional lists and continuations (but no ++) mainly because I'm lacking an equivalent of the second line of the above solution which allows for the simpler 'zipWith (++)' instead of the merge function. Anyway, once you know what they mean, Matt's combinators are quite useful. Thanks for pointing that out! Cheers, Sebastian From Christian.Maeder at dfki.de Mon Apr 20 08:56:39 2009 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Mon Apr 20 08:42:52 2009 Subject: [Haskell-cafe] breaking too long lines Message-ID: <49EC7107.2030704@dfki.de> Hi, according the several style guides, lines shouldn't be too long (longer than 78 characters). http://www.cs.caltech.edu/courses/cs11/material/haskell/misc/haskell_style_guide.html http://www.haskell.org/haskellwiki/Programming_guidelines However, I miss hints how to break lines best. Therefore I make some suggestions here and ask for comments. If a "one-liner" does not fit on one line I break the line after "=" rather than breaking the following infix- or prefix-expression. (I break in the same way after "->" or "<-" in case- or do- expressions) (Some people move "=" to the next line, but I only suggest this for proper infix operators, below.) If a "do" or a short "case ... of" or "let ... in" fits, I leave it at the end of the previous line behind "=" ("->" or "<-"). A line should be broken after "do" or "of" (from "case") in order to allow insertions without breaking the layout, provided there is preceding text at all. The following is fine, because there's no text before "do") c x = do y <-... z ... But this is fine, too, if not better: c x = do y <- ... z ... It's not necessary to put "do" (or "let") on a separate line (and care about the indentation of that keyword): c x = do y <-... z ... Because layout may easily break (if b is renamed) and the layout block starts already too far to the right, this is really bad: c b x = unless b $ do y <- ... z ... In many cases a "do" can be moved to the end of the previous line: c b x = unless b $ do y <- ... z What applies to "do" could be applied to "let" as well (and vice versa), but: f x = let y = x + x z = y + y in z does not look as nice as: f x = let y = x + x z = y + y in z And also a "let" (without "in") within a "do" should not be broken after "let". A long infix-expression should be broken _before_ an infix symbol to better indicate it's continuation: f ++ g ++ h f . g $ h x (One should also put spaces around infix operators and should not put unnecessary brackets around prefix applications.) Surely a long prefix expression can be broken anywhere, but I try to break expressions on the top-level and not within too deeply nested sub-expressions: f arg1 arg2 arg3 (longArg4 sa1 sa2 sa3 sa4) arg5 arg6 arg7 After a line break (following "=", "do", "<-", or "->") I try to stay as far to the left as layout permits (using 2 spaces as minimal indentation). I don't care if "=", <-", or "->" of one block line up (which surely is difficult for the top-level module block) and I may put parts of the rhs below parts of the lhs: let longPattern = case bla of Nothing -> "don't know" Just b -> "a longer expression" vN = ... The standard breaking of if-then-else (within "do") is: if ... then ... else ... but I think the following variations are also fine: ... <- if ... then ... else ... if ... then ... else ... By chance I rarely use guards and "where", therefore I give no examples for those expressions. Somewhat tricky I've found are 2 do-expressions connected by an infix-operator within an outer do-expression: do c <- letter do d <- digit return [c, d] <|> do u <- char '_' return [c, u] The line containing "<|> do" is critical to indentation. If "<|> do" is moved (2 columns) to the left it'll be wrong (by chance c will not be in scope). If "<|> do" is moved (3 columns) to the right it'll mean something different, namely parsing and returning a letter and a digit _or_ parsing a letter, a digit, and an underscore, but only return the letter and the underscore. In order to more clearly put the infix operator into the middle I've tried to insert one more space: do c <- letter do d <- digit return [c, d] <|> do u <- char '_' return [c, u] Also the indentation of data types is an issue, because I think, code shouldn't be indented due to long (constructor) names. I've nothing against long names, but one shouldn't try to put blocks to the right of them: data TName = LongConstructorName { selector1 :: C1 , ... } | LongSecondConstructor .... deriving ... Cheers Christian From sjoerd at w3future.com Mon Apr 20 09:18:10 2009 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Mon Apr 20 09:04:28 2009 Subject: [Haskell-cafe] Code Golf In-Reply-To: <184454C6-DE1F-473A-BF3D-67B8213A8E4A@informatik.uni-kiel.de> References: <299E42C0-BFD8-4A67-B5C4-927A5A96ACF4@informatik.uni-kiel.de> <1bc51a990904151959k4cfc156fx682f4242ea78f56e@mail.gmail.com> <34485EA1-D608-4174-8364-48BC185F4DDE@informatik.uni-kiel.de> <184454C6-DE1F-473A-BF3D-67B8213A8E4A@informatik.uni-kiel.de> Message-ID: <81C4434C-98C1-42FC-8C05-EEB3D5F2306D@w3future.com> This is one with functional lists: diag = foldr1 (zipWith (.) $. id ~> (id:) ~> id) $. map (++ repeat id) ~> takeWhile (not.null.($[])) $. (map.map) (:) ~> ($[]) . mconcat On Apr 20, 2009, at 1:48 PM, Sebastian Fischer wrote: > > On Apr 18, 2009, at 2:48 AM, Sjoerd Visscher wrote: > >> using Matt Hellige's pointless fun >> http://matt.immute.net/content/pointless-fun >> >> diag = foldr1 (zipWith (++) $. id ~> ([]:) ~> id) >> $. map (++ repeat []) ~> takeWhile (not.null) >> $. (map.map) (:[]) ~> concat > > pretty! Those seem to be exactly the combinators that I was looking > for. > > Unfortunately, I still don't manage to mimic my version that uses > functional lists and continuations (but no ++) mainly because I'm > lacking an equivalent of the second line of the above solution which > allows for the simpler 'zipWith (++)' instead of the merge function. > > Anyway, once you know what they mean, Matt's combinators are quite > useful. Thanks for pointing that out! > > Cheers, > Sebastian > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Sjoerd Visscher sjoerd@w3future.com From nowgate at yahoo.com Mon Apr 20 09:27:21 2009 From: nowgate at yahoo.com (michael rice) Date: Mon Apr 20 09:13:37 2009 Subject: [Haskell-cafe] CPS and the product function Message-ID: <264161.44901.qm@web31101.mail.mud.yahoo.com> I've been looking at CPS in Haskell and wondering how many multiplications the product function performs if it encounters a zero somewhere in the input list. Zero? Does anyone know the definition of the product function? Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090420/86d83538/attachment-0001.htm From ekirpichov at gmail.com Mon Apr 20 09:40:42 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Mon Apr 20 09:26:56 2009 Subject: [Haskell-cafe] CPS and the product function In-Reply-To: <264161.44901.qm@web31101.mail.mud.yahoo.com> References: <264161.44901.qm@web31101.mail.mud.yahoo.com> Message-ID: <5e0214850904200640v6d851984td882ce685d52d84a@mail.gmail.com> Check that by experiment in ghci or by looking at the source: Prelude*> product [0..] Or search "product" at http://holumbus.fh-wedel.de/hayoo/hayoo.html and click on one of the Source links. 2009/4/20 michael rice : > I've been looking at CPS in Haskell and wondering how many multiplications > the product function performs if it encounters a zero somewhere in the input > list. Zero? > > Does anyone know the definition of the product function? > > Michael > > > > _______________________________________________ > 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 jake.mcarthur at gmail.com Mon Apr 20 09:42:17 2009 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Mon Apr 20 09:29:04 2009 Subject: [Haskell-cafe] Optimizing unamb by determining the "state" of a thunk? In-Reply-To: <166C1634-5CC9-4B89-AE27-66C67A2D6ABD@gmail.com> References: <517AA469-4A57-4ADE-89E5-9C7D91C93EFD@gmail.com> <166C1634-5CC9-4B89-AE27-66C67A2D6ABD@gmail.com> Message-ID: <49EC7BB9.1030405@gmail.com> > Sure, so hnf would give us a non-determined result, but I don't think > that makes unamb any less referentially transparent ? the same value is > always returned, and always reduced at least to hnf. I think it is hnf that Peter was talking about needing to be in IO, not unamb. - Jake From bugfact at gmail.com Mon Apr 20 09:47:02 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Apr 20 09:33:15 2009 Subject: [Haskell-cafe] Optimizing unamb by determining the "state" of a thunk? In-Reply-To: <49EC7BB9.1030405@gmail.com> References: <517AA469-4A57-4ADE-89E5-9C7D91C93EFD@gmail.com> <166C1634-5CC9-4B89-AE27-66C67A2D6ABD@gmail.com> <49EC7BB9.1030405@gmail.com> Message-ID: Yes indeed. On Mon, Apr 20, 2009 at 3:42 PM, Jake McArthur wrote: > Sure, so hnf would give us a non-determined result, but I don't think that >> makes unamb any less referentially transparent ? the same value is always >> returned, and always reduced at least to hnf. >> > > I think it is hnf that Peter was talking about needing to be in IO, not > unamb. > > - Jake > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090420/b6e370fa/attachment.htm From barsoap at web.de Mon Apr 20 09:57:01 2009 From: barsoap at web.de (Achim Schneider) Date: Mon Apr 20 09:43:45 2009 Subject: [Haskell-cafe] Re: General function to count list elements? References: <736016.58929.qm@web31106.mail.mud.yahoo.com> <5e0214850904180839w452394f8vcc78dcf2d606db52@mail.gmail.com> Message-ID: <20090420155701.79e812a5@solaris> Lennart Augustsson wrote: > On Sun, Apr 19, 2009 at 10:43 PM, Peter Verswyvelen > wrote: > > For example, suppose you have a predicate a -> Bool, and a list of > > these predicates [a -> Bool], but you want to remove all functions > > that are obviously equal in the C way from the list for > > optimization... Okay big hack, and one could do this already with > > reallyUnsafePtrEquality# I guess... > > And when the need gets big enough you pull out StablePtr and use > that. :) > Waaagh! Don't give him ideas, he's going to do it... Make yourself an enum, generate your list, nub it, then transform it to a list of functions. Always do everything with the least information sanely feasible, and a function is more information than a value, even if you can't get at it, anymore. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From barsoap at web.de Mon Apr 20 10:03:16 2009 From: barsoap at web.de (Achim Schneider) Date: Mon Apr 20 09:50:06 2009 Subject: [Haskell-cafe] Re: breaking too long lines References: <49EC7107.2030704@dfki.de> Message-ID: <20090420160316.443b8d94@solaris> Christian Maeder wrote: > [...] > All very fine, but what about simply moving code into a top-level binding or a function-level let/where? -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. From bugfact at gmail.com Mon Apr 20 10:17:12 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Apr 20 10:03:24 2009 Subject: [Haskell-cafe] Re: General function to count list elements? In-Reply-To: <20090420155701.79e812a5@solaris> References: <736016.58929.qm@web31106.mail.mud.yahoo.com> <5e0214850904180839w452394f8vcc78dcf2d606db52@mail.gmail.com> <20090420155701.79e812a5@solaris> Message-ID: A solution with enums would severely suffer from the expression problem... One would need to extent the enums every time one needs to support a new function. Maybe could be solved with type classes, don't know. On Mon, Apr 20, 2009 at 3:57 PM, Achim Schneider wrote: > Lennart Augustsson wrote: > > > On Sun, Apr 19, 2009 at 10:43 PM, Peter Verswyvelen > > wrote: > > > For example, suppose you have a predicate a -> Bool, and a list of > > > these predicates [a -> Bool], but you want to remove all functions > > > that are obviously equal in the C way from the list for > > > optimization... Okay big hack, and one could do this already with > > > reallyUnsafePtrEquality# I guess... > > > > And when the need gets big enough you pull out StablePtr and use > > that. :) > > > Waaagh! Don't give him ideas, he's going to do it... Make yourself an > enum, generate your list, nub it, then transform it to a list of > functions. Always do everything with the least information sanely > feasible, and a function is more information than a value, even if you > can't get at it, anymore. > > > -- > (c) this sig last receiving data processing entity. Inspect headers > for copyright history. All rights reserved. Copying, hiring, renting, > performance and/or quoting of this signature prohibited. > > > _______________________________________________ > 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/20090420/ac79c2aa/attachment.htm From nowgate at yahoo.com Mon Apr 20 10:32:47 2009 From: nowgate at yahoo.com (michael rice) Date: Mon Apr 20 10:19:00 2009 Subject: [Haskell-cafe] CPS and the product function Message-ID: <918950.77951.qm@web31105.mail.mud.yahoo.com> Hi Eugene, Clever solution. It didn't come right back so I interrupted it. Guess it would do all those multiplies by zero. Does anyone know how to define it to avoid that? Thanks. Michael --- On Mon, 4/20/09, Eugene Kirpichov wrote: From: Eugene Kirpichov Subject: Re: [Haskell-cafe] CPS and the product function To: "michael rice" Cc: haskell-cafe@haskell.org Date: Monday, April 20, 2009, 9:40 AM Check that by experiment in ghci or by looking at the source: Prelude*> product [0..] Or search "product" at http://holumbus.fh-wedel.de/hayoo/hayoo.html and click on one of the Source links. 2009/4/20 michael rice : > I've been looking at CPS in Haskell and wondering how many multiplications > the product function performs if it encounters a zero somewhere in the input > list. Zero? > > Does anyone know the definition of the product function? > > Michael > > > > _______________________________________________ > 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/20090420/93bc807e/attachment.htm From sfvisser at cs.uu.nl Mon Apr 20 10:39:30 2009 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Mon Apr 20 10:25:49 2009 Subject: [Haskell-cafe] CPS and the product function In-Reply-To: <918950.77951.qm@web31105.mail.mud.yahoo.com> References: <918950.77951.qm@web31105.mail.mud.yahoo.com> Message-ID: On Apr 20, 2009, at 4:32 PM, michael rice wrote: > Hi Eugene, > > Clever solution. > > It didn't come right back so I interrupted it. Guess it would do all > those multiplies by zero. > > Does anyone know how to define it to avoid that? > > Thanks. > > Michael > > --- On Mon, 4/20/09, Eugene Kirpichov wrote: > > From: Eugene Kirpichov > Subject: Re: [Haskell-cafe] CPS and the product function > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Monday, April 20, 2009, 9:40 AM > > Check that by experiment in ghci or by looking at the source: > > Prelude*> product [0..] > > Or search "product" at http://holumbus.fh-wedel.de/hayoo/hayoo.html > and click on one of the Source links. > > 2009/4/20 michael rice : > > I've been looking at CPS in Haskell and wondering how many > multiplications > > the product function performs if it encounters a zero somewhere in > the input > > list. Zero? > > > > Does anyone know the definition of the product function? > > > > Michael > Eugene Kirpichov Making multiplication non-strict? From rendel at cs.au.dk Mon Apr 20 10:44:58 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Mon Apr 20 10:30:57 2009 Subject: [Haskell-cafe] breaking too long lines In-Reply-To: <49EC7107.2030704@dfki.de> References: <49EC7107.2030704@dfki.de> Message-ID: <49EC8A6A.9050307@cs.au.dk> Christian Maeder wrote: > I've nothing against long names, but one shouldn't try to put blocks > to the right of them. This is very important from my point of view. Indention should not depend on identifier length. However, I make an exception to that rule sometimes for definitions which look like tables (e.g. step functions for abstract machines). > do c <- letter > do d <- digit > return [c, d] > <|> do > u <- char '_' > return [c, u] I try to avoid these, e.g. I would use this instead: do c <- letter choice [ do d <- digit return [c, d] , do u <- char '_' return [c, u] ] Actually, I try to avoid do-blocks, but that's a different story. > data TName = > LongConstructorName > { selector1 :: C1 > , ... } > | LongSecondConstructor > .... > deriving ... I use data Maybe a = Just a | Nothing deriving Show or data Maybe a = Just { fromJust :: a } | Nothing deriving Show However, I would prefer the following Coq-like syntax: data Maybe a = | Just a | Nothing Tillmann From leimy2k at gmail.com Mon Apr 20 10:46:08 2009 From: leimy2k at gmail.com (David Leimbach) Date: Mon Apr 20 10:32:20 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <20090419145226.70c4e3c9@solaris> <995500650.20090420150246@gmail.com> <49EC5B1B.9000006@yandex.ru> Message-ID: <3e1162e60904200746t66732813p86d2704c131d7909@mail.gmail.com> Just refuse to use UHC until it conforms. One can refuse to use GHC libraries that use extensions as well for similar reasons. I always think twice when I see something that isn't Haskell 98 in my stack. Anything that doesn't conform completely to Haskell 98 can effectively be considered not Haskell 98 at all (all or nothing mentality), if you want to be really strict. The fact is we have a choice... I won't tell people not to implement things in a way I don't like, I'll just look at it and decide whether I care to use it or not. As a result, UHC is not something I care to use, though I'm sure it's interesting for those who are using it. If I cared enough, and I don't, and the UHC sources are licensed in a way permitting so, I could make a Haskell 98 conforming version of it, and fork it myself. Dave On Mon, Apr 20, 2009 at 4:31 AM, Lennart Augustsson wrote: > I don't think that other languages failing should be an excuse for > Haskell to be equally bad. > > On Mon, Apr 20, 2009 at 1:23 PM, Miguel Mitrofanov > wrote: > > Well, the problem is that every implementor does choose a subset of > standart > > to implement. > > > > It's much worse in JavaScript - essential features working differently in > > Internet Explorer, Firefox, Opera, and Safari, and sometimes they even > > differ between versions; Web programmers still manage. (n+k)-patterns are > > nothing compared to that. > > > > Lennart Augustsson wrote on 20.04.2009 15:17: > >> > >> If every implementor got to choose what subset of the standard to > >> implement that all code would have have to written in the implemented > >> intersection. I think that's a terrible idea. > >> The Haskell98 standard was set so there would be a baseline that > >> people could rely on. > >> > >> When I implemented Haskell (both times) there were odds and ends that > >> I really hated (some of those feelings have changed), but I did it > >> anyway. > >> > >> -- Lennart > >> > >> On Mon, Apr 20, 2009 at 1:02 PM, Bulat Ziganshin > >> wrote: > >>> > >>> Hello Jon, > >>> > >>> Monday, April 20, 2009, 1:59:07 PM, you wrote: > >>> > >>>> It's not an implementor's place to make such decisions -- > >>>> they can legitimately say "this feature sucks" and tell the > >>>> next Haskell committee so. If they care enough about it, > >>>> they can lobby or get on that next committee, but the > >>>> arguments for n+k patterns /in Haskell98/ were done long > >>>> ago. > >>> > >>> if you really believe in that you said, you can spend your own time > >>> adding its support :) i never seen n+k patterns in real code so i > >>> understand developers that don't want to waste time just to compliant > >>> standard even if their efforts will be never really used > >>> > >>> > >>> > >>> -- > >>> Best regards, > >>> Bulat mailto:Bulat.Ziganshin@gmail.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 > >> > > _______________________________________________ > > 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/20090420/f07ce916/attachment.htm From bulat.ziganshin at gmail.com Mon Apr 20 10:42:03 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Apr 20 10:34:45 2009 Subject: [Haskell-cafe] CPS and the product function In-Reply-To: <918950.77951.qm@web31105.mail.mud.yahoo.com> References: <918950.77951.qm@web31105.mail.mud.yahoo.com> Message-ID: <47004671.20090420184203@gmail.com> Hello michael, Monday, April 20, 2009, 6:32:47 PM, you wrote: something like 0*_ = 0 x*y = x *# y or vice versa _*0 = 0 x*y = x *# y where *# is original (*) definition. current ghc definiton just performs cpu-level operation w/o checking for 0 since this is rarely useful and need some time OTOH, boolean operations are expected to short-circuit, so they are defined properly. try and (iterate [True,False]) > Hi Eugene, > Clever solution. > It didn't come right back so I interrupted it. Guess it would do all those multiplies by zero. > Does anyone know how to define it to avoid that? > Thanks. > Michael > --- On Mon, 4/20/09, Eugene Kirpichov wrote: > From: Eugene Kirpichov > Subject: Re: [Haskell-cafe] CPS and the product function > To: "michael rice" > Cc: haskell-cafe@haskell.org > Date: Monday, April 20, 2009, 9:40 AM > Check that by experiment in ghci or by looking at the source: Prelude*>> product [0..] > Or search "product" at http://holumbus.fh-wedel.de/hayoo/hayoo.html > and click on one of the Source links. > 2009/4/20 michael rice : >> I've been looking at CPS in Haskell and wondering how many multiplications >> the product function performs if it encounters a zero somewhere in the input >> list. Zero? >> >> Does anyone know the definition of the product function? >> >> Michael >> >> >> >> _______________________________________________ >> 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 rendel at cs.au.dk Mon Apr 20 11:07:29 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Mon Apr 20 10:53:29 2009 Subject: [Haskell-cafe] CPS and the product function In-Reply-To: <264161.44901.qm@web31101.mail.mud.yahoo.com> References: <264161.44901.qm@web31101.mail.mud.yahoo.com> Message-ID: <49EC8FB1.7030408@cs.au.dk> michael rice wrote: > I've been looking at CPS in Haskell and wondering how many multiplications the product function performs if it encounters a zero somewhere in the input list. Zero? > > Does anyone know the definition of the product function? You can use Hoogle [1] to search for product [2]. The documentation page [3] has a link to the source code [4]. Depending on some flag, it is either product = foldl (*) 1 or an explicit loop with an accumulator. That means that even for a non-strict (*), the whole input list would be processed before a result could be returned. > Does anyone know how to define it to avoid that? You have to define a multiplication function which is non-strict in the second argument if the first is 0. mult 0 b = 0 mult a b = a * b Now we can foldr this multiplication function over a list, and evaluation will stop at the first 0. foldr mult 1 ([1..100] ++ [0 ..]) However, this solution seems not to run in constant space. We can write it with a strict accumulator to avoid this problem: product = product' 1 where product' acc [] = acc product' acc (0 : xs) = 0 product' acc (x : xs) = (product' $! acc * x) xs Tillmann [1] http://www.haskell.org/hoogle/ [2] http://www.haskell.org/hoogle/?hoogle=product [3] http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:product [4] http://haskell.org/ghc/docs/latest/html/libraries/base/src/Data-List.html#product From martijn at van.steenbergen.nl Mon Apr 20 11:19:58 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Mon Apr 20 11:06:16 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <3e1162e60904200746t66732813p86d2704c131d7909@mail.gmail.com> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <20090419145226.70c4e3c9@solaris> <995500650.20090420150246@gmail.com> <49EC5B1B.9000006@yandex.ru> <3e1162e60904200746t66732813p86d2704c131d7909@mail.gmail.com> Message-ID: <49EC929E.3030202@van.steenbergen.nl> David Leimbach wrote: > Just refuse to use UHC until it conforms. One can refuse to use GHC > libraries that use extensions as well for similar reasons. I always > think twice when I see something that isn't Haskell 98 in my stack. Do you not use Hugs for the same reason? http://cvs.haskell.org/Hugs/pages/users_guide/haskell98.html#BUGS-HASKELL98 Martijn. From nowgate at yahoo.com Mon Apr 20 11:28:08 2009 From: nowgate at yahoo.com (michael rice) Date: Mon Apr 20 11:14:23 2009 Subject: [Haskell-cafe] CPS and the product function Message-ID: <313957.54039.qm@web31102.mail.mud.yahoo.com> This also seems to work: myprod l = prod l id ? where ??? prod [] k = k 1 ??? prod (x:xs) k = if x == 0 then 0 else prod xs (\ z -> k (x * z)) *Main Data.List> :load prod [1 of 1] Compiling Main???????????? ( prod.hs, interpreted ) Ok, modules loaded: Main. *Main Data.List> myprod [1,2,3,4,5,0,6,7,8,9] 0 *Main Data.List> myprod [1,2,3,4,5] 120 *Main Data.List> myprod [0..] 0 *Main Data.List> Michael --- On Mon, 4/20/09, Tillmann Rendel wrote: From: Tillmann Rendel Subject: Re: [Haskell-cafe] CPS and the product function To: haskell-cafe@haskell.org Date: Monday, April 20, 2009, 11:07 AM michael rice wrote: > I've been looking at CPS in Haskell and wondering how many multiplications the product function performs if it encounters a zero somewhere in the input list. Zero? > > Does anyone know the definition of the product function? You can use Hoogle [1] to search for product [2]. The documentation page [3] has a link to the source code [4]. Depending on some flag, it is either ? product = foldl (*) 1 or an explicit loop with an accumulator. That means that even for a non-strict (*), the whole input list would be processed before a result could be returned. > Does anyone know how to define it to avoid that? You have to define a multiplication function which is non-strict in the second argument if the first is 0. ? mult 0 b = 0 ? mult a b = a * b Now we can foldr this multiplication function over a list, and evaluation will stop at the first 0. ? foldr mult 1 ([1..100] ++ [0 ..]) However, this solution seems not to run in constant space. We can write it with a strict accumulator to avoid this problem: ? product = product' 1 where ? ? product' acc []? ? ???= acc ? ? product' acc (0 : xs) = 0 ? ? product' acc (x : xs) = (product' $! acc * x) xs Tillmann [1] http://www.haskell.org/hoogle/ [2] http://www.haskell.org/hoogle/?hoogle=product [3] http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:product [4] http://haskell.org/ghc/docs/latest/html/libraries/base/src/Data-List.html#product _______________________________________________ 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/20090420/40816a4a/attachment.htm From lrpalmer at gmail.com Mon Apr 20 11:34:32 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Apr 20 11:20:43 2009 Subject: [Haskell-cafe] Re: General function to count list elements? In-Reply-To: <20090420155701.79e812a5@solaris> References: <736016.58929.qm@web31106.mail.mud.yahoo.com> <5e0214850904180839w452394f8vcc78dcf2d606db52@mail.gmail.com> <20090420155701.79e812a5@solaris> Message-ID: <7ca3f0160904200834n5015467ak9e4c24e4f0d2dd8@mail.gmail.com> On Mon, Apr 20, 2009 at 7:57 AM, Achim Schneider wrote: > Lennart Augustsson wrote: > > > On Sun, Apr 19, 2009 at 10:43 PM, Peter Verswyvelen > > wrote: > > > For example, suppose you have a predicate a -> Bool, and a list of > > > these predicates [a -> Bool], but you want to remove all functions > > > that are obviously equal in the C way from the list for > > > optimization... Okay big hack, and one could do this already with > > > reallyUnsafePtrEquality# I guess... > > > > And when the need gets big enough you pull out StablePtr and use > > that. :) > > > Waaagh! Don't give him ideas, he's going to do it... Nah, I don't think so. I think, even after all this mess, we've been relatively clear that Eq is how you do it. Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090420/ae9fb23c/attachment.htm From Malcolm.Wallace at cs.york.ac.uk Mon Apr 20 11:38:01 2009 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Mon Apr 20 11:25:01 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <49EC929E.3030202@van.steenbergen.nl> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <20090419145226.70c4e3c9@solaris> <995500650.20090420150246@gmail.com> <49EC5B1B.9000006@yandex.ru> <3e1162e60904200746t66732813p86d2704c131d7909@mail.gmail.com> <49EC929E.3030202@van.steenbergen.nl> Message-ID: <20090420163801.22a4b9a5.Malcolm.Wallace@cs.york.ac.uk> > > Just refuse to use UHC until it conforms. > Do you not use Hugs for the same reason? Not to mention that GHC does not comply with the H'98 standard either: http://www.haskell.org/ghc/docs/latest/html/users_guide/bugs-and-infelicities.html#vs-Haskell-defn Regards, Malcolm From leimy2k at gmail.com Mon Apr 20 11:43:58 2009 From: leimy2k at gmail.com (David Leimbach) Date: Mon Apr 20 11:30:10 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <49EC929E.3030202@van.steenbergen.nl> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <20090419145226.70c4e3c9@solaris> <995500650.20090420150246@gmail.com> <49EC5B1B.9000006@yandex.ru> <3e1162e60904200746t66732813p86d2704c131d7909@mail.gmail.com> <49EC929E.3030202@van.steenbergen.nl> Message-ID: <3e1162e60904200843j49cf3195ud8619952858f85d7@mail.gmail.com> On Mon, Apr 20, 2009 at 8:19 AM, Martijn van Steenbergen < martijn@van.steenbergen.nl> wrote: > David Leimbach wrote: > >> Just refuse to use UHC until it conforms. One can refuse to use GHC >> libraries that use extensions as well for similar reasons. I always think >> twice when I see something that isn't Haskell 98 in my stack. >> > > Do you not use Hugs for the same reason? > > http://cvs.haskell.org/Hugs/pages/users_guide/haskell98.html#BUGS-HASKELL98 > > Martijn. > > I never use hugs... the only time I've ever run hugs, is because it was available for Plan 9. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090420/5b9c6b0b/attachment.htm From leimy2k at gmail.com Mon Apr 20 11:44:00 2009 From: leimy2k at gmail.com (David Leimbach) Date: Mon Apr 20 11:30:22 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <20090420163801.22a4b9a5.Malcolm.Wallace@cs.york.ac.uk> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <20090419145226.70c4e3c9@solaris> <995500650.20090420150246@gmail.com> <49EC5B1B.9000006@yandex.ru> <3e1162e60904200746t66732813p86d2704c131d7909@mail.gmail.com> <49EC929E.3030202@van.steenbergen.nl> <20090420163801.22a4b9a5.Malcolm.Wallace@cs.york.ac.uk> Message-ID: <3e1162e60904200844g7cdf06c6sda23fcf47424a09@mail.gmail.com> On Mon, Apr 20, 2009 at 8:38 AM, Malcolm Wallace < Malcolm.Wallace@cs.york.ac.uk> wrote: > > > Just refuse to use UHC until it conforms. > > Do you not use Hugs for the same reason? > > Not to mention that GHC does not comply with the H'98 standard either: > > > http://www.haskell.org/ghc/docs/latest/html/users_guide/bugs-and-infelicities.html#vs-Haskell-defn > > Regards, > Malcolm It's still a matter of choice. So we're saying there are no implementations of Haskell 98? Sounds like the same problem C++ and C99 have. 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/20090420/65f1e4a8/attachment.htm From nfjinjing at gmail.com Mon Apr 20 11:46:21 2009 From: nfjinjing at gmail.com (Jinjing Wang) Date: Mon Apr 20 11:32:37 2009 Subject: [Haskell-cafe] [ANN] Hack: a sexy Haskell Webserver Interface ^^ Message-ID: <81ea7d400904200846r2f1df6cdpc28eebb55272978d@mail.gmail.com> Simplest app should look like this module Main where import Hack import Hack.Handler.Kibro hello :: Application hello = \env -> return $ Response { status = 200 , headers = [ ("Content-Type", "text/plain") ] , body = "Hello World" } main = run hello Hack is a brainless port of the brilliant Ruby Rack framework. Rack is very modular and that's very important. Rack utilities and middlewares should be able to be ported with minimal effort, I hope. link / source: http://github.com/nfjinjing/hack/tree/master -- jinjing From vanenkj at gmail.com Mon Apr 20 11:48:42 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon Apr 20 11:34:53 2009 Subject: [Haskell-cafe] [ANN] Hack: a sexy Haskell Webserver Interface ^^ In-Reply-To: <81ea7d400904200846r2f1df6cdpc28eebb55272978d@mail.gmail.com> References: <81ea7d400904200846r2f1df6cdpc28eebb55272978d@mail.gmail.com> Message-ID: Can you stick this on Hackage? I'd love to play with it... On Mon, Apr 20, 2009 at 11:46 AM, Jinjing Wang wrote: > Simplest app should look like this > > module Main where > > import Hack > import Hack.Handler.Kibro > > hello :: Application > hello = \env -> return $ Response > { status = 200 > , headers = [ ("Content-Type", "text/plain") ] > , body = "Hello World" > } > > main = run hello > > Hack is a brainless port of the brilliant Ruby Rack framework. Rack is > very modular and that's > very important. > > Rack utilities and middlewares should be able to be ported with > minimal effort, I hope. > > link / source: http://github.com/nfjinjing/hack/tree/master > > -- > jinjing > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090420/2dfd8de3/attachment.htm From vanenkj at gmail.com Mon Apr 20 11:49:30 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon Apr 20 11:35:44 2009 Subject: [Haskell-cafe] [ANN] Hack: a sexy Haskell Webserver Interface ^^ In-Reply-To: References: <81ea7d400904200846r2f1df6cdpc28eebb55272978d@mail.gmail.com> Message-ID: Oh look: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hack-2009.4.20 *slinks away* On Mon, Apr 20, 2009 at 11:48 AM, John Van Enk wrote: > Can you stick this on Hackage? I'd love to play with it... > > > On Mon, Apr 20, 2009 at 11:46 AM, Jinjing Wang wrote: > >> Simplest app should look like this >> >> module Main where >> >> import Hack >> import Hack.Handler.Kibro >> >> hello :: Application >> hello = \env -> return $ Response >> { status = 200 >> , headers = [ ("Content-Type", "text/plain") ] >> , body = "Hello World" >> } >> >> main = run hello >> >> Hack is a brainless port of the brilliant Ruby Rack framework. Rack is >> very modular and that's >> very important. >> >> Rack utilities and middlewares should be able to be ported with >> minimal effort, I hope. >> >> link / source: http://github.com/nfjinjing/hack/tree/master >> >> -- >> jinjing >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > > -- > /jve > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090420/f368924c/attachment.htm From sfvisser at cs.uu.nl Mon Apr 20 12:25:25 2009 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Mon Apr 20 12:11:51 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release In-Reply-To: <3e1162e60904200844g7cdf06c6sda23fcf47424a09@mail.gmail.com> References: <49542.131.211.150.16.1240063432.squirrel@mail.cs.uu.nl> <20090419145226.70c4e3c9@solaris> <995500650.20090420150246@gmail.com> <49EC5B1B.9000006@yandex.ru> <3e1162e60904200746t66732813p86d2704c131d7909@mail.gmail.com> <49EC929E.3030202@van.steenbergen.nl> <20090420163801.22a4b9a5.Malcolm.Wallace@cs.york.ac.uk> <3e1162e60904200844g7cdf06c6sda23fcf47424a09@mail.gmail.com> Message-ID: On Apr 20, 2009, at 5:44 PM, David Leimbach wrote: > On Mon, Apr 20, 2009 at 8:38 AM, Malcolm Wallace > wrote: > > > Just refuse to use UHC until it conforms. > > Do you not use Hugs for the same reason? > > Not to mention that GHC does not comply with the H'98 standard either: > > http://www.haskell.org/ghc/docs/latest/html/users_guide/bugs-and-infelicities.html#vs-Haskell-defn > > Regards, > Malcolm > > > It's still a matter of choice. So we're saying there are no > implementations of Haskell 98? Sounds like the same problem C++ and > C99 have. > > Dave Why is this such a problem? You can still write and compile very beautiful programs with both GHC and UHC. And keep in mind that the UHC compiler is probably not designed to replace GHC and to be fully compliant with the Haskell 98 standard. It still has a very useful place in education and is certainly worth looking at. It is intensively making use of the attribute grammar system to perform traversals over the different internally used languages. This is a very different approach from what GHC does which makes it very interesting from an educational and scientific point of view. I encourage you to take a look inside, it is reasonably easy to grasp what going on inside of UHC. -- Sebastiaan From jfredett at gmail.com Mon Apr 20 12:30:47 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Apr 20 12:16:59 2009 Subject: [Haskell-cafe] [ANN] Hack: a sexy Haskell Webserver Interface ^^ In-Reply-To: <81ea7d400904200846r2f1df6cdpc28eebb55272978d@mail.gmail.com> References: <81ea7d400904200846r2f1df6cdpc28eebb55272978d@mail.gmail.com> Message-ID: <49ECA337.6040302@gmail.com> We need to start referring to more haskell packages as "sexy" /Joe Jinjing Wang wrote: > Simplest app should look like this > > module Main where > > import Hack > import Hack.Handler.Kibro > > hello :: Application > hello = \env -> return $ Response > { status = 200 > , headers = [ ("Content-Type", "text/plain") ] > , body = "Hello World" > } > > main = run hello > > Hack is a brainless port of the brilliant Ruby Rack framework. Rack is > very modular and that's > very important. > > Rack utilities and middlewares should be able to be ported with > minimal effort, I hope. > > link / source: http://github.com/nfjinjing/hack/tree/master > > -------------- next part -------------- A non-text attachment was scrubbed... Name: jfredett.vcf Type: text/x-vcard Size: 307 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090420/7e9124ce/jfredett.vcf From wagner.andrew at gmail.com Mon Apr 20 12:47:24 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Mon Apr 20 12:33:39 2009 Subject: [Haskell-cafe] [ANN] Hack: a sexy Haskell Webserver Interface ^^ In-Reply-To: <49ECA337.6040302@gmail.com> References: <81ea7d400904200846r2f1df6cdpc28eebb55272978d@mail.gmail.com> <49ECA337.6040302@gmail.com> Message-ID: Err, is there some reason you don't have simpler interfaces like:plaintext :: String -> Application plaintext text = \env -> return $ Response { status = 200 , headers = [ ("Content-Type", "text/plain") ] , body = text } On Mon, Apr 20, 2009 at 12:30 PM, Joe Fredette wrote: > We need to start referring to more haskell packages as "sexy" > > /Joe > > Jinjing Wang wrote: > >> Simplest app should look like this >> >> module Main where >> >> import Hack >> import Hack.Handler.Kibro >> >> hello :: Application >> hello = \env -> return $ Response >> { status = 200 >> , headers = [ ("Content-Type", "text/plain") ] >> , body = "Hello World" >> } >> >> main = run hello >> >> Hack is a brainless port of the brilliant Ruby Rack framework. Rack is >> very modular and that's >> very important. >> >> Rack utilities and middlewares should be able to be ported with >> minimal effort, I hope. >> >> link / source: http://github.com/nfjinjing/hack/tree/master >> >> >> > > _______________________________________________ > 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/20090420/6a35b151/attachment.htm From thaldyron at gmail.com Mon Apr 20 12:55:01 2009 From: thaldyron at gmail.com (Peter Robinson) Date: Mon Apr 20 12:41:31 2009 Subject: [Haskell-cafe] Re: [Haskell] ANN: persistent-map-0.0.0 In-Reply-To: References: Message-ID: 2009/4/20 Alberto G. Corona : > Interesting. It seems similar to TCache. It is indeed. I particularly like the feature of TCache that you can "fill" partially initialized values from the cache so I've added a similar high-level interface for TMap (module TStorage). Cheers, Peter From andrewcoppin at btinternet.com Mon Apr 20 15:17:10 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Apr 20 15:03:22 2009 Subject: [Haskell-cafe] [ANN] Hack: a sexy Haskell Webserver Interface ^^ In-Reply-To: <49ECA337.6040302@gmail.com> References: <81ea7d400904200846r2f1df6cdpc28eebb55272978d@mail.gmail.com> <49ECA337.6040302@gmail.com> Message-ID: <49ECCA36.4010109@btinternet.com> Joe Fredette wrote: > We need to start referring to more haskell packages as "sexy" Would *you* want to copulate with it? ;-) Hmm, no documentation... GHC log is complaining that "mps" is missing. Pitty. From lane at downstairspeople.org Mon Apr 20 16:00:46 2009 From: lane at downstairspeople.org (Christopher Lane Hinson) Date: Mon Apr 20 15:47:00 2009 Subject: [Haskell-cafe] Optimizing unamb by determining the "state" of a thunk? In-Reply-To: References: <517AA