From lambda-belka at yandex.ru Fri May 1 00:09:01 2009 From: lambda-belka at yandex.ru (Belka) Date: Thu Apr 30 23:54:40 2009 Subject: [Haskell-cafe] [tryReadAdvChan :: AdvChan a -> IO (Maybe a)] problems Message-ID: <23328237.post@talk.nabble.com> Hi! I need this function with requirement of heavy reads, *possibly under DDoS attack*. Was trying to write such function, but discovered some serious problems of ** possible racings, ** possible starvations ** unbalance: readAdvChan users may get better service than ones of tryReadAdvChan These are totally unacceptible for my case of DDoS risk. Actually, am I wrong thinking, that it can't be helped - and the degradation from cute concurency synchronization model of Chan is unavoidable? My (untested) code: ------------------------------------------- ------------------------------------------- module AdvChan ( AdvChan , newAdvChan , readAdvChan , writeAdvChan , writeList2AdvChan , advChan2StrictList , withResourceFromAdvChan , tryReadAdvChan , isEmptyAdvChan ) where import Control.Concurrent.Chan import Control.Concurrent.MVar data AdvChan a = AdvChan { acInst :: MVar Chan a , acWrite :: a -> IO () , acIsEmpty :: IO Bool } newAdvChan :: IO AdvChan a newAdvChan = do ch <- newChan mv_ch <- newMVar ch return AdvChan { acInst = mv_ch , acWrite = writeChan ch , acIsEmpty = isEmptyChan ch } readAdvChan :: AdvChan a -> IO a readAdvChan ach = modifyMVar (acInst ach) (\ ch -> do a <- readChan ch return (ch, a) ) writeAdvChan :: AdvChan a -> a -> IO () writeAdvChan = acWrite writeList2AdvChan :: AdvChan a -> [a] -> IO () writeList2AdvChan ach [] = return () writeList2AdvChan ach (h:t) = writeAdvChan ach h >> writeList2AdvChan ach t advChan2StrictList :: AdvChan a -> IO [a] advChan2StrictList ach = modifyMVar (acInst ach) (\ ch -> let readLoop = do emp <- isEmptyChan ch case emp of True -> return [] False -> do _head <- readChan ch _rest <- readLoop return (_head : _rest) in liftTuple (return ch, readLoop) ) withResourceFromAdvChan :: AdvChan a -> (\ a -> IO (a, b)) -> IO b withResourceFromAdvChan ach f = do res <- readAdvChan ach (res_processed, result) <- f res writeAdvChan ach res_processed return result isEmptyAdvChan :: AdvChan a -> IO Bool isEmptyAdvChan = acIsEmpty microDelta = 50 tryReadAdvChan :: AdvChan a -> IO (Maybe a) tryReadAdvChan ach = emp2Maybeness $ do mb_inst <- tryTakeMVar (acInst ach) case mb_inst of Nothing -> emp2Maybeness (threadDelay microDelta >> tryReadAdvChan ach) Just chan -> do emp <- isEmptyChan ch result <- case emp of True -> return Nothing False -> Just `liftM` readChan ch putMVar (acInst ach) chan return result where emp2Maybeness f = do emp <- isEmptyAdvChan ach case emp of True -> return Nothing False -> f ------------------------------------------- ------------------------------------------- Later after writing my own code, and understanding the problem I checked Hackage. Found "synchronous-channels" package there (http://hackage.haskell.org/cgi-bin/hackage-scripts/package/synchronous-channels), but it isn't any further in solving my the unbalacedness problems. Any suggestions on the fresh matter are welcome. Belka. -- View this message in context: http://www.nabble.com/-tryReadAdvChan-%3A%3A-AdvChan-a--%3E-IO-%28Maybe-a%29--problems-tp23328237p23328237.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From dons at galois.com Fri May 1 01:21:06 2009 From: dons at galois.com (Don Stewart) Date: Fri May 1 01:08:05 2009 Subject: [Haskell-cafe] The Haskell Reddit is 1 year old Message-ID: <20090501052106.GA19238@whirlpool.galois.com> Just a reminder, the Haskell Reddit is live and active: http://www.reddit.com/r/haskell/ It is a a place for fast, daily, comprehensive news about what's going on in the Haskell community, combining blogs, mail, irc, ghc's patches, the freaking types@ mailing list! It's all here, with comments. Enjoy. Contribute. -- Don From sargrigory at ya.ru Fri May 1 02:06:47 2009 From: sargrigory at ya.ru (Grigory Sarnitskiy) Date: Fri May 1 01:52:30 2009 Subject: [Haskell-cafe] Array Binary IO & molecular simulation Message-ID: <251001241158007@webmail128.yandex.ru> An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090501/25d23d86/attachment.htm From ivan.miljenovic at gmail.com Fri May 1 02:47:07 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Fri May 1 02:32:53 2009 Subject: [Haskell-cafe] ANNOUNCE: graphviz-2009.5.1 Message-ID: <87vdole2vo.fsf@gmail.com> I'd like to announce version 2009.5.1[1] of the graphviz[2] library, less than a week since Matthew Sackman passed maintainership onto me[3]. The graphviz library provides a Haskell interface to the GraphViz[4] program. [1] http://hackage.haskell.org/packages/archive/graphviz/2009.5.1/graphviz-2009.5.1.tar.gz [2] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/graphviz [3] http://www.mail-archive.com/haskell@haskell.org/msg21994.html [4] http://graphviz.org Major changes with this release are: * Supports polyparse >= 1.1 (the previous version didn't work with 1.3). * Requires base == 4.* (i.e. GHC 6.10.*) due to the new exception handling. * Includes functions from my Graphalyze [5] library for actually running the various GraphViz commands, etc. * Slight API breakages: - dirCommand, undirCommand and commandFor no longer return String, but GraphvizCommand - Data.GraphViz.ParserCombinators is no longer exported by the Cabal file, since I see no need for anyone to require acccess to this. If this is a problem for you, please let me know and I'll re-export it. * A lot more Haddock documentation. * A darcs repository is now available [6]. Patches are welcome! [5] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Graphalyze [6] http://code.haskell.org/graphviz Plans for the future: * Add support for Data.Graph-style graphs (maybe even making it generic such that custom graph types can be used). * Allow the user to choose whether the graph is directed or undirected. * Include all attributes offered by the Dot language. * Remove (or at least minimise) usage of extensions to increase portability. Oh, and to pre-empt Don, this is already available in the Gentoo-Haskell overlay ;-) -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From florbitous at gmail.com Fri May 1 03:16:39 2009 From: florbitous at gmail.com (Bernie Pope) Date: Fri May 1 03:02:19 2009 Subject: [Haskell-cafe] Few Alex questions In-Reply-To: References: Message-ID: <4d8ad03a0905010016x20a59a46wdd89cf94d9ced542@mail.gmail.com> 2009/5/1 Dimitry Golubovsky Can beginning of line (caret) be recognized by Alex? You can match the start of a line using a (left) context on a rule. See the docs here: http://www.haskell.org/alex/doc/html/alex-files.html#contexts Where it says: "The left context matches the character which immediately precedes the token in the input stream. The character immediately preceding the beginning of the stream is assumed to be ?\n?. The special left-context ?^? is shorthand for ?\n^?." Alex also supports right contexts too. Is this correct understanding that if we want to match any character > except for an asterisk, then Alex would like to see [^\*] rather than > [^*]? And [^\/] rather than [^/]? > > Or would it be better to use a hex code for the asterisk and slash? In a character set you must escape certain special characters. The list of special characters is specified in the docs here: http://www.haskell.org/alex/doc/html/syntax.html#lexical The key line is: $special = [\.\;\,\$\|\*\+\?\#\~\-\{\}\(\)\[\]\^\/] I'd try to avoid character codes where possible. Cheers, Bernie. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090501/317d2cb9/attachment.htm From maarten at snowlion.nl Fri May 1 03:29:23 2009 From: maarten at snowlion.nl (maarten) Date: Fri May 1 03:15:07 2009 Subject: [Haskell-cafe] Thread priority? In-Reply-To: References: Message-ID: <49FAA4D3.4010509@snowlion.nl> Hi all, Some two year I wrote a library to change thread priorities in Windows, including another library that allows real time processing. With this you can play midi files real time and without interruption from the OS. (Manipulating thread priorities is really easy in Windows, real time uninterrupted processing a little more complicated). Actually, I thought this problem was already resolved (haskore-realtime), but if there is interest I can see if I can dust them off, although I'm sure there will be still lots of things to improve. Right now I'm working in linux only, so it may take a few days to get a suitable xp version. (Actually, I would be really interested in a linux port, but have little time right now. Perhaps this library can help: http://sourceforge.net/projects/high-res-timers ?) Kind regards, Maarten Christopher Lane Hinson wrote: > > Is there any interest or movement in developing thread priority or any > other realtime support in Haskell? > > Right now, if I have tasks that need to be responsive in real time, > even if the realtime needs are very soft, it seems that the only > option is to try to ensure that at least one hardware thread is kept > clear of any other activity. > > To be very useful to me, thread priority would not need to come with > very strict guarantees, but there would need to be a way to make sure > that `par` sparks and DPH inherit the priority of the sparking thread. > > In part I ask because I'm working on a small library to support a > degree of cooperative task prioritization. > > Friendly, > --Lane > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From semanticphilosopher at googlemail.com Fri May 1 03:42:10 2009 From: semanticphilosopher at googlemail.com (Neil Davies) Date: Fri May 1 03:27:53 2009 Subject: [Haskell-cafe] [tryReadAdvChan :: AdvChan a -> IO (Maybe a)] problems In-Reply-To: <23328237.post@talk.nabble.com> References: <23328237.post@talk.nabble.com> Message-ID: <344909F5-7BC9-4893-9553-6FB7669A87A9@gmail.com> Belka You've described what you don't want - what do you want? Given that the fundamental premise of a DDoS attack is to saturate resources so that legitimate activity is curtailed - ultimately the only response has to be to discard load, preferably not the legitimate load (and therein lies the nub of the problem). What are you trying to achieve here - a guarantee of progress for the system? a guarantee of a fairness property? (e.g. some legitimate traffic will get processed) or, given that the DDoS load can be identified given some initial computation, guarantee to progress legitimate load up to some level of DDoS attack? Neil On 1 May 2009, at 05:09, Belka wrote: > > Hi! > > I need this function with requirement of heavy reads, *possibly > under DDoS > attack*. > Was trying to write such function, but discovered some serious > problems of > ** possible racings, > ** possible starvations > ** unbalance: readAdvChan users may get better service than ones of > tryReadAdvChan > These are totally unacceptible for my case of DDoS risk. > > Actually, am I wrong thinking, that it can't be helped - and the > degradation > from cute concurency synchronization model of Chan is unavoidable? > > My (untested) code: > ------------------------------------------- > ------------------------------------------- > module AdvChan ( AdvChan > , newAdvChan > , readAdvChan > , writeAdvChan > , writeList2AdvChan > , advChan2StrictList > , withResourceFromAdvChan > , tryReadAdvChan > , isEmptyAdvChan > ) where > > import Control.Concurrent.Chan > import Control.Concurrent.MVar > > data AdvChan a = AdvChan { > acInst :: MVar Chan a > , acWrite :: a -> IO () > , acIsEmpty :: IO Bool > } > > newAdvChan :: IO AdvChan a > newAdvChan = do ch <- newChan > mv_ch <- newMVar ch > return AdvChan { > acInst = mv_ch > , acWrite = writeChan ch > , acIsEmpty = isEmptyChan ch > } > > readAdvChan :: AdvChan a -> IO a > readAdvChan ach = modifyMVar (acInst ach) > (\ ch -> do a <- readChan ch > return (ch, a) > ) > > writeAdvChan :: AdvChan a -> a -> IO () > writeAdvChan = acWrite > > writeList2AdvChan :: AdvChan a -> [a] -> IO () > writeList2AdvChan ach [] = return () > writeList2AdvChan ach (h:t) = writeAdvChan ach h >> > writeList2AdvChan ach t > > advChan2StrictList :: AdvChan a -> IO [a] > advChan2StrictList ach = modifyMVar (acInst ach) > (\ ch -> let readLoop = do emp <- > isEmptyChan ch > case > emp of > > True -> > return [] > > False -> > do _head <- readChan ch > > _rest <- readLoop > > return (_head : _rest) > in liftTuple (return ch, > readLoop) > ) > > withResourceFromAdvChan :: AdvChan a -> (\ a -> IO (a, b)) -> IO b > withResourceFromAdvChan ach f = do res <- readAdvChan ach > (res_processed, result) <- f res > writeAdvChan ach res_processed > return result > > isEmptyAdvChan :: AdvChan a -> IO Bool > isEmptyAdvChan = acIsEmpty > > microDelta = 50 > > tryReadAdvChan :: AdvChan a -> IO (Maybe a) > tryReadAdvChan ach = emp2Maybeness $ do mb_inst <- tryTakeMVar > (acInst ach) > case mb_inst of > Nothing -> emp2Maybeness > (threadDelay microDelta >> tryReadAdvChan ach) > Just chan -> do emp <- > isEmptyChan ch > result <- > case > emp of > > True -> return Nothing > > False -> Just `liftM` readChan ch > putMVar > (acInst > ach) chan > return > result > where emp2Maybeness f = do emp <- isEmptyAdvChan ach > case emp of > True -> return Nothing > False -> f > > ------------------------------------------- > ------------------------------------------- > > Later after writing my own code, and understanding the problem I > checked > Hackage. Found "synchronous-channels" package there > (http://hackage.haskell.org/cgi-bin/hackage-scripts/package/synchronous-channels > ), > but it isn't any further in solving my the unbalacedness problems. > > Any suggestions on the fresh matter are welcome. > Belka. > -- > View this message in context: http://www.nabble.com/-tryReadAdvChan-%3A%3A-AdvChan-a--%3E-IO-%28Maybe-a%29--problems-tp23328237p23328237.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 semanticphilosopher at googlemail.com Fri May 1 04:14:13 2009 From: semanticphilosopher at googlemail.com (Neil Davies) Date: Fri May 1 04:00:11 2009 Subject: [Haskell-cafe] Estimating the time to garbage collect Message-ID: <6960D8EF-5AC1-4513-9673-86817582AC43@gmail.com> Hi With the discussion on threads and priority, and given that (in Stats.c) there are lots of useful pieces of information that the run time system is collecting, some of which is already visible (like the total amount of memory mutated) and it is easy to make other measures available - it has raised this question in my mind: Given that you have access to that information (the stuff that comes out at the end of a run if you use +RTS -S) is it possible to estimate the time a GC will take before asking for one? Ignoring, at least for the moment, all the issues of paging, processor cache occupancy etc, what are the complexity drivers for the time to GC? I realise that it is going to depend on things like, volume of data mutated, count of objects mutated, what fraction of them are live etc - and even if it turns out that these things are very program specific then I have a follow-on question - what properties do you need from your program to be able to construct a viable estimate of GC time from a past history of such garbage collections? Why am I interested? There are all manners of 'real time' in systems, there is a vast class where a statistical bound (ie some sort of 'time to complete' CDF) is more than adequate for production use. If this is possible then it opens up areas where all the lovely properties of haskell can be exploited if only you had confidence in the timing behaviour. Cheers Neil From nowgate at yahoo.com Fri May 1 06:29:37 2009 From: nowgate at yahoo.com (michael rice) Date: Fri May 1 06:15:20 2009 Subject: [Haskell-cafe] chr/ord? Message-ID: <246761.26081.qm@web31106.mail.mud.yahoo.com> Understood. Thanks. A little further on in the tutorial they define a "parent" function. The mplus operator is used to combine monadic values from separate computations into a single monadic value. Within the context of our sheep-cloning example, we could use Maybe's mplus to define a function, parent?s?=?(mother?s)?`mplus`?(father?s), which would return a parent if there is one, and Nothing is the sheep has no parents at all. For a sheep with both parents, the function would return one or the other, depending on the exact definition of mplus in the Maybe monad. But I get this when I try to use it: sheep.hs:30:22: Not in scope: `mplus' [michael@localhost ~]$ And here's the sheep.hs file, attempting to use "parent" near the bottom ========= {- Author:???? Jeff Newbern ?? Maintainer: Jeff Newbern ?? Time-stamp: ?? License:??? GPL -} {- DESCRIPTION Example 1 - Our first monad Usage: Compile the code and execute the resulting program. ?????? It will print Dolly's maternal grandfather. -} -- everything you need to know about sheep data Sheep = Sheep {name::String, mother::Maybe Sheep, father::Maybe Sheep} -- we show sheep by name instance Show Sheep where ? show s = show (name s) -- comb is a combinator for sequencing operations that return Maybe comb :: Maybe a -> (a -> Maybe b) -> Maybe b comb Nothing? _ = Nothing comb (Just x) f = f x parent s = (mother s) `mplus` (father s) -- now we can use `comb` to build complicated sequences maternalGrandfather :: Sheep -> Maybe Sheep maternalGrandfather s = (Just s) `comb` mother `comb` father fathersMaternalGrandmother :: Sheep -> Maybe Sheep fathersMaternalGrandmother s = (Just s) `comb` father `comb` mother `comb` mother mothersPaternalGrandfather :: Sheep -> Maybe Sheep mothersPaternalGrandfather s = (Just s) `comb` mother `comb` father `comb` father -- this builds our sheep family tree breedSheep :: Sheep breedSheep = let adam?? = Sheep "Adam" Nothing Nothing ???????????????? eve??? = Sheep "Eve" Nothing Nothing ??? ??? ?uranus = Sheep "Uranus" Nothing Nothing ??? ??? ?gaea?? = Sheep "Gaea" Nothing Nothing ??? ??? ?kronos = Sheep "Kronos" (Just gaea) (Just uranus) ???????????????? holly? = Sheep "Holly" (Just eve) (Just adam) ??? ???????? roger? = Sheep "Roger" (Just eve) (Just kronos) ??? ???????? molly? = Sheep "Molly" (Just holly) (Just roger) ??? ???? in Sheep "Dolly" (Just molly) Nothing -- print Dolly's maternal grandfather main :: IO () main = let dolly = breedSheep ?????? in do print (parent dolly) ??? ??? -- END OF FILE Michael --- On Wed, 4/29/09, Anton van Straaten wrote: From: Anton van Straaten Subject: Re: [Haskell-cafe] chr/ord? To: "haskell-cafe@haskell.org" Date: Wednesday, April 29, 2009, 12:33 PM michael rice wrote: > Since I'm trying to learn Monads, let's look at this as a teaching moment. The example code (see below), which I pulled off YAMT (Yet Another Monad Tutorial ;-)), is the source of my 'comb' function. > > I understand the code as it now stands, and I understand that the Prelude (>>=) would replace the 'comb'. Adding whatever statements are needed, how would you "specialize" the (>>=) to Maybe and solve this particular problem. Saying that "comb is just (>>=) specialized to Maybe" just means that you can define comb like this: ? comb :: Maybe a -> (a -> Maybe b) -> Maybe b ? comb = (>>=) Which also of course means that you can typically use (>>=) instead of comb.? Although in some cases, being more specific about the type can be useful. You can do this sort of specialization for any polymorphic function, e.g.: ? -- id is predefined in Haskell, definition given as example ? id :: a -> a ? id x = x ? intID :: Int -> Int ? intId = id In that case, the compiler basically specializes the function for you, providing a version of it that's specific to Ints. However, (>>=) is defined by the Monad type class, and as it happens there's also already a definition for it that's specific to the Maybe type.? You can see GHC's source for it here: http://haskell.org/ghc/docs/latest/html/libraries/base/src/Data-Maybe.html#Maybe Not surprisingly, that definition is essentially identical to the definition of comb: ? (Just x) >>= k? ? ? = k x ? Nothing? >>= _? ? ? = Nothing So defining "comb = (>>=)" just uses that definition. Anton _______________________________________________ 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/20090501/f3bb9d4e/attachment.htm From ndmitchell at gmail.com Fri May 1 06:32:49 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Fri May 1 06:18:40 2009 Subject: [Haskell-cafe] chr/ord? In-Reply-To: <246761.26081.qm@web31106.mail.mud.yahoo.com> References: <246761.26081.qm@web31106.mail.mud.yahoo.com> Message-ID: <404396ef0905010332s1f123fe1u7a479fbbaebf68bc@mail.gmail.com> Hi > But I get this when I try to use it: > > sheep.hs:30:22: Not in scope: `mplus' > [michael@localhost ~]$ You need to import Control.Monad. You can find answers to these sorts of questions with Hoogle: http://haskell.org/hoogle/?hoogle=mplus Thanks Neil From nowgate at yahoo.com Fri May 1 06:40:41 2009 From: nowgate at yahoo.com (michael rice) Date: Fri May 1 06:26:22 2009 Subject: [Haskell-cafe] chr/ord? Message-ID: <259591.22480.qm@web31101.mail.mud.yahoo.com> Thank you. I assumed when I saw this: ? "we could use Maybe's mplus to define a function, parent?s?=?(mother?s)?`mplus`?(father?s)" that mplus was *already* present in Maybe. Michael --- On Fri, 5/1/09, Neil Mitchell wrote: From: Neil Mitchell Subject: Re: [Haskell-cafe] chr/ord? To: "michael rice" Cc: "haskell-cafe@haskell.org" , "Anton van Straaten" Date: Friday, May 1, 2009, 6:32 AM Hi > But I get this when I try to use it: > > sheep.hs:30:22: Not in scope: `mplus' > [michael@localhost ~]$ You need to import Control.Monad. You can find answers to these sorts of questions with Hoogle: http://haskell.org/hoogle/?hoogle=mplus Thanks Neil -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090501/0437abf8/attachment.htm From claus.reinke at talk21.com Fri May 1 07:10:38 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Fri May 1 06:56:22 2009 Subject: [Haskell-cafe] Array Binary IO & molecular simulation References: <251001241158007@webmail128.yandex.ru> Message-ID: > So I wonder of existing projects of such type, both Molecular dynamics and Monte Carlo methods. The fastest Haskell Monte Carlo code I've seen in action is Simon's port of a Monte Carlo Go engine: http://www.haskell.org/pipermail/haskell-cafe/2009-March/057982.html http://www.haskell.org/pipermail/haskell-cafe/2009-March/058069.html That is competitive to lightly optimised non-Haskell versions, though not competitive with highly optimised versions (the kind that slows down when you update your compiler, but gives you dramatic boosts due to detailed attention both to generated assembly code and to high-level algorithm shortcuts). Though there's also specialization as an option http://www.cse.unsw.edu.au/~chak/papers/KCCSB07.html and googling for "haskell monte carlo" give a few more hits, such as http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.47.2981 http://www.citeulike.org/user/dguibert/article/561815 and even some hackage package, though I don't know whether efficiency was a concern there? >I've got also some technical questions. Now I'm using 2D DiffUArray >to represent particle positions during the simulation (when there are lots >of array updates). Is this reasonably fast (I want to use pure external >interface of DiffArray)? DiffArray is slow (don't know about DiffUArray): http://hackage.haskell.org/trac/ghc/ticket/2727 The default Random is also slow (see the mersenne alternatives on hackage instead, and be careful if you use them through the standard class interface): http://hackage.haskell.org/trac/ghc/ticket/2280 http://hackage.haskell.org/trac/ghc/ticket/427 Claus From doug_j_burke at yahoo.com Fri May 1 09:15:29 2009 From: doug_j_burke at yahoo.com (Doug Burke) Date: Fri May 1 09:01:14 2009 Subject: [Haskell-cafe] swish - semantic web in Haskell In-Reply-To: <5ae4f2ba0904301539qad2dd27o94399606eb120061@mail.gmail.com> Message-ID: <715670.25503.qm@web65602.mail.ac4.yahoo.com> --- On Thu, 4/30/09, Vasili I. Galchin wrote: > From: Vasili I. Galchin > Subject: [Haskell-cafe] swish - semantic web in Haskell > To: "haskell-cafe@haskell.org" > Cc: "Galchin Vasili" > Date: Thursday, April 30, 2009, 6:39 PM > Hello, > > http://www.ninebynine.org/Software/swish-0.2.1.html > .... I am trying > to get permission from the author of Swish to move it into > Hackage. I will > write "cabalize" it get up to current Haskell > standards. Before I go to this > effort is anybody attempting to do this? > > Kind regards, Vasili Vasili, I recently downloaded the code and started looking at it, but I am *exceedingly* unlikely to have time to do this any time soon. So, if you have the time and the permission to do it, I'll be happy :-) Doug From vanenkj at gmail.com Fri May 1 09:29:41 2009 From: vanenkj at gmail.com (John Van Enk) Date: Fri May 1 09:15:19 2009 Subject: [Haskell-cafe] Estimating the time to garbage collect In-Reply-To: <6960D8EF-5AC1-4513-9673-86817582AC43@gmail.com> References: <6960D8EF-5AC1-4513-9673-86817582AC43@gmail.com> Message-ID: I think the problem becomes slightly easier if you can provide an upper bound on the time GC will take. If I understand your problem domain, Neil, you're most concerned with holding up other processes/partitions who are expecting to have a certain amount of processing time per frame. If we can give an upper bound to the GC time, then we can plan for it in the schedule without upsetting the other processes. I don't have an answer (though I'd love one), but I do think that asking for an upper bound substantially simplifies the problem (though, I could be wrong) and still gives you the characterisics you need to give a 'time to complete'. /jve On Fri, May 1, 2009 at 4:14 AM, Neil Davies < semanticphilosopher@googlemail.com> wrote: > Hi > > With the discussion on threads and priority, and given that (in Stats.c) > there are lots of useful pieces of information that the run time system is > collecting, some of which is already visible (like the total amount of > memory mutated) and it is easy to make other measures available - it has > raised this question in my mind: > > Given that you have access to that information (the stuff that comes out at > the end of a run if you use +RTS -S) is it possible to estimate the time a > GC will take before asking for one? > > Ignoring, at least for the moment, all the issues of paging, processor > cache occupancy etc, what are the complexity drivers for the time to GC? > > I realise that it is going to depend on things like, volume of data > mutated, count of objects mutated, what fraction of them are live etc - and > even if it turns out that these things are very program specific then I have > a follow-on question - what properties do you need from your program to be > able to construct a viable estimate of GC time from a past history of such > garbage collections? > > Why am I interested? There are all manners of 'real time' in systems, there > is a vast class where a statistical bound (ie some sort of 'time to > complete' CDF) is more than adequate for production use. If this is possible > then it opens up areas where all the lovely properties of haskell can be > exploited if only you had confidence in the timing behaviour. > > Cheers > Neil > _______________________________________________ > 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/20090501/8a95bd99/attachment.htm From barsoap at web.de Fri May 1 10:57:32 2009 From: barsoap at web.de (Achim Schneider) Date: Fri May 1 10:43:58 2009 Subject: [Haskell-cafe] Re: Estimating the time to garbage collect References: <6960D8EF-5AC1-4513-9673-86817582AC43@gmail.com> Message-ID: <20090501165732.66d4723f@solaris> Neil Davies wrote: > Ignoring, at least for the moment, all the issues of paging, > processor cache occupancy etc, what are the complexity drivers for > the time to GC? > It largely depends on the GC implementation, especially when you interpret "time to GC" as "time until you get control back", in contrast to e.g. "time to claim back (at least) X bytes (because you want to allocate something)". There's GC schemes that are usable in hard realtime systems, but I _very_ much doubt ghc's gc is. If you want to go real-time, you might want to have a look at Timber. -- (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 alistair at abayley.org Fri May 1 11:16:22 2009 From: alistair at abayley.org (Alistair Bayley) Date: Fri May 1 11:02:02 2009 Subject: [Haskell-cafe] ANN: Takusen 0.8.4 Message-ID: <79d7c4980905010816r6bacades2f08804d5ed09761@mail.gmail.com> ANN: Takusen 0.8.4 This is mainly a "get it working with ghc-6.10" release. Changes since 0.8.3: - ODBC support: some bug fixes, and basic support for Out-parameters. There is at least one major outstanding bug with Out-parameters, where marshalling a String output bind-variable doesn't work correctly (if it was modified, you still get the String you passed in back, rather than the new String). - Sqlite: bug fix for resource leak: if a command (like rollback or commit) raised an error, the prepared-statement handle was not closed. - cabal: requires cabal 1.6 (or later). With ghc-6.6 on Windows you will need a later cabal than 1.6.0.1, as there is a bug which prevents building (setup configure fails with "setup: fdGetMode: invalid argument (Invalid argument)"). Eric Mertens patch for ODBC on OS x. Greg Leclerq patch for cabal 1.6. Thanks also to Austin Siepp and Brian Callendar for their patches. - ghc-6.10: will build with ghc's 6.10, 6.8, 6.6. Note that Takusen won't work with ghc-6.10.2 out-of-the-box, because the time package is missing. If you install time manually then it should be OK (but this is untested). We use the new extensible exceptions, but we have done so by including it within our own source tree. This will make it easier to use Takusen with older ghc's, and reduces the number of external package dependencies. We have dropped support for 6.4. That's not to say Takusen isn't usable with 6.4, just that we no longer test that configuration. The release bundle: http://hackage.haskell.org/packages/archive/Takusen/0.8.4/Takusen-0.8.4.tar.gz The latest code: darcs get http://darcs.haskell.org/takusen Docs: http://darcs.haskell.org/takusen/doc/html/index.html If you have cabal-install, then this command should work: cabal install Takusen --flags="sqlite odbc oracle postgres" ... but it doesn't (at least for the version of cabal-install that I have) because the .tar.gz file I uploaded has a bogus checksum. A comprehensive description of API usage can be found in the documentation for module Database.Enumerator (look for the Usage section): http://darcs.haskell.org/takusen/doc/html/Database-Enumerator.html Note that the haddock docs won't build with cabal-1.6.0.2 or earlier. This is because our literate-haskell source files need to be properly preprocessed before being passed to haddock. At the time of writing, you'll need the cabal HEAD to build the docs. Future plans: - Output bind-parameters and multiple-result sets for ODBC - support for Blobs and Clobs - FreeTDS backend (Sybase and MS Sql Server)... maybe For those of you unfamiliar with Takusen, here is our HCAR blurb: Takusen is a DBMS access library. Like HSQL and HDBC, we support arbitrary SQL statements (currently strings, extensible to anything that can be converted to a string). Takusen's 'unique-selling-point' is safety and efficiency. We statically ensure all acquired database resources - such as cursors, connection and statement handles - are released, exactly once, at predictable times. Takusen can avoid loading the whole result set in memory, and so can handle queries returning millions of rows in constant space. Takusen also supports automatic marshalling and unmarshalling of results and query parameters. These benefits come from the design of query result processing around a left-fold enumerator. Currently we fully support ODBC, Oracle, Sqlite, and PostgreSQL. From nowgate at yahoo.com Fri May 1 12:26:03 2009 From: nowgate at yahoo.com (michael rice) Date: Fri May 1 12:11:44 2009 Subject: [Haskell-cafe] Generating random enums Message-ID: <697159.63165.qm@web31101.mail.mud.yahoo.com> I'm using the code below to generate random days of the week [Monday..Sunday]. Is there a better/shorter way to do this? Michael ============== [michael@localhost ~]$ ghci dow 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???????????? ( dow.hs, interpreted ) Ok, modules loaded: Main. *Main> random (mkStdGen 100) :: (DayOfWeek, StdGen) Loading package old-locale-1.0.0.1 ... linking ... done. Loading package old-time-1.0.0.1 ... linking ... done. Loading package random-1.0.0.1 ... linking ... done. (Friday,4041414 40692) *Main> random (mkStdGen 123) :: (DayOfWeek, StdGen) (Tuesday,4961736 40692) *Main> ============== import System.Random data DayOfWeek ??? = Monday ??? | Tuesday ??? | Wednesday ??? | Thursday ??? | Friday ??? | Saturday ??? | Sunday ??? deriving (Show, Read, Eq, Enum, Ord, Bounded) instance Random DayOfWeek where ? randomR (a,b) g = ????? case (randomIvalInteger (toInteger (dow2Int a), toInteger (dow2Int b)) g) of ??????? (x, g) -> (int2Dow x, g) ?????? where ???????? dow2Int Monday??? = 0 ???????? dow2Int Tuesday?? = 1 ???????? dow2Int Wednesday = 2 ???????? dow2Int Thursday? = 3 ???????? dow2Int Friday??? = 4 ???????? dow2Int Saturday? = 5 ???????? dow2Int Sunday??? = 6 ?? ? int2Dow 0?? ?= Monday ?? ? int2Dow 1?? ?= Tuesday ?? ? int2Dow 2?? ?= Wednesday ?? ? int2Dow 3?? ?= Thursday ?? ? int2Dow 4?? ?= Friday ?? ? int2Dow 5?? ?= Saturday ?? ? int2Dow 6?? ?= Sunday ? random g?? ?? = randomR (minBound,maxBound) g randomIvalInteger :: (RandomGen g, Num a) => (Integer, Integer) -> g -> (a, g) randomIvalInteger (l,h) rng ?| l > h???? = randomIvalInteger (h,l) rng ?| otherwise = case (f n 1 rng) of (v, rng') -> (fromInteger (l + v `mod` k), rng') ???? where ?????? k = h - l + 1 ?????? b = 2147483561 ?????? n = iLogBase b k ?????? f 0 acc g = (acc, g) ?????? f n acc g = ????????? let ?? ??? (x,g')?? = next g ?? ?? in ?? ?? f (n-1) (fromIntegral x + acc * b) g' iLogBase :: Integer -> Integer -> Integer iLogBase b i = if i < b then 1 else 1 + iLogBase b (i `div` b) ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090501/2d228a8d/attachment.htm From vanenkj at gmail.com Fri May 1 12:36:08 2009 From: vanenkj at gmail.com (John Van Enk) Date: Fri May 1 12:21:51 2009 Subject: [Haskell-cafe] Generating random enums In-Reply-To: <697159.63165.qm@web31101.mail.mud.yahoo.com> References: <697159.63165.qm@web31101.mail.mud.yahoo.com> Message-ID: When you derive Enum, you get fromEnum and toEnum for free. You don't need your dow2Int stuff or int2Dow. Replace those with fromEnum and toEnum respectively. /jve On Fri, May 1, 2009 at 12:26 PM, michael rice wrote: > I'm using the code below to generate random days of the week > [Monday..Sunday]. > > Is there a better/shorter way to do this? > > Michael > > ============== > > [michael@localhost ~]$ ghci dow > 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 ( dow.hs, interpreted ) > Ok, modules loaded: Main. > *Main> random (mkStdGen 100) :: (DayOfWeek, StdGen) > Loading package old-locale-1.0.0.1 ... linking ... done. > Loading package old-time-1.0.0.1 ... linking ... done. > Loading package random-1.0.0.1 ... linking ... done. > (Friday,4041414 40692) > *Main> random (mkStdGen 123) :: (DayOfWeek, StdGen) > (Tuesday,4961736 40692) > *Main> > > ============== > > import System.Random > > data DayOfWeek > = Monday > | Tuesday > | Wednesday > | Thursday > | Friday > | Saturday > | Sunday > deriving (Show, Read, Eq, Enum, Ord, Bounded) > > instance Random DayOfWeek where > randomR (a,b) g = > case (randomIvalInteger (toInteger (dow2Int a), toInteger (dow2Int > b)) g) of > (x, g) -> (int2Dow x, g) > where > dow2Int Monday = 0 > dow2Int Tuesday = 1 > dow2Int Wednesday = 2 > dow2Int Thursday = 3 > dow2Int Friday = 4 > dow2Int Saturday = 5 > dow2Int Sunday = 6 > > int2Dow 0 = Monday > int2Dow 1 = Tuesday > int2Dow 2 = Wednesday > int2Dow 3 = Thursday > int2Dow 4 = Friday > int2Dow 5 = Saturday > int2Dow 6 = Sunday > > random g = randomR (minBound,maxBound) g > > randomIvalInteger :: (RandomGen g, Num a) => (Integer, Integer) -> g -> (a, > g) > randomIvalInteger (l,h) rng > | l > h = randomIvalInteger (h,l) rng > | otherwise = case (f n 1 rng) of (v, rng') -> (fromInteger (l + v `mod` > k), rng') > where > k = h - l + 1 > b = 2147483561 > n = iLogBase b k > > f 0 acc g = (acc, g) > f n acc g = > let > (x,g') = next g > in > f (n-1) (fromIntegral x + acc * b) g' > > iLogBase :: Integer -> Integer -> Integer > iLogBase b i = if i < b then 1 else 1 + iLogBase b (i `div` b) > > > > > > > > _______________________________________________ > 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/20090501/ea13eaf9/attachment.htm From tphyahoo at gmail.com Fri May 1 12:44:39 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Fri May 1 12:30:18 2009 Subject: [Haskell-cafe] Generating random enums In-Reply-To: <697159.63165.qm@web31101.mail.mud.yahoo.com> References: <697159.63165.qm@web31101.mail.mud.yahoo.com> Message-ID: <910ddf450905010944w6aecdda0g88c29134fda5589d@mail.gmail.com> see http://www.mail-archive.com/haskell-cafe@haskell.org/msg38528.html for some ideas, particularly antoine latter's answer. 2009/5/1 michael rice : > I'm using the code below to generate random days of the week > [Monday..Sunday]. > > Is there a better/shorter way to do this? > > Michael > > ============== > > [michael@localhost ~]$ ghci dow > 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???????????? ( dow.hs, interpreted ) > Ok, modules loaded: Main. > *Main> random (mkStdGen 100) :: (DayOfWeek, StdGen) > Loading package old-locale-1.0.0.1 ... linking ... done. > Loading package old-time-1.0.0.1 ... linking ... done. > Loading package random-1.0.0.1 ... linking ... done. > (Friday,4041414 40692) > *Main> random (mkStdGen 123) :: (DayOfWeek, StdGen) > (Tuesday,4961736 40692) > *Main> > > ============== > > import System.Random > > data DayOfWeek > ??? = Monday > ??? | Tuesday > ??? | Wednesday > ??? | Thursday > ??? | Friday > ??? | Saturday > ??? | Sunday > ??? deriving (Show, Read, Eq, Enum, Ord, Bounded) > > instance Random DayOfWeek where > ? randomR (a,b) g = > ????? case (randomIvalInteger (toInteger (dow2Int a), toInteger (dow2Int b)) > g) of > ??????? (x, g) -> (int2Dow x, g) > ?????? where > ???????? dow2Int Monday??? = 0 > ???????? dow2Int Tuesday?? = 1 > ???????? dow2Int Wednesday = 2 > ???????? dow2Int Thursday? = 3 > ???????? dow2Int Friday??? = 4 > ???????? dow2Int Saturday? = 5 > ???????? dow2Int Sunday??? = 6 > > ?? ? int2Dow 0?? ?= Monday > ?? ? int2Dow 1?? ?= Tuesday > ?? ? int2Dow 2?? ?= Wednesday > ?? ? int2Dow 3?? ?= Thursday > ?? ? int2Dow 4?? ?= Friday > ?? ? int2Dow 5?? ?= Saturday > ?? ? int2Dow 6?? ?= Sunday > > ? random g?? ?? = randomR (minBound,maxBound) g > > randomIvalInteger :: (RandomGen g, Num a) => (Integer, Integer) -> g -> (a, > g) > randomIvalInteger (l,h) rng > ?| l > h???? = randomIvalInteger (h,l) rng > ?| otherwise = case (f n 1 rng) of (v, rng') -> (fromInteger (l + v `mod` > k), rng') > ???? where > ?????? k = h - l + 1 > ?????? b = 2147483561 > ?????? n = iLogBase b k > > ?????? f 0 acc g = (acc, g) > ?????? f n acc g = > ????????? let > ?? ??? (x,g')?? = next g > ?? ?? in > ?? ?? f (n-1) (fromIntegral x + acc * b) g' > > iLogBase :: Integer -> Integer -> Integer > iLogBase b i = if i < b then 1 else 1 + iLogBase b (i `div` b) > > > > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From tphyahoo at gmail.com Fri May 1 14:08:26 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Fri May 1 13:54:04 2009 Subject: [Haskell-cafe] Generating random enums In-Reply-To: <697159.63165.qm@web31101.mail.mud.yahoo.com> References: <697159.63165.qm@web31101.mail.mud.yahoo.com> Message-ID: <910ddf450905011108m3f3c62bi7d844659ca879b7c@mail.gmail.com> So... I must say I am rather pleased with the following code. It allows you to use any value of type Bounded and Enum as a member of Random, or Arbitrary, which means you can quickCheck properties on it as well. For quickchecking, the code below "cheats" by not defining the coarbitrary funciton, which I confess I don't really understand and never use. Even so, I can see myself using this in a number of places... Does it seem reasonable to add a ticket to get this added to http://hackage.haskell.org/packages/archive/QuickCheck/2.1.0.1/doc/html/Test-QuickCheck-Arbitrary.html perhaps modulo the definition of an appropriate coarbitrary function? thomas. thartman@patchwiki:~/haskell-learning/testing>cat BoundedEnum.hs {-# LANGUAGE FlexibleInstances, UndecidableInstances, ScopedTypeVariables, OverlappingInstances #-} module Main where import Test.QuickCheck import System.Random class (Bounded a, Enum a) => BoundedEnum a instance (Bounded a, Enum a) => BoundedEnum a instance BoundedEnum a => Random a where random g = let min = fromEnum (minBound :: a) max = fromEnum (maxBound :: a) (i,g') = randomR (min,max) $ g in (toEnum i,g') randomR (low,high) g = let min = fromEnum low max = fromEnum high (i,g') = randomR (min,max) $ g in (toEnum i,g') instance BoundedEnum a => Arbitrary a where arbitrary = do let min = fromEnum (minBound :: a) max = fromEnum (maxBound :: a) i <- arbitrary return . toEnum $ min + (i `mod` (max-min)) coarbitrary = undefined data DayOfWeek = Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday deriving (Show, Read, Eq, Enum, Ord, Bounded) t :: IO DayOfWeek t = randomIO t2 :: IO Int t2 = randomIO pDayEqualsItself :: DayOfWeek -> Bool pDayEqualsItself day = day == day -- a trivial property, just so we can show t3 = quickCheck pDayEqualsItself -- show what days are being tested t4 = verboseCheck pDayEqualsItself 2009/5/1 michael rice : > I'm using the code below to generate random days of the week > [Monday..Sunday]. > > Is there a better/shorter way to do this? > > Michael > > ============== > > [michael@localhost ~]$ ghci dow > 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???????????? ( dow.hs, interpreted ) > Ok, modules loaded: Main. > *Main> random (mkStdGen 100) :: (DayOfWeek, StdGen) > Loading package old-locale-1.0.0.1 ... linking ... done. > Loading package old-time-1.0.0.1 ... linking ... done. > Loading package random-1.0.0.1 ... linking ... done. > (Friday,4041414 40692) > *Main> random (mkStdGen 123) :: (DayOfWeek, StdGen) > (Tuesday,4961736 40692) > *Main> > > ============== > > import System.Random > > data DayOfWeek > ??? = Monday > ??? | Tuesday > ??? | Wednesday > ??? | Thursday > ??? | Friday > ??? | Saturday > ??? | Sunday > ??? deriving (Show, Read, Eq, Enum, Ord, Bounded) > > instance Random DayOfWeek where > ? randomR (a,b) g = > ????? case (randomIvalInteger (toInteger (dow2Int a), toInteger (dow2Int b)) > g) of > ??????? (x, g) -> (int2Dow x, g) > ?????? where > ???????? dow2Int Monday??? = 0 > ???????? dow2Int Tuesday?? = 1 > ???????? dow2Int Wednesday = 2 > ???????? dow2Int Thursday? = 3 > ???????? dow2Int Friday??? = 4 > ???????? dow2Int Saturday? = 5 > ???????? dow2Int Sunday??? = 6 > > ?? ? int2Dow 0?? ?= Monday > ?? ? int2Dow 1?? ?= Tuesday > ?? ? int2Dow 2?? ?= Wednesday > ?? ? int2Dow 3?? ?= Thursday > ?? ? int2Dow 4?? ?= Friday > ?? ? int2Dow 5?? ?= Saturday > ?? ? int2Dow 6?? ?= Sunday > > ? random g?? ?? = randomR (minBound,maxBound) g > > randomIvalInteger :: (RandomGen g, Num a) => (Integer, Integer) -> g -> (a, > g) > randomIvalInteger (l,h) rng > ?| l > h???? = randomIvalInteger (h,l) rng > ?| otherwise = case (f n 1 rng) of (v, rng') -> (fromInteger (l + v `mod` > k), rng') > ???? where > ?????? k = h - l + 1 > ?????? b = 2147483561 > ?????? n = iLogBase b k > > ?????? f 0 acc g = (acc, g) > ?????? f n acc g = > ????????? let > ?? ??? (x,g')?? = next g > ?? ?? in > ?? ?? f (n-1) (fromIntegral x + acc * b) g' > > iLogBase :: Integer -> Integer -> Integer > iLogBase b i = if i < b then 1 else 1 + iLogBase b (i `div` b) > > > > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From felipe.lessa at gmail.com Fri May 1 14:12:47 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Fri May 1 13:58:30 2009 Subject: [Haskell-cafe] Generating random enums In-Reply-To: <910ddf450905011108m3f3c62bi7d844659ca879b7c@mail.gmail.com> References: <697159.63165.qm@web31101.mail.mud.yahoo.com> <910ddf450905011108m3f3c62bi7d844659ca879b7c@mail.gmail.com> Message-ID: <20090501181247.GA15131@kira.casa> On Fri, May 01, 2009 at 01:08:26PM -0500, Thomas Hartman wrote: > For quickchecking, the code below "cheats" by not defining the > coarbitrary funciton, which I confess I don't really understand and > never use. FWIW, QuickCheck 2 separates 'coarbitrary' in a different class. -- Felipe. From ryani.spam at gmail.com Fri May 1 17:13:44 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Fri May 1 16:59:21 2009 Subject: [Haskell-cafe] Generating random enums In-Reply-To: <910ddf450905011108m3f3c62bi7d844659ca879b7c@mail.gmail.com> References: <697159.63165.qm@web31101.mail.mud.yahoo.com> <910ddf450905011108m3f3c62bi7d844659ca879b7c@mail.gmail.com> Message-ID: <2f9b2d30905011413g7948c99u4e8c73d5ab02e09a@mail.gmail.com> On Fri, May 1, 2009 at 11:08 AM, Thomas Hartman wrote: > For quickchecking, the code below "cheats" by not defining the > coarbitrary funciton, which I confess I don't really understand and > never use. coarbitrary is simple; it's used for generating arbitrary functions. If you don't know how to define it for your type, "coarbitrary _ = id" is a reasonable definition. But it's usually easy to define, and I'll show you how! But first, the motivation for its existence. You have an instance of arbitrary "X", and an instance of arbitrary "Y", and some transformations: > transformX :: X -> X > transformY :: Y -> Y > > prop_natural_transform :: (X -> Y) -> X -> Bool > prop_natural_transform f x = f (transformX x) == transformY (f x) This says, for all f, (f . transformX) = (transformY . f). A real example of a property similar to this is for "map" and "reverse": > prop_map_reverse :: Eq b => (a -> b) -> [a] -> Bool > prop_map_reverse f xs = map f (reverse xs) == reverse (map f xs) Now, how can QuickCheck generate functions to pass to these properties? The function f is *pure*; it can't use a random generator to determine what Y to output. What QuickCheck *can* do, however, is "split" the random generator at the point where it needs to create "f", then uses "coarbitrary" to adjust the state of the generator based on the argument passed in: > mkArbFunction :: forall a b. (Arbitrary a, Arbitrary b) => Gen (a -> b) > mkArbFunction = sized $ \size -> do > randomSource <- rand > let > f :: a -> b > f x = generate size randomSource (coarbitrary x arbitrary) > return f Inside of "f", we have a single generator that is fixed; without coarbitrary, we would only be able to generate a single object of type "b", the one that is a result of running "arbitrary" with that fixed generator. But with coarbitrary, the argument can affect the response! The simplest thing to do is to extract some random values from the generator before using it to generate the result: > -- only works for non-negative values > twist :: Int -> Gen a -> Gen a > twist 0 g = g > twist n g = do > () <- elements [(), ()] -- just make the random generator do some work > coarbitrary (n-1) g It's really easy to implement coarbitrary for many types in terms of "twist": > data Color = Red | Green | Blue > instance Arbitrary Color where > arbitrary = elements [Red, Green, Blue] > coarbitrary Red = twist 0 > coarbitrary Green = twist 1 > coarbitrary Blue = twist 2 > instance Arbitrary a => Arbitrary (Maybe a) where > arbitrary = oneOf [return Nothing, liftM Just arbitrary] > coarbitrary Nothing = twist 0 > coarbitrary (Just x) = twist 1 . coarbitrary x A better version of "twist" is in Test.QuickCheck with the name "variant". In fact, for Bounded/Enum types like your code uses, it's easy to define coarbitrary from variant: > coarbEnum :: (Bounded a, Enum a) => a -> Gen b -> Gen b > coarbEnum a = variant (fromEnum a - fromEnum (minBound `asTypeOf` a)) -- ryan From tphyahoo at gmail.com Fri May 1 17:55:08 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Fri May 1 17:40:46 2009 Subject: [Haskell-cafe] What to do when cabal dependencies are not your friend. Message-ID: <910ddf450905011455l3771bd0cp6cb614e386aa3fdd@mail.gmail.com> I did a little write-up on an annoyance I frequently have when developing patch-tag, a happs application that has a lot of dependencies. Basically, on a virgin linux environment with the same cabal and ghc version as before, a cabal install that had previously worked, didn't work anymore. I assume this is because of changes on hackage that didn't affect my previous version because I had not done cabal update for a while. Luckly I had a working environment on a test box elsewehre so... http://blog.patch-tag.com/2009/05/01/what-to-do-when-cabal-install-works-in-one-environment-but-not-another/ Cheers, thomas. From lemming at henning-thielemann.de Fri May 1 17:54:44 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri May 1 17:41:07 2009 Subject: [Haskell-cafe] Thread priority? In-Reply-To: <49FAA4D3.4010509@snowlion.nl> References: <49FAA4D3.4010509@snowlion.nl> Message-ID: On Fri, 1 May 2009, maarten wrote: > Actually, I thought this problem was already resolved (haskore-realtime), I haven't done anything advanced in that package. I have e.g. not touched any priority. From pkeir at dcs.gla.ac.uk Fri May 1 18:01:30 2009 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Fri May 1 17:47:11 2009 Subject: [Haskell-cafe] fromInteger for Lists Message-ID: <3CDFB8AFEA98E34CB599475AB11589C82C3D59@EX2.ad.dcs.gla.ac.uk> There's nothing better than making a data type an instance of Num. In particular, fromInteger is a joy. But how about lists? For example, if I have data Foo a = F [a] I can create a fromInteger such as fromInteger i = F [fromInteger i] and then a 19::(Foo Int), could become F [19]. Is it possible to do something similar for lists? So could [1,2,3]::(Foo Int) become something slightly different, say, F [1,2,3] Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090501/52441ddb/attachment.htm From duncan.coutts at worc.ox.ac.uk Fri May 1 19:01:08 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri May 1 18:49:44 2009 Subject: [Haskell-cafe] What to do when cabal dependencies are not your friend. In-Reply-To: <910ddf450905011455l3771bd0cp6cb614e386aa3fdd@mail.gmail.com> References: <910ddf450905011455l3771bd0cp6cb614e386aa3fdd@mail.gmail.com> Message-ID: <1241218868.13908.1288.camel@localhost> On Fri, 2009-05-01 at 16:55 -0500, Thomas Hartman wrote: > I did a little write-up on an annoyance I frequently have when > developing patch-tag, a happs application that has a lot of > dependencies. > > Basically, on a virgin linux environment with the same cabal and ghc > version as before, a cabal install that had previously worked, didn't > work anymore. > > I assume this is because of changes on hackage that didn't affect my > previous version because I had not done cabal update for a while. > > Luckly I had a working environment on a test box elsewehre so... > > http://blog.patch-tag.com/2009/05/01/what-to-do-when-cabal-install-works-in-one-environment-but-not-another/ The problem is that the dependencies you specified were too lax, so in a different environment the deps said it was ok to use those different versions when really it wasn't ok. In your blog post you solve it by specifying exact dependencies. This works but is often too strict. Working out what the deps should be exactly isn't trivial. You need to know about the versioning policy of your dependencies. With more packages following the recommended package versioning policy this will become easier for you to do (indeed it'll become possible for the tools to give you sensible suggestions). http://haskell.org/haskellwiki/Package_versioning_policy Duncan From haskell at colquitt.org Fri May 1 19:06:15 2009 From: haskell at colquitt.org (John Dorsey) Date: Fri May 1 18:52:51 2009 Subject: [Haskell-cafe] fromInteger for Lists In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C82C3D59@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C82C3D59@EX2.ad.dcs.gla.ac.uk> Message-ID: <20090501230615.GD3278@colquitt.org> Paul, > There's nothing better than making a data type an instance of Num. In > particular, fromInteger is a joy. But how about lists? Do you mean something like Blargh below, only useful? John dorsey@elwood:~/src/scratch$ cat list.hs class Blargh f where fromList :: [a] -> f a data Foo a = Foo [a] deriving (Show) data Bar a = Bar [a] deriving (Show) instance Blargh Foo where fromList = Foo instance Blargh Bar where fromList l = Bar (reverse l) dorsey@elwood:~/src/scratch$ ghci list.hs GHCi, version 6.8.3: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. [1 of 1] Compiling Main ( list.hs, interpreted ) Ok, modules loaded: Main. *Main> fromList [1,2,3] :: Foo Int Foo [1,2,3] *Main> fromList [1,2,3] :: Bar Int Bar [3,2,1] *Main> From andy at adradh.org.uk Fri May 1 19:13:59 2009 From: andy at adradh.org.uk (andy morris) Date: Fri May 1 19:01:35 2009 Subject: [Haskell-cafe] fromInteger for Lists In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C82C3D59@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C82C3D59@EX2.ad.dcs.gla.ac.uk> Message-ID: 2009/5/1 Paul Keir : > There's nothing better than making a data type an instance of Num. In > particular, fromInteger is a joy. But how about lists? > > For example, if I have > > data Foo a = F [a] > > I can create a fromInteger such as > fromInteger i = F [fromInteger i] > > and then a 19::(Foo Int), could become F [19]. > > Is it possible to do something similar for lists? So could > [1,2,3]::(Foo Int) become something slightly different, say, > > F [1,2,3] > > Paul > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > If you mean what I think you're referring to, you can't. The only reason it works for integer literals is that the compiler replaces occurrences of, say, 19 with (fromInteger 19). There's no function that's automatically applied to list literals, so ([1,2,3] :: Foo Int) isn't able to do anything useful, unfortunately. However, there's an extension in GHC, OverloadedStrings, which lets you use the method fromString of class Data.String.IsString to overload literals. (That's not what you asked, though, I know. :) ) From duncan.coutts at worc.ox.ac.uk Fri May 1 19:14:08 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri May 1 19:01:45 2009 Subject: [Haskell-cafe] Re: [Haskell] ANN: Takusen 0.8.4 In-Reply-To: <79d7c4980905010816r6bacades2f08804d5ed09761@mail.gmail.com> References: <79d7c4980905010816r6bacades2f08804d5ed09761@mail.gmail.com> Message-ID: <1241219648.13908.1301.camel@localhost> On Fri, 2009-05-01 at 16:16 +0100, Alistair Bayley wrote: > ANN: Takusen 0.8.4 > The release bundle: > http://hackage.haskell.org/packages/archive/Takusen/0.8.4/Takusen-0.8.4.tar.gz > If you have cabal-install, then this command should work: > cabal install Takusen --flags="sqlite odbc oracle postgres" > ... but it doesn't (at least for the version of cabal-install > that I have) because the .tar.gz file I uploaded has a bogus checksum. Note that it is easy (and recommended) to upgrade to the latest released version of cabal-install: $ cabal update $ cabal install Cabal cabal-install You can check using: $ cabal --version cabal-install version 0.6.2 using version 1.6.0.2 of the Cabal library Duncan From ryani.spam at gmail.com Fri May 1 19:24:41 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Fri May 1 19:10:49 2009 Subject: [Haskell-cafe] fromInteger for Lists In-Reply-To: <20090501230615.GD3278@colquitt.org> References: <3CDFB8AFEA98E34CB599475AB11589C82C3D59@EX2.ad.dcs.gla.ac.uk> <20090501230615.GD3278@colquitt.org> Message-ID: <2f9b2d30905011624h6ed4271dsd9f33fa6ffe26a6@mail.gmail.com> I wish for a language extension "OverloadedLiterals" that includes all of these: 1 => fromInteger 1 "hello" => fromString "hello" ['a', 'b', 'c'] => cons 'a' (cons 'b' (cons 'c' nil)) [ ord x | x <- ['a', 'b', 'c'], ok x ] => cons 'a' (cons 'b' (cons 'c' nil)) >>= \x -> guard (ok x) >> return (ord x) Maybe something similar for pair notation too! GHC already has: class Num a where ... fromInteger :: Integer -> a class IsString where fromString :: String -> a What is the right interface for cons/nil? John's fromList is one suggestion. I'd suggest either: class ListLike c where type Element c fromList :: [Element c] -> c or class Nil c where nil :: c class Container c e where cons :: e -> c -> c This would allow something like: import qualified Data.Map as M data KeyVal k v = k :> v instance Ord k => ListLike (M.Map k v) where type Element (M.Map k v) = k :> v fromList = foldr insertElem M.empty where insertElem (k :> v) m = M.insert k v m which lets you have "first-class" looking maps: M.lookup "Bob" ["Bob" :> 1, "Alice" :> 2, "John" :> 15] -- ryan On Fri, May 1, 2009 at 4:06 PM, John Dorsey wrote: > Paul, > >> There's nothing better than making a data type an instance of Num. In >> particular, fromInteger is a joy. But how about lists? > > Do you mean something like Blargh below, only useful? > > John > > > dorsey@elwood:~/src/scratch$ cat list.hs > > class Blargh f where > ?fromList :: [a] -> f a > > data Foo a = Foo [a] deriving (Show) > data Bar a = Bar [a] deriving (Show) > > instance Blargh Foo where > ?fromList = Foo > > instance Blargh Bar where > ?fromList l = Bar (reverse l) > > dorsey@elwood:~/src/scratch$ ghci list.hs > GHCi, version 6.8.3: http://www.haskell.org/ghc/ ?:? for help > Loading package base ... linking ... done. > [1 of 1] Compiling Main ? ? ? ? ? ? ( list.hs, interpreted ) > Ok, modules loaded: Main. > *Main> fromList [1,2,3] :: Foo Int > Foo [1,2,3] > *Main> fromList [1,2,3] :: Bar Int > Bar [3,2,1] > *Main> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From schlepptop at henning-thielemann.de Fri May 1 19:39:07 2009 From: schlepptop at henning-thielemann.de (Henning Thielemann) Date: Fri May 1 19:37:07 2009 Subject: [Haskell-cafe] fromInteger for Lists In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C82C3D59@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C82C3D59@EX2.ad.dcs.gla.ac.uk> Message-ID: <49FB881B.2000406@henning-thielemann.de> Paul Keir schrieb: > There's nothing better than making a data type an instance of Num. In > particular, fromInteger is a joy. But how about lists? http://www.haskell.org/haskellwiki/Num_instance_for_functions http://www.haskell.org/haskellwiki/Type_classes_are_for_reusability From stevech1097 at yahoo.com.au Fri May 1 22:05:17 2009 From: stevech1097 at yahoo.com.au (Steve) Date: Fri May 1 21:50:55 2009 Subject: [Haskell-cafe] gcd In-Reply-To: <20090118204519.320AF32465D@www.haskell.org> References: <20090118204519.320AF32465D@www.haskell.org> Message-ID: <1241229917.3721.3.camel@host.localdomain> [Question moved over from Haskell-Beginners] I had a look at the gcd definition in GHC 6.10.1 ghc-6.10.1/libraries/base/GHC/Real.lhs -- | @'gcd' x y@ is the greatest (positive) integer that divides both @x@ -- and @y@; for example @'gcd' (-3) 6@ = @3@, @'gcd' (-3) (-6)@ = @3@, -- @'gcd' 0 4@ = @4@. @'gcd' 0 0@ raises a runtime error. gcd :: (Integral a) => a -> a -> a gcd 0 0 = error "Prelude.gcd: gcd 0 0 is undefined" gcd x y = gcd' (abs x) (abs y) where gcd' a 0 = a gcd' a b = gcd' b (a `rem` b) Why is gcd 0 0 undefined? http://en.wikipedia.org/wiki/Greatest_common_divisor says: "It is useful to define gcd(0, 0) = 0 and lcm(0, 0) = 0 because then the natural numbers become a complete distributive lattice with gcd as meet and lcm as join operation. This extension of the definition is also compatible with the generalization for commutative rings given below." An added advantage, for haskell, of defining gcd 0 0 = 0 is that gcd would change from being a partial function to a total function. Regards, Steve From jason.dusek at gmail.com Fri May 1 22:34:24 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri May 1 22:22:31 2009 Subject: [Haskell-cafe] The Haskell Reddit is 1 year old In-Reply-To: <20090501052106.GA19238@whirlpool.galois.com> References: <20090501052106.GA19238@whirlpool.galois.com> Message-ID: <42784f260905011934k825eee9o6cb742526a41e321@mail.gmail.com> Happy Birthday! -- Jason Dusek From aeyakovenko at gmail.com Fri May 1 22:47:22 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Fri May 1 22:33:14 2009 Subject: [Haskell-cafe] traversing a tree using monad.cont Message-ID: So I am trying to traverse a tree in a specific order, but i have no idea where the things that i am looking for are located, and i want to avoid explicit backtracking. I was thinking i could do it with the continuation monad. Here is what i have module TestCont where import Control.Monad.Cont import Control.Monad.Identity import Control.Monad.State.Lazy --our stupid tree data Tree a = Tree [Tree a] | Leaf a --traverse all the branches search (Tree ts) next = do mapM_ (\ ti -> (callCC (search ti))) ts next $ () search tt@(Leaf a) next = do cur <- lift get case ((cur + 1) == a) of True -> do --the current leaf is what we want, update the state and return lift $ put a return $ () False -> do --the current leaf is not what we want, continue first, then try again next () search tt (\ _ -> error "fail") t1 = Leaf 1 t2 = Leaf 2 t3 = Tree [t1,t2] t4 = Leaf 3 t5::Tree Int = Tree [t4,t3] run = runIdentity (runStateT ((runContT $ callCC (search t5)) return) 0) it seems like next isn't quite doing what i want, because i don't think I ever try again after i call next $ () in the second clause. Any ideas? Thanks, Anatoly From jvlask at hotmail.com Fri May 1 22:56:32 2009 From: jvlask at hotmail.com (John Lask) Date: Fri May 1 22:45:33 2009 Subject: [Haskell-cafe] swish - semantic web in Haskell References: <715670.25503.qm@web65602.mail.ac4.yahoo.com> Message-ID: you might like to change the name of the package slightly and thereby avoid confusion with swish the text indexing engine. jvl ----- Original Message ----- From: "Doug Burke" To: "Vasili I. Galchin" Cc: Sent: Friday, May 01, 2009 11:15 PM Subject: Re: [Haskell-cafe] swish - semantic web in Haskell > > > --- On Thu, 4/30/09, Vasili I. Galchin wrote: > >> From: Vasili I. Galchin >> Subject: [Haskell-cafe] swish - semantic web in Haskell >> To: "haskell-cafe@haskell.org" >> Cc: "Galchin Vasili" >> Date: Thursday, April 30, 2009, 6:39 PM >> Hello, >> >> http://www.ninebynine.org/Software/swish-0.2.1.html >> .... I am trying >> to get permission from the author of Swish to move it into >> Hackage. I will >> write "cabalize" it get up to current Haskell >> standards. Before I go to this >> effort is anybody attempting to do this? >> >> Kind regards, Vasili > > Vasili, > > I recently downloaded the code and started looking at it, but I am > *exceedingly* unlikely to have time to do this any time soon. So, if you > have the time and the permission to do it, I'll be happy :-) > > Doug > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From lrpalmer at gmail.com Fri May 1 23:35:22 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri May 1 23:23:56 2009 Subject: [Haskell-cafe] traversing a tree using monad.cont In-Reply-To: References: Message-ID: <7ca3f0160905012035h6c333b57yca03c34e7cc342ec@mail.gmail.com> On Fri, May 1, 2009 at 8:47 PM, Anatoly Yakovenko wrote: > So I am trying to traverse a tree in a specific order, but i have no > idea where the things that i am looking for are located, and i want to > avoid explicit backtracking. Though I don't fully understand what you are doing (specifically what you mean by "specific order"), but in a lazy language, traversals are usually simply encoded as lists. Just write a function which returns all the leaves as a list, and filter over it. traverse (Tree ts) = concatMap traverse ts traverse (Leaf x) = [x] I believe this simple definition has more overhead than necessary because of all the appends; a DList will be more efficient. import qualified Data.DList as DList traverse = DList.toList . traverse' where traverse' t (Tree ts) = DList.concat (map traverse' ts) traverse' t (Leaf x) = DList.singleton x (DList is on hackage) I was thinking i could do it with the > continuation monad. Here is what i have > > module TestCont where > import Control.Monad.Cont > import Control.Monad.Identity > import Control.Monad.State.Lazy > > --our stupid tree > data Tree a = Tree [Tree a] > | Leaf a > > --traverse all the branches > search (Tree ts) next = do > mapM_ (\ ti -> (callCC (search ti))) ts > next $ () > > search tt@(Leaf a) next = do > cur <- lift get > case ((cur + 1) == a) of > True -> do --the current leaf is what we want, update the state and > return > lift $ put a > return $ () > False -> do --the current leaf is not what we want, continue > first, then try again > next () > search tt (\ _ -> error "fail") > > t1 = Leaf 1 > t2 = Leaf 2 > t3 = Tree [t1,t2] > t4 = Leaf 3 > t5::Tree Int = Tree [t4,t3] > > run = runIdentity (runStateT ((runContT $ callCC (search t5)) return) 0) > > it seems like next isn't quite doing what i want, because i don't > think I ever try again after i call next $ () in the second clause. > Any ideas? > > 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/20090501/7f6f67a4/attachment.htm From vigalchin at gmail.com Sat May 2 00:09:51 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Fri May 1 23:58:39 2009 Subject: [Haskell-cafe] swish - semantic web in Haskell In-Reply-To: References: <715670.25503.qm@web65602.mail.ac4.yahoo.com> Message-ID: <5ae4f2ba0905012109o1fc09232m1c25b6f5dc916446@mail.gmail.com> Hi John, I am not the author of Swish so I have absolutely no control ... I sympathize with you and I can bring up with the author ...In any case,I have read through a lot of the code and Swish/swish is pervasive .. so that may prove a "readability" problem. Kind regards, Vasili On Fri, May 1, 2009 at 9:56 PM, John Lask wrote: > you might like to change the name of the package slightly and thereby avoid > confusion with swish the text indexing engine. > > jvl > > ----- Original Message ----- From: "Doug Burke" > To: "Vasili I. Galchin" > Cc: > Sent: Friday, May 01, 2009 11:15 PM > Subject: Re: [Haskell-cafe] swish - semantic web in Haskell > > > >> >> --- On Thu, 4/30/09, Vasili I. Galchin wrote: >> >> From: Vasili I. Galchin >>> Subject: [Haskell-cafe] swish - semantic web in Haskell >>> To: "haskell-cafe@haskell.org" >>> Cc: "Galchin Vasili" >>> Date: Thursday, April 30, 2009, 6:39 PM >>> Hello, >>> >>> http://www.ninebynine.org/Software/swish-0.2.1.html >>> .... I am trying >>> to get permission from the author of Swish to move it into >>> Hackage. I will >>> write "cabalize" it get up to current Haskell >>> standards. Before I go to this >>> effort is anybody attempting to do this? >>> >>> Kind regards, Vasili >>> >> >> Vasili, >> >> I recently downloaded the code and started looking at it, but I am >> *exceedingly* unlikely to have time to do this any time soon. So, if you >> have the time and the permission to do it, I'll be happy :-) >> >> Doug >> >> >> >> >> _______________________________________________ >> 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/20090501/aad91705/attachment.htm From lambda-belka at yandex.ru Sat May 2 01:27:07 2009 From: lambda-belka at yandex.ru (Belka) Date: Sat May 2 01:15:21 2009 Subject: [Haskell-cafe] [tryReadAdvChan :: AdvChan a -> IO (Maybe a)] problems In-Reply-To: <344909F5-7BC9-4893-9553-6FB7669A87A9@gmail.com> References: <23328237.post@talk.nabble.com> <344909F5-7BC9-4893-9553-6FB7669A87A9@gmail.com> Message-ID: <23343213.post@talk.nabble.com> Thanks, Niel. :) You actually motivated me to determine/specify defense requirements <- that I should have done long before writing here. Now I'm not experienced in DDoSs defending, so my reasoning here might be a bit voulnerable. Few basic requirements: 1. Server has services that shouldn't be endangered by computational resource starvation. That is why I use load balancing for SAR (Services under Attack Risk). I even use 2 types of load controls: one per each SAR, and the second - above all ARSes. 2. Even when under attack SAR should be able to serve. Of course, it's effective input capability becomes much lower, but requirement here is to provide possible maximum of effectiveness. That is why 2.1. identification of bad request should be fast, and 2.2. request processing should be fair (without starvation on acceptance time). After projecting this /\ specification on architecture plan, the need in *good* tryReadChan is now less sharp. However, it still would be very useful - I also have other applications for it. The *good* tryReadChan would be atomic, immediate, and with determinate result (of type Maybe)... ---------- By the way, for > Actually, am I wrong thinking, that it can't be helped - and the > degradation > from cute concurency synchronization model of Chan is unavoidable? I have an idea of such solution (without getting down to lower level programming), - called it "fishing": one should complicate the flow unit (FlowUnit), that is being passed in the Channel. The FlowUnit diversifies to real bizness data, and service data. That way I now may gain control over blocking.... But this solution is not simple and lightweight. If anybody is interested, I could describe the concept in more details. Belka Neil Davies-2 wrote: > > Belka > > You've described what you don't want - what do you want? > > Given that the fundamental premise of a DDoS attack is to saturate > resources > so that legitimate activity is curtailed - ultimately the only > response has to be to > discard load, preferably not the legitimate load (and therein lies the > nub of the problem). > > What are you trying to achieve here - a guarantee of progress for the > system? > a guarantee of a fairness property? (e.g. some legitimate traffic will > get > processed) or, given that the DDoS load can be identified given some > initial > computation, guarantee to progress legitimate load up to some level of > DDoS > attack? > > Neil > > -- View this message in context: http://www.nabble.com/-tryReadAdvChan-%3A%3A-AdvChan-a--%3E-IO-%28Maybe-a%29--problems-tp23328237p23343213.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From semanticphilosopher at googlemail.com Sat May 2 02:53:58 2009 From: semanticphilosopher at googlemail.com (Neil Davies) Date: Sat May 2 02:41:38 2009 Subject: [Haskell-cafe] [tryReadAdvChan :: AdvChan a -> IO (Maybe a)] problems In-Reply-To: <23343213.post@talk.nabble.com> References: <23328237.post@talk.nabble.com> <344909F5-7BC9-4893-9553-6FB7669A87A9@gmail.com> <23343213.post@talk.nabble.com> Message-ID: Belka Now that you've got some metrics to know when you have a successful design, start examining the trades. Most systems have a turning point in their performance as load is increased, you need manage the traffic so that the offered load does not push the system over that point (or if it does, not for too long - it doesn't have to be perfect all the time, just suitably good - this is where stochastic come it, another story). What you are doing here is trading efficient use of the infrastructure (e.g. you are not going to try and run the servers close to 100%) for responsive behaviour. This is one of the reasons why people create multi-levelled web manage architectures - you could think of the design as having an initial stage that can analyse and identify the traffic an characterise it - ideally it should be able to cope with line rate or at least a known upper bound (which the load balancer in front knows and can be configured for), it can then pass the real traffic on for processing. This all comes down to creating back pressure: typically by mediating between producer and consumer with a finite queue - then configuring that queue to have the right length so that the back pressure is felt at an appropriate point, too long and the experienced delay is too large, too short and you are changing modes of behaviour too quickly - again it that stochastics/queueing theory stuff. Avoiding starvation is easy, FIFO service does that - but you'll find that's not enough you also need to bound the service time for certain requests people often think that 'priority' is the right answer but usually that is too naive. Resources are finite, giving one source of demand 'priority' means that the other sources loose out and that trade is highly non-linear and creates its own denial-of-service. Neil On 2 May 2009, at 06:27, Belka wrote: > > Thanks, Niel. :) > You actually motivated me to determine/specify defense requirements > <- that > I should have done long before writing here. > Now I'm not experienced in DDoSs defending, so my reasoning here > might be a > bit voulnerable. Few basic requirements: > 1. Server has services that shouldn't be endangered by computational > resource starvation. That is why I use load balancing for SAR > (Services > under Attack Risk). I even use 2 types of load controls: one per > each SAR, > and the second - above all ARSes. > 2. Even when under attack SAR should be able to serve. Of course, it's > effective input capability becomes much lower, but requirement here > is to > provide possible maximum of effectiveness. That is why > 2.1. identification of bad request should be fast, and > 2.2. request processing should be fair (without starvation on > acceptance > time). > > After projecting this /\ specification on architecture plan, the > need in > *good* tryReadChan is now less sharp. However, it still would be > very useful > - I also have other applications for it. > > The *good* tryReadChan would be atomic, immediate, and with > determinate > result (of type Maybe)... > ---------- > By the way, for >> Actually, am I wrong thinking, that it can't be helped - and the >> degradation >> from cute concurency synchronization model of Chan is unavoidable? > I have an idea of such solution (without getting down to lower level > programming), - called it "fishing": one should complicate the flow > unit > (FlowUnit), that is being passed in the Channel. The FlowUnit > diversifies to > real bizness data, and service data. That way I now may gain control > over > blocking.... > > But this solution is not simple and lightweight. If anybody is > interested, > I could describe the concept in more details. > > Belka > > > Neil Davies-2 wrote: >> >> Belka >> >> You've described what you don't want - what do you want? >> >> Given that the fundamental premise of a DDoS attack is to saturate >> resources >> so that legitimate activity is curtailed - ultimately the only >> response has to be to >> discard load, preferably not the legitimate load (and therein lies >> the >> nub of the problem). >> >> What are you trying to achieve here - a guarantee of progress for the >> system? >> a guarantee of a fairness property? (e.g. some legitimate traffic >> will >> get >> processed) or, given that the DDoS load can be identified given some >> initial >> computation, guarantee to progress legitimate load up to some level >> of >> DDoS >> attack? >> >> Neil >> >> > > -- > View this message in context: http://www.nabble.com/-tryReadAdvChan-%3A%3A-AdvChan-a--%3E-IO-%28Maybe-a%29--problems-tp23328237p23343213.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 semanticphilosopher at googlemail.com Sat May 2 03:34:54 2009 From: semanticphilosopher at googlemail.com (Neil Davies) Date: Sat May 2 03:20:50 2009 Subject: [Haskell-cafe] Estimating the time to garbage collect In-Reply-To: References: <6960D8EF-5AC1-4513-9673-86817582AC43@gmail.com> Message-ID: <37c497340905020034ic56d187kaeb70b9c735c4c81@mail.gmail.com> Yes, you've got the problem domain. I don't have to deliver responses to stimuli all the time within a bound, but I need to supply some probability for that figure. That problem domain is everywhere - all that varies is the bound on the time and the probability of meeting it. 'Hard real time' systems are very expensive to build and, typically, make very low utilisation of resources and have interesting failure modes when timing stops being be met. Meeting strict timing constraints is becoming more difficult as processors become more complex (think multi-level caching, clock rates that vary with temperature and/or load) and when those systems use packet based multiplexed as their interconnect (time slotted shared bus being too expensive). Yes, the proof obligations are more challenging, no more ability to enumerate the complete state space and prove that the schedule can always be met, no more 'certainty' that events and communications will occur within a fixed time. Interestingly giving up that constraint may well have its up-side, it was being used as a design 'crutch' - possibly being leaned on too heavily. Having to explicitly consider a probability distribution appears to create more robust overall systems. On the flip side, this more stochastic approach has to work - the commercial trends in wide area networking mean things are getting more stochastic, deterministic timings for wide are communications will be a thing of the past in 10 - 15 years (or prohibitively expensive). This is already worrying people like electricity distribution folks - their control systems are looking vulnerable to such changes and the issue of co-ordination electricity grids is only going to get more difficult as the number of generations sources increase, as is inevitable. Perhaps this is too much for a Saturday morning, sunny one at that.... Neil 2009/5/1 John Van Enk > I think the problem becomes slightly easier if you can provide an upper > bound on the time GC will take. If I understand your problem domain, Neil, > you're most concerned with holding up other processes/partitions who are > expecting to have a certain amount of processing time per frame. If we can > give an upper bound to the GC time, then we can plan for it in the schedule > without upsetting the other processes. > > I don't have an answer (though I'd love one), but I do think that asking > for an upper bound substantially simplifies the problem (though, I could be > wrong) and still gives you the characterisics you need to give a 'time to > complete'. > /jve > On Fri, May 1, 2009 at 4:14 AM, Neil Davies < > semanticphilosopher@googlemail.com> wrote: > >> Hi >> >> With the discussion on threads and priority, and given that (in Stats.c) >> there are lots of useful pieces of information that the run time system is >> collecting, some of which is already visible (like the total amount of >> memory mutated) and it is easy to make other measures available - it has >> raised this question in my mind: >> >> Given that you have access to that information (the stuff that comes out >> at the end of a run if you use +RTS -S) is it possible to estimate the time >> a GC will take before asking for one? >> >> Ignoring, at least for the moment, all the issues of paging, processor >> cache occupancy etc, what are the complexity drivers for the time to GC? >> >> I realise that it is going to depend on things like, volume of data >> mutated, count of objects mutated, what fraction of them are live etc - and >> even if it turns out that these things are very program specific then I have >> a follow-on question - what properties do you need from your program to be >> able to construct a viable estimate of GC time from a past history of such >> garbage collections? >> >> Why am I interested? There are all manners of 'real time' in systems, >> there is a vast class where a statistical bound (ie some sort of 'time to >> complete' CDF) is more than adequate for production use. If this is possible >> then it opens up areas where all the lovely properties of haskell can be >> exploited if only you had confidence in the timing behaviour. >> >> Cheers >> Neil >> _______________________________________________ >> 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/20090502/a824797d/attachment.htm From jason.dusek at gmail.com Sat May 2 05:12:47 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Sat May 2 05:00:31 2009 Subject: [Haskell-cafe] Array Binary IO & molecular simulation In-Reply-To: <251001241158007@webmail128.yandex.ru> References: <251001241158007@webmail128.yandex.ru> Message-ID: <42784f260905020212l2122cbdu876daf0a430a199d@mail.gmail.com> I believe Data.Binary includes a header with the data it serializes. In consequence, the second and all following arrays will be invisible. Sorry I can not be of more help. -- Jason Dusek From aeyakovenko at gmail.com Sat May 2 05:13:18 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Sat May 2 05:00:50 2009 Subject: [Haskell-cafe] traversing a tree using monad.cont In-Reply-To: <7ca3f0160905012035h6c333b57yca03c34e7cc342ec@mail.gmail.com> References: <7ca3f0160905012035h6c333b57yca03c34e7cc342ec@mail.gmail.com> Message-ID: > Though I don't fully understand what you are doing (specifically what you > mean by "specific order"), but in a lazy language, traversals are usually > simply encoded as lists. ?Just write a function which returns all the leaves > as a list, and filter over it. yea, i know, i am trying to learn how to use the Cont monad. or continuation in haskell. The idea is that while i am processing some data i may hit a point whree some dependency isn't met and i want to take a different branch via continuation. I expect that branch to furfill my dependency and when its done i want to continue down the original branch >> module TestCont where >> import Control.Monad.Cont >> import Control.Monad.Identity >> import Control.Monad.State.Lazy >> >> --our stupid tree >> data Tree a = Tree [Tree a] >> ? ? ? ? ? ?| Leaf a >> >> --traverse all the branches >> search (Tree ts) next = do >> ? mapM_ (\ ti -> (callCC (search ti))) ts >> ? next $ () >> >> search tt@(Leaf a) next = do >> ? cur <- lift get >> ? case ((cur + 1) == a) of >> ? ? ?True -> do --the current leaf is what we want, update the state and return this is where i succeed in my current branch, so i can just do my thing and exit >> ? ? ? ? lift $ put a >> ? ? ? ? return $ () >> ? ? ?False -> do --the current leaf is not what we want, continue first, then try again this is where i fail, so i want to take the "other" branch first expecting it to fulfill my dependency. >> ? ? ? ? next () >> ? ? ? ? search tt (\ _ -> error "fail") >> >> t1 = Leaf 1 >> t2 = Leaf 2 >> t3 = Tree [t1,t2] >> t4 = Leaf 3 >> t5::Tree Int = Tree [t4,t3] >> >> run = ?runIdentity (runStateT ((runContT $ callCC (search t5)) return) 0) but i think next doesn't do exactly what i think it does From lrpalmer at gmail.com Sat May 2 05:33:58 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Sat May 2 05:20:44 2009 Subject: [Haskell-cafe] traversing a tree using monad.cont In-Reply-To: References: <7ca3f0160905012035h6c333b57yca03c34e7cc342ec@mail.gmail.com> Message-ID: <7ca3f0160905020233x4aeb0391xcd394ffcb2236527@mail.gmail.com> On Sat, May 2, 2009 at 3:13 AM, Anatoly Yakovenko wrote: > > Though I don't fully understand what you are doing (specifically what you > > mean by "specific order"), but in a lazy language, traversals are usually > > simply encoded as lists. Just write a function which returns all the > leaves > > as a list, and filter over it. > > yea, i know, i am trying to learn how to use the Cont monad. or > continuation in haskell. The idea is that while i am processing some > data i may hit a point whree some dependency isn't met and i want to > take a different branch via continuation. I expect that branch to > furfill my dependency and when its done i want to continue down the > original branch Ah I see. Well, in my opinion, Cont is almost never the right answer. Others, who have an easier time thinking about continuations, may differ. In any case, you are stating your problem very imperatively, which may be why you feel inclined to use continuations. E.g. "when it's done I want to continue down the original branch" is talking about control flow. Maybe you really just want to do a topological sort of some data in your tree? How is the tree structure related to the dependencies? How is the tree structure related to your traversal? E.g. are you using a combining function on each branch to a value over its subtrees? Basically I think "do a traversal" is not enough information to answer your question. What is the relationship of the contents of the tree to the *contents *of the traversal? Luke > > > >> module TestCont where > >> import Control.Monad.Cont > >> import Control.Monad.Identity > >> import Control.Monad.State.Lazy > >> > >> --our stupid tree > >> data Tree a = Tree [Tree a] > >> | Leaf a > >> > >> --traverse all the branches > >> search (Tree ts) next = do > >> mapM_ (\ ti -> (callCC (search ti))) ts > >> next $ () > >> > >> search tt@(Leaf a) next = do > >> cur <- lift get > >> case ((cur + 1) == a) of > >> True -> do --the current leaf is what we want, update the state and > return > > this is where i succeed in my current branch, so i can just do my thing and > exit > > >> lift $ put a > >> return $ () > >> False -> do --the current leaf is not what we want, continue first, > then try again > > this is where i fail, so i want to take the "other" branch first > expecting it to fulfill my dependency. > > >> next () > >> search tt (\ _ -> error "fail") > >> > >> t1 = Leaf 1 > >> t2 = Leaf 2 > >> t3 = Tree [t1,t2] > >> t4 = Leaf 3 > >> t5::Tree Int = Tree [t4,t3] > >> > >> run = runIdentity (runStateT ((runContT $ callCC (search t5)) return) > 0) > > > but i think next doesn't do exactly what i think it does > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090502/e5d0a907/attachment.htm From gtener at gmail.com Sat May 2 05:59:41 2009 From: gtener at gmail.com (=?UTF-8?Q?Krzysztof_Skrz=C4=99tnicki?=) Date: Sat May 2 05:46:05 2009 Subject: [Haskell-cafe] Array Binary IO & molecular simulation In-Reply-To: <42784f260905020212l2122cbdu876daf0a430a199d@mail.gmail.com> References: <251001241158007@webmail128.yandex.ru> <42784f260905020212l2122cbdu876daf0a430a199d@mail.gmail.com> Message-ID: <220e47b40905020259r2ad1ce24k5cc5df55760730c7@mail.gmail.com> On Sat, May 2, 2009 at 11:12, Jason Dusek wrote: > ?I believe Data.Binary includes a header with the data > ?it serializes. In consequence, the second and all following > ?arrays will be invisible. [Apologies for Jason for sending this twice to him] I didn't check the Binary instance for arrays, however I belive it's not true. Consider Binary instances for tuples: instance (Binary a, Binary b) => Binary (a,b) where put (a,b) = put a >> put b get = liftM2 (,) get get instance (Binary a, Binary b, Binary c) => Binary (a,b,c) where put (a,b,c) = put a >> put b >> put c get = liftM3 (,,) get get get If what you are saying would be true, the tuple instances would be incorrect for array tuples. Best regards Christopher Skrz?tnicki From jon.fairbairn at cl.cam.ac.uk Sat May 2 06:24:47 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Sat May 2 06:12:02 2009 Subject: [Haskell-cafe] Re: fromInteger for Lists References: <3CDFB8AFEA98E34CB599475AB11589C82C3D59@EX2.ad.dcs.gla.ac.uk> <49FB881B.2000406@henning-thielemann.de> Message-ID: Henning Thielemann writes: > Paul Keir schrieb: >> There's nothing better than making a data type an instance of Num. In >> particular, fromInteger is a joy. But how about lists? > > http://www.haskell.org/haskellwiki/Num_instance_for_functions > http://www.haskell.org/haskellwiki/Type_classes_are_for_reusability Hear, hear! -- 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 jason.dusek at gmail.com Sat May 2 07:16:53 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Sat May 2 07:06:02 2009 Subject: [Haskell-cafe] Array Binary IO & molecular simulation In-Reply-To: <220e47b40905020259r2ad1ce24k5cc5df55760730c7@mail.gmail.com> References: <251001241158007@webmail128.yandex.ru> <42784f260905020212l2122cbdu876daf0a430a199d@mail.gmail.com> <220e47b40905020259r2ad1ce24k5cc5df55760730c7@mail.gmail.com> Message-ID: <42784f260905020416p5b2190e0u75ea80ece8a19498@mail.gmail.com> 2009/05/02 Krzysztof Skrz?tnicki : > 2009/05/02 Jason Dusek : >> I believe Data.Binary includes a header with the data it >> serializes. In consequence, the second and all following >> arrays will be invisible. > > I didn't check the Binary instance for arrays, however I > belive it's not true. Consider Binary instances for tuples: These instances describe serializers for tuples; however, there is nothing preventing Data.Binary from tacking on a length header or anything else like that when `encode` is called. The original poster should try serializing a tuple of arrays instead of serializing each array individually. > If what you are saying would be true, the tuple instances > would be incorrect for array tuples. What is an array tuple? -- Jason Dusek From martijn at van.steenbergen.nl Sat May 2 07:17:00 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Sat May 2 07:06:20 2009 Subject: [Haskell-cafe] gcd In-Reply-To: <1241229917.3721.3.camel@host.localdomain> References: <20090118204519.320AF32465D@www.haskell.org> <1241229917.3721.3.camel@host.localdomain> Message-ID: <49FC2BAC.7000205@van.steenbergen.nl> Hi Steve, Steve wrote: > Why is gcd 0 0 undefined? That's a good question. Can you submit an official proposal? http://www.haskell.org/haskellwiki/Library_submissions Thanks, Martijn. From mads_lindstroem at yahoo.dk Sat May 2 08:11:42 2009 From: mads_lindstroem at yahoo.dk (Mads =?ISO-8859-1?Q?Lindstr=F8m?=) Date: Sat May 2 07:58:41 2009 Subject: [Haskell-cafe] When is it OK to create a new mailing list? Message-ID: <1241266302.4314.15.camel@supermule.opasia.dk> Hi I wanted a mailing list for my project WxGeneric and I am wondering when it is OK to do so? How big must the potential audience be? Is there any kind of etiquette or guidelines? Here http://haskell.org/mailman/admin it says that I must have "the proper authority" to create a mailing list. What is meant by "proper authority"? Can I just try to create one and see if I am successful? Or must I request someone to do it? Regards, Mads Lindstr?m -------------- 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/20090502/66b341d3/attachment.bin From sargrigory at ya.ru Sat May 2 10:22:51 2009 From: sargrigory at ya.ru (Grigory Sarnitskiy) Date: Sat May 2 10:11:38 2009 Subject: [Haskell-cafe] Array Binary IO & molecular simulation In-Reply-To: <42784f260905020416p5b2190e0u75ea80ece8a19498@mail.gmail.com> References: <251001241158007@webmail128.yandex.ru> <42784f260905020212l2122cbdu876daf0a430a199d@mail.gmail.com> <220e47b40905020259r2ad1ce24k5cc5df55760730c7@mail.gmail.com> <42784f260905020416p5b2190e0u75ea80ece8a19498@mail.gmail.com> Message-ID: <742701241274171@webmail37.yandex.ru> An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090502/8c52a776/attachment.htm From pkeir at dcs.gla.ac.uk Sat May 2 12:31:03 2009 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Sat May 2 12:17:23 2009 Subject: [Haskell-cafe] The essence of my monad confusion Message-ID: <3CDFB8AFEA98E34CB599475AB11589C82C3D5A@EX2.ad.dcs.gla.ac.uk> On the wiki page for Applicative Functors (http://www.haskell.org/haskellwiki/Applicative_functor) a familiar characteristic of monads is quoted; that they "allow you to run actions depending on the outcomes of earlier actions". I feel comfortable with Functors and Applicative Functors, but I don't yet get that "extra power" that monads provide. An example immediately follows that quotation on the wiki: do text <- getLine if null text then putStrLn "You refuse to enter something?" else putStrLn ("You entered " ++ text) For simplicity's sake, I modified it to avoid using the IO monad; the "text" binding is now provided by the first parameter, and (=<<) is used due to its similarity to fmap: bar :: Monad m => m String -> m String bar as = (=<<) (\a -> if null a then return "nothing" else return "something") as This works fine, so bar ["Blah"] gives ["something"], and bar (Just "") gives ["nothing"]. But, I can get the same effect using a Functor (replacing (=<<) with fmap): bar2 :: Functor f => f String -> f String bar2 as = fmap (\a -> if null a then "nothing" else "something") as Can anyone help me out of the swamp? Cheers, Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090502/027487ee/attachment.htm From pkeir at dcs.gla.ac.uk Sat May 2 12:33:08 2009 From: pkeir at dcs.gla.ac.uk (Paul Keir) Date: Sat May 2 12:23:47 2009 Subject: [Haskell-cafe] fromInteger for Lists References: <3CDFB8AFEA98E34CB599475AB11589C82C3D59@EX2.ad.dcs.gla.ac.uk> Message-ID: <3CDFB8AFEA98E34CB599475AB11589C82C3D5C@EX2.ad.dcs.gla.ac.uk> Thanks Andy, et al. I can stop hacking for now then. I'm using a simple fromList function already which seems like a reasonable, and at least semi-standard solution (http://www.haskell.org/hoogle/?hoogle=fromList) Paul -----Original Message----- From: sploink88@gmail.com on behalf of andy morris Sent: Sat 02/05/2009 00:13 To: Paul Keir Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] fromInteger for Lists[MESSAGE NOT SCANNED] 2009/5/1 Paul Keir : > There's nothing better than making a data type an instance of Num. In > particular, fromInteger is a joy. But how about lists? > > For example, if I have > > data Foo a = F [a] > > I can create a fromInteger such as > fromInteger i = F [fromInteger i] > > and then a 19::(Foo Int), could become F [19]. > > Is it possible to do something similar for lists? So could > [1,2,3]::(Foo Int) become something slightly different, say, > > F [1,2,3] > > Paul > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > If you mean what I think you're referring to, you can't. The only reason it works for integer literals is that the compiler replaces occurrences of, say, 19 with (fromInteger 19). There's no function that's automatically applied to list literals, so ([1,2,3] :: Foo Int) isn't able to do anything useful, unfortunately. However, there's an extension in GHC, OverloadedStrings, which lets you use the method fromString of class Data.String.IsString to overload literals. (That's not what you asked, though, I know. :) ) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090502/d832bd2d/attachment.htm From aslatter at gmail.com Sat May 2 12:51:49 2009 From: aslatter at gmail.com (Antoine Latter) Date: Sat May 2 12:38:17 2009 Subject: [Haskell-cafe] The essence of my monad confusion In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C82C3D5A@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C82C3D5A@EX2.ad.dcs.gla.ac.uk> Message-ID: <694519c50905020951m7a8fd4f7r9cc79f7fea2fc931@mail.gmail.com> On Sat, May 2, 2009 at 11:31 AM, Paul Keir wrote: > On the wiki page for Applicative Functors > (http://www.haskell.org/haskellwiki/Applicative_functor) a familiar > characteristic of monads is quoted; that they "allow you to run actions > depending on the outcomes of earlier actions". I feel comfortable with > Functors and Applicative Functors, but I don't yet get that "extra power" > that monads provide. > > An example immediately follows that quotation on the wiki: > > do text <- getLine > ?? if null text > ???? then putStrLn "You refuse to enter something?" > ???? else putStrLn ("You entered " ++ text) > > For simplicity's sake, I modified it to avoid using the IO monad; the "text" > binding is now provided by the first parameter, and (=<<) is used due to its > similarity to fmap: > > bar :: Monad m => m String -> m String > bar as = (=<<)? (\a -> if null a then return "nothing" else return > "something")? as > > This works fine, so bar ["Blah"] gives ["something"], and bar (Just "") > gives ["nothing"]. > > But, I can get the same effect using a Functor (replacing (=<<) with fmap): > > bar2 :: Functor f => f String -> f String > bar2 as = fmap (\a -> if null a then "nothing" else "something") as > > Can anyone help me out of the swamp? > Suppose I had functions: bar3 :: Functor f => String -> f Bool bar4 :: Funcotr f => Bool -> f Integer If the only thing I have is the functor constraint, to chain them together I have to end up with something of type (Functor f => String -> f (f Integer)). If I had a Monad constraint on bar3 and bar4 I could flatten the result type and get rid of the "double nesting" and end up with a function of type (String -> f Integer). So it's not about what a single function can do, but what tools I have to compose the functions. Antoine From byorgey at seas.upenn.edu Sat May 2 12:58:37 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat May 2 12:44:46 2009 Subject: [Haskell-cafe] The essence of my monad confusion In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C82C3D5A@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C82C3D5A@EX2.ad.dcs.gla.ac.uk> Message-ID: <20090502165837.GA23142@seas.upenn.edu> On Sat, May 02, 2009 at 05:31:03PM +0100, Paul Keir wrote: > On the wiki page for Applicative Functors (http://www.haskell.org/haskellwiki/Applicative_functor) a familiar characteristic of monads is quoted; that they "allow you to run actions depending on the outcomes of earlier actions". I feel comfortable with Functors and Applicative Functors, but I don't yet get that "extra power" that monads provide. > > An example immediately follows that quotation on the wiki: > > do text <- getLine > if null text > then putStrLn "You refuse to enter something?" > else putStrLn ("You entered " ++ text) > > For simplicity's sake, I modified it to avoid using the IO monad; the "text" binding is now provided by the first parameter, and (=<<) is used due to its similarity to fmap: > > bar :: Monad m => m String -> m String > bar as = (=<<) (\a -> if null a then return "nothing" else return "something") as This simplification does not preserve the crucial aspect of the example: (putStrLn "blah") has an effect (namely, printing something on the screen), whereas (return "blah") never has an effect (whatever "effect" means for the particular monad in question). You seem to be confusing the return value of a monadic computation with its side effects. In the case of 'putStrLn "blah"', the return value is (), and the side effect is to print "blah" to the screen; in the case of 'return "blah"', the return value is "blah" and there are no side effects. Since IO is a monad, we can compute the result of 'getLine' and then use it to decide which of the two putStrLns to run; the effect of the other one (printing something on the screen) will never happen. But there is no way to do this with only the Applicative interface. Try writing a function f :: IO String -> IO () -> IO () -> IO () which has the same behavior as the 'do text <- getLine...' example above, using *only* the Applicative instance of IO; you won't be able to do it. Depending how you implement f, it may execute only the first IO (), or only the second, or both, or neither; but it will always be the same. You won't be able to have f choose which to execute based on the result of the IO String parameter. -Brent From felipe.lessa at gmail.com Sat May 2 13:09:29 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat May 2 12:55:14 2009 Subject: [Haskell-cafe] The essence of my monad confusion In-Reply-To: <3CDFB8AFEA98E34CB599475AB11589C82C3D5A@EX2.ad.dcs.gla.ac.uk> References: <3CDFB8AFEA98E34CB599475AB11589C82C3D5A@EX2.ad.dcs.gla.ac.uk> Message-ID: <20090502170929.GA21146@kira.casa> On Sat, May 02, 2009 at 05:31:03PM +0100, Paul Keir wrote: > An example immediately follows that quotation on the wiki: > > do text <- getLine > if null text > then putStrLn "You refuse to enter something?" > else putStrLn ("You entered " ++ text) Then, how about getMyLine = getLine >>= \text -> if null text then getMyLine else return m Can you, using functors, decide to run 'getLine' again or not? HTH, -- Felipe. From Sven.Panne at aedion.de Sat May 2 13:14:13 2009 From: Sven.Panne at aedion.de (Sven Panne) Date: Sat May 2 12:59:53 2009 Subject: [Haskell-cafe] Decoupling OpenAL/ALUT packages from OpenGL Message-ID: <200905021914.13307.Sven.Panne@aedion.de> I'd like to get some feedback from the Haskell community about some packaging issues, so here is my problem: As a medium-term goal, I'd like to decouple the OpenAL/ALUT packages from the OpenGL package, because there are very sensible use cases where you might need some sound, but not OpenGL. The current coupling has mostly historic reasons. The OpenAL package depends on the OpenGL package in 3 areas: * OpenAL uses OpenGL's notion of StateVars all over the place. * OpenAL's Buffer and Source are instances of OpenGL's ObjectName class. * OpenAL's sources and listeners have some properties like velocity, orientation, direction and position which are modeled by OpenGL's Vector3 and Vertex3 data types. The ALUT package depends on the OpenGL package because of GettableStateVars. The packages are supposed to fit nicely together, so using the same types is a must, but the actual packaging is not nice. So the obvious idea is to introduce 3 new packages which lift out functionality from the OpenGL package: * a small "StateVar" package, consisting only of OpenGL's StateVar module (in a better place in the name hierarchy, of course, perhaps "Data.StateVar"?) * a tiny "ObjectName" package, consisting only of OpenGL's ObjectName class (In "Data.ObjectName"? I'm not very sure about a good place in the hierarchy here.) * a package containing most of the data types/newtypes in OpenGL's VertexSpec module (Vertex{2,3,4}, Color{3,4}, etc.) plus instances for the base classes like Eq, Ord, Show, etc. I really don't know a good name for this package and what a good place in the hierarchy would be (probably something like "Data.Foo", but what is Foo?) The point is: The first two package would be very small. Would this be OK? Does anybody see other alternatives? What would be good names for those packages and where in the naming hierarchy should they really go? Cheers, S. From khaelin at gmail.com Sat May 2 13:17:55 2009 From: khaelin at gmail.com (Nicolas Martyanoff) Date: Sat May 2 13:03:35 2009 Subject: [Haskell-cafe] using haskell for a project Message-ID: <20090502171755.GA2939@valhala.gaia.loc> Hi, I don't think I already presented myself; I'm Nicolas, a 23y french student, trying to learn and use haskell. I've been using C for years, for all sort of tasks, and am quite comfortable with it. I'm also using it 40h a week in my internship for network systems, so I kind of know how to use it. I discovered Haskell some monthes ago, bought `Real World Haskell', quickly read, and enjoyed it. So now I'd want to use it for a small project of mine, a simple multiplayer roguelike based on telnet. I wrote a minimal server in C, and it took me a few hours. Now I'm thinking about doing the same in Haskell, and I'm in trouble. I don't really know how to map my ideas in haskell code. For example, a character can cast spells, so I'd have something like this in C: struct hashtable spells; struct character { int n_spells; struct spell **spells; }; I thought I could do something like this in haskell: spells = Data.Map.Map Int Spell data Character = Character { charSpells :: [Int] } But now I don't know how to dynamically add new spells (new spells can be created in my gameplay). Since I can't assign a new value to the `spells' variable (Data.Map.insert returns a new map), I just don't know where to go. I have the same problem for a bout every problem. I love writing pure functions in haskell, but as soon as I try to write some code involving states or side effects, I can't write a line. I just wanted a 2d array to store a zone, for example, dead simple in C, but this kind of link http://greenokapi.net/blog/2009/03/10/rough-grids-in-haskell make me shiver. Point is, I'd like to use haskell, but I don't know how, it seems totally alien. How did you manage to change the way you map ideas to code, from imperative to pure functional ? Thank you. Regards, -- Nicolas Martyanoff http://codemore.org khaelin@gmail.com -------------- 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/20090502/e4102352/attachment.bin From bulat.ziganshin at gmail.com Sat May 2 13:22:59 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat May 2 13:09:30 2009 Subject: [Haskell-cafe] Decoupling OpenAL/ALUT packages from OpenGL In-Reply-To: <200905021914.13307.Sven.Panne@aedion.de> References: <200905021914.13307.Sven.Panne@aedion.de> Message-ID: <723653168.20090502212259@gmail.com> Hello Sven, Saturday, May 2, 2009, 9:14:13 PM, you wrote: > must, but the actual packaging is not nice. So the obvious idea is to > introduce 3 new packages which lift out functionality from the OpenGL package: another possible variant: OpenGL-DataTypes package that joins these 3 -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From nowgate at yahoo.com Sat May 2 13:45:40 2009 From: nowgate at yahoo.com (michael rice) Date: Sat May 2 13:32:55 2009 Subject: [Haskell-cafe] Generating random enums Message-ID: <515911.18381.qm@web31103.mail.mud.yahoo.com> OK, I think what you're saying is to work with (random) integers and use fromEnum and toEnum to get corresponding DayOfWeek. But I get this when I try to use toEnum: [michael@localhost ~]$ ghci dow 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???????????? ( dow.hs, interpreted ) Ok, modules loaded: Main. *Main> fromEnum Wednesday Loading package old-locale-1.0.0.1 ... linking ... done. Loading package old-time-1.0.0.1 ... linking ... done. Loading package random-1.0.0.1 ... linking ... done. 2 *Main> toEnum 2 *** Exception: Prelude.Enum.().toEnum: bad argument *Main> Michael --- On Fri, 5/1/09, John Van Enk wrote: From: John Van Enk Subject: Re: [Haskell-cafe] Generating random enums To: "michael rice" Cc: haskell-cafe@haskell.org Date: Friday, May 1, 2009, 12:36 PM When you derive Enum, you get fromEnum and toEnum for free. You don't need your dow2Int stuff or int2Dow. Replace those with fromEnum and toEnum respectively. ? /jve On Fri, May 1, 2009 at 12:26 PM, michael rice wrote: I'm using the code below to generate random days of the week [Monday..Sunday]. Is there a better/shorter way to do this? Michael ============== [michael@localhost ~]$ ghci dow 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???????????? ( dow.hs, interpreted ) Ok, modules loaded: Main. *Main> random (mkStdGen 100) :: (DayOfWeek, StdGen) Loading package old-locale-1.0.0.1 ... linking ... done. Loading package old-time-1.0.0.1 ... linking ... done. Loading package random-1.0.0.1 ... linking ... done. (Friday,4041414 40692) *Main> random (mkStdGen 123) :: (DayOfWeek, StdGen) (Tuesday,4961736 40692) *Main> ============== import System.Random data DayOfWeek ??? = Monday ??? | Tuesday ??? | Wednesday ??? | Thursday ??? | Friday ??? | Saturday ??? | Sunday ??? deriving (Show, Read, Eq, Enum, Ord, Bounded) instance Random DayOfWeek where ? randomR (a,b) g = ????? case (randomIvalInteger (toInteger (dow2Int a), toInteger (dow2Int b)) g) of ??????? (x, g) -> (int2Dow x, g) ?????? where ???????? dow2Int Monday??? = 0 ???????? dow2Int Tuesday?? = 1 ???????? dow2Int Wednesday = 2 ???????? dow2Int Thursday? = 3 ???????? dow2Int Friday??? = 4 ???????? dow2Int Saturday? = 5 ???????? dow2Int Sunday??? = 6 ?? ? int2Dow 0?? ?= Monday ?? ? int2Dow 1?? ?= Tuesday ?? ? int2Dow 2?? ?= Wednesday ?? ? int2Dow 3?? ?= Thursday ?? ? int2Dow 4?? ?= Friday ?? ? int2Dow 5?? ?= Saturday ?? ? int2Dow 6?? ?= Sunday ? random g?? ?? = randomR (minBound,maxBound) g randomIvalInteger :: (RandomGen g, Num a) => (Integer, Integer) -> g -> (a, g) randomIvalInteger (l,h) rng ?| l > h???? = randomIvalInteger (h,l) rng ?| otherwise = case (f n 1 rng) of (v, rng') -> (fromInteger (l + v `mod` k), rng') ???? where ?????? k = h - l + 1 ?????? b = 2147483561 ?????? n = iLogBase b k ?????? f 0 acc g = (acc, g) ?????? f n acc g = ????????? let ?? ??? (x,g')?? = next g ?? ?? in ?? ?? f (n-1) (fromIntegral x + acc * b) g' iLogBase :: Integer -> Integer -> Integer iLogBase b i = if i < b then 1 else 1 + iLogBase b (i `div` b) ? _______________________________________________ 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/20090502/7d40f332/attachment.htm From rk at trie.org Sat May 2 14:00:54 2009 From: rk at trie.org (Rahul Kapoor) Date: Sat May 2 13:47:02 2009 Subject: [Haskell-cafe] Generating random enums In-Reply-To: <515911.18381.qm@web31103.mail.mud.yahoo.com> References: <515911.18381.qm@web31103.mail.mud.yahoo.com> Message-ID: > OK, I think what you're saying is to work with (random) integers and use > fromEnum and toEnum to get corresponding DayOfWeek. But I get this when I > try to use toEnum: > > *Main> toEnum 2 ghci does not know what type of enum you want to create from the number 2. Try: toEnum 2 :: DayOfWeek That said, I would expect "toEnum 2" to give an error like: 'Ambiguous type variable `a'....'. So I am not sure why your error message says: '** Exception: Prelude.Enum.().toEnum: bad argument' From aeyakovenko at gmail.com Sat May 2 14:21:52 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Sat May 2 14:07:43 2009 Subject: [Haskell-cafe] traversing a tree using monad.cont In-Reply-To: <7ca3f0160905020233x4aeb0391xcd394ffcb2236527@mail.gmail.com> References: <7ca3f0160905012035h6c333b57yca03c34e7cc342ec@mail.gmail.com> <7ca3f0160905020233x4aeb0391xcd394ffcb2236527@mail.gmail.com> Message-ID: its a syntax tree, and at some point i hit a type reference who'se declaration will be satisfied in some other part of the tree. the type references are always leaves, so when i hit a typeref, i just want to continue along the rest of the parser until i hit a declaration. My current solution is to do multiple passes, store the declarations in a map in one pass then resolve all the type references in another, but that's kind of boring. From byorgey at seas.upenn.edu Sat May 2 14:33:24 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat May 2 14:19:14 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 116 - May 2, 2009 Message-ID: <20090502183324.GA24954@seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090502 Issue 116 - May 02, 2009 --------------------------------------------------------------------------- Welcome to issue 116 of HWN, a newsletter covering developments in the [1]Haskell community. Announcements GHC 6.10.3 prerelease. Ian Lynagh [2]announced a [3]prerelease [4]version of GHC 6.10.3. There have been [5]very few changes relative to 6.10.2. Unless any major problems are uncovered, the final release is expected to be built in a couple of days. graphviz-2009.5.1. Ivan Lazar Miljenovic [6]announced version 2009.5.1 of the [7]graphviz library, which provides a Haskell interface to the [8]GraphViz program. Major changes include support for polyparse >= 1.1, dependency on GHC 6.10.*, functions from the [9]Graphalyze library, and more. priority-sync-0.1.0.1: Cooperative task prioritization.. Christopher Lane Hinson [10]announced the release of the [11]priority-sync package for cooperative task prioritization. HaL4: Local Haskell meeting, Halle/Saale, Germany, June 12. Henning Thielemann [12]requested proposals for talks for [13]HaL4, a local Haskell meeting in Halle, Germany on June 12. TraverseAccum: an effectful accumulating map.. Florent Balestrieri [14]posted some code implementing an effectful accumulating map. LondonHUG talk: Engineering Large Projects in Haskell. Don Stewart [15]posted [16]slides from last week's [17]London HUG talk, which attempts to document some of the tips and tricks Galois has accumulated using Haskell commercially for the past 10 years. atom-0.0.2. Tom Hawkins [18]announced the release of [19]atom, a Haskell DSL for designed hard realtime embedded programs. Eaton is using it to control hydraulic hybrid refuse trucks and shuttle buses. Bamse-0.9.4, a Windows Installer generator. Sigbjorn Finne [20]announced a new version of [21]Bamse, a package and application for letting you quickly put together Windows Installers for your software projects/products from within the comforts of Haskell. New in this release is the support for generating MSIs from your Cabal projects, having them either be built from source or just have them be installed and registered at install-time. Dutch Haskell Users' Group (first meeting: May 6th). Chris Eidhof [22]announced the first meeting of the newly formed [23]Dutch Haskell Users' Group (DHUG), on May 6th at 19:30 in Utrecht. Haskell Symposium Submission site now open. Stephanie Weirich [24]announced that [25]submission to the Haskell Symposium is now open. The submission deadline is May 8. OpenGL, GLUT, OpenAL, and ALUT updates. Sven Panne [26]announced [27]new [28]bugfix [29]releases for the [30]OpenGL, [31]GLUT, [32]OpenAL, and [33]ALUT packages. control-monad-exception-0.1: Explicitly typed exceptions. Pepe Iborra [34]announced the [35]control-monad-exception package, which provides explicitly typed exceptions for Haskell. The type of a computation in the EM monad carries a list of the exceptions that the computation may throw. A exception is raised with 'throw', which in addition adds it to the type, and captured with 'catch', which correspondingly removes it from the type. Only safe computations (all exceptions handled) can escape from the monad. Haskell File Manager. Michael Dever [36]announced the first release of [37]Haskell File Manager, a program for viewing/managing the files on your computer. It has all the common functionality you would expect from your current file manager, copying, moving, deleting, renaming, opening and searching. uu-parsinglib-2.0.0. S. Doaitse Swierstra [38]announced the release of [39]uu-parsinglib, the first version of the new parsing combinator library package from Utrecht University. Features include online result construction, much simpler internals than the combinators in the uulib package, error correction, parsing ambiguous grammars, a monadic interface, and more. Takusen 0.8.4. Alistair Bayley [40]announced version 0.8.4 of [41]Takusen, a database package; this is mostly a "get it working with ghc-6.10" release. Discussion Google SoC: Space profiling reloaded. Patai Gergely [42]asked for ideas on his Google Summer of Code project to [43]improve the Haskell space profiling experience. Blog noise [44]Haskell news from the [45]blogosphere. * Bryan O'Sullivan: [46]Slides from my Erlang Factory talk this morning. * Thomas Hartman: [47]What to do when cabal install works in one environment, but not another.. * Christopher Lane Hinson: [48]ANN: priority-sync. * Well-Typed.Com: [49]"Hello world" now only 11k using GHC with shared libs. * The GHC Team: [50]The new GHC build system is here!. * Well-Typed.Com: [51]First round of Industrial Haskell Group development work. * London Haskell Users Group: [52]Don's slides. * Galois, Inc: [53]Engineering Large Projects in Haskell: A Decade of FP at Galois. * JP Moresmau: [54]Haskell RPG Game uploaded on Hackage!. * Holumbus: [55]Distributed data structures. * Niklas Broberg: [56]GSoC09 => haskell-src-exts -> haskell-src. * >>> Remco Niemeijer: [57]Forcing evaluation in Haskell. * Chris Eidhof: [58]Building commercial Haskell applications. * >>> Lab49: [59]Differentiating Types in Haskell. Quotes of the Week * MonadState: Do not try to change the state; that's impossible. Instead only try to realize the truth: There is no state. * Baughn: Those who would give up essential laziness for a little ephemeral performance, deserve neither laziness nor performance. * Axman6: what's @flush do? saves stuff to dick? * bos: Crummy languages give static types a bad name. 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.glasgow.user/16852 3. http://www.haskell.org/ghc/dist/stable/dist/ghc-6.10.2.20090430-src.tar.bz2 4. http://www.haskell.org/ghc/dist/stable/dist/ghc-6.10.2.20090430-src-extralibs.tar.bz2 5. http://www.haskell.org/ghc/dist/stable/docs/users_guide/release-6-10-3.html 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/57826 7. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/graphviz 8. http://graphviz.org/ 9. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Graphalyze 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/57776 11. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/priority-sync 12. http://article.gmane.org/gmane.comp.lang.haskell.cafe/57764 13. http://www.iba-cg.de/hal4.html 14. http://article.gmane.org/gmane.comp.lang.haskell.cafe/57730 15. http://article.gmane.org/gmane.comp.lang.haskell.cafe/57719 16. http://www.galois.com/blog/2009/04/27/engineering-large-projects-in-haskell-a-decade-of-fp-at-galois/ 17. http://www.londonhug.net/ 18. http://article.gmane.org/gmane.comp.lang.haskell.cafe/57676 19. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/atom 20. http://article.gmane.org/gmane.comp.lang.haskell.cafe/57640 21. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bamse 22. http://article.gmane.org/gmane.comp.lang.haskell.general/17142 23. http://haskell.org/haskellwiki/Dutch_HUG 24. http://article.gmane.org/gmane.comp.lang.haskell.general/17140 25. http://www.easychair.org/conferences/?conf=haskell09 26. http://article.gmane.org/gmane.comp.lang.haskell.general/17132 27. http://article.gmane.org/gmane.comp.lang.haskell.general/17133 28. http://article.gmane.org/gmane.comp.lang.haskell.general/17134 29. http://article.gmane.org/gmane.comp.lang.haskell.general/17135 30. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/OpenGL 31. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/GLUT 32. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/OpenAL 33. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ALUT 34. http://article.gmane.org/gmane.comp.lang.haskell.general/17120 35. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/control%2Dmonad%2Dexception 36. http://www.haskell.org//pipermail/haskell/2009-April/021271.html 37. http://code.haskell.org/haskellfm 38. http://www.haskell.org//pipermail/haskell/2009-April/021284.html 39. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/uu%2Dparsinglib 40. http://www.haskell.org//pipermail/haskell/2009-May/021293.html 41. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Takusen 42. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/57810 43. http://socghop.appspot.com/student_project/show/google/gsoc2009/haskell/t124022468245 44. http://planet.haskell.org/ 45. http://haskell.org/haskellwiki/Blog_articles 46. http://www.serpentine.com/blog/2009/05/01/slides-from-my-erlang-factory-talk-this-morning/ 47. http://blog.patch-tag.com/2009/05/01/what-to-do-when-cabal-install-works-in-one-environment-but-not-another/ 48. http://blog.downstairspeople.org/2009/04/29/ann-priority-sync/ 49. http://blog.well-typed.com/2009/04/hello-world-now-only-11k-using-ghc-with-shared-libs/ 50. http://ghcmutterings.wordpress.com/2009/04/28/the-new-ghc-build-system-is-here/ 51. http://blog.well-typed.com/2009/04/first-round-of-ihg-development-work/ 52. http://www.londonhug.net/2009/04/27/dons-slides/ 53. http://www.galois.com/blog/2009/04/27/engineering-large-projects-in-haskell-a-decade-of-fp-at-galois/ 54. http://jpmoresmau.blogspot.com/2009/04/haskell-rpg-game-uploaded-on-hackage.html 55. http://holumbus.fh-wedel.de/blog/?p=22 56. http://nibrofun.blogspot.com/2009/04/gsoc09-haskell-src-exts-haskell-src.html 57. http://bonsaicode.wordpress.com/2009/04/27/forcing-evaluation-in-haskell/ 58. http://blog.tupil.com/building-commercial-haskell-applications/ 59. http://blog.lab49.com/archives/3027 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 nowgate at yahoo.com Sat May 2 14:54:21 2009 From: nowgate at yahoo.com (michael rice) Date: Sat May 2 14:40:14 2009 Subject: [Haskell-cafe] Generating random enums Message-ID: <746506.11371.qm@web31105.mail.mud.yahoo.com> I intuited that that's what the problem was. Thanks, Michael --- On Sat, 5/2/09, Rahul Kapoor wrote: From: Rahul Kapoor Subject: Re: [Haskell-cafe] Generating random enums To: "michael rice" Cc: "John Van Enk" , haskell-cafe@haskell.org Date: Saturday, May 2, 2009, 2:00 PM > OK, I think what you're saying is to work with (random) integers and use > fromEnum and toEnum to get corresponding DayOfWeek. But I get this when I > try to use toEnum: > > *Main> toEnum 2 ghci does not know what type of enum you want to create from the number 2. Try: toEnum 2 :: DayOfWeek That said, I would expect "toEnum 2" to give an error like: 'Ambiguous type variable `a'....'. So I am not sure why your error message says: '** Exception: Prelude.Enum.().toEnum: bad argument' -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090502/29b0c9ea/attachment.htm From daniel.is.fischer at web.de Sat May 2 14:59:42 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat May 2 14:45:50 2009 Subject: [Haskell-cafe] Generating random enums In-Reply-To: References: <515911.18381.qm@web31103.mail.mud.yahoo.com> Message-ID: <200905022059.42757.daniel.is.fischer@web.de> Am Samstag 02 Mai 2009 20:00:54 schrieb Rahul Kapoor: > > OK, I think what you're saying is to work with (random) integers and use > > fromEnum and toEnum to get corresponding DayOfWeek. But I get this when I > > try to use toEnum: > > > > *Main> toEnum 2 > > ghci does not know what type of enum you want to create from the number 2. > Try: toEnum 2 :: DayOfWeek > > That said, I would expect "toEnum 2" to give an error like: 'Ambiguous > type variable `a'....'. So I am not sure why your error message says: > '** Exception: Prelude.Enum.().toEnum: bad argument' Defaulting. If ghci doesn't know which type (let's call it a) is demanded, it looks at the constraints (here Enum a) and tries to choose a type from its default list that satisfies the constraints. AFAIK, the default list is (), Integer, Double. () satisfies the constraint, so ghci chooses that. fromEnum () is 0, so 0 is the only acceptable argument for toEnum :: Int -> (). It's a two-edged sword, if ghci didn't default, it would have to issue a *lot* of ambiguous type messages and you would have to give a type signature to most expressions you type at the prompt, with the defaulting, you get pretty unintuitive error messages when it does the wrong thing. From duane.johnson at gmail.com Sat May 2 15:00:23 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Sat May 2 14:46:09 2009 Subject: [Haskell-cafe] ANN: Silkworm game Message-ID: <98A96C9E-6685-4512-AB3B-50E3A1F39E91@gmail.com> Reprinted from my blog post [1]: === The semester is over, my final project was a success (at least in that I passed the class) and it?s time now to release the game I made for Graphics 455: Silkworm! This is my first full application in Haskell. The process has been an enlarging experience?I?ve come to really enjoy the mental work that goes into thinking about a program in a functional way. I highly recommend the challenge to other software engineers. Silkworm combines the Hipmunk binding to Chipmunk 2D Game Dynamics with OpenGL, and GLFW (an alternative to GLUT). It?s built to work on Mac OS X, but it uses cross-platform libraries so it should be fairly easy to port to other platforms. The source code is here [2] and below are some screenshots [1] -- Duane Johnson (canadaduane) === [1] http://blog.inquirylabs.com/2009/05/02/silkworm-game-written-in-haskell/ [2] http://inquirylabs.com/downloads/Silkworm.tgz From ketil at malde.org Sat May 2 15:22:26 2009 From: ketil at malde.org (Ketil Malde) Date: Sat May 2 15:07:26 2009 Subject: [Haskell-cafe] Generating random enums In-Reply-To: (Rahul Kapoor's message of "Sat\, 2 May 2009 14\:00\:54 -0400") References: <515911.18381.qm@web31103.mail.mud.yahoo.com> Message-ID: <87skjncnt9.fsf@malde.org> Rahul Kapoor writes: >> *Main> toEnum 2 > > ghci does not know what type of enum you want to create from the number 2. > Try: toEnum 2 :: DayOfWeek > > That said, I would expect "toEnum 2" to give an error like: 'Ambiguous > type variable `a'....'. So I am not sure why your error message says: > '** Exception: Prelude.Enum.().toEnum: bad argument' Wild guess: The dread monomorphism restriction uses () as a reasonable type, and it only has one element. Does 'toEnum 0' give '()' as the result? (I couldn't reproduce it with my version of GHCi - I get the ambigous type error message) -k -- If I haven't seen further, it is by standing in the footprints of giants From heringtonlacey at mindspring.com Sat May 2 15:26:51 2009 From: heringtonlacey at mindspring.com (Dean Herington) Date: Sat May 2 15:13:12 2009 Subject: [Haskell-cafe] using haskell for a project In-Reply-To: <20090502171755.GA2939@valhala.gaia.loc> References: <20090502171755.GA2939@valhala.gaia.loc> Message-ID: At 7:17 PM +0200 5/2/09, Nicolas Martyanoff wrote: >Content-Type: multipart/signed; micalg=pgp-sha1; > protocol="application/pgp-signature"; boundary="ibTvN161/egqYuK8" >Content-Disposition: inline > >Hi, > >I don't think I already presented myself; I'm Nicolas, a 23y french >student, trying to learn and use haskell. > >I've been using C for years, for all sort of tasks, and am quite >comfortable with it. I'm also using it 40h a week in my internship for >network systems, so I kind of know how to use it. > >I discovered Haskell some monthes ago, bought `Real World Haskell', >quickly read, and enjoyed it. > >So now I'd want to use it for a small project of mine, a simple >multiplayer roguelike based on telnet. I wrote a minimal server in C, and >it took me a few hours. Now I'm thinking about doing the same in Haskell, >and I'm in trouble. > >I don't really know how to map my ideas in haskell code. For example, a >character can cast spells, so I'd have something like this in C: > > struct hashtable spells; > > struct character { > int n_spells; > struct spell **spells; > }; > >I thought I could do something like this in haskell: > > spells = Data.Map.Map Int Spell > > data Character = Character { charSpells :: [Int] } > >But now I don't know how to dynamically add new spells (new spells can be >created in my gameplay). Since I can't assign a new value to the `spells' >variable (Data.Map.insert returns a new map), I just don't know where to >go. > >I have the same problem for a bout every problem. I love writing pure >functions in haskell, but as soon as I try to write some code involving >states or side effects, I can't write a line. > >I just wanted a 2d array to store a zone, for example, dead simple in C, >but this kind of link >http://greenokapi.net/blog/2009/03/10/rough-grids-in-haskell make me >shiver. > >Point is, I'd like to use haskell, but I don't know how, it seems totally >alien. > >How did you manage to change the way you map ideas to code, from >imperative to pure functional ? > >Thank you. > >Regards, > >-- >Nicolas Martyanoff > http://codemore.org > khaelin@gmail.com Nicolas, First, bienvenue ? Haskell ! Learning it will stretch your mind; it may be rocky at times, but it will be rewarding. You've quickly come upon a key difference between imperative and functional programming. State management in Haskell is more explicit, which is a double-edged sword. It requires greater discipline and mechanism, but provides greater control and security. In your example program you could manage your state with a State monad. Assuming you'll want to be able to do I/O, you'll probably want to combine State with IO. For starters, something like: > import Control.Monad.State > import qualified Data.Map as M > > data Spell = ... > data Character = Character { charName :: String, charSpells :: [Spell], ... } > data MyState = MyState { characters :: M.Map String Character, ... } > initialState = MyState { characters = M.empty, ... } > > type MyMonad = StateT MyState IO > > addSpellForCharacter :: String -> Spell -> MyMonad () > addSpellForCharacter name spell = do > state <- get > let chars = characters state > case M.lookup name chars of > Just char -> let char' = char { >charSpells = spell : charSpells char } > state' = state { >characters = M.insert name char' chars } > in put state' > Nothing -> ... -- leave these issues for another time > > main = do > ... > finalState <- execStateT game initialState > ... > > game :: MyMonad () > game = do > ... > addSpellForCharacter ... > liftIO $ putStrLn "Added spell ..." > ... Dean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090502/4cc143a3/attachment.htm From dons at galois.com Sat May 2 15:41:14 2009 From: dons at galois.com (Don Stewart) Date: Sat May 2 15:28:15 2009 Subject: [Haskell-cafe] ANN: Silkworm game In-Reply-To: <98A96C9E-6685-4512-AB3B-50E3A1F39E91@gmail.com> References: <98A96C9E-6685-4512-AB3B-50E3A1F39E91@gmail.com> Message-ID: <20090502194114.GC6651@whirlpool.galois.com> Excellent work! Time to upload to hackage?? -- Don duane.johnson: > Reprinted from my blog post [1]: > > === > > The semester is over, my final project was a success (at least in that I > passed the class) and it?s time now to release the game I made for > Graphics 455: Silkworm! > > This is my first full application in Haskell. The process has been an > enlarging experience?I?ve come to really enjoy the mental work that goes > into thinking about a program in a functional way. I highly recommend > the challenge to other software engineers. > > Silkworm combines the Hipmunk binding to Chipmunk 2D Game Dynamics with > OpenGL, and GLFW (an alternative to GLUT). > > It?s built to work on Mac OS X, but it uses cross-platform libraries so > it should be fairly easy to port to other platforms. The source code is > here [2] and below are some screenshots [1] > > -- Duane Johnson > (canadaduane) > > === > > [1] http://blog.inquirylabs.com/2009/05/02/silkworm-game-written-in-haskell/ > [2] http://inquirylabs.com/downloads/Silkworm.tgz_______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From daniel.is.fischer at web.de Sat May 2 16:37:49 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat May 2 16:25:42 2009 Subject: [Haskell-cafe] Generating random enums In-Reply-To: <87skjncnt9.fsf@malde.org> References: <515911.18381.qm@web31103.mail.mud.yahoo.com> <87skjncnt9.fsf@malde.org> Message-ID: <200905022237.49343.daniel.is.fischer@web.de> Am Samstag 02 Mai 2009 21:22:26 schrieb Ketil Malde: > Rahul Kapoor writes: > >> *Main> toEnum 2 > > > > ghci does not know what type of enum you want to create from the number > > 2. Try: toEnum 2 :: DayOfWeek > > > > That said, I would expect "toEnum 2" to give an error like: 'Ambiguous > > type variable `a'....'. So I am not sure why your error message says: > > '** Exception: Prelude.Enum.().toEnum: bad argument' > > Wild guess: The dread monomorphism restriction uses () as a reasonable > type, and it only has one element. Does 'toEnum 0' give '()' as the > result? Actually, it seems to be the other way round here: Prelude> toEnum 2 :1:0: Ambiguous type variable `a' in the constraint: `Enum a' arising from a use of `toEnum' at :1:0-7 Probable fix: add a type signature that fixes these type variable(s) Prelude> :set -fno-monomorphism-restriction : Warning: -fno-monomorphism-restriction is deprecated: use -XNoMonomorphismRestriction or pragma {-# LANGUAGE NoMonomorphismRestriction#-} instead Prelude> toEnum 2 *** Exception: Prelude.Enum.().toEnum: bad argument > > (I couldn't reproduce it with my version of GHCi - I get the ambigous > type error message) > > -k From felipe.lessa at gmail.com Sat May 2 16:44:22 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat May 2 16:31:05 2009 Subject: [Haskell-cafe] ANN: Silkworm game In-Reply-To: <98A96C9E-6685-4512-AB3B-50E3A1F39E91@gmail.com> References: <98A96C9E-6685-4512-AB3B-50E3A1F39E91@gmail.com> Message-ID: <20090502204422.GA30959@kira.casa> Hi! On Sat, May 02, 2009 at 01:00:23PM -0600, Duane Johnson wrote: > Silkworm combines the Hipmunk binding to Chipmunk 2D Game > Dynamics with OpenGL, and GLFW (an alternative to GLUT). It's great to see Hipmunk being useful to someone :). I've written the binding to turn some of my ideas into code but I've never finished any of them. -- Felipe. From bugfact at gmail.com Sat May 2 17:33:02 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sat May 2 17:20:47 2009 Subject: [Haskell-cafe] ANN: Silkworm game In-Reply-To: <98A96C9E-6685-4512-AB3B-50E3A1F39E91@gmail.com> References: <98A96C9E-6685-4512-AB3B-50E3A1F39E91@gmail.com> Message-ID: Congratulations!!! It is actually a fun game to play too :-) On Sat, May 2, 2009 at 9:00 PM, Duane Johnson wrote: > Reprinted from my blog post [1]: > > === > > The semester is over, my final project was a success (at least in that I > passed the class) and it?s time now to release the game I made for Graphics > 455: Silkworm! > > This is my first full application in Haskell. The process has been an > enlarging experience?I?ve come to really enjoy the mental work that goes > into thinking about a program in a functional way. I highly recommend the > challenge to other software engineers. > > Silkworm combines the Hipmunk binding to Chipmunk 2D Game Dynamics with > OpenGL, and GLFW (an alternative to GLUT). > > It?s built to work on Mac OS X, but it uses cross-platform libraries so it > should be fairly easy to port to other platforms. The source code is here > [2] and below are some screenshots [1] > > -- Duane Johnson > (canadaduane) > > === > > [1] > http://blog.inquirylabs.com/2009/05/02/silkworm-game-written-in-haskell/ > [2] > http://inquirylabs.com/downloads/Silkworm.tgz_______________________________________________ > 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/20090502/c83ee474/attachment.htm From sebastian.sylvan at gmail.com Sat May 2 17:46:01 2009 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Sat May 2 17:32:42 2009 Subject: [Haskell-cafe] using haskell for a project In-Reply-To: <20090502171755.GA2939@valhala.gaia.loc> References: <20090502171755.GA2939@valhala.gaia.loc> Message-ID: <3d96ac180905021446y689f216dta1caa7b6d40bde51@mail.gmail.com> On Sat, May 2, 2009 at 6:17 PM, Nicolas Martyanoff wrote: > Hi, > > I don't think I already presented myself; I'm Nicolas, a 23y french > student, trying to learn and use haskell. > > I've been using C for years, for all sort of tasks, and am quite > comfortable with it. I'm also using it 40h a week in my internship for > network systems, so I kind of know how to use it. > > I discovered Haskell some monthes ago, bought `Real World Haskell', > quickly read, and enjoyed it. > > So now I'd want to use it for a small project of mine, a simple > multiplayer roguelike based on telnet. I wrote a minimal server in C, and > it took me a few hours. Now I'm thinking about doing the same in Haskell, > and I'm in trouble. > > I don't really know how to map my ideas in haskell code. For example, a > character can cast spells, so I'd have something like this in C: > > struct hashtable spells; > > struct character { > int n_spells; > struct spell **spells; > }; > > I thought I could do something like this in haskell: > > spells = Data.Map.Map Int Spell > > data Character = Character { charSpells :: [Int] } > > But now I don't know how to dynamically add new spells (new spells can be > created in my gameplay). Since I can't assign a new value to the `spells' > variable (Data.Map.insert returns a new map), I just don't know where to > go. I'm not sure I understand how your C version and Haskell version are similar? Wouldn't the character just have a list of Spells (since this is what the C version seems to do)? That global spells variable should probably be put in some sort of "game state" data type that encapsulates the game world. Then consider writing updates as a function that takes the old value, and produces a new value. Indeed, consider letting the following function be your main "update" for the game state. gameTick :: Time -> PlayerInput -> GameState -> GameState That function would update all parts of your game state, and if you want to change some property of a character, you simply compute a new character from the old one with the field you want to change updated. Because values are immutable, any data you don't touch will just refer to the old stuff so it's actually quite efficient. You main loop could then be something like: gameLoop oldTime gameState = do time <- getTime let dt = time - oldTime input <- processInput gameState gsNew <- gameTick dt input gameState renderGame gsNew gameLoop time gsNew > > I just wanted a 2d array to store a zone, for example, dead simple in C, > but this kind of link > http://greenokapi.net/blog/2009/03/10/rough-grids-in-haskell make me > shiver. Try a list of lists, or better yet just an Array. Make sure you update the grid "in bulk" though, as modifying just a single element at a time is slow with immutable arrays. > Point is, I'd like to use haskell, but I don't know how, it seems totally > alien. > > How did you manage to change the way you map ideas to code, from > imperative to pure functional ? Massive brain-rewiring. Keep at it, don't think in terms of modifying state, think of it as computing new values from old values. I find that the payoff of learning to think ,like this is massive, as it's usually much easier to reason about. If you really do lots of "state" in a program, consider using a state monad like someone else already mentioned, but honestly I'd try to stay away from it and stick to a more "functional" style as far as possible. -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090502/4f82795f/attachment.htm From lane at downstairspeople.org Sat May 2 18:07:19 2009 From: lane at downstairspeople.org (Christopher Lane Hinson) Date: Sat May 2 17:54:02 2009 Subject: [Haskell-cafe] Re: [HOpenGL] Decoupling OpenAL/ALUT packages from OpenGL In-Reply-To: <200905021914.13307.Sven.Panne@aedion.de> References: <200905021914.13307.Sven.Panne@aedion.de> Message-ID: > * OpenAL uses OpenGL's notion of StateVars all over the place. I've thought that this would be an appropriate package in it's own right. It may be small and simple but it captures and generalizes a frequently needed concept. As for the other two, I don't know that anything besides GL/AL would benefit from them, so they might go in the OpenGL-DataTypes mentioned previously. Friendly, --Lane From barsoap at web.de Sat May 2 18:17:22 2009 From: barsoap at web.de (Achim Schneider) Date: Sat May 2 18:03:46 2009 Subject: [Haskell-cafe] Re: gcd References: <20090118204519.320AF32465D@www.haskell.org> <1241229917.3721.3.camel@host.localdomain> Message-ID: <20090503001722.4a253bce@solaris> Steve wrote: > "It is useful to define gcd(0, 0) = 0 and lcm(0, 0) = 0 because then > the natural numbers become a complete distributive lattice with gcd > as meet and lcm as join operation. This extension of the definition > is also compatible with the generalization for commutative rings > given below." > Ouch. Speak of mathematicians annoying programmers by claiming that 0 isn't divisible by any of [1..], and further implying that 0 is bigger than all of those, not to mention justifying all that with long words. Damn them buggers. -- (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 Sat May 2 18:23:06 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sat May 2 18:09:01 2009 Subject: [Haskell-cafe] Decoupling OpenAL/ALUT packages from OpenGL In-Reply-To: <200905021914.13307.Sven.Panne@aedion.de> References: <200905021914.13307.Sven.Panne@aedion.de> Message-ID: I think splitting this up is a good thing, and at first sight I thought it was overkill to make 3 micro packages, but when thinking twice I believe it is indeed the way to go: - Having StateVar into its own module will hopefully promote its reuse by other imperative wrapper libs which currently all have their own custom code. - I usually tend to rewrite my own strict vectors but I would prefer to reuse the ones defined in OpenGL, so definitely these should go into a package. It would also be nice to have another package that makes Data.VectorSpace instances for each of these types. I have no idea about a good package name :( - I'm not sure about the ObjectName package, but it certainly does not belong in any of the previous two packages, so it should go into another package. On Sat, May 2, 2009 at 7:14 PM, Sven Panne wrote: > I'd like to get some feedback from the Haskell community about some > packaging > issues, so here is my problem: As a medium-term goal, I'd like to decouple > the > OpenAL/ALUT packages from the OpenGL package, because there are very > sensible > use cases where you might need some sound, but not OpenGL. The current > coupling has mostly historic reasons. > > The OpenAL package depends on the OpenGL package in 3 areas: > > * OpenAL uses OpenGL's notion of StateVars all over the place. > > * OpenAL's Buffer and Source are instances of OpenGL's ObjectName class. > > * OpenAL's sources and listeners have some properties like velocity, > orientation, direction and position which are modeled by OpenGL's Vector3 > and > Vertex3 data types. > > The ALUT package depends on the OpenGL package because of > GettableStateVars. > > The packages are supposed to fit nicely together, so using the same types > is a > must, but the actual packaging is not nice. So the obvious idea is to > introduce 3 new packages which lift out functionality from the OpenGL > package: > > * a small "StateVar" package, consisting only of OpenGL's StateVar module > (in a better place in the name hierarchy, of course, perhaps > "Data.StateVar"?) > > * a tiny "ObjectName" package, consisting only of OpenGL's ObjectName > class > (In "Data.ObjectName"? I'm not very sure about a good place in the > hierarchy > here.) > > * a package containing most of the data types/newtypes in OpenGL's > VertexSpec module (Vertex{2,3,4}, Color{3,4}, etc.) plus instances for the > base classes like Eq, Ord, Show, etc. I really don't know a good name for > this > package and what a good place in the hierarchy would be (probably something > like "Data.Foo", but what is Foo?) > > The point is: The first two package would be very small. Would this be OK? > Does anybody see other alternatives? What would be good names for those > packages and where in the naming hierarchy should they really go? > > Cheers, > S. > _______________________________________________ > 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/20090503/65b1dbaf/attachment.htm From uhollerbach at gmail.com Sat May 2 18:32:53 2009 From: uhollerbach at gmail.com (Uwe Hollerbach) Date: Sat May 2 18:18:43 2009 Subject: [Haskell-cafe] Runge-Kutta and architectural style In-Reply-To: References: Message-ID: <65d7a7e0905021532u598087f5p5f017cc4d7e178c@mail.gmail.com> Hi, Richard, these are interesting suggestions, I may explore them a bit. I tried initially to make something that would be usable without too much pain for small-to-medium problem, and that could be used, albeit with a performance hit, for a larger problem; but I'm sure I am nowhere near what could be achieved for a larger problem. On the other hand, it's quite possible that evaluation of the derivative function would dominate, so that the time spent in the actual RK code would be negligible; in that case, this might already be as good as it needs to be. Purely for my own interest, I doubt whether I'll make this public unless someone specifically asks, I'm playing with a code generator from this, that will try to generate good code from these tables -- but it's C code so far, not haskell. This isn't really a practical thing, if I needed the ultimate C routine, it would have already been faster and simpler to just write it directly instead of the code-generation stuff I've been doing, but hey... Uwe On 4/26/09, Richard O'Keefe wrote: > I was interested to see a Runge-Kutta package > posted to this list recently, particularly as > I have a fairly simple-minded non-adaptive RK > "generator": an AWK script that takes a table > and some optional stuff and spits out C. The > Haskell package is, of course, a lot prettier > than my AWK program, as well as offering some > adaptive methods, which is important. > > We can imagine a spectrum of RK packages: > > (1) Higher order function taking some runtime > parameters. That's what we got. > > (2) The same specialised for a known table at > compile time. Doable using the code that > we were given plus SPECIALIZE pragmas. I > don't how well that works across modules. > > (3) A generator that writes Haskell source. > > (4) Template Haskell. > > (5) A generator that generates native code to > be called through FFI. > > The question is, how do you decide what's the > appropriate approach? > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From Tillmann.Vogt at rwth-aachen.de Sat May 2 18:56:00 2009 From: Tillmann.Vogt at rwth-aachen.de (Tillmann Vogt) Date: Sat May 2 18:43:07 2009 Subject: [Haskell-cafe] Decoupling OpenAL/ALUT packages from OpenGL In-Reply-To: References: Message-ID: <49FCCF80.3080600@rwth-aachen.de> Sven Panne schrieb: > > * a tiny "ObjectName" package, consisting only of OpenGL's ObjectName class > (In "Data.ObjectName"? I'm not very sure about a good place in the hierarchy > here.) How about Data.GraphicsObjects ? > > * a package containing most of the data types/newtypes in OpenGL's > VertexSpec module (Vertex{2,3,4}, Color{3,4}, etc.) plus instances for the > base classes like Eq, Ord, Show, etc. I really don't know a good name for this > package and what a good place in the hierarchy would be (probably something > like "Data.Foo", but what is Foo?) Now that you mention it. I just looked through haskell hierachical libraries and there seems to be no standard data types for vector math. Am I getting something wrong or is every library that is using linear algebra stuff using its own data types? So if I use a numeric library for matrices inside HOpenGL I have to convert around? I think it would be nice to have data types and functions for dot produkt, scalar product, norms, ... together with HOpenGL types. Currently I am trying to embed a triangulation library from a ten year old diploma thesis (http://www.dinkla.net/fp/cglib.html) in my libary (I know that glu has tesselation). The author has developed a quite big and abstract type structure for all sorts of computer graphics algorithms and I didn't wanted to copy this into my library just for triangulation. But it is reasonable. It could be combined with HOpenGL types to maybe Data.VectorMath or Data.LinearAlgebra . I would favour the second. > > The point is: The first two package would be very small. Would this be OK? > Does anybody see other alternatives? What would be good names for those > packages and where in the naming hierarchy should they really go? > > Cheers, > S. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From duane.johnson at gmail.com Sat May 2 18:59:43 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Sat May 2 18:45:33 2009 Subject: [Haskell-cafe] ANN: Silkworm game In-Reply-To: <20090502204422.GA30959@kira.casa> References: <98A96C9E-6685-4512-AB3B-50E3A1F39E91@gmail.com> <20090502204422.GA30959@kira.casa> Message-ID: <885BD9EF-3D38-43A1-A056-F30C1914B560@gmail.com> Thanks, Felipe! Indeed, it was a wonderful surprise to see a 2D physics engine binding for Haskell. It made it possible for me to choose Haskell as my implementation language. I'm very grateful for that. I wish you luck (and time!) in implementing your ideas :) Regards, Duane On May 2, 2009, at 2:44 PM, Felipe Lessa wrote: > Hi! > > On Sat, May 02, 2009 at 01:00:23PM -0600, Duane Johnson wrote: >> Silkworm combines the Hipmunk binding to Chipmunk 2D Game >> Dynamics with OpenGL, and GLFW (an alternative to GLUT). > > It's great to see Hipmunk being useful to someone :). I've > written the binding to turn some of my ideas into code but I've > never finished any of them. > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From dons at galois.com Sat May 2 20:07:08 2009 From: dons at galois.com (Don Stewart) Date: Sat May 2 19:54:20 2009 Subject: [Haskell-cafe] ANN: Silkworm game In-Reply-To: References: <98A96C9E-6685-4512-AB3B-50E3A1F39E91@gmail.com> Message-ID: <20090503000708.GD6893@whirlpool.galois.com> Yes, it is quite fun. I think it should be using cabal's datadir from Paths_silkworm.hs to install (and find) the resources. Yell if you can't figure out how to do that. (xmonad has an example) -- Don bugfact: > Congratulations!!! It is actually a fun game to play too :-) > > On Sat, May 2, 2009 at 9:00 PM, Duane Johnson wrote: > > Reprinted from my blog post [1]: > > === > > The semester is over, my final project was a success (at least in that I > passed the class) and it s time now to release the game I made for Graphics > 455: Silkworm! > > This is my first full application in Haskell. The process has been an > enlarging experience I ve come to really enjoy the mental work that goes > into thinking about a program in a functional way. I highly recommend the > challenge to other software engineers. > > Silkworm combines the Hipmunk binding to Chipmunk 2D Game Dynamics with > OpenGL, and GLFW (an alternative to GLUT). > > It s built to work on Mac OS X, but it uses cross-platform libraries so it > should be fairly easy to port to other platforms. The source code is here > [2] and below are some screenshots [1] > > -- Duane Johnson > (canadaduane) > > === > > [1] http://blog.inquirylabs.com/2009/05/02/silkworm-game-written-in-haskell > / > [2] http://inquirylabs.com/downloads/ > Silkworm.tgz_______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jason.dusek at gmail.com Sat May 2 20:32:15 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Sat May 2 20:18:36 2009 Subject: [Haskell-cafe] Array Binary IO & molecular simulation In-Reply-To: <742701241274171@webmail37.yandex.ru> References: <251001241158007@webmail128.yandex.ru> <42784f260905020212l2122cbdu876daf0a430a199d@mail.gmail.com> <220e47b40905020259r2ad1ce24k5cc5df55760730c7@mail.gmail.com> <42784f260905020416p5b2190e0u75ea80ece8a19498@mail.gmail.com> <742701241274171@webmail37.yandex.ru> Message-ID: <42784f260905021732l309f922dm8b196463f2e5f04c@mail.gmail.com> 2009/05/02 Grigory Sarnitskiy : > 2009/05/02 Jason Dusek : >> The original poster should try serializing a tuple of arrays >> instead of serializing each array individually. > > Maybe, but I have some doubts.?I have to operate with > thousands of arrays --- are tuples good in such case? No, they can be only 17 elements long. Then you need lists of arrays, I guess. > Moreover it is desirable to write data as it is calculated to > be sure it wont be lost... Would it be too much trouble to write to separate files? -- Jason Dusek From dbueno at gmail.com Sat May 2 21:38:33 2009 From: dbueno at gmail.com (Denis Bueno) Date: Sat May 2 21:24:47 2009 Subject: [Haskell-cafe] Dynamically altering sort order In-Reply-To: <7fb8f82f0904241849h430113f5mba2c7e73d2eff09d@mail.gmail.com> References: <6dbd4d000904241411i2cb2d657h7dd10b71b73567fa@mail.gmail.com> <7fb8f82f0904241849h430113f5mba2c7e73d2eff09d@mail.gmail.com> Message-ID: <6dbd4d000905021838n2b8758b8w1c273592d14d27c4@mail.gmail.com> On Fri, Apr 24, 2009 at 19:49, Edward Kmett wrote: > On Fri, Apr 24, 2009 at 5:11 PM, Denis Bueno wrote: >> Is there an Ord instance that can be dynamically changed in this way? >> >> My first idea is something like this: >> >> ? ?data CompareRecord = CR{ rCompare :: Record -> Record -> Ordering, >> unCR :: Record } >> ? ?instance Ord CompareRecord where >> ? ? ? ?compare (CR cmp x) (CR _ y) = cmp x y >> >> where the rCompare field would be a function that is based on the >> flags passed to the command-line problem. ?But this has an ugly >> asymmetry. ?Does anyone have any other ideas? > > You can make a safer 'CompareRecord' using 'reflection' from hackage: This is what I ended up doing and it worked out great. Thanks for the suggestion. Denis From nowgate at yahoo.com Sat May 2 21:52:03 2009 From: nowgate at yahoo.com (michael rice) Date: Sat May 2 21:39:03 2009 Subject: [Haskell-cafe] Combining computations Message-ID: <671548.30261.qm@web31102.mail.mud.yahoo.com> If you look at this stuff long enough it almost begins to make sense. Maybe. ;-) I've been messing around with MonadPlus and I understand its usage with the Maybe and List monads. Since one use of Monads is combining computations, how can I combine a Maybe with a List? let m1 = Nothing let m2 = [1] let m3 = m1 `mplus` m2? ==> [1]??? --if the Maybe is Nothing, do nothing? let m1 = Just 1 let m2 = [] let m3 = m1 `mplus` m2? ==> [1]? --if the Maybe is not Nothing, add it to the list Or am I misunderstanding combining computations? Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090502/eeb9bf93/attachment.htm From daniel.is.fischer at web.de Sat May 2 22:34:44 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat May 2 22:22:29 2009 Subject: [Haskell-cafe] Re: gcd In-Reply-To: <20090503001722.4a253bce@solaris> References: <20090118204519.320AF32465D@www.haskell.org> <1241229917.3721.3.camel@host.localdomain> <20090503001722.4a253bce@solaris> Message-ID: <200905030434.45003.daniel.is.fischer@web.de> Am Sonntag 03 Mai 2009 00:17:22 schrieb Achim Schneider: > Steve wrote: > > "It is useful to define gcd(0, 0) = 0 and lcm(0, 0) = 0 because then > > the natural numbers become a complete distributive lattice with gcd > > as meet and lcm as join operation. This extension of the definition > > is also compatible with the generalization for commutative rings > > given below." > > Ouch. Speak of mathematicians annoying programmers by claiming that 0 > isn't divisible by any of [1..], Beg pardon? 0 is divisible by all of them. And while we're talking about rings, 0 is also divisible by 0. > and further implying that 0 is bigger > than all of those, 'Tis, in the divisibility preorder :) > not to mention justifying all that with long words. Sorry for the long words, but having gcd 0 0 == lcm 0 0 == 0 is the sensible thing and having it differently in Haskell is a bad mistake (IMO). > > Damn them buggers. From lrpalmer at gmail.com Sat May 2 22:56:56 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Sat May 2 22:43:27 2009 Subject: [Haskell-cafe] Re: gcd In-Reply-To: <20090503001722.4a253bce@solaris> References: <20090118204519.320AF32465D@www.haskell.org> <1241229917.3721.3.camel@host.localdomain> <20090503001722.4a253bce@solaris> Message-ID: <7ca3f0160905021956s57f97436s391db468bb09f1b@mail.gmail.com> On Sat, May 2, 2009 at 4:17 PM, Achim Schneider wrote: > Steve wrote: > > > "It is useful to define gcd(0, 0) = 0 and lcm(0, 0) = 0 because then > > the natural numbers become a complete distributive lattice with gcd > > as meet and lcm as join operation. This extension of the definition > > is also compatible with the generalization for commutative rings > > given below." > > > Ouch. Speak of mathematicians annoying programmers by claiming that 0 > isn't divisible by any of [1..], and further implying that 0 is bigger > than all of those, not to mention justifying all that with long words. > > Damn them buggers. 0 is divisible by everything. It's "bigger" than all of them with respect to divisibility, not size. Which you may have known. Your irony was too complex for me :-p Lukk -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090502/fa3a464a/attachment.htm From nowgate at yahoo.com Sat May 2 23:26:22 2009 From: nowgate at yahoo.com (michael rice) Date: Sat May 2 23:12:38 2009 Subject: [Haskell-cafe] Combining computations Message-ID: <169272.11504.qm@web31106.mail.mud.yahoo.com> I posted something similar about an hour ago but it seems to have gotten lost. Very strange. I've read that Monads can combine computations. Can a Maybe monad be combined with a List monad such that Nothing `mplus` [] ==> [] Just 1 `mplus` [] ==> [1] If not, can someone supply a simple example of combining computations? Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090502/f0e9d420/attachment.htm From lambda-belka at yandex.ru Sun May 3 00:57:04 2009 From: lambda-belka at yandex.ru (Belka) Date: Sun May 3 00:43:46 2009 Subject: [Haskell-cafe] using haskell for a project In-Reply-To: <20090502171755.GA2939@valhala.gaia.loc> References: <20090502171755.GA2939@valhala.gaia.loc> Message-ID: <23352598.post@talk.nabble.com> Welcome to Haskell! =) > But now I don't know how to dynamically add new spells (new spells can be > created in my gameplay). Since I can't assign a new value to the `spells' > variable (Data.Map.insert returns a new map), I just don't know where to > go. Do distinguish *pure function* concept and *action with side effects* concept. The default in FP (Funct. Progr.) paradigm usualy is *pure function*, if *action with side effects* is avoidable. Pure functions deal with immutable memory "objects". So in your case, whenever you add a new spell, you get a new character (since your chacter's "essence" is a spell list). That way after calculating *addNewSpell* you will have 2 versions of character: a new one (with spells list bigger), an the original one. Since old one usualy drop out of the scope (while program evaluation progresses) it gets *garbage collected* (note: garbage collection showed up in FP already in 1960s). addNewSpell :: Character -> Spell -> Character addNewSpell char_old_version spell_to_add = ... main = let char_new_version = addNewSpell char_old_version new_spell in putStrLn $ show char_new_version where char_old_version = Charcter {...} new_spell = Spell { .... } Have luck, with the brain rewriting! =) Belka -- View this message in context: http://www.nabble.com/using-haskell-for-a-project-tp23348425p23352598.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From nbloomf at gmail.com Sun May 3 02:35:04 2009 From: nbloomf at gmail.com (Nathan Bloomfield) Date: Sun May 3 02:24:50 2009 Subject: [Haskell-cafe] Re: gcd In-Reply-To: <20090503001722.4a253bce@solaris> References: <20090118204519.320AF32465D@www.haskell.org> <1241229917.3721.3.camel@host.localdomain> <20090503001722.4a253bce@solaris> Message-ID: <9858b5620905022335gbf68a6ch7397468f97f8ed63@mail.gmail.com> Having gcd(0,0) = 0 doesn't mean that 0 is not divisible by any other natural number. On the contrary, any natural trivially divides 0 since n*0 = 0. Perhaps the disagreement is over what is meant by "greatest". The "greatest" in gcd is not w.r.t. the canonical ordering on the naturals; rather w.r.t. the partial order given by the divides relation. Similarly for the "least" in lcm. Suppose gcd(0,0) = a. Then a|0, and if b|0 then b|a. (That's what it means to be the gcd.) So what is a? Since every natural number divides zero, a must be divisible by every natural number. The only natural number with this property is 0, which can be proved using the essential uniqueness of prime factorizations and infinitude of primes. So having gcd(0,0) = 0 isn't just useful, it's the correct thing to do. I hope that didn't use too many long words. :) -Nathan Bloomfield Grad Assistant, University of Arkansas, Fayetteville On Sat, May 2, 2009 at 5:17 PM, Achim Schneider wrote: > Steve wrote: > > > "It is useful to define gcd(0, 0) = 0 and lcm(0, 0) = 0 because then > > the natural numbers become a complete distributive lattice with gcd > > as meet and lcm as join operation. This extension of the definition > > is also compatible with the generalization for commutative rings > > given below." > > > Ouch. Speak of mathematicians annoying programmers by claiming that 0 > isn't divisible by any of [1..], and further implying that 0 is bigger > than all of those, not to mention justifying all that with long words. > > Damn them buggers. > > -- > (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/20090503/2e48e222/attachment.htm From tonymorris at gmail.com Sun May 3 03:59:04 2009 From: tonymorris at gmail.com (Tony Morris) Date: Sun May 3 03:48:42 2009 Subject: [Haskell-cafe] Combining computations In-Reply-To: <671548.30261.qm@web31102.mail.mud.yahoo.com> References: <671548.30261.qm@web31102.mail.mud.yahoo.com> Message-ID: <49FD4EC8.6090506@gmail.com> michael rice wrote: > If you look at this stuff long enough it almost begins to make sense. > Maybe. ;-) > > I've been messing around with MonadPlus and I understand its usage > with the Maybe and List monads. Since one use of Monads is combining > computations, how can I combine a Maybe with a List? > > let m1 = Nothing > let m2 = [1] > let m3 = m1 `mplus` m2 ==> [1] --if the Maybe is Nothing, do nothing > > let m1 = Just 1 > let m2 = [] > let m3 = m1 `mplus` m2 ==> [1] --if the Maybe is not Nothing, add it > to the list > > Or am I misunderstanding combining computations? > > Michael > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > Hi Michael, You'll want the Data.Maybe.listToMaybe and Data.Maybe.maybeToList functions. -- Tony Morris http://tmorris.net/ From waldmann at imn.htwk-leipzig.de Sun May 3 04:01:11 2009 From: waldmann at imn.htwk-leipzig.de (j.waldmann) Date: Sun May 3 03:49:24 2009 Subject: [Haskell-cafe] using haskell for a project In-Reply-To: <3d96ac180905021446y689f216dta1caa7b6d40bde51@mail.gmail.com> References: <20090502171755.GA2939@valhala.gaia.loc> <3d96ac180905021446y689f216dta1caa7b6d40bde51@mail.gmail.com> Message-ID: <23353526.post@talk.nabble.com> don't think in terms of modifying state, think of it as computing new values from old values. I find that the payoff of learning to think ,like this is massive, as it's usually much easier to reason about. Indeed. [warning: what follows is a rant with a purpose:] The imperative/OO guys have learnt this as well, and the result comes under different names, e.g., "a service component should be stateless", "stateless session bean", "refactoring: introduce state object". It's kind of funny how they re-invent functional programming (in several places, e.g. "composite pattern" = algebraic data type, "visitor pattern" = fold, "iterator pattern" = lazy list). ... after trying to avoid the truth for some 20 years or so. You're exactly right, the functional/declarative way is "much easier to reason about", and this matches the observation that there was not much reasoning going on during these decades instead, just hacking, and then some testing. Well, they even finally admitted one should write the tests before coding. Yes, that's called specification before implementation, and that's what Dijkstra had been teaching for ages, e.g., http://www.cs.utexas.edu/users/EWD/transcriptions/EWD13xx/EWD1305.html Still, given their strange approach to programming, the imperative/OO guys have rather brilliant tools for developers. No surprise, without them they'd be lost immediately. But we have http://leksah.org/ , and there's a GSoC project for eclipsefp . [now, the punchline:] (for extended rants on the subject, register for http://www.iba-cg.de/hal4.html ) -- View this message in context: http://www.nabble.com/using-haskell-for-a-project-tp23348425p23353526.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From noel.kalman at googlemail.com Sun May 3 05:17:15 2009 From: noel.kalman at googlemail.com (Kalman Noel) Date: Sun May 3 05:03:08 2009 Subject: [Haskell-cafe] Combining computations In-Reply-To: References: Message-ID: <49FD611B.8030009@googlemail.com> michael rice schrieb: > let m1 = Just 1 > let m2 = [] > let m3 = m1 `mplus` m2 ==> [1] --if the Maybe is not Nothing, add it to the list > > Or am I misunderstanding combining computations? You just got the type of mplus wrong: mplus :: (MonadPlus m) => m a -> m a -> m a Note that it takes two values of the same type (m a), but you're giving it values of different types. That is, combining computations of different types is not within the scope of MonadPlus. In this case, it makes sense to convert (Just 1) to [1] via Data.Maybe.maybeToList, thus: m1 = Just 1 m2 = [2,3] m3 = maybeToList m1 `mplus` m2 -- [1,2,3] Note also that, in this example, Monoid (mappend) instead of MonadPlus (mplus) would be sufficient. Actually MonadPlus becomes useful only when you are concerned about the extra properties that its instances are expected to satisfy. Kalman From lrpalmer at gmail.com Sun May 3 06:41:20 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun May 3 06:27:00 2009 Subject: [Haskell-cafe] Combining computations In-Reply-To: <169272.11504.qm@web31106.mail.mud.yahoo.com> References: <169272.11504.qm@web31106.mail.mud.yahoo.com> Message-ID: <7ca3f0160905030341n6a033bf4x74867467dbd2db4a@mail.gmail.com> mplus requires both arguments to be in the same monad (the same type, even). Fortunately, the empty list behaves like Nothing, and a singleton list behaves like Just. So convert the Maybe before composing, using: maybeToList Nothing = [] maybeToList (Just x) = [x] (The maybeToList function can be found in Data.Maybe) Keep in mind that this will give you: Just 1 `mplus` [2,3,4] ==> [1,2,3,4] Which may not be what you want... Luke On Sat, May 2, 2009 at 9:26 PM, michael rice wrote: > I posted something similar about an hour ago but it seems to have gotten > lost. Very strange. > > I've read that Monads can combine computations. Can a Maybe monad be > combined with a List monad such that > > Nothing `mplus` [] ==> [] > Just 1 `mplus` [] ==> [1] > > If not, can someone supply a simple example of combining computations? > > 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/20090503/7e19f5d1/attachment.htm From lrpalmer at gmail.com Sun May 3 06:41:46 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun May 3 06:27:19 2009 Subject: [Haskell-cafe] Combining computations In-Reply-To: <7ca3f0160905030341n6a033bf4x74867467dbd2db4a@mail.gmail.com> References: <169272.11504.qm@web31106.mail.mud.yahoo.com> <7ca3f0160905030341n6a033bf4x74867467dbd2db4a@mail.gmail.com> Message-ID: <7ca3f0160905030341h168146b2na5636bdf58ea511b@mail.gmail.com> On Sun, May 3, 2009 at 4:41 AM, Luke Palmer wrote: > mplus requires both arguments to be in the same monad (the same type, > even). Fortunately, the empty list behaves like Nothing, and a singleton > list behaves like Just. So convert the Maybe before composing, using: > > maybeToList Nothing = [] > maybeToList (Just x) = [x] > > (The maybeToList function can be found in Data.Maybe) > > Keep in mind that this will give you: > > Just 1 `mplus` [2,3,4] ==> [1,2,3,4] Silly me: maybeToList (Just 1) `mplus` [2,3,4] ==> [1,2,3,4] > > > Which may not be what you want... > > Luke > > On Sat, May 2, 2009 at 9:26 PM, michael rice wrote: > >> I posted something similar about an hour ago but it seems to have gotten >> lost. Very strange. >> >> I've read that Monads can combine computations. Can a Maybe monad be >> combined with a List monad such that >> >> Nothing `mplus` [] ==> [] >> Just 1 `mplus` [] ==> [1] >> >> If not, can someone supply a simple example of combining computations? >> >> 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/20090503/58d102b0/attachment.htm From Sven.Panne at aedion.de Sun May 3 06:44:04 2009 From: Sven.Panne at aedion.de (Sven Panne) Date: Sun May 3 06:29:44 2009 Subject: [Haskell-cafe] Decoupling OpenAL/ALUT packages from OpenGL In-Reply-To: <49FCCF80.3080600@rwth-aachen.de> References: <49FCCF80.3080600@rwth-aachen.de> Message-ID: <200905031244.04713.Sven.Panne@aedion.de> Am Sonntag, 3. Mai 2009 00:56:00 schrieb Tillmann Vogt: > Sven Panne schrieb: > > * a tiny "ObjectName" package, consisting only of OpenGL's ObjectName > > class (In "Data.ObjectName"? I'm not very sure about a good place in the > > hierarchy here.) > > How about Data.GraphicsObjects ? [...] Thanks for all the suggestions so far, a few remarks from my side (I just picked the last mail for the reply, no strong reason for this...): "Data.GraphicsObjects" is a bit misleading, because OpenAL's Buffers and Sources are instances, too, and they have nothing to do with graphics. Instances of ObjectName are just opaque resources from an external API, which you have to allocate and deallocate explicitly. > I think it would be nice to have data types and functions for dot > produkt, scalar product, norms, ... > together with HOpenGL types. I fear that this might open a can of worms and could lead to even longer discussions than the ones about a collection framework. The design space for a vector math package is quite large, and I fear that e.g. a mathematician trying to implement some linear algebra package has vastly different requirements than somebody trying to implement the n-th incarnation of the Quake engine. Some points to consider: * Should the components of vectors etc. be strict? In OpenGL they are, and Data.Complex is similar in this respect. In my experience non-strict components lead to space leaks too easily, and I guess this is the rationale behind Complex, too. But non-strict components have some benefits, too, of course, especially if you do symbolic computation. * Should we abstract over the number of dimension of vectors, etc.? If yes, how strong can our compile-time type checking be? * If we really make this a more general vector math package, things like colors etc. should probably stay in the OpenGL package. But there are a few other packages needing color data types, too... * If the package is not general enough, it might be a bad idea to steal names/hierarchy locations which *are* general. Nevertheless, I'd be happy to see some proposals for a sensible, compact vector math package. Probably we can fulfill most of the common use cases with something simple. And one word about lumping the 3 packages together: Any function, module, and package should have *one* clearly defined task, this is crucial for every SW design. I would have a hard time explaining what this "super package" is all about, even if we throw only 2 of the 3 packages together. Personally I feel that this is a strong argument for 3 separate packages. > (I know that glu has tesselation). [...] But GLU is basically dead with OpenGL 3.x. :-) Cheers, S. From felipe.lessa at gmail.com Sun May 3 07:04:44 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sun May 3 06:50:27 2009 Subject: [Haskell-cafe] Combining computations In-Reply-To: <169272.11504.qm@web31106.mail.mud.yahoo.com> References: <169272.11504.qm@web31106.mail.mud.yahoo.com> Message-ID: <20090503110444.GA13354@kira.casa> I don't know if I understood your intentions, but let's go. The problem is that you're trying to combine different monads. We have mplus :: MonadPlus m => m a -> m a -> m a, so you never leave 'm', but you want mplus' :: ??? => n a -> m a -> m a where 'n' could be a different monad. In some specific cases where you know the internal structure of the monad, you can write 'mplus'', for example: mplus' :: MonadPlus m => Maybe a -> m a -> m a mplus' m l = maybeToMonad m `mplus` l maybeToMonad :: Monad m => Maybe a -> m a maybeToMonad = maybe (fail "Nothing") return In general, however, this operation can't be done. For example, how would you write: mplus' :: IO a -> [a] -> [a] ? HTH, -- Felipe. From daniel.is.fischer at web.de Sun May 3 07:19:30 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun May 3 07:05:41 2009 Subject: [Haskell-cafe] Combining computations In-Reply-To: <169272.11504.qm@web31106.mail.mud.yahoo.com> References: <169272.11504.qm@web31106.mail.mud.yahoo.com> Message-ID: <200905031319.31110.daniel.is.fischer@web.de> Am Sonntag 03 Mai 2009 05:26:22 schrieb michael rice: > I posted something similar about an hour ago but it seems to have gotten > lost. Very strange. > > I've read that Monads can combine computations. Can a Maybe monad be > combined with a List monad such that > > Nothing `mplus` [] ==> [] > Just 1 `mplus` [] ==> [1] Not directly, the type of mplus is mplus :: MonadPlus m => m a -> m a -> m a , so the monad has to be the same for both arguments. For [] and Maybe, you can use maybeToList and listToMaybe to convert one into the other: Prelude Data.Maybe Control.Monad> maybeToList Nothing [] Prelude Data.Maybe Control.Monad> maybeToList (Just 1) [1] Prelude Data.Maybe Control.Monad> maybeToList Nothing `mplus` [1] [1] Prelude Data.Maybe Control.Monad> maybeToList (Just 1) `mplus` [] [1] Prelude Data.Maybe Control.Monad> Nothing `mplus` listToMaybe [1] Just 1 Prelude Data.Maybe Control.Monad> Nothing `mplus` listToMaybe [1,2,3] Just 1 , for certain other combinations, you can also have a meaningful conversion from one monad to another (e.g. stateToStateT :: Monad m => State s a -> StateT s m a stateToStateT comp = StateT (return . runState comp) ) and employ the technique to combine them, but it's of limited use. A monad allows you to combine computations of 'similar' type (for some fuzzy meaning of similar), using (>>=), (>>) to combine them sequentially and perhaps mplus to combine them 'in parallel'. > > If not, can someone supply a simple example of combining computations? > > Michael From rendel at cs.au.dk Sun May 3 07:33:31 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Sun May 3 07:19:55 2009 Subject: [Haskell-cafe] Combining computations In-Reply-To: <671548.30261.qm@web31102.mail.mud.yahoo.com> References: <671548.30261.qm@web31102.mail.mud.yahoo.com> Message-ID: <49FD810B.1010104@cs.au.dk> Hi, normally, one uses monads to express and combine computations in the same monad. However, you can convert between some monads, e.g. from Maybe to List: import Data.Maybe (maybeToList) > let m1 = Nothing > let m2 = [1] > let m3 = maybeToList m1 `mplus` m2 > let m1 = Just 1 > let m2 = [] > let m3 = maybeToList m1 `mplus` m2 In fact, you can convert from Maybe to any MonadPlus. maybeToMonadPlus Nothing = mzero maybeToMonadPlus (Just x) = return x And you can convert from List to any MonadPlus: listToMonadPlus Nothing = [] listToMonadPlus (x : xs) = return x `mplus` listToMonadPlus xs Now you should be able to do: m1 = maybeToMonadPlus (Just 1) m2 = listtoMonadPlus [2, 3] m3 = m1 `mplus` m2 :: Just Int -- Just 1 m4 = m1 `mplus` m2 :: [Int] -- [1, 2, 3] The reason this is possible is that Maybe and List do not support additional effects beyond what is common to all MonadPlus instances. Another option is to never specify which monad your computations are in in the first place. Instead, only specify which computational effects the monad should support. m1 = mzero :: MonadPlus m => m a m2 = return 1 :: (Monad m, Num a) => m a m3 = m1 `mplus` m2 `mplus` Just 2 -- Just 1 m4 = m1 `mplus` m2 `mplus` [2, 3] -- [1, 2, 3] In this version, m1 and m2 are polymorphic computations, which can be used together with List computations, Maybe computations, or any other MonadPlus instances. m1 needs MonadPlus, while m2 is happy with any Monad instance. This fact is encoded in their type. Tillmann From sargrigory at ya.ru Sun May 3 07:42:48 2009 From: sargrigory at ya.ru (Grigory Sarnitskiy) Date: Sun May 3 07:28:28 2009 Subject: [Haskell-cafe] Array Binary IO & molecular simulation In-Reply-To: <251001241158007@webmail128.yandex.ru> References: <251001241158007@webmail128.yandex.ru> Message-ID: <543631241350968@webmail20.yandex.ru> To sum up here is the example that can write two arrays in one file and then read this two arrays back. To restore written data it just reads the file into bytestring, then splits the bytestring into equal parts. The parts are decoded. I suppose the method is suitable for decoding files with unboxed arrays of equal size. import Data.Array.Unboxed import Data.Binary import qualified Data.ByteString.Lazy as BL import IO a = listArray ((1,1),(3,2)) [3,4,5,6,7,8] :: UArray (Int, Int) Float b = listArray ((1,1),(3,2)) [9,10,11,12,13,14] :: UArray (Int, Int) Float encodeFile2 f = BL.appendFile f . encode encoder = do encodeFile "Results.txt" a encodeFile2 "Results.txt" b decoder = do contents <- BL.readFile "Results.txt" print $ (show (decode (fst (BL.splitAt 118 contents)) :: UArray (Int, Int) Float)) print $ (show (decode (snd (BL.splitAt 118 contents)) :: UArray (Int, Int) Float)) From Sven.Panne at aedion.de Sun May 3 08:07:23 2009 From: Sven.Panne at aedion.de (Sven Panne) Date: Sun May 3 07:53:18 2009 Subject: [Haskell-cafe] ANN: Silkworm game In-Reply-To: <98A96C9E-6685-4512-AB3B-50E3A1F39E91@gmail.com> References: <98A96C9E-6685-4512-AB3B-50E3A1F39E91@gmail.com> Message-ID: <200905031407.23483.Sven.Panne@aedion.de> Nice work! Two minor suggestions, apart from the the paths issue already discussed here: * Either include a license file in the source distribution or remove the corresponding line in the .cabal file. Cabal won't work if it is specified and missing. * List all your build dependencies directly, so users can simply do a "cabal install", pulling all missing dependencies automatically. No need for Makefiles or a long description in the README anymore... Patch for those items attached. As a side note, I get a very bad feeling when Hipmunk gets compiled on my x86_64 box: chipmunk/cpCollision.c: In function ?findVerts?: chipmunk/cpCollision.c:174:0: warning: cast from pointer to integer of different size chipmunk/cpCollision.c:180:0: warning: cast from pointer to integer of different size chipmunk/cpCollision.c: In function ?findPointsBehindSeg?: chipmunk/cpCollision.c:233:0: warning: cast from pointer to integer of different size chipmunk/cpCollision.c: In function ?seg2poly?: chipmunk/cpCollision.c:274:0: warning: cast from pointer to integer of different size chipmunk/cpCollision.c:276:0: warning: cast from pointer to integer of different size chipmunk/cpSpace.c: In function ?queryFunc?: chipmunk/cpSpace.c:411:0: warning: cast from pointer to integer of different size chipmunk/cpSpace.c:411:0: warning: cast from pointer to integer of different size This can't be correct, but I'll probably have to take a look at that. Or is it a know bug that Hipmunk ist not 64bit-clean? Cheers, S. -------------- next part -------------- A non-text attachment was scrubbed... Name: Silkworm.cabal.patch Type: text/x-patch Size: 592 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090503/1491149f/Silkworm.cabal.bin From martijn at van.steenbergen.nl Sun May 3 08:38:06 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Sun May 3 08:24:01 2009 Subject: [Haskell-cafe] using haskell for a project In-Reply-To: <20090502171755.GA2939@valhala.gaia.loc> References: <20090502171755.GA2939@valhala.gaia.loc> Message-ID: <49FD902E.3010404@van.steenbergen.nl> Hi Nicolas, Nicolas Martyanoff wrote: > So now I'd want to use it for a small project of mine, a simple > multiplayer roguelike based on telnet. I wrote a minimal server in C, and > it took me a few hours. Now I'm thinking about doing the same in Haskell, > and I'm in trouble. I don't know if this is of any help at all but I've been working a bit on a MUD in Haskell. You can find the source code here: http://code.google.com/p/custard/ You might be able to get some ideas from the source code. If you have any questions, feel free to ask. There are no spells (yet), but there are players and rooms and you can walk around a few rooms. Martijn. From ekirpichov at gmail.com Sun May 3 09:46:29 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sun May 3 09:32:10 2009 Subject: [Haskell-cafe] using haskell for a project In-Reply-To: <23352598.post@talk.nabble.com> References: <20090502171755.GA2939@valhala.gaia.loc> <23352598.post@talk.nabble.com> Message-ID: <5e0214850905030646y3ad26412qcd5bb8942a75dd09@mail.gmail.com> To the original author: I must notice that this is not the most convincing use of purity. I personally would prefer to have a character's spell list be mutable because this corresponds better to the nature of the problem (in the problem domain it is nonsense to have two versions of a character and hope that one version will drop out of the scope). However, Haskell forces you to be pure, and that pays off a lot, despite the existence of problems that are not modeled intuitively this way. In case you absolutely need mutable state, use the ST monad or IORef's, but **you have to first become skilled with pure computations, because that's the only way to not make a mess of your treatment of the impure ones**. And if anyone tries to seduce you with unsafePerformIO, resist! 2009/5/3 Belka : > > Welcome to Haskell! =) > >> But now I don't know how to dynamically add new spells (new spells can be >> created in my gameplay). Since I can't assign a new value to the `spells' >> variable (Data.Map.insert returns a new map), I just don't know where to >> go. > > Do distinguish *pure function* concept and *action with side effects* > concept. > The default in FP (Funct. Progr.) paradigm usualy is *pure function*, if > *action with side effects* is avoidable. Pure functions deal with immutable > memory "objects". So in your case, whenever you add a new spell, you get a > new character (since your chacter's "essence" is a spell list). That way > after calculating *addNewSpell* you will have 2 versions of character: a new > one (with spells list bigger), an the original one. Since old one usualy > drop out of the scope (while program evaluation progresses) it gets *garbage > collected* (note: garbage collection showed up in FP already in 1960s). > > addNewSpell :: Character -> Spell -> Character > addNewSpell char_old_version spell_to_add = ... > > main = let char_new_version = addNewSpell char_old_version new_spell in > putStrLn $ show char_new_version > ? ? ? ? ?where char_old_version = Charcter {...} > ? ? ? ? ? ? ? ? ? new_spell = Spell { .... } > > Have luck, with the brain rewriting! =) > Belka > -- > View this message in context: http://www.nabble.com/using-haskell-for-a-project-tp23348425p23352598.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 > -- Eugene Kirpichov Web IR developer, market.yandex.ru From nowgate at yahoo.com Sun May 3 11:05:33 2009 From: nowgate at yahoo.com (michael rice) Date: Sun May 3 10:51:15 2009 Subject: [Haskell-cafe] Combining computations Message-ID: <776846.25811.qm@web31108.mail.mud.yahoo.com> Thanks for all the help, everyone. I think this stuff is starting to come together. Michael --- On Sun, 5/3/09, Tillmann Rendel wrote: From: Tillmann Rendel Subject: Re: [Haskell-cafe] Combining computations To: "michael rice" Cc: haskell-cafe@haskell.org Date: Sunday, May 3, 2009, 7:33 AM Hi, normally, one uses monads to express and combine computations in the same monad. However, you can convert between some monads, e.g. from Maybe to List: ? import Data.Maybe (maybeToList) ? > let m1 = Nothing ? > let m2 = [1] ? > let m3 = maybeToList m1 `mplus` m2 ? > let m1 = Just 1 ? > let m2 = [] ? > let m3 = maybeToList m1 `mplus` m2 In fact, you can convert from Maybe to any MonadPlus. ? maybeToMonadPlus Nothing = mzero ? maybeToMonadPlus (Just x) = return x And you can convert from List to any MonadPlus: ? listToMonadPlus Nothing? = [] ? listToMonadPlus (x : xs) = return x `mplus` listToMonadPlus xs Now you should be able to do: ? m1 = maybeToMonadPlus (Just 1) ? m2 = listtoMonadPlus [2, 3] ? m3 = m1 `mplus` m2 :: Just Int -- Just 1 ? m4 = m1 `mplus` m2 :: [Int]? ? -- [1, 2, 3] The reason this is possible is that Maybe and List do not support additional effects beyond what is common to all MonadPlus instances. Another option is to never specify which monad your computations are in in the first place. Instead, only specify which computational effects the monad should support. ? m1 = mzero? ? :: MonadPlus m => m a ? m2 = return 1 :: (Monad m, Num a) => m a ? m3 = m1 `mplus` m2 `mplus` Just 2 -- Just 1 ? m4 = m1 `mplus` m2 `mplus` [2, 3] -- [1, 2, 3] In this version, m1 and m2 are polymorphic computations, which can be used together with List computations, Maybe computations, or any other MonadPlus instances. m1 needs MonadPlus, while m2 is happy with any Monad instance. This fact is encoded in their type. ? Tillmann -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090503/328a4e28/attachment.htm From sargrigory at ya.ru Sun May 3 11:33:23 2009 From: sargrigory at ya.ru (Grigory Sarnitskiy) Date: Sun May 3 11:19:02 2009 Subject: [Haskell-cafe] Array Binary IO & molecular simulation In-Reply-To: <42784f260905021732l309f922dm8b196463f2e5f04c@mail.gmail.com> References: <251001241158007@webmail128.yandex.ru> <42784f260905020212l2122cbdu876daf0a430a199d@mail.gmail.com> <220e47b40905020259r2ad1ce24k5cc5df55760730c7@mail.gmail.com> <42784f260905020416p5b2190e0u75ea80ece8a19498@mail.gmail.com> <742701241274171@webmail37.yandex.ru> <42784f260905021732l309f922dm8b196463f2e5f04c@mail.gmail.com> Message-ID: <2851241364803@webmail20.yandex.ru> An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090503/1c8c5533/attachment.htm From lazycat.manatee at gmail.com Sun May 3 11:27:03 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Sun May 3 11:54:18 2009 Subject: [Haskell-cafe] StateT IO Action on `onKeyPress` Message-ID: <87hc021a2g.fsf@ubuntu.domain> Hi all, I have a function named `keymapTest` need moand state WindowListT, and WindowListT is `type WindowListT = StateT WindowList IO`. when i add "(\event -> keymapTest winList event >> return False)" after `onKeyPress` for handle key press event, i got GHC error: Manatee.hs:57:58: Couldn't match expected type `IO a' against inferred type `WindowListT Bool' In the first argument of `(>>)', namely `keymapTest winList event' In the expression: keymapTest winList event >> return False In the second argument of `onKeyPress', namely `(\ event -> keymapTest winList event >> return False)' So function `onKeyPress` just accept *one* IO-action? Have a way to fix above problem? Any help? Thanks! -- Andy Below is source code of Manatee.hs file. ------------------------------> Manatee.hs start <------------------------------ module Main where import Text.Printf import Data.Monoid import Data.List import Data.Maybe import Control.Monad import Control.Monad.State import Control.Applicative import Data.IORef import Graphics.UI.Gtk hiding (Window, windowNew, get) import Graphics.UI.Gtk.SourceView import Graphics.UI.Gtk.Abstract.Widget import Manatee.Event import Manatee.Buffer import Manatee.WindowList import Manatee.Pane import Manatee.Statusbar import Manatee.Utils import Manatee.Window import qualified Data.Set as Set import qualified Graphics.UI.Gtk.Windows.Window as W import qualified Graphics.UI.Gtk.Gdk.Events as E main :: IO () main = do -- Init. initGUI -- Root frame. rootFrame <- W.windowNew rootFrame `onDestroy` mainQuit -- quit main loop when root frame close -- Root frame status. windowFullscreen rootFrame -- fullscreen -- Windows list. let windowsList = WindowList 0 Set.empty evalStateT (do -- Window 1 window1 <- windowNewWithBuffer DTop "test" liftIO $ containerAdd rootFrame $ windowPaned window1 (window2, window3) <- windowSplitVertically window1 (window4, window5) <- windowSplitHorizontally window3 winList <- windowListGetList liftIO $ rootFrame `onKeyPress` (\event -> keymapTest winList event >> return False) -- Handle window content synchronous. windowHandleSynchronous ) windowsList -- Loop widgetShowAll rootFrame -- display all widget mainGUI keymapTest :: [Window] -> E.Event -> WindowListT Bool keymapTest winList event = do window <- liftIO $ windowFindFocus winList case window of Just x -> handleKeyPress x event Nothing -> return False handleKeyPress :: Window -> E.Event -> WindowListT Bool handleKeyPress window ev = do liftIO $ case eventTransform ev of Nothing -> return False Just e -> do let display = statusbarOutputSubitemSetText $ paneStatusbar $ windowPane $ window eventName = eventGetName e case eventName of -- Window commands. "M-t" -> display "windowSplitVertically" -- "M-t" -> windowSplitVertically window >> return False _ -> display $ printf "%s undefined." eventName ------------------------------> Manatee.hs end <------------------------------ From barsoap at web.de Sun May 3 12:16:38 2009 From: barsoap at web.de (Achim Schneider) Date: Sun May 3 12:02:23 2009 Subject: [Haskell-cafe] Re: gcd References: <20090118204519.320AF32465D@www.haskell.org> <1241229917.3721.3.camel@host.localdomain> <20090503001722.4a253bce@solaris> <9858b5620905022335gbf68a6ch7397468f97f8ed63@mail.gmail.com> Message-ID: <20090503181638.1729b37f@solaris> Nathan Bloomfield wrote: > The "greatest" in gcd is not w.r.t. the canonical ordering on the > naturals; rather w.r.t. the partial order given by the divides > relation. > This, to defend myself, was not how it was explained in high school. -- (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 tobsan at gmail.com Sun May 3 13:27:52 2009 From: tobsan at gmail.com (Tobias Olausson) Date: Sun May 3 13:13:34 2009 Subject: [Haskell-cafe] ST.Lazy vs ST.Strict Message-ID: <65c9dbea0905031027j60e08cefh162cb63b70c1c721@mail.gmail.com> Hello! I have a program that is using ST.Strict, which works fine. However, the program needs to be extended, and to do that, lazy evaluation is needed. As a result of that, I have switched to ST.Lazy to be able to do stuff like foo y = do x <- something xs <- foo (y+1) return (x:xs) However, when running the program compiled with ST.Lazy, the following is outputted: [tobsi@wobsi]$ ./runnerLazy looper.hex runnerLazy: <> The very same program compiled with ST.Strict outputs: [tobsi@wobsi]$ ./runner looper.hex 83298556 The code that is actually computing stuff is this: loopSys :: Int -> CPU s Int loopSys cc = do instr <- fetch if instr == 0xEA --NOP then return cc else do c <- execute instr loopSys $! (cc+c) The CPU type looks as follows: type CPU s a = ReaderT (SysEnv s) (ST s) a The program is run like runReaderT (loopSys 0) which in turn is being runST'd and then printed Does anyone know why the program just outputs <> when compiled under ghc 6.10.2, and runs perfectly fine under ghc 6.8.2? The program is compiled with --make and -O2 Tobias Olausson tobsan@gmail.com From gtener at gmail.com Sun May 3 14:06:30 2009 From: gtener at gmail.com (=?UTF-8?Q?Krzysztof_Skrz=C4=99tnicki?=) Date: Sun May 3 13:52:06 2009 Subject: [Haskell-cafe] Vector-like data structure Message-ID: <220e47b40905031106i1ff14d0ap6fb5fc223d220996@mail.gmail.com> Hi I'm looking for a data structure with following characteristics: 1. O(1) lookup 2. O(1) modification 3. amortized O(1) append 4. O(1) size query This roughly characterizes C++ vector<> class. I'm ready to implement it myself, but first I would like to ask if anyone knows package with similar data structure. If there are many, which one would you choose and why? Best regards Christopher Skrz?tnicki From daniel.carrera at theingots.org Sun May 3 14:24:52 2009 From: daniel.carrera at theingots.org (Daniel Carrera) Date: Sun May 3 14:10:29 2009 Subject: [Haskell-cafe] Haskell vs Clean (speed comparison) Message-ID: <49FDE174.9050402@theingots.org> Hi, I think the mail server may have been acting up earlier. I sent this to Haskell-beginners, but it more properly belongs here. I found something interesting. "General wisdom" is that Clean (or OCaml) is faster than Haskell. The claim is often followed by a link to the Debian shootout. But on closer inspection, I question this conclusion. The Debian shoot out actually has four sets of benchmarks: 1) Intel 32-bit one core. 2) Intel 32-bit quad-core. 3) Intel 64-bit one core. 4) Intel 64-bit quad-core. It turns out that Clean is only faster for (1). For the others, Haskell is faster. Here I compare Haskell, Clean, OCaml, Lisp SBCL, C# Mono and Fortran because they are all in the same ball mark: 32-bit sing core [1]: Lisp, Fortran, Clean, Haskell, C# Mono. 32-bit quad-core [2]: Haskell, C# Mono, Lisp, Clean, Fortran. 64-bit sing core [3]: Fortran, OCaml, Haskell, Clean, C# Mono, Lisp. 64-bit quad-core [4]: Haskell, OCaml, Lisp, C# Mono, Fortran, Clean. Notes: * The order is "fast language first". * There are no results for OCaml for 32-bit. * "Lisp" is "List SCBL" whatever that is. Tentative conclusions: 1) Haskell makes very good use of multiple cores. It smokes Clean. 2) For single core, they are neck and neck. Whether Clean is faster depends non the architecture. What do you think? Daniel. P.S. [1]http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=all&d=data&ghc=on&ocaml=on&sbcl=on&csharp=on&ifc=on&clean=on&calc=calculate&box=1 [2]http://shootout.alioth.debian.org/u32q/benchmark.php?test=all&lang=all&d=data&ghc=on&ocaml=on&sbcl=on&csharp=on&ifc=on&clean=on&calc=calculate&box=1 [3]http://shootout.alioth.debian.org/u64/benchmark.php?test=all&lang=all&d=data&ghc=on&ocaml=on&sbcl=on&csharp=on&ifc=on&clean=on&calc=calculate&box=1 [4]http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=all&d=data&ghc=on&ocaml=on&sbcl=on&csharp=on&ifc=on&clean=on&calc=calculate&box=1 From gwern0 at gmail.com Sun May 3 14:29:37 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Sun May 3 14:15:09 2009 Subject: [Haskell-cafe] Haskell vs Clean (speed comparison) In-Reply-To: <49FDE174.9050402@theingots.org> References: <49FDE174.9050402@theingots.org> Message-ID: On Sun, May 3, 2009 at 2:24 PM, Daniel Carrera wrote: > Hi, > > I think the mail server may have been acting up earlier. I sent this to > Haskell-beginners, but it more properly belongs here. > > I found something interesting. "General wisdom" is that Clean (or OCaml) is > faster than Haskell. The claim is often followed by a link to the Debian > shootout. But on closer inspection, I question this conclusion. The Debian > shoot out actually has four sets of benchmarks: > > 1) Intel 32-bit one core. > 2) Intel 32-bit quad-core. > 3) Intel 64-bit one core. > 4) Intel 64-bit quad-core. > > It turns out that Clean is only faster for (1). For the others, Haskell is > faster. Here I compare Haskell, Clean, OCaml, Lisp SBCL, C# Mono and Fortran > because they are all in the same ball mark: > > 32-bit sing core [1]: Lisp, Fortran, Clean, Haskell, C# Mono. > 32-bit quad-core [2]: Haskell, C# Mono, Lisp, Clean, Fortran. > 64-bit sing core [3]: Fortran, OCaml, Haskell, Clean, C# Mono, Lisp. > 64-bit quad-core [4]: Haskell, OCaml, Lisp, C# Mono, Fortran, Clean. > > Notes: > > * The order is "fast language first". > * There are no results for OCaml for 32-bit. > * "Lisp" is "List SCBL" whatever that is. > > Tentative conclusions: > > 1) Haskell makes very good use of multiple cores. It smokes Clean. > 2) For single core, they are neck and neck. Whether Clean is faster depends > non the architecture. > > > What do you think? > > Daniel. > > P.S. > [1]http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=all&d=data&ghc=on&ocaml=on&sbcl=on&csharp=on&ifc=on&clean=on&calc=calculate&box=1 > [2]http://shootout.alioth.debian.org/u32q/benchmark.php?test=all&lang=all&d=data&ghc=on&ocaml=on&sbcl=on&csharp=on&ifc=on&clean=on&calc=calculate&box=1 > [3]http://shootout.alioth.debian.org/u64/benchmark.php?test=all&lang=all&d=data&ghc=on&ocaml=on&sbcl=on&csharp=on&ifc=on&clean=on&calc=calculate&box=1 > [4]http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=all&d=data&ghc=on&ocaml=on&sbcl=on&csharp=on&ifc=on&clean=on&calc=calculate&box=1 Perhaps it's just that no one has parallelized the Clean programs? Haskellers seem to care about the shootout programs much more than Cleaners do. eg. I randomly looked at Mandelbrot on [2]. clean: http://shootout.alioth.debian.org/u32q/benchmark.php?test=mandelbrot&lang=clean&id=2 haskell: http://shootout.alioth.debian.org/u32q/benchmark.php?test=mandelbrot&lang=ghc&id=2 I can't really read Clean, but it certainly looks as if it's making no use of concurrency at all, while the Haskell one most certainly is. -- gwern From nbloomf at gmail.com Sun May 3 14:36:30 2009 From: nbloomf at gmail.com (Nathan Bloomfield) Date: Sun May 3 14:22:02 2009 Subject: [Haskell-cafe] Re: gcd In-Reply-To: <20090503181638.1729b37f@solaris> References: <20090118204519.320AF32465D@www.haskell.org> <1241229917.3721.3.camel@host.localdomain> <20090503001722.4a253bce@solaris> <9858b5620905022335gbf68a6ch7397468f97f8ed63@mail.gmail.com> <20090503181638.1729b37f@solaris> Message-ID: <9858b5620905031136v52991bdt6da9f2c064fc8e61@mail.gmail.com> > This, to defend myself, was not how it was explained in high school. No worries. I didn't realize this myself until college; most nonspecialist teachers just don't know any better. Nor did, it appears, the original authors of the Haskell Prelude. :) BTW, this definition of gcd makes it possible to consider gcds in rings that otherwise have no natural order- such as rings of polynomials in several variables, group rings, et cetera. Nathan Bloomfield On Sun, May 3, 2009 at 11:16 AM, Achim Schneider wrote: > Nathan Bloomfield wrote: > > > The "greatest" in gcd is not w.r.t. the canonical ordering on the > > naturals; rather w.r.t. the partial order given by the divides > > relation. > > > This, to defend myself, was not how it was explained in high school. > > -- > (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/20090503/7d25f84d/attachment.htm From bulat.ziganshin at gmail.com Sun May 3 14:32:18 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun May 3 14:24:17 2009 Subject: [Haskell-cafe] using haskell for a project In-Reply-To: <20090502171755.GA2939@valhala.gaia.loc> References: <20090502171755.GA2939@valhala.gaia.loc> Message-ID: <175230539.20090503223218@gmail.com> Hello Nicolas, Saturday, May 2, 2009, 9:17:55 PM, you wrote: > But now I don't know how to dynamically add new spells (new spells can be > created in my gameplay). Since I can't assign a new value to the `spells' > variable (Data.Map.insert returns a new map), I just don't know where to > go. well, i've written mid-size program that combines pure haskell, imperative haskell and c++ and that's my vision: in C, you don't have the barrier between pure and imperative worlds and as result you don't got habit to distinguish them. haskell forces you to separate pure and imperative code: pure code is much simpler to write but it cannot call imperative one (i.e. function can't call procedures) so you should understand the difference and carefully make your choice you are *forced* to use imperative code when it responds to some external events - user input, network input, so on. so when your spell list mutates as a result of external events, you should do something imperatively. although it may be as easy as tail-recursively calling itself with purely modified value: mainCycle spells = do x <- userInput case x of AddSpell -> mainCycle (newSpell:spells) .... further improving this idea, you may develop data structire contating whole state info: data GameState = GameState {spells: [Spell], .....} and update appropriate parts of GameState on tail-recursive calls: mainCycle gameState = do x <- userInput case x of AddSpell -> mainCycle (gameState {spells = newSpell:spells gameState}) .... as you see, this approach allows you to live in imperative world but use only pure computations to update state but once your program will become larger, you may find that this approach needs too much typing. in that case, you can program using IORefs, MVars and other types of C-like global vars. or, you may use them semi-globally - i.e. create this vars in outside procedure and then pass to all interested routines: main = do vspells <- newIORef [] let stateVars = StateVars {spells=vspells, ...} mainCycle stateVars you may even use implicit parameters to hide passing details from program code but i don't have experience of using them -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From daniel.carrera at theingots.org Sun May 3 14:42:06 2009 From: daniel.carrera at theingots.org (Daniel Carrera) Date: Sun May 3 14:27:40 2009 Subject: [Haskell-cafe] Haskell vs Clean (speed comparison) In-Reply-To: References: <49FDE174.9050402@theingots.org> Message-ID: <49FDE57E.1090608@theingots.org> Gwern Branwen wrote: > Perhaps it's just that no one has parallelized the Clean programs? > Haskellers seem to care about the shootout programs much more than > Cleaners do. I'm not sure about the second comment. I haven't seen the Haskell site mention the shootout, whereas web pages about Clean often do. Perhaps what happens is that Haskell has a larger community, so there's more chance that someone will submit an optimized program. Daniel. From deniz.a.m.dogan at gmail.com Sun May 3 14:47:27 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Sun May 3 14:34:10 2009 Subject: [Haskell-cafe] Foldable for BNFC generated tree Message-ID: <7b501d5c0905031147n24a5ec46jea3926da78d61498@mail.gmail.com> Hi I have a bunch of data types which are used to represent a JavaScript program. The data types and a lexer and a parser have all been generated using BNFC. So basically an entire JavaScript program is represented as a tree using these data types. Ideally I'd like to be able to "fold" over this data structure, but I can't instantiate Foldable for my data types, since the data types all have kind *, if I'm not completely lost. Here's an example data type: data Statement = StmtFunDecl JIdent [JIdent] ExprOrBlock | StmtVarDecl [VarDecl] | StmtLetDecl [VarDecl] | StmtWhile Expr Statement | ... So, basically I'd like some sort of folding functionality for these data types, without having to hack the lexer/parser myself (parameterising the data types), because as I said they're being generated by BNFC. I noticed that you can make BNFC generate GADTs instead of normal ADTs, which would allow me to instantiate Foldable, but I'm not entirely sure that this is the best way to do this. Any help is appreciated, Deniz Dogan From bulat.ziganshin at gmail.com Sun May 3 14:42:21 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun May 3 14:34:31 2009 Subject: [Haskell-cafe] Haskell vs Clean (speed comparison) In-Reply-To: <49FDE174.9050402@theingots.org> References: <49FDE174.9050402@theingots.org> Message-ID: <705940834.20090503224221@gmail.com> Hello Daniel, Sunday, May 3, 2009, 10:24:52 PM, you wrote: > 32-bit sing core [1]: Lisp, Fortran :) this test measures speed of some programs, not "languages". results are depends mainly on bundled libraries and RTS. by no means it demonstrates speed of compiler-generated code of carefully-written program what is typically considered as "language speed". the reasons are: 1) C++ people (and probably Fortran too) aren't so interested in making fastest possible programs as Haskell community. it becomes popular a few years ago, you can find that Haskell becomes several faster at average since then, which doesn't reflect actual improvements in GHC code generation (10-20%) 2) Most programs there depend on speed of libraries. Moreover, there is limitation that it should be *bundled* libraries, so results greatly depends on what currently included in one compiler or another 3) it's prohibited to write your own fast code if bundled library is too slow (for example, because it's too general) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Sun May 3 14:45:02 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun May 3 14:34:35 2009 Subject: [Haskell-cafe] Vector-like data structure In-Reply-To: <220e47b40905031106i1ff14d0ap6fb5fc223d220996@mail.gmail.com> References: <220e47b40905031106i1ff14d0ap6fb5fc223d220996@mail.gmail.com> Message-ID: <1335975587.20090503224502@gmail.com> Hello Krzysztof, Sunday, May 3, 2009, 10:06:30 PM, you wrote: > This roughly characterizes C++ vector<> class. I'm ready to implement http://haskell.org/haskellwiki/Library/ArrayRef#Using_dynamic_.28resizable.29_arrays although this (mine) package is probably incompatible with current ghc versions :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Sun May 3 14:47:19 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun May 3 14:34:41 2009 Subject: [Haskell-cafe] Haskell vs Clean (speed comparison) In-Reply-To: References: <49FDE174.9050402@theingots.org> Message-ID: <44550187.20090503224719@gmail.com> Hello Gwern, Sunday, May 3, 2009, 10:29:37 PM, you wrote: >> 32-bit quad-core [2]: Haskell, C# Mono, Lisp, Clean, Fortran. > I can't really read Clean, but it certainly looks as if it's making no > use of concurrency at all, while the Haskell one most certainly is. probably other languages goes w/o built-in concurrency support and this test doesn't allow to use external libs :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From joao at joaoff.com Sun May 3 14:49:24 2009 From: joao at joaoff.com (=?ISO-8859-1?Q?Jo=E3o_Ferreira?=) Date: Sun May 3 14:35:05 2009 Subject: [Haskell-cafe] Re: gcd In-Reply-To: <9858b5620905031136v52991bdt6da9f2c064fc8e61@mail.gmail.com> References: <20090118204519.320AF32465D@www.haskell.org> <1241229917.3721.3.camel@host.localdomain> <20090503001722.4a253bce@solaris> <9858b5620905022335gbf68a6ch7397468f97f8ed63@mail.gmail.com> <20090503181638.1729b37f@solaris> <9858b5620905031136v52991bdt6da9f2c064fc8e61@mail.gmail.com> Message-ID: <82da07730905031149y12243d72j3692c09adbf0ba40@mail.gmail.com> Something that perhaps could be added is that leaving 0 `gcd` 0 undefined has two obvious annoying consequences: gcd is no longer idempotent (i.e. we don't have a `gcd` a = a, for all a), and it is no longer associative ((a `gcd` 0) `gcd` 0 is well-defined whilst a `gcd` (0 `gcd` 0) is not). (We actually wrote something about this on a recent paper. If you're interested, see http://www.joaoff.com/publications/2009/euclid-alg ) Regards, Joao 2009/5/3 Nathan Bloomfield > > This, to defend myself, was not how it was explained in high school. > > No worries. I didn't realize this myself until college; most nonspecialist > teachers just don't know any better. Nor did, it appears, the original > authors of the Haskell Prelude. :) > > BTW, this definition of gcd makes it possible to consider gcds in rings > that otherwise have no natural order- such as rings of polynomials in > several variables, group rings, et cetera. > > Nathan Bloomfield > > > On Sun, May 3, 2009 at 11:16 AM, Achim Schneider wrote: > >> Nathan Bloomfield wrote: >> >> > The "greatest" in gcd is not w.r.t. the canonical ordering on the >> > naturals; rather w.r.t. the partial order given by the divides >> > relation. >> > >> This, to defend myself, was not how it was explained in high school. >> >> -- >> (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 >> > > > _______________________________________________ > 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/20090503/8778ff54/attachment.htm From bulat.ziganshin at gmail.com Sun May 3 14:49:13 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun May 3 14:36:09 2009 Subject: [Haskell-cafe] Haskell vs Clean (speed comparison) In-Reply-To: <49FDE57E.1090608@theingots.org> References: <49FDE174.9050402@theingots.org> <49FDE57E.1090608@theingots.org> Message-ID: <197390016.20090503224913@gmail.com> Hello Daniel, Sunday, May 3, 2009, 10:42:06 PM, you wrote: > I'm not sure about the second comment. I haven't seen the Haskell site > mention the shootout just search cafe archives ;) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From daniel.is.fischer at web.de Sun May 3 14:56:25 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun May 3 14:42:38 2009 Subject: [Haskell-cafe] Re: gcd In-Reply-To: <20090503181638.1729b37f@solaris> References: <20090118204519.320AF32465D@www.haskell.org> <9858b5620905022335gbf68a6ch7397468f97f8ed63@mail.gmail.com> <20090503181638.1729b37f@solaris> Message-ID: <200905032056.26631.daniel.is.fischer@web.de> Am Sonntag 03 Mai 2009 18:16:38 schrieb Achim Schneider: > Nathan Bloomfield wrote: > > The "greatest" in gcd is not w.r.t. the canonical ordering on the > > naturals; rather w.r.t. the partial order given by the divides > > relation. Nitpick: it's not a partial order, but a preorder (2 | (-2), (-2) | 2, 2 /= (-2)). > > This, to defend myself, was not how it was explained in high school. Understandably. One wouldn't want to confuse the average pupil with too abstract concepts like arbitrary rings or preorders. Unfortunately that leads to teaching concepts of primes, greatest common divisors and least common multiples which don't agree with the modern mathematical concepts :-( From daniel.carrera at theingots.org Sun May 3 15:00:16 2009 From: daniel.carrera at theingots.org (Daniel Carrera) Date: Sun May 3 14:45:52 2009 Subject: [Haskell-cafe] Haskell vs Clean (speed comparison) In-Reply-To: <705940834.20090503224221@gmail.com> References: <49FDE174.9050402@theingots.org> <705940834.20090503224221@gmail.com> Message-ID: <49FDE9C0.4070400@theingots.org> Bulat Ziganshin wrote: >> 32-bit sing core [1]: Lisp, Fortran > > :) this test measures speed of some programs, not "languages". I know. But since I know that you know that too, I opted for brevity. "How can we benchmark a programming language? We can't - we benchmark programming language implementations. How can we benchmark language implementations? We can't - we measure particular programs." Daniel. From thomas.dubuisson at gmail.com Sun May 3 15:00:22 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Sun May 3 14:45:56 2009 Subject: [Haskell-cafe] Haskell vs Clean (speed comparison) In-Reply-To: <49FDE57E.1090608@theingots.org> References: <49FDE174.9050402@theingots.org> <49FDE57E.1090608@theingots.org> Message-ID: <4c44d90b0905031200t71b45669u9839348bb08a6716@mail.gmail.com> > > I haven't seen the Haskell site mention the shootout, whereas web pages > about Clean often do. Well, there certainly has been significant efforts on the shootout in the Haskell community. There's wiki pages about it [1] and it comes up on the Haskell reddit and proggit frequently. With regard to the original discussion on comparing Haskell shootout results to Clean I suggest people think more about making Haskell use as little memory as Clean does and not worrying so much about the Haskell vs. Clean CPU time. Thomas [1] http://haskell.org/haskellwiki/Shootout [2] http://www.reddit.com/r/haskell/search?q=shootout - and that doesn't show comments, just some submitted links. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090503/9f89898e/attachment.htm From duane.johnson at gmail.com Sun May 3 15:38:54 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Sun May 3 15:24:38 2009 Subject: [Haskell-cafe] ANN: Silkworm game In-Reply-To: <20090503000708.GD6893@whirlpool.galois.com> References: <98A96C9E-6685-4512-AB3B-50E3A1F39E91@gmail.com> <20090503000708.GD6893@whirlpool.galois.com> Message-ID: So here's the thing.... to get it to run on Mac OS X, I have to build a "SilkwormGame.app" directory, with a "Resources" directory inside, along with a lot of other rubbish, just so that GLFW can create a Mac OS window that accepts mouse and keyboard input. This is the purpose of the Makefile--it uses a script borrowed from wxWindows to assemble all the parts. Obviously, this rigamarole is not necessary in Unix. But am I correct in assuming that there is no facility in Cabal that prepares a Mac OS "app" in this way? Any suggestions so that a cabal install will work for both Unix and Mac users? Here is what I get (using Don's Silkworm.cabal): > ~/Documents/Duane/BYU Semesters/2009-Winter/Graphics/ > Silkworm(master) $ cabal install > Resolving dependencies... > Configuring Silkworm-0.2... > Preprocessing executables for Silkworm-0.2... > Building Silkworm-0.2... > [ 1 of 16] Compiling Silkworm.Action ( Silkworm/Action.hs, dist/ > build/SilkwormGame/SilkwormGame-tmp/Silkworm/Action.o ) > ... ... > [16 of 16] Compiling Main ( main.hs, dist/build/ > SilkwormGame/SilkwormGame-tmp/Main.o ) > Linking dist/build/SilkwormGame/SilkwormGame ... > Installing executable(s) in /Users/duane/.cabal/bin > > ~/Silkworm(master) $ SilkwormGame > Working in unbundled mode. You should build a .app wrapper for your > Mac OS X applications. > SilkwormGame: ~/Silkworm/background.png: openBinaryFile: does not > exist (No such file or directory) Putting the binary files in the place it expects produces the same "working in unbundled mode" along with a window that will not capture ANY input from the mouse or keyboard. In fact, it won't even rise to the top of the window stack--it remains behind the terminal window. Thanks for you help, -- Duane On May 2, 2009, at 6:07 PM, Don Stewart wrote: > Yes, it is quite fun. > > I think it should be using cabal's datadir from Paths_silkworm.hs to > install (and find) the resources. > > Yell if you can't figure out how to do that. (xmonad has an example) > > -- Don From dons at galois.com Sun May 3 15:41:37 2009 From: dons at galois.com (Don Stewart) Date: Sun May 3 15:28:35 2009 Subject: [Haskell-cafe] ANN: Silkworm game In-Reply-To: References: <98A96C9E-6685-4512-AB3B-50E3A1F39E91@gmail.com> <20090503000708.GD6893@whirlpool.galois.com> Message-ID: <20090503194137.GA11310@whirlpool.galois.com> For the Mac, you might have to use mkbndl or one of the other native package builders for the Mac. -- Don duane.johnson: > So here's the thing.... to get it to run on Mac OS X, I have to build a > "SilkwormGame.app" directory, with a "Resources" directory inside, along > with a lot of other rubbish, just so that GLFW can create a Mac OS window > that accepts mouse and keyboard input. This is the purpose of the > Makefile--it uses a script borrowed from wxWindows to assemble all the > parts. > > Obviously, this rigamarole is not necessary in Unix. But am I correct > in assuming that there is no facility in Cabal that prepares a Mac OS > "app" in this way? Any suggestions so that a cabal install will work > for both Unix and Mac users? > > Here is what I get (using Don's Silkworm.cabal): > >> ~/Documents/Duane/BYU Semesters/2009-Winter/Graphics/Silkworm(master) $ >> cabal install >> Resolving dependencies... >> Configuring Silkworm-0.2... >> Preprocessing executables for Silkworm-0.2... >> Building Silkworm-0.2... >> [ 1 of 16] Compiling Silkworm.Action ( Silkworm/Action.hs, dist/ >> build/SilkwormGame/SilkwormGame-tmp/Silkworm/Action.o ) >> ... ... >> [16 of 16] Compiling Main ( main.hs, dist/build/ >> SilkwormGame/SilkwormGame-tmp/Main.o ) >> Linking dist/build/SilkwormGame/SilkwormGame ... >> Installing executable(s) in /Users/duane/.cabal/bin >> >> ~/Silkworm(master) $ SilkwormGame >> Working in unbundled mode. You should build a .app wrapper for your >> Mac OS X applications. >> SilkwormGame: ~/Silkworm/background.png: openBinaryFile: does not >> exist (No such file or directory) > > Putting the binary files in the place it expects produces the same > "working in unbundled mode" along with a window that will not capture > ANY input from the mouse or keyboard. In fact, it won't even rise to > the top of the window stack--it remains behind the terminal window. > > Thanks for you help, > -- Duane > > On May 2, 2009, at 6:07 PM, Don Stewart wrote: > >> Yes, it is quite fun. >> >> I think it should be using cabal's datadir from Paths_silkworm.hs to >> install (and find) the resources. >> >> Yell if you can't figure out how to do that. (xmonad has an example) >> >> -- Don > From dons at galois.com Sun May 3 15:50:07 2009 From: dons at galois.com (Don Stewart) Date: Sun May 3 15:38:27 2009 Subject: [Haskell-cafe] Vector-like data structure In-Reply-To: <220e47b40905031106i1ff14d0ap6fb5fc223d220996@mail.gmail.com> References: <220e47b40905031106i1ff14d0ap6fb5fc223d220996@mail.gmail.com> Message-ID: <20090503195007.GD11310@whirlpool.galois.com> gtener: > Hi > > I'm looking for a data structure with following characteristics: > 1. O(1) lookup > 2. O(1) modification > 3. amortized O(1) append > 4. O(1) size query > > This roughly characterizes C++ vector<> class. I'm ready to implement > it myself, but first I would like to ask if anyone knows package with > similar data structure. > If there are many, which one would you choose and why? > A number of the array packages behave like this. The trie packages are O(log(wordsize)), so another option (they tend to have better append complexity as well). -- Don From claus.reinke at talk21.com Sun May 3 16:59:44 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Sun May 3 16:46:26 2009 Subject: [Haskell-cafe] Combining computations References: <169272.11504.qm@web31106.mail.mud.yahoo.com> <20090503110444.GA13354@kira.casa> Message-ID: > mplus' :: MonadPlus m => Maybe a -> m a -> m a > mplus' m l = maybeToMonad m `mplus` l > > maybeToMonad :: Monad m => Maybe a -> m a > maybeToMonad = maybe (fail "Nothing") return > > In general, however, this operation can't be done. For example, > how would you write: > > mplus' :: IO a -> [a] -> [a] Perhaps the question should be: is there an interesting structure that would allow us to capture when this kind of merging Monads is possible? We can convert every 'Maybe a' to a '[] a', but the other way round is partial or loses information, so lets focus on the first direction. Should there be a type family Up m1 m2 type instance Up Maybe [] = [] so that one could define mplusUp :: m1 a -> m2 a -> (m1 `Up` m2) a ? Well, we'd need the conversions, too, so perhaps {-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, TypeFamilies, TypeOperators #-} import Control.Monad class Up m1 m2 where type m1 :/\: m2 :: * -> * up :: m1 a -> m2 a -> ((m1 :/\: m2) a, (m1 :/\: m2) a) instance Up m m where type m :/\: m = m up ma1 ma2 = (ma1, ma2) instance Up Maybe [] where type Maybe :/\: [] = [] up m1a m2a = (maybe [] (:[]) m1a, m2a) instance Up [] Maybe where type [] :/\: Maybe = [] up m1a m2a = (m1a, maybe [] (:[]) m2a) mplusUp :: (m ~ (m1 :/\: m2), Up m1 m2, MonadPlus m) => m1 a -> m2 a -> m a m1a `mplusUp` m2a = mUp1a `mplus` mUp2a where (mUp1a,mUp2a) = up m1a m2a Whether or not that is interesting, or whether it needs to be defined differently to correspond to an interesting structure, I'll leave to the residential (co-)Categorians!-) Claus From haberg at math.su.se Sun May 3 17:11:14 2009 From: haberg at math.su.se (Hans Aberg) Date: Sun May 3 16:57:07 2009 Subject: [Haskell-cafe] gcd In-Reply-To: <1241229917.3721.3.camel@host.localdomain> References: <20090118204519.320AF32465D@www.haskell.org> <1241229917.3721.3.camel@host.localdomain> Message-ID: <6F978CFC-2F26-42B6-9139-D9A23453A367@math.su.se> On 2 May 2009, at 04:05, Steve wrote: > Why is gcd 0 0 undefined? In math, one may define gcd(x, y) as a generator of the ideal generated by x and y in the ring of integers Z. The gcd(x, y) then always exists as the ring Z is a PID (principal ideal domain), i.e., all ideals can be generated by a single element, which can be proven using Euclid's algorithm, also useful for computing the gcd in Z. Anyway, the ideal generated by 0 and 0 is the zero ideal 0, which also is generated by the single generator 0. So gcd(0, 0) = 0 by this definition. In Z, one may take the gcd >= 0, but that may not work in every PID. If k is a field, then the polynomial ring k[x] is a PID, but not the ring k[x_1, ..., x_n]. So that leads to Buchberger's Groebner Basis Algorithm. Hans From wasserman.louis at gmail.com Sun May 3 17:13:25 2009 From: wasserman.louis at gmail.com (Louis Wasserman) Date: Sun May 3 16:59:50 2009 Subject: [Haskell-cafe] Research in functional programming Message-ID: Where might I find or submit a paper on functional data structures? Examples I've found so far include ICFP and the JFP , but Google hasn't found me anything else. Louis Wasserman wasserman.louis@gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090503/25b83f5f/attachment.htm From allbery at ece.cmu.edu Sun May 3 17:15:03 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun May 3 17:00:51 2009 Subject: [Haskell-cafe] Combining computations In-Reply-To: References: <169272.11504.qm@web31106.mail.mud.yahoo.com> <20090503110444.GA13354@kira.casa> Message-ID: <22E9F80F-FDC1-4DF3-ABCE-2E5BA88675B2@ece.cmu.edu> On May 3, 2009, at 16:59 , Claus Reinke wrote: > Perhaps the question should be: is there an interesting structure > that would allow us to capture when this kind of merging Monads > is possible? We can convert every 'Maybe a' to a '[] a', but the > other way round is partial or loses information, so lets focus on > the first direction. Should there be a It feels to me kinda like numeric upconversion. -- 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/20090503/2e393410/PGP.bin From magnus at therning.org Sun May 3 17:17:11 2009 From: magnus at therning.org (Magnus Therning) Date: Sun May 3 17:02:54 2009 Subject: [Haskell-cafe] Getting WriterT log lazily Message-ID: <49FE09D7.5090108@therning.org> I've been playing around with (WriterT [Int] IO), trying to get the log out and map `print` over it... and do it lazily. However, I'm not really happy with what I have so far, since I've had to resort to `unsafePerformIO`. Any hints are welcome. What I have so far is: foo = let _tell i = do a <- return $ unsafePerformIO $ sleep 1 tell [a + 1 `seq` i] in do mapM_ _tell [1..10] main = do (_, ~res) <- runWriterT foo mapM_ print res Without the `seq` the call to sleep will simply be skipped (is there an easier way to force evaluation there?). Without `unsafePerformIO` all the sleeping is done up front, and all numbers are print at once at the end. The goal is of course to use code along the same shape to do something more useful, and then `unsafePerformIO` will really be unsafe... /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090503/df976534/signature.bin From ryani.spam at gmail.com Sun May 3 17:40:55 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sun May 3 17:27:23 2009 Subject: [Haskell-cafe] traversing a tree using monad.cont In-Reply-To: References: <7ca3f0160905012035h6c333b57yca03c34e7cc342ec@mail.gmail.com> Message-ID: <2f9b2d30905031440m79a6e00fi1b58c3b69ea97c9a@mail.gmail.com> Cont with success and failure isn't Cont; it's something else (albeit similar) There's a great exposition of using something much like Cont to get success and failure "for free" here: http://www-ps.informatik.uni-kiel.de/~sebf/haskell/barefaced-pilferage-of-monadic-bind.lhs.html -- ryan On Sat, May 2, 2009 at 2:13 AM, Anatoly Yakovenko wrote: >> Though I don't fully understand what you are doing (specifically what you >> mean by "specific order"), but in a lazy language, traversals are usually >> simply encoded as lists. ?Just write a function which returns all the leaves >> as a list, and filter over it. > > yea, i know, i am trying to learn how to use the Cont monad. or > continuation in haskell. ?The idea is that while i am processing some > data i may hit a point whree some dependency isn't met and i want to > take a different branch via continuation. ?I expect that branch to > furfill my dependency and when its done i want to continue down the > original branch > > >>> module TestCont where >>> import Control.Monad.Cont >>> import Control.Monad.Identity >>> import Control.Monad.State.Lazy >>> >>> --our stupid tree >>> data Tree a = Tree [Tree a] >>> ? ? ? ? ? ?| Leaf a >>> >>> --traverse all the branches >>> search (Tree ts) next = do >>> ? mapM_ (\ ti -> (callCC (search ti))) ts >>> ? next $ () >>> >>> search tt@(Leaf a) next = do >>> ? cur <- lift get >>> ? case ((cur + 1) == a) of >>> ? ? ?True -> do --the current leaf is what we want, update the state and return > > this is where i succeed in my current branch, so i can just do my thing and exit > >>> ? ? ? ? lift $ put a >>> ? ? ? ? return $ () >>> ? ? ?False -> do --the current leaf is not what we want, continue first, then try again > > this is where i fail, so i want to take the "other" branch first > expecting it to fulfill my dependency. > >>> ? ? ? ? next () >>> ? ? ? ? search tt (\ _ -> error "fail") >>> >>> t1 = Leaf 1 >>> t2 = Leaf 2 >>> t3 = Tree [t1,t2] >>> t4 = Leaf 3 >>> t5::Tree Int = Tree [t4,t3] >>> >>> run = ?runIdentity (runStateT ((runContT $ callCC (search t5)) return) 0) > > > but i think next doesn't do exactly what i think it does > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ryani.spam at gmail.com Sun May 3 17:52:32 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sun May 3 17:38:33 2009 Subject: [Haskell-cafe] Getting WriterT log lazily In-Reply-To: <49FE09D7.5090108@therning.org> References: <49FE09D7.5090108@therning.org> Message-ID: <2f9b2d30905031452l197ddfb5w13c9e111784305bc@mail.gmail.com> How about this: > type ActionLog v = Writer [IO v] > myTell :: v -> ActionLog v () > myTell a = tell [sleep 1 >> return a] > foo :: ActionLog Int () > foo = mapM_ myTell [1..10] > main = sequence_ results where > (_, vals) = runWriter foo > results = map (>>= print) vals -- ryan On Sun, May 3, 2009 at 2:17 PM, Magnus Therning wrote: > I've been playing around with (WriterT [Int] IO), trying to get the log > out and map `print` over it... and do it lazily. However, I'm not > really happy with what I have so far, since I've had to resort to > `unsafePerformIO`. Any hints are welcome. > > What I have so far is: > > foo = let > _tell i = do > a <- return $ unsafePerformIO $ sleep 1 > tell [a + 1 `seq` i] > in do > mapM_ _tell [1..10] > > main = do > (_, ~res) <- runWriterT foo > mapM_ print res > > Without the `seq` the call to sleep will simply be skipped (is there an > easier way to force evaluation there?). Without `unsafePerformIO` all > the sleeping is done up front, and all numbers are print at once at the > end. > > The goal is of course to use code along the same shape to do something more > useful, and then `unsafePerformIO` will really be unsafe... > > /M > > -- > Magnus Therning (OpenPGP: 0xAB4DFBA4) > magnus?therning?org Jabber: magnus?therning?org > http://therning.org/magnus identi.ca|twitter: magthe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From rendel at cs.au.dk Sun May 3 18:02:09 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Sun May 3 17:48:23 2009 Subject: [Haskell-cafe] Combining computations In-Reply-To: References: <169272.11504.qm@web31106.mail.mud.yahoo.com> <20090503110444.GA13354@kira.casa> Message-ID: <49FE1461.5050608@cs.au.dk> Claus Reinke wrote: >> mplus' :: MonadPlus m => Maybe a -> m a -> m a >> mplus' m l = maybeToMonad m `mplus` l >> >> maybeToMonad :: Monad m => Maybe a -> m a >> maybeToMonad = maybe (fail "Nothing") return >> >> In general, however, this operation can't be done. For example, >> how would you write: >> >> mplus' :: IO a -> [a] -> [a] > > Perhaps the question should be: is there an interesting structure > that would allow us to capture when this kind of merging Monads > is possible? For me, it seems that Foldable is the other side of Alternative. A functor F supports Alternative if (F a) supports a monoidal structure for the construction of values, and it supports Foldable if (F a) supports a monoidal structure for the decomposition of values. That means that we can give a translation from every Foldable functor to every Alternative functor as follows: foldable2alternative = foldr (<|>) empty . fmap pure Tillmann From ryani.spam at gmail.com Sun May 3 18:11:17 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sun May 3 17:56:49 2009 Subject: [Haskell-cafe] ST.Lazy vs ST.Strict In-Reply-To: <65c9dbea0905031027j60e08cefh162cb63b70c1c721@mail.gmail.com> References: <65c9dbea0905031027j60e08cefh162cb63b70c1c721@mail.gmail.com> Message-ID: <2f9b2d30905031511s347e2783vf2a2bcd24083d0de@mail.gmail.com> So, I don't know what is causing your problem, but foo will not do what you want even with lazy ST. foo y = do x <- something xs <- foo (y+1) return (x:xs) Desugaring: foo y = something >>= \x -> foo (y+1) >>= \xs -> return (x:xs) = something >>= \x -> something >>= \x2 -> foo (y+2) >>= \xs2 -> return (x2:xs2) >>= \xs -> return (x:xs) = something >>= \x -> something >>= \x2 -> foo (y+2) >>= \xs2 -> return (x:x2:xs2) You see that there is an infinite chain of "foo" calls; the lazy ST still needs to thread the state through that chain; so in the case of foo 0 >>= something_else, the state is _|_ for something_else and you will fail if you use read/write/newSTRef after that point. In fact, I'm not sure that lazy ST is very useful :) My guess is that you want one of (1) mdo, when the effects in 'something' only matter once, or (2) unsafeInterleaveST, if you just want to be able to traverse the (x:xs) list lazily and the references it uses are dead after calling foo. -- ryan On Sun, May 3, 2009 at 10:27 AM, Tobias Olausson wrote: > Hello! > I have a program that is using ST.Strict, which works fine. > However, the program needs to be extended, and to do that, > lazy evaluation is needed. As a result of that, I have switched > to ST.Lazy to be able to do stuff like > > foo y = do > ? ?x <- something > ? ?xs <- foo (y+1) > ? ?return (x:xs) > > However, when running the program compiled with ST.Lazy, the > following is outputted: > ? [tobsi@wobsi]$ ./runnerLazy looper.hex > ? runnerLazy: <> > > The very same program compiled with ST.Strict outputs: > ? [tobsi@wobsi]$ ./runner looper.hex > ? 83298556 > > The code that is actually computing stuff is this: > loopSys :: Int -> CPU s Int > loopSys cc = do > ? ?instr <- fetch > ? ?if instr == 0xEA --NOP > ? ? ? then return cc > ? ? ? else do > ? ? ? ? c <- execute instr > ? ? ? ? loopSys $! (cc+c) > > The CPU type looks as follows: > ? type CPU s a = ReaderT (SysEnv s) (ST s) a > > The program is run like > ? runReaderT (loopSys 0) > which in turn is being runST'd and then printed > > Does anyone know why the program just outputs <> > when compiled under ghc 6.10.2, and runs perfectly fine > under ghc 6.8.2? The program is compiled with --make and -O2 > > > Tobias Olausson > tobsan@gmail.com > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ryani.spam at gmail.com Sun May 3 18:28:58 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sun May 3 18:16:02 2009 Subject: [Haskell-cafe] StateT IO Action on `onKeyPress` In-Reply-To: <87hc021a2g.fsf@ubuntu.domain> References: <87hc021a2g.fsf@ubuntu.domain> Message-ID: <2f9b2d30905031528x470e632dm8e3110889d38d1e6@mail.gmail.com> Hi Andy. The GTK bindings use IO for their callbacks, not any custom monad like your WindowListT. I suggest, instead of StateT s IO a, you use ReaderT (IORef s) IO a: putR :: s -> ReaderT (IORef s) IO () putR s = do r <- ask liftIO $ writeIORef r s getR :: ReaderT (IORef s) IO s getR = ask >>= liftIO . readIORef Otherwise, there are techniques to use an IORef to hold onto the state while calling into IO (which might make callbacks), and then read it back out and put it in the state while running your action. But it's simpler to just switch to ReaderT -- ryan On Sun, May 3, 2009 at 8:27 AM, Andy Stewart wrote: > Hi all, > > I have a function named `keymapTest` need moand state WindowListT, and > WindowListT is `type WindowListT = StateT WindowList IO`. > > when i add "(\event -> keymapTest winList event >> return False)" after > `onKeyPress` for handle key press event, i got GHC error: > > Manatee.hs:57:58: > ? ?Couldn't match expected type `IO a' > ? ? ? ? ? against inferred type `WindowListT Bool' > ? ?In the first argument of `(>>)', namely `keymapTest winList event' > ? ?In the expression: keymapTest winList event >> return False > ? ?In the second argument of `onKeyPress', namely > ? ? ? ?`(\ event -> keymapTest winList event >> return False)' > > So function `onKeyPress` just accept *one* IO-action? > Have a way to fix above problem? > > Any help? > > Thanks! > > ?-- Andy > > Below is source code of Manatee.hs file. > > ------------------------------> Manatee.hs start ? <------------------------------ > module Main where > > import Text.Printf > import Data.Monoid > import Data.List > import Data.Maybe > import Control.Monad > import Control.Monad.State > import Control.Applicative > > import Data.IORef > > import Graphics.UI.Gtk hiding (Window, windowNew, get) > import Graphics.UI.Gtk.SourceView > import Graphics.UI.Gtk.Abstract.Widget > > import Manatee.Event > import Manatee.Buffer > import Manatee.WindowList > import Manatee.Pane > import Manatee.Statusbar > import Manatee.Utils > import Manatee.Window > > import qualified Data.Set as Set > import qualified Graphics.UI.Gtk.Windows.Window as W > import qualified Graphics.UI.Gtk.Gdk.Events as E > > main :: IO () > main = do > ?-- Init. > ?initGUI > > ?-- Root frame. > ?rootFrame <- W.windowNew > ?rootFrame `onDestroy` mainQuit ?-- quit main loop when root frame close > > ?-- Root frame status. > ?windowFullscreen rootFrame ? -- fullscreen > > ?-- Windows list. > ?let windowsList = WindowList 0 Set.empty > > ?evalStateT (do > ? ? ? ? ? ? ? -- Window 1 > ? ? ? ? ? ? ? window1 <- windowNewWithBuffer DTop "test" > ? ? ? ? ? ? ? liftIO $ containerAdd rootFrame $ windowPaned window1 > > ? ? ? ? ? ? ? (window2, window3) <- windowSplitVertically window1 > > ? ? ? ? ? ? ? (window4, window5) <- windowSplitHorizontally window3 > > ? ? ? ? ? ? ? winList <- windowListGetList > ? ? ? ? ? ? ? liftIO $ rootFrame `onKeyPress` (\event -> keymapTest winList event >> return False) > > ? ? ? ? ? ? ? -- Handle window content synchronous. > ? ? ? ? ? ? ? windowHandleSynchronous > ? ? ? ? ? ? ? ) windowsList > > ?-- Loop > ?widgetShowAll rootFrame ? ? ? -- display all widget > ?mainGUI > > keymapTest :: [Window] -> E.Event -> WindowListT Bool > keymapTest winList event = do > ?window <- liftIO $ windowFindFocus winList > ?case window of > ? ?Just x -> handleKeyPress x event > ? ?Nothing -> return False > > handleKeyPress :: Window -> E.Event -> WindowListT Bool > handleKeyPress window ev = do > ?liftIO $ > ? ? ? ? case eventTransform ev of > ? ? ? ? ? Nothing -> return False > ? ? ? ? ? Just e -> do > ? ? ? ? ? ? let display = statusbarOutputSubitemSetText $ paneStatusbar $ windowPane $ window > ? ? ? ? ? ? ? ? eventName = eventGetName e > ? ? ? ? ? ? case eventName of > ? ? ? ? ? ? ? ?-- Window commands. > ? ? ? ? ? ? ? ?"M-t" -> display "windowSplitVertically" > ? ? ? ? ? ? ? ?-- "M-t" -> windowSplitVertically window >> return False > ? ? ? ? ? ? ? ?_ -> display $ printf "%s undefined." eventName > ------------------------------> Manatee.hs end ? <------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From brian at lorf.org Sun May 3 18:36:07 2009 From: brian at lorf.org (brian@lorf.org) Date: Sun May 3 18:22:32 2009 Subject: [Haskell-cafe] converting IOException to Either in ErrorT Message-ID: <20090503223607.GB19506@doses> I wrote this to make it a little nicer to catch IO exceptions and convert them to ErrorT failure: onExceptionThrowError :: (Error ce) => IO a -> (String -> ce) -> ErrorT ce IO a onExceptionThrowError a ce = liftIO (try a) >>= either (\(e :: IOException) -> throwError (ce (show e))) return So now I can do, e.g., writeFile fp s `onExceptionThrowError` SpecificErrorConstructor ... It works, but seems bad. Please let me know if you see ways to improve it. Thanks. From dmehrtash at gmail.com Sun May 3 18:48:24 2009 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Sun May 3 18:35:22 2009 Subject: [Haskell-cafe] ANN: Silkworm game In-Reply-To: <98A96C9E-6685-4512-AB3B-50E3A1F39E91@gmail.com> References: <98A96C9E-6685-4512-AB3B-50E3A1F39E91@gmail.com> Message-ID: I noticed that Chipmunk also has a Ruby interface. Do you have any pro/con of implementing the game in Ruby vs Haskell? Thanks, Daryoush On Sat, May 2, 2009 at 12:00 PM, Duane Johnson wrote: > Reprinted from my blog post [1]: > > === > > The semester is over, my final project was a success (at least in that I > passed the class) and it?s time now to release the game I made for Graphics > 455: Silkworm! > > This is my first full application in Haskell. The process has been an > enlarging experience?I?ve come to really enjoy the mental work that goes > into thinking about a program in a functional way. I highly recommend the > challenge to other software engineers. > > Silkworm combines the Hipmunk binding to Chipmunk 2D Game Dynamics with > OpenGL, and GLFW (an alternative to GLUT). > > It?s built to work on Mac OS X, but it uses cross-platform libraries so it > should be fairly easy to port to other platforms. The source code is here > [2] and below are some screenshots [1] > > -- Duane Johnson > (canadaduane) > > === > > [1] > http://blog.inquirylabs.com/2009/05/02/silkworm-game-written-in-haskell/ > [2] > http://inquirylabs.com/downloads/Silkworm.tgz_______________________________________________ > 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/20090503/d94cd7a1/attachment.htm From es at ertes.de Sun May 3 18:57:17 2009 From: es at ertes.de (Ertugrul Soeylemez) Date: Sun May 3 18:43:54 2009 Subject: [Haskell-cafe] Re: Getting WriterT log lazily References: <49FE09D7.5090108@therning.org> Message-ID: <20090504005717.5ab0f5b6@tritium.xx> Hello Magnus, although your approach is a bit more pragmatic, I always prefer to use concurrency to implement predictable logging. This is a bit more code, but works much nicer and a lot more predictable: {-# LANGUAGE ExistentialQuantification #-} module Main where import Control.Concurrent import Control.Monad data LoggerMsg = forall a. Show a => LogLine a | QuitLogger (IO ()) main :: IO () main = do log <- newEmptyMVar forkIO $ forever $ do msg <- takeMVar log case msg of LogLine ln -> print ln QuitLogger c -> c >> myThreadId >>= killThread forM_ [1..10] $ putMVar log . LogLine waiter <- newEmptyMVar putMVar log $ QuitLogger (putMVar waiter ()) takeMVar waiter Whenever you put a LogLine message into the MVar, as soon as the putMVar action returns, it is guaranteed that the last log line has been processed. If you don't need that guarantee, use Chan instead of MVar. Greets, Ertugrul. Magnus Therning wrote: > I've been playing around with (WriterT [Int] IO), trying to get the > log out and map `print` over it... and do it lazily. However, I'm not > really happy with what I have so far, since I've had to resort to > `unsafePerformIO`. Any hints are welcome. > > What I have so far is: > > foo = let > _tell i = do > a <- return $ unsafePerformIO $ sleep 1 > tell [a + 1 `seq` i] > in do > mapM_ _tell [1..10] > > main = do > (_, ~res) <- runWriterT foo > mapM_ print res > > Without the `seq` the call to sleep will simply be skipped (is there > an easier way to force evaluation there?). Without `unsafePerformIO` > all the sleeping is done up front, and all numbers are print at once > at the end. > > The goal is of course to use code along the same shape to do something > more useful, and then `unsafePerformIO` will really be unsafe... -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/ From duane.johnson at gmail.com Sun May 3 19:10:56 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Sun May 3 18:56:47 2009 Subject: [Haskell-cafe] ANN: Silkworm game In-Reply-To: References: <98A96C9E-6685-4512-AB3B-50E3A1F39E91@gmail.com> Message-ID: <6350B72E-202D-444B-8287-388716002136@gmail.com> I'm not too much of an expert in Haskell, but I did notice that building the game required keeping track of a lot of state information, which was not very intuitive in Haskell (although the OpenGL state info is rather intuitive). If I were to do it in Haskell again, I would try to learn more about FRP (Functional Reactive Programming) and see if that improves things in terms of state. Ruby is my favorite imperative language, so I would certainly recommend it for game development. It would likely be much easier in Ruby, but perhaps a little slower. My experience with Ruby on Rails has been that it is always a little slower than I wish it were :) -- Duane On May 3, 2009, at 4:48 PM, Daryoush Mehrtash wrote: > I noticed that Chipmunk also has a Ruby interface. Do you have any > pro/con of implementing the game in Ruby vs Haskell? > > Thanks, > > Daryoush > > On Sat, May 2, 2009 at 12:00 PM, Duane Johnson > wrote: > Reprinted from my blog post [1]: > > === > > The semester is over, my final project was a success (at least in > that I passed the class) and it?s time now to release the game I > made for Graphics 455: Silkworm! > > This is my first full application in Haskell. The process has been > an enlarging experience?I?ve come to really enjoy the mental work > that goes into thinking about a program in a functional way. I > highly recommend the challenge to other software engineers. > > Silkworm combines the Hipmunk binding to Chipmunk 2D Game Dynamics > with OpenGL, and GLFW (an alternative to GLUT). > > It?s built to work on Mac OS X, but it uses cross-platform libraries > so it should be fairly easy to port to other platforms. The source > code is here [2] and below are some screenshots [1] > > -- Duane Johnson > (canadaduane) > > === > > [1] http://blog.inquirylabs.com/2009/05/02/silkworm-game-written-in-haskell/ > [2] http://inquirylabs.com/downloads/Silkworm.tgz_______________________________________________ > 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/20090503/2072ce55/attachment.htm From felipe.lessa at gmail.com Sun May 3 19:21:26 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sun May 3 19:08:07 2009 Subject: [Haskell-cafe] ANN: Silkworm game In-Reply-To: <200905031407.23483.Sven.Panne@aedion.de> References: <98A96C9E-6685-4512-AB3B-50E3A1F39E91@gmail.com> <200905031407.23483.Sven.Panne@aedion.de> Message-ID: <20090503232126.GA29549@kira.casa> On Sun, May 03, 2009 at 02:07:23PM +0200, Sven Panne wrote: > As a side note, I get a very bad feeling when Hipmunk gets compiled on my > x86_64 box: [...] > This can't be correct, but I'll probably have to take a look at that. Or is it > a know bug that Hipmunk ist not 64bit-clean? My machine is actually a x86_64, and I don't like those warnings as well :). Yes, it is a know bug in Chipmunk, but maybe it got corrected. One small problem with Chipmunk is that it is a moving target, so updating Hipmunk's Chipmunk library would require changing the bindings as well (AFAIK at least the joints code would have to be rewritten), and I don't know if there is a changelog specifying the changes (i.e. "read the diff" :). -- Felipe. From tobsan at gmail.com Sun May 3 19:54:49 2009 From: tobsan at gmail.com (Tobias Olausson) Date: Sun May 3 19:43:27 2009 Subject: [Haskell-cafe] ST.Lazy vs ST.Strict In-Reply-To: <2f9b2d30905031511s347e2783vf2a2bcd24083d0de@mail.gmail.com> References: <65c9dbea0905031027j60e08cefh162cb63b70c1c721@mail.gmail.com> <2f9b2d30905031511s347e2783vf2a2bcd24083d0de@mail.gmail.com> Message-ID: <65c9dbea0905031654m6550aa98v477643e5abbb4cf0@mail.gmail.com> Would unsafeInterleaveST work just as unsafeInterleaveIO in the manner that it returns immediately, and then is computed lazily? The idea in the complete program is that one part representing the CPU will produce a list lazily, which will then be consumed lazily by another part of the program, which in turn will produce a lazy list fed to the CPU. I might add that there was a base case for foo. It turns out i omitted that for "simplicity". Even stranger, if one adds the following foo y = do if something then return y else do val <- foo (y+1) fail "this is a fail" Will make the program fail with "this is a fail". Without the fail, that does not return the computed y. How come? //Tobias 2009/5/4 Ryan Ingram : > So, I don't know what is causing your problem, but foo will not do > what you want even with lazy ST. > > foo y = do > ? x <- something > ? xs <- foo (y+1) > ? return (x:xs) > > Desugaring: > > foo y = something >>= \x -> foo (y+1) >>= \xs -> return (x:xs) > = something >>= \x -> something >>= \x2 -> foo (y+2) >>= \xs2 -> > return (x2:xs2) >>= \xs -> return (x:xs) > = something >>= \x -> something >>= \x2 -> foo (y+2) >>= \xs2 -> > return (x:x2:xs2) > > You see that there is an infinite chain of "foo" calls; the lazy ST > still needs to thread the state through that chain; so in the case of > foo 0 >>= something_else, the state is _|_ for something_else and you > will fail if you use read/write/newSTRef after that point. ?In fact, > I'm not sure that lazy ST is very useful :) > > My guess is that you want one of > (1) mdo, when the effects in 'something' only matter once, or > (2) unsafeInterleaveST, if you just want to be able to traverse the > (x:xs) list lazily and the references it uses are dead after calling > foo. > > ?-- ryan > > On Sun, May 3, 2009 at 10:27 AM, Tobias Olausson wrote: >> Hello! >> I have a program that is using ST.Strict, which works fine. >> However, the program needs to be extended, and to do that, >> lazy evaluation is needed. As a result of that, I have switched >> to ST.Lazy to be able to do stuff like >> >> foo y = do >> ? ?x <- something >> ? ?xs <- foo (y+1) >> ? ?return (x:xs) >> >> However, when running the program compiled with ST.Lazy, the >> following is outputted: >> ? [tobsi@wobsi]$ ./runnerLazy looper.hex >> ? runnerLazy: <> >> >> The very same program compiled with ST.Strict outputs: >> ? [tobsi@wobsi]$ ./runner looper.hex >> ? 83298556 >> >> The code that is actually computing stuff is this: >> loopSys :: Int -> CPU s Int >> loopSys cc = do >> ? ?instr <- fetch >> ? ?if instr == 0xEA --NOP >> ? ? ? then return cc >> ? ? ? else do >> ? ? ? ? c <- execute instr >> ? ? ? ? loopSys $! (cc+c) >> >> The CPU type looks as follows: >> ? type CPU s a = ReaderT (SysEnv s) (ST s) a >> >> The program is run like >> ? runReaderT (loopSys 0) >> which in turn is being runST'd and then printed >> >> Does anyone know why the program just outputs <> >> when compiled under ghc 6.10.2, and runs perfectly fine >> under ghc 6.8.2? The program is compiled with --make and -O2 >> >> >> Tobias Olausson >> tobsan@gmail.com >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > -- Tobias Olausson tobsan@gmail.com From lazycat.manatee at gmail.com Sun May 3 20:38:26 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Sun May 3 20:55:55 2009 Subject: [Haskell-cafe] Re: StateT IO Action on `onKeyPress` References: <87hc021a2g.fsf@ubuntu.domain> <2f9b2d30905031528x470e632dm8e3110889d38d1e6@mail.gmail.com> Message-ID: <87y6tdzoql.fsf@ubuntu.domain> Ryan Ingram writes: Thank you very much! I try to use your solution to fix my problem. -- Andy > Hi Andy. > > The GTK bindings use IO for their callbacks, not any custom monad like > your WindowListT. > > I suggest, instead of StateT s IO a, you use ReaderT (IORef s) IO a: > > putR :: s -> ReaderT (IORef s) IO () > putR s = do > r <- ask > liftIO $ writeIORef r s > > getR :: ReaderT (IORef s) IO s > getR = ask >>= liftIO . readIORef > > Otherwise, there are techniques to use an IORef to hold onto the state > while calling into IO (which might make callbacks), and then read it > back out and put it in the state while running your action. But it's > simpler to just switch to ReaderT > > -- ryan > > On Sun, May 3, 2009 at 8:27 AM, Andy Stewart wrote: >> Hi all, >> >> I have a function named `keymapTest` need moand state WindowListT, and >> WindowListT is `type WindowListT = StateT WindowList IO`. >> >> when i add "(\event -> keymapTest winList event >> return False)" after >> `onKeyPress` for handle key press event, i got GHC error: >> >> Manatee.hs:57:58: >> ? ?Couldn't match expected type `IO a' >> ? ? ? ? ? against inferred type `WindowListT Bool' >> ? ?In the first argument of `(>>)', namely `keymapTest winList event' >> ? ?In the expression: keymapTest winList event >> return False >> ? ?In the second argument of `onKeyPress', namely >> ? ? ? ?`(\ event -> keymapTest winList event >> return False)' >> >> So function `onKeyPress` just accept *one* IO-action? >> Have a way to fix above problem? >> >> Any help? >> >> Thanks! >> >> ?-- Andy >> >> Below is source code of Manatee.hs file. >> >> ------------------------------> Manatee.hs start ? <------------------------------ >> module Main where >> >> import Text.Printf >> import Data.Monoid >> import Data.List >> import Data.Maybe >> import Control.Monad >> import Control.Monad.State >> import Control.Applicative >> >> import Data.IORef >> >> import Graphics.UI.Gtk hiding (Window, windowNew, get) >> import Graphics.UI.Gtk.SourceView >> import Graphics.UI.Gtk.Abstract.Widget >> >> import Manatee.Event >> import Manatee.Buffer >> import Manatee.WindowList >> import Manatee.Pane >> import Manatee.Statusbar >> import Manatee.Utils >> import Manatee.Window >> >> import qualified Data.Set as Set >> import qualified Graphics.UI.Gtk.Windows.Window as W >> import qualified Graphics.UI.Gtk.Gdk.Events as E >> >> main :: IO () >> main = do >> ?-- Init. >> ?initGUI >> >> ?-- Root frame. >> ?rootFrame <- W.windowNew >> ?rootFrame `onDestroy` mainQuit ?-- quit main loop when root frame close >> >> ?-- Root frame status. >> ?windowFullscreen rootFrame ? -- fullscreen >> >> ?-- Windows list. >> ?let windowsList = WindowList 0 Set.empty >> >> ?evalStateT (do >> ? ? ? ? ? ? ? -- Window 1 >> ? ? ? ? ? ? ? window1 <- windowNewWithBuffer DTop "test" >> ? ? ? ? ? ? ? liftIO $ containerAdd rootFrame $ windowPaned window1 >> >> ? ? ? ? ? ? ? (window2, window3) <- windowSplitVertically window1 >> >> ? ? ? ? ? ? ? (window4, window5) <- windowSplitHorizontally window3 >> >> ? ? ? ? ? ? ? winList <- windowListGetList >> ? ? ? ? ? ? ? liftIO $ rootFrame `onKeyPress` (\event -> keymapTest winList event >> return False) >> >> ? ? ? ? ? ? ? -- Handle window content synchronous. >> ? ? ? ? ? ? ? windowHandleSynchronous >> ? ? ? ? ? ? ? ) windowsList >> >> ?-- Loop >> ?widgetShowAll rootFrame ? ? ? -- display all widget >> ?mainGUI >> >> keymapTest :: [Window] -> E.Event -> WindowListT Bool >> keymapTest winList event = do >> ?window <- liftIO $ windowFindFocus winList >> ?case window of >> ? ?Just x -> handleKeyPress x event >> ? ?Nothing -> return False >> >> handleKeyPress :: Window -> E.Event -> WindowListT Bool >> handleKeyPress window ev = do >> ?liftIO $ >> ? ? ? ? case eventTransform ev of >> ? ? ? ? ? Nothing -> return False >> ? ? ? ? ? Just e -> do >> ? ? ? ? ? ? let display = statusbarOutputSubitemSetText $ paneStatusbar $ windowPane $ window >> ? ? ? ? ? ? ? ? eventName = eventGetName e >> ? ? ? ? ? ? case eventName of >> ? ? ? ? ? ? ? ?-- Window commands. >> ? ? ? ? ? ? ? ?"M-t" -> display "windowSplitVertically" >> ? ? ? ? ? ? ? ?-- "M-t" -> windowSplitVertically window >> return False >> ? ? ? ? ? ? ? ?_ -> display $ printf "%s undefined." eventName >> ------------------------------> Manatee.hs end ? <------------------------------ >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> From dave at zednenem.com Mon May 4 00:38:34 2009 From: dave at zednenem.com (David Menendez) Date: Mon May 4 00:32:44 2009 Subject: [Haskell-cafe] ST.Lazy vs ST.Strict In-Reply-To: <2f9b2d30905031511s347e2783vf2a2bcd24083d0de@mail.gmail.com> References: <65c9dbea0905031027j60e08cefh162cb63b70c1c721@mail.gmail.com> <2f9b2d30905031511s347e2783vf2a2bcd24083d0de@mail.gmail.com> Message-ID: <49a77b7a0905032138g33cdb1can2b7a02ea200d2db8@mail.gmail.com> On Sun, May 3, 2009 at 6:11 PM, Ryan Ingram wrote: > So, I don't know what is causing your problem, but foo will not do > what you want even with lazy ST. That depends on what he wants to do. As long as nothing subsequent to the call to foo tries to read a reference, then foo is fine. For example, this works fine: bar r = do x <- readSTRef r writeSTRef $! x + 1 return x > take 10 $ runST (newSTRef 0 >>= \r -> sequence (repeat (bar r))) [0,1,2,3,4,5,6,7,8,9] >> Does anyone know why the program just outputs <> >> when compiled under ghc 6.10.2, and runs perfectly fine >> under ghc 6.8.2? The program is compiled with --make and -O2 As I understand it, you get <> when the RTS detects a thunk which depends on itself, which can happen if you're trying to do a strict computation lazily. I can't imagine why different versions of GHC would give different results, though. -- Dave Menendez From dave at zednenem.com Mon May 4 00:52:04 2009 From: dave at zednenem.com (David Menendez) Date: Mon May 4 00:49:30 2009 Subject: [Haskell-cafe] ST.Lazy vs ST.Strict In-Reply-To: <65c9dbea0905031654m6550aa98v477643e5abbb4cf0@mail.gmail.com> References: <65c9dbea0905031027j60e08cefh162cb63b70c1c721@mail.gmail.com> <2f9b2d30905031511s347e2783vf2a2bcd24083d0de@mail.gmail.com> <65c9dbea0905031654m6550aa98v477643e5abbb4cf0@mail.gmail.com> Message-ID: <49a77b7a0905032152j39a08871me99463366b3c1488@mail.gmail.com> On Sun, May 3, 2009 at 7:54 PM, Tobias Olausson wrote: > Would unsafeInterleaveST work just as unsafeInterleaveIO in the manner > that it returns immediately, and then is computed lazily? > The idea in the complete program is that one part representing > the CPU will produce a list lazily, which will then be consumed > lazily by another part of the program, which in turn will produce > a lazy list fed to the CPU. Like co-routines? It might be possible to do this with non-strict ST, but it feels like it would be tricky to get right. How are you feeding the lists from the two computations together? Are they computed in the same ST thread? > I might add that there was a base case for foo. It turns out i omitted > that for "simplicity". Even stranger, if one adds the following > > foo y = do > ? ?if something then return y > ? ?else do > ? ? ? val <- foo (y+1) > ? ? ? fail "this is a fail" > > Will make the program fail with "this is a fail". Without the fail, that > does not return the computed y. How come? In the non-strict ST monad, the recursive call to foo does not get evaluated until forced by an evaluation of val. That particular version would work identically if you replaced the recursive call to foo with "undefined". -- Dave Menendez From dave at zednenem.com Mon May 4 01:05:56 2009 From: dave at zednenem.com (David Menendez) Date: Mon May 4 00:59:34 2009 Subject: [Haskell-cafe] converting IOException to Either in ErrorT In-Reply-To: <20090503223607.GB19506@doses> References: <20090503223607.GB19506@doses> Message-ID: <49a77b7a0905032205wade207bo73f3e7a2ab6765bf@mail.gmail.com> On Sun, May 3, 2009 at 6:36 PM, wrote: > I wrote this to make it a little nicer to catch IO exceptions and > convert them to ErrorT failure: > > onExceptionThrowError > ?:: (Error ce) => > ? ? IO a > ?-> (String -> ce) > ?-> ErrorT ce IO a > onExceptionThrowError a ce = > ? ?liftIO (try a) >>= > ? ? ?either > ? ? ? ?(\(e :: IOException) -> throwError (ce (show e))) > ? ? ? ?return > > So now I can do, e.g., > writeFile fp s `onExceptionThrowError` SpecificErrorConstructor ... > > It works, but seems bad. Please let me know if you see ways to improve > it. Thanks. What about this? liftCatch :: (IOException -> e) -> IO a -> ErrorT e IO a liftCatch f m = ErrorT $ liftM (either (Left . f) Right) (try m) -- Dave Menendez From martijn at van.steenbergen.nl Mon May 4 03:48:16 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Mon May 4 03:53:27 2009 Subject: [Haskell-cafe] Getting WriterT log lazily In-Reply-To: <49FE09D7.5090108@therning.org> References: <49FE09D7.5090108@therning.org> Message-ID: <49FE9DC0.9060201@van.steenbergen.nl> Magnus Therning wrote: > Without the `seq` the call to sleep will simply be skipped (is there an > easier way to force evaluation there?). Without `unsafePerformIO` all > the sleeping is done up front, and all numbers are print at once at the > end. > > The goal is of course to use code along the same shape to do something > more useful, and then `unsafePerformIO` will really be unsafe... So what you're trying to do is run two IO actions at the same time: one to produce values, the other to consume values. If you want to be really safe use threads (does that sound paradoxical?), as Ertegrul suggested, although I'd use channels instead of an MVar since this seems to be a perfect example for them. Otherwise, you can use unsafeInterleaveIO: no unsafePerformIO or seq needed, but there's still "unsafe" in that name there. This works for me: > foo :: WriterT [Int] IO () > foo = let > _tell i = do > a <- lift $ unsafeInterleaveIO $ threadDelay 100000 >> return 0 > tell [i + a] > in do > mapM_ _tell [1..10] Martijn. From jekor at jekor.com Mon May 4 03:45:30 2009 From: jekor at jekor.com (Chris Forno) Date: Mon May 4 03:53:39 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) Message-ID: <87fxfll3ad.fsf@forno.us> I decided to find out for myself. You can find the results at http://jekor.com/article/is-haskell-a-good-choice-for-web-applications Included is the source code for the web application powering http://www.vocabulink.com/ The source is roughly 2,000 lines of Haskell, along with some SQL and JavaScript. It's written in literate style and includes a 75-page PDF. It demonstrates and explains how to: * use FastCGI to communicate with a web server (nginx in this case) * move data to and from a PostgreSQL database (HDBC) * authenticate users with cookies * interact with users via asynchronous JavaScript and JSON (AJAJ) * collect data with HTML forms (formlets) * communicate with users via email * cache with memcached * implement a custom forums system (with threaded comments) I make no claims that the code is elegant or idiomatic. It is however real code that's running "in the wild". And I hope it's useful to anyone else considering doing web development in Haskell. I welcome and encourage your feedback! From martijn at van.steenbergen.nl Mon May 4 03:55:51 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Mon May 4 04:05:39 2009 Subject: [Haskell-cafe] Foldable for BNFC generated tree In-Reply-To: <7b501d5c0905031147n24a5ec46jea3926da78d61498@mail.gmail.com> References: <7b501d5c0905031147n24a5ec46jea3926da78d61498@mail.gmail.com> Message-ID: <49FE9F87.6020208@van.steenbergen.nl> Hi Deniz, Deniz Dogan wrote: > So, basically I'd like some sort of folding functionality for these > data types, without having to hack the lexer/parser myself > (parameterising the data types), because as I said they're being > generated by BNFC. What exactly do you mean by folding functionality? Folding as in the Foldable type class applies to containers, which your data type isn't. Perhaps you're looking for generic programming? There are several good GP libraries out there: * EMGM: http://www.cs.uu.nl/wiki/GenericProgramming/EMGM * Uniplate: http://community.haskell.org/~ndm/uniplate/ * SYB: http://www.cs.vu.nl/boilerplate/ See also Neil Mitchell's blog for some examples: http://neilmitchell.blogspot.com/2009/03/concise-generic-queries.html HTH, Martijn. From lazycat.manatee at gmail.com Mon May 4 04:02:16 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Mon May 4 04:16:06 2009 Subject: [Haskell-cafe] Re: StateT IO Action on `onKeyPress` References: <87hc021a2g.fsf@ubuntu.domain> <2f9b2d30905031528x470e632dm8e3110889d38d1e6@mail.gmail.com> Message-ID: <87d4api9dj.fsf@ubuntu.domain> Hi Ryan, Ryan Ingram writes: > Hi Andy. > > The GTK bindings use IO for their callbacks, not any custom monad like > your WindowListT. > > I suggest, instead of StateT s IO a, you use ReaderT (IORef s) IO a: > > putR :: s -> ReaderT (IORef s) IO () > putR s = do > r <- ask > liftIO $ writeIORef r s > > getR :: ReaderT (IORef s) IO s > getR = ask >>= liftIO . readIORef > > Otherwise, there are techniques to use an IORef to hold onto the state > while calling into IO (which might make callbacks), and then read it > back out and put it in the state while running your action. But it's > simpler to just switch to ReaderT I'm curious another techniques that use IORef hold on state. Can you implement a simple example that make my code pass `onKeyPress`? Thanks! -- Andy > > -- ryan > > On Sun, May 3, 2009 at 8:27 AM, Andy Stewart wrote: >> Hi all, >> >> I have a function named `keymapTest` need moand state WindowListT, and >> WindowListT is `type WindowListT = StateT WindowList IO`. >> >> when i add "(\event -> keymapTest winList event >> return False)" after >> `onKeyPress` for handle key press event, i got GHC error: >> >> Manatee.hs:57:58: >> ? ?Couldn't match expected type `IO a' >> ? ? ? ? ? against inferred type `WindowListT Bool' >> ? ?In the first argument of `(>>)', namely `keymapTest winList event' >> ? ?In the expression: keymapTest winList event >> return False >> ? ?In the second argument of `onKeyPress', namely >> ? ? ? ?`(\ event -> keymapTest winList event >> return False)' >> >> So function `onKeyPress` just accept *one* IO-action? >> Have a way to fix above problem? >> >> Any help? >> >> Thanks! >> >> ?-- Andy >> >> Below is source code of Manatee.hs file. >> >> ------------------------------> Manatee.hs start ? <------------------------------ >> module Main where >> >> import Text.Printf >> import Data.Monoid >> import Data.List >> import Data.Maybe >> import Control.Monad >> import Control.Monad.State >> import Control.Applicative >> >> import Data.IORef >> >> import Graphics.UI.Gtk hiding (Window, windowNew, get) >> import Graphics.UI.Gtk.SourceView >> import Graphics.UI.Gtk.Abstract.Widget >> >> import Manatee.Event >> import Manatee.Buffer >> import Manatee.WindowList >> import Manatee.Pane >> import Manatee.Statusbar >> import Manatee.Utils >> import Manatee.Window >> >> import qualified Data.Set as Set >> import qualified Graphics.UI.Gtk.Windows.Window as W >> import qualified Graphics.UI.Gtk.Gdk.Events as E >> >> main :: IO () >> main = do >> ?-- Init. >> ?initGUI >> >> ?-- Root frame. >> ?rootFrame <- W.windowNew >> ?rootFrame `onDestroy` mainQuit ?-- quit main loop when root frame close >> >> ?-- Root frame status. >> ?windowFullscreen rootFrame ? -- fullscreen >> >> ?-- Windows list. >> ?let windowsList = WindowList 0 Set.empty >> >> ?evalStateT (do >> ? ? ? ? ? ? ? -- Window 1 >> ? ? ? ? ? ? ? window1 <- windowNewWithBuffer DTop "test" >> ? ? ? ? ? ? ? liftIO $ containerAdd rootFrame $ windowPaned window1 >> >> ? ? ? ? ? ? ? (window2, window3) <- windowSplitVertically window1 >> >> ? ? ? ? ? ? ? (window4, window5) <- windowSplitHorizontally window3 >> >> ? ? ? ? ? ? ? winList <- windowListGetList >> ? ? ? ? ? ? ? liftIO $ rootFrame `onKeyPress` (\event -> keymapTest winList event >> return False) >> >> ? ? ? ? ? ? ? -- Handle window content synchronous. >> ? ? ? ? ? ? ? windowHandleSynchronous >> ? ? ? ? ? ? ? ) windowsList >> >> ?-- Loop >> ?widgetShowAll rootFrame ? ? ? -- display all widget >> ?mainGUI >> >> keymapTest :: [Window] -> E.Event -> WindowListT Bool >> keymapTest winList event = do >> ?window <- liftIO $ windowFindFocus winList >> ?case window of >> ? ?Just x -> handleKeyPress x event >> ? ?Nothing -> return False >> >> handleKeyPress :: Window -> E.Event -> WindowListT Bool >> handleKeyPress window ev = do >> ?liftIO $ >> ? ? ? ? case eventTransform ev of >> ? ? ? ? ? Nothing -> return False >> ? ? ? ? ? Just e -> do >> ? ? ? ? ? ? let display = statusbarOutputSubitemSetText $ paneStatusbar $ windowPane $ window >> ? ? ? ? ? ? ? ? eventName = eventGetName e >> ? ? ? ? ? ? case eventName of >> ? ? ? ? ? ? ? ?-- Window commands. >> ? ? ? ? ? ? ? ?"M-t" -> display "windowSplitVertically" >> ? ? ? ? ? ? ? ?-- "M-t" -> windowSplitVertically window >> return False >> ? ? ? ? ? ? ? ?_ -> display $ printf "%s undefined." eventName >> ------------------------------> Manatee.hs end ? <------------------------------ >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> From ndmitchell at gmail.com Mon May 4 04:11:49 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon May 4 04:16:09 2009 Subject: [Haskell-cafe] Research in functional programming In-Reply-To: References: Message-ID: <404396ef0905040111w19893315kf52e2b7180ddf974@mail.gmail.com> Hi http://www.haskell.org/haskell-symposium/2009/ And you've got til Friday! Thanks, Neil On Sun, May 3, 2009 at 10:13 PM, Louis Wasserman wrote: > Where might I find or submit a paper on functional data structures? > Examples I've found so far include ICFP and the JFP, but Google hasn't found > me anything else. > > Louis Wasserman > wasserman.louis@gmail.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From brian at lorf.org Mon May 4 04:19:12 2009 From: brian at lorf.org (brian@lorf.org) Date: Mon May 4 04:26:25 2009 Subject: [Haskell-cafe] *system*-time timeout? Message-ID: <20090504081912.GC19506@doses> System.Timeout.timeout is OK for wall clock time, but can I limit the amount of system time an IO action can take? From martijn at van.steenbergen.nl Mon May 4 05:01:21 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Mon May 4 05:05:18 2009 Subject: [Haskell-cafe] instance Monad (Except err) Message-ID: <49FEAEE1.7060304@van.steenbergen.nl> Hello, Mr. McBride and mr. Paterson define in their Applicative paper: > data Except e a = OK a | Failed e > instance Monoid e => Applicative (Except e) where ... Sometimes I'd still like to use >>= on Excepts but this "feels" wrong somehow, because it doesn't use monoids nicely like the Applicative instance does. Are there any good reasons such a Monad instance shouldn't be defined? Does it violate any laws, for example? Thanks, Martijn. From magnus at therning.org Mon May 4 05:13:48 2009 From: magnus at therning.org (Magnus Therning) Date: Mon May 4 05:17:08 2009 Subject: [Haskell-cafe] Getting WriterT log lazily In-Reply-To: <49FE9DC0.9060201@van.steenbergen.nl> References: <49FE09D7.5090108@therning.org> <49FE9DC0.9060201@van.steenbergen.nl> Message-ID: <49FEB1CC.5030501@therning.org> Martijn van Steenbergen wrote: > Magnus Therning wrote: >> Without the `seq` the call to sleep will simply be skipped (is there an >> easier way to force evaluation there?). Without `unsafePerformIO` all >> the sleeping is done up front, and all numbers are print at once at the >> end. >> >> The goal is of course to use code along the same shape to do something >> more useful, and then `unsafePerformIO` will really be unsafe... > > So what you're trying to do is run two IO actions at the same time: one > to produce values, the other to consume values. > > If you want to be really safe use threads (does that sound > paradoxical?), as Ertegrul suggested, although I'd use channels instead > of an MVar since this seems to be a perfect example for them. > > Otherwise, you can use unsafeInterleaveIO: no unsafePerformIO or seq > needed, but there's still "unsafe" in that name there. This works for me: > >> foo :: WriterT [Int] IO () >> foo = let >> _tell i = do >> a <- lift $ unsafeInterleaveIO $ threadDelay 100000 >> >> return 0 >> tell [i + a] >> in do >> mapM_ _tell [1..10] Thanks, that does indeed work, but it still requires that "unsafe" there so I'm hesitant replacing the call to threadDelay with something more complicated, where it isn't obviously safe. Indeed, I think I'll go for the MVar or possibly a Chan. Thanks for the help. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090504/e6f0efcf/signature.bin From tonymorris at gmail.com Mon May 4 05:22:04 2009 From: tonymorris at gmail.com (Tony Morris) Date: Mon May 4 05:32:38 2009 Subject: [Haskell-cafe] instance Monad (Except err) In-Reply-To: <49FEAEE1.7060304@van.steenbergen.nl> References: <49FEAEE1.7060304@van.steenbergen.nl> Message-ID: <49FEB3BC.4010307@gmail.com> Martijn van Steenbergen wrote: > Hello, > > Mr. McBride and mr. Paterson define in their Applicative paper: > >> data Except e a = OK a | Failed e >> instance Monoid e => Applicative (Except e) where ... > > Sometimes I'd still like to use >>= on Excepts but this "feels" wrong > somehow, because it doesn't use monoids nicely like the Applicative > instance does. Are there any good reasons such a Monad instance > shouldn't be defined? Does it violate any laws, for example? > > Thanks, > > Martijn. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > I'm sure you could, but then ap /= (<*>). This seems related to a question that I once asked http://www.haskell.org/pipermail/haskell-cafe/2009-January/054139.html -- Tony Morris http://tmorris.net/ From Malcolm.Wallace at cs.york.ac.uk Mon May 4 05:32:58 2009 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Mon May 4 05:49:48 2009 Subject: [Haskell-cafe] Research in functional programming In-Reply-To: References: Message-ID: <20090504103258.11e56750.Malcolm.Wallace@cs.york.ac.uk> Louis Wasserman wrote: > Where might I find or submit a paper on functional data structures? > Examples I've found so far include ICFP > and the JFP > , but > Google hasn't found me anything else. See also the annual workshops IFL - Implementation and Application of Functional Languages TFP - Trends in Functional Programming PADL - Practical Aspects of Declarative Languages Regards, Malcolm From nccb2 at kent.ac.uk Mon May 4 05:37:50 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Mon May 4 05:50:19 2009 Subject: [Haskell-cafe] instance Monad (Except err) In-Reply-To: <49FEAEE1.7060304@van.steenbergen.nl> References: <49FEAEE1.7060304@van.steenbergen.nl> Message-ID: <49FEB76E.2020308@kent.ac.uk> Martijn van Steenbergen wrote: > Hello, > > Mr. McBride and mr. Paterson define in their Applicative paper: > >> data Except e a = OK a | Failed e >> instance Monoid e => Applicative (Except e) where ... > > Sometimes I'd still like to use >>= on Excepts but this "feels" wrong > somehow, because it doesn't use monoids nicely like the Applicative > instance does. Are there any good reasons such a Monad instance > shouldn't be defined? Does it violate any laws, for example? Isn't the Except type just Either by another name? OK = Right, Failed = Left. Therefore the monad is just the same as the Either monad, and is useful as an error monad: instance Monad (Except e) where (OK x) >>= f = f x Failed e >>= _ = Failed e return = OK This obeys all the monad laws. Thanks, Neil. From daniel.carrera at theingots.org Mon May 4 05:51:29 2009 From: daniel.carrera at theingots.org (Daniel Carrera) Date: Mon May 4 06:06:44 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <87fxfll3ad.fsf@forno.us> References: <87fxfll3ad.fsf@forno.us> Message-ID: <49FEBAA1.5060205@theingots.org> Hi Chris, Thanks. This should be interesting. I currently work as a web developer and I've been wondering how easy or hard it would be to develop web applications with Haskell. So I'll be interested in reading our article. On a separate topic, I also took a glance at vocabulink.com. I'm interested in languages (I am fluent in English and Spanish and speak "advanced" German). I will have to disagree a bit with your pedagogy: 1) You say that grammar doesn't matter. Well, for some languages it matters more than others. German, for example, has a very particular word order that takes some effort to learn, and if you get it wrong people really won't understand you. In German it's ok if you conjugate wrong, but it's not ok if you put words in the wrong place. Second, some people actually enjoy grammar better and find that grammar helps them understand the language. I am one of those people. Different people learn differently. I learn rules more easily than disconnected words. When I learn vocabulary I do better by learning word families, and so on. The Germanic languages rely heavily in word derivation (not so much English) so that can be important for learners like me. 2) Your analysis of word count is flawed. Sure, most of the words you read come from a very small vocabulary set, but most of the *meaning* in a sentence comes from the more obscure words. Imagine that you read this sentence: "In the newspaper I read that the __________ said that the problem is that the river has too much ________ ". In this sentence you can understand 90% of the words, but you have almost no idea of what's happening. What your word count test really shows is that human languages have a lot of redundancy. You could omit the word "the" from the above sentence and you would understand it almost as well. The word "the" is common and contains very little information. That said, do you have any stories in German? I can't figure out where to get the stories. Daniel. Chris Forno wrote: > I decided to find out for myself. You can find the results at > http://jekor.com/article/is-haskell-a-good-choice-for-web-applications > > Included is the source code for the web application powering > http://www.vocabulink.com/ > > The source is roughly 2,000 lines of Haskell, along with some SQL and > JavaScript. It's written in literate style and includes a 75-page PDF. > It demonstrates and explains how to: > > * use FastCGI to communicate with a web server (nginx in this case) > * move data to and from a PostgreSQL database (HDBC) > * authenticate users with cookies > * interact with users via asynchronous JavaScript and JSON (AJAJ) > * collect data with HTML forms (formlets) > * communicate with users via email > * cache with memcached > * implement a custom forums system (with threaded comments) > > I make no claims that the code is elegant or idiomatic. It is however > real code that's running "in the wild". And I hope it's useful to anyone > else considering doing web development in Haskell. > > I welcome and encourage your feedback! > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From paolo.losi at gmail.com Mon May 4 06:05:44 2009 From: paolo.losi at gmail.com (Paolo Losi) Date: Mon May 4 06:23:53 2009 Subject: [Haskell-cafe] Interesting Thread on OO Usefulness (scala mailing list) Message-ID: Hi all, I'm following an interesting thread on the scala mailing list: http://www.nabble.com/-scala--usefulness-of-OOP-td23268250.html Martin Odersky advocates the OO features of the scala language proposing an interesting problem where the OO approach seams valuable. I would be very much interested in seeing an Haskell solution to that problem. Any haskell guru want to take a stub at it or give an opinion from a pure FP point of view? Thanks Paolo From paolo.losi at gmail.com Mon May 4 06:19:13 2009 From: paolo.losi at gmail.com (Paolo Losi) Date: Mon May 4 06:43:24 2009 Subject: [Haskell-cafe] Thread on scala ml: Usefulness of OOP Message-ID: <2af4014d0905040319l4ea22fe0v732bf3df7b426e5c@mail.gmail.com> Hi all, I'd like to mention an interesting thread on the scala mailing list about usefulness of OOP. http://www.nabble.com/-scala--usefulness-of-OOP-td23268250.html Martin Odersky, scala creator, advocates the use of OOP using an interesting toy problem. I would be very interested about the haskell point of view on the topic. Is there any haskell guru that wants to take a stub at the problem or give his opinion? Thanks Paolo From g9ks157k at acme.softbase.org Mon May 4 06:51:16 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Mon May 4 07:04:11 2009 Subject: [Haskell-cafe] When is it OK to create a new mailing list? In-Reply-To: <1241266302.4314.15.camel@supermule.opasia.dk> References: <1241266302.4314.15.camel@supermule.opasia.dk> Message-ID: <200905041251.16492.g9ks157k@acme.softbase.org> Am Samstag, 2. Mai 2009 14:11 schrieb Mads Lindstr?m: > Hi > > I wanted a mailing list for my project WxGeneric and I am wondering when > it is OK to do so? How big must the potential audience be? Is there any > kind of etiquette or guidelines? > > Here http://haskell.org/mailman/admin it says that I must have "the > proper authority" to create a mailing list. What is meant by "proper > authority"? Can I just try to create one and see if I am successful? Or > must I request someone to do it? Hello, I think there are two Mailmans on haskell.org. The page refers to the one which hosts haskell-cafe, ghc-users, etc. The other one hosts the mailing lists of projects.haskell.org. You can host relatively small projects on projects.haskell.org and you can create a mailing list for each of them. So maybe projects.haskell.org is the way to go for you? Best wishes, Wolfgang From g9ks157k at acme.softbase.org Mon May 4 07:00:11 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Mon May 4 07:25:02 2009 Subject: [Haskell-cafe] Research in functional programming In-Reply-To: <20090504103258.11e56750.Malcolm.Wallace@cs.york.ac.uk> References: <20090504103258.11e56750.Malcolm.Wallace@cs.york.ac.uk> Message-ID: <200905041300.11834.g9ks157k@acme.softbase.org> Am Montag, 4. Mai 2009 11:32 schrieb Malcolm Wallace: > TFP - Trends in Functional Programming Deadline on sunday. Best wishes, Wolfgang From g9ks157k at acme.softbase.org Mon May 4 07:01:05 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Mon May 4 07:25:24 2009 Subject: [Haskell-cafe] Research in functional programming In-Reply-To: References: Message-ID: <200905041301.06072.g9ks157k@acme.softbase.org> Am Sonntag, 3. Mai 2009 23:13 schrieb Louis Wasserman: > Where might I find or submit a paper on functional data structures? > Examples I've found so far include ICFP > and the JFP , > but Google hasn't found me anything else. > > Louis Wasserman > wasserman.louis@gmail.com Have a look at . Best wishes, Wolfgang From djd at comp.leeds.ac.uk Mon May 4 07:33:33 2009 From: djd at comp.leeds.ac.uk (David Duke) Date: Mon May 4 07:50:03 2009 Subject: [Haskell-cafe] Decoupling OpenAL/ALUT packages from OpenGL In-Reply-To: <200905031244.04713.Sven.Panne@aedion.de> References: <49FCCF80.3080600@rwth-aachen.de> <200905031244.04713.Sven.Panne@aedion.de> Message-ID: <49FED28D.4060307@comp.leeds.ac.uk> Sven, Decoupling basic primitives for geometric modelling from OpenGL would be useful. For our work on data visualization (www.comp.leeds.ac.uk/funvis/) we introduced our own coordinate primitives for 2D and 3D (Coord2D and Coord3D), along with a simple typeclass for vector-like operations. As with HOpenGL, the constructors are strict. In addition to abstracting from spatial dimension, we were also thinking about different coordinate systems, e.g. polar, spherical, although we never developed this direction. > Nevertheless, I'd be happy to see some proposals for a sensible, compact > vector math package. Probably we can fulfill most of the common use cases with > something simple. > Even just data constructors and instances of these within Functor and Applicative are a useful starting point. If you wanted a type class to support vector maths, most of the standard graphics texts have an annex on vector operations; if your aim is a compact set of operations sufficient for OpenGL/AL, these would seem a sensible starting point - happy to summarise the contents of the texts on my shelf, but I doubt the list is surprising. regards, David -- Dr. David Duke E: djd@comp.leeds.ac.uk School of Computing W: www.comp.leeds.ac.uk/djd/ University of Leeds T: +44 113 3436800 Leeds, LS2 9JT, U.K. From bulat.ziganshin at gmail.com Mon May 4 07:35:50 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon May 4 08:12:17 2009 Subject: [Haskell-cafe] Interesting Thread on OO Usefulness (scala mailing list) In-Reply-To: References: Message-ID: <1634993073.20090504153550@gmail.com> Hello Paolo, Monday, May 4, 2009, 2:05:44 PM, you wrote: > Martin Odersky advocates the OO features of the scala language > proposing an interesting problem where the OO approach seams > valuable. i know two problems in Haskell/GHC that require OO-loke features - extensible exceptions and GUI widget types hierarchy -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From duncan.coutts at worc.ox.ac.uk Mon May 4 07:42:11 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon May 4 08:12:36 2009 Subject: [Haskell-cafe] When is it OK to create a new mailing list? In-Reply-To: <200905041251.16492.g9ks157k@acme.softbase.org> References: <1241266302.4314.15.camel@supermule.opasia.dk> <200905041251.16492.g9ks157k@acme.softbase.org> Message-ID: <1241437331.7387.179.camel@localhost> On Mon, 2009-05-04 at 12:51 +0200, Wolfgang Jeltsch wrote: > Am Samstag, 2. Mai 2009 14:11 schrieb Mads Lindstr?m: > > Hi > > > > I wanted a mailing list for my project WxGeneric and I am wondering when > > it is OK to do so? How big must the potential audience be? Is there any > > kind of etiquette or guidelines? > > > > Here http://haskell.org/mailman/admin it says that I must have "the > > proper authority" to create a mailing list. What is meant by "proper > > authority"? Can I just try to create one and see if I am successful? Or > > must I request someone to do it? > > Hello, > > I think there are two Mailmans on haskell.org. The page > refers to the one which hosts > haskell-cafe, ghc-users, etc. The other one hosts the mailing lists of > projects.haskell.org. > > You can host relatively small projects on projects.haskell.org and you can > create a mailing list for each of them. So maybe projects.haskell.org is the > way to go for you? Yes, I would recommend for smaller project-specific mailing lists that you take advantage of the community server which is set up for this purpose. We provide code hosting, project webspace, shell access, trac instances and mailing lists. You can pick and choose, you don't need to use all of them. See http://community.haskell.org/ Duncan From wagner.andrew at gmail.com Mon May 4 07:46:06 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Mon May 4 08:12:43 2009 Subject: [Haskell-cafe] Interesting Thread on OO Usefulness (scala mailing list) In-Reply-To: References: Message-ID: This sounds like a really interesting question. To save some people weeding through the thread and Jon Harrop's usual trolling garbage, here's a description of the problem: [quote] Here's [a]language to to interpret (where postfix * means tupling): Variables: x Integer literals: i Terms: t = Lambda x*. t | Apply t t* | Var(x) | Num(i) We assume usual operational semantics of lambda calculus (i.e. static scoping). The task is to write two interpreters, one with variables x being DeBruijn indices and one with them being names. You should go for maximal sharing, i.e. factor out commonalities into a common class/typeclass/functor/whatever, so that there remains no duplication of code in the two solutions. [/quote] On Mon, May 4, 2009 at 6:05 AM, Paolo Losi wrote: > Hi all, > > I'm following an interesting thread on the scala mailing list: > > http://www.nabble.com/-scala--usefulness-of-OOP-td23268250.html > > Martin Odersky advocates the OO features of the scala language > proposing an interesting problem where the OO approach seams > valuable. > > I would be very much interested in seeing an Haskell solution > to that problem. Any haskell guru want to take a stub at it > or give an opinion from a pure FP point of view? > > Thanks > Paolo > > _______________________________________________ > 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/20090504/0b09eae8/attachment.htm From duncan.coutts at worc.ox.ac.uk Mon May 4 07:51:53 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon May 4 08:12:44 2009 Subject: [Haskell-cafe] Estimating the time to garbage collect In-Reply-To: <6960D8EF-5AC1-4513-9673-86817582AC43@gmail.com> References: <6960D8EF-5AC1-4513-9673-86817582AC43@gmail.com> Message-ID: <1241437913.7387.192.camel@localhost> On Fri, 2009-05-01 at 09:14 +0100, Neil Davies wrote: > Hi > > With the discussion on threads and priority, and given that (in > Stats.c) there are lots of useful pieces of information that the run > time system is collecting, some of which is already visible (like the > total amount of memory mutated) and it is easy to make other measures > available - it has raised this question in my mind: > > Given that you have access to that information (the stuff that comes > out at the end of a run if you use +RTS -S) is it possible to estimate > the time a GC will take before asking for one? > > Ignoring, at least for the moment, all the issues of paging, processor > cache occupancy etc, what are the complexity drivers for the time to GC? > > I realise that it is going to depend on things like, volume of data > mutated, count of objects mutated, what fraction of them are live etc > - and even if it turns out that these things are very program specific > then I have a follow-on question - what properties do you need from > your program to be able to construct a viable estimate of GC time from > a past history of such garbage collections? Would looking at statistics suffice? Treat it mostly as a black box. Measure all the info you can before and after each GC and then use statistical methods to look for correlations to see if any set of variables predicts GC time. Duncan From gue.schmidt at web.de Mon May 4 08:27:52 2009 From: gue.schmidt at web.de (=?UTF-8?B?R8O8wp9udGhlciBTY2htaWR0?=) Date: Mon May 4 09:03:33 2009 Subject: [Haskell-cafe] HDBC 2.1, UTF8 and Umlauts Message-ID: Hi guys, for some reason, any way I try, all the Umlauts get garbled with HDBC 2.1. HDBC 1.16 worked fine with any backend (ODBC, Sqlite3, ... what have you). Anybody else had similar problems and knows how to solve this? G?nther From daniel.carrera at theingots.org Mon May 4 08:37:04 2009 From: daniel.carrera at theingots.org (Daniel Carrera) Date: Mon May 4 09:03:53 2009 Subject: [Haskell-cafe] When is it OK to create a new mailing list? In-Reply-To: <1241437331.7387.179.camel@localhost> References: <1241266302.4314.15.camel@supermule.opasia.dk> <200905041251.16492.g9ks157k@acme.softbase.org> <1241437331.7387.179.camel@localhost> Message-ID: <49FEE170.5090607@theingots.org> Duncan Coutts wrote: >>> I wanted a mailing list for my project WxGeneric and I am wondering when >>> it is OK to do so? How big must the potential audience be? Is there any >>> kind of etiquette or guidelines? ... > > Yes, I would recommend for smaller project-specific mailing lists that > you take advantage of the community server which is set up for this > purpose. We provide code hosting, project webspace, shell access, trac > instances and mailing lists. You can pick and choose, you don't need to > use all of them. Would this not fit well in the wxHaskell mailing list? That list is not very high traffic and there is an obvious overlap in the target audience. Daniel. From gue.schmidt at web.de Mon May 4 08:52:17 2009 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FC=3Fnther_Schmidt?=) Date: Mon May 4 13:57:23 2009 Subject: [Haskell-cafe] Darcs and binary files Message-ID: Hi, I've gotten used to darcs now, and use it for my project. There is one quirk though, I also added some rather large binary files, an sqlite database and an MS Access database to the repository. Now whenever I do a push from a branch into the main trunk the system runs out of memory. Guess I should have left the binary files out of there? G?nther From martijn at van.steenbergen.nl Mon May 4 09:08:25 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Mon May 4 13:58:24 2009 Subject: [Haskell-cafe] Interesting Thread on OO Usefulness (scala mailing list) In-Reply-To: References: Message-ID: <49FEE8C9.6030405@van.steenbergen.nl> Andrew Wagner wrote: > [quote] > Here's [a]language to to interpret (where postfix * means tupling): > > Variables: x > Integer literals: i > Terms: > > t = Lambda x*. t > | Apply t t* > | Var(x) > | Num(i) Can someone explain to me how I should read this? It supposedly explains what the postfix * means ("tupling") but I still can only guess how it translates to a Haskell datatype. Thanks, Martijn. From stevech1097 at yahoo.com.au Mon May 4 09:33:33 2009 From: stevech1097 at yahoo.com.au (Steve) Date: Mon May 4 13:58:26 2009 Subject: [Haskell-cafe] gcd In-Reply-To: <49FC2BAC.7000205@van.steenbergen.nl> References: <20090118204519.320AF32465D@www.haskell.org> <1241229917.3721.3.camel@host.localdomain> <49FC2BAC.7000205@van.steenbergen.nl> Message-ID: <1241444013.5349.15.camel@host.localdomain> Thanks for all the replies, it looks like there is a lot of support for having gcd 0 0 = 0. I've since discovered that there was a similar discussion in 2001, where the majority supported gcd 0 0 = 0, but the suggested change was never implemented. http://www.haskell.org/pipermail/haskell/2001-December/008560.html On Sat, 2009-05-02 at 13:17 +0200, Martijn van Steenbergen wrote: > Hi Steve, > > Steve wrote: > > Why is gcd 0 0 undefined? > > That's a good question. Can you submit an official proposal? > > http://www.haskell.org/haskellwiki/Library_submissions > > Thanks, > > Martijn. OK, I'll work my way through proposal steps. Steve From gwern0 at gmail.com Mon May 4 10:01:01 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Mon May 4 13:58:37 2009 Subject: [Haskell-cafe] When is it OK to create a new mailing list? In-Reply-To: <49FEE170.5090607@theingots.org> References: <1241266302.4314.15.camel@supermule.opasia.dk> <200905041251.16492.g9ks157k@acme.softbase.org> <1241437331.7387.179.camel@localhost> <49FEE170.5090607@theingots.org> Message-ID: On Mon, May 4, 2009 at 8:37 AM, Daniel Carrera wrote: > Would this not fit well in the wxHaskell mailing list? That list is not very > high traffic and there is an obvious overlap in the target audience. > > Daniel. This was my thought as well. Adding another list is considerable overhead, and keeping it on the wxHaskell list has the benefits of no-administration and possibly drawing in interested wxHaskellers (and I imagine many issues will turn out to be wxHaskell issues, so keeping them in the loop from the start is a good idea anyway). -- gwern From semanticphilosopher at googlemail.com Mon May 4 10:05:05 2009 From: semanticphilosopher at googlemail.com (Neil Davies) Date: Mon May 4 13:58:51 2009 Subject: [Haskell-cafe] Estimating the time to garbage collect In-Reply-To: <1241437913.7387.192.camel@localhost> References: <6960D8EF-5AC1-4513-9673-86817582AC43@gmail.com> <1241437913.7387.192.camel@localhost> Message-ID: <13C27819-9F21-4A16-AEB6-23F2BB72967D@gmail.com> Duncan That was my first thought - but what I'm looking for is some confirmation from those who know better that treating the GC as 'statistical source' is a valid hypothesis. If the thing is 'random' that's fine - if its timing is non-deterministic, that's not fine. So GC experts are there any hints you can give me? - are there any papers that cover this timing aspect? and are there any corner cases that might make the statistical approach risky? (or at worse invalid). I don't want to have to build a stochastic model of the GC, if I can help it! Neil On 4 May 2009, at 12:51, Duncan Coutts wrote: > On Fri, 2009-05-01 at 09:14 +0100, Neil Davies wrote: >> Hi >> >> With the discussion on threads and priority, and given that (in >> Stats.c) there are lots of useful pieces of information that the run >> time system is collecting, some of which is already visible (like the >> total amount of memory mutated) and it is easy to make other measures >> available - it has raised this question in my mind: >> >> Given that you have access to that information (the stuff that comes >> out at the end of a run if you use +RTS -S) is it possible to >> estimate >> the time a GC will take before asking for one? >> >> Ignoring, at least for the moment, all the issues of paging, >> processor >> cache occupancy etc, what are the complexity drivers for the time >> to GC? >> >> I realise that it is going to depend on things like, volume of data >> mutated, count of objects mutated, what fraction of them are live etc >> - and even if it turns out that these things are very program >> specific >> then I have a follow-on question - what properties do you need from >> your program to be able to construct a viable estimate of GC time >> from >> a past history of such garbage collections? > > Would looking at statistics suffice? Treat it mostly as a black box. > Measure all the info you can before and after each GC and then use > statistical methods to look for correlations to see if any set of > variables predicts GC time. > > Duncan > From duncan.coutts at worc.ox.ac.uk Mon May 4 10:26:41 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon May 4 13:58:56 2009 Subject: [Haskell-cafe] Estimating the time to garbage collect In-Reply-To: <13C27819-9F21-4A16-AEB6-23F2BB72967D@gmail.com> References: <6960D8EF-5AC1-4513-9673-86817582AC43@gmail.com> <1241437913.7387.192.camel@localhost> <13C27819-9F21-4A16-AEB6-23F2BB72967D@gmail.com> Message-ID: <1241447202.7387.351.camel@localhost> On Mon, 2009-05-04 at 15:05 +0100, Neil Davies wrote: > Duncan > > That was my first thought - but what I'm looking for is some > confirmation from those who know better that treating the GC as > 'statistical source' is a valid hypothesis. If the thing is 'random' > that's fine - if its timing is non-deterministic, that's not fine. > > So GC experts are there any hints you can give me? - are there any > papers that cover this timing aspect? and are there any corner cases > that might make the statistical approach risky? (or at worse invalid). I suggest you repost this question on the ghc users mailing list as -cafe is a bit high volume sometimes for the ghc hackers to keep up with. Duncan From jgoerzen at complete.org Mon May 4 10:35:55 2009 From: jgoerzen at complete.org (John Goerzen) Date: Mon May 4 13:58:58 2009 Subject: [Haskell-cafe] HDBC 2.1, UTF8 and Umlauts In-Reply-To: References: Message-ID: <49FEFD4B.105@complete.org> G??nther Schmidt wrote: > Hi guys, > > for some reason, any way I try, all the Umlauts get garbled with HDBC 2.1. > HDBC 1.16 worked fine with any backend (ODBC, Sqlite3, ... what have you). > > Anybody else had similar problems and knows how to solve this? You need to be more specific, but it is likely you are trying to send something to HDBC that isn't encoded in UTF-8. HDBC 2.x has a global preference for UTF-8 now, actually partly to resolve complaints like this. If you are feeding it ISO-8859-1 data or somesuch, try giving it UTF-8 instead. -- John From mads_lindstroem at yahoo.dk Mon May 4 11:01:16 2009 From: mads_lindstroem at yahoo.dk (Mads =?ISO-8859-1?Q?Lindstr=F8m?=) Date: Mon May 4 13:59:01 2009 Subject: [Haskell-cafe] Interesting Thread on OO Usefulness (scala mailing list) In-Reply-To: <1634993073.20090504153550@gmail.com> References: <1634993073.20090504153550@gmail.com> Message-ID: <1241449276.4846.5.camel@supermule.opasia.dk> Hi Bulat Ziganshin wrote: > Hello Paolo, > > Monday, May 4, 2009, 2:05:44 PM, you wrote: > > > Martin Odersky advocates the OO features of the scala language > > proposing an interesting problem where the OO approach seams > > valuable. > > i know two problems in Haskell/GHC that require OO-loke features - > extensible exceptions and GUI widget types hierarchy Yes, type hierarchies require OO. But, do we really need to represent different widget-types in a hierarchy? An alternative to a big hierarchy would be to let different widget-types implement different type classes. We could have type classes like MouseEvents, KeyboardEvents, Activated, ... /Mads Lindstr?m -------------- 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/20090504/16fb12d0/attachment-0001.bin From jgbailey at gmail.com Mon May 4 11:31:01 2009 From: jgbailey at gmail.com (Justin Bailey) Date: Mon May 4 13:59:03 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <87fxfll3ad.fsf@forno.us> References: <87fxfll3ad.fsf@forno.us> Message-ID: Thanks for sharing your code and experience. Very interesting and a good example of how to put the libraries together to build a real app. On Mon, May 4, 2009 at 12:45 AM, Chris Forno wrote: > I decided to find out for myself. You can find the results at > http://jekor.com/article/is-haskell-a-good-choice-for-web-applications > > Included is the source code for the web application powering > http://www.vocabulink.com/ > > The source is roughly 2,000 lines of Haskell, along with some SQL and > JavaScript. It's written in literate style and includes a 75-page PDF. > It demonstrates and explains how to: > > ?* use FastCGI to communicate with a web server (nginx in this case) > ?* move data to and from a PostgreSQL database (HDBC) > ?* authenticate users with cookies > ?* interact with users via asynchronous JavaScript and JSON (AJAJ) > ?* collect data with HTML forms (formlets) > ?* communicate with users via email > ?* cache with memcached > ?* implement a custom forums system (with threaded comments) > > I make no claims that the code is elegant or idiomatic. It is however > real code that's running "in the wild". And I hope it's useful to anyone > else considering doing web development in Haskell. > > I welcome and encourage your feedback! > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jgoerzen at complete.org Mon May 4 12:19:38 2009 From: jgoerzen at complete.org (John Goerzen) Date: Mon May 4 13:59:06 2009 Subject: [Haskell-cafe] HDBC 2.1, UTF8 and Umlauts In-Reply-To: <49FF1160.6020409@web.de> References: <49FEFD4B.105@complete.org> <49FEFF34.5090203@web.de> <20090504154439.GB5013@hustlerturf.com> <49FF1160.6020409@web.de> Message-ID: <49FF159A.8090107@complete.org> Guenther Schmidt wrote: > Hi John, > > thanks for taking the time. It actually is \252 that turned into > something else because of my email client, damn the thing. OK, perhaps we have some confusion here. Are you saying that you entered the Unicode characters directly into your Haskell source as literals? In other words, you did not type: backslash two five two but instead just typed the umlaut on the keyboard? If so, that won't work directly -- I think. Maybe somebody can correct me on this, but my hunch is that would save the umlaut as UTF-8 when you save the .hs file. Then you will get a String which is supposed to have decoded Unicode data, instead having encoded UTF-8 data. You could wrap it with Codec.Binary.UTF8.String.decodeString from utf8-string and see if that helps. If it does, that'll be your problem. It's a complicated topic, I know. And the scary thing is that Unicode makes this all *easier*. > > I'll do some further investigating and give you some more details when I > have them, thanks in advance. > > G?nther > > > John Goerzen schrieb: >> On Mon, May 04, 2009 at 04:44:04PM +0200, Guenther Schmidt wrote: >> >>> Hi John, >>> >>> I'm trying stuff like: >>> >>> dbc <- connectSqlite3 "somedatabase" >>> run dbc "insert into someTable values (?)" [toSql "G?nni"]. >>> >> SO what do you get back after adding: >> >> commit >> r <- quickQuery' dbc "select * from someTable" >> print r >> >> Just knowing it's garbled doesn't help. Need to know *how* it's >> garbled. >> >> But the problem is that \374 isn't Unicode at all. It's ISO-8859-1. >> You're not actually giving it Unicode data to start with. I believe >> the proper sequence is \252. >> >> For all I know, \374 may not even be a valid Unicode encoding (haven't >> tested it). >> >> Try \252. >> >> >> >>> I also tried: >>> >>> dbc <- connectSqlite3 "somedatabase" >>> run dbc "insert into someTable values ('G?nni')" []. >>> >>> So since this is Haskell code I presume it's in UTF-8, my emacs stores >>> all my *.hs files as UTF-8 >>> >>> In either case the "?" becomes garbled. >>> >>> With the previous version of HDBC, 1.1.6, this worked just fine. >>> >>> >>> It also garbles any Umlauts coming *out*, the source is an UTF-8 sqlite3 >>> db file. >>> >>> G?nther >>> >>> >>> >>> John Goerzen schrieb: >>> >>>> G??nther Schmidt wrote: >>>> >>>> >>>>> Hi guys, >>>>> >>>>> for some reason, any way I try, all the Umlauts get garbled with HDBC 2.1. >>>>> HDBC 1.16 worked fine with any backend (ODBC, Sqlite3, ... what have you). >>>>> >>>>> Anybody else had similar problems and knows how to solve this? >>>>> >>>>> >>>> You need to be more specific, but it is likely you are trying to send >>>> something to HDBC that isn't encoded in UTF-8. HDBC 2.x has a global >>>> preference for UTF-8 now, actually partly to resolve complaints like this. >>>> >>>> If you are feeding it ISO-8859-1 data or somesuch, try giving it UTF-8 >>>> instead. >>>> >>>> -- John >>>> >>>> >>> > > > From lrpalmer at gmail.com Mon May 4 08:58:52 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon May 4 13:59:16 2009 Subject: [Haskell-cafe] Interesting Thread on OO Usefulness (scala mailing list) In-Reply-To: References: Message-ID: <7ca3f0160905040558nb67c634y9b180e5ab5aef57d@mail.gmail.com> ML functors seem the ideal tool for this task. People have shown how you can emulate them with typeclasses, but it won't necessarily be pretty... On Mon, May 4, 2009 at 4:05 AM, Paolo Losi wrote: > Hi all, > > I'm following an interesting thread on the scala mailing list: > > http://www.nabble.com/-scala--usefulness-of-OOP-td23268250.html > > Martin Odersky advocates the OO features of the scala language > proposing an interesting problem where the OO approach seams > valuable. > > I would be very much interested in seeing an Haskell solution > to that problem. Any haskell guru want to take a stub at it > or give an opinion from a pure FP point of view? > > Thanks > Paolo > > _______________________________________________ > 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/20090504/842a9d9d/attachment-0001.htm From duncan.coutts at worc.ox.ac.uk Mon May 4 14:29:01 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon May 4 14:15:39 2009 Subject: [Haskell-cafe] HDBC 2.1, UTF8 and Umlauts In-Reply-To: <49FF159A.8090107@complete.org> References: <49FEFD4B.105@complete.org> <49FEFF34.5090203@web.de> <20090504154439.GB5013@hustlerturf.com> <49FF1160.6020409@web.de> <49FF159A.8090107@complete.org> Message-ID: <1241461741.26036.53.camel@localhost> On Mon, 2009-05-04 at 11:19 -0500, John Goerzen wrote: > Guenther Schmidt wrote: > > Hi John, > > > > thanks for taking the time. It actually is \252 that turned into > > something else because of my email client, damn the thing. > > OK, perhaps we have some confusion here. > > Are you saying that you entered the Unicode characters directly into > your Haskell source as literals? In other words, you did not type: > > backslash two five two > > but instead just typed the umlaut on the keyboard? > > If so, that won't work directly -- I think. It should work if one is using an editor that saves files as UTF-8. > Maybe somebody can correct me on this, but my hunch is that would save > the umlaut as UTF-8 when you save the .hs file. Which is what we want. Since version 6.6, GHC treats .hs files as UTF-8. > Then you will get a String which is supposed to have decoded Unicode > data, instead having encoded UTF-8 data. That's what used to happen prior to GHC version 6.6. As long as your editor is set to use UTF-8 then String literals containing Unicode will work fine. Duncan From briqueabraque at yahoo.com Mon May 4 14:32:45 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=EDcio?=) Date: Mon May 4 14:19:06 2009 Subject: [Haskell-cafe] Re: When is it OK to create a new mailing list? In-Reply-To: References: <1241266302.4314.15.camel@supermule.opasia.dk> <200905041251.16492.g9ks157k@acme.softbase.org> <1241437331.7387.179.camel@localhost> <49FEE170.5090607@theingots.org> Message-ID: >> Would this not fit well in the wxHaskell mailing list? That list is not very >> high traffic and there is an obvious overlap in the target audience. > This was my thought as well. Adding another list is considerable > overhead, and keeping it on the wxHaskell list has the benefits of > no-administration and possibly drawing in interested wxHaskellers (and > I imagine many issues will turn out to be wxHaskell issues, so keeping > them in the loop from the start is a good idea anyway). > Or: while your package has not get a user base big enough to make a mailing list work well, maybe what you need is just a bug-tracking system. The community server provides that (as Duncan pointed earlier). Best, Maur?cio From simon at joyful.com Mon May 4 14:44:27 2009 From: simon at joyful.com (Simon Michael) Date: Mon May 4 14:30:53 2009 Subject: [Haskell-cafe] Re: Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <87fxfll3ad.fsf@forno.us> References: <87fxfll3ad.fsf@forno.us> Message-ID: A very interesting read, thank you Chris! From jgoerzen at complete.org Mon May 4 14:47:58 2009 From: jgoerzen at complete.org (John Goerzen) Date: Mon May 4 14:33:30 2009 Subject: [Haskell-cafe] HDBC 2.1, UTF8 and Umlauts In-Reply-To: References: Message-ID: <49FF385E.2030804@complete.org> G?nther Schmidt wrote: > Hi John, > > what I just noticed is that *all* strings come back as SqlByteStrings. That's normal, and pretty much irrelevant, since fromSql takes care of it. It's documented, even: the SqlByteString is assumed to be in UTF-8, and is decoded when converted to a String. It is not correct to have \252 in the SqlByteString. The proper sequence there is \xc3\xbc. When converted to String, *then* it should be \252. Are you positive you're seeing \252 in the SqlByteString? That doesn't make any sense to me. It's not a valid UTF-8 encoding. > > ie. I get my "G?nni", (G\252nni), back as an SqlByteString "G\252nni" > instead of an SqlString "G\252nni". > > So when I cast, ie. fromSql x :: String, I get an "G\65533nni", which > is where the garbling occurs. > > > BTW this is the 3rd time now that I'm writing the same bloody email, > my email client "clipped" the previous 2. > > G?nther > > From bulat.ziganshin at gmail.com Mon May 4 14:51:47 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon May 4 14:42:28 2009 Subject: [Haskell-cafe] Interesting Thread on OO Usefulness (scala mailing list) In-Reply-To: <1241449276.4846.5.camel@supermule.opasia.dk> References: <1634993073.20090504153550@gmail.com> <1241449276.4846.5.camel@supermule.opasia.dk> Message-ID: <1092175536.20090504225147@gmail.com> Hello Mads, Monday, May 4, 2009, 7:01:16 PM, you wrote: >> i know two problems in Haskell/GHC that require OO-loke features - >> extensible exceptions and GUI widget types hierarchy > Yes, type hierarchies require OO. > But, do we really need to represent different widget-types in a > hierarchy? > An alternative to a big hierarchy would be to let different widget-types > implement different type classes. We could have type classes like > MouseEvents, KeyboardEvents, Activated, ... there is obvious difference between OOP and type class hierarchies - OOP ones includes data fields. (somewhat close functionality provided by extensible records, but they are not in GHC nor provide strong type-checking) this means a lot of boilerplate code written, i.e. we lose compared to OOP -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From jgoerzen at complete.org Mon May 4 15:07:19 2009 From: jgoerzen at complete.org (John Goerzen) Date: Mon May 4 14:53:23 2009 Subject: [Haskell-cafe] HDBC 2.1, UTF8 and Umlauts In-Reply-To: <374D4741-689D-4632-8406-F69EFCE6FFF6@web.de> References: <49FF385E.2030804@complete.org> <374D4741-689D-4632-8406-F69EFCE6FFF6@web.de> Message-ID: <49FF3CE7.9080404@complete.org> G?nther Schmidt wrote: > Hi John, > > I'm afraid so. > > If it came back as an SqlString "G\252nni" then it propably wouldn't > be a problem. Can you boil this down to a few-line self-contained test program so I can try it myself? I do have test cases for Unicode stuff and they are all passing here. I would like to be able to eliminate your environment as a culprit. Incidentally, could you run make test in the HDBC-sqlite3 source directory? > > > > > Am 04.05.2009 um 20:47 schrieb John Goerzen: > >> G?nther Schmidt wrote: >>> Hi John, >>> >>> what I just noticed is that *all* strings come back as >>> SqlByteStrings. >> That's normal, and pretty much irrelevant, since fromSql takes care >> of it. >> >> It's documented, even: the SqlByteString is assumed to be in UTF-8, >> and >> is decoded when converted to a String. >> >> It is not correct to have \252 in the SqlByteString. The proper >> sequence there is \xc3\xbc. When converted to String, *then* it >> should >> be \252. >> >> Are you positive you're seeing \252 in the SqlByteString? That >> doesn't >> make any sense to me. It's not a valid UTF-8 encoding. >> > > How have Umlauts been behaving on your end? Were they as mean to you > as they were to me? > > > >>> ie. I get my "G?nni", (G\252nni), back as an SqlByteString "G\252nni" >>> instead of an SqlString "G\252nni". >>> >>> So when I cast, ie. fromSql x :: String, I get an "G\65533nni", which >>> is where the garbling occurs. >>> >>> >>> BTW this is the 3rd time now that I'm writing the same bloody email, >>> my email client "clipped" the previous 2. >>> >>> G?nther >>> >>> > > From jgoerzen at complete.org Mon May 4 15:35:57 2009 From: jgoerzen at complete.org (John Goerzen) Date: Mon May 4 15:22:08 2009 Subject: [Haskell-cafe] HDBC 2.1, UTF8 and Umlauts In-Reply-To: <2E6BD398-242F-493D-A82D-D44EF364F0CB@web.de> References: <49FF385E.2030804@complete.org> <374D4741-689D-4632-8406-F69EFCE6FFF6@web.de> <49FF3CE7.9080404@complete.org> <2E6BD398-242F-493D-A82D-D44EF364F0CB@web.de> Message-ID: <49FF439D.7040204@complete.org> G?nther Schmidt wrote: > Am 04.05.2009 um 21:07 schrieb John Goerzen: > >> G?nther Schmidt wrote: >>> Hi John, >>> >>> I'm afraid so. >>> >>> If it came back as an SqlString "G\252nni" then it propably wouldn't >>> be a problem. >> Can you boil this down to a few-line self-contained test program so I >> can try it myself? I do have test cases for Unicode stuff and they >> are >> all passing here. I would like to be able to eliminate your >> environment >> as a culprit. >> > I'll try, it will take me some time since I've never written a test in > haskell. You don't really have to make a special unit test. Just a simple client program that creates a table, inserts some data, reads it back, and demonstrates the corruption. > That'll be harder to do since I'm on XP here, but I'll try that too, No problem. It's just runghc setup configure -f buildtests runghc setup build and just run runtests >>> >>> >>> >>> Am 04.05.2009 um 20:47 schrieb John Goerzen: >>> >>>> G?nther Schmidt wrote: >>>>> Hi John, >>>>> >>>>> what I just noticed is that *all* strings come back as >>>>> SqlByteStrings. >>>> That's normal, and pretty much irrelevant, since fromSql takes care >>>> of it. >>>> >>>> It's documented, even: the SqlByteString is assumed to be in UTF-8, >>>> and >>>> is decoded when converted to a String. >>>> >>>> It is not correct to have \252 in the SqlByteString. The proper >>>> sequence there is \xc3\xbc. When converted to String, *then* it >>>> should >>>> be \252. >>>> >>>> Are you positive you're seeing \252 in the SqlByteString? That >>>> doesn't >>>> make any sense to me. It's not a valid UTF-8 encoding. >>>> >>> How have Umlauts been behaving on your end? Were they as mean to you >>> as they were to me? >>> >>> >>> >>>>> ie. I get my "G?nni", (G\252nni), back as an SqlByteString "G >>>>> \252nni" >>>>> instead of an SqlString "G\252nni". >>>>> >>>>> So when I cast, ie. fromSql x :: String, I get an "G\65533nni", >>>>> which >>>>> is where the garbling occurs. >>>>> >>>>> >>>>> BTW this is the 3rd time now that I'm writing the same bloody >>>>> email, >>>>> my email client "clipped" the previous 2. >>>>> >>>>> G?nther >>>>> >>>>> >>> > > From byorgey at seas.upenn.edu Mon May 4 15:58:25 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Mon May 4 15:44:34 2009 Subject: [Haskell-cafe] Interesting Thread on OO Usefulness (scala mailing list) In-Reply-To: <49FEE8C9.6030405@van.steenbergen.nl> References: <49FEE8C9.6030405@van.steenbergen.nl> Message-ID: <20090504195825.GA29806@seas.upenn.edu> On Mon, May 04, 2009 at 03:08:25PM +0200, Martijn van Steenbergen wrote: > Andrew Wagner wrote: >> [quote] >> Here's [a]language to to interpret (where postfix * means tupling): >> Variables: x Integer literals: i Terms: t = Lambda x*. t | Apply t t* >> | Var(x) | Num(i) > > Can someone explain to me how I should read this? It supposedly explains > what the postfix * means ("tupling") but I still can only guess how it > translates to a Haskell datatype. I think t* is supposed to represent an arbitrary number (a tuple) of t's. So in Haskell syntax, you can read t* as [t]. Hence, the language described above is not curried: lambda expressions can have any finite number of arguments, and applications are correspondingly some term applied to a tuple of arguments. -Brent From byorgey at seas.upenn.edu Mon May 4 16:00:58 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Mon May 4 15:46:27 2009 Subject: [Haskell-cafe] Darcs and binary files In-Reply-To: References: Message-ID: <20090504200058.GB29806@seas.upenn.edu> On Mon, May 04, 2009 at 02:52:17PM +0200, G??nther Schmidt wrote: > Hi, > > I've gotten used to darcs now, and use it for my project. There is one > quirk though, I also added some rather large binary files, an sqlite > database and an MS Access database to the repository. > > Now whenever I do a push from a branch into the main trunk the system runs > out of memory. What version of darcs are you using? I don't know whether it makes a difference, just curious. Also, you'll probably get better help/tips on the darcs-users mailing list. -Brent From andrewcoppin at btinternet.com Mon May 4 16:28:13 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon May 4 16:13:40 2009 Subject: [Haskell-cafe] Performance counters Message-ID: <49FF4FDD.5080606@btinternet.com> OK, so I'm pretty sure I'm not the first person to run into this... I've got a fairly large, complex program. It seems to work fine. But now I want to add some counters to measure various things. Trouble is, to do that, I'd have to "infect" the entire program with boilerplate code to propogate these counters. At best I could wrap it up in a monad, but it's still annoying to have to make 90% of the code in the program monadic just to carry these performance counters around. Does anybody know of a better solution? I could use the dreaded unsafePerformIO to prod some IORefs, but now you have to start sprinkling NOINLINE pragmas around and hope you know what you're doing... Scary! o_O From dons at galois.com Mon May 4 16:28:13 2009 From: dons at galois.com (Don Stewart) Date: Mon May 4 16:15:08 2009 Subject: [Haskell-cafe] Performance counters In-Reply-To: <49FF4FDD.5080606@btinternet.com> References: <49FF4FDD.5080606@btinternet.com> Message-ID: <20090504202813.GE15715@whirlpool.galois.com> andrewcoppin: > OK, so I'm pretty sure I'm not the first person to run into this... > > I've got a fairly large, complex program. It seems to work fine. But now > I want to add some counters to measure various things. > > Trouble is, to do that, I'd have to "infect" the entire program with > boilerplate code to propogate these counters. At best I could wrap it up > in a monad, but it's still annoying to have to make 90% of the code in > the program monadic just to carry these performance counters around. > > Does anybody know of a better solution? I could use the dreaded > unsafePerformIO to prod some IORefs, but now you have to start > sprinkling NOINLINE pragmas around and hope you know what you're > doing... Scary! o_O What kind of counters? Do you just want to measure how often things are evaluated? Use -fhpc (which inserts 'ticks' for you). Otherwise, you'll need some kind of manual tick system. -- Don From aeyakovenko at gmail.com Mon May 4 16:32:32 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Mon May 4 16:18:16 2009 Subject: [Haskell-cafe] traversing a tree using monad.cont In-Reply-To: <2f9b2d30905031440m79a6e00fi1b58c3b69ea97c9a@mail.gmail.com> References: <7ca3f0160905012035h6c333b57yca03c34e7cc342ec@mail.gmail.com> <2f9b2d30905031440m79a6e00fi1b58c3b69ea97c9a@mail.gmail.com> Message-ID: thanks, that looks promising, but will probably take me a week to understand :) On Sun, May 3, 2009 at 2:40 PM, Ryan Ingram wrote: > Cont with success and failure isn't Cont; it's something else (albeit similar) > > There's a great exposition of using something much like Cont to get > success and failure "for free" here: > http://www-ps.informatik.uni-kiel.de/~sebf/haskell/barefaced-pilferage-of-monadic-bind.lhs.html > > ?-- ryan > > On Sat, May 2, 2009 at 2:13 AM, Anatoly Yakovenko wrote: >>> Though I don't fully understand what you are doing (specifically what you >>> mean by "specific order"), but in a lazy language, traversals are usually >>> simply encoded as lists. ?Just write a function which returns all the leaves >>> as a list, and filter over it. >> >> yea, i know, i am trying to learn how to use the Cont monad. or >> continuation in haskell. ?The idea is that while i am processing some >> data i may hit a point whree some dependency isn't met and i want to >> take a different branch via continuation. ?I expect that branch to >> furfill my dependency and when its done i want to continue down the >> original branch >> >> >>>> module TestCont where >>>> import Control.Monad.Cont >>>> import Control.Monad.Identity >>>> import Control.Monad.State.Lazy >>>> >>>> --our stupid tree >>>> data Tree a = Tree [Tree a] >>>> ? ? ? ? ? ?| Leaf a >>>> >>>> --traverse all the branches >>>> search (Tree ts) next = do >>>> ? mapM_ (\ ti -> (callCC (search ti))) ts >>>> ? next $ () >>>> >>>> search tt@(Leaf a) next = do >>>> ? cur <- lift get >>>> ? case ((cur + 1) == a) of >>>> ? ? ?True -> do --the current leaf is what we want, update the state and return >> >> this is where i succeed in my current branch, so i can just do my thing and exit >> >>>> ? ? ? ? lift $ put a >>>> ? ? ? ? return $ () >>>> ? ? ?False -> do --the current leaf is not what we want, continue first, then try again >> >> this is where i fail, so i want to take the "other" branch first >> expecting it to fulfill my dependency. >> >>>> ? ? ? ? next () >>>> ? ? ? ? search tt (\ _ -> error "fail") >>>> >>>> t1 = Leaf 1 >>>> t2 = Leaf 2 >>>> t3 = Tree [t1,t2] >>>> t4 = Leaf 3 >>>> t5::Tree Int = Tree [t4,t3] >>>> >>>> run = ?runIdentity (runStateT ((runContT $ callCC (search t5)) return) 0) >> >> >> but i think next doesn't do exactly what i think it does >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From andrewcoppin at btinternet.com Mon May 4 16:35:05 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon May 4 16:20:28 2009 Subject: [Haskell-cafe] Performance counters In-Reply-To: <20090504202813.GE15715@whirlpool.galois.com> References: <49FF4FDD.5080606@btinternet.com> <20090504202813.GE15715@whirlpool.galois.com> Message-ID: <49FF5179.8040501@btinternet.com> Don Stewart wrote: > andrewcoppin: > >> OK, so I'm pretty sure I'm not the first person to run into this... >> >> I've got a fairly large, complex program. It seems to work fine. But now >> I want to add some counters to measure various things. >> >> Trouble is, to do that, I'd have to "infect" the entire program with >> boilerplate code to propogate these counters. At best I could wrap it up >> in a monad, but it's still annoying to have to make 90% of the code in >> the program monadic just to carry these performance counters around. >> >> Does anybody know of a better solution? I could use the dreaded >> unsafePerformIO to prod some IORefs, but now you have to start >> sprinkling NOINLINE pragmas around and hope you know what you're >> doing... Scary! o_O >> > > What kind of counters? Do you just want to measure how often things are > evaluated? Use -fhpc (which inserts 'ticks' for you). > > Otherwise, you'll need some kind of manual tick system. > Stuff like "how many times does this function get called? How what's the maximum depth it recurses to?" That kind of thing. From jeremy at n-heptane.com Mon May 4 16:52:58 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Mon May 4 16:38:34 2009 Subject: [Haskell-cafe] HDBC 2.1, UTF8 and Umlauts In-Reply-To: <49FF159A.8090107@complete.org> References: <49FEFD4B.105@complete.org> <49FEFF34.5090203@web.de> <20090504154439.GB5013@hustlerturf.com> <49FF1160.6020409@web.de> <49FF159A.8090107@complete.org> Message-ID: <87hc00h9p1.wl%jeremy@n-heptane.com> At Mon, 04 May 2009 11:19:38 -0500, John Goerzen wrote: > but instead just typed the umlaut on the keyboard? > > If so, that won't work directly -- I think. Maybe somebody can correct > me on this, but my hunch is that would save the umlaut as UTF-8 when you > save the .hs file. Then you will get a String which is supposed to have > decoded Unicode data, instead having encoded UTF-8 data. As far as I know, that is how it would work. You type an umlaut on the keyboard in the source code, and at runtime you have a value of type 'String' which contains the Unicode value for an umlaut. I am confused why that would not work directly? (Though, I have never used HDBC). It seems to be that the only way to keep things sensible is if all values of type 'String' *only* ever contain Unicode chars. If you need a utf-8 encoded 'string' then it should use a different type -- perhaps a newtype wrapper around a plain old bytestring. - jeremy From magnus at therning.org Mon May 4 17:09:38 2009 From: magnus at therning.org (Magnus Therning) Date: Mon May 4 16:59:39 2009 Subject: [Haskell-cafe] Performance counters In-Reply-To: <49FF5179.8040501@btinternet.com> References: <49FF4FDD.5080606@btinternet.com> <20090504202813.GE15715@whirlpool.galois.com> <49FF5179.8040501@btinternet.com> Message-ID: <49FF5992.4010807@therning.org> Andrew Coppin wrote: > Don Stewart wrote: >> andrewcoppin: >> >>> OK, so I'm pretty sure I'm not the first person to run into this... >>> >>> I've got a fairly large, complex program. It seems to work fine. But >>> now I want to add some counters to measure various things. >>> >>> Trouble is, to do that, I'd have to "infect" the entire program with >>> boilerplate code to propogate these counters. At best I could wrap it >>> up in a monad, but it's still annoying to have to make 90% of the >>> code in the program monadic just to carry these performance counters >>> around. >>> >>> Does anybody know of a better solution? I could use the dreaded >>> unsafePerformIO to prod some IORefs, but now you have to start >>> sprinkling NOINLINE pragmas around and hope you know what you're >>> doing... Scary! o_O >>> >> >> What kind of counters? Do you just want to measure how often things are >> evaluated? Use -fhpc (which inserts 'ticks' for you). >> >> Otherwise, you'll need some kind of manual tick system. >> > > Stuff like "how many times does this function get called? How what's the > maximum depth it recurses to?" That kind of thing. It won't help you, but wouldn't it be the kind of thing that'd fit in the GHC runtime? Do you also require that the counters are available to the program itself? (This is starting to sound like something Don mentioned in his talk in London...) /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090504/0245962e/signature.bin From tphyahoo at gmail.com Mon May 4 17:15:52 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Mon May 4 17:01:23 2009 Subject: [Haskell-cafe] applicative challenge Message-ID: <910ddf450905041415o23086d0cxef88b1b8f4fc04a3@mail.gmail.com> {-# LANGUAGE NoMonomorphismRestriction #-} import Data.List import Control.Monad import Control.Applicative -- Can the function below be tweaked to quit on blank input, provisioned in the applicative style? -- which function(s) needs to be rewritten to make it so? -- Can you tell/guess which function(s) is the problem just by looking at the code below? -- If so, can you explain what the strategy for doing so is? notQuiteRight = takeWhile (not . blank) <$> ( sequence . repeat $ echo ) echo = do l <- getLine putStrLn l return l -- this seems to work... is there a way to make it work Applicatively, with lifted takeWhile? seemsToWork = sequenceWhile_ (not . blank) (repeat echo) sequenceWhile_ p [] = return () sequenceWhile_ p (mx:mxs) = do x <- mx if p x then do sequenceWhile_ p mxs else return () blank x = "" == x From thomas.dubuisson at gmail.com Mon May 4 17:32:19 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Mon May 4 17:19:13 2009 Subject: [Haskell-cafe] Performance counters In-Reply-To: <49FF5179.8040501@btinternet.com> References: <49FF4FDD.5080606@btinternet.com> <20090504202813.GE15715@whirlpool.galois.com> <49FF5179.8040501@btinternet.com> Message-ID: <4c44d90b0905041432o3fcd632bnc0f55cecacb59468@mail.gmail.com> While not entirely handy, do the .prof files not contain enough information on entries into a function? [tom@Mavlo Test]$ grep addLeaf PingNet.prof addLeaf Network.Pastry.Data.LeafSet 822 1 0.0 0.0 0.0 0.0 addLeaf Network.Pastry.Data.LeafSet 687 243 0.0 0.0 0.1 0.1 addLeaf Network.Pastry.Data.LeafSet 734 619933 0.1 0.0 60.5 94.6 addLeaf Network.Pastry.Data.LeafSet 609 4013 0.0 0.0 0.5 0.6 addLeaf Network.Pastry.Data.LeafSet 644 3600 0.0 0.0 0.3 0.6 addLeaf Network.Pastry.Data.LeafSet 784 2666 0.0 0.0 0.3 0.4 addLeaf Network.Pastry.Data.LeafSet 566 6 0.0 0.0 0.0 0.0 addLeaf Network.Pastry.Data.LeafSet 569 0 0.0 0.0 0.0 0.0 In this manner I know addLeaf was entered 72000+ times. Though it won't give you any information about recursion depth (which is often optimized out so you see fewer entries than there are logical calls to the function). I'm not proposing people want to do this manually, but asking if pulling the information out of the .prof files with some tool would give much of the information you desire? Or perhaps you desire this information within the program like Magnus mentioned. Thomas On Mon, May 4, 2009 at 1:35 PM, Andrew Coppin wrote: > > Don Stewart wrote: >> >> andrewcoppin: >> >>> >>> OK, so I'm pretty sure I'm not the first person to run into this... >>> >>> I've got a fairly large, complex program. It seems to work fine. But now ?I want to add some counters to measure various things. >>> >>> Trouble is, to do that, I'd have to "infect" the entire program with ?boilerplate code to propogate these counters. At best I could wrap it up ?in a monad, but it's still annoying to have to make 90% of the code in ?the program monadic just to carry these performance counters around. >>> >>> Does anybody know of a better solution? I could use the dreaded ?unsafePerformIO to prod some IORefs, but now you have to start ?sprinkling NOINLINE pragmas around and hope you know what you're ?doing... Scary! o_O >>> >> >> What kind of counters? Do you just want to measure how often things are >> evaluated? Use -fhpc (which inserts 'ticks' for you). >> >> Otherwise, you'll need some kind of manual tick system. >> > > Stuff like "how many times does this function get called? How what's the maximum depth it recurses to?" That kind of thing. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From conor at strictlypositive.org Mon May 4 17:49:56 2009 From: conor at strictlypositive.org (Conor McBride) Date: Mon May 4 19:14:58 2009 Subject: [Haskell-cafe] applicative challenge In-Reply-To: <910ddf450905041415o23086d0cxef88b1b8f4fc04a3@mail.gmail.com> References: <910ddf450905041415o23086d0cxef88b1b8f4fc04a3@mail.gmail.com> Message-ID: Hi Thomas This is "iffy versus miffy", a standard applicative problem. When you use the result of one computation to choose the next computation (e.g., to decide whether you want to keep doing-and-taking), that's when you need yer actual monad. It's the join of a monad that lets you compute computations. The applicative interface does not allow any interference between the value and computation layers. It's enough for effects which facilitate but do not determine the flow of computation (e.g. threading an environment, counting how often something happens, etc...). So, you ask a sensible... On 4 May 2009, at 22:15, Thomas Hartman wrote: > {-# LANGUAGE NoMonomorphismRestriction #-} > import Data.List > import Control.Monad > import Control.Applicative > > -- Can the function below be tweaked to quit on blank input, > provisioned in the applicative style? > -- which function(s) needs to be rewritten to make it so? > -- Can you tell/guess which function(s) is the problem just by looking > at the code below? > -- If so, can you explain what the strategy for doing so is? ...nostril question. > > notQuiteRight = takeWhile (not . blank) <$> ( sequence . repeat $ > echo ) ^^^ Here, we're doing all the computations, then post-processing the values with a pure function. There's no way the pure function can tell the computation to stop bothering. > echo = do > l <- getLine > putStrLn l > return l > > > -- this seems to work... is there a way to make it work Applicatively, > with lifted takeWhile? > seemsToWork = sequenceWhile_ (not . blank) (repeat echo) > > sequenceWhile_ p [] = return () > sequenceWhile_ p (mx:mxs) = do > x <- mx > if p x ^^^ Here, you're exactly using the result of a computation to choose which computations come next. That's a genuinely monadic thing to do: miffy not iffy. > > then do sequenceWhile_ p mxs > else return () If you're wondering what I'm talking about, let me remind/inform you of the definitions. iffy :: Applicative a => a Bool -> a t -> a t -> a t iffy test yes no = cond <$> test <*> yes <*> no where cond b y n = if b then y else n miffy :: Monad m => m Bool -> m t -> m t -> m t miffy test yes no = do b <- test if b then yes else no Apologies for slang/pop-culture references, but "iffy" means dubious, questionable, untrustworthy "miffy" is a cute Dutch cartoon character drawn by Dick Bruna The effect of iffy askPresident launchMissiles seekUNResolution is to ask the President, then launch the missiles, then lobby the UN, then decide that the result of seeking a UN resolution is preferable. Remember folks: Missiles need miffy! Cheers Conor From rendel at cs.au.dk Mon May 4 17:58:56 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Mon May 4 19:15:15 2009 Subject: [Haskell-cafe] applicative challenge In-Reply-To: <910ddf450905041415o23086d0cxef88b1b8f4fc04a3@mail.gmail.com> References: <910ddf450905041415o23086d0cxef88b1b8f4fc04a3@mail.gmail.com> Message-ID: <49FF6520.1050501@cs.au.dk> Thomas Hartman wrote: > -- Can the function below be tweaked to quit on blank input, > provisioned in the applicative style? No. Applicative on its own does not support to decide which action to take based on the result of some previous action. It is therefore not possible to look at the last line read, and read another line or stop processing depending on whether the last line was empty or not. You need something beyond Applicative to do that. > -- Can you tell/guess which function(s) is the problem just by looking > at the code below? repeat creates an infinite list, and sequence is strict, so ( sequence . repeat $ ...) diverges. fmap for IO is strict in its second argument, so notQuiteRight diverges. repeat, sequence and fmap work together to make this expression diverge, so I would not say that one of them is more problematic then the others. > -- If so, can you explain what the strategy for doing so is? No. > notQuiteRight = takeWhile (not . blank) <$> ( sequence . repeat $ echo ) > > echo = do > l <- getLine > putStrLn l > return l > > > -- this seems to work... is there a way to make it work Applicatively, > with lifted takeWhile? > seemsToWork = sequenceWhile_ (not . blank) (repeat echo) > > sequenceWhile_ p [] = return () > sequenceWhile_ p (mx:mxs) = do > x <- mx > if p x > then do sequenceWhile_ p mxs > else return () While this should work and looks like a reasonable implementation, it is clearly not in Applicative style, since you use bind to look at the x. Tillmann From gtener at gmail.com Mon May 4 18:40:55 2009 From: gtener at gmail.com (=?UTF-8?Q?Krzysztof_Skrz=C4=99tnicki?=) Date: Mon May 4 19:15:19 2009 Subject: [Haskell-cafe] Vector-like data structure In-Reply-To: <20090503195007.GD11310@whirlpool.galois.com> References: <220e47b40905031106i1ff14d0ap6fb5fc223d220996@mail.gmail.com> <20090503195007.GD11310@whirlpool.galois.com> Message-ID: <220e47b40905041540v29d08f1k29fc4b756887dc78@mail.gmail.com> Thank both of you for your responses. Unfortunately I decided to switch to Python for this project, as I plan to use BerkeleyDB and Haskell bindings for it are poorly written. Best regards Christopher Skrz?tnicki 2009/5/3 Don Stewart : > gtener: >> Hi >> >> I'm looking for a data structure with following characteristics: >> 1. O(1) lookup >> 2. O(1) modification >> 3. amortized O(1) append >> 4. O(1) size query >> >> This roughly characterizes C++ vector<> class. I'm ready to implement >> it myself, but first I would like to ask if anyone knows package with >> similar data structure. >> If there are many, which one would you choose and why? >> > > A number of the array packages behave like this. ?The trie packages are > O(log(wordsize)), so another option (they tend to have better append > complexity as well). > > -- Don > From dons at galois.com Mon May 4 18:58:45 2009 From: dons at galois.com (Don Stewart) Date: Mon May 4 19:15:22 2009 Subject: [Haskell-cafe] Vector-like data structure In-Reply-To: <220e47b40905041540v29d08f1k29fc4b756887dc78@mail.gmail.com> References: <220e47b40905031106i1ff14d0ap6fb5fc223d220996@mail.gmail.com> <20090503195007.GD11310@whirlpool.galois.com> <220e47b40905041540v29d08f1k29fc4b756887dc78@mail.gmail.com> Message-ID: <20090504225845.GF15715@whirlpool.galois.com> Interesting. Thanks for the feedback. You were referring to Stephen Blackheath's BerkeleyDB package? http://hackage.haskell.org/cgi-bin/hackage-scripts/package/BerkeleyDB -- Don gtener: > Thank both of you for your responses. Unfortunately I decided to > switch to Python for this project, as I plan to use BerkeleyDB and > Haskell bindings for it are poorly written. > > Best regards > > Christopher Skrz?tnicki > > 2009/5/3 Don Stewart : > > gtener: > >> Hi > >> > >> I'm looking for a data structure with following characteristics: > >> 1. O(1) lookup > >> 2. O(1) modification > >> 3. amortized O(1) append > >> 4. O(1) size query > >> > >> This roughly characterizes C++ vector<> class. I'm ready to implement > >> it myself, but first I would like to ask if anyone knows package with > >> similar data structure. > >> If there are many, which one would you choose and why? > >> > > > > A number of the array packages behave like this. ?The trie packages are > > O(log(wordsize)), so another option (they tend to have better append > > complexity as well). > > > > -- Don > > > From deniz.a.m.dogan at gmail.com Mon May 4 19:06:25 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Mon May 4 19:15:28 2009 Subject: [Haskell-cafe] Foldable for BNFC generated tree In-Reply-To: <49FE9F87.6020208@van.steenbergen.nl> References: <7b501d5c0905031147n24a5ec46jea3926da78d61498@mail.gmail.com> <49FE9F87.6020208@van.steenbergen.nl> Message-ID: <7b501d5c0905041606j28426548y829c050c29ebc372@mail.gmail.com> 2009/5/4 Martijn van Steenbergen : > Hi Deniz, > > Deniz Dogan wrote: >> >> So, basically I'd like some sort of folding functionality for these >> data types, without having to hack the lexer/parser myself >> (parameterising the data types), because as I said they're being >> generated by BNFC. > > What exactly do you mean by folding functionality? Folding as in the > Foldable type class applies to containers, which your data type isn't. > Perhaps you're looking for generic programming? > > There are several good GP libraries out there: > > * EMGM: http://www.cs.uu.nl/wiki/GenericProgramming/EMGM > * Uniplate: http://community.haskell.org/~ndm/uniplate/ > * SYB: http://www.cs.vu.nl/boilerplate/ > > See also Neil Mitchell's blog for some examples: > http://neilmitchell.blogspot.com/2009/03/concise-generic-queries.html You're right, what I was asking for didn't make much sense... I was really looking for GP. Thanks, Deniz From jefferson.r.heard at gmail.com Mon May 4 19:31:48 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Mon May 4 19:17:17 2009 Subject: [Haskell-cafe] Odd error message from ghc --make Message-ID: <4165d3a70905041631q23653a79ra936c72b3c1e29e5@mail.gmail.com> I was just running a test that has compiled before just fine, and now I'm getting this rather odd message: EventBusTest.hs:20:9: Couldn't match expected type `Bus a' against inferred type `buster-1.1:App.EventBus.Bus [buster-1.1:App.EventBus.EData a1]' Expected type: MVar (Bus a) Inferred type: MVar (buster-1.1:App.EventBus.Bus [buster-1.1:App.EventBus.EData a1]) In the expression: mk In the first argument of `bus', namely `[mk]' Any ideas? I mean, it looks like it type checks to me. From felipe.lessa at gmail.com Mon May 4 19:39:00 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Mon May 4 19:25:51 2009 Subject: [Haskell-cafe] applicative challenge In-Reply-To: References: <910ddf450905041415o23086d0cxef88b1b8f4fc04a3@mail.gmail.com> Message-ID: <20090504233900.GA27253@kira.casa> On Mon, May 04, 2009 at 10:49:56PM +0100, Conor McBride wrote: > The effect of > > iffy askPresident launchMissiles seekUNResolution > > is to ask the President, then launch the missiles, then lobby the > UN, then decide that the result of seeking a UN resolution is > preferable. > > Remember folks: Missiles need miffy! Haha, you made my day! This e-mail has to be saved somewhere :). Cheers, -- Felipe. From chris at forno.us Mon May 4 13:25:47 2009 From: chris at forno.us (Chris Forno jekor) Date: Mon May 4 19:45:11 2009 Subject: [Haskell-cafe] Re: Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) References: <87fxfll3ad.fsf@forno.us> <49FEBAA1.5060205@theingots.org> Message-ID: <87ab5skcf8.fsf@forno.us> Daniel Carrera writes: > 1) You say that grammar doesn't matter. Well, for some languages it matters > more than others. German, for example, has a very particular word order that > takes some effort to learn, and if you get it wrong people really won't > understand you. In German it's ok if you conjugate wrong, but it's not ok if > you put words in the wrong place. Second, some people actually enjoy grammar > better and find that grammar helps them understand the language. I am one of > those people. Different people learn differently. I learn rules more easily > than disconnected words. When I learn vocabulary I do better by learning word > families, and so on. The Germanic languages rely heavily in word derivation > (not so much English) so that can be important for learners like me. I haven't taken German into consideration. Perhaps I need to re-evaluate or restate my conviction. Maybe you can help me find a better way of putting it. The idea is that I spent years studying different languages, generally with a textbook. The textbooks tend to focus on teaching rules and grammar, with a little bit of vocabulary and dialog each chapter. I think the focus should be reversed. Obviously grammar is very important. But is reading about it effective for everyone? I know that some people enjoy studying formal grammars, myself included. I consider myself to be a highly logically-oriented (audio-digital?) learning type, as I expect many programmers are. However, I still don't remember most grammar lessons. The only way I successfully became fluent in a language (Esperanto) was through immersion, and that wouldn't have been possible without a decent vocabulary to start with. Fortunately Esperanto has a lot of English cognates and you can build a large vocabulary with it pretty quickly. And of course it has very forgiving sentence and a rather simple grammar, but I'm finding the experience to be very similar with Japanese so far. That being said, Esperanto, and even Japanese sentence structure perhaps is not as different as an agglutinative language like German. I'll need to study it more to find out. > 2) Your analysis of word count is flawed. Sure, most of the words you read come > from a very small vocabulary set, but most of the *meaning* in a sentence comes > from the more obscure words. Imagine that you read this sentence: "In the > newspaper I read that the __________ said that the problem is that the river > has too much ________ ". In this sentence you can understand 90% of the words, > but you have almost no idea of what's happening. What your word count test > really shows is that human languages have a lot of redundancy. You could omit > the word "the" from the above sentence and you would understand it almost as > well. The word "the" is common and contains very little information. Absolutely. I'm not trying to claim that you only need 1,000 words to become fluent, like some courses claim. I do think though that if you focus on particles, common verbs, etc. up front you'll get to immersive learning much faster. Again, this has been my personal experience. The idea is that once you can begin to read with a dictionary by your side you'll begin learning much faster because you can focus on reading what *you* are interested in rather than some contrived dialog from a textbook. > That said, do you have any stories in German? I can't figure out where to get > the stories. So far I've been focusing on Japanese. I only have 15 or so stories currently. They take a bit of time to create ;) For now, the navigation is basically to click the "Latest Links" link in the header bar or in the "Latest Links" box. Thank you very much for the feedback. I appreciate it, and I'll take what you've said into consideration when I rewrite the front page. From gue.schmidt at web.de Mon May 4 20:00:31 2009 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FC=3Fnther_Schmidt?=) Date: Mon May 4 19:47:18 2009 Subject: [Haskell-cafe] Using Takusen is a real intellectual challenge Message-ID: Hi, well I'm *trying* to use Takusen to export from one database into the other. I'm using Takusen for this so that I can guarantee that during the export not a single huge result is assembled (possibly in memory) and then insert in one lump into the second database. Trying to figure out how to do that in Takusen has left me totally exhausted, my brain is pudding and I need to have a lay down now. I couldn't even figure out whether that's at all possible. help G?nther From ok at cs.otago.ac.nz Mon May 4 20:04:12 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Mon May 4 19:51:35 2009 Subject: [Haskell-cafe] A brief note on n_k patterns and Hackage Message-ID: I never really understood why it was thought to be relevant, but I was challenged to show that n+k patterns occurred in Hackage. Last week I downloaded it. I had to miss a couple of days looking after my daughter, but today I got back to it. Guess what? I found one. Having found one I stopped looking. I don't want to start another thread, but having promised that I'd look I thought I should follow that up. From rendel at cs.au.dk Mon May 4 20:06:28 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Mon May 4 19:53:31 2009 Subject: [Haskell-cafe] Interesting Thread on OO Usefulness (scala mailing list) In-Reply-To: References: Message-ID: <49FF8304.7040800@cs.au.dk> Hi, Paolo Losi wrote: > I'm following an interesting thread on the scala mailing list: > > http://www.nabble.com/-scala--usefulness-of-OOP-td23268250.html > > Martin Odersky advocates the OO features of the scala language > proposing an interesting problem where the OO approach seams > valuable. > > I would be very much interested in seeing an Haskell solution > to that problem. Here is my take on it, using type families. Tillmann {-# LANGUAGE TypeFamilies #-} import Data.List (elemIndex) -- COMMON INTERFACE -- -- environments and variables class Env env where data V env empty :: env a bind :: (String, a) -> env a -> env a find :: env a -> V env -> a -- too bad we have to include these here :( showVar :: Int -> V env -> ShowS showEnv :: Show a => Int -> env a -> ShowS -- GENERIC INTERPRETER -- -- terms (for some type of variables v) data T env = Lam [String] (T env) | App (T env) [T env] | Var (V env) | Lit Integer instance Env env => Show (T env) where showsPrec p t = showParen (p > 10) $ case t of Lam vs t -> ("Lam " ++) . showsPrec 11 vs . (' ' :) . showsPrec 11 t App f xs -> ("App " ++) . showsPrec 11 f . (' ' :) . showsPrec 11 xs Var v -> ("Var " ++) . showVar 11 v Lit n -> ("Lit " ++) . showsPrec 11 n -- domain of values data D env = Fun [String] (T env) (env (D env)) | Num Integer instance Env env => Show (D env) where showsPrec p t = showParen (p > 10) $ case t of Fun vs t env -> ("Fun " ++) . showsPrec 11 vs . (' ' :) . showsPrec 11 t . (' ' :) . showEnv 11 env Num n -> ("Num " ++) . showsPrec 11 n -- interpreter eval :: Env env => env (D env) -> T env -> D env eval env (Lam vs t) = Fun vs t env eval env (App f xs) = apply (eval env f) (map (eval env) xs) eval env (Var v ) = find env v eval env (Lit n ) = Num n apply :: Env env => D env -> [D env] -> D env apply (Fun vs t env) xs | length vs == length xs = eval env' t | otherwise = error ("arity mismatch: " ++ show vs ++ ", " ++ show xs) where env' = foldr bind env (zip vs xs) apply (Num n) xs = error "not a function" -- VARIABLES AS STRINGS -- data AssocList a = AssocList [(String, a)] deriving Show instance Env AssocList where data V AssocList = Name String deriving Show empty = AssocList [] bind (v, x) (AssocList env) = AssocList ((v, x) : env) find (AssocList env) (Name v) = case lookup v env of Just x -> x Nothing -> error "free variable" showVar = showsPrec showEnv = showsPrec -- VARIABLES AS De-BRUIJN INDICES -- data Stack a = Stack [a] deriving Show instance Env Stack where data V Stack = Index Int deriving Show empty = Stack [] bind (v, x) (Stack env) = Stack (x : env) find (Stack env) (Index v) = if v < length env then env !! v else error "free variable" showVar = showsPrec showEnv = showsPrec -- CONVERT NAMES TO DE-BRUIJN INDICES -- index :: [String] -> T AssocList -> T Stack index vs (Lam ws t ) = Lam ws (index (ws ++ vs) t) index vs (App f xs ) = App (index vs f) (map (index vs) xs) index vs (Var (Name v)) = case elemIndex v vs of Just n -> Var (Index n) Nothing -> error "free variable" index vs (Lit n ) = Lit n -- TEST -- identity = Lam ["x"] (Var (Name "x")) two = Lam ["f", "x"] (App (Var (Name "f")) [(App (Var (Name "f")) [(Var (Name "x"))])]) five = App two [identity, Lit 5] test = case (eval empty five, eval empty (index [] five)) of (Num 5, Num 5) -> True _ -> False From vanenkj at gmail.com Mon May 4 20:23:59 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon May 4 20:12:51 2009 Subject: [Haskell-cafe] A brief note on n_k patterns and Hackage In-Reply-To: References: Message-ID: Which package? /jve On Mon, May 4, 2009 at 8:04 PM, Richard O'Keefe wrote: > I never really understood why it was thought to be relevant, > but I was challenged to show that n+k patterns occurred in > Hackage. > > Last week I downloaded it. I had to miss a couple of days > looking after my daughter, but today I got back to it. > > Guess what? I found one. Having found one I stopped looking. > > I don't want to start another thread, but having promised that > I'd look I thought I should follow that up. > > _______________________________________________ > 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/20090504/672b5636/attachment-0001.htm From barsoap at web.de Mon May 4 20:26:58 2009 From: barsoap at web.de (Achim Schneider) Date: Mon May 4 20:13:42 2009 Subject: [Haskell-cafe] Re: applicative challenge References: <910ddf450905041415o23086d0cxef88b1b8f4fc04a3@mail.gmail.com> Message-ID: <20090505022658.2ac61970@solaris> Conor McBride wrote: > Remember folks: Missiles need miffy! > Hmmmm. Iff you have something like CoPointed or Foldable, you can thread your own, Applicative, tail back into yourself and decide what you are by inspecting it. That makes foldr the join of Hask itself, or something. Bear with me, I'm merely attempting to delurk our resident category theorists by giving them headaches. -- (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 Mon May 4 20:26:51 2009 From: dons at galois.com (Don Stewart) Date: Mon May 4 20:14:29 2009 Subject: [Haskell-cafe] A brief note on n_k patterns and Hackage In-Reply-To: References: Message-ID: <20090505002650.GJ15715@whirlpool.galois.com> I think the Hinze streams package I uploaded on Sunday uses n+k... http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hinze-streams-1.0 turn :: (Integral a) => a -> [a] turn 0 = [] turn (n + 1) = turn n ++ [n] ++ turn n vanenkj: > Which package? > > /jve > > > On Mon, May 4, 2009 at 8:04 PM, Richard O'Keefe wrote: > > I never really understood why it was thought to be relevant, > but I was challenged to show that n+k patterns occurred in > Hackage. > > Last week I downloaded it. I had to miss a couple of days > looking after my daughter, but today I got back to it. > > Guess what? I found one. Having found one I stopped looking. > > I don't want to start another thread, but having promised that > I'd look I thought I should follow that up. > > _______________________________________________ > 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 barsoap at web.de Mon May 4 20:29:34 2009 From: barsoap at web.de (Achim Schneider) Date: Mon May 4 20:16:43 2009 Subject: [Haskell-cafe] Re: A brief note on n_k patterns and Hackage References: Message-ID: <20090505022934.27285bac@solaris> John Van Enk wrote: > Which package? > More importantly, is it a recent version, that's still live? Does it compile with ghc > 5.2? -- (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 conor at strictlypositive.org Mon May 4 20:50:06 2009 From: conor at strictlypositive.org (Conor McBride) Date: Mon May 4 20:37:31 2009 Subject: [Haskell-cafe] Re: applicative challenge In-Reply-To: <20090505022658.2ac61970@solaris> References: <910ddf450905041415o23086d0cxef88b1b8f4fc04a3@mail.gmail.com> <20090505022658.2ac61970@solaris> Message-ID: <3A07587C-72E7-4BD0-B3E5-0332B8F97565@strictlypositive.org> Hi Achim On 5 May 2009, at 01:26, Achim Schneider wrote: > Conor McBride wrote: > >> Remember folks: Missiles need miffy! >> > Hmmmm. Iff you have something like CoPointed or Foldable, you can > thread your own, Applicative, tail back into yourself and decide what > you are by inspecting it. Yeah, Applicative on its own is kind of "effects without control", or in Lindley-Wadler-Yallop parlance "oblivious". The fun starts when you just chuck in a little bit more. Copointed might be overdoing it. Even Alternative gives you quite a lot of control, without going as far as Monad. > That makes foldr the join of Hask itself, or something. Bear with me, > I'm merely attempting to delurk our resident category theorists by > giving them headaches. Good luck Conor From tonymorris at gmail.com Mon May 4 21:06:51 2009 From: tonymorris at gmail.com (Tony Morris) Date: Mon May 4 20:55:10 2009 Subject: [Haskell-cafe] instance Monad (Except err) In-Reply-To: <49FEB76E.2020308@kent.ac.uk> References: <49FEAEE1.7060304@van.steenbergen.nl> <49FEB76E.2020308@kent.ac.uk> Message-ID: <49FF912B.4000003@gmail.com> Yes, however, ap is not equal to (<*>) for the given Applicative. I don't believe such a monad is possible. Neil Brown wrote: > Martijn van Steenbergen wrote: >> Hello, >> >> Mr. McBride and mr. Paterson define in their Applicative paper: >> >>> data Except e a = OK a | Failed e >>> instance Monoid e => Applicative (Except e) where ... >> >> Sometimes I'd still like to use >>= on Excepts but this "feels" wrong >> somehow, because it doesn't use monoids nicely like the Applicative >> instance does. Are there any good reasons such a Monad instance >> shouldn't be defined? Does it violate any laws, for example? > Isn't the Except type just Either by another name? OK = Right, Failed > = Left. Therefore the monad is just the same as the Either monad, and > is useful as an error monad: > > instance Monad (Except e) where > (OK x) >>= f = f x > Failed e >>= _ = Failed e > return = OK > > This obeys all the monad laws. > > Thanks, > > Neil. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Tony Morris http://tmorris.net/ From ok at cs.otago.ac.nz Mon May 4 21:48:10 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Mon May 4 21:34:24 2009 Subject: [Haskell-cafe] A brief note on n_k patterns and Hackage In-Reply-To: References: Message-ID: <7531905E-CC09-40DB-A6B7-7F447B22FC2E@cs.otago.ac.nz> [about n+k in Hackage] On 5 May 2009, at 12:23 pm, John Van Enk wrote: > Which package? There are at least two occurrences of n+1 as a pattern. If anyone wants to get rid of them, I'd like them to work as hard at this as I did... From leimy2k at gmail.com Mon May 4 22:38:11 2009 From: leimy2k at gmail.com (David Leimbach) Date: Mon May 4 22:24:22 2009 Subject: [Haskell-cafe] Using Takusen is a real intellectual challenge In-Reply-To: References: Message-ID: <3e1162e60905041938h6b7fa5d6o50342fac6135e30a@mail.gmail.com> Ohhhh-kaaaaay? On Mon, May 4, 2009 at 5:00 PM, G??nther Schmidt wrote: > Hi, > > well I'm *trying* to use Takusen to export from one database into the > other. > I'm using Takusen for this so that I can guarantee that during the export > not a single huge result is assembled (possibly in memory) and then insert > in one lump into the second database. > > Trying to figure out how to do that in Takusen has left me totally > exhausted, my brain is pudding and I need to have a lay down now. > > I couldn't even figure out whether that's at all possible. > > help > > G?nther > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090504/7ea0d642/attachment.htm From lennart at augustsson.net Mon May 4 23:26:20 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Mon May 4 23:11:50 2009 Subject: [Haskell-cafe] A brief note on n_k patterns and Hackage In-Reply-To: <7531905E-CC09-40DB-A6B7-7F447B22FC2E@cs.otago.ac.nz> References: <7531905E-CC09-40DB-A6B7-7F447B22FC2E@cs.otago.ac.nz> Message-ID: I presume that is a joke, but it's not very funny. On Mon, May 4, 2009 at 6:48 PM, Richard O'Keefe wrote: > [about n+k in Hackage] > On 5 May 2009, at 12:23 pm, John Van Enk wrote: > >> Which package? > > There are at least two occurrences of n+1 as a pattern. > If anyone wants to get rid of them, I'd like them to work > as hard at this as I did... > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From vanenkj at gmail.com Tue May 5 00:06:54 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon May 4 23:52:25 2009 Subject: [Haskell-cafe] ANN: atom-0.0.2 In-Reply-To: <594c1e830904261339n2a1f9a5ak38d629d225452bed@mail.gmail.com> References: <594c1e830904261339n2a1f9a5ak38d629d225452bed@mail.gmail.com> Message-ID: If any one has been looking at this and wants another example, I've finished two posts on the topic of Atom. These posts depend on a patch: http://code.sw17ch.com/blog/atom/atom_0.0.2_sw17ch_1.diff Part 1: http://blog.sw17ch.com/wordpress/?p=84 <- Brief discussion and describes the patch Part 2: http://blog.sw17ch.com/wordpress/?p=111 <- Writing a program to blink an LED. Feed back would be appreciated! /jve On Sun, Apr 26, 2009 at 4:39 PM, Tom Hawkins wrote: > Atom is a DSL in Haskell for designed hard realtime embedded programs. > At Eaton, we are using it to control hydraulic hybrid refuse trucks > and shuttle buses. After my talk at CUFP > (http://cufp.galois.com/2008/schedule.html), a few people inquired > about atom -- I finally had a chance to upload it to Hackage. > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/atom-0.0.2 > > Some new enhancements: > - A simple rule scheduler for load balancing. > - Signal probing for debug and data logging. > - Functional coverage to monitor which rules have executed. > - Started integration with the Yices SMT solver for bounded model checking. > > Experiences with our Eaton project: > - 5K lines of Haskell/atom replaced 120K lines of matlab, simulink, > and visual basic. > - 2 months to port simulink design to atom. > - 3K lines of atom generates 22K lines of embedded C. > - Design composed of 450 atomic state transition rules. > - Rules with execution periods from 1ms to 10s all scheduled at > compile time to a 1 ms main loop. > - 3 minute compilation time from atom source to ECU. > - Atom design clears electronic/sw testing on first pass. > - Currently in vehicle testing with no major issues. > > > Tom > _______________________________________________ > 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/20090505/3fe2d66e/attachment.htm From ryani.spam at gmail.com Tue May 5 00:56:29 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue May 5 00:41:58 2009 Subject: [Haskell-cafe] Re: StateT IO Action on `onKeyPress` In-Reply-To: <87d4api9dj.fsf@ubuntu.domain> References: <87hc021a2g.fsf@ubuntu.domain> <2f9b2d30905031528x470e632dm8e3110889d38d1e6@mail.gmail.com> <87d4api9dj.fsf@ubuntu.domain> Message-ID: <2f9b2d30905042156o34591d0ai579a76e41aeb02da@mail.gmail.com> Something like this: -- Replaces "runStateT" for callbacks that might affect the state invert :: IORef s -> StateT s IO a -> IO a invert r m = do s <- readIORef r (a, s') <- runStateT m s writeIORef r s' return a -- Replaces "liftIO" when the action called might use "invert" revert :: IORef s -> IO a -> StateT s IO a revert r m = do s <- get writeIORef r s a <- liftIO m s' <- readIORef r put s' return a Then you use ... `onKeyPress` (\event -> invert windowListRef (...)) I'm not sure where in your code revert is required; I don't know when WindowListT might call back into IO. If you want to be extra safe, make the IORef be a Maybe WindowList and make sure it's "Nothing" except between 'revert' and 'invert'. -- ryan On Mon, May 4, 2009 at 1:02 AM, Andy Stewart wrote: > Hi Ryan, > > Ryan Ingram writes: > >> Hi Andy. >> >> The GTK bindings use IO for their callbacks, not any custom monad like >> your WindowListT. >> >> I suggest, instead of StateT s IO a, you use ReaderT (IORef s) IO a: >> >> putR :: s -> ReaderT (IORef s) IO () >> putR s = do >> ? ? r <- ask >> ? ? liftIO $ writeIORef r s >> >> getR :: ReaderT (IORef s) IO s >> getR = ask >>= liftIO . readIORef >> >> Otherwise, there are techniques to use an IORef to hold onto the state >> while calling into IO (which might make callbacks), and then read it >> back out and put it in the state while running your action. ?But it's >> simpler to just switch to ReaderT > I'm curious another techniques that use IORef hold on state. > > Can you implement a simple example that make my code pass `onKeyPress`? > > Thanks! > > ?-- Andy > >> >> ? -- ryan >> >> On Sun, May 3, 2009 at 8:27 AM, Andy Stewart wrote: >>> Hi all, >>> >>> I have a function named `keymapTest` need moand state WindowListT, and >>> WindowListT is `type WindowListT = StateT WindowList IO`. >>> >>> when i add "(\event -> keymapTest winList event >> return False)" after >>> `onKeyPress` for handle key press event, i got GHC error: >>> >>> Manatee.hs:57:58: >>> ? ?Couldn't match expected type `IO a' >>> ? ? ? ? ? against inferred type `WindowListT Bool' >>> ? ?In the first argument of `(>>)', namely `keymapTest winList event' >>> ? ?In the expression: keymapTest winList event >> return False >>> ? ?In the second argument of `onKeyPress', namely >>> ? ? ? ?`(\ event -> keymapTest winList event >> return False)' >>> >>> So function `onKeyPress` just accept *one* IO-action? >>> Have a way to fix above problem? >>> >>> Any help? >>> >>> Thanks! >>> >>> ?-- Andy >>> >>> Below is source code of Manatee.hs file. >>> >>> ------------------------------> Manatee.hs start ? <------------------------------ >>> module Main where >>> >>> import Text.Printf >>> import Data.Monoid >>> import Data.List >>> import Data.Maybe >>> import Control.Monad >>> import Control.Monad.State >>> import Control.Applicative >>> >>> import Data.IORef >>> >>> import Graphics.UI.Gtk hiding (Window, windowNew, get) >>> import Graphics.UI.Gtk.SourceView >>> import Graphics.UI.Gtk.Abstract.Widget >>> >>> import Manatee.Event >>> import Manatee.Buffer >>> import Manatee.WindowList >>> import Manatee.Pane >>> import Manatee.Statusbar >>> import Manatee.Utils >>> import Manatee.Window >>> >>> import qualified Data.Set as Set >>> import qualified Graphics.UI.Gtk.Windows.Window as W >>> import qualified Graphics.UI.Gtk.Gdk.Events as E >>> >>> main :: IO () >>> main = do >>> ?-- Init. >>> ?initGUI >>> >>> ?-- Root frame. >>> ?rootFrame <- W.windowNew >>> ?rootFrame `onDestroy` mainQuit ?-- quit main loop when root frame close >>> >>> ?-- Root frame status. >>> ?windowFullscreen rootFrame ? -- fullscreen >>> >>> ?-- Windows list. >>> ?let windowsList = WindowList 0 Set.empty >>> >>> ?evalStateT (do >>> ? ? ? ? ? ? ? -- Window 1 >>> ? ? ? ? ? ? ? window1 <- windowNewWithBuffer DTop "test" >>> ? ? ? ? ? ? ? liftIO $ containerAdd rootFrame $ windowPaned window1 >>> >>> ? ? ? ? ? ? ? (window2, window3) <- windowSplitVertically window1 >>> >>> ? ? ? ? ? ? ? (window4, window5) <- windowSplitHorizontally window3 >>> >>> ? ? ? ? ? ? ? winList <- windowListGetList >>> ? ? ? ? ? ? ? liftIO $ rootFrame `onKeyPress` (\event -> keymapTest winList event >> return False) >>> >>> ? ? ? ? ? ? ? -- Handle window content synchronous. >>> ? ? ? ? ? ? ? windowHandleSynchronous >>> ? ? ? ? ? ? ? ) windowsList >>> >>> ?-- Loop >>> ?widgetShowAll rootFrame ? ? ? -- display all widget >>> ?mainGUI >>> >>> keymapTest :: [Window] -> E.Event -> WindowListT Bool >>> keymapTest winList event = do >>> ?window <- liftIO $ windowFindFocus winList >>> ?case window of >>> ? ?Just x -> handleKeyPress x event >>> ? ?Nothing -> return False >>> >>> handleKeyPress :: Window -> E.Event -> WindowListT Bool >>> handleKeyPress window ev = do >>> ?liftIO $ >>> ? ? ? ? case eventTransform ev of >>> ? ? ? ? ? Nothing -> return False >>> ? ? ? ? ? Just e -> do >>> ? ? ? ? ? ? let display = statusbarOutputSubitemSetText $ paneStatusbar $ windowPane $ window >>> ? ? ? ? ? ? ? ? eventName = eventGetName e >>> ? ? ? ? ? ? case eventName of >>> ? ? ? ? ? ? ? ?-- Window commands. >>> ? ? ? ? ? ? ? ?"M-t" -> display "windowSplitVertically" >>> ? ? ? ? ? ? ? ?-- "M-t" -> windowSplitVertically window >> return False >>> ? ? ? ? ? ? ? ?_ -> display $ printf "%s undefined." eventName >>> ------------------------------> Manatee.hs end ? <------------------------------ >>> >>> _______________________________________________ >>> 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 oleg at okmij.org Tue May 5 01:20:18 2009 From: oleg at okmij.org (oleg@okmij.org) Date: Tue May 5 01:06:21 2009 Subject: [Haskell-cafe] Re: Using Takusen is a real intellectual challenge Message-ID: <20090505052018.BCFEE1782F@Adric.metnet.navy.mil> Perhaps you might find the following code, relying on low-level Takusen's functions, useful http://darcs.haskell.org/takusen/Database/PostgreSQL/Test/pgaccess.hs The code is a stand-alone program that does the following: docstrings = [ "A helper to access a PostgreSQL from a `scripting' language.", "This function attempts to closely emulate `dbaccess' of Informix.", "The goal is to have my Scheme-to-Informix interface work with", "PostgreSQL with minimal changes.", "", "Synopsys:", " dbaccess ", "where is the string of database connection parameters.", "", "The program connects to the database and listens on its standard", "input for a SQL command. A command is an ASCII sequence terminated by", "NL-NULL-NL.", "If the command is other than SELECT or COPY, we submit it to the database.", "On success, no reply is generated, and we wait for a new command.", "If the command starts with a /*simple*/ SELECT, we expect few rows.", "We submit the query to the database and write the result to stdout.", "If the command was SELECT, we make a query and write the result,", "in groups, to the stdout. Each group of results has the form:", " 0 NL", " for the last group of results", " NL", " followed by the matrix of * field values in the", " row-major order. Each field value has the form", " NL", " where is the length of the value proper (no NL).", "", "If the command was COPY, we assume ", " COPY /* fname*/ table ... FROM STDIN...", " where is the length of the file name. We open the file and", " send its contents to the server", "", "Any error causes the termination of this program.", "We log all the results to stderr." ] The above was my attempt at comments shared between compile-time and run-time. HERE documents would have certainly helped; I hope Haskell will get them one day. As the comments show, pgaccess is a very simple program to endow any scripting language (Scheme in my case) to communicate with a PostgreSQL database. The scripting language communicates with pgaccess via a pipe; thus the language itself needs to know nothing about databases and need not depend on any database libraries. The code has been designed keeping incremental processing firmly in mind. It was written about three years ago and in constant use. The program runs for days and indeed moves quite large amount of data to and from the database (the amount of data in a transaction can be larger than the amount of available memory). From lazycat.manatee at gmail.com Tue May 5 03:03:42 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Tue May 5 02:53:51 2009 Subject: [Haskell-cafe] Re: StateT IO Action on `onKeyPress` References: <87hc021a2g.fsf@ubuntu.domain> <2f9b2d30905031528x470e632dm8e3110889d38d1e6@mail.gmail.com> <87d4api9dj.fsf@ubuntu.domain> <2f9b2d30905042156o34591d0ai579a76e41aeb02da@mail.gmail.com> Message-ID: <873abkhvzl.fsf@ubuntu.domain> Ryan Ingram writes: > Something like this: > > -- Replaces "runStateT" for callbacks that might affect the state > invert :: IORef s -> StateT s IO a -> IO a > invert r m = do > s <- readIORef r > (a, s') <- runStateT m s > writeIORef r s' > return a > > -- Replaces "liftIO" when the action called might use "invert" > revert :: IORef s -> IO a -> StateT s IO a > revert r m = do > s <- get > writeIORef r s > a <- liftIO m > s' <- readIORef r > put s' > return a > > Then you use ... `onKeyPress` (\event -> invert windowListRef (...)) > > I'm not sure where in your code revert is required; I don't know when > WindowListT might call back into IO. If you want to be extra safe, > make the IORef be a Maybe WindowList and make sure it's "Nothing" > except between 'revert' and 'invert'. Result is ReaderT is cleaner and simpler. Thanks for your help! -- Andy > > -- ryan > > On Mon, May 4, 2009 at 1:02 AM, Andy Stewart wrote: >> Hi Ryan, >> >> Ryan Ingram writes: >> >>> Hi Andy. >>> >>> The GTK bindings use IO for their callbacks, not any custom monad like >>> your WindowListT. >>> >>> I suggest, instead of StateT s IO a, you use ReaderT (IORef s) IO a: >>> >>> putR :: s -> ReaderT (IORef s) IO () >>> putR s = do >>> ? ? r <- ask >>> ? ? liftIO $ writeIORef r s >>> >>> getR :: ReaderT (IORef s) IO s >>> getR = ask >>= liftIO . readIORef >>> >>> Otherwise, there are techniques to use an IORef to hold onto the state >>> while calling into IO (which might make callbacks), and then read it >>> back out and put it in the state while running your action. ?But it's >>> simpler to just switch to ReaderT >> I'm curious another techniques that use IORef hold on state. >> >> Can you implement a simple example that make my code pass `onKeyPress`? >> >> Thanks! >> >> ?-- Andy >> >>> >>> ? -- ryan >>> >>> On Sun, May 3, 2009 at 8:27 AM, Andy Stewart wrote: >>>> Hi all, >>>> >>>> I have a function named `keymapTest` need moand state WindowListT, and >>>> WindowListT is `type WindowListT = StateT WindowList IO`. >>>> >>>> when i add "(\event -> keymapTest winList event >> return False)" after >>>> `onKeyPress` for handle key press event, i got GHC error: >>>> >>>> Manatee.hs:57:58: >>>> ? ?Couldn't match expected type `IO a' >>>> ? ? ? ? ? against inferred type `WindowListT Bool' >>>> ? ?In the first argument of `(>>)', namely `keymapTest winList event' >>>> ? ?In the expression: keymapTest winList event >> return False >>>> ? ?In the second argument of `onKeyPress', namely >>>> ? ? ? ?`(\ event -> keymapTest winList event >> return False)' >>>> >>>> So function `onKeyPress` just accept *one* IO-action? >>>> Have a way to fix above problem? >>>> >>>> Any help? >>>> >>>> Thanks! >>>> >>>> ?-- Andy >>>> >>>> Below is source code of Manatee.hs file. >>>> >>>> ------------------------------> Manatee.hs start ? <------------------------------ >>>> module Main where >>>> >>>> import Text.Printf >>>> import Data.Monoid >>>> import Data.List >>>> import Data.Maybe >>>> import Control.Monad >>>> import Control.Monad.State >>>> import Control.Applicative >>>> >>>> import Data.IORef >>>> >>>> import Graphics.UI.Gtk hiding (Window, windowNew, get) >>>> import Graphics.UI.Gtk.SourceView >>>> import Graphics.UI.Gtk.Abstract.Widget >>>> >>>> import Manatee.Event >>>> import Manatee.Buffer >>>> import Manatee.WindowList >>>> import Manatee.Pane >>>> import Manatee.Statusbar >>>> import Manatee.Utils >>>> import Manatee.Window >>>> >>>> import qualified Data.Set as Set >>>> import qualified Graphics.UI.Gtk.Windows.Window as W >>>> import qualified Graphics.UI.Gtk.Gdk.Events as E >>>> >>>> main :: IO () >>>> main = do >>>> ?-- Init. >>>> ?initGUI >>>> >>>> ?-- Root frame. >>>> ?rootFrame <- W.windowNew >>>> ?rootFrame `onDestroy` mainQuit ?-- quit main loop when root frame close >>>> >>>> ?-- Root frame status. >>>> ?windowFullscreen rootFrame ? -- fullscreen >>>> >>>> ?-- Windows list. >>>> ?let windowsList = WindowList 0 Set.empty >>>> >>>> ?evalStateT (do >>>> ? ? ? ? ? ? ? -- Window 1 >>>> ? ? ? ? ? ? ? window1 <- windowNewWithBuffer DTop "test" >>>> ? ? ? ? ? ? ? liftIO $ containerAdd rootFrame $ windowPaned window1 >>>> >>>> ? ? ? ? ? ? ? (window2, window3) <- windowSplitVertically window1 >>>> >>>> ? ? ? ? ? ? ? (window4, window5) <- windowSplitHorizontally window3 >>>> >>>> ? ? ? ? ? ? ? winList <- windowListGetList >>>> ? ? ? ? ? ? ? liftIO $ rootFrame `onKeyPress` (\event -> keymapTest winList event >> return > False) >>>> >>>> ? ? ? ? ? ? ? -- Handle window content synchronous. >>>> ? ? ? ? ? ? ? windowHandleSynchronous >>>> ? ? ? ? ? ? ? ) windowsList >>>> >>>> ?-- Loop >>>> ?widgetShowAll rootFrame ? ? ? -- display all widget >>>> ?mainGUI >>>> >>>> keymapTest :: [Window] -> E.Event -> WindowListT Bool >>>> keymapTest winList event = do >>>> ?window <- liftIO $ windowFindFocus winList >>>> ?case window of >>>> ? ?Just x -> handleKeyPress x event >>>> ? ?Nothing -> return False >>>> >>>> handleKeyPress :: Window -> E.Event -> WindowListT Bool >>>> handleKeyPress window ev = do >>>> ?liftIO $ >>>> ? ? ? ? case eventTransform ev of >>>> ? ? ? ? ? Nothing -> return False >>>> ? ? ? ? ? Just e -> do >>>> ? ? ? ? ? ? let display = statusbarOutputSubitemSetText $ paneStatusbar $ windowPane $ window >>>> ? ? ? ? ? ? ? ? eventName = eventGetName e >>>> ? ? ? ? ? ? case eventName of >>>> ? ? ? ? ? ? ? ?-- Window commands. >>>> ? ? ? ? ? ? ? ?"M-t" -> display "windowSplitVertically" >>>> ? ? ? ? ? ? ? ?-- "M-t" -> windowSplitVertically window >> return False >>>> ? ? ? ? ? ? ? ?_ -> display $ printf "%s undefined." eventName >>>> ------------------------------> Manatee.hs end ? <------------------------------ >>>> >>>> _______________________________________________ >>>> 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 dav.vire+haskell at gmail.com Tue May 5 03:19:12 2009 From: dav.vire+haskell at gmail.com (david48) Date: Tue May 5 03:04:39 2009 Subject: [Haskell-cafe] applicative challenge In-Reply-To: References: <910ddf450905041415o23086d0cxef88b1b8f4fc04a3@mail.gmail.com> Message-ID: <4c88418c0905050019o6e8a703alf27729a8a0cd061@mail.gmail.com> On Mon, May 4, 2009 at 11:49 PM, Conor McBride wrote: > Remember folks: Missiles need miffy! Quote of the week ! From tom.davie at gmail.com Tue May 5 03:27:06 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Tue May 5 03:12:35 2009 Subject: [Haskell-cafe] applicative challenge In-Reply-To: <910ddf450905041415o23086d0cxef88b1b8f4fc04a3@mail.gmail.com> References: <910ddf450905041415o23086d0cxef88b1b8f4fc04a3@mail.gmail.com> Message-ID: <0BA32E64-1CDE-45DC-BF8B-27DF4F14D437@gmail.com> On 4 May 2009, at 23:15, Thomas Hartman wrote: > {-# LANGUAGE NoMonomorphismRestriction #-} > import Data.List > import Control.Monad > import Control.Applicative > > -- Can the function below be tweaked to quit on blank input, > provisioned in the applicative style? > -- which function(s) needs to be rewritten to make it so? > -- Can you tell/guess which function(s) is the problem just by looking > at the code below? > -- If so, can you explain what the strategy for doing so is? > notQuiteRight = takeWhile (not . blank) <$> ( sequence . repeat $ > echo ) > > echo = do > l <- getLine > putStrLn l > return l > > > -- this seems to work... is there a way to make it work Applicatively, > with lifted takeWhile? > seemsToWork = sequenceWhile_ (not . blank) (repeat echo) > > sequenceWhile_ p [] = return () > sequenceWhile_ p (mx:mxs) = do > x <- mx > if p x > then do sequenceWhile_ p mxs > else return () Conor's already give you a comprehensive explanation of why Applicative can't be used to do this, but that doesn't mean you can't use applicative style! How about... echo = unlines . takeWhile (not . blank) . lines seemsToWork = interact echo Bob From magnus at therning.org Tue May 5 04:30:05 2009 From: magnus at therning.org (Magnus Therning) Date: Tue May 5 04:15:33 2009 Subject: [Haskell-cafe] A brief note on n_k patterns and Hackage In-Reply-To: References: Message-ID: On Tue, May 5, 2009 at 1:04 AM, Richard O'Keefe wrote: > I never really understood why it was thought to be relevant, > but I was challenged to show that n+k patterns occurred in > Hackage. Why is it relevant? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From brian at lorf.org Tue May 5 04:52:39 2009 From: brian at lorf.org (brian@lorf.org) Date: Tue May 5 04:38:49 2009 Subject: [Haskell-cafe] setResourceLimit Message-ID: <20090505085239.GJ19506@doses> I have a long-lived multithreaded server process that needs to execute programs and interact with them via Handles. The programs could misbehave, like loop or hang, so I need to limit the real and CPU time they can take. I guess System.Posix.Resource.setResourceLimit sets limits on the current process, so I can't use it in the server process. Is it a good approach to write some utility program for the server to call that does setResourceLimit and executes the programs that could misbehave? From z_axis at 163.com Tue May 5 05:27:16 2009 From: z_axis at 163.com (z_axis) Date: Tue May 5 05:12:47 2009 Subject: [Haskell-cafe] How to understand the fmap here ? Message-ID: <200905051727159682365@163.com> The following code snippets is from xmonad: -- Given a window, find the screen it is located on, and compute -- the geometry of that window wrt. that screen. floatLocation :: Window -> X (ScreenId, W.RationalRect) --....... rr <- snd `fmap` floatLocation w Prelude> :i fmap class Functor f where fmap :: (a -> b) -> f a -> f b It seems it is different from the definition of fmap ? sincerely! 2009-05-05 z_axis -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090505/41f80c4d/attachment.htm From tom.davie at gmail.com Tue May 5 05:36:00 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Tue May 5 05:21:29 2009 Subject: [Haskell-cafe] How to understand the fmap here ? In-Reply-To: <200905051727159682365@163.com> References: <200905051727159682365@163.com> Message-ID: <4E928C4F-8A24-4B04-BDA1-21C1316E6551@gmail.com> On 5 May 2009, at 11:27, z_axis wrote: > The following code snippets is from xmonad: > -- Given a window, find the screen it is located on, and compute > -- the geometry of that window wrt. that screen. > floatLocation :: Window -> X (ScreenId, W.RationalRect) > --....... > rr <- snd `fmap` floatLocation w > > Prelude> :i fmap > class Functor f where fmap :: (a -> b) -> f a -> f b > > It seems it is different from the definition of fmap ? > sincerely! As the type signature of fmap explains, it transforms a function. Specifically, it starts with a function (a -> b), and it transforms it to accept an 'a' inside a functor instead of just an a, and return a 'b' inside the same functor instead of just a b. In other words, fmap applies functions inside containers. We can see from floatLocation that it returns a pair inside a container - specifically, an X container. Fmap takes snd, and transforms it to work on values inside the X. So, snd has type (a,b) -> b, thus fmap snd has type f (a,b) -> f b. In this case, the type it's being applied to is X (ScreenId, W.RationalRect), so f unifies with X, a with ScreenID and b with W.RationalRect. Making snd `fmap` floatLocation w hav the type X W.RationalRect. Finally, the bind into rr there takes it out of the X monad all together, getting you a W.RationalRect. You may want to read this article which explains some of Haskell's abstraciton mechanisms: http://noordering.wordpress.com/2009/03/31/how-you-shouldnt-use-monad/ Bob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090505/e68dc423/attachment.htm From noteed at gmail.com Tue May 5 05:35:48 2009 From: noteed at gmail.com (minh thu) Date: Tue May 5 05:21:36 2009 Subject: [Haskell-cafe] How to understand the fmap here ? In-Reply-To: <200905051727159682365@163.com> References: <200905051727159682365@163.com> Message-ID: <40a414c20905050235i7fa79bdeobd2087a4b4ef268f@mail.gmail.com> 2009/5/5 z_axis : > The following code snippets is from xmonad: > -- Given a window, find the screen it is located on, and compute > -- the geometry of that window wrt. that screen. > floatLocation :: Window -> X (ScreenId, W.RationalRect) > --....... > rr <- snd `fmap` floatLocation w > > Prelude> :i fmap > class Functor f where fmap :: (a -> b) -> f a -> f b > > It seems it is different from the definition of fmap ? > sincerely! X is a Functor (and a Monad). floatLocation w :: X (ScreenId, W.RationalRect) -- i.e. f is X and a is (ScreenId, W.RationalRect) snd :: (ScreenId, W.RationalRect) -> W.RationalRect fmap :: (same as snd) -> X (ScreenId, W.RationalRect) -> X W.RationalRect Makes sense ? Cheers, Thu From bulat.ziganshin at gmail.com Tue May 5 05:39:46 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue May 5 05:34:52 2009 Subject: [Haskell-cafe] How to understand the fmap here ? In-Reply-To: <200905051727159682365@163.com> References: <200905051727159682365@163.com> Message-ID: <25635145.20090505133946@gmail.com> Hello z_axis, Tuesday, May 5, 2009, 1:27:16 PM, you wrote: > floatLocation?::?Window?->?X?(ScreenId,?W.RationalRect) > > rr?<-?snd?`fmap`?floatLocation?w > > class?Functor?f?where?fmap?::?(a?->?b)?->?f?a?->?f?b looks ok. X===f, fmap executes floatLocation?w :: X?(ScreenId,?W.RationalRect) === f a and then applies snd :: (ScreenId,?W.RationalRect) -> W.RationalRect === a->b to result, so that entire (snd?`fmap`?floatLocation?w) has type X?W.RationalRect === f b -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From daniel.carrera at theingots.org Tue May 5 05:56:35 2009 From: daniel.carrera at theingots.org (Daniel Carrera) Date: Tue May 5 05:42:04 2009 Subject: [Haskell-cafe] Re: Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <87ab5skcf8.fsf@forno.us> References: <87fxfll3ad.fsf@forno.us> <49FEBAA1.5060205@theingots.org> <87ab5skcf8.fsf@forno.us> Message-ID: <4A000D53.7050400@theingots.org> Chris Forno (jekor) wrote: > The idea is that I spent years studying different languages, generally > with a textbook. The textbooks tend to focus on teaching rules and > grammar, with a little bit of vocabulary and dialog each chapter. I > think the focus should be reversed. I think it largely depends on the learner. Some people find vocabulary easier, or more interesting, others not. I have a hard time learning a lot of isolated facts (e.g. vocabulary), but I find it easier and more enjoyable to learn a rule that I can apply many times. But I know people who are the exact opposite. I wouldn't want to make an absolute rule. I generally like rules that will save me a lot of memorization. I hate rules that force me to memorize a lot. I am not good at memorization. > I consider myself to be a highly logically-oriented > (audio-digital?) learning type, as I expect many programmers are. > However, I still don't remember most grammar lessons. The only way I > successfully became fluent in a language (Esperanto) was through > immersion, and that wouldn't have been possible without a decent > vocabulary to start with. I totally understand, and I agree. And with only a few exceptions, I would say that vocabulary is more useful than grammar (even if I find the former harder to learn). That said, I cause Esperanto as a good example of a language with rules that make learning easier. In Esperanto, the ending of a word tells you if the word is a noun, a verb, an adjective, a subject, an object, etc. Knowing these rules makes it much easier for you to learn Esperanto. When I learn a language, I like learning rules that will make language learning easier. > That being said, Esperanto, and even Japanese sentence structure perhaps > is not as different as an agglutinative language like German. I'll need > to study it more to find out. In the specific case of German, word order is a lot more important than any other language I know. You can get everything else about grammar wrong, but as long as you put the words in the right place people will probably understand you. But if you get everything else right, and put the words in the wrong place, you won't be understood. > Absolutely. I'm not trying to claim that you only need 1,000 words to > become fluent, like some courses claim. Ok. I probably misunderstood something. > The idea is that once you can begin to read with a dictionary by your > side you'll begin learning much faster because you can focus on reading > what *you* are interested in rather than some contrived dialog from a > textbook. In my case, the things I'm interested in are too technical :-( I've had a hard time finding things that are interesting and are simple enough for me to read in German. But I'll get better. > So far I've been focusing on Japanese. I only have 15 or so stories > currently. They take a bit of time to create ;) For now, the navigation > is basically to click the "Latest Links" link in the header bar or in > the "Latest Links" box. Ok. Cheers, Daniel. From tphyahoo at gmail.com Tue May 5 09:48:20 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Tue May 5 09:33:47 2009 Subject: [Haskell-cafe] applicative challenge In-Reply-To: <0BA32E64-1CDE-45DC-BF8B-27DF4F14D437@gmail.com> References: <910ddf450905041415o23086d0cxef88b1b8f4fc04a3@mail.gmail.com> <0BA32E64-1CDE-45DC-BF8B-27DF4F14D437@gmail.com> Message-ID: <910ddf450905050648g41bd42d8g6ce3b82eefe087d0@mail.gmail.com> That's slick, but is there some way to use interact twice in the same program? t10 = let f = unlines . takeWhile (not . blank) . lines in do putStrLn "first time" interact f putStrLn "second time" interact f this results in *** Exception: : hGetContents: illegal operation (handle is closed) -} I also tried t15 = let grabby = unlines . takeWhile (not . blank) . lines top = ("first time: " ++) . grabby . ("second time: " ++) . grabby in interact top but that didn't work either: thartman@ubuntu:~/haskell-learning/lazy-n-strict>runghc sequencing.hs a first time: second time: a b b If someone can explain the subtleties of using interact when you run out of stdio here, it would be nice to incorporate this into http://www.haskell.org/haskellwiki/Haskell_IO_for_Imperative_Programmers#IO where it talks about how using interact is the easy way to approach these types of problems. Not *that* easy though, as this scenario suggests. 2009/5/5 Thomas Davie : > > On 4 May 2009, at 23:15, Thomas Hartman wrote: > >> {-# LANGUAGE NoMonomorphismRestriction #-} >> import Data.List >> import Control.Monad >> import Control.Applicative >> >> -- Can the function below be tweaked to quit on blank input, >> provisioned in the applicative style? >> -- which function(s) needs to be rewritten to make it so? >> -- Can you tell/guess which function(s) is the problem just by looking >> at the code below? >> -- If so, can you explain what the strategy for doing so is? >> notQuiteRight = takeWhile (not . blank) <$> ( sequence . repeat $ echo ) >> >> echo = do >> ? ? ? ? l <- getLine >> ? ? ? ? putStrLn l >> ? ? ? ? return l >> >> >> -- this seems to work... is there a way to make it work Applicatively, >> with lifted takeWhile? >> seemsToWork = sequenceWhile_ (not . blank) (repeat echo) >> >> sequenceWhile_ p [] = return () >> sequenceWhile_ p (mx:mxs) = do >> ?x <- mx >> ?if p x >> ? then do sequenceWhile_ p mxs >> ? else return () > > Conor's already give you a comprehensive explanation of why Applicative > can't be used to do this, but that doesn't mean you can't use applicative > style! > > How about... > > echo = unlines . takeWhile (not . blank) . lines > > seemsToWork = interact echo > > Bob > > From ketil at malde.org Tue May 5 10:06:52 2009 From: ketil at malde.org (Ketil Malde) Date: Tue May 5 09:50:42 2009 Subject: [Haskell-cafe] applicative challenge In-Reply-To: <910ddf450905050648g41bd42d8g6ce3b82eefe087d0@mail.gmail.com> (Thomas Hartman's message of "Tue\, 5 May 2009 08\:48\:20 -0500") References: <910ddf450905041415o23086d0cxef88b1b8f4fc04a3@mail.gmail.com> <0BA32E64-1CDE-45DC-BF8B-27DF4F14D437@gmail.com> <910ddf450905050648g41bd42d8g6ce3b82eefe087d0@mail.gmail.com> Message-ID: <871vr37if7.fsf@malde.org> Thomas Hartman writes: > That's slick, but is there some way to use interact twice in the same program? No :-) > t10 = > let f = unlines . takeWhile (not . blank) . lines > in do putStrLn "first time" > interact f > putStrLn "second time" > interact f > > this results in *** Exception: : hGetContents: illegal > operation (handle is closed) -} Yes. Interacting uses hGetContents, and hGetContents semi-closes (or fully-closes) the handle. If you do it from GHCi, you only get to run your program once. > I also tried > > t15 = > let grabby = unlines . takeWhile (not . blank) . lines > top = ("first time: " ++) . grabby . ("second time: " ++) . grabby > in interact top > but that didn't work either: > thartman@ubuntu:~/haskell-learning/lazy-n-strict>runghc sequencing.hs > a > first time: second time: a > b > b Well - the input to the leftmost grabby is "second time" prepended to the input from the first, and then you prepend "first time" - so this makes sense. Something like this, perhaps: interact (\s -> let (first,second) = span (not . null) (lines s) in unlines ("first":first++"second":takeWhile (not.null) second)) > If someone can explain the subtleties of using interact when you run > out of stdio here, it would be nice to incorporate this into hGetContents - there can only be one. -k -- If I haven't seen further, it is by standing in the footprints of giants From tom.davie at gmail.com Tue May 5 10:13:14 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Tue May 5 09:58:49 2009 Subject: [Haskell-cafe] applicative challenge In-Reply-To: <910ddf450905050648g41bd42d8g6ce3b82eefe087d0@mail.gmail.com> References: <910ddf450905041415o23086d0cxef88b1b8f4fc04a3@mail.gmail.com> <0BA32E64-1CDE-45DC-BF8B-27DF4F14D437@gmail.com> <910ddf450905050648g41bd42d8g6ce3b82eefe087d0@mail.gmail.com> Message-ID: <2B948BF2-FC7D-47DE-A157-C644C1968235@gmail.com> > I also tried > > t15 = > let grabby = unlines . takeWhile (not . blank) . lines > top = ("first time: " ++) . grabby . ("second time: " ++) . > grabby > in interact top > > > but that didn't work either: > > thartman@ubuntu:~/haskell-learning/lazy-n-strict>runghc sequencing.hs > a > first time: second time: a > b > b > > If someone can explain the subtleties of using interact when you run > out of stdio here, it would be nice to incorporate this into Essentially, what's happening here is that interact consumes *all* of standard input, and runs your function on it. This means that as you've realised here, your function must do *all* of the processing of input in one go ? but this is good! This means our IO is restricted to one tiny little corner of the program, and we get to write pure Haskell everywhere else :) What's going on with your top function on the other hand is that (.) is not `after` in the sense you're thinking. If you want one grabby to consume some of the input, but not all of it you'd need to return a pair containing the output, and the unconsumed input. > where it talks about how using interact is the easy way to approach > these types of problems. Not *that* easy though, as this scenario > suggests. The key here is that it's more composable than using IO ? IO can change all kinds of wierd state, and result in two functions doing totally different things depending on when they're called. This means you can't reliably stick bits of IO code together. With pure functional code though, referential transparency guarentees that you can. Bob From tphyahoo at gmail.com Tue May 5 10:50:45 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Tue May 5 10:36:12 2009 Subject: [Haskell-cafe] applicative challenge In-Reply-To: <871vr37if7.fsf@malde.org> References: <910ddf450905041415o23086d0cxef88b1b8f4fc04a3@mail.gmail.com> <0BA32E64-1CDE-45DC-BF8B-27DF4F14D437@gmail.com> <910ddf450905050648g41bd42d8g6ce3b82eefe087d0@mail.gmail.com> <871vr37if7.fsf@malde.org> Message-ID: <910ddf450905050750k161ef2fdr431c286a0cf64834@mail.gmail.com> seems to be the same behavior whether in ghci or compiled with ghc. 2009/5/5 Ketil Malde : > Thomas Hartman writes: > >> That's slick, but is there some way to use interact twice in the same program? > > No :-) > >> t10 = >> ? let f = unlines . takeWhile (not . blank) . lines >> ? in ?do putStrLn "first time" >> ? ? ? ? ?interact f >> ? ? ? ? ?putStrLn "second time" >> ? ? ? ? ?interact f >> >> this results in *** Exception: : hGetContents: illegal >> operation (handle is closed) -} > > Yes. Interacting uses hGetContents, and hGetContents semi-closes (or > fully-closes) the handle. ?If you do it from GHCi, you only get to run > your program once. > >> I also tried >> >> t15 = >> ? let grabby = unlines . takeWhile (not . blank) . lines >> ? ? ? top = ("first time: " ++) . grabby . ("second time: " ++) . grabby >> ? in ?interact top > >> but that didn't work either: >> thartman@ubuntu:~/haskell-learning/lazy-n-strict>runghc sequencing.hs >> a >> first time: second time: a >> b >> b > > Well - the input to the leftmost grabby is "second time" prepended to > the input from the first, and then you prepend "first time" - so this > makes sense. > > Something like this, perhaps: > > interact (\s -> let (first,second) = span (not . null) (lines s) > ? ? ? ? ? ? ? ?in unlines ("first":first++"second":takeWhile (not.null) second)) > >> If someone can explain the subtleties of using interact when you run >> out of stdio here, it would be nice to incorporate this into > > hGetContents - there can only be one. > > -k > -- > If I haven't seen further, it is by standing in the footprints of giants > From mwinter at brocku.ca Tue May 5 11:02:15 2009 From: mwinter at brocku.ca (mwinter@brocku.ca) Date: Tue May 5 10:47:38 2009 Subject: [Haskell-cafe] Parsec - Custom Fail Message-ID: <4A001CB7.22512.61BAFB@mwinter.brocku.ca> Hi, I am using parsec to parse a small programming language. The language is typed and I need to do some type checking, too. I have decided to do the parsing and type checking simultaneously in the my parsec parser. This approach avoids to keep source code positions in the data type in order to produce suitable error messages during type checking. Anyhow, because type errors are usually detected after parsing some code I need produce error messages with an earlier source position. Unfortunately, there is no function that produces an error taking a position as parameter. I tried the following: myFail :: SourcePos -> String -> GenParser tok st a myFail pos msg = setPosition pos >> fail msg This is already a workaround because I am modifying the position in the parser just to produce an error message. But even worse, it does not work. If I use this function as in: test :: Either ParseError () test = runParser (char '(' >> myFail (newPos "" 100 100) "Test") () "" "(" the position of the error is still the original position (line 1, column 2). As far as I can tell setPosition does not take effect until another symbol is read. This could be achieved by simply using anyToken if we are not at the end of the input (as in the example above). I came up with the following: myFail :: SourcePos -> String -> GenParser Char st a myFail pos msg = do { State toks _ st <- getParserState; setParserState $ State ('d':toks) pos st; anyToken; fail msg } This code works but it is not nice at all. The function myFail is not longer polymorphic in the type of tokens since we need an element of this data type in order to add it temporarily to the input ('d' above). My guess is that one has to enforce strictness at some point in order to work with the first approach, but I was not successful. Any ideas? Thanks, Michael From nccb2 at kent.ac.uk Tue May 5 11:10:40 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Tue May 5 10:55:17 2009 Subject: [Haskell-cafe] Parsec - Custom Fail In-Reply-To: <4A001CB7.22512.61BAFB@mwinter.brocku.ca> References: <4A001CB7.22512.61BAFB@mwinter.brocku.ca> Message-ID: <4A0056F0.3000200@kent.ac.uk> Hi, When we needed to do something similar with Parsec, we chose to pack the relevant source position into the error string (you can just use Show/Read, plus a special sequence of characters to indicate where the position ends and the real error starts). We then unpack it outside runParser before issuing the error to the user. If there's no packed position found, we just use the Parsec position. Thanks, Neil. mwinter@brocku.ca wrote: > Hi, > > I am using parsec to parse a small programming language. The language is typed and > I need to do some type checking, too. I have decided to do the parsing and type checking > simultaneously in the my parsec parser. This approach avoids to keep source code positions > in the data type in order to produce suitable error messages during type checking. Anyhow, > because type errors are usually detected after parsing some code I need produce error > messages with an earlier source position. Unfortunately, there is no function that produces > an error taking a position as parameter. > > I tried the following: > > myFail :: SourcePos -> String -> GenParser tok st a > myFail pos msg = setPosition pos >> fail msg > > This is already a workaround because I am modifying the position in the parser just to > produce an error message. But even worse, it does not work. If I use this function as in: > > test :: Either ParseError () > test = runParser (char '(' >> myFail (newPos "" 100 100) "Test") () "" "(" > > the position of the error is still the original position (line 1, column 2). As far as I can tell > setPosition does not take effect until another symbol is read. This could be achieved by > simply using anyToken if we are not at the end of the input (as in the example above). I > came up with the following: > > myFail :: SourcePos -> String -> GenParser Char st a > myFail pos msg = do { > State toks _ st <- getParserState; > setParserState $ State ('d':toks) pos st; > anyToken; > fail msg > } > > This code works but it is not nice at all. The function myFail is not longer polymorphic in > the type of tokens since we need an element of this data type in order to add it temporarily > to the input ('d' above). > > My guess is that one has to enforce strictness at some point in order to work with the first > approach, but I was not successful. Any ideas? > > Thanks, > Michael > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From martijn at van.steenbergen.nl Tue May 5 11:10:37 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Tue May 5 10:56:05 2009 Subject: [Haskell-cafe] Parsec - Custom Fail In-Reply-To: <4A001CB7.22512.61BAFB@mwinter.brocku.ca> References: <4A001CB7.22512.61BAFB@mwinter.brocku.ca> Message-ID: <4A0056ED.1090601@van.steenbergen.nl> mwinter@brocku.ca wrote: > Hi, > > I am using parsec to parse a small programming language. The language is typed and > I need to do some type checking, too. I have decided to do the parsing and type checking > simultaneously in the my parsec parser. This approach avoids to keep source code positions > in the data type in order to produce suitable error messages during type checking. Anyhow, > because type errors are usually detected after parsing some code I need produce error > messages with an earlier source position. Unfortunately, there is no function that produces > an error taking a position as parameter. If you already know what position you want to report the error at, then why bother calling setPosition to let parsec know? Just do: > fail (show pos ++ ": " ++ msg) Parsec will then result in a ParseError with its own ideas of location, but you can ignore that. HTH, Martijn. From applebiz89 at hotmail.com Tue May 5 11:20:35 2009 From: applebiz89 at hotmail.com (applebiz89) Date: Tue May 5 11:06:00 2009 Subject: [Haskell-cafe] List comprehension Message-ID: <23389686.post@talk.nabble.com> Hi, I think I need to use a list comprehension for this function but Im not good with list comprehension. this is what I have so at the moment? filmsInGivenYear :: Int -> [Film] -> [String] filmsInGivenYear filmYear ?= [ title | year <- (Film title director year fans) , year == filmYear] (this code wont compile - error given '?Syntax error in expression (unexpected `;', possibly due to bad layout)') Is there an alternative solution instead of comprehension? I want the function to be given a release date and then return all films with that date. Thanks -- View this message in context: http://www.nabble.com/List-comprehension-tp23389686p23389686.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From bulat.ziganshin at gmail.com Tue May 5 11:32:12 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue May 5 11:17:59 2009 Subject: [Haskell-cafe] List comprehension In-Reply-To: <23389686.post@talk.nabble.com> References: <23389686.post@talk.nabble.com> Message-ID: <1318211542.20090505193212@gmail.com> Hello applebiz89, Tuesday, May 5, 2009, 7:20:35 PM, you wrote: > filmsInGivenYear :: Int -> [Film] -> [String] > filmsInGivenYear filmYear ?= [ title | year <- (Film title director year > fans) , year == filmYear] (this code wont compile - error given '?Syntax > error in expression (unexpected `;', possibly due to bad layout)') you forget films list variable: filmsInGivenYear filmYear films = [ title | (Film title director year fans) <- films, year == filmYear] -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From noteed at gmail.com Tue May 5 11:34:37 2009 From: noteed at gmail.com (minh thu) Date: Tue May 5 11:20:23 2009 Subject: [Haskell-cafe] List comprehension In-Reply-To: <23389686.post@talk.nabble.com> References: <23389686.post@talk.nabble.com> Message-ID: <40a414c20905050834g7eeaeb57y273aea747dc61c8e@mail.gmail.com> 2009/5/5 applebiz89 : > > Hi, I think I need to use a list comprehension for this function but Im not > good with list comprehension. this is what I have so at the moment? > > filmsInGivenYear :: Int -> [Film] -> [String] > filmsInGivenYear filmYear ?= [ title | year <- (Film title director year > fans) , year == filmYear] (this code wont compile - error given '?Syntax > error in expression (unexpected `;', possibly due to bad layout)') > > Is there an alternative solution instead of comprehension? I want the > function to be given a release date and then return all films with that > date. Hi, I suggest you start by some simple examples, then move to your goal. For instance you can try to write a function which takes in input a list of Int and outputs a list of those Int that are odd. f [1,2,3,4,5] => [1,3,5] You can generalise this function to accept a predicate. g even [1,2,3,4,5] => [2,4] Returning back to your problem, can you write a function that takes a Film and returns its release date ? Then you can write a function which test if that date match a given one. Then, finally, you can write a function which get a list of Film and outputs only those satisfying your desire. Cheers, Thu From rendel at cs.au.dk Tue May 5 11:36:12 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Tue May 5 11:21:11 2009 Subject: [Haskell-cafe] List comprehension In-Reply-To: <23389686.post@talk.nabble.com> References: <23389686.post@talk.nabble.com> Message-ID: <4A005CEC.4040400@cs.au.dk> Hi, applebiz89 wrote: > Hi, I think I need to use a list comprehension There is no need to use list comprehensions, there is always a way to express the same thing without them. In fact, list comprehensions are defined as syntactic shorthands for this other way. > filmsInGivenYear :: Int -> [Film] -> [String] > filmsInGivenYear filmYear ?= [ title | year <- (Film title director year > fans) , year == filmYear] Let's look at the type of your function. You have two arguments of types Int and [Film], so your definition should have two argument names: filmsInGivenYear filmYear films = ... Now, we want to look at each of the films filmsInGivenYear filmYear films = [ ... | film <- films ... ] The part "film <- films" means: Look at each element of films in turn, and name the current one film. But we actually want to look inside the film (we want to check the year). filmsInGivenYear filmYear films = [ ... | Film title director year fans <- films ...] This means to look at each of the films in turn, and match the current film against the pattern (Film title director year fans). So if the current film has been created by a call like (Film ...), we will get the various data fields in the variables title, directory, year and fans. Now we want to check that the year is correct. filmsInGivenYear filmYear films = [ ... | Film title director year fans <- films, filmYear == year] The part (filmYear == year) means that we are only interested in such films where year is filmYear. Finally, we want to return the name of the remaining films. filmsInGivenYear filmYear films = [title | Film title director year fans <- films, filmYear == year] Hope that helps, Tillmann PS. I'm not a native speaker, but shouldn't it be "movies" and not "films"? From mwinter at brocku.ca Tue May 5 11:38:35 2009 From: mwinter at brocku.ca (mwinter@brocku.ca) Date: Tue May 5 11:23:58 2009 Subject: [Haskell-cafe] Parsec - Custom Fail In-Reply-To: <4A0056ED.1090601@van.steenbergen.nl> References: <4A001CB7.22512.61BAFB@mwinter.brocku.ca>, <4A0056ED.1090601@van.steenbergen.nl> Message-ID: <4A00253B.5652.82FCF5@mwinter.brocku.ca> Thanks, but I want a nice solution not another, even more complicated, workaround. On 5 May 2009 at 17:10, Martijn van Steenbergen wrote: > mwinter@brocku.ca wrote: > > Hi, > > > > I am using parsec to parse a small programming language. The language is typed and > > I need to do some type checking, too. I have decided to do the parsing and type checking > > simultaneously in the my parsec parser. This approach avoids to keep source code positions > > in the data type in order to produce suitable error messages during type checking. Anyhow, > > because type errors are usually detected after parsing some code I need produce error > > messages with an earlier source position. Unfortunately, there is no function that produces > > an error taking a position as parameter. > > If you already know what position you want to report the error at, then > why bother calling setPosition to let parsec know? Just do: > > > fail (show pos ++ ": " ++ msg) > > Parsec will then result in a ParseError with its own ideas of location, > but you can ignore that. > > HTH, > > Martijn. From byorgey at seas.upenn.edu Tue May 5 11:48:08 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Tue May 5 11:33:32 2009 Subject: [Haskell-cafe] List comprehension In-Reply-To: <4A005CEC.4040400@cs.au.dk> References: <23389686.post@talk.nabble.com> <4A005CEC.4040400@cs.au.dk> Message-ID: <20090505154808.GA16092@seas.upenn.edu> On Tue, May 05, 2009 at 05:36:12PM +0200, Tillmann Rendel wrote: > > PS. I'm not a native speaker, but shouldn't it be "movies" and not "films"? Both are correct. =) -Brent From dagit at codersbase.com Tue May 5 11:57:36 2009 From: dagit at codersbase.com (Jason Dagit) Date: Tue May 5 11:43:03 2009 Subject: [Haskell-cafe] A brief note on n_k patterns and Hackage In-Reply-To: References: Message-ID: On Tue, May 5, 2009 at 1:30 AM, Magnus Therning wrote: > On Tue, May 5, 2009 at 1:04 AM, Richard O'Keefe wrote: >> I never really understood why it was thought to be relevant, >> but I was challenged to show that n+k patterns occurred in >> Hackage. > > Why is it relevant? Showing that they occur was not relevant. Showing the number of occurrences relative to the number of packages, function definitions, and other features was relevant (in my opinion): http://www.mail-archive.com/haskell-cafe@haskell.org/msg58320.html But, I phrased the challenge poorly and this is what we get :) I was just curious if it's a feature worth holding on it (eg., it gets a lot of good use). Sadly, just me commenting here about that goal will probably rekindle the thread we would all like to avoid... My sincerest apologizes if that happens. Jason From joshhoyt at gmail.com Tue May 5 12:22:45 2009 From: joshhoyt at gmail.com (j3h) Date: Tue May 5 12:08:12 2009 Subject: [Haskell-cafe] A brief note on n_k patterns and Hackage In-Reply-To: References: Message-ID: <34714aad0905050922i17224879jb5ab4dd39ffff5dd@mail.gmail.com> On Mon, May 4, 2009 at 5:23 PM, John Van Enk wrote: > Which package? In 1251 packages, I found 20 source files out of 15144 source files that use (n+k) patterns: queuelike-1.0.9/Data/Queue/Stack.hs queuelike-1.0.9/Data/Queue/TrieQueue.hs hinze-streams-1.0/Data/Stream/Hinze/Stream.hs compression-0.1/Codec/Compression/Utils.hs bytestring-0.9.1.4/tests/lazybuildcons.hs bytestring-0.9.1.4/tests/lazybuild.hs liboleg-0.1.1/Language/TypeLC.hs pqueue-mtl-1.0.7/Data/Queue/Stack.hs pqueue-mtl-1.0.7/Data/Queue/Queue.hs IOSpec-0.2/examples/Echo.hs pxsl-tools-1.0.1/src/PxsltFormat.hs pdf2line-0.0.1/pdf2line.hs stream-fusion-0.1.2.1/tests/Test/SmallCheck/Partial.hs queue-0.1.1.3/src/Data/Queue/Instances/STM.hs frag-1.1.2/src/AFRP.hs th-fold-0.0.0.1/src/Language/Haskell/TH/Fold.hs tetris-0.27178/Util.hs random-fu-0.0.0.2/src/Data/Random/Distribution/Binomial.hs random-fu-0.0.0.2/src/Data/Random/Source/PureMT.hs The method that I used to extract them may have missed some files (e.g. anything that is Haskell source but needs to be preprocessed), but I just wanted to save people the trouble of finding them themselves ;) j3h -- For the curious, those who wish to search other sources, or those who wish to improve on my results, I found these by I downloaded the full Hackage tarball, unpacked it and ran: find ./ -type f \( -name \*.hs -o \*.lhs \) | xargs npk where npk is the following program: > import System.Environment ( getArgs ) > import Control.Monad ( when ) > import Data.Generics ( cast, GenericQ, gcount ) > import Language.Haskell.Exts ( Module, ParseResult(..), Pat(..), parseFile ) > isNPlusK :: GenericQ Bool > isNPlusK x = case cast x of > Just (PNPlusK _ _) -> True > _ -> False > hasNPlusK :: Module -> Bool > hasNPlusK = (> 0) . gcount isNPlusK > printIfNPlusK :: FilePath -> IO () > printIfNPlusK fn = do > res <- parseFile fn > case res of > ParseOk mod -> when (hasNPlusK mod) $ putStrLn fn > _ -> return () > main :: IO () > main = mapM_ printIfNPlusK =<< getArgs From g9ks157k at acme.softbase.org Tue May 5 12:27:17 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Tue May 5 12:12:45 2009 Subject: [Haskell-cafe] Interesting Thread on OO Usefulness (scala mailing list) In-Reply-To: <1634993073.20090504153550@gmail.com> References: <1634993073.20090504153550@gmail.com> Message-ID: <200905051827.18279.g9ks157k@acme.softbase.org> Am Montag, 4. Mai 2009 13:35 schrieb Bulat Ziganshin: > Hello Paolo, > > Monday, May 4, 2009, 2:05:44 PM, you wrote: > > Martin Odersky advocates the OO features of the scala language > > proposing an interesting problem where the OO approach seams > > valuable. > > i know two problems in Haskell/GHC that require OO-loke features - > extensible exceptions and GUI widget types hierarchy Note that you don?t need different types for different kinds of GUI widgets if you use Functional Reactive Programming (FRP). You need different types if you use OO because you have to explicitely modify widgets after you have created them, and what modifications you are allowed to do, depends on the kind of widget. With FRP, you specify the behavior over all time when you create the widget, so no need for later method calls. Best wishes, Wolfgang From bulat.ziganshin at gmail.com Tue May 5 12:39:04 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue May 5 12:24:55 2009 Subject: [Haskell-cafe] Interesting Thread on OO Usefulness (scala mailing list) In-Reply-To: <200905051827.18279.g9ks157k@acme.softbase.org> References: <1634993073.20090504153550@gmail.com> <200905051827.18279.g9ks157k@acme.softbase.org> Message-ID: <1183842735.20090505203904@gmail.com> Hello Wolfgang, Tuesday, May 5, 2009, 8:27:17 PM, you wrote: >> i know two problems in Haskell/GHC that require OO-loke features - >> extensible exceptions and GUI widget types hierarchy > Note that you don?t need different types for different kinds of GUI widgets if > you use Functional Reactive Programming (FRP). You need different types if > you use OO because you have to explicitely modify widgets after you have > created them, and what modifications you are allowed to do, depends on the > kind of widget. With FRP, you specify the behavior over all time when you > create the widget, so no need for later method calls. (i don't know anything about FRP) i think it doesn't change anything. the main reason why i need common operations is because i write generic procedures. another erason os what i can't remember 100 individual 'setSize' operations for 100 types of widgets. so we need to have some generic names, short of they are used due initialization or later -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From haskell at list.mightyreason.com Tue May 5 12:43:26 2009 From: haskell at list.mightyreason.com (ChrisK) Date: Tue May 5 12:29:11 2009 Subject: [Haskell-cafe] ANN: BUG FIX release of regex-tdfa-1.1.2 Message-ID: <4A006CAE.9010506@list.mightyreason.com> Hello, While occasionally and slowly updating the future version of regex-tdfa I found a bug that exists in the released 1.1.1 version. It was just a matter of passing the wrong value into a function, so was easy to fix when I figured it out. The test case triggered an impossible "error" call and so I know this can kill a program that uses a buggy version of this library. Please upgrade regex-tdfa to version 1.1.2 which is available on hackage at: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-tdfa Cheers, Chris From nrolle at web.de Tue May 5 12:49:54 2009 From: nrolle at web.de (Nico Rolle) Date: Tue May 5 12:35:19 2009 Subject: [Haskell-cafe] calling a variable length parameter lambda expression Message-ID: <45fccde20905050949y6a0e8e40s89efdcadd3c8b217@mail.gmail.com> Hi everyone. I have a problem. A function is recieving a lambda expression like this: (\ x y -> x > y) or like this (\ x y z a -> (x > y) && (z < a) my problem is now i know i have a list filled with the parameters for the lambda expression. but how can i call that expression? [parameters] is my list of parameters for the lambda expression. lambda_ex is my lambda expression is there a function wich can do smth like that? lambda _ex (unfold_parameters parameters) best regards From miguelimo38 at yandex.ru Tue May 5 12:56:32 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Tue May 5 12:42:06 2009 Subject: [Haskell-cafe] calling a variable length parameter lambda expression In-Reply-To: <45fccde20905050949y6a0e8e40s89efdcadd3c8b217@mail.gmail.com> References: <45fccde20905050949y6a0e8e40s89efdcadd3c8b217@mail.gmail.com> Message-ID: Short answer: that's impossible. Well, with some oleging it should be possible, but the very fact that you're trying to do something like this indicates that you're doing something wrong. Where did this list of parameters came from? May be, you can apply your function to them one at a time, as they arrive? On 5 May 2009, at 20:49, Nico Rolle wrote: > Hi everyone. > > I have a problem. > A function is recieving a lambda expression like this: > (\ x y -> x > y) > or like this > (\ x y z a -> (x > y) && (z < a) > > my problem is now i know i have a list filled with the parameters for > the lambda expression. > but how can i call that expression? > [parameters] is my list of parameters for the lambda expression. > lambda_ex is my lambda expression > > is there a function wich can do smth like that? > > lambda _ex (unfold_parameters parameters) > > best regards > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ryani.spam at gmail.com Tue May 5 12:58:10 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue May 5 12:43:41 2009 Subject: [Haskell-cafe] calling a variable length parameter lambda expression In-Reply-To: <45fccde20905050949y6a0e8e40s89efdcadd3c8b217@mail.gmail.com> References: <45fccde20905050949y6a0e8e40s89efdcadd3c8b217@mail.gmail.com> Message-ID: <2f9b2d30905050958k6f53f08i18d13cc2dec5b3ea@mail.gmail.com> This is a Hard Problem in Haskell. Let me ask you, how many parameters does this function take? a = (\x -> x) How many parameters does this function take? b = (\f x -> f x) How many parameters does this function take? c = (\f x y -> f x y) What if I call a (+)? -- ryan On Tue, May 5, 2009 at 9:49 AM, Nico Rolle wrote: > Hi everyone. > > I have a problem. > A function is recieving a lambda expression like this: > (\ x y -> x > y) > or like this > (\ x y z a -> (x > y) && (z < a) > > my problem is now i know i have a list filled with the parameters for > the lambda expression. > but how can i call that expression? > [parameters] is my list of parameters for the lambda expression. > lambda_ex is my lambda expression > > is there a function wich can do smth like that? > > lambda _ex (unfold_parameters parameters) > > best regards > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From daniel.is.fischer at web.de Tue May 5 13:42:37 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue May 5 13:29:52 2009 Subject: [Haskell-cafe] Parsec - Custom Fail In-Reply-To: <4A00253B.5652.82FCF5@mwinter.brocku.ca> References: <4A001CB7.22512.61BAFB@mwinter.brocku.ca> <4A0056ED.1090601@van.steenbergen.nl> <4A00253B.5652.82FCF5@mwinter.brocku.ca> Message-ID: <200905051942.38326.daniel.is.fischer@web.de> Am Dienstag 05 Mai 2009 17:38:35 schrieb mwinter@brocku.ca: > Thanks, but I want a nice solution not another, even more complicated, > workaround. I'm afraid you're out of luck there. Parsec carries a ParseError around even for successful parses (where it's a SourcePos and and empty list of messages). When binding two parsers, if the second doesn't consume any input, for the overall result it calls mergeErrorReply, which calls mergeError from Text.ParserCombinators.Parsec.Error: mergeError :: ParseError -> ParseError -> ParseError mergeError (ParseError pos msgs1) (ParseError _ msgs2) = ParseError pos (msgs1 ++ msgs2) So that doesn't look at the position of the second error :( You could change the sources of parsec, the least intrusive would probably be to modify mergeError: mergeError :: ParseError -> ParseError -> ParseError mergeError (ParseError _ []) pe2 = pe2 mergeError (ParseError pos msgs1) (ParseError _ msgs2) = ParseError pos (msgs1 ++ msgs2) or you could employ an ugly workaround like setPosAndFail :: tok -> SourcePos -> String -> GenParser tok st a setPosAndFail dummy pos msg = do setPosition pos inp <- getInput setInput (dummy:inp) tokenPrim (const "") (\p _ _ -> p) Just fail msg myFail :: SourcePos -> String -> GenParser Char st a myFail = setPosAndFail 'a' to pretend you actually consumed some input. It works: *TestWorkAround> test Left (line 100, column 100): Test but isn't pretty. From tphyahoo at gmail.com Tue May 5 14:17:19 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Tue May 5 14:02:46 2009 Subject: [Haskell-cafe] applicative challenge In-Reply-To: <871vr37if7.fsf@malde.org> References: <910ddf450905041415o23086d0cxef88b1b8f4fc04a3@mail.gmail.com> <0BA32E64-1CDE-45DC-BF8B-27DF4F14D437@gmail.com> <910ddf450905050648g41bd42d8g6ce3b82eefe087d0@mail.gmail.com> <871vr37if7.fsf@malde.org> Message-ID: <910ddf450905051117x71f71825qfaac0c04b9c27946@mail.gmail.com> > interact (\s -> let (first,second) = span (not . null) (lines s) in unlines ("first":first++"second":takeWhile (not.null) second)) So, that didn't quite do the right thing, and it seemed like using span/break wouldn't scale well for more than two iterations. Here's another attempt, which is a little closer I think, except that it seems to be using some sort of half-assed state without being explicit about it: module Main where t17 = interact f17 f17 s = let (first,rest) = grabby s (second,_) = grabby rest in "first\n" ++ first ++ "second\n" ++ second grabby :: String -> (String,String) grabby s = let (beg,end) = break null . lines $ s in (unlines beg, (unlines . drop 2 $ end)) 2009/5/5 Ketil Malde : > Thomas Hartman writes: > >> That's slick, but is there some way to use interact twice in the same program? > > No :-) > >> t10 = >> ? let f = unlines . takeWhile (not . blank) . lines >> ? in ?do putStrLn "first time" >> ? ? ? ? ?interact f >> ? ? ? ? ?putStrLn "second time" >> ? ? ? ? ?interact f >> >> this results in *** Exception: : hGetContents: illegal >> operation (handle is closed) -} > > Yes. Interacting uses hGetContents, and hGetContents semi-closes (or > fully-closes) the handle. ?If you do it from GHCi, you only get to run > your program once. > >> I also tried >> >> t15 = >> ? let grabby = unlines . takeWhile (not . blank) . lines >> ? ? ? top = ("first time: " ++) . grabby . ("second time: " ++) . grabby >> ? in ?interact top > >> but that didn't work either: >> thartman@ubuntu:~/haskell-learning/lazy-n-strict>runghc sequencing.hs >> a >> first time: second time: a >> b >> b > > Well - the input to the leftmost grabby is "second time" prepended to > the input from the first, and then you prepend "first time" - so this > makes sense. > > Something like this, perhaps: > > interact (\s -> let (first,second) = span (not . null) (lines s) > ? ? ? ? ? ? ? ?in unlines ("first":first++"second":takeWhile (not.null) second)) > >> If someone can explain the subtleties of using interact when you run >> out of stdio here, it would be nice to incorporate this into > > hGetContents - there can only be one. > > -k > -- > If I haven't seen further, it is by standing in the footprints of giants > From ryani.spam at gmail.com Tue May 5 14:23:42 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue May 5 14:09:08 2009 Subject: FW: Re: [Haskell-cafe] calling a variable length parameter lambda expression In-Reply-To: <45fccde20905051005wcea64caya4cd0923ece8d2ee@mail.gmail.com> References: <1141466607@web.de> <45fccde20905051005wcea64caya4cd0923ece8d2ee@mail.gmail.com> Message-ID: <2f9b2d30905051123u21698ce0m9ade3896be2c10d8@mail.gmail.com> On Tue, May 5, 2009 at 10:05 AM, Nico Rolle wrote: > I dont't understand why u ask me that but the lambda expression will > only get values not functions as a parameter. > a = 1 > b = 2 > c = 3 > >>> What if I call >>> a (+)? > > this won't happen in my use case. > regards nico Here's an example for a single fixed argument and return types: class LambdaApply lam where lamApply :: lam -> [Integer] -> Bool instance LambdaApply Bool where lamApply b [] = b lamApply _ _ = error "Too many arguments in argument list" instance LambdaApply r => LambdaApply (Integer -> r) where lamApply _ [] = error "Not enough arguments in argument list" lamApply f (x:xs) = lamApply (f x) xs The problem is generalizing this to any type, because of the base case: instance LambdaApply r where lamApply r [] = r lamApply _ _ = error "Too many arguments in argument list" overlaps with function types such as (Integer -> a). Since you say this is only for value types, if you're willing to encode each value type you care about, you can make this work in a somewhat more general way. But unless you are just using it for syntactic sugar (which seems unlikely for this use case), it's usually a signal that you are doing something wrong. -- ryan >>> Von: Ryan Ingram >>> Gesendet: 05.05.09 18:58:32 >>> An: Nico Rolle >>> CC: haskell-cafe@haskell.org >>> Betreff: Re: [Haskell-cafe] calling a variable length parameter lambda ?expression >> >>> This is a Hard Problem in Haskell. >>> >>> Let me ask you, how many parameters does this function take? >>> a = (\x -> x) >>> >>> How many parameters does this function take? >>> b = (\f x -> f x) >>> >>> How many parameters does this function take? >>> c = (\f x y -> f x y) >>> >>> What if I call >>> a (+)? >>> >>> ? -- ryan >>> >>> On Tue, May 5, 2009 at 9:49 AM, Nico Rolle wrote: >>> > Hi everyone. >>> > >>> > I have a problem. >>> > A function is recieving a lambda expression like this: >>> > (\ x y -> x > y) >>> > or like this >>> > (\ x y z a -> (x > y) && (z < a) >>> > >>> > my problem is now i know i have a list filled with the parameters for >>> > the lambda expression. >>> > but how can i call that expression? >>> > [parameters] is my list of parameters for the lambda expression. >>> > lambda_ex is my lambda expression >>> > >>> > is there a function wich can do smth like that? >>> > >>> > lambda _ex (unfold_parameters parameters) >>> > >>> > best regards >>> > _______________________________________________ >>> > Haskell-Cafe mailing list >>> > Haskell-Cafe@haskell.org >>> > http://www.haskell.org/mailman/listinfo/haskell-cafe >>> > >>> > From ketil at malde.org Tue May 5 14:53:41 2009 From: ketil at malde.org (Ketil Malde) Date: Tue May 5 14:37:31 2009 Subject: [Haskell-cafe] calling a variable length parameter lambda expression In-Reply-To: <45fccde20905050949y6a0e8e40s89efdcadd3c8b217@mail.gmail.com> (Nico Rolle's message of "Tue\, 5 May 2009 18\:49\:54 +0200") References: <45fccde20905050949y6a0e8e40s89efdcadd3c8b217@mail.gmail.com> Message-ID: <87r5z35qkq.fsf@malde.org> Nico Rolle writes: > A function is recieving a lambda expression like this: > (\ x y -> x > y) > or like this > (\ x y z a -> (x > y) && (z < a) And the type of that function is..? > my problem is now i know i have a list filled with the parameters for > the lambda expression. but how can i call that expression? > [parameters] is my list of parameters for the lambda expression. > lambda_ex is my lambda expression Would this work? data LambdaExpr a = L0 a | L1 (a -> a) | L2 (a -> a -> a) | ... apply :: LambdaExpr a -> [a] -> a apply (L0 x) _ = x apply (L1 f) (x:_) = f x apply (L2 f) (x1:x2:_) = f x1 s2 : -k -- If I haven't seen further, it is by standing in the footprints of giants From tphyahoo at gmail.com Tue May 5 15:30:47 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Tue May 5 15:16:14 2009 Subject: using interact with state, was Re: [Haskell-cafe] applicative challenge Message-ID: <910ddf450905051230w78502e8doed4cf27804ac854e@mail.gmail.com> Aha! There is in fact a way to fit this specification into the applicative paradigm. I'm a bit muzzy as to what it all means, but I must say, aesthetically I'm rather pleased with the result: module Main where import Control.Monad.State import Control.Applicative import Control.Applicative.State -- applicative-extras on hackage -- works t18 = interact $ evalState f18 where f18 = return paint `ap` grabTillBlank `ap` grabTillBlank paint first second = "first\n" ++ first ++ "second\n" ++ second grabTillBlank = State $ \s -> let (beg,end) = break null . lines $ s in (unlines beg, (unlines . drop 2 $ end)) -- And, with applicative extras: t19 = interact $ evalState f19 where f19 = paint <$> grabTillBlank <*> grabTillBlank paint first second = "first\n" ++ first ++ "second\n" ++ second 2009/5/5 Thomas Hartman : >> interact (\s -> let (first,second) = span (not . null) (lines s) > ? ? ? ? ? ? ? in unlines ("first":first++"second":takeWhile (not.null) second)) > > So, that didn't quite do the right thing, and it seemed like using > span/break wouldn't scale well for more than two iterations. Here's > another attempt, which is a little closer I think, except that it > seems to be using some sort of half-assed state without being explicit > about it: > > module Main where > > t17 = interact f17 > f17 s = let (first,rest) = grabby s > ? ? ? ? ? ?(second,_) = grabby rest > ? ? ? ?in "first\n" ++ first ++ "second\n" ++ second > > grabby :: String -> (String,String) > grabby s = > ?let (beg,end) = break null . lines $ s > ?in (unlines beg, (unlines . drop 2 $ end)) > > > 2009/5/5 Ketil Malde : >> Thomas Hartman writes: >> >>> That's slick, but is there some way to use interact twice in the same program? >> >> No :-) >> >>> t10 = >>> ? let f = unlines . takeWhile (not . blank) . lines >>> ? in ?do putStrLn "first time" >>> ? ? ? ? ?interact f >>> ? ? ? ? ?putStrLn "second time" >>> ? ? ? ? ?interact f >>> >>> this results in *** Exception: : hGetContents: illegal >>> operation (handle is closed) -} >> >> Yes. Interacting uses hGetContents, and hGetContents semi-closes (or >> fully-closes) the handle. ?If you do it from GHCi, you only get to run >> your program once. >> >>> I also tried >>> >>> t15 = >>> ? let grabby = unlines . takeWhile (not . blank) . lines >>> ? ? ? top = ("first time: " ++) . grabby . ("second time: " ++) . grabby >>> ? in ?interact top >> >>> but that didn't work either: >>> thartman@ubuntu:~/haskell-learning/lazy-n-strict>runghc sequencing.hs >>> a >>> first time: second time: a >>> b >>> b >> >> Well - the input to the leftmost grabby is "second time" prepended to >> the input from the first, and then you prepend "first time" - so this >> makes sense. >> >> Something like this, perhaps: >> >> interact (\s -> let (first,second) = span (not . null) (lines s) >> ? ? ? ? ? ? ? ?in unlines ("first":first++"second":takeWhile (not.null) second)) >> >>> If someone can explain the subtleties of using interact when you run >>> out of stdio here, it would be nice to incorporate this into >> >> hGetContents - there can only be one. >> >> -k >> -- >> If I haven't seen further, it is by standing in the footprints of giants >> > From tobsan at gmail.com Tue May 5 15:42:00 2009 From: tobsan at gmail.com (Tobias Olausson) Date: Tue May 5 15:27:26 2009 Subject: [Haskell-cafe] ST.Lazy vs ST.Strict In-Reply-To: <49a77b7a0905032152j39a08871me99463366b3c1488@mail.gmail.com> References: <65c9dbea0905031027j60e08cefh162cb63b70c1c721@mail.gmail.com> <2f9b2d30905031511s347e2783vf2a2bcd24083d0de@mail.gmail.com> <65c9dbea0905031654m6550aa98v477643e5abbb4cf0@mail.gmail.com> <49a77b7a0905032152j39a08871me99463366b3c1488@mail.gmail.com> Message-ID: <65c9dbea0905051242o6bb51935i6c8771f768fae74b@mail.gmail.com> This simple implementation of CPU does not behave as expected in the latest version of ghc using ST.Lazy since it updates the `pc` in the wrong order. When we use ghc-6.8 the code works as expected both with lazy and strict ST. How is that? How do we fix this so we can use ghc-6.10. -- ------------------------------------------------------------------ module Main where import Control.Monad.Reader import Control.Monad.ST.Lazy import Data.STRef.Lazy import Data.Array.ST import Int data Refs s = Refs { memory :: STArray s Int8 Int8 , pc :: STRef s Int8 } type CPU s a = ReaderT (Refs s) (ST s) a type Address = Int8 type OPCode = Int8 alterVar v f = asks v >>= lift . flip modifySTRef f getVar v = asks v >>= lift . readSTRef setVar v a = asks v >>= lift . flip writeSTRef a readMem :: Int8 -> CPU s Int8 readMem addr = asks memory >>= lift . flip readArray addr writeMem :: Address -> Int8 -> CPU s () writeMem addr v = asks memory >>= \r -> lift $ writeArray r addr v fetch :: CPU s OPCode fetch = getVar pc >>= \v -> alterVar pc (+1) >> readMem v execute :: OPCode -> CPU s () execute op = case op of 0x4 -> alterVar pc (+100) -- should run this _ -> error "should never match this" initCPU :: ST s (Refs s) initCPU = do m <- newArray_ (0,30) p <- newSTRef 0 return (Refs m p) main :: IO () main = do print $ runST (initCPU >>= runReaderT m) where m = do writeMem 0 0x4 writeMem 1 0x10 op <- fetch execute op getVar pc From andrewcoppin at btinternet.com Tue May 5 17:06:26 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Tue May 5 16:51:52 2009 Subject: [Haskell-cafe] Performance counters In-Reply-To: <49FF5992.4010807@therning.org> References: <49FF4FDD.5080606@btinternet.com> <20090504202813.GE15715@whirlpool.galois.com> <49FF5179.8040501@btinternet.com> <49FF5992.4010807@therning.org> Message-ID: <4A00AA52.5040703@btinternet.com> Magnus Therning wrote: > Andrew Coppin wrote: >> Stuff like "how many times does this function get called? How what's >> the maximum depth it recurses to?" That kind of thing. > > It won't help you, but wouldn't it be the kind of thing that'd fit in > the GHC runtime? > > Do you also require that the counters are available to the program > itself? > > (This is starting to sound like something Don mentioned in his talk in > London...) [I'm getting *really* tired of my ISP thinking that 30% of the traffic from Haskell-cafe is spam. If only there was a way to whitelist it or something... repeatedly clicking "this is not spam" doesn't seem to get the message across.] Um... hmm, that's a good question. Basically I've written a program that does adaptive sampling, and I want to see how much it's recursing. There are two parameters you can adjust: the minimum step size, and the maximum error tollerance. I'd like to know which of the two limits the program is reaching. (In other words, does the error eventually fall below the threshold, or does the step size become too small first?) I guess *ideally* I'd like the end user to be able to find this out from the running program... but I guess to do that there really is no other way than to sprinkle monads or unsafe I/O around the place. From daniel.is.fischer at web.de Tue May 5 17:22:13 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue May 5 17:08:08 2009 Subject: [Haskell-cafe] ST.Lazy vs ST.Strict In-Reply-To: <65c9dbea0905051242o6bb51935i6c8771f768fae74b@mail.gmail.com> References: <65c9dbea0905031027j60e08cefh162cb63b70c1c721@mail.gmail.com> <49a77b7a0905032152j39a08871me99463366b3c1488@mail.gmail.com> <65c9dbea0905051242o6bb51935i6c8771f768fae74b@mail.gmail.com> Message-ID: <200905052322.13746.daniel.is.fischer@web.de> Am Dienstag 05 Mai 2009 21:42:00 schrieb Tobias Olausson: > This simple implementation of CPU does not behave as expected in the > latest version of ghc using ST.Lazy since it updates the `pc` in the > wrong order. > When we use ghc-6.8 the code works as expected both with lazy and strict > ST. How is that? How do we fix this so we can use ghc-6.10. Fix 1: compile with optimisations. The sample code worked here with that. Fix 2: change fetch: > fetch :: CPU s OPCode > fetch = getVar pc >>= \v -> alterVar pc (+1) >> readMem v The lazy ST doesn't actually read the STRef before readMem v is called, so it reads the altered STRef and consequently the wrong memory address. Make sure that v is determined before the STRef is altered, e.g. by fetch = getVar pc >>= \v -> v `seq` (alterVar pc (+1) >> readMem v) or fetch = do v <- getVar pc w <- readMem v alterVar pc succ return w From noteed at gmail.com Tue May 5 17:25:37 2009 From: noteed at gmail.com (minh thu) Date: Tue May 5 17:11:24 2009 Subject: [Haskell-cafe] Performance counters In-Reply-To: <4A00AA52.5040703@btinternet.com> References: <49FF4FDD.5080606@btinternet.com> <20090504202813.GE15715@whirlpool.galois.com> <49FF5179.8040501@btinternet.com> <49FF5992.4010807@therning.org> <4A00AA52.5040703@btinternet.com> Message-ID: <40a414c20905051425i66996ab5sb6b229a257b5b26d@mail.gmail.com> 2009/5/5 Andrew Coppin : > Magnus Therning wrote: >> >> Andrew Coppin wrote: >>> >>> Stuff like "how many times does this function get called? How what's the >>> maximum depth it recurses to?" That kind of thing. >> >> It won't help you, but wouldn't it be the kind of thing that'd fit in the >> GHC runtime? >> >> Do you also require that the counters are available to the program itself? >> >> (This is starting to sound like something Don mentioned in his talk in >> London...) > > [I'm getting *really* tired of my ISP thinking that 30% of the traffic from > Haskell-cafe is spam. If only there was a way to whitelist it or > something... repeatedly clicking "this is not spam" doesn't seem to get the > message across.] > > Um... hmm, that's a good question. Basically I've written a program that > does adaptive sampling, and I want to see how much it's recursing. There are > two parameters you can adjust: the minimum step size, and the maximum error > tollerance. I'd like to know which of the two limits the program is > reaching. (In other words, does the error eventually fall below the > threshold, or does the step size become too small first?) > > I guess *ideally* I'd like the end user to be able to find this out from the > running program... but I guess to do that there really is no other way than > to sprinkle monads or unsafe I/O around the place. Hi, Since your recursive function has to test if the recursion should be ended or continued, when it ends, you know the reason. So why not just wrap your result inside something like: data Result a = ThresholdReached a | StepSizeTooSmall a ? Also, passing an accumulator to the function to record the number of steps should be straightforward. Cheers, Thu From lrpalmer at gmail.com Tue May 5 17:27:29 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue May 5 17:12:54 2009 Subject: [Haskell-cafe] ST.Lazy vs ST.Strict In-Reply-To: <65c9dbea0905031027j60e08cefh162cb63b70c1c721@mail.gmail.com> References: <65c9dbea0905031027j60e08cefh162cb63b70c1c721@mail.gmail.com> Message-ID: <7ca3f0160905051427k2d15a632wa123ca4964870656@mail.gmail.com> On Sun, May 3, 2009 at 11:27 AM, Tobias Olausson wrote: > Hello! > I have a program that is using ST.Strict, which works fine. > However, the program needs to be extended, and to do that, > lazy evaluation is needed. As a result of that, I have switched > to ST.Lazy to be able to do stuff like > > foo y = do > x <- something > xs <- foo (y+1) > return (x:xs) As Ryan points out, this will not do what you want. But that is incidental, not essential: foo y = do x <- something fmap (x:) $ foo (y+1) Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090505/a5b01d31/attachment.htm From lrpalmer at gmail.com Tue May 5 17:35:45 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue May 5 17:21:10 2009 Subject: [Haskell-cafe] ST.Lazy vs ST.Strict In-Reply-To: <7ca3f0160905051427k2d15a632wa123ca4964870656@mail.gmail.com> References: <65c9dbea0905031027j60e08cefh162cb63b70c1c721@mail.gmail.com> <7ca3f0160905051427k2d15a632wa123ca4964870656@mail.gmail.com> Message-ID: <7ca3f0160905051435q767910f7rd5e0e32914cf1d2c@mail.gmail.com> On Tue, May 5, 2009 at 3:27 PM, Luke Palmer wrote: > On Sun, May 3, 2009 at 11:27 AM, Tobias Olausson wrote: > >> Hello! >> I have a program that is using ST.Strict, which works fine. >> However, the program needs to be extended, and to do that, >> lazy evaluation is needed. As a result of that, I have switched >> to ST.Lazy to be able to do stuff like > > >> >> foo y = do >> x <- something >> xs <- foo (y+1) >> return (x:xs) > > > As Ryan points out, this will not do what you want. But that is > incidental, not essential: > > foo y = do > x <- something > fmap (x:) $ foo (y+1) > Questioning my own reasoning, I must apologize. I was wrong, these two programs are identical and both do what you want. Any references to the state *after* the infinite chain of foos will result in _|_, but as long as "something" is the only place that state calls occur, you will be fine. I also suspect that ST.Lazy should be no less defined than ST.Strict in all cases, modulo unsafe operations of course (you aren't doing those, are you?), so you have encountered a bug. Minimize the test case and submit a bug report :-) Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090505/5658c2a7/attachment-0001.htm From tomahawkins at gmail.com Tue May 5 17:50:14 2009 From: tomahawkins at gmail.com (Tom Hawkins) Date: Tue May 5 17:35:39 2009 Subject: [Haskell-cafe] ANN: atom-0.0.3 Message-ID: <594c1e830905051450r7068a7eaq444bd382939a10b8@mail.gmail.com> I pushed out a new version of atom that incorporates some of John's recommendations (thanks John). And it ships with a slightly better example. The release also includes means to extract code coverage to track which atom rules have fired during testing. -Tom http://hackage.haskell.org/cgi-bin/hackage-scripts/package/atom On Tue, May 5, 2009 at 4:06 AM, John Van Enk wrote: > If any one has been looking at this and wants another example, I've finished > two posts on the topic of Atom. > > These posts depend on a patch: > http://code.sw17ch.com/blog/atom/atom_0.0.2_sw17ch_1.diff > > Part 1: http://blog.sw17ch.com/wordpress/?p=84 <- Brief discussion and > describes the patch > Part 2: http://blog.sw17ch.com/wordpress/?p=111 <- Writing a program to > blink an LED. > > Feed back would be appreciated! > > /jve > > On Sun, Apr 26, 2009 at 4:39 PM, Tom Hawkins wrote: >> >> Atom is a DSL in Haskell for designed hard realtime embedded programs. >> ?At Eaton, we are using it to control hydraulic hybrid refuse trucks >> and shuttle buses. ?After my talk at CUFP >> (http://cufp.galois.com/2008/schedule.html), a few people inquired >> about atom -- I finally had a chance to upload it to Hackage. >> >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/atom-0.0.2 >> >> Some new enhancements: >> - A simple rule scheduler for load balancing. >> - Signal probing for debug and data logging. >> - Functional coverage to monitor which rules have executed. >> - Started integration with the Yices SMT solver for bounded model >> checking. >> >> Experiences with our Eaton project: >> - 5K lines of Haskell/atom replaced 120K lines of matlab, simulink, >> and visual basic. >> - 2 months to port simulink design to atom. >> - 3K lines of atom generates 22K lines of embedded C. >> - Design composed of 450 atomic state transition rules. >> - Rules with execution periods from 1ms to 10s all scheduled at >> compile time to a 1 ms main loop. >> - 3 minute compilation time from atom source to ECU. >> - Atom design clears electronic/sw testing on first pass. >> - Currently in vehicle testing with no major issues. >> >> >> Tom >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > From jgoerzen at complete.org Tue May 5 17:54:51 2009 From: jgoerzen at complete.org (John Goerzen) Date: Tue May 5 17:40:16 2009 Subject: [Haskell-cafe] Re: Tests In-Reply-To: <4A00ACF5.4050708@web.de> References: <49FF43D9.4090301@complete.org> <4A00ACF5.4050708@web.de> Message-ID: <4A00B5AB.6090101@complete.org> Guenther Schmidt wrote: > let me first of all thank you for providing the HDBC package. Haskell > would be a much, much less usefull language without a working database > interface. I could certainly not have written the app in Haskell > without it and in any other language I know writing this app would have > been much more difficult. Thanks! I'm glad you found it (and Real World Haskell) helpful. > The problem is what's in the database. > > You'd think there'd be a "G?nni" in the database, right? > > Wrong! > > At least this is where your library and Sqlite disagree. Sqlite with any > GUI client doesn't show a "G?nni", it shows a "G!$%?$?%nni". So do MS > Access and MySql btw. And now that is REALLY weird, because I can't duplicate it here. I wrote this little Haskell program: import Database.HDBC import Database.HDBC.Sqlite3 main = do dbh <- connectSqlite3 "foo.db" run dbh "CREATE TABLE foo (bar text)" [] run dbh "INSERT INTO foo VALUES (?)" [toSql "G?nther"] run dbh "INSERT INTO foo VALUES (?)" [toSql "2-G\252nther"] commit dbh disconnect dbh And when I inspect foo.db with the sqlite3 command-line tool: /tmp$ sqlite3 foo.db SQLite version 3.5.9 Enter ".help" for instructions sqlite> select * from foo; G?nther 2-G?nther Exactly correct, as expected. I can read it back correctly from Haskell, too: import Database.HDBC import Database.HDBC.Sqlite3 import qualified System.IO.UTF8 as U main = do dbh <- connectSqlite3 "foo.db" results <- quickQuery' dbh "SELECT * from foo" [] mapM_ ((print :: String -> IO ()) . fromSql . head) results mapM_ (U.putStrLn . fromSql . head) results disconnect dbh and when I run this: /tmp$ ./foo3a "G\252nther" "2-G\252nther" G?nther 2-G?nther I wonder if there is something weird about your environment: non-unicode terminals, databases, editors, or something? For me, it Just Works as it should. > > For now I managed to rollback the UTF8 code in the HDBC-2.1 and got my > app to work as needed. > > I hope you find this info useful, thanks once more > > G?nther > > From tphyahoo at gmail.com Tue May 5 18:56:38 2009 From: tphyahoo at gmail.com (Thomas Hartman) Date: Tue May 5 18:42:02 2009 Subject: [Haskell-cafe] applicative challenge In-Reply-To: <910ddf450905051117x71f71825qfaac0c04b9c27946@mail.gmail.com> References: <910ddf450905041415o23086d0cxef88b1b8f4fc04a3@mail.gmail.com> <0BA32E64-1CDE-45DC-BF8B-27DF4F14D437@gmail.com> <910ddf450905050648g41bd42d8g6ce3b82eefe087d0@mail.gmail.com> <871vr37if7.fsf@malde.org> <910ddf450905051117x71f71825qfaac0c04b9c27946@mail.gmail.com> Message-ID: <910ddf450905051556k4751d255ld42c97a58fbfc901@mail.gmail.com> > half-assed state for a real state solution, there's follow up here: http://groups.google.com/group/haskell-cafe/browse_thread/thread/d6143504c0e80075 2009/5/5 Thomas Hartman : >> interact (\s -> let (first,second) = span (not . null) (lines s) > ? ? ? ? ? ? ? in unlines ("first":first++"second":takeWhile (not.null) second)) > > So, that didn't quite do the right thing, and it seemed like using > span/break wouldn't scale well for more than two iterations. Here's > another attempt, which is a little closer I think, except that it > seems to be using some sort of half-assed state without being explicit > about it: > > module Main where > > t17 = interact f17 > f17 s = let (first,rest) = grabby s > ? ? ? ? ? ?(second,_) = grabby rest > ? ? ? ?in "first\n" ++ first ++ "second\n" ++ second > > grabby :: String -> (String,String) > grabby s = > ?let (beg,end) = break null . lines $ s > ?in (unlines beg, (unlines . drop 2 $ end)) > > > 2009/5/5 Ketil Malde : >> Thomas Hartman writes: >> >>> That's slick, but is there some way to use interact twice in the same program? >> >> No :-) >> >>> t10 = >>> ? let f = unlines . takeWhile (not . blank) . lines >>> ? in ?do putStrLn "first time" >>> ? ? ? ? ?interact f >>> ? ? ? ? ?putStrLn "second time" >>> ? ? ? ? ?interact f >>> >>> this results in *** Exception: : hGetContents: illegal >>> operation (handle is closed) -} >> >> Yes. Interacting uses hGetContents, and hGetContents semi-closes (or >> fully-closes) the handle. ?If you do it from GHCi, you only get to run >> your program once. >> >>> I also tried >>> >>> t15 = >>> ? let grabby = unlines . takeWhile (not . blank) . lines >>> ? ? ? top = ("first time: " ++) . grabby . ("second time: " ++) . grabby >>> ? in ?interact top >> >>> but that didn't work either: >>> thartman@ubuntu:~/haskell-learning/lazy-n-strict>runghc sequencing.hs >>> a >>> first time: second time: a >>> b >>> b >> >> Well - the input to the leftmost grabby is "second time" prepended to >> the input from the first, and then you prepend "first time" - so this >> makes sense. >> >> Something like this, perhaps: >> >> interact (\s -> let (first,second) = span (not . null) (lines s) >> ? ? ? ? ? ? ? ?in unlines ("first":first++"second":takeWhile (not.null) second)) >> >>> If someone can explain the subtleties of using interact when you run >>> out of stdio here, it would be nice to incorporate this into >> >> hGetContents - there can only be one. >> >> -k >> -- >> If I haven't seen further, it is by standing in the footprints of giants >> > From allbery at ece.cmu.edu Tue May 5 21:29:16 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue May 5 21:14:55 2009 Subject: [Haskell-cafe] Thread on scala ml: Usefulness of OOP In-Reply-To: <2af4014d0905040319l4ea22fe0v732bf3df7b426e5c@mail.gmail.com> References: <2af4014d0905040319l4ea22fe0v732bf3df7b426e5c@mail.gmail.com> Message-ID: On May 4, 2009, at 06:19 , Paolo Losi wrote: > http://www.nabble.com/-scala--usefulness-of-OOP-td23268250.html > > Martin Odersky, scala creator, advocates the use of OOP using > an interesting toy problem. > I would be very interested about the haskell point of view on the > topic. > Is there any haskell guru that wants to take a stub at the problem > or give his opinion? Did you read the HaskellWiki link given in the comments? http://haskell.org/haskellwiki/OOP_vs_type_classes The top of the page suggests it's incomplete but there is a lot of stuff in there including example 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/20090505/db6bb636/PGP.bin From ok at cs.otago.ac.nz Tue May 5 21:50:16 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue May 5 21:35:43 2009 Subject: [Haskell-cafe] A brief note on n_k patterns and Hackage In-Reply-To: References: Message-ID: On 5 May 2009, at 8:30 pm, Magnus Therning wrote: > On Tue, May 5, 2009 at 1:04 AM, Richard O'Keefe > wrote: >> I never really understood why it was thought to be relevant, >> but I was challenged to show that n+k patterns occurred in >> Hackage. > > Why is it relevant? Some people think that the popularity of a feature in an openly accessible collection of Haskell sources is relevant to whether it should continue to be supported, in a way that, say, appearance in textbooks, utility to beginners, and contribution to readability are not. Apparently. I don't understand this. n+k patterns are the ONLY Haskell98 feature scheduled for removal from Haskell'. From dons at galois.com Tue May 5 21:57:20 2009 From: dons at galois.com (Don Stewart) Date: Tue May 5 21:44:08 2009 Subject: [Haskell-cafe] A brief note on n_k patterns and Hackage In-Reply-To: References: Message-ID: <20090506015720.GA22602@whirlpool.galois.com> ok: > On 5 May 2009, at 8:30 pm, Magnus Therning wrote: > >> On Tue, May 5, 2009 at 1:04 AM, Richard O'Keefe >> wrote: >>> I never really understood why it was thought to be relevant, >>> but I was challenged to show that n+k patterns occurred in >>> Hackage. >> >> Why is it relevant? > > Some people think that the popularity of a feature in > an openly accessible collection of Haskell sources is > relevant to whether it should continue to be supported, > in a way that, say, appearance in textbooks, utility > to beginners, and contribution to readability are not. > Apparently. This was the main reason it was kept in Haskell 98, 11 years ago. New textbooks don't use it (RWH doesn't talk or recommend the use of n+k) > I don't understand this. n+k patterns are the ONLY > Haskell98 feature scheduled for removal from Haskell'. For multiple reasons, summarised here: http://hackage.haskell.org/trac/haskell-prime/wiki/RemoveNPlusK -- Don From porges at porg.es Tue May 5 21:58:45 2009 From: porges at porg.es (porges@porg.es) Date: Tue May 5 21:44:23 2009 Subject: [Haskell-cafe] List comprehension In-Reply-To: <1318211542.20090505193212@gmail.com> Message-ID: 2009/5/6 Bulat Ziganshin : > Hello applebiz89, > > Tuesday, May 5, 2009, 7:20:35 PM, you wrote: > >> filmsInGivenYear :: Int -> [Film] -> [String] >> filmsInGivenYear filmYear ?= [ title | year <- (Film title director year >> fans) , year == filmYear] (this code wont compile - error given '?Syntax >> error in expression (unexpected `;', possibly due to bad layout)') > > you forget films list variable: > > filmsInGivenYear filmYear films = > ?[ title | (Film title director year fans) <- films, year == filmYear] And this is nicer if you define Film with records: -- just guessing as to types data Film = Film { title :: String, director :: String, year :: Int, fans :: [Fan] } filmsInGivenYear filmYear films = [title | film <- films, year film == filmYear] -- and then it's probably easier written as: filmsInGivenYear filmYear films = filter (\film -> year film == filmYear) films -- or slightly simpler: filmsInGivenYear filmYear = filter (\film -> year film == filmYear) -- or with Data.Function.Predicate (shameless plug) : filmsInGivenYear filmYear = filter (year `equals` filmYear) -------------- 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/20090506/de2ff7ad/signature.bin From ok at cs.otago.ac.nz Tue May 5 22:20:42 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue May 5 22:06:08 2009 Subject: [Haskell-cafe] calling a variable length parameter lambda expression In-Reply-To: <45fccde20905050949y6a0e8e40s89efdcadd3c8b217@mail.gmail.com> References: <45fccde20905050949y6a0e8e40s89efdcadd3c8b217@mail.gmail.com> Message-ID: <8422FCF5-EFDA-40B3-82EC-DEDB9F002C1E@cs.otago.ac.nz> On 6 May 2009, at 4:49 am, Nico Rolle wrote: > Hi everyone. > > I have a problem. > A function is recieving a lambda expression like this: > (\ x y -> x > y) > or like this > (\ x y z a -> (x > y) && (z < a) Your first function has type Ord a => a -> a -> Bool so your list of parameters must have type Ord a => [a] and length 2. Your second function -- and why do you have the excess parentheses? they make it harder to read -- has type Ord a => a -> a -> a -> Bool so your list of parameters must have type Ord a => [a] and length 3. > but how can i call that expression? > [parameters] is my list of parameters for the lambda expression. > lambda_ex is my lambda expression > > is there a function wich can do smth like that? > > lambda _ex (unfold_parameters parameters) but in both cases lambda_ex wants a single Ord, so unfold_parameters parameters would have to return just that Ord. You _could_ fake something up for this case using type classes, but the big question is WHY do you want to do this? It makes sense for Lisp or Scheme, but not very much sense for a typed language. Why are you building a list [x,y] or [x,y,z] rather than a function (\f -> f x y) or (\f -> f x y z) so that you can do parameters lambda_ex? From wren at freegeek.org Tue May 5 22:38:09 2009 From: wren at freegeek.org (wren ng thornton) Date: Tue May 5 22:23:35 2009 Subject: [Haskell-cafe] Re: Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <87ab5skcf8.fsf@forno.us> References: <87fxfll3ad.fsf@forno.us> <49FEBAA1.5060205@theingots.org> <87ab5skcf8.fsf@forno.us> Message-ID: <4A00F811.8000206@freegeek.org> Chris Forno (jekor) wrote: > The idea is that I spent years studying different languages, generally > with a textbook. The textbooks tend to focus on teaching rules and > grammar, with a little bit of vocabulary and dialog each chapter. I > think the focus should be reversed. This varies wildly by textbook, with some bias for the language being taught. Personally I've found too many vocabulary textbooks and far too few grammar textbooks (that is, actual *grammar* textbooks not sentence-sized-vocabulary textbooks). > Obviously grammar is very important. But is reading about it effective > for everyone? In my experience learning and teaching languages, this too varies wildly by learner. Some people do better with an "examples first" or "vocabulary based" style where they must come to an intuition of the grammar rules; other people (such as myself) do better with a "rules first" or "grammar based" style where they must come to learn vocabulary on their own. Neither variety of person is superior nor, as far as I can tell, more common at large; so any good teacher or textbook should balance these "bottom up" and "top down" approaches. IMO vocabulary is easy to learn, it just takes time, whereas grammar is harder to figure out on one's own, and so is the better thing for a teacher to focus on. However, this says little about reference material (as opposed to learning material), and study guides walk a line between reference and teaching. JGram is an interesting study guide that takes a middle path, treating syntactic patterns the same as it does lexemes. This is particularly appropriate for a language like Japanese where it's not always immediately apparent whether something belongs to the "grammar" vs the "lexicon". > The only way I > successfully became fluent in a language (Esperanto) was through > immersion, This is, hands down, the best way to learn any language. For it to work, as you say, some vocabulary is necessary; however, I think the amount of vocabulary needed at first is not so large as some think. Daily small-talk for getting/giving directions, ordering food, and the like comprise a large portion of beginner's language and requires remarkably little breadth of vocabulary (a couple hundred words or so). Small-talk also includes some of the most obscure and difficult-to-master grammatical patterns like greetings, getting the right tone of politeness/familiarity, and knowing what sorts of sentence fragments and other "ungrammatical" patterns are perfectly acceptable. > And of course it has very forgiving sentence and a rather simple > grammar, but I'm finding the experience to be very similar with Japanese > so far. > > That being said, Esperanto, and even Japanese sentence structure perhaps > is not as different as an agglutinative language like German. I'll need > to study it more to find out. Actually, Japanese is agglutinative too (moreso than German is). The basic structures of Japanese are quite simple, however the details needed for fluency are quite intricate. Phrase order is rather free, though it is not entirely free and it is easy to reorder things so that they no longer make sense to native speakers. Aside from a few of the common mistakes beginners make, if you mess up the cases/particles you'll end up with gibberish. -- Live well, ~wren From allbery at ece.cmu.edu Tue May 5 22:48:28 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue May 5 22:34:16 2009 Subject: [Haskell-cafe] setResourceLimit In-Reply-To: <20090505085239.GJ19506@doses> References: <20090505085239.GJ19506@doses> Message-ID: <48CBBF03-FDD8-41CC-B931-501854ACBAB9@ece.cmu.edu> On May 5, 2009, at 04:52 , brian@lorf.org wrote: > I have a long-lived multithreaded server process that needs to execute > programs and interact with them via Handles. The programs could > misbehave, like loop or hang, so I need to limit the real and CPU time > they can take. > > I guess System.Posix.Resource.setResourceLimit sets limits on the > current process, so I can't use it in the server process. Is it a good > approach to write some utility program for the server to call that > does > setResourceLimit and executes the programs that could misbehave? An alternative is to forkProcess and have the child setResourceLimit and then executeFile. -- 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/20090505/09e4766e/PGP.bin From vigalchin at gmail.com Tue May 5 23:39:45 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Tue May 5 23:33:19 2009 Subject: [Haskell-cafe] runhaskell CLI parameters Message-ID: <5ae4f2ba0905052039tbe5791j53b80863650ffee3@mail.gmail.com> Hello, I have forgotten the runhaskell CLI parameters ... sigh. In particular I want to a "local" build of a set of of package: runhaskell Setup.hs configure --user??? I just did a "runhaskell -?" which didn't tell me a lot! Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090505/4b31d1a0/attachment.htm From allbery at ece.cmu.edu Tue May 5 23:54:45 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue May 5 23:40:32 2009 Subject: [Haskell-cafe] runhaskell CLI parameters In-Reply-To: <5ae4f2ba0905052039tbe5791j53b80863650ffee3@mail.gmail.com> References: <5ae4f2ba0905052039tbe5791j53b80863650ffee3@mail.gmail.com> Message-ID: <6A483BD5-3A80-4AD4-970C-0A37E298CECD@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/20090505/c883afb6/PGP.bin From mail at justinbogner.com Wed May 6 00:00:14 2009 From: mail at justinbogner.com (mail@justinbogner.com) Date: Tue May 5 23:45:53 2009 Subject: [Haskell-cafe] Re: runhaskell CLI parameters References: <5ae4f2ba0905052039tbe5791j53b80863650ffee3@mail.gmail.com> Message-ID: <87ocu6anjl.fsf@justinbogner.com> "Vasili I. Galchin" writes: > Hello, > > ???? I have forgotten the runhaskell CLI parameters ... sigh. In particular I > want to a "local" build of a set of of package: > > ???????? runhaskell Setup.hs configure --user??? > > I just did a "runhaskell -?" which didn't tell me a lot! Try runhaskell Setup.hs --help. runhaskell's help isn't very useful here, because the program you're interested in is actually Setup.hs. From dons at galois.com Wed May 6 01:52:31 2009 From: dons at galois.com (Don Stewart) Date: Wed May 6 01:39:18 2009 Subject: [Haskell-cafe] ANNOUNCE: The Haskell Platform Message-ID: <20090506055231.GC22875@whirlpool.galois.com> We're pleased to announce the first release of the Haskell Platform: a single, standard Haskell distribution for every system. Download the Haskell Platform 2009.2.0 installers and specification: http://hackage.haskell.org/platform/ The Haskell Platform is a blessed library and tool suite for Haskell culled from Hackage, along with installers for a wide variety of systems. It saves developers work picking and choosing the best Haskell libraries and tools to use for a task. What you get: http://hackage.haskell.org/platform/contents.html With regular time-based releases, we expect the platform will grow into a rich, indispensable development environment for all Haskell projects. Distro maintainers that support the Haskell Platform can be confident they're fully supporting Haskell as the developers intend it. Developers targetting the platform can be confident they have a trusted base of code to work with. *Please note that this is a beta release*. We do not expect all the installers to work perfectly, nor every developer need met, and we would appreciate feedback. You can help out by packaging the platform for your distro, or reporting bugs and feature requests, or installing Haskell onto your friends' machines. The process for adding new tools and libraries will be outlined in coming weeks. The Haskell Platform would not have been possible without the hard work of the Cabal development team, the Hackage developers and maintainers, the individual compiler, tool and library authors who contributed to the suite, and the distro maintainers who build and distribute the Haskell Platform. Thanks! -- The Platform Infrastructure Team From rvdalen at yahoo.co.uk Wed May 6 02:07:25 2009 From: rvdalen at yahoo.co.uk (Rouan van Dalen) Date: Wed May 6 01:52:54 2009 Subject: [Haskell-cafe] Writing a compiler in Hakell Message-ID: <999221.11069.qm@web23707.mail.ird.yahoo.com> Hi everyone. I am designing my own programming language. I would like to know what is the best way to go about writing my compiler in haskell. What are the tools available in haskell that can help with compiler construction? I know about Happy. Is that a good tool to use? The compiler is intended for serious use and I would like it to be very efficient, maybe competing with compilers written in C. It should also be very easy to extend as the languoge grows. Are there any good books that you can recommend on compiler construction in general and specific to haskell? On another note, how is the operator + implemented in haskell? is there a primitve (say #+) that is wrapped by the haskell operator +? Maybe something like: (+) :: a -> a -> a v1 + v2 = #+ v1 v2 Thanks in advance Rouan. From noteed at gmail.com Wed May 6 02:25:22 2009 From: noteed at gmail.com (minh thu) Date: Wed May 6 02:11:06 2009 Subject: [Haskell-cafe] Writing a compiler in Hakell In-Reply-To: <999221.11069.qm@web23707.mail.ird.yahoo.com> References: <999221.11069.qm@web23707.mail.ird.yahoo.com> Message-ID: <40a414c20905052325h5383a0c1l24894a07c229ef6b@mail.gmail.com> 2009/5/6 Rouan van Dalen : > > Hi everyone. > > I am designing my own programming language. > > I would like to know what is the best way to go about writing my compiler in haskell. > What are the tools available in haskell that can help with compiler construction? > > I know about Happy. Is that a good tool to use? > > The compiler is intended for serious use and I would like it to be very efficient, maybe competing > with compilers written in C. It should also be very easy to extend as the languoge grows. Hi, This seems an interesting project. Can you tell us a bit more about your language (functional, dynamic, lazy, does it support call/cc, ...) ? What about the target language (C, C--, x86 assembly, some virtual machine) ? What about the syntax ? Depending of the kind of answers you might provide, specific directions can probably be given. Also, you say "maybe competing with compilers written in C", do you really talk about compiler performance or about generated code performance ? Once those questions are resolved, you can go to hackage, see a list of packages. http://hackage.haskell.org/packages/archive/pkg-list.html For x86 machine code: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/harpy For LLVM: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/llvm For C: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/language-c Cheers, Thu From lrpalmer at gmail.com Wed May 6 02:31:40 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed May 6 02:17:03 2009 Subject: [Haskell-cafe] Writing a compiler in Hakell In-Reply-To: <999221.11069.qm@web23707.mail.ird.yahoo.com> References: <999221.11069.qm@web23707.mail.ird.yahoo.com> Message-ID: <7ca3f0160905052331q69bd2d99p118addd29323838c@mail.gmail.com> On Wed, May 6, 2009 at 12:07 AM, Rouan van Dalen wrote: > > Hi everyone. > > I am designing my own programming language. > > I would like to know what is the best way to go about writing my compiler > in haskell. > What are the tools available in haskell that can help with compiler > construction? > > I know about Happy. Is that a good tool to use? I don't like Happy. Using a parser generator is like admitting defeat, when we have no defeat to admit. I would recommend a parser combinator library like Parsec (or if you like building things from the ground up, ReadP). > > The compiler is intended for serious use and I would like it to be very > efficient, maybe competing with compilers written in C. It should also be very easy to extend as the > languoge grows. I agree with minh thu; there are too many questions to consider before giving too much specific advice. But in almost all cases, plan on the production version of your compiler being written in the language it is compiling. This has many advantages. > > Are there any good books that you can recommend on compiler construction in > general and specific to haskell? > > > On another note, how is the operator + implemented in haskell? > > is there a primitve (say #+) that is wrapped by the haskell operator +? > Maybe something like: > > (+) :: a -> a -> a > v1 + v2 = #+ v1 v2 It varies from compiler to compiler, but in general, yes. And in GHC I think it is called +#, actually, but you need to do some digging to find it, and your code won't be portable once you do. Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090506/41fa31d8/attachment.htm From jeanchristophe.mincke at gmail.com Wed May 6 02:46:17 2009 From: jeanchristophe.mincke at gmail.com (jean-christophe mincke) Date: Wed May 6 02:31:44 2009 Subject: [Haskell-cafe] Writing a compiler in Hakell In-Reply-To: <999221.11069.qm@web23707.mail.ird.yahoo.com> References: <999221.11069.qm@web23707.mail.ird.yahoo.com> Message-ID: Hello Rouan My bible : The dragon book of Aho, Sethi & Ullman http://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools Regards J-C On Wed, May 6, 2009 at 8:07 AM, Rouan van Dalen wrote: > > Hi everyone. > > I am designing my own programming language. > > I would like to know what is the best way to go about writing my compiler > in haskell. > What are the tools available in haskell that can help with compiler > construction? > > I know about Happy. Is that a good tool to use? > > The compiler is intended for serious use and I would like it to be very > efficient, maybe competing > with compilers written in C. It should also be very easy to extend as the > languoge grows. > > Are there any good books that you can recommend on compiler construction in > general and specific to haskell? > > > On another note, how is the operator + implemented in haskell? > > is there a primitve (say #+) that is wrapped by the haskell operator +? > Maybe something like: > > (+) :: a -> a -> a > v1 + v2 = #+ v1 v2 > > > > > Thanks in advance > > Rouan. > > > > > _______________________________________________ > 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/20090506/6336c687/attachment.htm From dagit at codersbase.com Wed May 6 02:50:51 2009 From: dagit at codersbase.com (Jason Dagit) Date: Wed May 6 02:36:15 2009 Subject: [Haskell-cafe] Writing a compiler in Hakell In-Reply-To: <999221.11069.qm@web23707.mail.ird.yahoo.com> References: <999221.11069.qm@web23707.mail.ird.yahoo.com> Message-ID: On Tue, May 5, 2009 at 11:07 PM, Rouan van Dalen wrote: > > Hi everyone. > > I am designing my own programming language. > > I would like to know what is the best way to go about writing my compiler in haskell. > What are the tools available in haskell that can help with compiler construction? I think GHC itself uses Alex and Happy for tokenizing and parsing respectively. Parsec is a nice parser combinator library. Another tool you could employ is Higher Order Abstract Syntax (more of an idiom), and there are papers about it if you google for them. It's a way of representing the program you want to compile and doing transformations on it. > I know about Happy. ?Is that a good tool to use? My understanding is that GHC uses it. I think they are happy with happy, but maybe a GHC dev could comment. > The compiler is intended for serious use and I would like it to be very efficient, maybe competing > with compilers written in C. ?It should also be very easy to extend as the languoge grows. I think one of the biggest slow downs for compilers is the complexity of parsing and the complexity of the compilation. For example, If you pick a grammar that parses efficiently and do less sophisticated analyses involving a single pass and so on it will be fast to compile. The draw back is that the compiled programs may execute more slowly than if you did lots of analysis or optimization. As an example of what not to do, C++ has a notoriously complex to parse grammar along with some other issues that make it a slow compiling language :) > Are there any good books that you can recommend on compiler construction in general and specific to haskell? I like "Modern Compiler Design" myself: http://www.amazon.com/Modern-Compiler-Design-D-Grune/dp/0471976970 I would also recommend reading the haskell report to get an idea of what a friendly language specification looks like: http://www.haskell.org/onlinereport/ One point of advice I would give is defining your language as an embedded language in Haskell first. You can start with the data type that holds your intermediate representation or abstract syntax. Then you can work on either code generation or evaluation. As you start to settle on your data structures and the language primitives you can begin working on a parser. In a sense, the parser is the last part you need to finish. I've found this approach to be quite accommodating and to also save me a lot of time. If you google for it, there is a fair bit of literature about domain specific and embedded domain specific languages in Haskell. It's quite a good language for prototyping this way. Once you write some code you'll discover that some things are taking too long. In that case, you'll want to learn how to make proper use of the GHC profiler, assuming you use GHC as your haskell compiler. It's quite powerful and by using it correctly you can zoom in on the slow spots and dramatically improve the performance of your compiler. I found this paper to be a nice way to get started: http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf One of the brilliant bits in that paper is that it teaches you to use an existing compiler (gcc) to generate code and then learn how to implement things by example! I highly recommend reading it. It's written about a scheme compiler, but it applies equally well to other languages. Good luck! Jason From scriptdevil.haskell at gmail.com Wed May 6 02:51:54 2009 From: scriptdevil.haskell at gmail.com (Ashok Gautham) Date: Wed May 6 02:37:18 2009 Subject: [Haskell-cafe] Reply to Message-ID: I feel that the haskell mailing lists must have the reply-to field set, so that a person can reply to the list by just clicking reply. I am unsure if I am the only one facing this problem. --- Ashok `ScriptDevil` Gautham From martijn at van.steenbergen.nl Wed May 6 03:16:19 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed May 6 03:01:48 2009 Subject: [Haskell-cafe] Writing a compiler in Hakell In-Reply-To: <999221.11069.qm@web23707.mail.ird.yahoo.com> References: <999221.11069.qm@web23707.mail.ird.yahoo.com> Message-ID: <4A013943.4000909@van.steenbergen.nl> Rouan van Dalen wrote: > Hi everyone. > > I am designing my own programming language. > > I would like to know what is the best way to go about writing my compiler in haskell. > What are the tools available in haskell that can help with compiler construction? > > I know about Happy. Is that a good tool to use? > > The compiler is intended for serious use and I would like it to be very efficient, maybe competing > with compilers written in C. It should also be very easy to extend as the languoge grows. Be sure to take a look at attribute grammars (AG). From what I hear it varies whether people like using them, but they're worth a try at least. The Monad Reader Issue 4 has an introductory article on AGs [1] by Wouter Swierstra, explaining what they do and how they are useful. I hear Happy has an AG system [2]. Probably the most mature standalone AG is the UUAG [3], with which the Utrecht Haskell Compiler [4] was built. HTH, Martijn. [1] http://www.haskell.org/haskellwiki/The_Monad.Reader/Issue4/Why_Attribute_Grammars_Matter [2] http://www.haskell.org/happy/doc/html/sec-AttributeGrammar.html [3] http://www.cs.uu.nl/wiki/HUT/AttributeGrammarSystem [4] http://www.cs.uu.nl/wiki/UHC From martijn at van.steenbergen.nl Wed May 6 03:21:00 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed May 6 03:06:28 2009 Subject: [Haskell-cafe] List comprehension In-Reply-To: References: Message-ID: <4A013A5C.7070504@van.steenbergen.nl> porges@porg.es wrote: > -- or with Data.Function.Predicate (shameless plug) > : Whoa, a function called "isn't", why is this the first time I see that? :-) Martijn. From matthijs at stdin.nl Wed May 6 03:40:02 2009 From: matthijs at stdin.nl (Matthijs Kooijman) Date: Wed May 6 03:25:26 2009 Subject: [Haskell-cafe] Reply to In-Reply-To: References: Message-ID: <20090506074001.GF16305@katherina.student.utwente.nl> Hi Ashok, > I feel that the haskell mailing lists must have the reply-to field set, so that > a person can reply to the list by just clicking reply. Most email clients have a "followup" or "reply-to-all" feature, that will do this. Better email clients also support (setting and reading) the Mail-Followup-To header, which can prevents duplicates from being sent to someone who is also subscribed to the list and ensure that replies are sent directly to someone who is not on the list. Using the reply-to header for this purpos is really wrong IMHO, since that prevents people from easily replying directly to the author (and usually makes personal email end up on the list as well) and makes it impossible for people to use the Reply-To header for the purpose it was really meant for. See also http://cr.yp.to/proto/replyto.html 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/20090506/6f97e7d1/attachment.bin From florbitous at gmail.com Wed May 6 04:02:45 2009 From: florbitous at gmail.com (Bernie Pope) Date: Wed May 6 03:48:08 2009 Subject: [Haskell-cafe] Writing a compiler in Hakell In-Reply-To: <999221.11069.qm@web23707.mail.ird.yahoo.com> References: <999221.11069.qm@web23707.mail.ird.yahoo.com> Message-ID: <4d8ad03a0905060102j5c0d7328u2d8ec6a09fe620a8@mail.gmail.com> 2009/5/6 Rouan van Dalen > > I know about Happy. ?Is that a good tool to use? Alex and Happy are used in (at least) these two packages: ?? http://hackage.haskell.org/cgi-bin/hackage-scripts/package/language-python ???http://hackage.haskell.org/cgi-bin/hackage-scripts/package/language-c You should be able to find lots of useful code to start with in both of those. You can get good performance out of Alex and Happy. Of course there are more considerations than just performance, and you will get different opinions about those other aspects. I wrote the python parser above and I was quite pleased with Alex and Happy from a usability perspective. LLVM is a nice framework for building the backend of a compiler, and the Haskell bindings are quite useful: ???http://hackage.haskell.org/cgi-bin/hackage-scripts/package/llvm The amount of work you have to do depends on your runtime system (GC, threads, exceptions etc). If your language has fairly conventional semantics?(a typical imperative language) then you can reuse a lot of the existing infrastructure that LLVM provides. > On another note, how is the operator + implemented in haskell? It is good to differentiate Haskell "the language specification" from compilers (and other tools)?which implement it. The language specification does not say exactly how the primitive operations should be implemented; that is a detail which is up to the compiler writer to decide. GHC's implementation is the best documented, and there are many research papers which describe aspects of it (some outdated). For numerical primitives, you could start by looking at this paper: ?? "Unboxed values as first class citizens in a non-strict functional language" Peyton Jones and Launchbury. ?? http://research.microsoft.com/en-us/um/people/simonpj/papers/unboxed-values.ps.Z Cheers, Bernie. From sfvisser at cs.uu.nl Wed May 6 04:52:58 2009 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Wed May 6 04:38:27 2009 Subject: [Haskell-cafe] Writing a compiler in Hakell In-Reply-To: <999221.11069.qm@web23707.mail.ird.yahoo.com> References: <999221.11069.qm@web23707.mail.ird.yahoo.com> Message-ID: On May 6, 2009, at 8:07 AM, Rouan van Dalen wrote: > Hi everyone. > > I am designing my own programming language. > > I would like to know what is the best way to go about writing my > compiler in haskell. > What are the tools available in haskell that can help with compiler > construction? > > I know about Happy. Is that a good tool to use? > > The compiler is intended for serious use and I would like it to be > very efficient, maybe competing > with compilers written in C. It should also be very easy to extend > as the languoge grows. > > Are there any good books that you can recommend on compiler > construction in general and specific to haskell? What is your goal? Writing a compiler, for fun and educational purposes, or to implement a new language? When the actual language is the main purpose and your language will be a functional one you can try to piggyback on existing compilers. For example, translate your language to the GHC core or UHC[1] core and you get a cross platform highly optimizing compiler for free. You can now freely focus on the semantics of your language and let an existing code generator do the dirty work for you. When, in the end when your languages is finished, the existing compiler is not fast enough, improve it and everyone benefits! > On another note, how is the operator + implemented in haskell? > > is there a primitve (say #+) that is wrapped by the haskell operator > +? > Maybe something like: > > (+) :: a -> a -> a > v1 + v2 = #+ v1 v2 > > Thanks in advance > > Rouan. [1] https://svn.cs.uu.nl:12443/repos/EHC/trunk/EHC/src/ehc/Core/AbsSyn.cag -- Sebastiaan Visser From magnus at therning.org Wed May 6 05:05:05 2009 From: magnus at therning.org (Magnus Therning) Date: Wed May 6 04:50:33 2009 Subject: [Haskell-cafe] Reply to In-Reply-To: References: Message-ID: On Wed, May 6, 2009 at 7:51 AM, Ashok Gautham wrote: > I feel that the haskell mailing lists must have the reply-to field set, so that > a person can reply to the list by just clicking reply. > > I am unsure if I am the only one facing this problem. This is a contentious issue: http://www.unicom.com/pw/reply-to-harmful.html http://marc.merlins.org/netrants/reply-to-useful.html I personally think mailing-lists shouldn't put themselves in the Reply-To, and that easy replying to the list is something that should be handled in the mail client (I base my choice of mail client on this). What client are you using? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From asviraspossible at gmail.com Wed May 6 05:55:02 2009 From: asviraspossible at gmail.com (Victor Nazarov) Date: Wed May 6 05:40:26 2009 Subject: [Haskell-cafe] calling a variable length parameter lambda expression In-Reply-To: <45fccde20905050949y6a0e8e40s89efdcadd3c8b217@mail.gmail.com> References: <45fccde20905050949y6a0e8e40s89efdcadd3c8b217@mail.gmail.com> Message-ID: On Tue, May 5, 2009 at 8:49 PM, Nico Rolle wrote: > Hi everyone. > > I have a problem. > A function is recieving a lambda expression like this: > (\ x y -> x > y) > or like this > (\ x y z a -> (x > y) && (z < a) > > my problem is now i know i have a list filled with the parameters for > the lambda expression. > but how can i call that expression? > [parameters] is my list of parameters for the lambda expression. > lambda_ex is my lambda expression > > is there a function wich can do smth like that? > > lambda _ex (unfold_parameters parameters) > Why not: lam1 = \[x, y] -> x > y lam2 = \[x, y, z, a] -> (x > y) && (z < a) doLam :: Ord a => ([a] -> Bool) -> [a] -> Bool doLam lam params = lam params So, this will work fine: doLam lam1 [1, 2] doLam lam2 [1,2,3,4] -- Victor Nazarov -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090506/901c0aef/attachment.htm From rvdalen at yahoo.co.uk Wed May 6 06:17:57 2009 From: rvdalen at yahoo.co.uk (Rouan van Dalen) Date: Wed May 6 06:03:22 2009 Subject: [Haskell-cafe] Writing a compiler in Hakell (continued 1) Message-ID: <73518.15028.qm@web23705.mail.ird.yahoo.com> Hi everyone. Thanks for the speedy replies. Let me elaborate on my language and situation. The language I have in mind is a statically typed, hybrid (OOP + functional), strict language. It contains both functional and imperitive features (much the same as OCaml/F#) with ideas from haskell, scheme, smalltalk, mozart/oz, F#, C#. The syntax is kept as succint as possible, adding things that I think would be useful that are not defined in any of the inspirational languages. As for the target language, im not quite sure yet. I am doing a lot of work in .NET/C# at the moment, but I would eventually like to use my own programming language, instead of C#. I would also like to use my language for linux programming, so I will eventually support both Windows and Linux environments. My aim with this project is to further explore haskell and deepen my understanding of it, while at the same time creating something useful where I can explore my own ideas about programmnig languages and concepts. I don't really intend to write "the next programming language" used by billions of people. If others find it useful, that's awsome. I definitely intend to use my language for my own projects and to make it freely availble on the net. So it is not just for learning or fun, it is more focused on implementing a decent programming language that can be used for commercial applications (and fun). The compiler for my language should have a decent compile time, comparing to compilers written in C. The approach that I have in mind is to piggy back on existing languages/compilers until their implementation is no longer adequite or I have time to write my own code generator. So the first stage would be something like translate to C# and then use the C# compiler to obtain an executable. I want the first steps to go as quick as possible so that I can refine the language and test ideas quickly, and once the language has stabalized, concentrarte on my own full fledged compiler (if it is necessary). I think I will try Parsec as a starting point for creating a parser. Thanks again everyone. Regards Rouan From daniel.is.fischer at web.de Wed May 6 06:42:38 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed May 6 06:28:32 2009 Subject: [Haskell-cafe] Reply to In-Reply-To: References: Message-ID: <200905061242.39298.daniel.is.fischer@web.de> Am Mittwoch 06 Mai 2009 11:05:05 schrieb Magnus Therning: > On Wed, May 6, 2009 at 7:51 AM, Ashok Gautham > > wrote: > > I feel that the haskell mailing lists must have the reply-to field set, > > so that a person can reply to the list by just clicking reply. > > > > I am unsure if I am the only one facing this problem. > > This is a contentious issue: > > http://www.unicom.com/pw/reply-to-harmful.html > http://marc.merlins.org/netrants/reply-to-useful.html May I add http://woozle.org/~neale/papers/reply-to-still-harmful.html > > I personally think mailing-lists shouldn't put themselves in the > Reply-To, and that easy replying to the list is something that should > be handled in the mail client (I base my choice of mail client on > this). Indeed. I have reply, reply-to-all and reply-to-list one click or one key combination away, and as far as I know those features are present in almost all mail clients since several years, so ease of replying to list shouldn't be an issue. On the other hand, I do not want messages intended to be private communications to end up on the list, which would happen more easily with munged headers. So, count me in the leave-reply-to-alone camp. > > What client are you using? > > /M Cheers, Daniel From applebiz89 at hotmail.com Wed May 6 06:57:36 2009 From: applebiz89 at hotmail.com (applebiz89) Date: Wed May 6 06:43:02 2009 Subject: [Haskell-cafe] Haskell IO problem Message-ID: <23404351.post@talk.nabble.com> I havent done much IO at all in haskell, only within the function itself. However I want to get the input from the interface for the function and havent done this before. // Say I have this as my data type and list of films data Film = Film String String Int [String] -- List of films testDatabase :: [Film] testDatabase = [(Film "Casino Royale" "Martin Campbell" 2006 ["Garry", "Dave", "Zoe"]) ] // with functions such as: becomeFan :: String -> String -> [Film] -> [Film] becomeFan _ _ [] = [] becomeFan filmName fanName ((Film title director year fans):xs) | filmName == title = (Film title director year fanName:fans) : xs | otherwise = (Film title director year fans) : becomeFan filmName fanName xs filmsInGivenYear :: Int -> [Film] -> [String] filmsInGivenYear filmYear films = [ title | (Film title director year fans) <- films, year == filmYear] // I want to ask the user what function they want to use, I have this so far main :: IO() do putStr "Hi there! what is your name: " fanName = getLine do putStr "1 = Insert film, 2 = Become a Fan, 3 = The number of fans of a film, 4 = Film released in a year: " input = getLine read input :: Int (if input == 1 then main x = insertFilm [] else if input == 2 then main x = becomeFan [] else if input == 3 then main x = numberOfFans []) // I thought using the if statement would work, but now I cant think how to gather the needed input for the function they have chosen? thanks apple -- View this message in context: http://www.nabble.com/Haskell-IO-problem-tp23404351p23404351.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From lrpalmer at gmail.com Wed May 6 07:17:13 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed May 6 07:02:37 2009 Subject: [Haskell-cafe] Writing a compiler in Hakell (continued 1) In-Reply-To: <73518.15028.qm@web23705.mail.ird.yahoo.com> References: <73518.15028.qm@web23705.mail.ird.yahoo.com> Message-ID: <7ca3f0160905060417v7ba297cagf6521faa2ddf0d3@mail.gmail.com> On Wed, May 6, 2009 at 4:17 AM, Rouan van Dalen wrote: > > As for the target language, im not quite sure yet. I am doing a lot of > work in > .NET/C# at the moment, but I would eventually like to use my own > programming language, > instead of C#. I would also like to use my language for linux programming, > so I will eventually > support both Windows and Linux environments. C# seems like a fine choice for target language, at least for starters. The CLR is a great virtual machine, with a good garbage collector and a mature JIT engine. Mono is also pretty nice and will give you support for linux. > > My aim with this project is to further explore haskell and deepen my > understanding of it, while at > the same time creating something useful where I can explore my own ideas > about programmnig > languages and concepts. I don't really intend to write "the next > programming language" used by billions of people. > If others find it useful, that's awsome. I definitely intend to use my > language for my own projects and > to make it freely availble on the net. So it is not just for learning or > fun, it is more focused on implementing > a decent programming language that can be used for commercial applications > (and fun). Great! Yes, absolutely write your compiler in your language itself after you have bootstrapped a little bit of it. This will stress-test the viability of your language to complex symbol manipulation tasks, and also give you the kind of self-referential improvements you see from such a situation. > > > The compiler for my language should have a decent compile time, comparing > to compilers written in C. That's not too hard. The design of C is terrible for that. Recompiling every header file each time it is included! With a decent module system and interface format it shouldn't be that hard to compete with C. > > > The approach that I have in mind is to piggy back on existing > languages/compilers until their implementation > is no longer adequite or I have time to write my own code generator. So > the first stage would be something like > translate to C# and then use the C# compiler to obtain an executable. I > want the first steps to go as quick as possible > so that I can refine the language and test ideas quickly, and once the > language has stabalized, concentrarte on my > own full fledged compiler (if it is necessary). > > I think I will try Parsec as a starting point for creating a parser. A final bit of advice. A compiler is best as a composition of lots of very small compilers (sans parsers; keep your data structured). Use lots of intermediate formats, and keep the translation between each intermediate format as small as possible. See UHC for an excellent example of this approach. In particular, aim for getting your language down to the smallest core calculus that you can think of. This makes it very easy to write interpreters, code generators and optimizers. A compiler is a large project, but you will safe yourself a lot of pain and complexity if you think of it as a bunch of small ones. Good luck! I'm interested to see what your language looks like (particularly the features you think are missing from your inspriations). And also have fun learning Haskell; you may find your principles of language design changing along the way as a result... :-) Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090506/afa70bae/attachment.htm From marlowsd at gmail.com Wed May 6 07:41:27 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Wed May 6 07:26:51 2009 Subject: [Haskell-cafe] Re: ST.Lazy vs ST.Strict In-Reply-To: <65c9dbea0905051242o6bb51935i6c8771f768fae74b@mail.gmail.com> References: <65c9dbea0905031027j60e08cefh162cb63b70c1c721@mail.gmail.com> <2f9b2d30905031511s347e2783vf2a2bcd24083d0de@mail.gmail.com> <65c9dbea0905031654m6550aa98v477643e5abbb4cf0@mail.gmail.com> <49a77b7a0905032152j39a08871me99463366b3c1488@mail.gmail.com> <65c9dbea0905051242o6bb51935i6c8771f768fae74b@mail.gmail.com> Message-ID: <4A017767.7080200@gmail.com> On 05/05/2009 20:42, Tobias Olausson wrote: > This simple implementation of CPU does not behave as expected in the > latest version of ghc using ST.Lazy since it updates the `pc` in the > wrong order. > When we use ghc-6.8 the code works as expected both with lazy and strict ST. > How is that? How do we fix this so we can use ghc-6.10. Looks like a real bug, I just created a ticket: http://hackage.haskell.org/trac/ghc/ticket/3207 Cheers, Simon From marlowsd at gmail.com Wed May 6 07:49:58 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Wed May 6 07:35:24 2009 Subject: [Haskell-cafe] Re: Writing a compiler in Hakell In-Reply-To: <7ca3f0160905052331q69bd2d99p118addd29323838c@mail.gmail.com> References: <999221.11069.qm@web23707.mail.ird.yahoo.com> <7ca3f0160905052331q69bd2d99p118addd29323838c@mail.gmail.com> Message-ID: <4A017966.2030607@gmail.com> On 06/05/2009 07:31, Luke Palmer wrote: > On Wed, May 6, 2009 at 12:07 AM, Rouan van Dalen > wrote: > > > Hi everyone. > > I am designing my own programming language. > > I would like to know what is the best way to go about writing my > compiler in haskell. > What are the tools available in haskell that can help with compiler > construction? > > I know about Happy. Is that a good tool to use? > > > I don't like Happy. Using a parser generator is like admitting defeat, > when we have no defeat to admit. I would recommend a parser combinator > library like Parsec (or if you like building things from the ground up, > ReadP). There are distinct advantages to using a parser generator over parsing combinators. For example, you get a static guarantee that your language is unambiguous and doesn't need backtracking. (and we like static guarantees!) I seem to recall there are parsing combinators that generate LR parsing tables at runtime, which might be a good compromise though. Cheers, Simon From abdel-hakim.hannousse at emn.fr Wed May 6 10:33:24 2009 From: abdel-hakim.hannousse at emn.fr (Hannousse) Date: Wed May 6 10:18:50 2009 Subject: [Haskell-cafe] Haskell Arrows Applications Message-ID: <23388417.post@talk.nabble.com> Hello, I'm interested to the concept of arrows in Haskell, however, I couldn't find a real application or example using this new technology in a real world application. All what I found are just academic examples and other people developing new specific libraries using arrows.Could someone, please, give me a reference to one of the real applications that uses arrows. Thank you for all Hannousse. -- View this message in context: http://www.nabble.com/Haskell-Arrows-Applications-tp23388417p23388417.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From doaitse at swierstra.net Wed May 6 10:42:52 2009 From: doaitse at swierstra.net (S. Doaitse Swierstra) Date: Wed May 6 10:28:25 2009 Subject: [Haskell-cafe] Writing a compiler in Hakell In-Reply-To: <999221.11069.qm@web23707.mail.ird.yahoo.com> References: <999221.11069.qm@web23707.mail.ird.yahoo.com> Message-ID: Dear Rouan, on http://www.cs.uu.nl/wiki/HUT/WebHome you will find a collection of tools which may help you to construct a compiler. As an example you will find a Tiger compiler constructed with the uulib tools and the uuagc attribute grammar system. Tiger is the language used in the book series by Andrew Apple. Not that Tiger is a great language, but the compiler contains an instance of all the things that have to be done when writing a compiler. Once you like these tools you may take a look at the UHC compiler, which actually is a series of compilers, starting from a small language, which is than gradually extended, both with new language concepts and with new aspects, such as code generation, new forms of types etc. Here you will also see that writing a compiler for a language like Haskell is not a small endeavour. You said you wanted to write a compiler in Haskell, but you did not say what language you want to compile? This sounds a bit strange: I have chosen my tool, but now I am going to decide what to use it for? With respect to your question about the + operator. There are many answers to this question; but it depends on what language you are compiling, with which goal in mind etc. It makes a big difference whether you are compiling a language like Perl into some byte-code language which is to be interpreted in which case your aproach looks reasaonable, or a special purpose language describing finite state machines into code for an embedded system in which case your approach does not work out. Doaitse Swierstra On 6 mei 2009, at 08:07, Rouan van Dalen wrote: > > Hi everyone. > > I am designing my own programming language. > > I would like to know what is the best way to go about writing my > compiler in haskell. > What are the tools available in haskell that can help with compiler > construction? > > I know about Happy. Is that a good tool to use? > > The compiler is intended for serious use and I would like it to be > very efficient, maybe competing > with compilers written in C. It should also be very easy to extend > as the languoge grows. > > Are there any good books that you can recommend on compiler > construction in general and specific to haskell? > > > On another note, how is the operator + implemented in haskell? > > is there a primitve (say #+) that is wrapped by the haskell operator > +? > Maybe something like: > > (+) :: a -> a -> a > v1 + v2 = #+ v1 v2 > > > > > Thanks in advance > > Rouan. > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From tom at lokhorst.eu Wed May 6 10:52:57 2009 From: tom at lokhorst.eu (Tom Lokhorst) Date: Wed May 6 10:38:42 2009 Subject: [Haskell-cafe] Current status of Annotations Message-ID: <317ca7670905060752s40b36212x5c2f89afcbf0dd5a@mail.gmail.com> Hello, I've been reading about Annotations [1] as implemented during last years Summer of Code, and about some earlier ideas [3] [2]. It seems though that these annotations have never been merged into HEAD [4]. Could anyone elaborate on the current status of this proposal? Has there been any further work or discussion about this subject that I haven't been able to dig up? - Tom Lokhorst [1] http://hackage.haskell.org/trac/ghc/wiki/Annotations [2] http://www.haskell.org/pipermail/haskell-prime/2006-November/001893.html [3] http://hackage.haskell.org/trac/haskell-prime/ticket/88 [4] http://www.haskell.org/pipermail/haskell-cafe/2008-September/047293.html From davidmiani at gmail.com Wed May 6 10:57:16 2009 From: davidmiani at gmail.com (David Miani) Date: Wed May 6 10:44:24 2009 Subject: [Haskell-cafe] Reply to In-Reply-To: <200905061242.39298.daniel.is.fischer@web.de> References: <200905061242.39298.daniel.is.fischer@web.de> Message-ID: <200905070057.16635.davidmiani@gmail.com> On Wednesday 06 May 2009 20:42:38 Daniel Fischer wrote: > > Indeed. I have reply, reply-to-all and reply-to-list one click or one key > combination away, and as far as I know those features are present in almost > all mail clients since several years, so ease of replying to list shouldn't > be an issue. > On the other hand, I do not want messages intended to be private > communications to end up on the list, which would happen more easily with > munged headers. > > So, count me in the leave-reply-to-alone camp. > There is a lot of combinations that can occur when replying to a message on a mailing list. **Situation 1**: Parent Message Header: From: parent@email.com To: mailinglist@mailinglist.com To reply to this, I could either use the following recipients: Reply method 1 (This happens when I choose "Reply" or "Reply to mailing list" with kmail) To: mailinglist@mailinglist.com Reply method 2 (Have to set recipients manually with this) To: mailinglist@mailinglist.com To: parent@email.com Reply method 3 (This happens when I choose "Reply to all" with kmail) To: mailinglist@mailinglist.com CC: parent@email.com Reply method 4 (Have to set recipients manually with this) To: parent@email.com CC: mailinglist@mailinglist.com Reply method 5 (This happens when I choose "Reply to author" with kmail) To: parent@email.com **Situation 2** *Parent Message Header*: From: parent@email.com To: grand-parent@email.com CC: mailinglist@mailinglist.com And to reply to this, I could use any of the following: Reply method 1 (This happens when I choose "Reply" or "Reply to mailing list" with kmail) To: mailinglist@mailinglist.com Reply method 2 (This happens when I choose "Reply to all" with kmail) To: mailinglist@mailinglist.com CC: parent@email.com CC: grand-parent@email.com Reply method 3 (Have to set recipients manually with this) To: parent@email.com CC: mailinglist@mailinglist.com Reply method 4 (Have to set recipients manually with this) To: parent@email.com To: mailinglist@mailinglist.com Reply method 5 (Have to set recipients manually with this) To: mailinglist@mailinglist.com CC: parent@email.com Reply method 5 (Have to set recipients manually with this) To: parent@email.com CC: mailinglist@mailinglist.com CC: parent@email.com Reply method 6 (This happens when I choose "Reply to author" with kmail) To: parent@email.com ------------------------------------------ I'm not sure about your mail client, but replying to lists doesn't seem that simple to me with kmail. The only situations I really understand is the reply to author methods (method 5 in situation 1 and method 6 in situation 2). The others I don't really know what difference it makes. Eg: - If you send to only the mailing list, does it break the message thread? (it seems like sometimes it does, sometimes it doesn't) - Do you use To for the mailing list or for the parent? - Do you ever include the grand-parent in the recipient list? - What's the difference between To and CC? - Does the mailing list do some kind of processing of the email headings sent (I don't get how kmail managed to know your message was in reply to Magnus Therning's message, since you didn't include him as a recipient) - Is kmail's mailing list management completely bonkers (eg what is the difference between Reply and Reply to mailing list)? And don't get me started on whether to use html or plain text in messages! (seen both pretty often here) Sometimes I feel I have missed some vital webpage somewhere that answers all this, and I'm just some clueless moron who can't work email yet :( If anyone knows of such a page, could you let me know of it? Google only gives very basic articles when searching for "using mailing lists". Anyway, I can't see why we still use mailing lists when we have reddit, which has all the good parts of mailing lists (nested messages), while it also: - is much simpler to use - allows voting up/down of good/inaccurate messages - allows voting up/down of interesting/boring topics - has a good web interface (mail-archive.com doesn't even come close) - uses markdown (no more html vs plain text problems) - allows messages to be edited after being sent - has rss feeds for article comments, and sub reddit topics - sends notifications when someone replies to one of your comments - and more! :P From simonpj at microsoft.com Wed May 6 11:00:07 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Wed May 6 10:45:32 2009 Subject: [Haskell-cafe] Current status of Annotations In-Reply-To: <317ca7670905060752s40b36212x5c2f89afcbf0dd5a@mail.gmail.com> References: <317ca7670905060752s40b36212x5c2f89afcbf0dd5a@mail.gmail.com> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C337E956DDA3@EA-EXMSG-C334.europe.corp.microsoft.com> Annotations are indeed implemented and in the HEAD. Looking at [1], the writeup looks historically skewed, rather than being a crisp writeup of what is actually there. I wonder if Max or Tristan might improve the situation (after the Haskell workshop deadline)? As it happens Tristan's Haskell Workshop submission makes essential use of annotations. Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On | Behalf Of Tom Lokhorst | Sent: 06 May 2009 15:53 | To: Haskell Cafe | Subject: [Haskell-cafe] Current status of Annotations | | Hello, | | I've been reading about Annotations [1] as implemented during last | years Summer of Code, and about some earlier ideas [3] [2]. It seems | though that these annotations have never been merged into HEAD [4]. | | Could anyone elaborate on the current status of this proposal? Has | there been any further work or discussion about this subject that I | haven't been able to dig up? | | - Tom Lokhorst | | [1] http://hackage.haskell.org/trac/ghc/wiki/Annotations | [2] http://www.haskell.org/pipermail/haskell-prime/2006-November/001893.html | [3] http://hackage.haskell.org/trac/haskell-prime/ticket/88 | [4] http://www.haskell.org/pipermail/haskell-cafe/2008-September/047293.html | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe From Steve.Schuldenzucker at web.de Wed May 6 11:16:16 2009 From: Steve.Schuldenzucker at web.de (Steffen Schuldenzucker) Date: Wed May 6 11:03:18 2009 Subject: [Haskell-cafe] Haskell Arrows Applications In-Reply-To: <23388417.post@talk.nabble.com> References: <23388417.post@talk.nabble.com> Message-ID: <20090506151616.GA5769@gandalf.mittelerde> On 07:33 Wed 06 May , Hannousse wrote: > > Hello, > > I'm interested to the concept of arrows in Haskell, however, I couldn't find > a real application or example using this new technology in a real world > application. All what I found are just academic examples and other people > developing new specific libraries using arrows.Could someone, please, give > me a reference to one of the real applications that uses arrows. Hi. HXT, the Haskell XML Toolbox [1], uses Arrows to define filters and modifications of XML trees. A structure called ListArrow can return several results, the Arrow combinators allow them to be used together in a clean way. There are Arrows that carry mutable state and perform IO, too. Also see the wiki page [2] and Hackage documentation [3]. It took me a while to understand what really goes on, but worked quite well then. Steffen [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hxt [2] http://haskell.org/haskellwiki/HXT [3] http://www.fh-wedel.de/~si/HXmlToolbox/hdoc/index.html From aneumann at inf.fu-berlin.de Wed May 6 11:27:08 2009 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Wed May 6 11:12:37 2009 Subject: [Haskell-cafe] Unfold fusion Message-ID: <6E4397AD-45B3-4116-B911-03309B474EEF@inf.fu-berlin.de> Hello, I'm trying to prove the unfold fusion law, as given in the chapter "Origami Programming" in "The Fun of Programming". unfold is defined like this: unfold p f g b = if p b then [] else (f b):unfold p f g (g b) And the law states: unfold p f g . h = unfold p' f' g' with p' = p.h f' = f.h h.g' = g.h Foremost I don't really see why one would want to fuse h into the unfold. h is executed once, at the beginning and is never needed again. Can someone give me an example? So, this is what I got so far: unfold p f g.h = (\b -> if p b then [] else (f b): unfold p f g (g b).h = if p (h b) then [] else (f (h b)) : unfold p f g (g (h b)) = if p' b then [] else f' b: unfold p f g (h (g' b)) not very much. I kinda see why it works after I "unfold" some more, but I can't really prove it. I suspect I need some technique I haven't learned yet. I've heard about fixpoint induction, that looks promising, but Google knows very little about it. I hope somebody can give me some hints. Regards, Adrian -------------- 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/20090506/7a1a2b79/PGP.bin From matthijs at stdin.nl Wed May 6 11:28:36 2009 From: matthijs at stdin.nl (Matthijs Kooijman) Date: Wed May 6 11:13:58 2009 Subject: [Haskell-cafe] Reply to In-Reply-To: <200905070057.16635.davidmiani@gmail.com> References: <200905061242.39298.daniel.is.fischer@web.de> <200905070057.16635.davidmiani@gmail.com> Message-ID: <20090506152836.GF30224@katherina.student.utwente.nl> Hi David, > - Do you use To for the mailing list or for the parent? > - Do you ever include the grand-parent in the recipient list? I use whatever my mail client does when I hit "list-reply" :-) For me (using mutt), that means to include any recipients and senders from the original message (so mailing list, parent and grand-parent in your example), unless the sender of the message I'm replying to has set the Mail-Followup-To header. My client sets the Mail-Followup-To properly to include all recipients and include myself when I am not subscribed to the list, and exclude myself when I am subscribed to the list. This is the only proper solution, since you can't guess from the addresses alone if someone is subscribed to the list and should thus be included or not. > - What's the difference between To and CC? Just a matter of style I guess, functionally they are the same AFAIK. > - If you send to only the mailing list, does it break the message thread? (it > seems like sometimes it does, sometimes it doesn't) > - Does the mailing list do some kind of processing of the email headings sent > (I don't get how kmail managed to know your message was in reply to Magnus > Therning's message, since you didn't include him as a recipient) These two questions are the same: This is handled by email clients entirely. They set the In-Reply-To header, which refers to the message ID of the replied-to message, for proper threading. Alternatively, some clients (can) use the subject for guessing threads, but the mailing list doesn't handle this in any way (it doesn't have any info that the recipients don't have either). > - Is kmail's mailing list management completely bonkers (eg what is the > difference between Reply and Reply to mailing list)? Dunno, but it seems so from your example. > And don't get me started on whether to use html or plain text in messages! > (seen both pretty often here) As long as messages have a decent text/plain part, feel free to use anything as far as I'm concerned (flash, anyone? :-p) > Anyway, I can't see why we still use mailing lists when we have reddit, which > has all the good parts of mailing lists (nested messages), while it also: Hmm, what's this reddit thing? *googles* At first glance, the reddit frontpage looks very crowded and incapable of conveying information to me... At second glance, it looks like some kind of giant forum with random topics and links to other forums/news sites/blogs? There's probably some way to organize threads belonging to a single topic that becomes evident when you login? > - is much simpler to use Can't say, never used it... > - allows voting up/down of good/inaccurate messages > - allows voting up/down of interesting/boring topics That's cool for when you're reading a topic back (ie would be nice on email archives) but not really useful for new questions and messages (which is what our mailing lists are usually about, right?). > - has a good web interface (mail-archive.com doesn't even come close) Nice, but does it have a non-web-interface? The only way I can actually manage all email traffic coming my way from a couple dozen mailing lists, is because mutt is so darn efficient when it comes to reading and processing mail. I would't want to do all that in a webinterface. > - uses markdown (no more html vs plain text problems) That's cool :-) Though you can also just write markdown in plain text email, looks pretty as well :-p > - allows messages to be edited after being sent You can always just reply with corrections. Editing messages after writing them only makes things confusing (since you probably won't be able to edit them before someone has read them...). > - has rss feeds for article comments, and sub reddit topics Aren't RSS feeds just invented to turn the normal "pull" information flow of a website to a sortof "push" flow (or rather, to automate the polling of a website for new info). The cool thing about email is that it's push by design! > - sends notifications when someone replies to one of your comments Like, via email? :-p Seriously though, I guess something like reddit has some merit, but I see that mostly for archival and/or discussions that have a longer lasting value. A lot of traffic on mailing lists is useful for as long as the question that's asked is unsolved and after that it's done. Also, no webinterface is not a substitute for a decent mail client, especially a heavily customized one. If you're serious about using reddit for haskell discussions, could you perhaps enlighten us with how that would work? I've been browsing a bit more, and reddit really looks like a collection of links to articles and topics, not like an actual discussion medium? 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/20090506/ce412388/attachment.bin From pumpkingod at gmail.com Wed May 6 11:40:52 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Wed May 6 11:26:14 2009 Subject: [Haskell-cafe] calling a variable length parameter lambda expression In-Reply-To: References: <45fccde20905050949y6a0e8e40s89efdcadd3c8b217@mail.gmail.com> Message-ID: isn't doLam just id with an Ord restriction there? On Wed, May 6, 2009 at 5:55 AM, Victor Nazarov wrote: > On Tue, May 5, 2009 at 8:49 PM, Nico Rolle wrote: >> >> Hi everyone. >> >> I have a problem. >> A function is recieving a lambda expression like this: >> (\ x y -> x > y) >> or like this >> (\ x y z a -> (x > y) && (z < a) >> >> my problem is now i know i have a list filled with the parameters for >> the lambda expression. >> but how can i call that expression? >> [parameters] is my list of parameters for the lambda expression. >> lambda_ex is my lambda expression >> >> is there a function wich can do smth like that? >> >> lambda _ex (unfold_parameters parameters) > > Why not: > > lam1 = \[x, y] -> x > y > lam2 = \[x, y, z, a] -> (x > y) && (z < a) > > doLam :: Ord a => ([a] -> Bool) -> [a] -> Bool > doLam lam params = lam params > > So, this will work fine: > > doLam lam1 [1, 2] > doLam lam2 [1,2,3,4] > > -- > Victor Nazarov > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From nrolle at web.de Wed May 6 11:41:42 2009 From: nrolle at web.de (Nico Rolle) Date: Wed May 6 11:27:17 2009 Subject: [Haskell-cafe] calling a variable length parameter lambda expression In-Reply-To: References: <45fccde20905050949y6a0e8e40s89efdcadd3c8b217@mail.gmail.com> Message-ID: <45fccde20905060841k712beff2y4fc2f802fc9c56d0@mail.gmail.com> super nice. best solution for me so far. big thanks. regards 2009/5/6 Victor Nazarov : > On Tue, May 5, 2009 at 8:49 PM, Nico Rolle wrote: >> >> Hi everyone. >> >> I have a problem. >> A function is recieving a lambda expression like this: >> (\ x y -> x > y) >> or like this >> (\ x y z a -> (x > y) && (z < a) >> >> my problem is now i know i have a list filled with the parameters for >> the lambda expression. >> but how can i call that expression? >> [parameters] is my list of parameters for the lambda expression. >> lambda_ex is my lambda expression >> >> is there a function wich can do smth like that? >> >> lambda _ex (unfold_parameters parameters) > > Why not: > > lam1 = \[x, y] -> x > y > lam2 = \[x, y, z, a] -> (x > y) && (z < a) > > doLam :: Ord a => ([a] -> Bool) -> [a] -> Bool > doLam lam params = lam params > > So, this will work fine: > > doLam lam1 [1, 2] > doLam lam2 [1,2,3,4] > > -- > Victor Nazarov > From pumpkingod at gmail.com Wed May 6 11:44:12 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Wed May 6 11:29:34 2009 Subject: [Haskell-cafe] calling a variable length parameter lambda expression In-Reply-To: <45fccde20905060841k712beff2y4fc2f802fc9c56d0@mail.gmail.com> References: <45fccde20905050949y6a0e8e40s89efdcadd3c8b217@mail.gmail.com> <45fccde20905060841k712beff2y4fc2f802fc9c56d0@mail.gmail.com> Message-ID: Keep in mind that using lists for your parameters means you lose static guarantees that you've passed the correct number of arguments to a function (so you could crash at runtime if you pass too few or too many parameters to a function). On Wed, May 6, 2009 at 11:41 AM, Nico Rolle wrote: > super nice. > best solution for me so far. > big thanks. > regards > > 2009/5/6 Victor Nazarov : >> On Tue, May 5, 2009 at 8:49 PM, Nico Rolle wrote: >>> >>> Hi everyone. >>> >>> I have a problem. >>> A function is recieving a lambda expression like this: >>> (\ x y -> x > y) >>> or like this >>> (\ x y z a -> (x > y) && (z < a) >>> >>> my problem is now i know i have a list filled with the parameters for >>> the lambda expression. >>> but how can i call that expression? >>> [parameters] is my list of parameters for the lambda expression. >>> lambda_ex is my lambda expression >>> >>> is there a function wich can do smth like that? >>> >>> lambda _ex (unfold_parameters parameters) >> >> Why not: >> >> lam1 = \[x, y] -> x > y >> lam2 = \[x, y, z, a] -> (x > y) && (z < a) >> >> doLam :: Ord a => ([a] -> Bool) -> [a] -> Bool >> doLam lam params = lam params >> >> So, this will work fine: >> >> doLam lam1 [1, 2] >> doLam lam2 [1,2,3,4] >> >> -- >> Victor Nazarov >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From huschi at gmx.org Wed May 6 11:48:58 2009 From: huschi at gmx.org (Martin Huschenbett) Date: Wed May 6 11:34:21 2009 Subject: [Haskell-cafe] Unfold fusion In-Reply-To: <6E4397AD-45B3-4116-B911-03309B474EEF@inf.fu-berlin.de> References: <6E4397AD-45B3-4116-B911-03309B474EEF@inf.fu-berlin.de> Message-ID: <4A01B16A.60603@gmx.org> Adrian Neumann schrieb: > Hello, > > I'm trying to prove the unfold fusion law, as given in the chapter > "Origami Programming" in "The Fun of Programming". unfold is defined > like this: > > unfold p f g b = if p b then [] else (f b):unfold p f g (g b) > > And the law states: > > unfold p f g . h = unfold p' f' g' > with > p' = p.h > f' = f.h > h.g' = g.h > > Foremost I don't really see why one would want to fuse h into the > unfold. h is executed once, at the beginning and is never needed again. > Can someone give me an example? Maybe you should read the euqation from the other direction. Then the h becomes "fused out" and is called only once instead of many times. But you can only do this if you can factor out h from p', f' and g'. > So, this is what I got so far: > > unfold p f g.h = (\b -> if p b then [] else (f b): unfold p f g (g b).h > = if p (h b) then [] else (f (h b)) : unfold p f g (g (h b)) > = if p' b then [] else f' b: unfold p f g (h (g' b)) > > not very much. I kinda see why it works after I "unfold" some more, but > I can't really prove it. I suspect I need some technique I haven't > learned yet. I've heard about fixpoint induction, that looks promising, > but Google knows very little about it. > > I hope somebody can give me some hints. > > Regards, > > Adrian Regards, Martin. > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From miguelimo38 at yandex.ru Wed May 6 12:06:02 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Wed May 6 11:52:47 2009 Subject: [Haskell-cafe] Unfold fusion In-Reply-To: <6E4397AD-45B3-4116-B911-03309B474EEF@inf.fu-berlin.de> References: <6E4397AD-45B3-4116-B911-03309B474EEF@inf.fu-berlin.de> Message-ID: <8F0C4F6F-D5F8-4F96-91CF-51EDF4038EA7@yandex.ru> On 6 May 2009, at 19:27, Adrian Neumann wrote: > Hello, > > I'm trying to prove the unfold fusion law, as given in the chapter > "Origami Programming" in "The Fun of Programming". unfold is defined > like this: > > unfold p f g b = if p b then [] else (f b):unfold p f g (g b) > > And the law states: > > unfold p f g . h = unfold p' f' g' > with > p' = p.h > f' = f.h > h.g' = g.h > > Foremost I don't really see why one would want to fuse h into the > unfold. h is executed once, at the beginning and is never needed > again. Can someone give me an example? > > So, this is what I got so far: > > unfold p f g.h = (\b -> if p b then [] else (f b): unfold p f g (g > b).h > = if p (h b) then [] else (f (h b)) : unfold p f g (g (h b)) > = if p' b then [] else f' b: unfold p f g (h (g' b)) = if p' b then [] else f' b : (unfold p f g . h) g' b = if p' b then [] else f' b : unfold p' f' g' (g' b) -- NB! = unfoldr p' f' g' b This "proof" is actually biting itself on the tail; however, you can make it work, for example, like this: (A_n) take n ((unfold p f g . h) b) = take n (unfold p' f' g' b) Now, A_0 is obvious (take 0 whatever = []), and A_n follows from A_{n-1} by the previous argument. By induction, A_n holds for all n. From nrolle at web.de Wed May 6 12:18:44 2009 From: nrolle at web.de (Nico Rolle) Date: Wed May 6 12:04:05 2009 Subject: [Haskell-cafe] beginner question: assigning local variable to a function Message-ID: <45fccde20905060918h3cacd28cx8bae9887848dee96@mail.gmail.com> hi why does this don't work? test = let a = (>) in 1 `a` 2 regards From allbery at ece.cmu.edu Wed May 6 12:21:47 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed May 6 12:07:28 2009 Subject: [Haskell-cafe] beginner question: assigning local variable to a function In-Reply-To: <45fccde20905060918h3cacd28cx8bae9887848dee96@mail.gmail.com> References: <45fccde20905060918h3cacd28cx8bae9887848dee96@mail.gmail.com> Message-ID: <46BE51D6-A08B-422A-9D6B-C81E0D6EC989@ece.cmu.edu> On May 6, 2009, at 12:18 , Nico Rolle wrote: > why does this don't work? > > test = let a = (>) > in 1 `a` 2 Works fine here once I correct your indentation (the "in" needs to be indented at least as far as the "l" in "let"). -- 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/20090506/b77ec871/PGP.bin From nrolle at web.de Wed May 6 12:27:42 2009 From: nrolle at web.de (Nico Rolle) Date: Wed May 6 12:13:05 2009 Subject: [Haskell-cafe] beginner question: assigning local variable to a function In-Reply-To: <46BE51D6-A08B-422A-9D6B-C81E0D6EC989@ece.cmu.edu> References: <45fccde20905060918h3cacd28cx8bae9887848dee96@mail.gmail.com> <46BE51D6-A08B-422A-9D6B-C81E0D6EC989@ece.cmu.edu> Message-ID: <45fccde20905060927o31d69485x738af7699e77187f@mail.gmail.com> Oh sorry guys was rlly a stupid indentation mistake next time i'll post the error message too thanks regards 2009/5/6 Brandon S. Allbery KF8NH : > On May 6, 2009, at 12:18 , Nico Rolle wrote: >> >> why does this don't work? >> >> test = let a = (>) >> ? in 1 `a` 2 > > > Works fine here once I correct your indentation (the "in" needs to be > indented at least as far as the "l" in "let"). > > -- > 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 > > > From stephenhicks at gmail.com Wed May 6 12:28:56 2009 From: stephenhicks at gmail.com (Stephen Hicks) Date: Wed May 6 12:14:17 2009 Subject: [Haskell-cafe] Getting WriterT log lazily In-Reply-To: <49FEB1CC.5030501@therning.org> References: <49FE09D7.5090108@therning.org> <49FE9DC0.9060201@van.steenbergen.nl> <49FEB1CC.5030501@therning.org> Message-ID: <50b5ae760905060928o454231b2ya0dccdb46afe9445@mail.gmail.com> Magnus Therning wrote: > Martijn van Steenbergen wrote: >> >> Otherwise, you can use unsafeInterleaveIO: no unsafePerformIO or seq >> needed, but there's still "unsafe" in that name there. This works for me: ... > Thanks, that does indeed work, but it still requires that "unsafe" there so > I'm hesitant replacing the call to threadDelay with something more > complicated, where it isn't obviously safe. Sorry for the late reply, but I'd like to piggy-back on this. It's my understanding that unsafeInterleaveIO is only unsafe insofar as it makes the IO lazy and so the IO may be performed later or never at all (if its return value is never wanted) and is therefore no less safe than, say, generating a list of IO actions as was suggested by an earlier reply. It seems to me that its unsafeness is of a completely different nature than unsafePerformIO... am I missing something? steve From scriptdevil.haskell at gmail.com Wed May 6 12:31:14 2009 From: scriptdevil.haskell at gmail.com (Ashok Gautham) Date: Wed May 6 12:16:38 2009 Subject: [Haskell-cafe] Haskell IO problem In-Reply-To: <23404351.post@talk.nabble.com> References: <23404351.post@talk.nabble.com> Message-ID: On Wed, May 6, 2009 at 4:27 PM, applebiz89 wrote: > > main :: IO() > do putStr "Hi there! what is your name: " > fanName = getLine > do putStr "1 = Insert film, 2 = Become a Fan, 3 = The number of fans of a > film, 4 = Film released in a year: " > input = getLine > read input :: Int > (if input == 1 then main x = insertFilm [] else if input == 2 then main x = > becomeFan [] else if input == 3 then main x = numberOfFans []) > > // I thought using the if statement would work, but now I cant think how to > gather the needed input for the function they have chosen? Well, here input is a String. Type of read is read :: (Read a) => String -> a i.e. If a is an instance of the read class, read will be able to produce a value of type a given a String. So you have to do something like x = read input :: Int read input will not destructively convert the type of input to int Alsom I think case x of will be better than if x = 1... --- Ashok `ScriptDevil` Gautham From davidmiani at gmail.com Wed May 6 12:43:14 2009 From: davidmiani at gmail.com (David Miani) Date: Wed May 6 12:30:25 2009 Subject: [Haskell-cafe] Reply to In-Reply-To: <20090506152836.GF30224@katherina.student.utwente.nl> References: <200905070057.16635.davidmiani@gmail.com> <20090506152836.GF30224@katherina.student.utwente.nl> Message-ID: <200905070243.14934.davidmiani@gmail.com> On Thursday 07 May 2009 01:28:36 Matthijs Kooijman wrote: > Hi David, > > > - Do you use To for the mailing list or for the parent? > > - Do you ever include the grand-parent in the recipient list? > > I use whatever my mail client does when I hit "list-reply" :-) > > For me (using mutt), that means to include any recipients and senders from > the original message (so mailing list, parent and grand-parent in your > example), unless the sender of the message I'm replying to has set the > Mail-Followup-To header. My client sets the Mail-Followup-To properly to > include all recipients and include myself when I am not subscribed to the > list, and exclude myself when I am subscribed to the list. This is the only > proper solution, since you can't guess from the addresses alone if someone > is subscribed to the list and should thus be included or not. > > > - What's the difference between To and CC? > > Just a matter of style I guess, functionally they are the same AFAIK. > > > - If you send to only the mailing list, does it break the message thread? > > (it seems like sometimes it does, sometimes it doesn't) > > - Does the mailing list do some kind of processing of the email headings > > sent (I don't get how kmail managed to know your message was in reply to > > Magnus Therning's message, since you didn't include him as a recipient) > > These two questions are the same: This is handled by email clients > entirely. They set the In-Reply-To header, which refers to the message ID > of the replied-to message, for proper threading. Alternatively, some > clients (can) use the subject for guessing threads, but the mailing list > doesn't handle this in any way (it doesn't have any info that the > recipients don't have either). > > > - Is kmail's mailing list management completely bonkers (eg what is the > > difference between Reply and Reply to mailing list)? > > Dunno, but it seems so from your example. > > > And don't get me started on whether to use html or plain text in > > messages! (seen both pretty often here) > > As long as messages have a decent text/plain part, feel free to use > anything as far as I'm concerned (flash, anyone? :-p) Thanks for those answers, that really cleared up alot of my misconceptions. I think I was assuming the mailing list did a lot more than it actually does. > > > Anyway, I can't see why we still use mailing lists when we have reddit, > > which has all the good parts of mailing lists (nested messages), while it > > also: > > Hmm, what's this reddit thing? *googles* Sorry, I should have put more about reddit in my original post :S > > At first glance, the reddit frontpage looks very crowded and incapable of > conveying information to me... Reddit is divided into different groups called "subreddits". Eg there is a pics one, politics one, economics on and so on. When you go to reddit.com, you get all the topics posted to the most popular 10 or so subreddits (if you register you can customize this though). That's why it appeared crowded :) If you want to only see the topics from one subreddit, you go to www.reddit.com/r/subredditname . There exists two haskell reddits I know of, haskell and haskell-proposals, it is www.reddit.com/r/haskell (for the haskell subreddit). > > At second glance, it looks like some kind of giant forum with random topics > and links to other forums/news sites/blogs? > There's probably some way to > organize threads belonging to a single topic that becomes evident when you > login? That's the subreddits :) > > > - is much simpler to use > > Can't say, never used it... Heh just my opinion... > > > - allows voting up/down of good/inaccurate messages > > - allows voting up/down of interesting/boring topics > > That's cool for when you're reading a topic back (ie would be nice on email > archives) but not really useful for new questions and messages (which is > what our mailing lists are usually about, right?). You have three main ways of sorting the topics in a reddit (seen at the top of the screen): - whats hot: puts articles getting lots of upvotes recently up higher - new: puts more recent articles up higher - top: puts the highest voted articles for hour/day/week/month/year/all-time up higher For browsing, you would use top, and for reading new stuff, you would use new. Also, you can subscribe to the rss feed http://www.reddit.com/r/haskell/new.rss to get a link for every new discussion > > > - has a good web interface (mail-archive.com doesn't even come close) > > Nice, but does it have a non-web-interface? The only way I can actually > manage all email traffic coming my way from a couple dozen mailing lists, > is because mutt is so darn efficient when it comes to reading and > processing mail. I would't want to do all that in a webinterface. This managed mainly through being able to select what subreddits appear on the front page. It is also very efficient commenting, as no new window is opened when you choose to comment, just a new box appears below the comment you are replying to. However, I doubt that it could be as efficient as mutt though. It would probably work like this: Proficiency mailing list reddit Beginner inefficient efficient Average efficient efficient Expert very efficient efficient > > > - uses markdown (no more html vs plain text problems) > > That's cool :-) Though you can also just write markdown in plain text > email, looks pretty as well :-p Though it doesn't look as pretty :) Seriously though there are a lot of haskell-cafe posts where the formatting for the code appears wrong even though it was probably right in the authors email client. This would fix that. > > > - allows messages to be edited after being sent > > You can always just reply with corrections. Editing messages after writing > them only makes things confusing (since you probably won't be able to edit > them before someone has read them...). For minor edits (eg spelling), it works fine. For other edits, it is common practice to include something like "Edit:Fixed mistake in function" or "Edit: added additional info" at the end of the post. I find this much nicer than submitting corrections, as when browsing archives, you can often miss the correction if you think you have found what you were looking for. > > > - has rss feeds for article comments, and sub reddit topics > > Aren't RSS feeds just invented to turn the normal "pull" information flow > of a website to a sortof "push" flow (or rather, to automate the polling of > a website for new info). The cool thing about email is that it's push by > design! I used to think that as well, until I started using them more frequently. They are very easy to subscribe/unsubscribe to (no sending your email address), and you don't need to create a filter for them. Having a good reader is also necessary, I like akregator, google reader is also good. > > > - sends notifications when someone replies to one of your comments > > Like, via email? :-p Hehe true, although with mailing lists, you have to get every single message sent by everyone. If you are only a light user of the list, this can get annoying. However with the reddit design, you can post a message, and if someone replies 2 months later, it will be the only message you get. > I've been browsing a bit > more, and reddit really looks like a collection of links to articles and > topics, not like an actual discussion medium? > When you make a reddit post, you can either choose to link it to an article, or to nothing. Eg the article http://www.reddit.com/r/haskell/comments/8fkjy/ask_haskit_where_to_learn_more_about_nonstrictness/ is a self post, just used for the discussion (about nonstrictness in this case). The article http://www.reddit.com/r/haskell/comments/8frkl/forcing_evaluation_in_haskell/ on the other hand has a link to a blog post talking about forcing evaluation. This could be useful for all those announcement posts on this list. Most of the front page links aren't self posts. Try www.reddit.com/r/askreddit and www.reddit.com/r/haskell_proposals to see more self posts (the haskell reddit doesn't really have many atm). From miguelimo38 at yandex.ru Wed May 6 12:59:49 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Wed May 6 12:46:27 2009 Subject: [Haskell-cafe] Reply to In-Reply-To: <20090506152836.GF30224@katherina.student.utwente.nl> References: <200905061242.39298.daniel.is.fischer@web.de> <200905070057.16635.davidmiani@gmail.com> <20090506152836.GF30224@katherina.student.utwente.nl> Message-ID: >> Anyway, I can't see why we still use mailing lists when we have >> reddit, which >> has all the good parts of mailing lists (nested messages), while it >> also: > Hmm, what's this reddit thing? *googles* Me too. Seems like this "reddit" thing is nothing but a mail list done wrong. I may be wrong, but it seems that I have to actually CLICK on all links I want to read, instead of just pressing spacebar in my mail client. From daniel.is.fischer at web.de Wed May 6 13:40:00 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed May 6 13:25:55 2009 Subject: [Haskell-cafe] Reply to In-Reply-To: <200905070057.16635.davidmiani@gmail.com> References: <200905061242.39298.daniel.is.fischer@web.de> <200905070057.16635.davidmiani@gmail.com> Message-ID: <200905061940.01158.daniel.is.fischer@web.de> Am Mittwoch 06 Mai 2009 16:57:16 schrieb David Miani: > On Wednesday 06 May 2009 20:42:38 Daniel Fischer wrote: > > Indeed. I have reply, reply-to-all and reply-to-list one click or one key > > combination away, and as far as I know those features are present in > > almost all mail clients since several years, so ease of replying to list > > shouldn't be an issue. > > On the other hand, I do not want messages intended to be private > > communications to end up on the list, which would happen more easily with > > munged headers. > > > > So, count me in the leave-reply-to-alone camp. > > There is a lot of combinations that can occur when replying to a message on > a mailing list. > > **Situation 1**: > Parent Message Header: > From: parent@email.com > To: mailinglist@mailinglist.com > > To reply to this, I could either use the following recipients: > > Reply method 1 > (This happens when I choose "Reply" or "Reply to mailing list" with kmail) > To: mailinglist@mailinglist.com Yes, a bit surprising that "Reply" doesn't include parent@email.com among the recipients. Probably assumes that parent is subscribed to mailinglist. Methods 2 to 4 are "equivalent for all practical purposes, unless you really know their differences and why you would choose any particular one", I'd say (well, except you may have filtering rules which would treat them differently, which probably wouldn't be very useful, because you never know if others would use Reply to mailing list, Reply or Reply to all). > > Reply method 2 > (Have to set recipients manually with this) > To: mailinglist@mailinglist.com > To: parent@email.com > > Reply method 3 > (This happens when I choose "Reply to all" with kmail) > To: mailinglist@mailinglist.com > CC: parent@email.com > > Reply method 4 > (Have to set recipients manually with this) > To: parent@email.com > CC: mailinglist@mailinglist.com > > Reply method 5 > (This happens when I choose "Reply to author" with kmail) > To: parent@email.com > > **Situation 2** > *Parent Message Header*: > From: parent@email.com > To: grand-parent@email.com > CC: mailinglist@mailinglist.com > > And to reply to this, I could use any of the following: > > Reply method 1 > (This happens when I choose "Reply" or "Reply to mailing list" with kmail) > To: mailinglist@mailinglist.com Again somewhat surprising behaviour of Reply. > > Reply method 2 > (This happens when I choose "Reply to all" with kmail) > To: mailinglist@mailinglist.com > CC: parent@email.com > CC: grand-parent@email.com Clear, isn't it? > > Reply method 3 > (Have to set recipients manually with this) > To: parent@email.com > CC: mailinglist@mailinglist.com > > Reply method 4 > (Have to set recipients manually with this) > To: parent@email.com > To: mailinglist@mailinglist.com > > Reply method 5 > (Have to set recipients manually with this) > To: mailinglist@mailinglist.com > CC: parent@email.com Again I don't know why one would pick any particular of these three, but special choices require individual treatment, I can fully understand that these are not among the default actions of a mail client. If you don't care about To/CC, it's easy in KMail, though, just type a (Reply to All), click delete on the To field with grandparent's address. If you care about To/CC, it's a few more clicks, but still easy. > > Reply method 5 > (Have to set recipients manually with this) > To: parent@email.com > CC: mailinglist@mailinglist.com > CC: parent@email.com Hit Reply to all and toggle To/CC if you really care (but again, I don't know why one would care). > > Reply method 6 > (This happens when I choose "Reply to author" with kmail) > To: parent@email.com Anything else would be a major WTF. Yes, there are many options but if you don't care about the difference between To and CC, all are easily obtained from the default reply modes. > > > ------------------------------------------ > > I'm not sure about your mail client, KMail (1.10.3) :-) > but replying to lists doesn't seem that simple to me with kmail. Just type l (lowercase L) or click Reply to mailing list, and it will send only to the list (as given in the List-ID field). If you want to reply to multiple lists (cafe, ghc- users, beginners), you'd probably have to choose Reply to all and delete other recipients. The case of multiple lists is not incredibly simple, but seems simple enough to me (and I'm emphatically not a power user, as soon as anything internetty is involved). > The only situations I really understand is > the reply to author methods (method 5 in situation 1 and method 6 in > situation 2). The others I don't really know what difference it makes. Eg: > - If you send to only the mailing list, does it break the message thread? > (it seems like sometimes it does, sometimes it doesn't) Shouldn't break the thread, can't remember that happening. > - Do you use To for the mailing list or for the parent? I don't care, the message being delivered to both is what I'm interested in, and that's achieved either way. Whether there are differences in how the message is sent through the tubes, I don't know. > - Do you ever include the grand-parent in the recipient list? If I choose Reply to all and don't delete it, which would happen if I want grand-parent to receive the message and suspect gp is not suscribed to the list. > - What's the difference between To and CC? Don't know, don't care :) > - Does the mailing list do some kind of processing of the email headings > sent (I don't get how kmail managed to know your message was in reply to > Magnus Therning's message, since you didn't include him as a recipient) I typed l while viewing that message, that's how KMail knew. The From field said it was a message by Magnus Therning. > - Is kmail's mailing list management completely bonkers (eg what is the > difference between Reply and Reply to mailing list)? Definitely somewhat unintuitive. Reply to mailing list needs something it can interpret as a mailing list, it seems it would choose the Reply-To field if that's present, but not a List-ID, if neither is present, it includes no address. What Reply does, I haven't figured out. If a Reply-To field is present, it should pick that, otherwise I'd expect it to use the From field, but it seems to have different ideas :-/ > > And don't get me started on whether to use html or plain text in messages! > (seen both pretty often here) HTML e-mails are evil, almost as evil as tabs in source code. Never use. > > Sometimes I feel I have missed some vital webpage somewhere that answers > all this, and I'm just some clueless moron who can't work email yet :( Me too. > If anyone knows of such a page, could you let me know of it? Google only gives > very basic articles when searching for "using mailing lists". > > Anyway, I can't see why we still use mailing lists when we have reddit, > which has all the good parts of mailing lists (nested messages), while it > also: - is much simpler to use Not for me. I prefer mailing lists every day of the week, much simpler for me. > - uses markdown (no more html vs plain text problems) That's really a good thing. > - allows messages to be edited after being sent That's bad, IMO, for high-traffic lists/threads. In a low-traffic environment, you have a chance to check whether a post you replied to was changed and take the appropriate measures, in a high-traffic environment, that's unfeasible, and you end up with egregiously incoherent threads (sometimes). > - sends notifications when someone replies to one of your comments And a mailing list actually sends the notification in the shape of the reply itself, which is even easier to follow. From magnus at therning.org Wed May 6 14:25:20 2009 From: magnus at therning.org (Magnus Therning) Date: Wed May 6 14:10:56 2009 Subject: [Haskell-cafe] Reply to In-Reply-To: References: <200905061242.39298.daniel.is.fischer@web.de> <200905070057.16635.davidmiani@gmail.com> <20090506152836.GF30224@katherina.student.utwente.nl> Message-ID: <4A01D610.5070203@therning.org> Miguel Mitrofanov wrote: >>> Anyway, I can't see why we still use mailing lists when we have >>> reddit, which >>> has all the good parts of mailing lists (nested messages), while it >>> also: >> Hmm, what's this reddit thing? *googles* > > Me too. Seems like this "reddit" thing is nothing but a mail list done > wrong. I may be wrong, but it seems that I have to actually CLICK on all > links I want to read, instead of just pressing spacebar in my mail client. It's a nice source for links to interesting topics, I use it via an RSS reader. I wouldn't say it's a "mailing list done wrong", I'd say it's more like slashdot, but without the moderation. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090506/f4cc34fc/signature.bin From magnus at therning.org Wed May 6 14:31:25 2009 From: magnus at therning.org (Magnus Therning) Date: Wed May 6 14:16:55 2009 Subject: [Haskell-cafe] beginner question: assigning local variable to a function In-Reply-To: <46BE51D6-A08B-422A-9D6B-C81E0D6EC989@ece.cmu.edu> References: <45fccde20905060918h3cacd28cx8bae9887848dee96@mail.gmail.com> <46BE51D6-A08B-422A-9D6B-C81E0D6EC989@ece.cmu.edu> Message-ID: <4A01D77D.9060801@therning.org> Brandon S. Allbery KF8NH wrote: > On May 6, 2009, at 12:18 , Nico Rolle wrote: >> why does this don't work? >> >> test = let a = (>) >> in 1 `a` 2 > > > Works fine here once I correct your indentation (the "in" needs to be > indented at least as far as the "l" in "let"). Really? For me it's enough to have "in" indented more then "test", and one space is enough: test = let a = (>) in 1 `a` 2 /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090506/70c2a8cd/signature.bin From fft1976 at gmail.com Wed May 6 15:59:53 2009 From: fft1976 at gmail.com (FFT) Date: Wed May 6 15:45:16 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <87fxfll3ad.fsf@forno.us> References: <87fxfll3ad.fsf@forno.us> Message-ID: I've heard it's hard to contain a long-running Haskell application in a finite amount of memory, but this is probably not a problem if your web site sleeps 0.001% of the time (like XMonad), or you can restart it every once in a while without anyone noticing. From dons at galois.com Wed May 6 16:01:23 2009 From: dons at galois.com (Don Stewart) Date: Wed May 6 15:48:04 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: References: <87fxfll3ad.fsf@forno.us> Message-ID: <20090506200123.GB26120@whirlpool.galois.com> fft1976: > I've heard it's hard to contain a long-running Haskell application in > a finite amount of memory, but this is probably not a problem if your Hmm. Gossip driven development? > web site sleeps 0.001% of the time (like XMonad), or you can restart > it every once in a while without anyone noticing. Keeping footprints small and stable isn't so hard. After all, we have wonderful heap profiling tools. I recommend the type-based heap profiler, in particular. Run your app for a week, and look at the heap graph. You'll know if things are ok. (Try this in C++ !) -- Don From bulat.ziganshin at gmail.com Wed May 6 16:18:13 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed May 6 16:04:14 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: References: <87fxfll3ad.fsf@forno.us> Message-ID: <204746127.20090507001813@gmail.com> Hello FFT, Wednesday, May 6, 2009, 11:59:53 PM, you wrote: > I've heard it's hard to contain a long-running Haskell application in > a finite amount of memory not exactly. you may alloc fixed pool of memory to application (say, 1gb) if you know that it never need more memory. but as far as you don't do it, memory usage grows with each major GC. ghc just don't provide any way to return memory to OS (there is a ticket on it, you can add yourself to CC list to vote for its resolution) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From brian at lorf.org Wed May 6 16:18:37 2009 From: brian at lorf.org (brian@lorf.org) Date: Wed May 6 16:05:01 2009 Subject: [Haskell-cafe] setResourceLimit In-Reply-To: <48CBBF03-FDD8-41CC-B931-501854ACBAB9@ece.cmu.edu> References: <20090505085239.GJ19506@doses> <48CBBF03-FDD8-41CC-B931-501854ACBAB9@ece.cmu.edu> Message-ID: <20090506201837.GA5132@doses> On Tuesday, 05.05.09 at 22:48, Brandon S. Allbery KF8NH wrote: > On May 5, 2009, at 04:52 , brian@lorf.org wrote: >> I have a long-lived multithreaded server process that needs to execute >> programs and interact with them via Handles. The programs could >> misbehave, like loop or hang, so I need to limit the real and CPU time >> they can take. >> > An alternative is to forkProcess and have the child setResourceLimit and > then executeFile. The documentation for forkProcess seems to say that Handle-based I/O won't work in the child process. I need to communicate with the program I'm running via its standard input and output. Does this mean forkProcess is out of the question? From dagit at codersbase.com Wed May 6 16:22:22 2009 From: dagit at codersbase.com (Jason Dagit) Date: Wed May 6 16:07:46 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <20090506200123.GB26120@whirlpool.galois.com> References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> Message-ID: On Wed, May 6, 2009 at 1:01 PM, Don Stewart wrote: > fft1976: >> I've heard it's hard to contain a long-running Haskell application in >> a finite amount of memory, but this is probably not a problem if your > > Hmm. Gossip driven development? I don't mean to undermine your marketing efforts, but I don't think this is gossip driven. I know from experience that lambdabot tends to be leaky. Otherwise, lambdabot wouldn't be running on my server to begin with. And, even so, Cale monitors lambdabot to make sure it is not using too many resources (and I complain when/if I notice it). I have heard similar stories related to hpaste and happs. I have also experienced it with writing a forever loop in Haskell that did polling from channels. I would leave my app running for, say, 4 hours and it would be using tons of memory. >> web site sleeps 0.001% of the time (like XMonad), or you can restart >> it every once in a while without anyone noticing. > > Keeping footprints small and stable isn't so hard. After all, we have > wonderful heap profiling tools. I recommend the type-based heap > profiler, in particular. Run your app for a week, and look at the heap > graph. You'll know if things are ok. (Try this in C++ !) In C++ we have valgrind right? But, yes, C++ has issues too with memory leaks. I think Java does as well. In fact, probably every programming language has issues here :) Garbage collectors are good at removing errors from freeing too soon and other manual memory management issues, but in my experience they actually cause an increase in space leaks by being conservative. I think it's fair to say that keeping the memory usage low of a long running Haskell app is hard, but that is a general issue not just a Haskell issue. It's hard in most languages. I think what we need to address this is more information about preventative measures. What programming styles cause the problem and which ones solve it. I would say that I lack confidence recommending anyone to use Haskell for long running processes because I don't understand well the problem of keeping the usage low. If it is a well documented problem with documented solutions (more than just profiling), then I would regain my confidence because I know the problem can be worked around reliably. Does this make sense? Maybe it's already well documented? In particular, we need expert Haskell programmers, such as Don, to write more about how they avoid space leaks in long running apps. Again, profiling is nice, but that's more of a tuning effort. Thanks, Jason From allbery at ece.cmu.edu Wed May 6 16:25:54 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed May 6 16:11:37 2009 Subject: [Haskell-cafe] setResourceLimit In-Reply-To: <20090506201837.GA5132@doses> References: <20090505085239.GJ19506@doses> <48CBBF03-FDD8-41CC-B931-501854ACBAB9@ece.cmu.edu> <20090506201837.GA5132@doses> Message-ID: <9ADF282F-EE68-4C6C-A656-BDF9A443F7F8@ece.cmu.edu> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On May 6, 2009, at 16:18 , brian@lorf.org wrote: > On Tuesday, 05.05.09 at 22:48, Brandon S. Allbery KF8NH wrote: >> On May 5, 2009, at 04:52 , brian@lorf.org wrote: >>> I have a long-lived multithreaded server process that needs to >>> execute >>> programs and interact with them via Handles. The programs could >>> misbehave, like loop or hang, so I need to limit the real and CPU >>> time >>> they can take. >>> >> An alternative is to forkProcess and have the child >> setResourceLimit and >> then executeFile. > > The documentation for forkProcess seems to say that Handle-based I/O > won't work in the child process. I need to communicate with the > program > I'm running via its standard input and output. Does this mean > forkProcess is out of the question? No. What it means is that, if the child will continue to run in the same Haskell program after forkProcess-ing, any open Handles won't work right. You could fix this with handleToFd and fdToHandle, I suspect, but it's irrelevant because you're going to executeFile instead. - -- 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) iEYEARECAAYFAkoB8l4ACgkQIn7hlCsL25U4ZwCePdfbEmXc5n8OJc++jTafUQOX uc8An1XJlXAx5mqYBM5c/iLaGIihq00W =FFS9 -----END PGP SIGNATURE----- From dan.doel at gmail.com Wed May 6 16:26:15 2009 From: dan.doel at gmail.com (Dan Doel) Date: Wed May 6 16:11:45 2009 Subject: [Haskell-cafe] Unfold fusion In-Reply-To: <6E4397AD-45B3-4116-B911-03309B474EEF@inf.fu-berlin.de> References: <6E4397AD-45B3-4116-B911-03309B474EEF@inf.fu-berlin.de> Message-ID: <200905061626.16342.dan.doel@gmail.com> On Wednesday 06 May 2009 11:27:08 am Adrian Neumann wrote: > Hello, > > I'm trying to prove the unfold fusion law, as given in the chapter > "Origami Programming" in "The Fun of Programming". unfold is defined > like this: > > unfold p f g b = if p b then [] else (f b):unfold p f g (g b) > > And the law states: > > unfold p f g . h = unfold p' f' g' > with > p' = p.h > f' = f.h > h.g' = g.h If you don't mind a more category theoretic tack, we can argue something like this: Lists of A are the terminal coalgebra for the functor L X = 1 + A*X. Defining them this way means that we get the unique existence of the above unfold function. Roughly, for any: ob : X -> L X there exists a unique: unfold ob : X -> [A] Such that: out . unfold ob = map (unfold ob) . ob where out : [A] -> 1 + A*[A] is the coalgebra action of the list (observing either that it's null, or what the head and tail are), and map corresponds to the functor L (so we're mapping on the X part, not the A part). Coalgebra actions ob have type: ob : X -> 1 + A*X and you can finesse that into three functions in something like Haskell: p : X -> 2, f : X -> A, g : X -> X which is what your unfold at the start does. Now, we have: p' = p . h f' = f . h h . g' = g . h Suppose we combine things back into the single coalgebra actions. Then we have: ob : X -> 1 + A*X ob' : X' -> 1 + A*X' where ob corresponds to (p,f,g) and ob' corresponds to (p',f',g'). Now, the equations above tell us that with regard to these observation functions: ob' agrees with ob . h as far as left or right goes ob' agrees with ob . h as far as As go, when applicable map h . ob' agrees with ob . h as far as Xs go. All together this means: map h . ob' = ob . h Which means it's an L-coalgebra homomorphism. Such homomorphisms are arrows in the category of L-coalgebras, for which [A] is a terminal object (giving us the unique existence property of arrows to it from any other object). So, h : X' -> X is an arrow in the L-coalgebra category. And, so are: unfold ob : X -> [A] unfold ob' : X' -> [A] Since this is a category: unfold ob . h : X' -> [A] must also be an arrow. *However*, [A] being a terminal object means that for every object, there is a unique arrow from it to [A]. We appear to have two from X': unfold ob' : X' -> [A] unfold ob . h : X' -> [A] So the uniqueness property tells us that these are the same arrow. Thus, unfold ob' = unfold ob . h unfold p' f' g' = unfold p f g . h and we're done. Hopefully that wasn't too verbose. Normally you'd have most of that covered by the time you got to proving the unfold fusion, but I wasn't sure how much of that part of the theory you'd read before. Another way you can go is to use coinduction and bisimulation (which can be ultimately explained in terms of the above primitives), which talks about making individual observations, which would go something like: If for all x: null (f x) = null (f' x) (if not null) head (f x) = head (f' x) tail (f x) = tail (f' x) (where equality on the tail is defined as being the same subsequent observations) then f and f' are the same function (by coinduction). If we look at the equations at the start: null . unfold p' f' g' = p' = p . h = null . unfold p f g . h head . unfold p' f' g' = f' = f . h = head . unfold p f g . h tail . unfold p' f' g' = unfold p' f' g' . g' (coinductive hypothesis?) = unfold p f g . h . g' = unfold p f g . g . h = tail . unfold p f g . h unfortunately it looks like I'm doing something wrong in that "coinductive hypothesis" step, by assuming that unfold p' f' g' = unfold p f g . h. However, I'm pretty sure that's how these sorts of coinductive proofs work, though I'm not familiar enough with presenting this angle to explain why you should allow it. Anyhow, if you believe the above, then we've established that all the observations you can make are equal, so our functions must be equal. Note, that it's somewhat important to have these coalgebraic/coinductive proof methods here. Miguel Mitrofanov gave you a proof that: take n . unfold p f g . h = take n . unfold p' f' g' for all n using induction. But, that is not exactly a proof that they are equal, but a proof that any finite amount of observation you can make of their output will be equal, and unfold can produce infinite objects. That may be good enough (for instance, in a total functional programming language extended with coinduction, only the inductive/recursive parts and single-step observation of coinductive values 'ought' to be subject to evaluation, so you can only make finite observations of any corecursively defined value, and the above 'take n' proof in a way covers everything you're able to do), but they feel different, to me at least. Anyhow, I'll stop rambling. Hope that helped some. -- Dan From brian at lorf.org Wed May 6 16:39:27 2009 From: brian at lorf.org (brian@lorf.org) Date: Wed May 6 16:25:49 2009 Subject: [Haskell-cafe] setResourceLimit In-Reply-To: <9ADF282F-EE68-4C6C-A656-BDF9A443F7F8@ece.cmu.edu> References: <20090505085239.GJ19506@doses> <48CBBF03-FDD8-41CC-B931-501854ACBAB9@ece.cmu.edu> <20090506201837.GA5132@doses> <9ADF282F-EE68-4C6C-A656-BDF9A443F7F8@ece.cmu.edu> Message-ID: <20090506203927.GB5132@doses> On Wednesday, 06.05.09 at 16:25, Brandon S. Allbery KF8NH wrote: > No. What it means is that, if the child will continue to run in the > same Haskell program after forkProcess-ing, any open Handles won't > work right. You could fix this with handleToFd and fdToHandle, I > suspect, but it's irrelevant because you're going to executeFile > instead. I forkProcess. The parent gets the PID. The child does setResourceLimit, then executeFile, which is done with one of the execvs, which replaces the child process with the program I'm trying to communicate with. So now the program is resource limited and will probably quit if it takes too much CPU time. But the parent just has the child's PID. How is it communicating with the child? From andrewcoppin at btinternet.com Wed May 6 16:45:13 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed May 6 16:30:45 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> Message-ID: <4A01F6D9.8080602@btinternet.com> Jason Dagit wrote: > I don't mean to undermine your marketing efforts, but I don't think > this is gossip driven. > > I know from experience that lambdabot tends to be leaky. Otherwise, > lambdabot wouldn't be running on my server to begin with. And, even > so, Cale monitors lambdabot to make sure it is not using too many > resources (and I complain when/if I notice it). I have heard similar > stories related to hpaste and happs. I have also experienced it with > writing a forever loop in Haskell that did polling from channels. I > would leave my app running for, say, 4 hours and it would be using > tons of memory. > > I think it's fair to say that keeping the memory usage low of a long > running Haskell app is hard, but that is a general issue not just a > Haskell issue. It's hard in most languages. I think what we need to > address this is more information about preventative measures. What > programming styles cause the problem and which ones solve it. I would > say that I lack confidence recommending anyone to use Haskell for long > running processes because I don't understand well the problem of > keeping the usage low. If it is a well documented problem with > documented solutions (more than just profiling), then I would regain > my confidence because I know the problem can be worked around > reliably. Does this make sense? Maybe it's already well documented? > > In particular, we need expert Haskell programmers, such as Don, to > write more about how they avoid space leaks in long running apps. > Again, profiling is nice, but that's more of a tuning effort. > Mmm, interesting. Clearly I don't run anything for long enough to notice this effect. (I just had a look at a Haskell program I wrote myself which I happen to have running in the background right now. Process Explorer tells me it's used 4 hours of CPU time, and it's memory graph is still flat. It was reading 106 MB shortly after I started it, and it still says 106 MB now. OTOH, it's a fairly trivial program, so...) But if you're going to advocate more expert knowledge being diseminated, I certainly won't argue against that! :-D Export knowledge is something it seems difficult to have too much of... From allbery at ece.cmu.edu Wed May 6 16:57:29 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed May 6 16:43:04 2009 Subject: [Haskell-cafe] setResourceLimit In-Reply-To: <20090506203927.GB5132@doses> References: <20090505085239.GJ19506@doses> <48CBBF03-FDD8-41CC-B931-501854ACBAB9@ece.cmu.edu> <20090506201837.GA5132@doses> <9ADF282F-EE68-4C6C-A656-BDF9A443F7F8@ece.cmu.edu> <20090506203927.GB5132@doses> Message-ID: <3BC262CE-71F9-41EA-9F4D-13A2BB9C6577@ece.cmu.edu> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On May 6, 2009, at 16:39 , brian@lorf.org wrote: > On Wednesday, 06.05.09 at 16:25, Brandon S. Allbery KF8NH wrote: >> No. What it means is that, if the child will continue to run in the >> same Haskell program after forkProcess-ing, any open Handles won't >> work right. You could fix this with handleToFd and fdToHandle, I >> suspect, but it's irrelevant because you're going to executeFile >> instead. > > I forkProcess. The parent gets the PID. The child does > setResourceLimit, > then executeFile, which is done with one of the execvs, which replaces > the child process with the program I'm trying to communicate with. > > So now the program is resource limited and will probably quit if it > takes too much CPU time. But the parent just has the child's PID. > How is > it communicating with the child? Create pipes (System.Posix.IO.createPipe) before forkProcess. In the child, close stdin/stdout/stderr handles (which are unusable anyway) as appropriate and dupTo the write pipes to stdout and stderr and read pipe to stdin (again, as appropriate; remember that doing both stdin and stdout means you need to be careful to avoid data starvation deadlocks). In the parent you use fdToHandle to turn the other end of each pipe into a Handle that you can use as normal. You might want to study how to do this in C first, as the System.Posix calls are simple wrappers around the standard POSIX library routines. - -- 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) iEYEARECAAYFAkoB+cQACgkQIn7hlCsL25UtDwCfVzY1Qck/+/fvguMHGPVAefMy F7cAoMloJ/4AqKhTHQNtaVbHGhYwylls =5H08 -----END PGP SIGNATURE----- From dan.doel at gmail.com Wed May 6 17:20:22 2009 From: dan.doel at gmail.com (Dan Doel) Date: Wed May 6 17:05:47 2009 Subject: [Haskell-cafe] Unfold fusion In-Reply-To: <200905061626.16342.dan.doel@gmail.com> References: <6E4397AD-45B3-4116-B911-03309B474EEF@inf.fu-berlin.de> <200905061626.16342.dan.doel@gmail.com> Message-ID: <200905061720.22588.dan.doel@gmail.com> On Wednesday 06 May 2009 4:26:15 pm Dan Doel wrote: > unfortunately it looks like I'm doing something wrong in that "coinductive > hypothesis" Sorry about the self-reply, but I realized where I went wrong. The principle of proof by coinduction for defining a function 'f' goes something like this (expressed all point-free like): if null . f = p' (and when not null) head . f = f' tail . f = f . g' then f = unfold p' f' g' now we have: null . (unfold p f g . h) = p . h = p' head . (unfold p f g . h) = f . h = f' tail . (unfold p f g . h) = unfold p f g . g . h = unfold p f g . h . g' = (unfold p f g . h) . g' now we have a system of equations for (unfold p f g . h) that fits the format, so by coinduction we have: unfold p f g . h = unfold p' f' g' And we're done. -- Dan From batterseapower at hotmail.com Wed May 6 17:28:09 2009 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Wed May 6 17:13:31 2009 Subject: [Haskell-cafe] Current status of Annotations In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C337E956DDA3@EA-EXMSG-C334.europe.corp.microsoft.com> References: <317ca7670905060752s40b36212x5c2f89afcbf0dd5a@mail.gmail.com> <638ABD0A29C8884A91BC5FB5C349B1C337E956DDA3@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <9d4d38820905061428q10b62fd4j456e1420b0a40d6e@mail.gmail.com> I wrote a small section for the manual that will appear online (at http://www.haskell.org/ghc/docs/latest/html/users_guide/pragmas.html) when we release 6.12. I've updated the wiki page to reflect this and give some other helpful info (http://hackage.haskell.org/trac/ghc/wiki/Annotations). Cheers, Max 2009/5/6 Simon Peyton-Jones : > Annotations are indeed implemented and in the HEAD. ?Looking at [1], the writeup looks historically skewed, rather than being a crisp writeup of what is actually there. > > I wonder if Max or Tristan might improve the situation (after the Haskell workshop deadline)? ?As it happens Tristan's Haskell Workshop submission makes essential use of annotations. From dons at galois.com Wed May 6 17:28:04 2009 From: dons at galois.com (Don Stewart) Date: Wed May 6 17:14:46 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> Message-ID: <20090506212804.GC26120@whirlpool.galois.com> dagit: > In particular, we need expert Haskell programmers, such as Don, to > write more about how they avoid space leaks in long running apps. > Again, profiling is nice, but that's more of a tuning effort. I talk a bit about that in my LondonHUG talk: http://www.galois.com/blog/2009/04/27/engineering-large-projects-in-haskell-a-decade-of-fp-at-galois/ As I said earlier: stress test with heap profiling on (is one way to absolutely ensure you know what's going on). -- Don From rendel at cs.au.dk Wed May 6 17:36:35 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Wed May 6 17:22:33 2009 Subject: [Haskell-cafe] instance Monad (Except err) In-Reply-To: <49FEAEE1.7060304@van.steenbergen.nl> References: <49FEAEE1.7060304@van.steenbergen.nl> Message-ID: <4A0202E3.1010809@cs.au.dk> Hi, Martijn van Steenbergen wrote: > Mr. McBride and mr. Paterson define in their Applicative paper: > >> data Except e a = OK a | Failed e >> instance Monoid e => Applicative (Except e) where ... > > Sometimes I'd still like to use >>= on Excepts but this "feels" wrong > somehow, because it doesn't use monoids nicely like the Applicative > instance does. Are there any good reasons such a Monad instance > shouldn't be defined? Does it violate any laws, for example? The problem is that one would like to define Failed e1 >> Failed e2 = Failed (e1 `mappend` e2) but then p >> q is no longer the same as p >>= const q which could be confusing. Tillmann From lemming at henning-thielemann.de Wed May 6 17:59:39 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed May 6 17:45:01 2009 Subject: [Haskell-cafe] Vector-like data structure In-Reply-To: <220e47b40905031106i1ff14d0ap6fb5fc223d220996@mail.gmail.com> References: <220e47b40905031106i1ff14d0ap6fb5fc223d220996@mail.gmail.com> Message-ID: On Sun, 3 May 2009, Krzysztof Skrz?tnicki wrote: > Hi > > I'm looking for a data structure with following characteristics: > 1. O(1) lookup > 2. O(1) modification > 3. amortized O(1) append > 4. O(1) size query > > This roughly characterizes C++ vector<> class. I'm ready to implement > it myself, but first I would like to ask if anyone knows package with > similar data structure. > If there are many, which one would you choose and why? If you want exchange with C and like packed elements then you can use Data.StorableVector.ST. From anton at appsolutions.com Wed May 6 18:54:13 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Wed May 6 18:39:48 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> Message-ID: <4A021515.4090603@appsolutions.com> Jason Dagit wrote: > I know from experience that lambdabot tends to be leaky. Otherwise, > lambdabot wouldn't be running on my server to begin with. And, even > so, Cale monitors lambdabot to make sure it is not using too many > resources (and I complain when/if I notice it). I have heard similar > stories related to hpaste and happs. FWIW, I have an internal HAppS application that's been running continuously since November last year, used daily, with stable memory usage. > I have also experienced it with > writing a forever loop in Haskell that did polling from channels. I > would leave my app running for, say, 4 hours and it would be using > tons of memory. If you posted an example of that, there are probably people who'd be interested in debugging it. > I think it's fair to say that keeping the memory usage low of a long > running Haskell app is hard, but that is a general issue not just a > Haskell issue. It's hard in most languages. I don't agree with this. This should not be hard in language implementations with good garbage collectors, that don't have known limitations (this excludes e.g. conservative GC and reference-counting systems). In my experience, it's not hard to write stable long-running code in good implementations of languages like Haskell, Scheme, Common Lisp, or Java. > I think what we need to > address this is more information about preventative measures. What > programming styles cause the problem and which ones solve it. I would > say that I lack confidence recommending anyone to use Haskell for long > running processes because I don't understand well the problem of > keeping the usage low. If it is a well documented problem with > documented solutions (more than just profiling), then I would regain > my confidence because I know the problem can be worked around > reliably. Does this make sense? Maybe it's already well documented? This doesn't completely make sense to me, in that either a program has a space leak, or it doesn't. If it does, you debug it and resolve it. If a leak really is due to a problem with the language implementation or standard libraries, then that should be identified and reported. There shouldn't be any deep mystery here. At the very least, it should be possible to point to the relevant trac tickets if there really is a problem. Anton From vigalchin at gmail.com Wed May 6 19:05:40 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Wed May 6 18:51:07 2009 Subject: [Haskell-cafe] cabal parse problems Message-ID: <5ae4f2ba0905061605l7121bc58kab2f40f36c784874@mail.gmail.com> Hello, I am trying to cabalize a package (swish .. semantic web) but am running into parse error: vigalchin@ubuntu:~/FTP/Haskell/Swish-0.2.1$ runhaskell Setup.hs configure Setup.hs: swish.cabal:24: Parse of field 'exposed-modules' failed. vigalchin@ubuntu:~/FTP/Haskell/Swish-0.2.1$ Below: is a fragment from my .cabal file. Line #24 starts with "Exposed-modules:" ..... ..... ..... Data-Files: README Exposed-modules: Swish.HaskellRDF.BuiltInDatatypes, Swish.HaskellRDF.BuiltInMap, Swish.HaskellRDF.BuiltInMapTest, Swish.HaskellRDF.BuiltInRules, Swish.HaskellRDF.ClassRestrictionRule, Swish.HaskellRDF.ClassRestrictionRuleTest, Swish.HaskellRDF.Datatype, Swish.HaskellRDF.GraphClass, Swish.HaskellRDF.GraphMatch, Any ideas why I am getting parse error? Pretty vague error message! Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090506/ee4bcf41/attachment.htm From vigalchin at gmail.com Wed May 6 19:12:06 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Wed May 6 18:57:27 2009 Subject: [Haskell-cafe] cabal parse problems In-Reply-To: <20090506230639.GC5132@doses> References: <5ae4f2ba0905061605l7121bc58kab2f40f36c784874@mail.gmail.com> <20090506230639.GC5132@doses> Message-ID: <5ae4f2ba0905061612k7a13e857v4a88eec8eeaf1521@mail.gmail.com> sorrily nope, Brian ... Vasili On Wed, May 6, 2009 at 6:06 PM, wrote: > On Wednesday, 06.05.09 at 18:05, Vasili I. Galchin wrote: > > Exposed-modules: Swish.HaskellRDF.BuiltInDatatypes, > > ... > > Swish.HaskellRDF.GraphMatch, > > Think it probably doesn't like that trailing comma. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090506/0e636378/attachment.htm From dagit at codersbase.com Wed May 6 19:12:21 2009 From: dagit at codersbase.com (Jason Dagit) Date: Wed May 6 18:57:45 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <20090506212804.GC26120@whirlpool.galois.com> References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> <20090506212804.GC26120@whirlpool.galois.com> Message-ID: On Wed, May 6, 2009 at 2:28 PM, Don Stewart wrote: > dagit: > >> In particular, we need expert Haskell programmers, such as Don, to >> write more about how they avoid space leaks in long running apps. >> Again, profiling is nice, but that's more of a tuning effort. > > I talk a bit about that in my LondonHUG talk: > > ? ?http://www.galois.com/blog/2009/04/27/engineering-large-projects-in-haskell-a-decade-of-fp-at-galois/ > > As I said earlier: stress test with heap profiling on (is one way to > absolutely ensure you know what's going on). I wish I could have gone to the talk. I have a feeling the slides only tell part of the story. I did see these bullet points which I think are related: This one on Laziness: ? Makes time and space reasoning harder! ?Mostly harmless in practice ? Stress testing tends to reveal retainers ? Graphical profiling knocks it dead ? Must be able to precisely enable/disable ? Be careful with exceptions and mutation ? whnf/rnf/! are your friends This one on performance: ? Really precise performance requires expertise ? Libraries are helping reify ?oral traditions? about optimization ? Still a lack of clarity about performance techniques in the broader Haskell community though The last bullet point makes me think you do agree with me :) I thought about it more since my last email, and I think what I want is something like the Effective C++ and Effective Java books, but for Haskell. A series of expert advice "items" with advice about when to use them. Real-World Haskell is a very good title, but I feel like it's at a different audience and level. Looking over Real-World haskell I see that some of these topics are discussed, which is really good. In particular, Chapter 25 would be valuable to anyone trying to find space leaks. There you discuss reduction to normal form, for example, and some strictness issues and how to control evaluation. While I'm thinking out loud, it would be very cool if someone wrote some articles, say for the monad reader, that follow the formula of the Effective C++ books. Write up the oral traditions of how to effectively use Haskell along with the dos/don'ts of each idiom. I think it could make a nice companion to the wisdom of Real-World Haskell. Have we made any tools yet that analyze haskell code and give warnings about styles and idioms that are prone to causing space leaks? For example, leaky folds are a well known problem. I know Neil Mitchel was working on some utilities to offer advice about Haskell source. Anyone know if his programs can detect potential space leaks? Thanks, Jason From bos at serpentine.com Wed May 6 19:17:21 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Wed May 6 19:02:42 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> <20090506212804.GC26120@whirlpool.galois.com> Message-ID: On Wed, May 6, 2009 at 4:12 PM, Jason Dagit wrote: > > While I'm thinking out loud, it would be very cool if someone wrote > some articles, say for the monad reader, that follow the formula of > the Effective C++ books. The last couple of times I've wanted a book like that, I wrote the book myself. It's a very effective way to get the book you want, compared to wishing. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090506/42f81d4f/attachment.htm From daniel.is.fischer at web.de Wed May 6 19:18:38 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed May 6 19:04:30 2009 Subject: [Haskell-cafe] cabal parse problems In-Reply-To: <5ae4f2ba0905061605l7121bc58kab2f40f36c784874@mail.gmail.com> References: <5ae4f2ba0905061605l7121bc58kab2f40f36c784874@mail.gmail.com> Message-ID: <200905070118.38996.daniel.is.fischer@web.de> Am Donnerstag 07 Mai 2009 01:05:40 schrieb Vasili I. Galchin: > Hello, > > I am trying to cabalize a package (swish .. semantic web) but am > running into parse error: > vigalchin@ubuntu:~/FTP/Haskell/Swish-0.2.1$ runhaskell Setup.hs configure > Setup.hs: swish.cabal:24: Parse of field 'exposed-modules' failed. > vigalchin@ubuntu:~/FTP/Haskell/Swish-0.2.1$ > > > Below: is a fragment from my .cabal file. Line #24 starts with > "Exposed-modules:" > ..... > ..... > ..... > Data-Files: README > > Exposed-modules: Swish.HaskellRDF.BuiltInDatatypes, > Swish.HaskellRDF.BuiltInMap, > Swish.HaskellRDF.BuiltInMapTest, > Swish.HaskellRDF.BuiltInRules, > Swish.HaskellRDF.ClassRestrictionRule, > Swish.HaskellRDF.ClassRestrictionRuleTest, > Swish.HaskellRDF.Datatype, > Swish.HaskellRDF.GraphClass, > Swish.HaskellRDF.GraphMatch, > > Any ideas why I am getting parse error? Pretty vague error message! Idea: The syntax of the value depends on the field. Field types include: token , filename , directory Either a sequence of one or more non-space non-comma characters, or a quoted string in Haskell 98 lexical syntax. Unless otherwise stated, relative filenames and directories are interpreted from the package root directory. Don't use commas. > > Kind regards, > > Vasili From dagit at codersbase.com Wed May 6 19:52:07 2009 From: dagit at codersbase.com (Jason Dagit) Date: Wed May 6 19:37:28 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <4A021515.4090603@appsolutions.com> References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> <4A021515.4090603@appsolutions.com> Message-ID: On Wed, May 6, 2009 at 3:54 PM, Anton van Straaten wrote: > FWIW, I have an internal HAppS application that's been running continuously > since November last year, used daily, with stable memory usage. Do you have advice about the way you wrote you app? Things you knowingly did to avoid space leaks? Maybe a blog about your HAppS app? >> I have also experienced it with >> writing a forever loop in Haskell that did polling from channels. ?I >> would leave my app running for, say, 4 hours and it would be using >> tons of memory. > > If you posted an example of that, there are probably people who'd be > interested in debugging it. I'm not sure if I still have the source code or not. I did ask people at the time and the only thing I recall now was that I was told to make sure that I fully evaluate the thunks I create on each iteration of my forever loop. This was at least 2 years ago now. I don't know if I ever resolved it as it was just a toy benchmark anyway and I wasn't really happy with the results. >> I think it's fair to say that keeping the memory usage low of a long >> running Haskell app is hard, but that is a general issue not just a >> Haskell issue. ?It's hard in most languages. > > I don't agree with this. ?This should not be hard in language > implementations with good garbage collectors, that don't have known > limitations (this excludes e.g. conservative GC and reference-counting > systems). ?In my experience, it's not hard to write stable long-running code > in good implementations of languages like Haskell, Scheme, Common Lisp, or > Java. There are certainly cases where no automatic garbage collector could know when it is safe to collect certain things. A quick google search for java space leaks turned up this article: http://www.ibm.com/developerworks/java/library/j-leaks/ I think wikipedia uses the term "logical leak" for the type of space leak I'm thinking of. The garbage collector thinks you care about an object but in fact, you want it to be freed. Yes, it's because of a bug, but these are bugs that tend to be subtle and tedious. >> I think what we need to >> address this is more information about preventative measures. ?What >> programming styles cause the problem and which ones solve it. ?I would >> say that I lack confidence recommending anyone to use Haskell for long >> running processes because I don't understand well the problem of >> keeping the usage low. ?If it is a well documented problem with >> documented solutions (more than just profiling), then I would regain >> my confidence because I know the problem can be worked around >> reliably. ?Does this make sense? ?Maybe it's already well documented? > > This doesn't completely make sense to me, in that either a program has a > space leak, or it doesn't. ?If it does, you debug it and resolve it. ?If a > leak really is due to a problem with the language implementation or standard > libraries, then that should be identified and reported. ?There shouldn't be > any deep mystery here. ?At the very least, it should be possible to point to > the relevant trac tickets if there really is a problem. The ambiguity is me thinking of relative cost of finding/fixing these bugs. Testing for correctness is something we tend to automate very well. See unit testing for example. But, testing for space leaks is not something we have automated in my experience. Take Don's comment that you let it run for a while and then look at the profiling graph. How do you automate this and make it part of your automatic test suite? It seems like something that requires manual testing. So maybe you do some QA prior to releases? That sounds reasonable to me. The darcs team collects misbehaving repositories and has tools to automate the collection of statistics so that at regular intervals they can check the performance of darcs to make sure it's getting better or staying the same with each release (in practice I think these stats are collected by buildbots on each applied patch bundle). So then, at some point we must have a bag of tricks for dealing with these space leaks. I want to talk about those tricks. I'm not talking about bugs in a specific program, but instead about techniques and styles that are known to work well in practice. I hope that clarifies things a bit. Thanks, Jason From vigalchin at gmail.com Wed May 6 20:01:20 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Wed May 6 19:46:41 2009 Subject: [Haskell-cafe] WolframAlpha Message-ID: <5ae4f2ba0905061701r78d41401uc361856fe78c2909@mail.gmail.com> Hello, http://blog.wolframalpha.com/2009/05/01/the-secret-behind-the-computational-engine-in-wolframalpha/ <<< this is obviously a Wolfram Inc. blog so maybe not totally objective ... but here is a snippet that speaks in Haskell's favor: As a result, the five million lines of *Mathematica* code that make up Wolfram|Alpha are equivalent to many tens of millions of lines of code in a lower-level language like C, Java, or Python. * I am some what familiar with Mathematica and it's multi-paradigm nature (like F#, OCaml, etc.). In any case, I would like the Haskell community to view WolframAlpha as a challenge. For what is it worth I presently cabalizing Swish .... Based on my reading of WolframAlpha it is a semantic web ... i.e. formal knowledge representation! all Google results => http://www.google.com/search?q=WolframAlpha&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a Kind regards, Vasili * -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090506/c128e41a/attachment.htm From warren.henning at gmail.com Wed May 6 20:13:01 2009 From: warren.henning at gmail.com (Warren Henning) Date: Wed May 6 19:58:23 2009 Subject: [Haskell-cafe] WolframAlpha In-Reply-To: <5ae4f2ba0905061701r78d41401uc361856fe78c2909@mail.gmail.com> References: <5ae4f2ba0905061701r78d41401uc361856fe78c2909@mail.gmail.com> Message-ID: <9e5767b0905061713j6eeb5ec5p373a2a8e63abfe01@mail.gmail.com> >From what I recall of Mathematica the language, it has more in common with Lisp than Haskell: it's symbolic, dynamically typed, etc. Allegedly Wolfram spent years on this; if it has any merit, duplicating it would be difficult. What I'd like to see most is WolframAlpha in action. At this point it is vaporware to me and for all I know this could be the beginning of a neverending charade of "coming to a Interwebs near you Real Soon Now" every few months for the next 10 years, like Duke Nukem Forever. Warren On Wed, May 6, 2009 at 5:01 PM, Vasili I. Galchin wrote: > Hello, > > > http://blog.wolframalpha.com/2009/05/01/the-secret-behind-the-computational-engine-in-wolframalpha/ > <<< this is obviously a Wolfram Inc. blog so maybe not totally objective ... > but here is a snippet that speaks in Haskell's favor: > > As a result, the five million lines of Mathematica code that make up > Wolfram|Alpha are equivalent to many tens of millions of lines of code in a > lower-level language like C, Java, or Python. > > I am some what familiar with Mathematica and it's multi-paradigm nature > (like F#, OCaml, etc.). In any case, I would like the Haskell community to > view WolframAlpha as a challenge. For what is it worth I presently > cabalizing Swish .... Based on my reading of WolframAlpha it is a semantic > web ... i.e.? formal knowledge representation! > > all Google results => > http://www.google.com/search?q=WolframAlpha&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a > > > Kind regards, Vasili > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From vigalchin at gmail.com Wed May 6 20:37:23 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Wed May 6 20:22:44 2009 Subject: [Haskell-cafe] cabal parse problems In-Reply-To: <5ae4f2ba0905061612k7a13e857v4a88eec8eeaf1521@mail.gmail.com> References: <5ae4f2ba0905061605l7121bc58kab2f40f36c784874@mail.gmail.com> <20090506230639.GC5132@doses> <5ae4f2ba0905061612k7a13e857v4a88eec8eeaf1521@mail.gmail.com> Message-ID: <5ae4f2ba0905061737l70503256k4ca6dc0fec33208c@mail.gmail.com> are them some CLI switches I can enable in order to better determine what "parse error" is?? Kind regards, Vasili On Wed, May 6, 2009 at 6:12 PM, Vasili I. Galchin wrote: > sorrily nope, Brian ... > > Vasili > > > On Wed, May 6, 2009 at 6:06 PM, wrote: > >> On Wednesday, 06.05.09 at 18:05, Vasili I. Galchin wrote: >> > Exposed-modules: Swish.HaskellRDF.BuiltInDatatypes, >> > ... >> > Swish.HaskellRDF.GraphMatch, >> >> Think it probably doesn't like that trailing comma. >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090506/84e2696a/attachment.htm From vigalchin at gmail.com Wed May 6 22:22:19 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Wed May 6 22:07:41 2009 Subject: [Haskell-cafe] cabal parse problems In-Reply-To: <5ae4f2ba0905061737l70503256k4ca6dc0fec33208c@mail.gmail.com> References: <5ae4f2ba0905061605l7121bc58kab2f40f36c784874@mail.gmail.com> <20090506230639.GC5132@doses> <5ae4f2ba0905061612k7a13e857v4a88eec8eeaf1521@mail.gmail.com> <5ae4f2ba0905061737l70503256k4ca6dc0fec33208c@mail.gmail.com> Message-ID: <5ae4f2ba0905061922j5a838951td154fd207016c28@mail.gmail.com> I figured out myself ... even though the parse was allegedly was on line #24 .. it was below because I used as a separator '/' instead of '.'! Kind regards, Vasili On Wed, May 6, 2009 at 7:37 PM, Vasili I. Galchin wrote: > are them some CLI switches I can enable in order to better determine what > "parse error" is?? > > Kind regards, Vasili > > > On Wed, May 6, 2009 at 6:12 PM, Vasili I. Galchin wrote: > >> sorrily nope, Brian ... >> >> Vasili >> >> >> On Wed, May 6, 2009 at 6:06 PM, wrote: >> >>> On Wednesday, 06.05.09 at 18:05, Vasili I. Galchin wrote: >>> > Exposed-modules: Swish.HaskellRDF.BuiltInDatatypes, >>> > ... >>> > Swish.HaskellRDF.GraphMatch, >>> >>> Think it probably doesn't like that trailing comma. >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090506/87867090/attachment.htm From anton at appsolutions.com Wed May 6 23:20:01 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Wed May 6 23:05:28 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> <4A021515.4090603@appsolutions.com> Message-ID: <4A025361.8080307@appsolutions.com> Jason Dagit wrote: > On Wed, May 6, 2009 at 3:54 PM, Anton van Straaten > wrote: >> FWIW, I have an internal HAppS application that's been running continuously >> since November last year, used daily, with stable memory usage. > > Do you have advice about the way you wrote you app? Things you > knowingly did to avoid space leaks? Maybe a blog about your HAppS > app? The app is written for a client under NDA, so a blog about it would have to be annoyingly vague. But I don't think there's much mystery about why it doesn't leak: The app does simulations. Each simulation uses at least about 10MB of memory, more depending on parameters. Typically a few thousand simulations are run successively, and the results are aggregated and analyzed. The computation itself is purely functional - it takes some input parameters and produces results. The results are written to a file. Since each run of a set of simulations is essentially independent, there's not much risk of space leaks persisting across runs. No doubt the potential for encountering space leaks goes up as one writes less pure code, persist more things in memory, and depend on more libraries. My main point in mentioning my app is that "long-running" isn't really the issue - that's just a way of saying that an app has space leaks that are small enough not to be noticed until it's stressed. >> In my experience, it's not hard to write stable long-running code >> in good implementations of languages like Haskell, Scheme, Common Lisp, or >> Java. > > There are certainly cases where no automatic garbage collector could > know when it is safe to collect certain things. If there are bugs in the user's program, sure - but that still doesn't make it "hard" to write applications that don't leak, given a decent GC. On the contrary, I'd say it's very easy, in the great majority of cases. > A quick google search > for java space leaks turned up this article: > http://www.ibm.com/developerworks/java/library/j-leaks/ > > I think wikipedia uses the term "logical leak" for the type of space > leak I'm thinking of. The garbage collector thinks you care about an > object but in fact, you want it to be freed. Yes, it's because of a > bug, but these are bugs that tend to be subtle and tedious. The example given in the IBM article is quite typical, but isn't subtle at all - it was simply an object being added to a table and never being removed. You can often find such bugs quite easily by searching the source tree, without touching a debugging tool. It's also possible to prevent them quite easily, with good coding practices (e.g. centralize uses of long-lived tables) and some simple code auditing practices. If you're dealing with code that's complex enough to involve the kinds of non-trivial mutually dependent references that you need in order to encounter truly subtle instances of these bugs, the increased difficulty of memory management comes with the territory, i.e. it's harder because the application is harder. > The ambiguity is me thinking of relative cost of finding/fixing these > bugs. To put this back into context, I was objecting to your having extended the space leak worrying to all GC'd languages. I'm saying that it isn't hard, using most decent language implementations, to avoid space leaks. For trivial cases such as the IBM example, it should be no harder in Haskell, either - possibly easier, since use of things like mutable tables is more controlled, and may be rarer. However, Haskell does theoretically introduce a new class of dangers for space leaks, I'm not denying that. Being pure and lazy introduces its own set of space leak risks. But on that front, I was disturbed by the vagueness of the claims about long-running apps. I haven't seen any solid justification for scaring people off about writing long-running apps in Haskell. If there is such a justification, it needs to be more clearly identified. > Testing for correctness is something we tend to automate very > well. How do you automate testing for performance under load? Space usage is a similar kind of dynamic issue, in general. > So then, at some point we must have a bag of tricks for dealing with > these space leaks. I want to talk about those tricks. I'm not > talking about bugs in a specific program, but instead about techniques > and styles that are known to work well in practice. OK. That's a bit different from FFT's original contention, "hard to contain a long-running Haskell application in a finite amount of memory." For my own part, I'm at least as non-strict as Haskell, and that bag of tricks, for me, is a thunk that hasn't yet been forced. Anton From fft1976 at gmail.com Wed May 6 23:40:53 2009 From: fft1976 at gmail.com (FFT) Date: Wed May 6 23:26:13 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <4A025361.8080307@appsolutions.com> References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> <4A021515.4090603@appsolutions.com> <4A025361.8080307@appsolutions.com> Message-ID: On Wed, May 6, 2009 at 8:20 PM, Anton van Straaten wrote: > The app is written for a client under NDA, so a blog about it would have to > be annoyingly vague. > No doubt the potential for encountering space leaks goes up as one writes > less pure code, persist more things in memory, and depend on more libraries. Exactly. I'm worried about, e.g. needing to use something as simple as a stream of prime numbers (see the recent thread about leaks there) > ?My main point in mentioning my app is that "long-running" isn't really the > issue - that's just a way of saying that an app has space leaks that are > small enough not to be noticed until it's stressed. An internal web site with few benign users is one thing, but if it's an external web site, it might get stressed in ways different from your expected usage scenarios, if you know what I mean. > To put this back into context, I was objecting to your having extended the > space leak worrying to all GC'd languages. I agree. From wren at freegeek.org Thu May 7 00:06:10 2009 From: wren at freegeek.org (wren ng thornton) Date: Wed May 6 23:51:36 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> <4A021515.4090603@appsolutions.com> <4A025361.8080307@appsolutions.com> Message-ID: <4A025E32.9080608@freegeek.org> FFT wrote: > Anton van Straaten wrote: > > > The app is written for a client under NDA, so a blog about it would have to > > be annoyingly vague. > > > No doubt the potential for encountering space leaks goes up as one writes > > less pure code, persist more things in memory, and depend on more libraries. > > Exactly. I'm worried about, e.g. needing to use something as simple as > a stream of prime numbers (see the recent thread about leaks there) The issues here are going to be the same in Haskell as in every other language. There's always a tradeoff between the memory of caching old results vs the time of recalculating them. At present no language's RTS/GC is smart enough to make that tradeoff for you, and so memoization must be done manually. There are some tricks to help make this easier (e.g. weak pointers), but the problem will always remain. The only thing that makes this perhaps trickier than in other languages is that, AFAIK/R, the reflection API to ask the RTS how it's feeling about memory at any given point isn't terribly portable (between Haskell compilers) or polished/pretty. Then again, the other GC languages I've dealt with aren't much better and are often worse. -- Live well, ~wren From jeff at nokrev.com Thu May 7 00:37:46 2009 From: jeff at nokrev.com (Jeff Wheeler) Date: Thu May 7 00:23:08 2009 Subject: [Haskell-cafe] WolframAlpha In-Reply-To: <9e5767b0905061713j6eeb5ec5p373a2a8e63abfe01@mail.gmail.com> References: <5ae4f2ba0905061701r78d41401uc361856fe78c2909@mail.gmail.com> <9e5767b0905061713j6eeb5ec5p373a2a8e63abfe01@mail.gmail.com> Message-ID: <1241671066.14621.0.camel@ulysses> On Wed, 2009-05-06 at 17:13 -0700, Warren Henning wrote: > What I'd like to see most is WolframAlpha in action. At this point it > is vaporware to me and for all I know this could be the beginning of a > neverending charade of "coming to a Interwebs near you Real Soon Now" > every few months for the next 10 years, like Duke Nukem Forever. The website says May 2009 (this month), and I don't know of any previous announcements claiming to have a date. I'm buying this one. Jeff Wheeler From anton at appsolutions.com Thu May 7 02:27:51 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Thu May 7 02:13:11 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> <4A021515.4090603@appsolutions.com> <4A025361.8080307@appsolutions.com> Message-ID: <4A027F67.6000807@appsolutions.com> FFT wrote: > On Wed, May 6, 2009 at 8:20 PM, Anton van Straaten > wrote: > >> The app is written for a client under NDA, so a blog about it would have to >> be annoyingly vague. > >> No doubt the potential for encountering space leaks goes up as one writes >> less pure code, persist more things in memory, and depend on more libraries. > > Exactly. I'm worried about, e.g. needing to use something as simple as > a stream of prime numbers (see the recent thread about leaks there) Haskell lets you easily create "infinite" lists, which is a powerful and useful feature. But if you abuse that feature, you'll have problems, because you don't have infinite memory. The further you traverse an infinite list, while maintaining a reference to its head, the more memory you use. It'd be a stretch to characterize this as "hard". I don't see much connection between this and the space efficiency of long-running programs. I feel a bit like we're discussing a monster under the bed: "i bet it's huge! its teeth must be so sharp!" Maybe we should just look under the bed, i.e. implement what we need and see what happens? Anton From ketil at malde.org Thu May 7 03:30:04 2009 From: ketil at malde.org (Ketil Malde) Date: Thu May 7 03:13:46 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <4A027F67.6000807@appsolutions.com> (Anton van Straaten's message of "Thu\, 07 May 2009 02\:27\:51 -0400") References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> <4A021515.4090603@appsolutions.com> <4A025361.8080307@appsolutions.com> <4A027F67.6000807@appsolutions.com> Message-ID: <873abhz7yb.fsf@malde.org> Anton van Straaten writes: >> Exactly. I'm worried about, e.g. needing to use something as simple as >> a stream of [...] > Haskell lets you easily create "infinite" lists, which is a powerful > and useful feature. This has bit me on several occasions, and I think streaming over an infinite list with too little strictness has been the cause of most of my space "leaks". I've become pretty good at spotting this in advance now, so I no longer need to whip out the profiling as often. The archetypical case is parsing a large file into a non-strict data structure. The data structure will then tend to hang onto the whole input, instead of the result, which typically is much more compact. Making the data structure strict solves the problem. > It'd be a stretch to characterize this as "hard". I guess it's hard in the sense that a) it's something different from what you need to think about in other languages, and b) it's not really an error, so you don't get as much help from the compiler or RTS. > I don't see much connection between this and the space efficiency of > long-running programs. Except a long-running program could be doing something like parsing a conceptually infinite input stream. -k -- If I haven't seen further, it is by standing in the footprints of giants From jvlask at hotmail.com Thu May 7 03:37:17 2009 From: jvlask at hotmail.com (John Lask) Date: Thu May 7 03:24:45 2009 Subject: [Haskell] Re[2]: [Haskell-cafe] Is Haskell a Good Choice for WebApplications? (ANN: Vocabulink) References: <87fxfll3ad.fsf@forno.us> <204746127.20090507001813@gmail.com> Message-ID: Well this is interesting. So what you are saying is that if your haskell application requires a peek memory utilisation of (for example) 1GB, after the memory intesive computation has completed and the GC has run (assuming all references have been dropped) the GHC RTS will retain the 1GB allocated to the process. Does this occur on both windows and posix platforms, does anyone know ? If so then this is a real issue. It would be reasonable to expect that the RTS release resources to the OS when not explicitly required. jvl ----- Original Message ----- From: "Bulat Ziganshin" To: "FFT" Cc: "Chris Forno" ; ; Sent: Thursday, May 07, 2009 6:18 AM Subject: [Haskell] Re[2]: [Haskell-cafe] Is Haskell a Good Choice for WebApplications? (ANN: Vocabulink) > Hello FFT, > > Wednesday, May 6, 2009, 11:59:53 PM, you wrote: > >> I've heard it's hard to contain a long-running Haskell application in >> a finite amount of memory > > not exactly. you may alloc fixed pool of memory to application (say, 1gb) > if you know that it never need more memory. but as far as you don't do > it, memory usage grows with each major GC. ghc just don't provide > any way to return memory to OS (there is a ticket on it, you can add > yourself to CC list to vote for its resolution) > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > _______________________________________________ > Haskell mailing list > Haskell@haskell.org > http://www.haskell.org/mailman/listinfo/haskell > From timd at macquarie.com.au Thu May 7 04:04:09 2009 From: timd at macquarie.com.au (Tim Docker) Date: Thu May 7 03:50:29 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications?(ANN: Vocabulink) In-Reply-To: <4A027F67.6000807@appsolutions.com> References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> <4A021515.4090603@appsolutions.com> <4A025361.8080307@appsolutions.com> <4A027F67.6000807@appsolutions.com> Message-ID: <7CA1B7BF2916F0418CAB6E705BC1224A3752E5@ntsydexm04.pc.internal.macquarie.com> I think that multi-threading in combination with laziness makes space usage harder to manage. In fact, just today I have discovered a problem with a long running server process with a subtle space leak. With a regular process that communicates with the outside world via IO, I know that the act of communicating a value causes it to be fully evaluated. However, with a multi threaded process, communication occurs via writes to TVars/IOVars and leaves thunks unevaluated. This gives lots of opportunities for space leaks. In this particularly case cleanup code was removing a large entry from a map stored in a Tvar. Because that map is only read infrequently, however, the memory release is delayed. This is the second such problem I've found. The profiling tools do help in discovering them, but it still needs a bit of thought and analysis. I wonder if, for my application, I should work out some means of deepseqing every value written to a Tvar. Tim -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Anton van Straaten Sent: Thursday, 7 May 2009 4:28 PM To: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is Haskell a Good Choice for Web Applications?(ANN: Vocabulink) FFT wrote: > On Wed, May 6, 2009 at 8:20 PM, Anton van Straaten > wrote: > >> The app is written for a client under NDA, so a blog about it would >> have to be annoyingly vague. > >> No doubt the potential for encountering space leaks goes up as one >> writes less pure code, persist more things in memory, and depend on more libraries. > > Exactly. I'm worried about, e.g. needing to use something as simple as > a stream of prime numbers (see the recent thread about leaks there) Haskell lets you easily create "infinite" lists, which is a powerful and useful feature. But if you abuse that feature, you'll have problems, because you don't have infinite memory. The further you traverse an infinite list, while maintaining a reference to its head, the more memory you use. It'd be a stretch to characterize this as "hard". I don't see much connection between this and the space efficiency of long-running programs. I feel a bit like we're discussing a monster under the bed: "i bet it's huge! its teeth must be so sharp!" Maybe we should just look under the bed, i.e. implement what we need and see what happens? Anton _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From timd at macquarie.com.au Thu May 7 04:04:21 2009 From: timd at macquarie.com.au (Tim Docker) Date: Thu May 7 03:50:40 2009 Subject: [Haskell-cafe] Is Haskell a Good Choice for Web Applications?(ANN: Vocabulink) In-Reply-To: <4A025E32.9080608@freegeek.org> References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> <4A021515.4090603@appsolutions.com> <4A025361.8080307@appsolutions.com> <4A025E32.9080608@freegeek.org> Message-ID: <7CA1B7BF2916F0418CAB6E705BC1224A3752E6@ntsydexm04.pc.internal.macquarie.com> I think that multi-threading in combination with laziness makes space usage harder to manage. In fact, just today I have discovered a problem with a long running server process with a subtle space leak. With a regular process that communicates with the outside world via IO, I know that the act of communicating a value causes it to be fully evaluated. However, with a multi threaded process, communication occurs via writes to TVars/IOVars and nothing gets evaluated. This gives lots of opportunities for space leaks. In this particularly case cleanup code was removing a large entry from a map stored in a Tvar. Because that map is only read infrequently, however, the memory release is delayed. This is the second such problem I've found. The profiling tools do help in discovering them, but it still needs a bit of thought and analysis. I wonder if, for my application, I should work out some means of deepseqing every value written to a Tvar. Tim -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of wren ng thornton Sent: Thursday, 7 May 2009 2:06 PM To: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is Haskell a Good Choice for Web Applications?(ANN: Vocabulink) FFT wrote: > Anton van Straaten wrote: > > > The app is written for a client under NDA, so a blog about it would > > have to be annoyingly vague. > > > No doubt the potential for encountering space leaks goes up as one > > writes less pure code, persist more things in memory, and depend on more libraries. > > Exactly. I'm worried about, e.g. needing to use something as simple as > a stream of prime numbers (see the recent thread about leaks there) The issues here are going to be the same in Haskell as in every other language. There's always a tradeoff between the memory of caching old results vs the time of recalculating them. At present no language's RTS/GC is smart enough to make that tradeoff for you, and so memoization must be done manually. There are some tricks to help make this easier (e.g. weak pointers), but the problem will always remain. The only thing that makes this perhaps trickier than in other languages is that, AFAIK/R, the reflection API to ask the RTS how it's feeling about memory at any given point isn't terribly portable (between Haskell compilers) or polished/pretty. Then again, the other GC languages I've dealt with aren't much better and are often worse. -- Live well, ~wren _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From apfelmus at quantentunnel.de Thu May 7 04:12:17 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Thu May 7 03:57:38 2009 Subject: [Haskell-cafe] Re: Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> <20090506212804.GC26120@whirlpool.galois.com> Message-ID: Bryan O'Sullivan wrote: > Jason Dagit wrote: > >> While I'm thinking out loud, it would be very cool if someone wrote >> some articles, say for the monad reader, that follow the formula of >> the Effective C++ books. > > > The last couple of times I've wanted a book like that, I wrote the book > myself. It's a very effective way to get the book you want, compared to > wishing. There is of course the dilemma that writing such a book requires a thorough understanding of the subject matter, which one intends to acquire by reading the book in the first place. I see a _|_ lurking there. :) Regards, apfelmus -- http://apfelmus.nfshost.com From waldmann at imn.htwk-leipzig.de Thu May 7 04:23:41 2009 From: waldmann at imn.htwk-leipzig.de (j.waldmann) Date: Thu May 7 04:09:01 2009 Subject: Re[Haskell-cafe] commending "Design concepts in programming languages" In-Reply-To: <5e0214850904291029gd68128bofccf9691c400adf4@mail.gmail.com> References: <5e0214850904291029gd68128bofccf9691c400adf4@mail.gmail.com> Message-ID: <23422300.post@talk.nabble.com> jkff wrote: > > To all those people who are in any sense interested in PL theory I'd > like to recommend the book "Design concepts in programming languages" > [...] > I ordered the book because of your description, and I agree completely. Besides the core points you already mentioned, it's also interesting to note what the book does not do (on purpose, for clearer exposition) * concepts are defined mathematically, and for each, a "mini" language is given that contains the concept (and not much else). and, there's lots of exercises (relating to these languages). - the book is *not* a review of how the design concepts are realized in different "real" programming languages. (There's other books that do this.) * the book avoids discussions on concrete syntax and parsing theory. Of the > 1200 pages, about 26 are on syntax, and it's just S-expressions. Again, very reasonable choice. * what they call "Pragmatics" contains a nice 100 pages on code generation that could be used in a compiler construction course. The approach is transformational: source, intermediate, and target languages are actually different subsets of one common language. The advantage is that you can discuss many small-step transformations, and still need only one semantics definition (and for implementation exercises, you could use one and the same interpreter for each). nit-pickingly, though: * Section 17.6.1 (in the "Compilation" part) tries to explain why the intermediate language is not explicitly typed. Using phrases like "explicit type information is often larger than the code it describes", "specifying each compiler stage becomes more complicated" etc. Well, this sounds like the typical "practicioner's complaint" that type systems may be nice, but only get in the way if you're doing real work. * in the Appendix on notation, he defines composition of functions the "wrong way around" (i.e., the Haskell way, (f.g)(x) = f(g(x)). This is of course very awkward, especially considering that functions are relations, and an element of a relation is a directed edge, and there's a very obvious meaning of how edges are composed to give a path. Well, the book's "solution" is to avoid to define composition of relations! (p. 1155, they only define the n-fold composition of a relation with itself, and there the problem does not show.) PS: I was shocked to find recently that Bourbaki (!) also defines functional composition "wrongly" (at least in the English edition of Elements of Math./Theory of Sets, II.3.7) but at least they are consistent and define composition of relations ("graphs") accordingly. They are very honest about this, e.g. "Let G1, G2, G3 be graphs. Then (G3 * G2) * G1 = G3 * (G2 * G1)." (note the order of the variables) -- View this message in context: http://www.nabble.com/Recommending-%22Design-concepts-in-programming-languages%22-tp23301907p23422300.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From apfelmus at quantentunnel.de Thu May 7 04:24:16 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Thu May 7 04:09:38 2009 Subject: [Haskell-cafe] Re: Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> <20090506212804.GC26120@whirlpool.galois.com> Message-ID: Jason Dagit wrote: > Looking over Real-World > haskell I see that some of these topics are discussed, which is really > good. In particular, Chapter 25 would be valuable to anyone trying to > find space leaks. There you discuss reduction to normal form, for > example, and some strictness issues and how to control evaluation. For some time now, I have this theory that confusion about space leaks can often be attributed to people not being informed about the evaluation model. They simply don't know what's going on; they only know that it's got something to do with these "thunks". Is that an accurate description? Regards, apfelmus -- http://apfelmus.nfshost.com From miguelimo38 at yandex.ru Thu May 7 04:28:45 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Thu May 7 04:14:37 2009 Subject: Re[Haskell-cafe] commending "Design concepts in programming languages" In-Reply-To: <23422300.post@talk.nabble.com> References: <5e0214850904291029gd68128bofccf9691c400adf4@mail.gmail.com> <23422300.post@talk.nabble.com> Message-ID: <4A029BBD.2070701@yandex.ru> > * in the Appendix on notation, he defines composition of functions > the "wrong way around" (i.e., the Haskell way, (f.g)(x) = f(g(x)). Just to make sure I understand correctly: are you claiming that Haskell definition of composition is wrong? From asviraspossible at gmail.com Thu May 7 04:40:28 2009 From: asviraspossible at gmail.com (Victor Nazarov) Date: Thu May 7 04:25:50 2009 Subject: [Haskell-cafe] calling a variable length parameter lambda expression In-Reply-To: References: <45fccde20905050949y6a0e8e40s89efdcadd3c8b217@mail.gmail.com> <45fccde20905060841k712beff2y4fc2f802fc9c56d0@mail.gmail.com> Message-ID: On Wed, May 6, 2009 at 7:44 PM, Daniel Peebles wrote: > Keep in mind that using lists for your parameters means you lose > static guarantees that you've passed the correct number of arguments > to a function (so you could crash at runtime if you pass too few or > too many parameters to a function). > Yes, program will crash with error "Pattern match failure" or smth like that. And yes, doLam is just an id with restricted type. My solution is close to what seems the most common way of passing arguments in Scheme, and the payoff is Scheme's dynamic typing... This solution is not the Haskell way and should be avoid. -- Victor Nazarov > On Wed, May 6, 2009 at 11:41 AM, Nico Rolle wrote: > > super nice. > > best solution for me so far. > > big thanks. > > regards > > > > 2009/5/6 Victor Nazarov : > >> On Tue, May 5, 2009 at 8:49 PM, Nico Rolle wrote: > >>> > >>> Hi everyone. > >>> > >>> I have a problem. > >>> A function is recieving a lambda expression like this: > >>> (\ x y -> x > y) > >>> or like this > >>> (\ x y z a -> (x > y) && (z < a) > >>> > >>> my problem is now i know i have a list filled with the parameters for > >>> the lambda expression. > >>> but how can i call that expression? > >>> [parameters] is my list of parameters for the lambda expression. > >>> lambda_ex is my lambda expression > >>> > >>> is there a function wich can do smth like that? > >>> > >>> lambda _ex (unfold_parameters parameters) > >> > >> Why not: > >> > >> lam1 = \[x, y] -> x > y > >> lam2 = \[x, y, z, a] -> (x > y) && (z < a) > >> > >> doLam :: Ord a => ([a] -> Bool) -> [a] -> Bool > >> doLam lam params = lam params > >> > >> So, this will work fine: > >> > >> doLam lam1 [1, 2] > >> doLam lam2 [1,2,3,4] > >> > >> -- > >> Victor Nazarov > >> > > _______________________________________________ > > 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/20090507/fcb934be/attachment.htm From timd at macquarie.com.au Thu May 7 04:45:52 2009 From: timd at macquarie.com.au (Tim Docker) Date: Thu May 7 04:31:55 2009 Subject: [Haskell-cafe] Data.Map and strictness (was: Is Haskell a Good Choice for WebApplications?(ANN: Vocabulink)) In-Reply-To: <7CA1B7BF2916F0418CAB6E705BC1224A3752E6@ntsydexm04.pc.internal.macquarie.com> References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> <4A021515.4090603@appsolutions.com> <4A025361.8080307@appsolutions.com><4A025E32.9080608@freegeek.org> <7CA1B7BF2916F0418CAB6E705BC1224A3752E6@ntsydexm04.pc.internal.macquarie.com> Message-ID: <7CA1B7BF2916F0418CAB6E705BC1224A3752E7@ntsydexm04.pc.internal.macquarie.com> Actually, I'm unsure how to fix this. For an expression like this: Data.Map.delete key map how can I use seq (or something else) to sufficiently evaluate the above to ensure that the value associated with key can be garbage collected? My knowledge of Data.Map is limited to it's haddock documentation. -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Tim Docker Sent: Thursday, 7 May 2009 6:04 PM To: haskell-cafe@haskell.org Subject: RE: [Haskell-cafe] Is Haskell a Good Choice for WebApplications?(ANN: Vocabulink) I think that multi-threading in combination with laziness makes space usage harder to manage. In fact, just today I have discovered a problem with a long running server process with a subtle space leak. With a regular process that communicates with the outside world via IO, I know that the act of communicating a value causes it to be fully evaluated. However, with a multi threaded process, communication occurs via writes to TVars/IOVars and nothing gets evaluated. This gives lots of opportunities for space leaks. In this particularly case cleanup code was removing a large entry from a map stored in a Tvar. Because that map is only read infrequently, however, the memory release is delayed. This is the second such problem I've found. The profiling tools do help in discovering them, but it still needs a bit of thought and analysis. I wonder if, for my application, I should work out some means of deepseqing every value written to a Tvar. Tim -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of wren ng thornton Sent: Thursday, 7 May 2009 2:06 PM To: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is Haskell a Good Choice for Web Applications?(ANN: Vocabulink) FFT wrote: > Anton van Straaten wrote: > > > The app is written for a client under NDA, so a blog about it would > > have to be annoyingly vague. > > > No doubt the potential for encountering space leaks goes up as one > > writes less pure code, persist more things in memory, and depend on more libraries. > > Exactly. I'm worried about, e.g. needing to use something as simple as > a stream of prime numbers (see the recent thread about leaks there) The issues here are going to be the same in Haskell as in every other language. There's always a tradeoff between the memory of caching old results vs the time of recalculating them. At present no language's RTS/GC is smart enough to make that tradeoff for you, and so memoization must be done manually. There are some tricks to help make this easier (e.g. weak pointers), but the problem will always remain. The only thing that makes this perhaps trickier than in other languages is that, AFAIK/R, the reflection API to ask the RTS how it's feeling about memory at any given point isn't terribly portable (between Haskell compilers) or polished/pretty. Then again, the other GC languages I've dealt with aren't much better and are often worse. -- Live well, ~wren _______________________________________________ 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 g9ks157k at acme.softbase.org Thu May 7 04:56:00 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Thu May 7 04:41:32 2009 Subject: [Haskell-cafe] Interesting Thread on OO Usefulness (scala mailing list) In-Reply-To: <1183842735.20090505203904@gmail.com> References: <200905051827.18279.g9ks157k@acme.softbase.org> <1183842735.20090505203904@gmail.com> Message-ID: <200905071056.01149.g9ks157k@acme.softbase.org> Am Dienstag, 5. Mai 2009 18:39 schrieb Bulat Ziganshin: > Hello Wolfgang, > > Tuesday, May 5, 2009, 8:27:17 PM, you wrote: > >> i know two problems in Haskell/GHC that require OO-loke features - > >> extensible exceptions and GUI widget types hierarchy > > > > Note that you don?t need different types for different kinds of GUI > > widgets if you use Functional Reactive Programming (FRP). You need > > different types if you use OO because you have to explicitely modify > > widgets after you have created them, and what modifications you are > > allowed to do, depends on the kind of widget. With FRP, you specify the > > behavior over all time when you create the widget, so no need for later > > method calls. > > (i don't know anything about FRP) > > i think it doesn't change anything. the main reason why i need common > operations is because i write generic procedures. another erason os > what i can't remember 100 individual 'setSize' operations for 100 > types of widgets. so we need to have some generic names, short of they > are used due initialization or later Yes, you need generic names also with FRP. The difference is that with OO, every property (e.g., size) corresponds to a pair of methods (setSize, getSize) while in FRP every property correspond to an input (or a parameter of the constructor if you think in OO terms). So with FRP, you need some kind of record system, preferably with the possibility to extend records. At least, this is the solution I use in Grapefruit. Best wishes, Wolfgang From applebiz89 at hotmail.com Thu May 7 05:46:34 2009 From: applebiz89 at hotmail.com (applebiz89) Date: Thu May 7 05:31:55 2009 Subject: [Haskell-cafe] IO help Message-ID: <23423403.post@talk.nabble.com> I havent done much IO at all in haskell, only within the function itself. However I want to get the input from the interface for the function and havent done this before. In my main function, I want to ask the user what they would like to do 'become fan' for example, then with their choice initiate the function and ask for the appropriate input for that function. This is the code below: main :: IO() do putStr "Hi there! what is your name: " fanName = getLine do putStr "1 = Insert film, 2 = Become a Fan, 3 = The number of fans of a film, 4 = Film released in a year: " input = getLine read input :: Int (if input == 1 then main x = insertFilm [] else if input == 2 then main x = becomeFan [] else if input == 3 then main x = numberOfFans []) Say they choose film in a given year function function: filmsInGivenYear :: Int -> [Film] -> [String] filmsInGivenYear filmYear films = [ title | (Film title director year fans) <- films, year == filmYear] I need to ask the user what filmYear they want to insert. But i need to do this from the main function...I chose to do an if statement to choose what function they want, but i dont know where to go from there? any help will be greatly appreciated. thanks apple -- View this message in context: http://www.nabble.com/IO-help-tp23423403p23423403.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From miguelimo38 at yandex.ru Thu May 7 05:56:53 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Thu May 7 05:42:42 2009 Subject: [Haskell-cafe] IO help In-Reply-To: <23423403.post@talk.nabble.com> References: <23423403.post@talk.nabble.com> Message-ID: <4A02B065.5010000@yandex.ru> I have a suggestion. Why don't you grab some introductory book on Haskell and learn Haskell syntax a little? applebiz89 wrote on 07.05.2009 13:46: > I havent done much IO at all in haskell, only within the function itself. > However I want to get the input from the interface for the function and > havent done this before. > > In my main function, I want to ask the user what they would like to do > 'become fan' for example, then with their choice initiate the function and > ask for the appropriate input for that function. This is the code below: > > main :: IO() > do putStr "Hi there! what is your name: " > fanName = getLine > do putStr "1 = Insert film, 2 = Become a Fan, 3 = The number of fans of a > film, 4 = Film released in a year: " > input = getLine > read input :: Int What exactly do you think this line is going to do? > (if input == 1 then main x = insertFilm [] else if input == 2 then main x = > becomeFan [] else if input == 3 then main x = numberOfFans []) All these "main x =" are just syntax errors. > > Say they choose film in a given year function function: > > filmsInGivenYear :: Int -> [Film] -> [String] > filmsInGivenYear filmYear films = [ title | (Film title director year fans) > <- films, year == filmYear] > > I need to ask the user what filmYear they want to insert. But i need to do > this from the main function...I chose to do an if statement to choose what > function they want, but i dont know where to go from there? > > any help will be greatly appreciated. > > thanks > > apple From marlowsd at gmail.com Thu May 7 06:04:05 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Thu May 7 05:49:28 2009 Subject: [Haskell] Re[2]: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <204746127.20090507001813@gmail.com> References: <87fxfll3ad.fsf@forno.us> <204746127.20090507001813@gmail.com> Message-ID: <4A02B215.4060902@gmail.com> On 06/05/2009 21:18, Bulat Ziganshin wrote: > Hello FFT, > > Wednesday, May 6, 2009, 11:59:53 PM, you wrote: > >> I've heard it's hard to contain a long-running Haskell application in >> a finite amount of memory > > not exactly. you may alloc fixed pool of memory to application (say, 1gb) > if you know that it never need more memory. but as far as you don't do > it, memory usage grows with each major GC. ghc just don't provide > any way to return memory to OS (there is a ticket on it, you can add > yourself to CC list to vote for its resolution) http://hackage.haskell.org/trac/ghc/ticket/698 But let's be clear: this is not a memory leak, the issue is only that GHC's runtime retains as much memory as was required by the program's high-water-mark memory usage. Fixing this will never reduce the high-water-mark. So I'm not sure what you meant by "memory usage grows with each major GC". Cheers, Simon From ganesh.sittampalam at credit-suisse.com Thu May 7 06:07:27 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Thu May 7 05:53:26 2009 Subject: [Haskell-cafe] Data.Map and strictness (was: Is Haskell a GoodChoice for WebApplications?(ANN: Vocabulink)) In-Reply-To: <7CA1B7BF2916F0418CAB6E705BC1224A3752E7@ntsydexm04.pc.internal.macquarie.com> References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> <4A021515.4090603@appsolutions.com> <4A025361.8080307@appsolutions.com><4A025E32.9080608@freegeek.org><7CA1B7BF2916F0418CAB6E705BC1224A3752E6@ntsydexm04.pc.internal.macquarie.com> <7CA1B7BF2916F0418CAB6E705BC1224A3752E7@ntsydexm04.pc.internal.macquarie.com> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B01ABAAD2@ELON17P32001A.csfb.cs-group.com> seq something like size map that will force a traversal of the entire tree, and ensure that the result is actually demanded, e.g. when writing to a TVar: do ... let map' = Data.Map.delete key map size map' `seq` writeTVar tvar map' ... (Not tested) Note that this also won't force any of the values; it sounds like in this case you don't want them forced. -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Tim Docker Sent: 07 May 2009 09:46 To: haskell-cafe@haskell.org Subject: [Haskell-cafe] Data.Map and strictness (was: Is Haskell a GoodChoice for WebApplications?(ANN: Vocabulink)) Actually, I'm unsure how to fix this. For an expression like this: Data.Map.delete key map how can I use seq (or something else) to sufficiently evaluate the above to ensure that the value associated with key can be garbage collected? My knowledge of Data.Map is limited to it's haddock documentation. -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Tim Docker Sent: Thursday, 7 May 2009 6:04 PM To: haskell-cafe@haskell.org Subject: RE: [Haskell-cafe] Is Haskell a Good Choice for WebApplications?(ANN: Vocabulink) I think that multi-threading in combination with laziness makes space usage harder to manage. In fact, just today I have discovered a problem with a long running server process with a subtle space leak. With a regular process that communicates with the outside world via IO, I know that the act of communicating a value causes it to be fully evaluated. However, with a multi threaded process, communication occurs via writes to TVars/IOVars and nothing gets evaluated. This gives lots of opportunities for space leaks. In this particularly case cleanup code was removing a large entry from a map stored in a Tvar. Because that map is only read infrequently, however, the memory release is delayed. This is the second such problem I've found. The profiling tools do help in discovering them, but it still needs a bit of thought and analysis. I wonder if, for my application, I should work out some means of deepseqing every value written to a Tvar. Tim -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of wren ng thornton Sent: Thursday, 7 May 2009 2:06 PM To: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Is Haskell a Good Choice for Web Applications?(ANN: Vocabulink) FFT wrote: > Anton van Straaten wrote: > > > The app is written for a client under NDA, so a blog about it would > > have to be annoyingly vague. > > > No doubt the potential for encountering space leaks goes up as one > > writes less pure code, persist more things in memory, and depend on more libraries. > > Exactly. I'm worried about, e.g. needing to use something as simple as > a stream of prime numbers (see the recent thread about leaks there) The issues here are going to be the same in Haskell as in every other language. There's always a tradeoff between the memory of caching old results vs the time of recalculating them. At present no language's RTS/GC is smart enough to make that tradeoff for you, and so memoization must be done manually. There are some tricks to help make this easier (e.g. weak pointers), but the problem will always remain. The only thing that makes this perhaps trickier than in other languages is that, AFAIK/R, the reflection API to ask the RTS how it's feeling about memory at any given point isn't terribly portable (between Haskell compilers) or polished/pretty. Then again, the other GC languages I've dealt with aren't much better and are often worse. -- Live well, ~wren _______________________________________________ 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 =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From bulat.ziganshin at gmail.com Thu May 7 06:11:10 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu May 7 05:56:50 2009 Subject: [Haskell-cafe] IO help In-Reply-To: <23423403.post@talk.nabble.com> References: <23423403.post@talk.nabble.com> Message-ID: <162813495.20090507141110@gmail.com> Hello applebiz89, Thursday, May 7, 2009, 1:46:34 PM, you wrote: > main :: IO() you may find http://haskell.org/haskellwiki/IO_inside interesting -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From DekuDekuplex at Yahoo.com Thu May 7 06:28:01 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Thu May 7 06:13:37 2009 Subject: [Haskell-cafe] How difficult would creating a collaborative multi-user online virtual world application be in Haskell? Message-ID: One question that has been coming up at the back of my mind for the past several weeks has been how difficult would it be to create a collaborative multi-user online virtual world application in Haskell. More specifically, last August, I came across a very interesting application called Croquet (see http://www.opencroquet.org/index.php/Main_Page), which happens to be based on Squeak (see http://www.squeak.org/), a dialect of Smalltalk. Croquet, in turn, provides the basis for Cobalt (see http://www.duke.edu/~julian/Cobalt/Home.html), a "virtual workspace browser and construction toolkit for accessing, creating, and publishing hyperlinked multi-user virtual environments" (according to the home page for that project). What struck me as especially interesting was how Croquet allows multiple users to collaborate together in a multi-user online virtual world in software development and other collaborative projects. As one application, the video clip on the upper-right-hand corner of the above-mentioned Croquet home page illustrates how a user can, by writing code from inside the application, create on-the-fly additional virtual environments, which can then be entered by either the programmer or other programmers. Other applications (shown in other video clips on the "Screenshots/Videos" page (see http://www.opencroquet.org/index.php/Screenshots/Videos) show alternative applications that include text-based annotations, a 3D spreadsheet, and writing a conventional blog from within a virtual world. Unfortunately, Smalltalk is an object-oriented language. If possible, I would like to see something similar in a functional programming language such as Haskell. Does anybody know whether duplicating this project in Haskell would be feasible? -- 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 aneumann at inf.fu-berlin.de Thu May 7 06:44:11 2009 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Thu May 7 06:29:45 2009 Subject: [Haskell-cafe] IO help In-Reply-To: <23423403.post@talk.nabble.com> References: <23423403.post@talk.nabble.com> Message-ID: Have a look at the wikibook: http://en.wikibooks.org/wiki/Haskell/Simple_input_and_output Am 07.05.2009 um 11:46 schrieb applebiz89: > > I havent done much IO at all in haskell, only within the function > itself. > However I want to get the input from the interface for the function > and > havent done this before. > > In my main function, I want to ask the user what they would like to do > 'become fan' for example, then with their choice initiate the > function and > ask for the appropriate input for that function. This is the code > below: > > main :: IO() > do putStr "Hi there! what is your name: " > fanName = getLine > do putStr "1 = Insert film, 2 = Become a Fan, 3 = The number of > fans of a > film, 4 = Film released in a year: " > input = getLine > read input :: Int > (if input == 1 then main x = insertFilm [] else if input == 2 then > main x = > becomeFan [] else if input == 3 then main x = numberOfFans []) > > Say they choose film in a given year function function: > > filmsInGivenYear :: Int -> [Film] -> [String] > filmsInGivenYear filmYear films = [ title | (Film title director > year fans) > <- films, year == filmYear] > > I need to ask the user what filmYear they want to insert. But i > need to do > this from the main function...I chose to do an if statement to > choose what > function they want, but i dont know where to go from there? > > any help will be greatly appreciated. > > thanks > > apple > -- > View this message in context: http://www.nabble.com/IO-help- > tp23423403p23423403.html > Sent from the Haskell - Haskell-Cafe mailing list archive at > Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- 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/20090507/85fe7701/PGP.bin From bulat.ziganshin at gmail.com Thu May 7 06:51:02 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu May 7 06:36:44 2009 Subject: [Haskell] Re[2]: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <4A02B215.4060902@gmail.com> References: <87fxfll3ad.fsf@forno.us> <204746127.20090507001813@gmail.com> <4A02B215.4060902@gmail.com> Message-ID: <811855674.20090507145102@gmail.com> Hello Simon, Thursday, May 7, 2009, 2:04:05 PM, you wrote: >>> I've heard it's hard to contain a long-running Haskell application in >>> a finite amount of memory >> >> not exactly. you may alloc fixed pool of memory to application (say, 1gb) >> if you know that it never need more memory. but as far as you don't do >> it, memory usage grows with each major GC. ghc just don't provide >> any way to return memory to OS (there is a ticket on it, you can add >> yourself to CC list to vote for its resolution) > http://hackage.haskell.org/trac/ghc/ticket/698 > But let's be clear: this is not a memory leak, the issue is only that > GHC's runtime retains as much memory as was required by the program's > high-water-mark memory usage. Fixing this will never reduce the > high-water-mark. So I'm not sure what you meant by "memory usage grows > with each major GC". 1. none said that it's memory leak, at least in haskell code 2. it seems that one of us doesn't know intimate details of GHC GC :) the following is my understanding, learned from +RTS -s/-S listings with ghc 6.4 or so: copying GC: let's imagine that we perform major GC when 100 mb is allocated, of those 10 mb are live. doing GC, ghc will alloc 10+ mb from OS, and promote 100 mb freed to allocation area. so from this point program will occupy 110mb of memory (although only 10 mb is really used ATM) next major GC will occur when all these 100 mb will be allocated, i.e. overall memory allocated will be 110 mb. again, GHC will allocate as much memory as required for live data, increasing program footprint compacting GC: if major GC occurs when 100 mb is allocated, GHC increase memory footprint 2x (controlled by +RTS -F), and then perform GC. or it will perform GC and only then alloc more memory? i don't remember Simon, it will be VERY USEFUL if GC description that says about these behaviors will be added to manual. i'm definitely not the authoritative source on this topic and it seems that even you forget some details as time goes. this topic is very important for large programs and this question regularly arises here. we need authoritative description that pays attention to all GC-related RTS switches -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From wagner.andrew at gmail.com Thu May 7 07:09:29 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Thu May 7 06:55:04 2009 Subject: [Haskell-cafe] How difficult would creating a collaborative multi-user online virtual world application be in Haskell? In-Reply-To: References: Message-ID: <354B094E-59B3-468B-AB3C-0F64C1568CD6@gmail.com> This reminds me of a server app I saw recently in a language called Clojure. Clojure is a relatively new lisp variant targeting the JVM, and has a home-grown STM layer built into the language. Anyway, the app I saw was a (admittedly didactic-focused) multi-threaded MUD server (google "clojure mire"), which could easy serve as the foundation for a project like this. Thus, I would say that STM is up for the challenge. The question in my mind would be whether or not Haskell's graphics/video libraries are mature enough. On May 7, 2009, at 6:28 AM, Benjamin L.Russell wrote: > One question that has been coming up at the back of my mind for the > past several weeks has been how difficult would it be to create a > collaborative multi-user online virtual world application in Haskell. > > More specifically, last August, I came across a very interesting > application called Croquet (see > http://www.opencroquet.org/index.php/Main_Page), which happens to be > based on Squeak (see http://www.squeak.org/), a dialect of Smalltalk. > Croquet, in turn, provides the basis for Cobalt (see > http://www.duke.edu/~julian/Cobalt/Home.html), a "virtual workspace > browser and construction toolkit for accessing, creating, and > publishing hyperlinked multi-user virtual environments" (according to > the home page for that project). > > What struck me as especially interesting was how Croquet allows > multiple users to collaborate together in a multi-user online virtual > world in software development and other collaborative projects. As > one application, the video clip on the upper-right-hand corner of the > above-mentioned Croquet home page illustrates how a user can, by > writing code from inside the application, create on-the-fly additional > virtual environments, which can then be entered by either the > programmer or other programmers. Other applications (shown in other > video clips on the "Screenshots/Videos" page (see > http://www.opencroquet.org/index.php/Screenshots/Videos) show > alternative applications that include text-based annotations, a 3D > spreadsheet, and writing a conventional blog from within a virtual > world. > > Unfortunately, Smalltalk is an object-oriented language. If possible, > I would like to see something similar in a functional programming > language such as Haskell. > > Does anybody know whether duplicating this project in Haskell would be > feasible? > > -- Benjamin L. Russell > -- > Benjamin L. Russell / DekuDekuplex at Yahoo dot com > http://dekudekuplex.wordpress.com/ > Translator/Interpreter / Mobile: +011 81 80-3603-6725 > "Furuike ya, kawazu tobikomu mizu no oto." > -- Matsuo Basho^ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From sebf at informatik.uni-kiel.de Thu May 7 07:48:40 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Thu May 7 07:34:04 2009 Subject: [Haskell-cafe] traversing a tree using monad.cont In-Reply-To: References: <7ca3f0160905012035h6c333b57yca03c34e7cc342ec@mail.gmail.com> <2f9b2d30905031440m79a6e00fi1b58c3b69ea97c9a@mail.gmail.com> Message-ID: <4956E4B4-9136-4E47-891F-1A29E0EB8E98@informatik.uni-kiel.de> > On Sun, May 3, 2009 at 2:40 PM, Ryan Ingram > wrote: >> There's a great exposition of using something much like Cont to get >> success and failure "for free" here: >> http://www-ps.informatik.uni-kiel.de/~sebf/haskell/barefaced-pilferage-of-monadic-bind.lhs.html On May 4, 2009, at 10:32 PM, Anatoly Yakovenko wrote: > thanks, that looks promising, but will probably take me a week to > understand :) maybe the article version is easier to grasp: http://www-ps.informatik.uni-kiel.de/~sebf/data/pub/atps09.pdf -Sebastian From claus.reinke at talk21.com Thu May 7 08:30:34 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Thu May 7 08:16:00 2009 Subject: [Haskell-cafe] Data.Map and strictness (was: Is Haskell aGoodChoice for WebApplications?(ANN: Vocabulink)) References: <87fxfll3ad.fsf@forno.us> <20090506200123.GB26120@whirlpool.galois.com> <4A021515.4090603@appsolutions.com> <4A025361.8080307@appsolutions.com><4A025E32.9080608@freegeek.org><7CA1B7BF2916F0418CAB6E705BC1224A3752E6@ntsydexm04.pc.internal.macquarie.com><7CA1B7BF2916F0418CAB6E705BC1224A3752E7@ntsydexm04.pc.internal.macquarie.com> <16442B752A06A74AB4D9F9A5FF076E4B01ABAAD2@ELON17P32001A.csfb.cs-group.com> Message-ID: > seq something like size map that will force a traversal of the entire > tree, and ensure that the result is actually demanded, .. > (Not tested) and not recommended, either, I'm afraid!-) |> Actually, I'm unsure how to fix this. For an expression like this: |> |> Data.Map.delete key map |> |> how can I use seq (or something else) to sufficiently evaluate the above |> to ensure that the value associated with key can be garbage collected? You can ensure that the Map update no longer holds on to the old key by keeping a copy of the old Map in an unevaluated thunk, but for garbage collection, you'd also have to make sure that there are no other unused references to the old Map, and no other references to the value in that old key. I assume you knew that, but the discussion suggested that we should keep making such things explicit. |> My knowledge of Data.Map is limited to it's haddock documentation. That won't be sufficient in practice, eg., most of the documentation is silent about strictness properties. If you are willing to look a little bit under the hood, GHCi's :info is your friend: Prelude> :m +Data.Map Prelude Data.Map> :info Map data Map k a = Data.Map.Tip | Data.Map.Bin !Data.Map.Size !k a !(Map k a) !(Map k a) -- Defined in Data.Map ... You can see that the constructors are not exported (GHCi reports them qualified, even though we've brought Data.Map into scope), so any use you make of their strictness properties is version dependent. They are not likely to change soon, and should probably be documented in the haddock API specification (at least for the abstract constructors that are actually exported), so that we can rely on them with clear conscience, but that isn't quite the case at the moment. Anyway;-) You can see that size is actually pre-computed, so there's no guarantee that asking for it will traverse the internal representation, the element type is not stored strictly (which isn't all that unexpected, but sometimes surprises because it isn't documented), and everything else is strict. So, with the current representation, if you force the Map, its whole structure will be forced, though none of its elements will be. Hth, Claus PS. GHood is useful for observing dynamic strictness properties (what is inspected when, with what dependencies and results), though it won't help you directly with garbage collection issues (it can't observe when a value gets collected). From daniel.is.fischer at web.de Thu May 7 08:42:50 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu May 7 08:28:41 2009 Subject: Re[Haskell-cafe] commending "Design concepts in programming languages" In-Reply-To: <23422300.post@talk.nabble.com> References: <5e0214850904291029gd68128bofccf9691c400adf4@mail.gmail.com> <23422300.post@talk.nabble.com> Message-ID: <200905071442.50257.daniel.is.fischer@web.de> Am Donnerstag 07 Mai 2009 10:23:41 schrieb j.waldmann: > * in the Appendix on notation, ?he defines composition of functions > the "wrong way around" (i.e., the Haskell way, (f.g)(x) = f(g(x)). > This is of course very awkward, especially considering that functions are > relations, > and an element of a relation is a directed edge, and there's a very obvious > meaning > of how edges are composed to give a path. > Well, the book's "solution" is to avoid to define composition of relations! > (p. 1155, they only define the n-fold composition of a relation with > itself, and there the problem does not show.) > > PS: I was shocked to find recently that Bourbaki (!) also defines > functional composition "wrongly" > (at least in the English edition of Elements of Math./Theory of Sets, > II.3.7) > but at least they are consistent and define composition of relations > ("graphs") accordingly. > They are very honest about this, e.g. "Let G1, G2, G3 be graphs. > Then (G3 * G2) * G1 = G3 * (G2 * G1)." ?(note the order of the variables) That's the way composition of functions (and more generally relations) has been done for ages in mathematics. And since one writes f(x) and not x.f, it's the consistent way to define the composition. Of course, if centuries ago people had decided to write the argument before the function, composition would've been defined the other way round. They haven't. From marlowsd at gmail.com Thu May 7 09:45:53 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Thu May 7 09:31:16 2009 Subject: [Haskell] Re[2]: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <811855674.20090507145102@gmail.com> References: <87fxfll3ad.fsf@forno.us> <204746127.20090507001813@gmail.com> <4A02B215.4060902@gmail.com> <811855674.20090507145102@gmail.com> Message-ID: <4A02E611.1000807@gmail.com> On 07/05/2009 11:51, Bulat Ziganshin wrote: > Hello Simon, > > Thursday, May 7, 2009, 2:04:05 PM, you wrote: > >>>> I've heard it's hard to contain a long-running Haskell application in >>>> a finite amount of memory >>> not exactly. you may alloc fixed pool of memory to application (say, 1gb) >>> if you know that it never need more memory. but as far as you don't do >>> it, memory usage grows with each major GC. ghc just don't provide >>> any way to return memory to OS (there is a ticket on it, you can add >>> yourself to CC list to vote for its resolution) > >> http://hackage.haskell.org/trac/ghc/ticket/698 > >> But let's be clear: this is not a memory leak, the issue is only that >> GHC's runtime retains as much memory as was required by the program's >> high-water-mark memory usage. Fixing this will never reduce the >> high-water-mark. So I'm not sure what you meant by "memory usage grows >> with each major GC". > > 1. none said that it's memory leak, at least in haskell code You said "memory usage grows with each major GC", which sounded like a leak, I just wanted to clarify. > 2. it seems that one of us doesn't know intimate details of GHC GC :) > the following is my understanding, learned from +RTS -s/-S listings > with ghc 6.4 or so: > > copying GC: let's imagine that we perform major GC when 100 mb is > allocated, of those 10 mb are live. doing GC, ghc will alloc 10+ mb > from OS, Yes. > and promote 100 mb freed to allocation area. No. Well, it depends on the GC settings. With the default GC settings, the allocation area for each core is fixed at 512k (the docs are a bit out of date and say 256k, I've just fixed that). The old generation is allowed to grow to 2x its previous size by default before being collected. This is tunable with +RTS -F. In your example, the live data is 10MB, so the old generation will be allowed to grow to 20MB before being collected, meanwhile the young generation has 512KB for the allocation area, plus "step 2" of the young generation which will be at most another 512KB and usually a lot smaller. So 21MB max in total. When the old generation is next collected, assuming 10MB are still live, we'll need in total 21MB + 10MB of copied live data = 31MB. The problem referred to originally in this thread is that even though the program might be running with a steady memory usage of 31MB, if in the past it needed 100MB that extra memory is retained by the RTS and won't be freed back to the OS. > so from this > point program will occupy 110mb of memory (although only 10 mb is > really used ATM) Yes - if 100MB has been allocated, and 10MB copied, then the total memory that the RTS has allocated from the OS will be 110MB. > next major GC will occur when all these 100 mb will be allocated, i.e. > overall memory allocated will be 110 mb. No - see above. > again, GHC will allocate as > much memory as required for live data, increasing program footprint > > > compacting GC: if major GC occurs when 100 mb is allocated, GHC > increase memory footprint 2x (controlled by +RTS -F), and then perform > GC. or it will perform GC and only then alloc more memory? i don't > remember exactly as above, except that the heap is compacted in-place rather than the live data being copied, so no additional memory is required by the GC. Well, there's a little memory used for the bitmaps and the mark stack, but that will be a few percent at most. > Simon, it will be VERY USEFUL if GC description that says about these > behaviors will be added to manual. i'm definitely not the > authoritative source on this topic and it seems that even you forget > some details as time goes. this topic is very important for large > programs and this question regularly arises here. we need > authoritative description that pays attention to all GC-related RTS > switches The -A and -F flags are pretty well documented in the manual: http://www.haskell.org/ghc/docs/latest/html/users_guide/runtime-control.html#rts-options-gc I'm happy to add more text here, what else would you like to see? Cheers, Simon From bulat.ziganshin at gmail.com Thu May 7 10:17:52 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu May 7 10:04:28 2009 Subject: [Haskell] Re[2]: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <4A02E611.1000807@gmail.com> References: <87fxfll3ad.fsf@forno.us> <204746127.20090507001813@gmail.com> <4A02B215.4060902@gmail.com> <811855674.20090507145102@gmail.com> <4A02E611.1000807@gmail.com> Message-ID: <1210666055.20090507181752@gmail.com> Hello Simon, Thursday, May 7, 2009, 5:45:53 PM, you wrote: > out of date and say 256k, I've just fixed that). The old generation is > allowed to grow to 2x its previous size by default before being > collected. you are right. i just checked old logs - seems that previously i just misinterpreted them >> we need authoritative description that pays attention to all >> GC-related RTS switches > I'm happy to add more text here, what else would you like to see? how about text that describes GC scenario like you was wrote in this letter? plus, description of RTS +S report format - it may be added to this scenario, i.e. "after this major GC, the following line will be printed to +S report: ..." for example, i still doesn't understand why old_live + alloc - collect != new_live in the report below (i extracted two sequential lines): Alloc Collect Live GC GC TOT TOT Page Flts bytes bytes bytes user elap user elap 265016 303104 840008 0.00 0.00 0.11 0.17 0 0 (Gen: 0) 265612 266240 904196 0.00 0.00 0.11 0.17 0 0 (Gen: 0) and completely separate topic - +RTS -s report description also doesn't exist -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From marlowsd at gmail.com Thu May 7 10:58:02 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Thu May 7 10:43:24 2009 Subject: [Haskell] Re[2]: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <1210666055.20090507181752@gmail.com> References: <87fxfll3ad.fsf@forno.us> <204746127.20090507001813@gmail.com> <4A02B215.4060902@gmail.com> <811855674.20090507145102@gmail.com> <4A02E611.1000807@gmail.com> <1210666055.20090507181752@gmail.com> Message-ID: <4A02F6FA.80804@gmail.com> On 07/05/2009 15:17, Bulat Ziganshin wrote: > Hello Simon, > > Thursday, May 7, 2009, 5:45:53 PM, you wrote: > >> out of date and say 256k, I've just fixed that). The old generation is >> allowed to grow to 2x its previous size by default before being >> collected. > > you are right. i just checked old logs - seems that previously i just > misinterpreted them > >>> we need authoritative description that pays attention to all >>> GC-related RTS switches > >> I'm happy to add more text here, what else would you like to see? > > how about text that describes GC scenario like you was wrote in this > letter? plus, description of RTS +S report format - it may be added to > this scenario, i.e. "after this major GC, the following line will be > printed to +S report: ..." > > for example, i still doesn't understand why > > old_live + alloc - collect != new_live The output has changed: it now counts copied data, since as you say "collect" is a function of the other columns. > in the report below (i extracted two sequential lines): > > Alloc Collect Live GC GC TOT TOT Page Flts > bytes bytes bytes user elap user elap > 265016 303104 840008 0.00 0.00 0.11 0.17 0 0 (Gen: 0) > 265612 266240 904196 0.00 0.00 0.11 0.17 0 0 (Gen: 0) > > > and completely separate topic - +RTS -s report description also > doesn't exist Scroll down in that section I linked to before: http://www.haskell.org/ghc/docs/latest/html/users_guide/runtime-control.html#rts-options-gc Cheers, Simon From es at ertes.de Thu May 7 12:37:20 2009 From: es at ertes.de (Ertugrul Soeylemez) Date: Thu May 7 12:22:49 2009 Subject: [Haskell-cafe] Re: Getting WriterT log lazily References: <49FE09D7.5090108@therning.org> <49FE9DC0.9060201@van.steenbergen.nl> <49FEB1CC.5030501@therning.org> <50b5ae760905060928o454231b2ya0dccdb46afe9445@mail.gmail.com> Message-ID: <20090507183720.73c65395@tritium.xx> Stephen Hicks wrote: > Magnus Therning wrote: > > Martijn van Steenbergen wrote: > >> > >> Otherwise, you can use unsafeInterleaveIO: no unsafePerformIO or seq > >> needed, but there's still "unsafe" in that name there. This works for me: > ... > > Thanks, that does indeed work, but it still requires that "unsafe" there so > > I'm hesitant replacing the call to threadDelay with something more > > complicated, where it isn't obviously safe. > > Sorry for the late reply, but I'd like to piggy-back on this. It's my > understanding that unsafeInterleaveIO is only unsafe insofar as it > makes the IO lazy and so the IO may be performed later or never at all > (if its return value is never wanted) and is therefore no less safe > than, say, generating a list of IO actions as was suggested by an > earlier reply. It seems to me that its unsafeness is of a completely > different nature than unsafePerformIO... am I missing something? There are two issues with unsafePerformIO: The laziness makes evaluation unpredictable to some extent, but that's intentional. But for example what if the IO computation throws an exception? There is no well-defined behaviour, not even a well-known convention. For example, hGetContents simply aborts, which makes errors undetectable. All in all, unsafeInterleaveIO is a handy tool, but you need to be careful about its side effects. Greets, Ertugrul. -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/ From bulat.ziganshin at gmail.com Thu May 7 12:55:18 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu May 7 12:41:06 2009 Subject: [Haskell] Re[2]: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <4A02F6FA.80804@gmail.com> References: <87fxfll3ad.fsf@forno.us> <204746127.20090507001813@gmail.com> <4A02B215.4060902@gmail.com> <811855674.20090507145102@gmail.com> <4A02E611.1000807@gmail.com> <1210666055.20090507181752@gmail.com> <4A02F6FA.80804@gmail.com> Message-ID: <118713518.20090507205518@gmail.com> Hello Simon, Thursday, May 7, 2009, 6:58:02 PM, you wrote: >> and completely separate topic - +RTS -s report description also >> doesn't exist > Scroll down in that section I linked to before: > http://www.haskell.org/ghc/docs/latest/html/users_guide/runtime-control.html#rts-options-gc you are right again. so, that remains: you shouldn't suppose that user have read 90's GC paper. give a short excerpt of it: how generational GC works and how memory usage converts to memory footprint. then descriptions of RTS options will serve as "modifications" to this "baseline" one minor update: manual said "For each garbage collection, we print: * How many bytes we allocated this garbage collection." i think it should be "How many bytes we allocated *SINCE* last garbage collection." -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From dagit at codersbase.com Thu May 7 13:06:33 2009 From: dagit at codersbase.com (Jason Dagit) Date: Thu May 7 12:51:51 2009 Subject: [Haskell] Re[2]: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: <118713518.20090507205518@gmail.com> References: <87fxfll3ad.fsf@forno.us> <204746127.20090507001813@gmail.com> <4A02B215.4060902@gmail.com> <811855674.20090507145102@gmail.com> <4A02E611.1000807@gmail.com> <1210666055.20090507181752@gmail.com> <4A02F6FA.80804@gmail.com> <118713518.20090507205518@gmail.com> Message-ID: On Thu, May 7, 2009 at 9:55 AM, Bulat Ziganshin wrote: > Hello Simon, > > Thursday, May 7, 2009, 6:58:02 PM, you wrote: > >>> and completely separate topic - +RTS -s report description also >>> doesn't exist > >> Scroll down in that section I linked to before: > >> http://www.haskell.org/ghc/docs/latest/html/users_guide/runtime-control.html#rts-options-gc > > you are right again. so, that remains: you shouldn't suppose that > user have read 90's GC paper. give a short excerpt of it: how > generational GC works and how memory usage converts to memory > footprint. then descriptions of RTS options will serve as > "modifications" to this "baseline" Bulat, Perhaps you could write a description here to the list or the wiki and after a few iterations it could be included in the GHC manual? Thanks, Jason From itsme213 at hotmail.com Thu May 7 13:18:47 2009 From: itsme213 at hotmail.com (Itsme (Sophie)) Date: Thu May 7 13:04:16 2009 Subject: [Haskell-cafe] Trying to contact authors of "Real World Haskell"? Message-ID: I could not find any contact info for Brian O'Sullivan, Don Stewart, or John Goerzen on their book site. Any pointers to how I might locate any of them much appreciated. Thanks! Sophie From nccb2 at kent.ac.uk Thu May 7 13:28:20 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Thu May 7 13:12:46 2009 Subject: [Haskell-cafe] Trying to contact authors of "Real World Haskell"? In-Reply-To: References: Message-ID: <4A031A34.8080000@kent.ac.uk> Itsme (Sophie) wrote: > I could not find any contact info for Brian O'Sullivan, Don Stewart, > or John > Goerzen on their book site. Any pointers to how I might locate any of > them > much appreciated. Two of the three have posted to this list in the last 24 hours, so you can take their email addresses from the archive. Although I heard that if you chant "I don't think this can be done in Haskell" three times in front of a text editor, Don Stewart appears and implements it in one line... Thanks, Neil. From colinpauladams at googlemail.com Thu May 7 13:31:12 2009 From: colinpauladams at googlemail.com (Colin Adams) Date: Thu May 7 13:16:33 2009 Subject: [Haskell-cafe] Trying to contact authors of "Real World Haskell"? In-Reply-To: <4A031A34.8080000@kent.ac.uk> References: <4A031A34.8080000@kent.ac.uk> Message-ID: <1afdeaec0905071031n59a747c9lef04770aace6c5ed@mail.gmail.com> I don't think that CAN be done in Haskell (but just in case, I'm only saying it once). 2009/5/7 Neil Brown : > Although I heard that if you chant "I don't think this can be done in > Haskell" three times in front of a text editor, Don Stewart appears and > implements it in one line... From daniel.is.fischer at web.de Thu May 7 13:31:24 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu May 7 13:17:18 2009 Subject: [Haskell-cafe] Trying to contact authors of "Real World Haskell"? In-Reply-To: <4A031A34.8080000@kent.ac.uk> References: <4A031A34.8080000@kent.ac.uk> Message-ID: <200905071931.25321.daniel.is.fischer@web.de> Am Donnerstag 07 Mai 2009 19:28:20 schrieb Neil Brown: > Although I heard that if you chant "I don't think this can be done in > Haskell" three times in front of a text editor, Don Stewart appears and > implements it in one line... Not if it's type trickery, then it's going to be oleg :) > > Thanks, > > Neil. From bulat.ziganshin at gmail.com Thu May 7 13:31:42 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu May 7 13:17:29 2009 Subject: [Haskell-cafe] Trying to contact authors of "Real World Haskell"? In-Reply-To: References: Message-ID: <883065640.20090507213142@gmail.com> Hello Itsme, Thursday, May 7, 2009, 9:18:47 PM, you wrote: > I could not find any contact info for Brian O'Sullivan, Don Stewart, or John > Goerzen on their book site. Any pointers to how I might locate any of them > much appreciated. they are highly secret Haskell agents sent from 21xx. we are not yet sure they are really exists -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From j.romildo at gmail.com Thu May 7 08:59:47 2009 From: j.romildo at gmail.com (j.romildo@gmail.com) Date: Thu May 7 13:23:30 2009 Subject: [Haskell-cafe] Operator precedence and associativity on happy grammars Message-ID: <20090507125947.GA25990@darling.DHCP-GERAL> Hello. I am learning how to use Happy (a LALR(1) parser generator) and I have a question on a grammar based on an example from the manual. The input file to Happy is attached to this message. The grammar is: Exp -> let var = Exp in Exp Exp -> Exp + Exp Exp -> Exp - Exp Exp -> Exp * Exp Exp -> Exp / Exp Exp -> ( Exp ) This grammar is ambiguous, but the conflicts that will appear in the parser table can be resolved with precedence and associativity declarations for the operators that surround expressions: %right in %left + - %left * / giving right associativity to the in token, and left associativity to the arithmetic operators, and giving lower precedence to in, followed by + and -, and then by * and /. I see that if the token in is not given a precedence declaration, the grammar still is ambiguous, as can be seen in the example of parsing the expression: let v = e1 in e2 + e3 which could be parsed as (let v = e1 in e2) + e3 or let v = e1 in (e2 + e3) Giving the token in a lower precedence makes the parser choose the last option. My question is about the associativity of the token in? Does it make any difference giving it left associativity, right associativity, or making it non associative? Regards. Jos? Romildo -------------- next part -------------- -- calc3.y -*- mode: haskell -*- { module Main where import Data.Char (isSpace, isDigit, isAlpha, isAlphaNum) import Data.Maybe (fromMaybe) } %name calc %tokentype { Token } %error { parseError } %token let { TokenLet } in { TokenIn } int { TokenInt $$ } var { TokenVar $$ } '=' { TokenEq } '+' { TokenPlus } '-' { TokenMinus } '*' { TokenTimes } '/' { TokenDiv } '(' { TokenLP } ')' { TokenRP } %nonassoc in %left '+' '-' %left '*' '/' %left NEG %% Exp : let var '=' Exp in Exp { \env -> $6 (($2,$4 env) : env) } | Exp '+' Exp { \env -> $1 env + $3 env } | Exp '-' Exp { \env -> $1 env - $3 env } | Exp '*' Exp { \env -> $1 env * $3 env } | Exp '/' Exp { \env -> $1 env `div` $3 env } | '(' Exp ')' { $2 } | '-' Exp %prec NEG { \env -> - ($2 env) } | int { \env -> $1 } | var { \env -> fromMaybe 0 (lookup $1 env) } { parseError :: [Token] -> a parseError _ = error "Parse error" data Token = TokenLet | TokenIn | TokenInt Int | TokenVar String | TokenEq | TokenPlus | TokenMinus | TokenTimes | TokenDiv | TokenLP | TokenRP deriving (Show) lexer :: String -> [Token] lexer [] = [] lexer (c:cs) | isSpace c = lexer cs | isAlpha c = let (name,rest) = span isAlphaNum cs tok = case c:name of "let" -> TokenLet "in" -> TokenIn var -> TokenVar var in tok : lexer rest | isDigit c = let (num,rest) = span isDigit cs in TokenInt (read (c:num)) : lexer rest lexer ('=':cs) = TokenEq : lexer cs lexer ('+':cs) = TokenPlus : lexer cs lexer ('-':cs) = TokenMinus : lexer cs lexer ('*':cs) = TokenTimes : lexer cs lexer ('/':cs) = TokenDiv : lexer cs lexer ('(':cs) = TokenLP : lexer cs lexer (')':cs) = TokenRP : lexer cs main = do input <- getContents mapM_ print (map (($ []) . calc . lexer) (lines input)) } From dons at galois.com Thu May 7 13:47:06 2009 From: dons at galois.com (Don Stewart) Date: Thu May 7 13:33:46 2009 Subject: [Haskell-cafe] Trying to contact authors of "Real World Haskell"? In-Reply-To: References: Message-ID: <20090507174706.GA30635@whirlpool.galois.com> We're all on haskell-cafe@ :) itsme213: > I could not find any contact info for Brian O'Sullivan, Don Stewart, or John > Goerzen on their book site. Any pointers to how I might locate any of them > much appreciated. > > Thanks! > > Sophie > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From es at ertes.de Thu May 7 13:54:56 2009 From: es at ertes.de (Ertugrul Soeylemez) Date: Thu May 7 13:40:26 2009 Subject: [Haskell-cafe] Re: Getting WriterT log lazily References: <49FE09D7.5090108@therning.org> <49FE9DC0.9060201@van.steenbergen.nl> <49FEB1CC.5030501@therning.org> <50b5ae760905060928o454231b2ya0dccdb46afe9445@mail.gmail.com> <20090507183720.73c65395@tritium.xx> Message-ID: <20090507195456.5732c4cf@tritium.xx> Ertugrul Soeylemez wrote: > There are two issues with unsafePerformIO: [...] Of course I meant unsafeInterleaveIO, sorry. There are a lot more than two issues with unsafePerformIO. =) Greets, Ertugrul. -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/ From vogt.adam at gmail.com Thu May 7 13:59:51 2009 From: vogt.adam at gmail.com (adam vogt) Date: Thu May 7 13:45:10 2009 Subject: [Haskell-cafe] beginner question: assigning local variable to a function In-Reply-To: <4A01D77D.9060801@therning.org> References: <45fccde20905060918h3cacd28cx8bae9887848dee96@mail.gmail.com> <46BE51D6-A08B-422A-9D6B-C81E0D6EC989@ece.cmu.edu> <4A01D77D.9060801@therning.org> Message-ID: This is most likely attributable to the use of different compilers. I don't see how accepting such a variant can cause ambiguity, but I'm not quite sure whether it is legal H98. On 5/6/09, Magnus Therning wrote: > Brandon S. Allbery KF8NH wrote: > > On May 6, 2009, at 12:18 , Nico Rolle wrote: > > > > > why does this don't work? > > > > > > test = let a = (>) > > > in 1 `a` 2 > > > > > > > > > Works fine here once I correct your indentation (the "in" needs to be > indented at least as far as the "l" in "let"). > > > > Really? For me it's enough to have "in" indented more then "test", and one > space is enough: > > test = let a = (>) > in 1 `a` 2 > > /M > > -- > Magnus Therning (OpenPGP: 0xAB4DFBA4) > magnus?therning?org Jabber: magnus?therning?org > http://therning.org/magnus identi.ca|twitter: magthe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > From magnus at therning.org Thu May 7 14:03:17 2009 From: magnus at therning.org (Magnus Therning) Date: Thu May 7 13:48:55 2009 Subject: [Haskell-cafe] beginner question: assigning local variable to a function In-Reply-To: References: <45fccde20905060918h3cacd28cx8bae9887848dee96@mail.gmail.com> <46BE51D6-A08B-422A-9D6B-C81E0D6EC989@ece.cmu.edu> <4A01D77D.9060801@therning.org> Message-ID: <4A032265.5070000@therning.org> adam vogt wrote: > This is most likely attributable to the use of different compilers. > > I don't see how accepting such a variant can cause ambiguity, but I'm > not quite sure whether it is legal H98. Just a bit curious then what compiler Brandon was using. I'm using GHC 6.10.2 on AMD64 Linux (Arch). /M > On 5/6/09, Magnus Therning wrote: >> Brandon S. Allbery KF8NH wrote: >>> On May 6, 2009, at 12:18 , Nico Rolle wrote: >>> >>>> why does this don't work? >>>> >>>> test = let a = (>) >>>> in 1 `a` 2 >>>> >>> >>> Works fine here once I correct your indentation (the "in" needs to be >> indented at least as far as the "l" in "let"). >> Really? For me it's enough to have "in" indented more then "test", and one >> space is enough: >> >> test = let a = (>) >> in 1 `a` 2 >> >> /M >> >> -- >> Magnus Therning (OpenPGP: 0xAB4DFBA4) >> magnus?therning?org Jabber: magnus?therning?org >> http://therning.org/magnus identi.ca|twitter: magthe >> >> >> _______________________________________________ >> 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 -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090507/49015ed7/signature.bin From gue.schmidt at web.de Thu May 7 15:12:04 2009 From: gue.schmidt at web.de (=?UTF-8?B?R8O8wp9udGhlciBTY2htaWR0?=) Date: Thu May 7 14:57:39 2009 Subject: [Haskell-cafe] GLFW - Mac OS X Message-ID: Hi, has anybody recently install the GLFW package on Mac OS X? It won't install on my machine. G?nther From duane.johnson at gmail.com Thu May 7 15:48:05 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Thu May 7 15:33:29 2009 Subject: [Haskell-cafe] GLFW - Mac OS X In-Reply-To: References: Message-ID: <40E1776D-D536-4CD2-B09B-BB8DB7114C54@gmail.com> Yes, it seemed to work fine for me (this was about 2 months ago, however). I'm running Leopard (10.5.6). -- Duane On May 7, 2009, at 1:12 PM, G??nther Schmidt wrote: > Hi, > > has anybody recently install the GLFW package on Mac OS X? > > It won't install on my machine. > > G?nther > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From bos at serpentine.com Thu May 7 15:53:56 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Thu May 7 15:39:14 2009 Subject: [Haskell-cafe] How difficult would creating a collaborative multi-user online virtual world application be in Haskell? In-Reply-To: References: Message-ID: On Thu, May 7, 2009 at 3:28 AM, Benjamin L.Russell wrote: > One question that has been coming up at the back of my mind for the > past several weeks has been how difficult would it be to create a > collaborative multi-user online virtual world application in Haskell. > It should be easier than in many other languages, but that's not saying much: for any big, sprawling application, its own intrinsic complexity will make building it difficult. You can of course have an effect on extrinsic difficulties through, among other things, a careful choice of implementation language. An ill defined problem is going to face many more non-obvious decisions than one that is tightly scoped. On such a project, the chances that you'll make decisions (probably many of them) that turn out to be both pivotal in their importance and detrimental in their effect are high. Haskell provides a certain amount of defence against some such decisions through its emphasis on purity, but again it's the fuzzy nature of the problem space that's likely to cause you the most headaches, not aspects that a language will help much with. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090507/c85a8419/attachment.htm From jgoerzen at complete.org Thu May 7 16:00:09 2009 From: jgoerzen at complete.org (John Goerzen) Date: Thu May 7 15:45:29 2009 Subject: [Haskell-cafe] Trying to contact authors of "Real World Haskell"? In-Reply-To: References: Message-ID: <20090507200009.GA19567@hustlerturf.com> On Thu, May 07, 2009 at 12:18:47PM -0500, Itsme (Sophie) wrote: > I could not find any contact info for Brian O'Sullivan, Don Stewart, or John > Goerzen on their book site. Any pointers to how I might locate any of them > much appreciated. This post seems to have worked out reasonably well for you :-) -- John From andrewcoppin at btinternet.com Thu May 7 16:01:11 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu May 7 15:46:30 2009 Subject: [Haskell-cafe] GC [Is Haskell a Good Choice for Web Applications?] In-Reply-To: <4A02B215.4060902@gmail.com> References: <87fxfll3ad.fsf@forno.us> <204746127.20090507001813@gmail.com> <4A02B215.4060902@gmail.com> Message-ID: <4A033E07.1080102@btinternet.com> Simon Marlow wrote: > http://hackage.haskell.org/trac/ghc/ticket/698 I presume that the reason for this is to avoid handing memory back only to immediately need it again? (I.e., we don't want to be constantly asking the OS to allocate and deallocate memory. Allocate it once and then let the RTS handle it.) How hard would it be to add a function to ask the RTS to shrink the allocated memory? E.g., you do something that you know consumes lots of RAM, you finish doing it, you know that your live set has probably gone way down now, so you ask the RTS to release some RAM if possible. Would that be difficult? (I might be talking moonshine, but isn't the parallel GC based around a block-structured heap? Does that affect the difficulty of the problem one way or the other?) We already have System.Mem, which currently contains a single function to "suggest" to the RTS that right now might be a good moment to perform some GC. I'd like to see some other functions added here - suggesting to the RTS that it should have a go at shrinking RAM usage is one, but it would be nice to at least be able to query how much RAM is allocated too. (I presume finding out how much we've allocated from the OS is fairly easy; finding out how much is live data is presumably far harder...) Maybe access to various interesting GC information - I don't know if the RTS actually records this stuff when not built for profiling though. (?) Just my thoughts... :-) From itsme213 at hotmail.com Thu May 7 16:11:45 2009 From: itsme213 at hotmail.com (Itsme (Sophie)) Date: Thu May 7 15:57:13 2009 Subject: [Haskell-cafe] Trying to contact authors of "Real WorldHaskell"? References: <20090507200009.GA19567@hustlerturf.com> Message-ID: It's been quite a response, yes :-) I was half expecting to be received like a spam-bot. Thanks, all. - Sophie ----- Original Message ----- From: "John Goerzen" To: "Itsme (Sophie)" Cc: Sent: Thursday, May 07, 2009 3:00 PM Subject: Re: [Haskell-cafe] Trying to contact authors of "Real WorldHaskell"? > On Thu, May 07, 2009 at 12:18:47PM -0500, Itsme (Sophie) wrote: >> I could not find any contact info for Brian O'Sullivan, Don Stewart, or >> John >> Goerzen on their book site. Any pointers to how I might locate any of >> them >> much appreciated. > > This post seems to have worked out reasonably well for you :-) > > -- John > From jgoerzen at complete.org Thu May 7 16:21:09 2009 From: jgoerzen at complete.org (John Goerzen) Date: Thu May 7 16:06:29 2009 Subject: [Haskell-cafe] Trying to contact authors of "Real WorldHaskell"? In-Reply-To: References: <20090507200009.GA19567@hustlerturf.com> Message-ID: <4A0342B5.8070409@complete.org> Itsme (Sophie) wrote: > It's been quite a response, yes :-) > > I was half expecting to be received like a spam-bot. Ahh, well if your late deceased father had left behind $13 BILLION ($13,000,000,000) USD in Nigeria, or if you were selling che$p blu3 pi11s, then you would have been received that way :-) From mad.one at gmail.com Thu May 7 16:21:50 2009 From: mad.one at gmail.com (Austin Seipp) Date: Thu May 7 16:07:09 2009 Subject: [Haskell-cafe] GLFW - Mac OS X In-Reply-To: References: Message-ID: <1241727458-sup-5232@existential.local> Excerpts from G??nther Schmidt's message of Thu May 07 14:12:04 -0500 2009: > Hi, > > has anybody recently install the GLFW package on Mac OS X? > > It won't install on my machine. > > G?nther > I ran into this problem - with GHC 6.10.2 or above if you try to install GLFW with cabal install you get a host of errors that are SSE-based and for that matter make absolutely no sense at all, but they do appear. The solution (unfortunately) is manually to alter the GLFW.cabal file to pass the '-msse2' option to gcc *while under OS X*. That is, the cabal file should look something like: if os(darwin) include-dirs: glfw/include glfw/lib glfw/lib/macosx c-sources: .... --> cc-options: -msse2 frameworks: AGL Carbon OpenGL So just add that line marked with '-->'. This will make sure GCC does not die while building. I'm honestly not sure why this change has occurred, but it's pretty annoying, and I guess I should probably send a patch to Paul. H. Liu... Austin From daniel.is.fischer at web.de Thu May 7 16:21:41 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu May 7 16:07:31 2009 Subject: [Haskell-cafe] GC [Is Haskell a Good Choice for Web Applications?] In-Reply-To: <4A033E07.1080102@btinternet.com> References: <87fxfll3ad.fsf@forno.us> <4A02B215.4060902@gmail.com> <4A033E07.1080102@btinternet.com> Message-ID: <200905072221.41786.daniel.is.fischer@web.de> Am Donnerstag 07 Mai 2009 22:01:11 schrieb Andrew Coppin: > Simon Marlow wrote: > > http://hackage.haskell.org/trac/ghc/ticket/698 > > I presume that the reason for this is to avoid handing memory back only > to immediately need it again? (I.e., we don't want to be constantly > asking the OS to allocate and deallocate memory. Allocate it once and > then let the RTS handle it.) > > How hard would it be to add a function to ask the RTS to shrink the > allocated memory? E.g., you do something that you know consumes lots of > RAM, you finish doing it, you know that your live set has probably gone > way down now, so you ask the RTS to release some RAM if possible. Would > that be difficult? Another idea, I have no idea how hard or sensible it is: What if the GC detects how much memory is currently used (it does already do that, doesn't it?) and how much is allocated from the OS, and if less than a third or a quarter of the allocated memory is used, return the memory that exceeds twice the used memory to the OS? Behaviour might be configurable by an RTS flag. From allbery at ece.cmu.edu Thu May 7 16:44:30 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu May 7 16:30:32 2009 Subject: [Haskell-cafe] beginner question: assigning local variable to a function In-Reply-To: <4A032265.5070000@therning.org> References: <45fccde20905060918h3cacd28cx8bae9887848dee96@mail.gmail.com> <46BE51D6-A08B-422A-9D6B-C81E0D6EC989@ece.cmu.edu> <4A01D77D.9060801@therning.org> <4A032265.5070000@therning.org> Message-ID: <6743F87E-EC42-43DA-A6DE-EC73B7EA5FC9@ece.cmu.edu> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On May 7, 2009, at 14:03 , Magnus Therning wrote: > adam vogt wrote: >> This is most likely attributable to the use of different compilers. >> I don't see how accepting such a variant can cause ambiguity, but I'm >> not quite sure whether it is legal H98. > > Just a bit curious then what compiler Brandon was using. I'm using > GHC 6.10.2 on AMD64 Linux (Arch). Actually it's probably because, rather than track separate rules depending on whether I'm embedded in other layout (read: "do"), I just remember to use the stricter rules everywhere. (This affects both "let" and "if".) - -- 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) iEYEARECAAYFAkoDSFUACgkQIn7hlCsL25VV+QCglo4Q1fCHl4coiRuT4tn0GXtb qqAAoI5BsygYL39i6UuWTYS+tRtXK8bQ =zn3F -----END PGP SIGNATURE----- From duane.johnson at gmail.com Thu May 7 17:01:47 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Thu May 7 16:47:19 2009 Subject: [Haskell-cafe] Visualizing Typed Functions Message-ID: I'm not sure what the policy is on posting with graphical attachments, but I'll give this a tentative try. In case this does not come through with images, I've also posted this on my blog at http://blog.inquirylabs.com/2009/05/07/visualizing-typed-functions/ ===== As I've worked in Haskell over the past several months, I've noticed that my mind has kind of implicitly modeled functional programming as a visual/mechanical representation of concepts. I'd like to make the ideas more explicit, however, so I'm writing this post and cooking up some graphics. I wonder if others have similar "internal representations" of functions, and if perhaps others might suggest improvements over my model. The basic idea is that a function is a semi-circle with inputs on one side (left) and the output at the right. Colors represent types. Here is a function that takes one input and produces one output (of the same type): Haskell would type this as "a -> a". Next, we have a function that takes one type and returns a different type... e.g. a hashing function might take a string and return an integer: (Please ignore the vertical stripe, it's an artifact of my poor Inkscape skills). We can also create functions with more than one input, of course, so here is a binary function. It might be the '+' operator, or some other binary operator, e.g. "a -> a -> a": Haskell and many other languages also have the concept of higher-order functions, i.e. functions that take functions as inputs. Here is a binary function that takes a binary function as input, along with another input, to produce an output of the same type: I imagine polymorphic types as "banded colors" so that the bands contain another type (color). Lists are polymorphic types. Here is what the "head" function might look like ("head" returns the first element in a list): Finally, here is a composite of all of the above visualizations. The "map" function in Haskell is a function that takes a function and a list, and applies that function to each element in the list, returning a new list with the "mapped" elements: The type signature for the "map" function is "(a -> b) -> [a] -> [b]". I wonder what a Monad would look like... With these functions visualized, one could make a kind of "drag and drop" interface for Haskell programming, although that isn't really my intention. I admit this is a little convoluted even for the purpose of visualization, but at least it's a starting place. Does anyone know of another system or better representation? -------------- next part -------------- Skipped content of type multipart/related From vanenkj at gmail.com Thu May 7 17:06:31 2009 From: vanenkj at gmail.com (John Van Enk) Date: Thu May 7 16:51:53 2009 Subject: [Haskell-cafe] Visualizing Typed Functions In-Reply-To: References: Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/png Size: 16791 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090507/30f3b8b0/attachment.png -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/png Size: 5199 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090507/30f3b8b0/attachment-0001.png -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/png Size: 9083 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090507/30f3b8b0/attachment-0002.png -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/png Size: 10348 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090507/30f3b8b0/attachment-0003.png -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/png Size: 9121 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090507/30f3b8b0/attachment-0004.png -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/png Size: 8608 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090507/30f3b8b0/attachment-0005.png From kyagrd at gmail.com Thu May 7 17:11:02 2009 From: kyagrd at gmail.com (Ahn, Ki Yung) Date: Thu May 7 16:56:12 2009 Subject: [Haskell-cafe] Re: Visualizing Typed Functions In-Reply-To: References: Message-ID: Duane Johnson wrote: > > With these functions visualized, one could make a kind of "drag and > drop" interface for Haskell programming, although that isn't really my > intention. I admit this is a little convoluted even for the purpose of > visualization, but at least it's a starting place. Does anyone know of > another system or better representation? > You must to take a look at this: Tangible Functional Programming http://www.youtube.com/watch?v=faJ8N0giqzw And, a little bit off topic but cool stuff: Vacuum: visualize Haskell data structures live http://www.youtube.com/watch?v=X4-212uMgy8 @ It seems that we are getting pretty close to the point that youtube is getting to be a better reference than a paper, at least for practitioners. A lot of talks are on youtube :) From dpiponi at gmail.com Thu May 7 17:11:42 2009 From: dpiponi at gmail.com (Dan Piponi) Date: Thu May 7 16:57:02 2009 Subject: [Haskell-cafe] Visualizing Typed Functions In-Reply-To: References: Message-ID: <625b74080905071411p7ee12f51tbc22815f70ba50fa@mail.gmail.com> Duane, Your fourth diagram is hard to distinguish from that for a function that takes three inputs and returns one. And what would be the diagram for a function that maps one binary function to another? I spend a bit of my time at work playing with typed visual dataflow type tools. I've never really seen a satisfactory visual scheme for clearly representing higher order functions and I've never managed to come up with one myself. -- Dan On Thu, May 7, 2009 at 2:01 PM, Duane Johnson wrote: > I'm not sure what the policy is on posting with graphical attachments, but > I'll give this a tentative try. In case this does not come through with > images, I've also posted this on my blog at > http://blog.inquirylabs.com/2009/05/07/visualizing-typed-functions/ From duane.johnson at gmail.com Thu May 7 17:12:40 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Thu May 7 16:58:09 2009 Subject: [Haskell-cafe] Visualizing Typed Functions In-Reply-To: References: Message-ID: <741196E5-41CB-4520-8D2C-45C8506B7424@gmail.com> No, this is a first-time draft that I made by hand using Inkscape. If we get to a point where a consistent set of visualizations makes sense, it would be rewarding to turn into code though. -- Duane On May 7, 2009, at 3:06 PM, John Van Enk wrote: > Do you have code to generate these images from type signatures? If > so I'd *love* to see it. From kyagrd at gmail.com Thu May 7 17:40:49 2009 From: kyagrd at gmail.com (Ahn, Ki Yung) Date: Thu May 7 17:26:00 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: The Haskell Platform In-Reply-To: <20090506055231.GC22875@whirlpool.galois.com> References: <20090506055231.GC22875@whirlpool.galois.com> Message-ID: Thanks for this great effort! Are we going to have a meta-package on hackage as well? (which makes it able to build it through cabal-install) -- Ahn, Ki Yung From sebf at informatik.uni-kiel.de Thu May 7 18:03:33 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Thu May 7 17:48:52 2009 Subject: [Haskell-cafe] Visualizing Typed Functions In-Reply-To: <625b74080905071411p7ee12f51tbc22815f70ba50fa@mail.gmail.com> References: <625b74080905071411p7ee12f51tbc22815f70ba50fa@mail.gmail.com> Message-ID: > I've never really seen a satisfactory visual scheme for > clearly representing higher order functions I saw a visual scheme for this purpose at FDPE'08. It uses an alternating colouring scheme, representing arguments as holes: a hole in a black thing is white and a hole in a white thing is black. I only found an ACM link: http://portal.acm.org/citation.cfm?id=1411272 Cheers, Sebastian From dons at galois.com Thu May 7 18:05:46 2009 From: dons at galois.com (Don Stewart) Date: Thu May 7 17:52:27 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: The Haskell Platform In-Reply-To: References: <20090506055231.GC22875@whirlpool.galois.com> Message-ID: <20090507220546.GI31370@whirlpool.galois.com> kyagrd: > Thanks for this great effort! > > Are we going to have a meta-package on hackage as well? > (which makes it able to build it through cabal-install) Yes, this ticket tracks that stuff: http://trac.haskell.org/haskell-platform/ticket/15 From duane.johnson at gmail.com Thu May 7 18:29:41 2009 From: duane.johnson at gmail.com (Duane Johnson) Date: Thu May 7 18:15:07 2009 Subject: [Haskell-cafe] Re: Visualizing Typed Functions In-Reply-To: References: Message-ID: Thank you, that was very instructive! Tangible Values look very interesting. -- Duane On May 7, 2009, at 3:11 PM, Ahn, Ki Yung wrote: > Duane Johnson wrote: >> With these functions visualized, one could make a kind of "drag and >> drop" interface for Haskell programming, although that isn't really >> my intention. I admit this is a little convoluted even for the >> purpose of visualization, but at least it's a starting place. Does >> anyone know of another system or better representation? > > You must to take a look at this: > > Tangible Functional Programming > http://www.youtube.com/watch?v=faJ8N0giqzw > > And, a little bit off topic but cool stuff: > > Vacuum: visualize Haskell data structures live > http://www.youtube.com/watch?v=X4-212uMgy8 > > > @ It seems that we are getting pretty close to the point that > youtube is getting to be a better reference than a paper, at least > for practitioners. A lot of talks are on youtube :) > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From claus.reinke at talk21.com Thu May 7 18:44:56 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Thu May 7 18:30:22 2009 Subject: [Haskell-cafe] Re: Visualizing Typed Functions References: Message-ID: <13215142FE574AD78DACE9A714FA54CA@cr3lt> >> With these functions visualized, one could make a kind of "drag and >> drop" interface for Haskell programming, although that isn't really my >> intention. I admit this is a little convoluted even for the purpose of >> visualization, but at least it's a starting place. Does anyone know of >> another system or better representation? Sure, google for visual programming languages - some examples: - there was a "Visual Haskell", before the Visual Studio plugin http://ptolemy.eecs.berkeley.edu/~johnr/papers/ - dissect a mockingbird http://users.bigpond.net.au/d.keenan/Lambda/ - vpl bibliography http://web.engr.oregonstate.edu/~burnett/vpl.html > @ It seems that we are getting pretty close to the point that youtube is > getting to be a better reference than a paper, at least for > practitioners. A lot of talks are on youtube :) You could always post a screencast of yourself reading a paper!-) Claus From dm.maillists at gmail.com Thu May 7 18:53:26 2009 From: dm.maillists at gmail.com (Daniel McAllansmith) Date: Thu May 7 18:38:59 2009 Subject: [Haskell-cafe] Data.Map and strictness (was: Is Haskell aGoodChoice for WebApplications?(ANN: Vocabulink)) In-Reply-To: References: <87fxfll3ad.fsf@forno.us> <16442B752A06A74AB4D9F9A5FF076E4B01ABAAD2@ELON17P32001A.csfb.cs-group.com> Message-ID: <200905081053.26967.dm.maillists@gmail.com> On Fri, 08 May 2009 00:30:34 Claus Reinke wrote: > > seq something like size map that will force a traversal of the entire > > tree, and ensure that the result is actually demanded, .. > > (Not tested) > > and not recommended, either, I'm afraid!-) > > |> Actually, I'm unsure how to fix this. For an expression like this: > |> > |> Data.Map.delete key map > |> > |> how can I use seq (or something else) to sufficiently evaluate the above > |> to ensure that the value associated with key can be garbage collected? [snip] > Anyway;-) You can see that size is actually pre-computed, so there's > no guarantee that asking for it will traverse the internal representation, Presumably seq'ing the Maybe you get from looking up the key will be sufficient to dereference the key, and will avoid unnecessary traversal of unrelated parts of the map. Dan From vigalchin at gmail.com Thu May 7 19:03:22 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Thu May 7 18:48:41 2009 Subject: [Haskell-cafe] Question concerning Haskell Foundation Message-ID: <5ae4f2ba0905071603m7ecfcd3ap3a187c34ad987043@mail.gmail.com> Hello, With Haskell Foundation, 1) Can we still publish packages on Hackage? 2) Is Hackage going away? Regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090507/819fab75/attachment.htm From dons at galois.com Thu May 7 19:07:44 2009 From: dons at galois.com (Don Stewart) Date: Thu May 7 18:54:23 2009 Subject: [Haskell-cafe] Question concerning Haskell Foundation In-Reply-To: <5ae4f2ba0905071603m7ecfcd3ap3a187c34ad987043@mail.gmail.com> References: <5ae4f2ba0905071603m7ecfcd3ap3a187c34ad987043@mail.gmail.com> Message-ID: <20090507230744.GM31370@whirlpool.galois.com> vigalchin: > Hello, > > With Haskell Foundation, > > 1) Can we still publish packages on Hackage? > > 2) Is Hackage going away? ??? -- Don From vigalchin at gmail.com Thu May 7 19:13:36 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Thu May 7 18:58:56 2009 Subject: [Haskell-cafe] Question concerning Haskell Foundation In-Reply-To: <20090507230744.GM31370@whirlpool.galois.com> References: <5ae4f2ba0905071603m7ecfcd3ap3a187c34ad987043@mail.gmail.com> <20090507230744.GM31370@whirlpool.galois.com> Message-ID: <5ae4f2ba0905071613v510e239ek42ecb9314ceaf63f@mail.gmail.com> sorry should read "With Haskell Platform" 1) Can we still publish/push up packages to Hackage? E.g. now I am trying to get Graham Lyle's Swish (semantic web package) cabalized. 2) Will Hackage go away? Vasili On Thu, May 7, 2009 at 6:07 PM, Don Stewart wrote: > vigalchin: > > Hello, > > > > With Haskell Foundation, > > > > 1) Can we still publish packages on Hackage? > > > > 2) Is Hackage going away? > > ??? > > -- Don > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090507/29df9391/attachment.htm From wren at freegeek.org Thu May 7 19:13:36 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu May 7 18:58:59 2009 Subject: [Haskell] Re[2]: [Haskell-cafe] Is Haskell a Good Choice for WebApplications? (ANN: Vocabulink) In-Reply-To: References: <87fxfll3ad.fsf@forno.us> <204746127.20090507001813@gmail.com> Message-ID: <4A036B20.4070301@freegeek.org> John Lask wrote: > Well this is interesting. So what you are saying is that if your haskell > application requires a peek memory utilisation of (for example) 1GB, > after the memory intesive computation has completed and the GC has run > (assuming all references have been dropped) the GHC RTS will retain the > 1GB allocated to the process. Does this occur on both windows and posix > platforms, does anyone know ? If so then this is a real issue. It would > be reasonable to expect that the RTS release resources to the OS when > not explicitly required. FWIW, the JVM also fails to release memory resources back to the OS. Given all the problems I've seen that one cause for long-running processes, I'm definitely in support of correcting any behavior like this in the GHC RTS. If the RTS does suffer from this, does anyone on this list know the cause (before moving his thread over to ghc@) ? -- Live well, ~wren From kyagrd at gmail.com Thu May 7 19:15:11 2009 From: kyagrd at gmail.com (Ahn, Ki Yung) Date: Thu May 7 19:00:24 2009 Subject: [Haskell-cafe] Re: Question concerning Haskell Foundation In-Reply-To: <20090507230744.GM31370@whirlpool.galois.com> References: <5ae4f2ba0905071603m7ecfcd3ap3a187c34ad987043@mail.gmail.com> <20090507230744.GM31370@whirlpool.galois.com> Message-ID: Don Stewart wrote: > vigalchin: >> Hello, >> >> With Haskell Foundation, >> >> 1) Can we still publish packages on Hackage? >> >> 2) Is Hackage going away? > > ??? > > -- Don Don, I think he's referring to your recent announcement about the Haskell platform. And, at that thread you also mentioned that Haskell platform is also going to be provided as a meta-package on Hackage. So, the answers to 1) Yes, 2) No. -- Ahn, Ki Yung From dons at galois.com Thu May 7 19:15:02 2009 From: dons at galois.com (Don Stewart) Date: Thu May 7 19:01:38 2009 Subject: [Haskell-cafe] Question concerning Haskell Foundation In-Reply-To: <5ae4f2ba0905071613v510e239ek42ecb9314ceaf63f@mail.gmail.com> References: <5ae4f2ba0905071603m7ecfcd3ap3a187c34ad987043@mail.gmail.com> <20090507230744.GM31370@whirlpool.galois.com> <5ae4f2ba0905071613v510e239ek42ecb9314ceaf63f@mail.gmail.com> Message-ID: <20090507231502.GQ31370@whirlpool.galois.com> No, it has no effect on the operation of Hackage. Please continue to release things. vigalchin: > sorry should read "With Haskell Platform" > > 1) Can we still publish/push up packages to Hackage? E.g. now I am trying > to get Graham Lyle's Swish (semantic web package) cabalized. > > 2) Will Hackage go away? > > Vasili > > > On Thu, May 7, 2009 at 6:07 PM, Don Stewart wrote: > > vigalchin: > > Hello, > > > > With Haskell Foundation, > > > > 1) Can we still publish packages on Hackage? > > > > 2) Is Hackage going away? > > ??? > > -- Don > > From wren at freegeek.org Thu May 7 19:33:11 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu May 7 19:18:29 2009 Subject: [Haskell-cafe] GC In-Reply-To: <200905072221.41786.daniel.is.fischer@web.de> References: <87fxfll3ad.fsf@forno.us> <4A02B215.4060902@gmail.com> <4A033E07.1080102@btinternet.com> <200905072221.41786.daniel.is.fischer@web.de> Message-ID: <4A036FB7.4070307@freegeek.org> Daniel Fischer wrote: > Am Donnerstag 07 Mai 2009 22:01:11 schrieb Andrew Coppin: > > Simon Marlow wrote: > > > http://hackage.haskell.org/trac/ghc/ticket/698 > > I presume that the reason for this is to avoid handing memory back only > > to immediately need it again? (I.e., we don't want to be constantly > > asking the OS to allocate and deallocate memory. Allocate it once and > > then let the RTS handle it.) > > > > How hard would it be to add a function to ask the RTS to shrink the > > allocated memory? E.g., you do something that you know consumes lots of > > RAM, you finish doing it, you know that your live set has probably gone > > way down now, so you ask the RTS to release some RAM if possible. Would > > that be difficult? > > Another idea, I have no idea how hard or sensible it is: > What if the GC detects how much memory is currently used (it does already do that, doesn't > it?) and how much is allocated from the OS, and if less than a third or a quarter of the > allocated memory is used, return the memory that exceeds twice the used memory to the OS? > Behaviour might be configurable by an RTS flag. +1 (assuming the GC does detect current usage). I think this behavior (with flags to tune the multiples, or to disable it) is nicely high-level and easy for users to reason about. For users with intimate knowledge of the GC and their program's behavior it could be helpful to have the alternative proposal of an impure function to give hints to the RTS, but in general this seems like far too low-level of an approach to solve the general problem. -- Live well, ~wren From wren at freegeek.org Thu May 7 19:41:32 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu May 7 19:26:51 2009 Subject: [Haskell-cafe] How difficult would creating a collaborative multi-user online virtual world application be in Haskell? In-Reply-To: References: Message-ID: <4A0371AC.5080501@freegeek.org> Benjamin L.Russell wrote: > Unfortunately, Smalltalk is an object-oriented language. If possible, > I would like to see something similar in a functional programming > language such as Haskell. > > Does anybody know whether duplicating this project in Haskell would be > feasible? In terms of technical feasibility, Smalltalk does have some advantages in the metacircularity of the VM/compiler/program, which seem like they're being taken advantage of for this application. Following along this direction, Luke Palmer is working on a language, Dana[1], which aims to be Haskell-like and also to have a Smalltalk-like metacircular VM. Depending on what exactly you want to duplicate, something like the Dana project may be a good thing to follow. [1] http://lukepalmer.wordpress.com/category/code/dana/ -- Live well, ~wren From dmehrtash at gmail.com Thu May 7 19:45:05 2009 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Thu May 7 19:30:24 2009 Subject: [Haskell-cafe] Curry and Reader monad Message-ID: In the Is currying monadic?post the author says: This is again a nested expression. So I wondered if you could again > "flatten" it with a monadic do block: > > let add3 = do > a <- get first parameter > b <- get second parameter > c <- get third parameter > > > return a+b+c > > OK, so I "know" that functions in Haskell (which uses currying for > functions as a general rule) are the "Reader monad". But I don't understand > it well enough to know if that means you can use Reader to implement the > above... > > (I don't understand Reader at all in fact. I must bang my head against it > again, but I find it very confusing - how the monad is represented, what the > functions are, and how they get magically applied.) > Any idea what he is talking about? Thanks Daryoush -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090507/6d4f9c7f/attachment.htm From jblake at omgwallhack.org Thu May 7 20:02:15 2009 From: jblake at omgwallhack.org (Julian Blake Kongslie) Date: Thu May 7 19:47:44 2009 Subject: [Haskell-cafe] Curry and Reader monad In-Reply-To: References: Message-ID: <1241740935.3371.4.camel@lizhou.omgwallhack.org> On Thu, 2009-05-07 at 16:45 -0700, Daryoush Mehrtash wrote: > In the Is currying monadic? post the author says: > > This is again a nested expression. So I wondered if you could > again "flatten" it with a monadic do block: > let add3 = do > a <- get first parameter > b <- get second parameter > c <- get third parameter > > return a+b+c > OK, so I "know" that functions in Haskell (which uses currying > for functions as a general rule) are the "Reader monad". But I > don't understand it well enough to know if that means you can > use Reader to implement the above... > > (I don't understand Reader at all in fact. I must bang my head > against it again, but I find it very confusing - how the monad > is represented, what the functions are, and how they get > magically applied.) > > > > > Any idea what he is talking about? A function of a single argument can be represented as a Reader monad, but Reader doesn't really do the currying action. It provides "ask" which is essentially "get first parameter". For multiple parameters, you'd be nesting Readers. If he's asking for a "get next parameter" operation, then you need to track the concept of "next", which implies some sort of state or indexing. An indexed monad in particular is highly appropriate for the "currying monad", as what he's asking for is essentially a session type. > Thanks > > Daryoush -- -Julian Blake Kongslie If this is a mailing list, please CC me on replies. vim: set ft=text : -------------- 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/20090507/1e3ef3cc/attachment.bin From jvlask at hotmail.com Thu May 7 21:53:27 2009 From: jvlask at hotmail.com (John Lask) Date: Thu May 7 21:40:54 2009 Subject: [Haskell-cafe] GC [Is Haskell a Good Choice for Web Applications?] References: <87fxfll3ad.fsf@forno.us> <204746127.20090507001813@gmail.com><4A02B215.4060902@gmail.com> <4A033E07.1080102@btinternet.com> Message-ID: for what its worth, I second this suggestion. ----- Original Message ----- From: "Andrew Coppin" To: Sent: Friday, May 08, 2009 6:01 AM Subject: [Haskell-cafe] GC [Is Haskell a Good Choice for Web Applications?] > Simon Marlow wrote: >> http://hackage.haskell.org/trac/ghc/ticket/698 > > I presume that the reason for this is to avoid handing memory back only > to immediately need it again? (I.e., we don't want to be constantly > asking the OS to allocate and deallocate memory. Allocate it once and > then let the RTS handle it.) > > How hard would it be to add a function to ask the RTS to shrink the > allocated memory? E.g., you do something that you know consumes lots of > RAM, you finish doing it, you know that your live set has probably gone > way down now, so you ask the RTS to release some RAM if possible. Would > that be difficult? > > (I might be talking moonshine, but isn't the parallel GC based around a > block-structured heap? Does that affect the difficulty of the problem > one way or the other?) > > We already have System.Mem, which currently contains a single function > to "suggest" to the RTS that right now might be a good moment to perform > some GC. I'd like to see some other functions added here - suggesting to > the RTS that it should have a go at shrinking RAM usage is one, but it > would be nice to at least be able to query how much RAM is allocated > too. (I presume finding out how much we've allocated from the OS is > fairly easy; finding out how much is live data is presumably far > harder...) Maybe access to various interesting GC information - I don't > know if the RTS actually records this stuff when not built for profiling > though. (?) > > Just my thoughts... :-) > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jvlask at hotmail.com Thu May 7 22:01:36 2009 From: jvlask at hotmail.com (John Lask) Date: Thu May 7 21:48:58 2009 Subject: [Haskell-cafe] GC References: <87fxfll3ad.fsf@forno.us><4A02B215.4060902@gmail.com> <4A033E07.1080102@btinternet.com><200905072221.41786.daniel.is.fischer@web.de> <4A036FB7.4070307@freegeek.org> Message-ID: on the other hand a function to release pool memory to the OS down to the current active level should (I hope) be easily implementable, and quickly incorporated into application where required, whereas arriving at one or more automatic deallocation policies would most likely require some analysis/trial and error. ----- Original Message ----- From: "wren ng thornton" To: Sent: Friday, May 08, 2009 9:33 AM Subject: Re: [Haskell-cafe] GC > Daniel Fischer wrote: >> Am Donnerstag 07 Mai 2009 22:01:11 schrieb Andrew Coppin: >> > Simon Marlow wrote: >> > > http://hackage.haskell.org/trac/ghc/ticket/698 >> > I presume that the reason for this is to avoid handing memory back only >> > to immediately need it again? (I.e., we don't want to be constantly >> > asking the OS to allocate and deallocate memory. Allocate it once and >> > then let the RTS handle it.) >> > >> > How hard would it be to add a function to ask the RTS to shrink the >> > allocated memory? E.g., you do something that you know consumes lots of >> > RAM, you finish doing it, you know that your live set has probably gone >> > way down now, so you ask the RTS to release some RAM if possible. Would >> > that be difficult? >> >> Another idea, I have no idea how hard or sensible it is: >> What if the GC detects how much memory is currently used (it does already >> do that, doesn't it?) and how much is allocated from the OS, and if less >> than a third or a quarter of the allocated memory is used, return the >> memory that exceeds twice the used memory to the OS? >> Behaviour might be configurable by an RTS flag. > > +1 (assuming the GC does detect current usage). > > I think this behavior (with flags to tune the multiples, or to disable it) > is nicely high-level and easy for users to reason about. > > For users with intimate knowledge of the GC and their program's behavior > it could be helpful to have the alternative proposal of an impure function > to give hints to the RTS, but in general this seems like far too low-level > of an approach to solve the general problem. > > -- > Live well, > ~wren > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From patil.nikhil at gmail.com Fri May 8 00:49:19 2009 From: patil.nikhil at gmail.com (Nikhil Patil) Date: Fri May 8 00:34:40 2009 Subject: [Haskell-cafe] is value evaluated? Message-ID: <20090508044919.GA13362@ece.utexas.edu> Hi, I am curious to know if there is a function in Haskell to find if a certain value has already been evaluated. The function I need would have the type: > (?!) :: a -> Bool And I expect it to be such that the following terminates after printing the first 101 fibonacci numbers. > fibs = 0 : 1 : zipWith (+) fibs (tail fibs) > > main = do print $ fibs !! 100 > print $ takeWhile (?!) fibs Although I guess I can imagine the following not terminating: > print $ filter (?!) fibs I would find such a function immensely useful in "printing out" my infinite lists. Thanks! nikhil From jfredett at gmail.com Fri May 8 01:33:05 2009 From: jfredett at gmail.com (Joe Fredette) Date: Fri May 8 01:18:23 2009 Subject: [Haskell-cafe] is value evaluated? In-Reply-To: <20090508044919.GA13362@ece.utexas.edu> References: <20090508044919.GA13362@ece.utexas.edu> Message-ID: <4A03C411.1090703@gmail.com> That strikes me as being bad in a "I'm violating the Halting Problem" sort of way- but I'm not sure how. Is there some contradictory construction that could be built from such a function? Nikhil Patil wrote: > Hi, > > I am curious to know if there is a function in Haskell to find if a certain > value has already been evaluated. The function I need would have the type: > > >> (?!) :: a -> Bool >> > > And I expect it to be such that the following terminates after printing the > first 101 fibonacci numbers. > > >> fibs = 0 : 1 : zipWith (+) fibs (tail fibs) >> >> main = do print $ fibs !! 100 >> print $ takeWhile (?!) fibs >> > > Although I guess I can imagine the following not terminating: > > >> print $ filter (?!) fibs >> > > I would find such a function immensely useful in "printing out" my infinite lists. > > Thanks! > > nikhil > _______________________________________________ > 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/20090508/30a96a9a/jfredett.vcf From jochem at functor.nl Fri May 8 02:45:01 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Fri May 8 02:30:22 2009 Subject: [Haskell-cafe] is value evaluated? In-Reply-To: <20090508044919.GA13362@ece.utexas.edu> References: <20090508044919.GA13362@ece.utexas.edu> Message-ID: <4A03D4ED.80603@functor.nl> Nikhil Patil wrote: > Hi, > > I am curious to know if there is a function in Haskell to find if a certain > value has already been evaluated. The function I need would have the type: > >> (?!) :: a -> Bool I will call this function `evaluated', since it is not a binary operator. The existence of such a function would violate referential transparency. What would the value of ( evaluated (fibs !! 100), evaluated (fibs !! 100) ) be ? Suppose that I first print the `fst' of this tuple, then print the 101st Fibonacci nummber, and then print the `snd' of this tuple. By lazy evaluation, one would expect that this yields False True but this violates referential transparency. Cheers, -- Jochem Berndsen | jochem@functor.nl GPG: 0xE6FABFAB From ketil at malde.org Fri May 8 02:49:23 2009 From: ketil at malde.org (Ketil Malde) Date: Fri May 8 02:33:01 2009 Subject: [Haskell] Re[2]: [Haskell-cafe] Is Haskell a Good Choice for WebApplications? (ANN: Vocabulink) In-Reply-To: <4A036B20.4070301@freegeek.org> (wren ng thornton's message of "Thu\, 07 May 2009 19\:13\:36 -0400") References: <87fxfll3ad.fsf@forno.us> <204746127.20090507001813@gmail.com> <4A036B20.4070301@freegeek.org> Message-ID: <871vr0w0lo.fsf@malde.org> wren ng thornton writes: > FWIW, the JVM also fails to release memory resources back to the > OS. Given all the problems I've seen that one cause for long-running > processes, I'm definitely in support of correcting any behavior like > this in the GHC RTS. I'm curious what real problems arise from this? As far as I can tell, virtual memory and overcommit ought to make this (i.e. not releasing memory back to the OS) mostly harmless. Is this on particular systems with different properties than your average run-of-the-mill Unix? -k -- If I haven't seen further, it is by standing in the footprints of giants From ketil at malde.org Fri May 8 03:06:59 2009 From: ketil at malde.org (Ketil Malde) Date: Fri May 8 02:50:36 2009 Subject: [Haskell-cafe] is value evaluated? In-Reply-To: <20090508044919.GA13362@ece.utexas.edu> (Nikhil Patil's message of "Thu\, 7 May 2009 23\:49\:19 -0500") References: <20090508044919.GA13362@ece.utexas.edu> Message-ID: <87tz3wul7w.fsf@malde.org> Nikhil Patil writes: > I am curious to know if there is a function in Haskell to find if a certain > value has already been evaluated. The function I need would have the type: > >> (?!) :: a -> Bool Well, obviously you can't do this, it would violate referential transparency. Except if you define it as (?!) :: a -> Bool (?!) x = x `seq` True ..but that's probably not what you meant? :-) > And I expect it to be such that the following terminates after printing the > first 101 fibonacci numbers. >> fibs = 0 : 1 : zipWith (+) fibs (tail fibs) >> >> main = do print $ fibs !! 100 >> print $ takeWhile (?!) fibs The obvious problem is that the pure function "takeWhile (?!) fibs" would return different things depending on what has happened to "fibs" earlier in the program. The run-time system has information about evaluation status, so it might be possible to query it - but you'd need to do so in IO. I also seem to remember a debugger being able to display evaluated and unevaluated thunks? Also, you might be able to inspect evaluation by something like fibs2 = sequence' [ print ("evaluating:"++show x)) >> return x | x <- fibs ] where sequence' is a lazy version of sequence. This is a bit clunky, but occasionally useful. -k -- If I haven't seen further, it is by standing in the footprints of giants From bulat.ziganshin at gmail.com Fri May 8 03:52:18 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri May 8 03:38:28 2009 Subject: [Haskell] Re[2]: [Haskell-cafe] Is Haskell a Good Choice for WebApplications? (ANN: Vocabulink) In-Reply-To: <871vr0w0lo.fsf@malde.org> References: <87fxfll3ad.fsf@forno.us> <204746127.20090507001813@gmail.com> <4A036B20.4070301@freegeek.org> <871vr0w0lo.fsf@malde.org> Message-ID: <594254548.20090508115218@gmail.com> Hello Ketil, Friday, May 8, 2009, 10:49:23 AM, you wrote: >> FWIW, the JVM also fails to release memory resources back to the >> OS. Given all the problems I've seen that one cause for long-running >> processes, I'm definitely in support of correcting any behavior like >> this in the GHC RTS. > I'm curious what real problems arise from this? As far as I can tell, > virtual memory and overcommit ought to make this (i.e. not releasing > memory back to the OS) mostly harmless. Is this on particular systems > with different properties than your average run-of-the-mill Unix? this increase virtual memory usage, leading to swapping data to disk once the memory is freed, it should be released - otherwise OS doesn't know that it contains garbage and writes it to the disk once RAM overflowed. it's pity to have file manager occupy 500 mb of virtual memory only because you've worked with large archive a week ago -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Fri May 8 04:06:38 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri May 8 03:52:29 2009 Subject: [Haskell] Re[2]: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: References: <87fxfll3ad.fsf@forno.us> <204746127.20090507001813@gmail.com> <4A02B215.4060902@gmail.com> <811855674.20090507145102@gmail.com> <4A02E611.1000807@gmail.com> <1210666055.20090507181752@gmail.com> <4A02F6FA.80804@gmail.com> <118713518.20090507205518@gmail.com> Message-ID: <13810270401.20090508120638@gmail.com> Hello Jason, Thursday, May 7, 2009, 9:06:33 PM, you wrote: >> you are right again. so, that remains: you shouldn't suppose that >> user have read 90's GC paper. give a short excerpt of it: how >> generational GC works and how memory usage converts to memory >> footprint. then descriptions of RTS options will serve as >> "modifications" to this "baseline" > Perhaps you could write a description here to the list or the wiki and > after a few iterations it could be included in the GHC manual? ok, once i will find spare time -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From jac at informatik.uni-kiel.de Fri May 8 06:47:45 2009 From: jac at informatik.uni-kiel.de (Jan Christiansen) Date: Fri May 8 06:33:27 2009 Subject: [Haskell-cafe] monad . comonad = id Message-ID: <939E92E8-AD2C-4936-89CB-2057595EF626@informatik.uni-kiel.de> Hi, I have a question regarding the connection between monads and comonads. I always thought of the comonad operations as being the inverse operations of the corresponding monad functions. As I do not know the underlying theory I thought I simply ask the masters. Is there a formal verification for this intuition? That is, are there always corresponding instances for monad and comonad such that the following laws are satisfied? extract . return == id join . duplicate == id If this is the case I would like to know what the corresponding monad for the following comond could be. This comonad treats lists as pointed sets where the first element is focused. instance Comonad [] where extract = head duplicate xs = init (zipWith (++) (tails xs) (inits xs)) Obviously we can define return x = [x]. But I do not know how to define join. Cheers, Jan From miguelimo38 at yandex.ru Fri May 8 07:14:50 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Fri May 8 07:00:39 2009 Subject: [Haskell-cafe] monad . comonad = id In-Reply-To: <939E92E8-AD2C-4936-89CB-2057595EF626@informatik.uni-kiel.de> References: <939E92E8-AD2C-4936-89CB-2057595EF626@informatik.uni-kiel.de> Message-ID: <4A04142A.7080001@yandex.ru> > I have a question regarding the connection between monads and comonads. > I always thought of the comonad operations as being the inverse > operations of the corresponding monad functions. That's not true. > If this is the case I would like to know what the corresponding monad > for the following comond could be. This comonad treats lists as pointed > sets where the first element is focused. > > instance Comonad [] where > extract = head > duplicate xs = init (zipWith (++) (tails xs) (inits xs)) First of all, this is NOT a comonad. The term "comonad" doesn't refer just to instances of Comonad class, it refers to instances that satisfy several laws. Secondly, "[]" is a monad, and there is an instance of Monad class for it. It's working; don't fix it. From g9ks157k at acme.softbase.org Fri May 8 07:23:09 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri May 8 07:08:27 2009 Subject: [Haskell-cafe] commending "Design concepts in programming languages" In-Reply-To: <200905071442.50257.daniel.is.fischer@web.de> References: <5e0214850904291029gd68128bofccf9691c400adf4@mail.gmail.com> <23422300.post@talk.nabble.com> <200905071442.50257.daniel.is.fischer@web.de> Message-ID: <200905081323.09106.g9ks157k@acme.softbase.org> Am Donnerstag, 7. Mai 2009 14:42 schrieb Daniel Fischer: > Of course, if centuries ago people had decided to write the argument before > the function, composition would've been defined the other way round. > They haven't. Algebraists used to write x f instead of f(x) at least in the 1980s. I think, also category theorists often wrote (write?) composition with the first morphism on the left, i.e., ?the other way round?. Best wishes, Wolfgang From jac at informatik.uni-kiel.de Fri May 8 07:44:51 2009 From: jac at informatik.uni-kiel.de (Jan Christiansen) Date: Fri May 8 07:30:30 2009 Subject: [Haskell-cafe] monad . comonad = id In-Reply-To: <4A04142A.7080001@yandex.ru> References: <939E92E8-AD2C-4936-89CB-2057595EF626@informatik.uni-kiel.de> <4A04142A.7080001@yandex.ru> Message-ID: Hi, On 08.05.2009, at 13:14, Miguel Mitrofanov wrote: >> I have a question regarding the connection between monads and >> comonads. I always thought of the comonad operations as being the >> inverse operations of the corresponding monad functions. > > That's not true. I thought there is some kind of duality between monads and comonads in category theory. Does this "only" refer to the types of the functions or am I totally wrong here? >> If this is the case I would like to know what the corresponding >> monad for the following comond could be. This comonad treats lists >> as pointed sets where the first element is focused. >> instance Comonad [] where >> extract = head >> duplicate xs = init (zipWith (++) (tails xs) (inits xs)) > > First of all, this is NOT a comonad. The term "comonad" doesn't > refer just to instances of Comonad class, it refers to instances > that satisfy several laws. I am aware of this. I thought it does satisfy all the laws. Which one have I missed? > Secondly, "[]" is a monad, and there is an instance of Monad class > for it. It's working; don't fix it. I am also aware of this. Perhaps I should have used a data type like data Pointed a = Pointed a [a] but in this case a corresponding duplicate implementation is more complicated. I am very sorry if have asked a stupid question. Cheers, Jan From miguelimo38 at yandex.ru Fri May 8 07:54:37 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Fri May 8 07:40:24 2009 Subject: [Haskell-cafe] monad . comonad = id In-Reply-To: <939E92E8-AD2C-4936-89CB-2057595EF626@informatik.uni-kiel.de> References: <939E92E8-AD2C-4936-89CB-2057595EF626@informatik.uni-kiel.de> Message-ID: <4A041D7D.90702@yandex.ru> Seems like I was wrong. It does satisfy comonad laws. Sorry. However, the "duality" of monads and comonads isn't that simple. A comonad is actually a monad itself, but in different category. It has nothing to do with inverse functions etc. Jan Christiansen wrote on 08.05.2009 14:47: > Hi, > > I have a question regarding the connection between monads and comonads. > I always thought of the comonad operations as being the inverse > operations of the corresponding monad functions. As I do not know the > underlying theory I thought I simply ask the masters. > > Is there a formal verification for this intuition? That is, are there > always corresponding instances for monad and comonad such that the > following laws are satisfied? > > extract . return == id > > join . duplicate == id > > > If this is the case I would like to know what the corresponding monad > for the following comond could be. This comonad treats lists as pointed > sets where the first element is focused. > > instance Comonad [] where > extract = head > duplicate xs = init (zipWith (++) (tails xs) (inits xs)) > > Obviously we can define return x = [x]. But I do not know how to define > join. > > > Cheers, Jan > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From daniel.is.fischer at web.de Fri May 8 08:31:09 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri May 8 08:16:56 2009 Subject: [Haskell-cafe] commending "Design concepts in programming languages" In-Reply-To: <200905081323.09106.g9ks157k@acme.softbase.org> References: <5e0214850904291029gd68128bofccf9691c400adf4@mail.gmail.com> <200905071442.50257.daniel.is.fischer@web.de> <200905081323.09106.g9ks157k@acme.softbase.org> Message-ID: <200905081431.09883.daniel.is.fischer@web.de> Am Freitag 08 Mai 2009 13:23:09 schrieb Wolfgang Jeltsch: > Am Donnerstag, 7. Mai 2009 14:42 schrieb Daniel Fischer: > > Of course, if centuries ago people had decided to write the argument > > before the function, composition would've been defined the other way > > round. They haven't. > > Algebraists used to write x f instead of f(x) at least in the 1980s. I think that should read *some* algebraists... Though I had no contact with algebraists in the 1980s, if that practice had been ubiquitous among them, I would have expected it to show up in the textbooks. I've never seen it in an algebra book, nor was it used in any algebra lecture I attended in the 1990s, so I doubt it was very widespread. Don't get me wrong, that notation does make sense and has some advantages over the conventional one, I wouldn't oppose a change, though it would take some time to get used to it. All I'm saying is that the overwhelming majority of mathematicians doesn't use it. > I think, also category theorists often wrote (write?) composition with the > first morphism on the left, i.e., ?the other way round?. Yeah, I heard that, too. It's a field where the advantages of postfix notation show clearly and a young one, so for them it was relatively easy to switch. You'd have a hard time persuading the statisticians and analysts, though. > > Best wishes, > Wolfgang Cheers, Daniel From waldmann at imn.htwk-leipzig.de Fri May 8 09:39:22 2009 From: waldmann at imn.htwk-leipzig.de (j.waldmann) Date: Fri May 8 09:24:43 2009 Subject: [Haskell-cafe] commending "Design concepts in programming languages" In-Reply-To: <200905081431.09883.daniel.is.fischer@web.de> References: <5e0214850904291029gd68128bofccf9691c400adf4@mail.gmail.com> <23422300.post@talk.nabble.com> <200905071442.50257.daniel.is.fischer@web.de> <200905081323.09106.g9ks157k@acme.softbase.org> <200905081431.09883.daniel.is.fischer@web.de> Message-ID: <23446161.post@talk.nabble.com> Wow. This is really a bikeshed discussion. My post contained praise for the book, a critique of one of its design decisions (intermediate language not explicitely typed), and a syntactical remark. Guess what the discussion is about. (This is also known as http://www.haskell.org/haskellwiki/Wadlers_Law) If you're advocating (f.g) = \ x -> f(g(x)), then: 1. Define composition of relations. 2. Is a function a special case of a relation? -- View this message in context: http://www.nabble.com/Recommending-%22Design-concepts-in-programming-languages%22-tp23301907p23446161.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From miguelimo38 at yandex.ru Fri May 8 09:51:28 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Fri May 8 09:37:08 2009 Subject: [Haskell-cafe] commending "Design concepts in programming languages" In-Reply-To: <23446161.post@talk.nabble.com> References: <5e0214850904291029gd68128bofccf9691c400adf4@mail.gmail.com> <23422300.post@talk.nabble.com> <200905071442.50257.daniel.is.fischer@web.de> <200905081323.09106.g9ks157k@acme.softbase.org> <200905081431.09883.daniel.is.fischer@web.de> <23446161.post@talk.nabble.com> Message-ID: <4A0438E0.5080604@yandex.ru> j.waldmann wrote on 08.05.2009 17:39: > Wow. This is really a bikeshed discussion. My post contained praise for the > book, > a critique of one of its design decisions (intermediate language not > explicitely typed), > and a syntactical remark. Guess what the discussion is about. > (This is also known as http://www.haskell.org/haskellwiki/Wadlers_Law) > > If you're advocating (f.g) = \ x -> f(g(x)), then: > > 1. Define composition of relations. R1 . R2 = {(x, y) | \exists z : (x, z) \in R2 & (z, y) \in R1} That's the definition I've usually seen. (If I'm not mistaken). > 2. Is a function a special case of a relation? Depends on the definition (i.e., some books define a relation on (A,B) as a subset in A\times B, and a function A -> B as a triple (A, B, G), where G is a subset in A\times B), but, generally speaking, yes. From es at ertes.de Fri May 8 09:58:08 2009 From: es at ertes.de (Ertugrul Soeylemez) Date: Fri May 8 09:43:38 2009 Subject: [Haskell-cafe] Re: monad . comonad = id References: <939E92E8-AD2C-4936-89CB-2057595EF626@informatik.uni-kiel.de> Message-ID: <20090508155808.17eab66b@tritium.xx> Hello Jan, the principle of duality in category theory is not like "being the inverse", but more like "stating the same somewhere else". To each category there is an opposite category, which is just the same, but with all arrows flipped. A comonad in the original category is then a monad in the corresponding opposite category. Greets, Ertugrul. Jan Christiansen wrote: > Hi, > > I have a question regarding the connection between monads and > comonads. I always thought of the comonad operations as being the > inverse operations of the corresponding monad functions. As I do not > know the underlying theory I thought I simply ask the masters. > > Is there a formal verification for this intuition? That is, are there > always corresponding instances for monad and comonad such that the > following laws are satisfied? > > extract . return == id > > join . duplicate == id > > > If this is the case I would like to know what the corresponding monad > for the following comond could be. This comonad treats lists as > pointed sets where the first element is focused. > > instance Comonad [] where > extract = head > duplicate xs = init (zipWith (++) (tails xs) (inits xs)) > > Obviously we can define return x = [x]. But I do not know how to > define join. > > > Cheers, Jan -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/ From wagner.andrew at gmail.com Fri May 8 10:32:01 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Fri May 8 10:17:19 2009 Subject: [Haskell-cafe] Poking fun at haskell and other programming languages Message-ID: http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090508/ec995661/attachment.htm From deduktionstheorem at web.de Fri May 8 10:36:41 2009 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Fri May 8 10:22:02 2009 Subject: [Haskell-cafe] Why is Bool no instance of Num and Bits? Message-ID: <4A044379.1020406@web.de> Hi! When looking for an xor function, I found one in Data.Bits but couldn't use it for Bool, because Bool is no instance of Bits and of Num (which would be necessary, because it's "class (Num b) => Bits b"). My question is: Why not? We could declare instance Num Bool where (+) False = id (+) True = not (*) True True = True (*) _ _ = False (-) = (+) negate = id abs = id signum = const True fromInteger = not . even which basically implements the field with 2 elements and instance Bits Bool where bitSize = const 1 isSigned = const False (.&.) = (&&) (.|.) = (||) xor = (+) complement = not shift = const shiftL = const shiftR = const rotate = const rotateL = const rotateR = const bit = (==0) setBit _ 0 = True setBit b _ = b clearBit _ 0 = False clearBit b _ = b complementBit b 0 = not b complementBit b _ = b testBit b 0 = b testBit _ _ = False quite trivial... Why is this not part of base? Or am I missing something? //Stephan -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From deniz.a.m.dogan at gmail.com Fri May 8 10:40:58 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Fri May 8 10:26:16 2009 Subject: [Haskell-cafe] Why is Bool no instance of Num and Bits? In-Reply-To: <4A044379.1020406@web.de> References: <4A044379.1020406@web.de> Message-ID: <7b501d5c0905080740gbdc5d2ft99b3909bd7ea52a7@mail.gmail.com> 2009/5/8 Stephan Friedrichs : > Hi! > > When looking for an xor function, I found one in Data.Bits but couldn't > use it for Bool, because Bool is no instance of Bits and of Num (which > would be necessary, because it's "class (Num b) => Bits b"). My question > is: Why not? > > We could declare > > instance Num Bool where > ? ?(+) False = id > ? ?(+) True ?= not > > ? ?(*) True ?True = True > ? ?(*) _ ? ? _ ? ?= False > > ? ?(-) = (+) > > ? ?negate ? ? ?= id > ? ?abs ? ? ? ? = id > ? ?signum ? ? ?= const True > ? ?fromInteger = not . even > > which basically implements the field with 2 elements and > > instance Bits Bool where > ? ?bitSize ?= const 1 > ? ?isSigned = const False > > ? ?(.&.) = (&&) > ? ?(.|.) = (||) > ? ?xor ? = (+) > > ? ?complement = not > > ? ?shift ?= const > ? ?shiftL = const > ? ?shiftR = const > > ? ?rotate ?= const > ? ?rotateL = const > ? ?rotateR = const > > ? ?bit = (==0) > > ? ?setBit _ 0 = True > ? ?setBit b _ = b > > ? ?clearBit _ 0 = False > ? ?clearBit b _ = b > > ? ?complementBit b 0 = not b > ? ?complementBit b _ = b > > ? ?testBit b 0 = b > ? ?testBit _ _ = False > > quite trivial... Why is this not part of base? Or am I missing something? > > //Stephan Isn't "XOR" for booleans (/=)? Deniz Dogan From deduktionstheorem at web.de Fri May 8 10:48:27 2009 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Fri May 8 10:34:19 2009 Subject: [Haskell-cafe] Why is Bool no instance of Num and Bits? In-Reply-To: <7b501d5c0905080740gbdc5d2ft99b3909bd7ea52a7@mail.gmail.com> References: <4A044379.1020406@web.de> <7b501d5c0905080740gbdc5d2ft99b3909bd7ea52a7@mail.gmail.com> Message-ID: <4A04463B.6020500@web.de> Deniz Dogan wrote: >> instance Num Bool where >> (+) False = id >> (+) True = not >> >> (*) True True = True >> (*) _ _ = False >> > > Isn't "XOR" for booleans (/=)? Oh right. And (*) would be (&&): instance Num Bool where (+) = (/=) (*) = (&&) -- ... //Stephan -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From ganesh.sittampalam at credit-suisse.com Fri May 8 10:51:32 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Fri May 8 10:37:28 2009 Subject: [Haskell-cafe] Why is Bool no instance of Num and Bits? In-Reply-To: <4A044379.1020406@web.de> References: <4A044379.1020406@web.de> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B01ABAAE9@ELON17P32001A.csfb.cs-group.com> Stephan Friedrichs wrote: > When looking for an xor function, I found one in Data.Bits but > couldn't use it for Bool, because Bool is no instance of Bits and of > Num (which would be necessary, because it's "class (Num b) => Bits > b"). My question is: Why not? > > [...] > quite trivial... Why is this not part of base? Or am I missing > something? One reason would be that we don't want 1 + True to typecheck, even if it does have a sensible interpretation. Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From pumpkingod at gmail.com Fri May 8 11:24:54 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Fri May 8 11:10:09 2009 Subject: [Haskell-cafe] Generating Haskell with associated types (and kind annotations) Message-ID: Hi all, I was wondering whether anyone had any suggestions on a good way to generate repetitive code with associated types and kind annotations. I'd like to use TH but as far as I understand, it doesn't support this yet (I think associated types are in HEAD but not kinds), so for now I've been using ruby with string interpolation, which feels rather ugly. It means that I have to edit the ruby script and regenerate the file in question each time I make a change, which doesn't fit in very nicely with cabal (or my patience) and so on. Ideally, I'd have something that I can write mostly like real Haskell (with "holes" to substitute values into), that can be integrated nicely into the cabal build system without using custom external preprocessors or anything like that. Any ideas? Thanks, Dan From daniel.is.fischer at web.de Fri May 8 11:30:42 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri May 8 11:16:29 2009 Subject: [Haskell-cafe] commending "Design concepts in programming languages" In-Reply-To: <4A0438E0.5080604@yandex.ru> References: <5e0214850904291029gd68128bofccf9691c400adf4@mail.gmail.com> <23446161.post@talk.nabble.com> <4A0438E0.5080604@yandex.ru> Message-ID: <200905081730.42405.daniel.is.fischer@web.de> Am Freitag 08 Mai 2009 15:51:28 schrieb Miguel Mitrofanov: > j.waldmann wrote on 08.05.2009 17:39: > > Wow. This is really a bikeshed discussion. My post contained praise for > > the book, > > a critique of one of its design decisions (intermediate language not > > explicitely typed), > > and a syntactical remark. Guess what the discussion is about. > > (This is also known as http://www.haskell.org/haskellwiki/Wadlers_Law) > > > > If you're advocating (f.g) = \ x -> f(g(x)), then: I'm not advocating it, just objecting to you calling it wrong, because that's the common definition. > > > > 1. Define composition of relations. > > R1 . R2 = {(x, y) | \exists z : (x, z) \in R2 & (z, y) \in R1} > > That's the definition I've usually seen. (If I'm not mistaken). > Same here, I can't remember having seen any other definition. But I won't deny that it would flow more easily if it were the other way round. > > 2. Is a function a special case of a relation? In set theory, a function is usually *defined* as a relation R where R[{a}] has at most one element, so yes. From bugfact at gmail.com Fri May 8 11:33:25 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri May 8 11:18:44 2009 Subject: [Haskell-cafe] Darcs as undo/redo system? Message-ID: If you work with a text editor like Microsoft Visual Studio (maybe also Eclipse, don't know), each text editor has its own undo/redo history. However, when you perform refactoring - like renaming a function - this becomes an undo/redo on multiple files together, so in a sense these changes are part of a global history. You can combine these two different kinds of mutations, and undo/redo still works as expected. I don't know how hard this is to implement, but it looks like this problem is somehow is related to Darcs theory of patches (which I don't know yet :-) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090508/7a420bce/attachment.htm From ndmitchell at gmail.com Fri May 8 11:49:07 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Fri May 8 11:34:24 2009 Subject: [Haskell-cafe] Generating Haskell with associated types (and kind annotations) In-Reply-To: References: Message-ID: <404396ef0905080849rb5beddcsdd9f500f1983cf6a@mail.gmail.com> Hi Dan, > I was wondering whether anyone had any suggestions on a good way to > generate repetitive code with associated types and kind annotations. haskell-src-exts is the answer: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskell-src-exts >From the project description: "Haskell-Source with Extensions (HSE, haskell-src-exts) is an extension of the standard haskell-src package, and handles most common syntactic extensions to Haskell, including: ... Indexed type families (including associated types)" I've used the project extensively in HLint (http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hlint) and it works fantastically. Thanks Neil On Fri, May 8, 2009 at 4:24 PM, Daniel Peebles wrote: > Hi all, > > I'd like to use TH but as far as I understand, it doesn't support this > yet (I think associated types are in HEAD but not kinds), so for now > I've been using ruby with string interpolation, which feels rather > ugly. It means that I have to edit the ruby script and regenerate the > file in question each time I make a change, which doesn't fit in very > nicely with cabal (or my patience) and so on. Ideally, I'd have > something that I can write mostly like real Haskell (with "holes" to > substitute values into), that can be integrated nicely into the cabal > build system without using custom external preprocessors or anything > like that. > > Any ideas? > > Thanks, > Dan > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From wagner.andrew at gmail.com Fri May 8 11:49:41 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Fri May 8 11:34:59 2009 Subject: [Haskell-cafe] Why is Bool no instance of Num and Bits? In-Reply-To: <16442B752A06A74AB4D9F9A5FF076E4B01ABAAE9@ELON17P32001A.csfb.cs-group.com> References: <4A044379.1020406@web.de> <16442B752A06A74AB4D9F9A5FF076E4B01ABAAE9@ELON17P32001A.csfb.cs-group.com> Message-ID: Err, I'm not seeing the danger of this (+) :: forall a. (Num a) => a -> a -> a Doesn't this require the two parameters to be the same instance of Num? On Fri, May 8, 2009 at 10:51 AM, Sittampalam, Ganesh < ganesh.sittampalam@credit-suisse.com> wrote: > Stephan Friedrichs wrote: > > > When looking for an xor function, I found one in Data.Bits but > > couldn't use it for Bool, because Bool is no instance of Bits and of > > Num (which would be necessary, because it's "class (Num b) => Bits > > b"). My question is: Why not? > > > > [...] > > quite trivial... Why is this not part of base? Or am I missing > > something? > > One reason would be that we don't want 1 + True to typecheck, even if it > does have a sensible interpretation. > > Ganesh > > > =============================================================================== > Please access the attached hyperlink for an important electronic > communications disclaimer: > http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html > > =============================================================================== > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090508/5590cddb/attachment.htm From ndmitchell at gmail.com Fri May 8 11:51:10 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Fri May 8 11:36:27 2009 Subject: [Haskell-cafe] Why is Bool no instance of Num and Bits? In-Reply-To: References: <4A044379.1020406@web.de> <16442B752A06A74AB4D9F9A5FF076E4B01ABAAE9@ELON17P32001A.csfb.cs-group.com> Message-ID: <404396ef0905080851t2b74d53y15bfda6c16c31cdd@mail.gmail.com> > Err, I'm not seeing the danger of this > (+) :: forall a. (Num a) => a -> a -> a > Doesn't this require the two parameters to be the same instance of Num? I didn't at first, then I remembered: 1 + True = fromInteger 1 + True And if we have Num for Bool, it type checks. Thanks Neil From wagner.andrew at gmail.com Fri May 8 11:53:53 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Fri May 8 11:39:09 2009 Subject: [Haskell-cafe] Why is Bool no instance of Num and Bits? In-Reply-To: <404396ef0905080851t2b74d53y15bfda6c16c31cdd@mail.gmail.com> References: <4A044379.1020406@web.de> <16442B752A06A74AB4D9F9A5FF076E4B01ABAAE9@ELON17P32001A.csfb.cs-group.com> <404396ef0905080851t2b74d53y15bfda6c16c31cdd@mail.gmail.com> Message-ID: Hmm, I never knew that. Is that a GHC thing? Is it strictly necessary? Seems like it could be done in the Num instance for Integers, Ints, etc. On Fri, May 8, 2009 at 11:51 AM, Neil Mitchell wrote: > > Err, I'm not seeing the danger of this > > (+) :: forall a. (Num a) => a -> a -> a > > Doesn't this require the two parameters to be the same instance of Num? > > I didn't at first, then I remembered: > > 1 + True > = > fromInteger 1 + True > > And if we have Num for Bool, it type checks. > > Thanks > > Neil > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090508/21d16fdf/attachment.htm From ndmitchell at gmail.com Fri May 8 11:57:33 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Fri May 8 11:42:49 2009 Subject: [Haskell-cafe] Why is Bool no instance of Num and Bits? In-Reply-To: References: <4A044379.1020406@web.de> <16442B752A06A74AB4D9F9A5FF076E4B01ABAAE9@ELON17P32001A.csfb.cs-group.com> <404396ef0905080851t2b74d53y15bfda6c16c31cdd@mail.gmail.com> Message-ID: <404396ef0905080857i34938e98nd185b5d16e7aab13@mail.gmail.com> Nope, it's in the Haskell standard. It means we can type: 1 + (2 :: Int) and have it work Otherwise what type would 1 have? Integer? Float? It's just a way of giving constants the type :: Num a => a On Fri, May 8, 2009 at 4:53 PM, Andrew Wagner wrote: > Hmm, I never knew that. Is that a GHC thing? Is it strictly necessary? Seems > like it could be done in the Num instance for Integers, Ints, etc. > > On Fri, May 8, 2009 at 11:51 AM, Neil Mitchell wrote: >> >> > Err, I'm not seeing the danger of this >> > (+) :: forall a. (Num a) => a -> a -> a >> > Doesn't this require the two parameters to be the same instance of Num? >> >> I didn't at first, then I remembered: >> >> 1 + True >> = >> fromInteger 1 + True >> >> And if we have Num for Bool, it type checks. >> >> Thanks >> >> Neil > > From nccb2 at kent.ac.uk Fri May 8 12:00:17 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Fri May 8 11:44:38 2009 Subject: [Haskell-cafe] Why is Bool no instance of Num and Bits? In-Reply-To: <404396ef0905080851t2b74d53y15bfda6c16c31cdd@mail.gmail.com> References: <4A044379.1020406@web.de> <16442B752A06A74AB4D9F9A5FF076E4B01ABAAE9@ELON17P32001A.csfb.cs-group.com> <404396ef0905080851t2b74d53y15bfda6c16c31cdd@mail.gmail.com> Message-ID: <4A045711.5040809@kent.ac.uk> Neil Mitchell wrote: > I didn't at first, then I remembered: > > 1 + True > = > fromInteger 1 + True > > And if we have Num for Bool, it type checks. > Does that also mean that you could write: if 3 - 4 then ... else ... (= if (fromInteger 3 :: Bool) - (fromInteger 4 :: Bool) then ... else ...) or perhaps (not sure if type defaulting stretches to this): if 1 then ... else ... (= if (fromInteger 1 :: Bool) then ... else ...) If you change fromInteger in Num Bool to be fromInteger x = x /= 0, then we could all start writing nasty C-like if-expressions... Thanks, Neil. From ndmitchell at gmail.com Fri May 8 12:04:54 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Fri May 8 11:50:10 2009 Subject: [Haskell-cafe] Why is Bool no instance of Num and Bits? In-Reply-To: <4A045711.5040809@kent.ac.uk> References: <4A044379.1020406@web.de> <16442B752A06A74AB4D9F9A5FF076E4B01ABAAE9@ELON17P32001A.csfb.cs-group.com> <404396ef0905080851t2b74d53y15bfda6c16c31cdd@mail.gmail.com> <4A045711.5040809@kent.ac.uk> Message-ID: <404396ef0905080904i197a79b2k15fe145b622756d8@mail.gmail.com> > Does that also mean that you could write: > > if 3 - 4 then ... else ... ?(= if (fromInteger 3 :: Bool) - (fromInteger 4 > :: Bool) then ... else ...) No. 3 - 4 is an Integer, the proposal is to convert Bools to Ints, not Ints to Bools. Of course, Lennart has been asking for precisely this functionality (overloaded Booleans) for some time - so one day it may be possible! You could however do: if 3 then ... else .. > If you change fromInteger in Num Bool to be fromInteger x = x /= 0, then we > could all start writing nasty C-like if-expressions... Yeah, the more people give examples of the power of Num Bool, the more it seems like a very bad idea! Which is a shame, having Bits on Bool seems entirely logical, having Num a superclass of Bits seems a little less clear. Thanks Neil From haskell at colquitt.org Fri May 8 12:43:39 2009 From: haskell at colquitt.org (John Dorsey) Date: Fri May 8 12:28:57 2009 Subject: [Haskell-cafe] Why is Bool no instance of Num and Bits? In-Reply-To: <404396ef0905080904i197a79b2k15fe145b622756d8@mail.gmail.com> References: <4A044379.1020406@web.de> <16442B752A06A74AB4D9F9A5FF076E4B01ABAAE9@ELON17P32001A.csfb.cs-group.com> <404396ef0905080851t2b74d53y15bfda6c16c31cdd@mail.gmail.com> <4A045711.5040809@kent.ac.uk> <404396ef0905080904i197a79b2k15fe145b622756d8@mail.gmail.com> Message-ID: <20090508164339.GF3278@colquitt.org> > > Does that also mean that you could write: > > > > if 3 - 4 then ... else ... ?(= if (fromInteger 3 :: Bool) - (fromInteger 4 > > :: Bool) then ... else ...) > > No. 3 - 4 is an Integer, the proposal is to convert Bools to Ints, not > Ints to Bools. Rather, (3 - 4) is a "(Num t) => t", so yes, this would work with instance Num Bool. *Main> if 3 - 4 then "yessirree" else "yep" "yep" > Yeah, the more people give examples of the power of Num Bool, the more > it seems like a very bad idea! +1 John From dagit at codersbase.com Fri May 8 12:43:54 2009 From: dagit at codersbase.com (Jason Dagit) Date: Fri May 8 12:29:12 2009 Subject: [Haskell-cafe] Darcs as undo/redo system? In-Reply-To: References: Message-ID: Hi Peter, On Fri, May 8, 2009 at 8:33 AM, Peter Verswyvelen wrote: > If you work with a text editor like Microsoft Visual Studio (maybe also > Eclipse, don't know), each text editor has its own undo/redo history. > However, when you perform refactoring - like renaming a function - this > becomes an undo/redo on multiple files together, so in a sense these changes > are part of a global history. > You can combine these two different kinds of mutations, and undo/redo still > works as expected. > I don't know how hard this is to implement, but it looks like this problem > is somehow is related to Darcs theory of patches (which I don't know yet :-) I have thought about applications of patch theory like this as well. I could imagine applying it to the undo stack in GIMP. Allowing you to undo things on different layers. I think one of the things you need for this to work, is a graphical representation of the undo history. You could commute the change you want to undo to the top of the stack, undo it, and then you have a branch in the history. Because this could get complicated, you need to display this branched history to the user so they are able to continue working with it. If you wanted to work on this, I would encourage you to read more about patch theory[1,2,3,4] and also try out libdarcs[5]. Thanks, Jason [1] http://darcs.net/manual/node9.html [2] http://en.wikibooks.org/wiki/Understanding_darcs/Patch_theory [3] http://files.codersbase.com/thesis.pdf (see chapter 3) [4] http://wiki.darcs.net/DarcsWiki/Talks [5] http://bugs.darcs.net/issue1149 From allbery at ece.cmu.edu Fri May 8 12:56:48 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri May 8 12:42:23 2009 Subject: [Haskell-cafe] is value evaluated? In-Reply-To: <4A03C411.1090703@gmail.com> References: <20090508044919.GA13362@ece.utexas.edu> <4A03C411.1090703@gmail.com> Message-ID: <4FF5A188-6518-47E3-B3F6-7435B0C37F16@ece.cmu.edu> On May 8, 2009, at 01:33 , Joe Fredette wrote: > That strikes me as being bad in a "I'm violating the Halting > Problem" sort of way- but I'm not sure how. Is there some > contradictory construction that > could be built from such a function? I don't think it is; surely the Haskell runtime knows which thunks it has evaluated. It just explicitly violates referential transparency, and therefore must be in IO. You may be thinking that it would return a result for _|_, but as described if you fed it _|_ it could only produce False (if the _|_ has been evaluated you would not be able to reach the test). -- 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/20090508/d5bbfc32/PGP.bin From noel.kalman at googlemail.com Fri May 8 12:57:58 2009 From: noel.kalman at googlemail.com (Kalman Noel) Date: Fri May 8 12:43:37 2009 Subject: [Haskell-cafe] OT: Languages (was: Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink)) In-Reply-To: References: Message-ID: <4A046496.8090905@googlemail.com> wren ng thornton schrieb: > Chris Forno (jekor) wrote: >> That being said, Esperanto, and even Japanese sentence structure perhaps >> is not as different as an agglutinative language like German. I'll need >> to study it more to find out. > > Actually, Japanese is agglutinative too (moreso than German is). I take it the above calling German agglutinative was sort of a typo, because well, it isn't, except having many compound words. Esperanto, on the other hand, is usually described as agglutinative. Kalman From noel.kalman at googlemail.com Fri May 8 13:04:21 2009 From: noel.kalman at googlemail.com (Kalman Noel) Date: Fri May 8 12:49:43 2009 Subject: [Haskell-cafe] Re: Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink) In-Reply-To: References: Message-ID: <4A046615.9010308@googlemail.com> Daniel Carrera schrieb: > I think it largely depends on the learner. Some people find vocabulary > easier, or more interesting, others not. I have a hard time learning a > lot of isolated facts (e.g. vocabulary), but I find it easier and more > enjoyable to learn a rule that I can apply many times. But I know people > who are the exact opposite. I wouldn't want to make an absolute rule. Or like a local physics prof likes to put it: ?I guess you all have an idea of Ohm's law? Or wait, right, for the medics being with us, here are the three Ohm's laws: U = RI, R = U/I, and I= U/R.? Kalman From jfredett at gmail.com Fri May 8 13:07:57 2009 From: jfredett at gmail.com (Joe Fredette) Date: Fri May 8 12:53:15 2009 Subject: [Haskell-cafe] is value evaluated? In-Reply-To: <4FF5A188-6518-47E3-B3F6-7435B0C37F16@ece.cmu.edu> References: <20090508044919.GA13362@ece.utexas.edu> <4A03C411.1090703@gmail.com> <4FF5A188-6518-47E3-B3F6-7435B0C37F16@ece.cmu.edu> Message-ID: <4A0466ED.2000107@gmail.com> That must have been the vibe I was getting. My haskell-spider senses were tingling, I just overshot RT and went for the Halting Problem. /Joe Brandon S. Allbery KF8NH wrote: > On May 8, 2009, at 01:33 , Joe Fredette wrote: >> That strikes me as being bad in a "I'm violating the Halting Problem" >> sort of way- but I'm not sure how. Is there some contradictory >> construction that >> could be built from such a function? > > I don't think it is; surely the Haskell runtime knows which thunks it > has evaluated. It just explicitly violates referential transparency, > and therefore must be in IO. You may be thinking that it would return > a result for _|_, but as described if you fed it _|_ it could only > produce False (if the _|_ has been evaluated you would not be able to > reach the test). > -------------- 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/20090508/fa174e1a/jfredett.vcf From ganesh.sittampalam at credit-suisse.com Fri May 8 13:08:39 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Fri May 8 12:54:27 2009 Subject: [Haskell-cafe] is value evaluated? In-Reply-To: <4FF5A188-6518-47E3-B3F6-7435B0C37F16@ece.cmu.edu> References: <20090508044919.GA13362@ece.utexas.edu><4A03C411.1090703@gmail.com> <4FF5A188-6518-47E3-B3F6-7435B0C37F16@ece.cmu.edu> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B01ABAAED@ELON17P32001A.csfb.cs-group.com> Brandon S. Allbery KF8NH wrote: > On May 8, 2009, at 01:33 , Joe Fredette wrote: >> That strikes me as being bad in a "I'm violating the Halting Problem" >> sort of way- but I'm not sure how. Is there some contradictory >> construction that could be built from such a function? > > I don't think it is; surely the Haskell runtime knows which thunks it > has evaluated. It just explicitly violates referential transparency, > and therefore must be in IO. You may be thinking that it would > return a result for _|_, but as described if you fed it _|_ it could > only produce False (if the _|_ has been evaluated you would not be > able to reach the test). It could probably return True in GHC since you can catch exceptions. That still doesn't mean it solves the halting problem, of course. Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From allbery at ece.cmu.edu Fri May 8 13:18:37 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri May 8 13:04:09 2009 Subject: [Haskell-cafe] Why is Bool no instance of Num and Bits? In-Reply-To: <4A045711.5040809@kent.ac.uk> References: <4A044379.1020406@web.de> <16442B752A06A74AB4D9F9A5FF076E4B01ABAAE9@ELON17P32001A.csfb.cs-group.com> <404396ef0905080851t2b74d53y15bfda6c16c31cdd@mail.gmail.com> <4A045711.5040809@kent.ac.uk> Message-ID: <792C0766-EF78-4083-8716-A2F65C2F9C3F@ece.cmu.edu> On May 8, 2009, at 12:00 , Neil Brown wrote: > If you change fromInteger in Num Bool to be fromInteger x = x /= 0, > then we could all start writing nasty C-like if-expressions... I'd be strongly tempted to say > fromInteger = const False -- 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/20090508/1ba55820/PGP.bin From allbery at ece.cmu.edu Fri May 8 13:25:55 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri May 8 13:11:28 2009 Subject: [Haskell-cafe] is value evaluated? In-Reply-To: <16442B752A06A74AB4D9F9A5FF076E4B01ABAAED@ELON17P32001A.csfb.cs-group.com> References: <20090508044919.GA13362@ece.utexas.edu><4A03C411.1090703@gmail.com> <4FF5A188-6518-47E3-B3F6-7435B0C37F16@ece.cmu.edu> <16442B752A06A74AB4D9F9A5FF076E4B01ABAAED@ELON17P32001A.csfb.cs-group.com> Message-ID: <26163CA5-8D58-4FBF-AB29-5FA142B4297A@ece.cmu.edu> On May 8, 2009, at 13:08 , Sittampalam, Ganesh wrote: > Brandon S. Allbery KF8NH wrote: >> and therefore must be in IO. You may be thinking that it would >> return a result for _|_, but as described if you fed it _|_ it could >> only produce False (if the _|_ has been evaluated you would not be >> able to reach the test). > > It could probably return True in GHC since you can catch exceptions. > That still doesn't mean it solves the halting problem, of course. Unless it catches exceptions itself (which strikes me as a bad idea; it becomes a trivial way to ignore exceptions, leading to bad programming practices) either they're handled inside the _|_ (in which case it isn't _|_ from the standpoint of our test) or in an outer scope (in which case our test produces _|_ from the standpoint of the exception handler). -- 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/20090508/025ba76e/PGP.bin From pumpkingod at gmail.com Fri May 8 13:46:58 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Fri May 8 13:32:15 2009 Subject: [Haskell-cafe] Generating Haskell with associated types (and kind annotations) In-Reply-To: <404396ef0905080849rb5beddcsdd9f500f1983cf6a@mail.gmail.com> References: <404396ef0905080849rb5beddcsdd9f500f1983cf6a@mail.gmail.com> Message-ID: Hi Neil, Thanks for the suggestion! I'd seen the package before, but I couldn't figure out a good way to integrate it into my codegen situation. I guess I should write the "skeleton" of the code I want to generate, get HSE to parse it, and then replace the parts I want to change of the AST with what I need? Is there a nicer way (TH-like?) to get the modified AST into GHC than prettyprinting the AST again and asking GHC to compile the output file? Thank you, Dan On Fri, May 8, 2009 at 11:49 AM, Neil Mitchell wrote: > Hi Dan, > >> I was wondering whether anyone had any suggestions on a good way to >> generate repetitive code with associated types and kind annotations. > > haskell-src-exts is the answer: > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskell-src-exts > > From the project description: > > "Haskell-Source with Extensions (HSE, haskell-src-exts) is an > extension of the standard haskell-src package, and handles most common > syntactic extensions to Haskell, including: ... Indexed type families > (including associated types)" > > I've used the project extensively in HLint > (http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hlint) and > it works fantastically. > > Thanks > > Neil > > On Fri, May 8, 2009 at 4:24 PM, Daniel Peebles wrote: >> Hi all, >> >> I'd like to use TH but as far as I understand, it doesn't support this >> yet (I think associated types are in HEAD but not kinds), so for now >> I've been using ruby with string interpolation, which feels rather >> ugly. It means that I have to edit the ruby script and regenerate the >> file in question each time I make a change, which doesn't fit in very >> nicely with cabal (or my patience) and so on. Ideally, I'd have >> something that I can write mostly like real Haskell (with "holes" to >> substitute values into), that can be integrated nicely into the cabal >> build system without using custom external preprocessors or anything >> like that. >> >> Any ideas? >> >> Thanks, >> Dan >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From gwern0 at gmail.com Fri May 8 13:59:16 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Fri May 8 13:44:37 2009 Subject: [Haskell-cafe] Darcs as undo/redo system? In-Reply-To: References: Message-ID: On Fri, May 8, 2009 at 12:43 PM, Jason Dagit wrote: > Hi Peter, > > On Fri, May 8, 2009 at 8:33 AM, Peter Verswyvelen wrote: >> If you work with a text editor like Microsoft Visual Studio (maybe also >> Eclipse, don't know), each text editor has its own undo/redo history. >> However, when you perform refactoring - like renaming a function - this >> becomes an undo/redo on multiple files together, so in a sense these changes >> are part of a global history. >> You can combine these two different kinds of mutations, and undo/redo still >> works as expected. >> I don't know how hard this is to implement, but it looks like this problem >> is somehow is related to Darcs theory of patches (which I don't know yet :-) > > I have thought about applications of patch theory like this as well. > I could imagine applying it to the undo stack in GIMP. ?Allowing you > to undo things on different layers. ?I think one of the things you > need for this to work, is a graphical representation of the undo > history. ?You could commute the change you want to undo to the top of > the stack, undo it, and then you have a branch in the history. > Because this could get complicated, you need to display this branched > history to the user so they are able to continue working with it. > > If you wanted to work on this, I would encourage you to read more > about patch theory[1,2,3,4] and also try out libdarcs[5]. > > Thanks, > Jason Also good and highly relevant: http://byorgey.wordpress.com/2008/02/04/gobby-haskell-and-patch-theory/ -- gwern From daniel.is.fischer at web.de Fri May 8 14:49:19 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri May 8 14:35:14 2009 Subject: [Haskell-cafe] Why is Bool no instance of Num and Bits? In-Reply-To: <792C0766-EF78-4083-8716-A2F65C2F9C3F@ece.cmu.edu> References: <4A044379.1020406@web.de> <4A045711.5040809@kent.ac.uk> <792C0766-EF78-4083-8716-A2F65C2F9C3F@ece.cmu.edu> Message-ID: <200905082049.20032.daniel.is.fischer@web.de> Am Freitag 08 Mai 2009 19:18:37 schrieb Brandon S. Allbery KF8NH: > On May 8, 2009, at 12:00 , Neil Brown wrote: > > If you change fromInteger in Num Bool to be fromInteger x = x /= 0, > > then we could all start writing nasty C-like if-expressions... > > I'd be strongly tempted to say > > > fromInteger = const False fromInteger _ = unsafePerformIO $ randomRIO (False,True) looks safer to me. From dagit at codersbase.com Fri May 8 15:08:44 2009 From: dagit at codersbase.com (Jason Dagit) Date: Fri May 8 14:54:02 2009 Subject: Can HLint help spot space leaks? (was: Re: [Haskell-cafe] Generating Haskell with associated types (and kind annotations)) Message-ID: On Fri, May 8, 2009 at 8:49 AM, Neil Mitchell wrote: > > I've used the project extensively in HLint > (http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hlint) and > it works fantastically. Hi Neil, A bit off-topic, but your post reminded me: Does HLint currently help the user find space leaks? For example, does it recommend strict folds instead of lazy folds? I looked at the FAQ but this was not listed. I don't really know how feasible this is. Thanks, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090508/b138c707/attachment.htm From naur at post11.tele.dk Fri May 8 15:11:35 2009 From: naur at post11.tele.dk (Thorkil Naur) Date: Fri May 8 15:00:44 2009 Subject: [Haskell-cafe] ANNOUNCE: hpc-strobe-0.1: Hpc-generated strobes for a running Haskell program Message-ID: <200905082111.39742.naur@post11.tele.dk> I am pleased to announce the initial release of hpc-strobe: Hpc-generated strobes for a running Haskell program. hpc-strobe is a rudimentary library that demonstrates the possibility of using Hpc (Haskell Program Coverage) to inspect the state of a running Haskell program. hpc-strobe-0.1 has been uploaded to hackage: http://hackage.haskell.org/packages/archive/hpc-strobe/0.1/hpc-strobe-0.1.tar.gz In ordinary use of Hpc, a single so-called tix file is produced at the end of a run. The tix file records how many times each expression has been used during the run. This can be used to mark up the source code, identifying expressions that have not been used. hpc-strobe uses the basic machinery provided by Hpc to produce multiple tix files, also called strobes, representing the coverage at different times while the program is running. By subtracting such two tix files, again using Hpc machinery, a tix file representing the expressions used between the times of recording the subtracted tix files is produced. This may be used, for example, to get a better idea of what a long-running program is doing. It could also be used as a profiling tool, getting information about how many times individual expressions are used. A program is included whose strobe differences produce a crude rendering of an analog clock when they are used to mark up the source code using Hpc. Please see the attached example (gunzip the file, point you browser to it, scroll down to view the canvas function). Use of the library involves a simple change of the main function and also requires the program to be enabled for hpc. At the time of writing, this means using a fairly recent version of GHC and compiling the Haskell code with the -fhpc option. For additional details, see the README included in the package. Best regards Thorkil -------------- next part -------------- A non-text attachment was scrubbed... Name: Main.hs.html.gz Type: application/x-gzip Size: 3863 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090508/2924e044/Main.hs.html.bin From jeremy at n-heptane.com Fri May 8 15:35:51 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Fri May 8 15:21:09 2009 Subject: [Haskell-cafe] Darcs as undo/redo system? In-Reply-To: References: Message-ID: <87bpq3gzfs.wl%jeremy@n-heptane.com> At Fri, 8 May 2009 17:33:25 +0200, Peter Verswyvelen wrote: > > [1 ] > [1.1 ] > If you work with a text editor like Microsoft Visual Studio (maybe also > Eclipse, don't know), each text editor has its own undo/redo history. > However, when you perform refactoring - like renaming a function - this > becomes an undo/redo on multiple files together, so in a sense these changes > are part of a global history. If you read this paper, you will find an undo system for a colloborative editor complete with a theory that looks like a primitive version of darcs patch theory (complete with the dreaded merge bug of darcs 1): Undoing actions in collaborative work: Framework and experience by Prakash and Knister http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.48.6443&rep=rep1&type=pdf You will probably find these papers informative as well: Recognizing creative needs in user interface design by Terry and Mynatt http://www.cc.gatech.edu/fce/ecl/projects/openEnded/pubs/creativeInterfaces-creativecog2002.pdf A Selective Undo Mechanism for Graphical User Interfaces Based On Command Objects (1994) by Thomas Berlage http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.31.755 Flexible Conflict Detection and Management In Collaborative Applications (1997) by Keith Edwards http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.49.5439 Undo Any Operation at Any Time in Group Editors (2000) by Chengzheng Sun http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.32.6266 And, of course, you can use citeseer to find more papers that reference those. - jeremy From ganesh.sittampalam at credit-suisse.com Fri May 8 16:31:38 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Fri May 8 16:17:30 2009 Subject: [Haskell-cafe] is value evaluated? In-Reply-To: <26163CA5-8D58-4FBF-AB29-5FA142B4297A@ece.cmu.edu> References: <20090508044919.GA13362@ece.utexas.edu><4A03C411.1090703@gmail.com> <4FF5A188-6518-47E3-B3F6-7435B0C37F16@ece.cmu.edu> <16442B752A06A74AB4D9F9A5FF076E4B01ABAAED@ELON17P32001A.csfb.cs-group.com> <26163CA5-8D58-4FBF-AB29-5FA142B4297A@ece.cmu.edu> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B01ABAAEE@ELON17P32001A.csfb.cs-group.com> Brandon S. Allbery KF8NH wrote: > On May 8, 2009, at 13:08 , Sittampalam, Ganesh wrote: >> Brandon S. Allbery KF8NH wrote: >>> and therefore must be in IO. You may be thinking that it would >>> return a result for _|_, but as described if you fed it _|_ it could >>> only produce False (if the _|_ has been evaluated you would not be >>> able to reach the test). >> >> It could probably return True in GHC since you can catch exceptions. >> That still doesn't mean it solves the halting problem, of course. > > Unless it catches exceptions itself (which strikes me as a bad idea; > it becomes a trivial way to ignore exceptions, leading to bad > programming practices) either they're handled inside the _|_ (in > which case it isn't _|_ from the standpoint of our test) or in an > outer scope (in which case our test produces _|_ from the standpoint > of the exception handler). Surely it just needs to inspect the thunk to decide whether it's _|_ or not, rather than entering it? Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From andrewcoppin at btinternet.com Fri May 8 17:37:32 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri May 8 17:22:49 2009 Subject: [Haskell-cafe] GC In-Reply-To: References: <87fxfll3ad.fsf@forno.us><4A02B215.4060902@gmail.com> <4A033E07.1080102@btinternet.com><200905072221.41786.daniel.is.fischer@web.de> <4A036FB7.4070307@freegeek.org> Message-ID: <4A04A61C.7010107@btinternet.com> John Lask wrote: > on the other hand a function to release pool memory to the OS down to > the current active level should (I hope) be easily implementable, and > quickly incorporated into application where required, whereas arriving > at one or more automatic deallocation policies would most likely > require some analysis/trial and error. I would suggest that trying to do this "automatically" in a way that is optimal for all applications requires some fairly serious heuristics. OTOH, for many Haskell programs it isn't a problem in the first place. (E.g., if you write something like Darcs which only ever runs for a few seconds, you barely need GC in the first place.) I'm just thinking, the application writer probably knows more about their specific program than the compiler designers do, so it would be nice to be able to provide hints to the RTS. (Still, until somebody implements it, I don't know how hard it is to actually decide when to use such a feature...) From dons at galois.com Fri May 8 18:14:12 2009 From: dons at galois.com (Don Stewart) Date: Fri May 8 18:02:54 2009 Subject: [Haskell-cafe] is value evaluated? In-Reply-To: <4A03D4ED.80603@functor.nl> References: <20090508044919.GA13362@ece.utexas.edu> <4A03D4ED.80603@functor.nl> Message-ID: <20090508221412.GG3755@whirlpool.galois.com> Andy Gill has been advocating programmatic access to the 'is evaluated' status bit for years now. 'seq' becomes cheaper, and we can write operational properties/assertions about strictness. -- Don jochem: > Nikhil Patil wrote: > > Hi, > > > > I am curious to know if there is a function in Haskell to find if a > certain > > value has already been evaluated. The function I need would have the type: > > > >> (?!) :: a -> Bool > > I will call this function `evaluated', since it is not a binary operator. > > The existence of such a function would violate referential transparency. > > What would the value of > ( evaluated (fibs !! 100), evaluated (fibs !! 100) ) > be ? Suppose that I first print the `fst' of this tuple, then print the > 101st Fibonacci nummber, and then print the `snd' of this tuple. By lazy > evaluation, one would expect that this yields > > False > > True > > but this violates referential transparency. > > Cheers, > -- > Jochem Berndsen | jochem@functor.nl > GPG: 0xE6FABFAB > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From thomas.dubuisson at gmail.com Fri May 8 19:22:19 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Fri May 8 19:07:34 2009 Subject: [Haskell-cafe] Simulation and GHC Thread Scheduling Message-ID: <4c44d90b0905081622y20f0d442vb6d47ad1b6ef91de@mail.gmail.com> All, I have a simple Haskell P2P library that I've been playing with in simulations of 20 to 600 nodes. To run the simulation there is a Haskell thread (forkIO) for every node in the system, one that starts up all the nodes and prints the info (so prints aren't mangled), and one that acts as the router. Before its mentioned - I understand the best way forward would be to refactor the code into IO-less 'algorithm' sections and other sections that perform the needed IO when I'm not simulating. I know this would allow me to declare what order each node runs in and would free me from the scheduler. I'd like to do that if its practical... but! None-the-less, here I am saying that there are many interesting little simulations that could be done without refactoring and the correctness isn't altered by the order of operations (not if the nodes behave properly, the slight variation is actually a good test). What I would like to know is are there any plans for GHC to incorporate user-definable scheduler? It would be useful in numerous instance beyond this poor example; I know user scheduling was briefly mentioned in Li's paper but haven't seen or heard of any interest from others since then. Thomas From monnier at iro.umontreal.ca Fri May 8 21:55:53 2009 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Fri May 8 21:41:20 2009 Subject: [Haskell-cafe] Re: Why is Bool no instance of Num and Bits? References: <4A044379.1020406@web.de> <4A045711.5040809@kent.ac.uk> <792C0766-EF78-4083-8716-A2F65C2F9C3F@ece.cmu.edu> <200905082049.20032.daniel.is.fischer@web.de> Message-ID: > "[...] unsafe [PerformIO ...]" looks safer to me. Hmmm.... Stefan From monnier at iro.umontreal.ca Fri May 8 21:58:14 2009 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Fri May 8 21:50:17 2009 Subject: [Haskell-cafe] Re: Darcs as undo/redo system? References: Message-ID: > I have thought about applications of patch theory like this as well. > I could imagine applying it to the undo stack in GIMP. Allowing you > to undo things on different layers. I think one of the things you Don't know about the GIMP, but in Emacs, you can select a region of text and undo just the changes in that region. Stefan From chak at cse.unsw.edu.au Fri May 8 22:20:24 2009 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Fri May 8 22:05:42 2009 Subject: [Haskell-cafe] Generating Haskell with associated types (and kind annotations) In-Reply-To: References: Message-ID: <35A90F1F-E925-4E33-91B5-046235053F81@cse.unsw.edu.au> Hi Dan, > I was wondering whether anyone had any suggestions on a good way to > generate repetitive code with associated types and kind annotations. > I'd like to use TH but as far as I understand, it doesn't support this > yet (I think associated types are in HEAD but not kinds), I implemented type families (including associated types) and kinds for TH in the HEAD. If there is anything missing that prevents you from using it, please let me know and I'll have a look at it. Manuel From john at n-brain.net Sat May 9 00:22:36 2009 From: john at n-brain.net (John A. De Goes) Date: Sat May 9 00:08:27 2009 Subject: [Haskell-cafe] Darcs as undo/redo system? In-Reply-To: <87bpq3gzfs.wl%jeremy@n-heptane.com> References: <87bpq3gzfs.wl%jeremy@n-heptane.com> Message-ID: <3E6A8195-D289-4287-AE8A-1C771DA1E5E6@n-brain.net> Una Merge does real-time merging and has per user undo. And it can do lots of stuff that seems darcs-like, though I don't know enough about darcs to say for sure (e.g. moving a user's own edits after other edits). http://www.n-brain.net/una_merge.html Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On May 8, 2009, at 1:35 PM, Jeremy Shaw wrote: > At Fri, 8 May 2009 17:33:25 +0200, > Peter Verswyvelen wrote: >> >> [1 ] >> [1.1 ] >> If you work with a text editor like Microsoft Visual Studio (maybe >> also >> Eclipse, don't know), each text editor has its own undo/redo history. >> However, when you perform refactoring - like renaming a function - >> this >> becomes an undo/redo on multiple files together, so in a sense >> these changes >> are part of a global history. > > If you read this paper, you will find an undo system for a > colloborative editor complete with a theory that looks like a > primitive version of darcs patch theory (complete with the dreaded > merge bug of darcs 1): > > Undoing actions in collaborative work: Framework and experience by > Prakash and Knister > http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.48.6443&rep=rep1&type=pdf > > You will probably find these papers informative as well: > > Recognizing creative needs in user interface design by Terry and > Mynatt > http://www.cc.gatech.edu/fce/ecl/projects/openEnded/pubs/creativeInterfaces-creativecog2002.pdf > > A Selective Undo Mechanism for Graphical User Interfaces Based On > Command Objects (1994) by Thomas Berlage > http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.31.755 > > Flexible Conflict Detection and Management In Collaborative > Applications (1997) by Keith Edwards > http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.49.5439 > > Undo Any Operation at Any Time in Group Editors (2000) by Chengzheng > Sun > http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.32.6266 > > And, of course, you can use citeseer to find more papers that > reference those. > > - jeremy > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From lennart at augustsson.net Sat May 9 01:52:57 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Sat May 9 01:38:41 2009 Subject: [Haskell-cafe] is value evaluated? In-Reply-To: <20090508221412.GG3755@whirlpool.galois.com> References: <20090508044919.GA13362@ece.utexas.edu> <4A03D4ED.80603@functor.nl> <20090508221412.GG3755@whirlpool.galois.com> Message-ID: But testing for something being evaluated has to be in the IO monad, or else you're going to break the semantics. On Fri, May 8, 2009 at 4:14 PM, Don Stewart wrote: > Andy Gill has been advocating programmatic access to the 'is evaluated' > status bit for years now. 'seq' becomes cheaper, and we can write > operational properties/assertions about strictness. > > -- Don > > > jochem: >> Nikhil Patil wrote: >> > Hi, >> > >> > I am curious to know if there is a function in Haskell to find if a >> certain >> > value has already been evaluated. The function I need would have the type: >> > >> >> (?!) :: a -> Bool >> >> I will call this function `evaluated', since it is not a binary operator. >> >> The existence of such a function would violate referential transparency. >> >> What would the value of >> ( evaluated (fibs !! 100), evaluated (fibs !! 100) ) >> be ? Suppose that I first print the `fst' of this tuple, then print the >> 101st Fibonacci nummber, and then print the `snd' of this tuple. By lazy >> evaluation, one would expect that this yields >> >> False >> >> True >> >> but this violates referential transparency. >> >> Cheers, >> -- >> Jochem Berndsen | jochem@functor.nl >> GPG: 0xE6FABFAB >> _______________________________________________ >> 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 deduktionstheorem at web.de Sat May 9 02:30:14 2009 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Sat May 9 02:16:22 2009 Subject: [Haskell-cafe] Why is Bool no instance of Num and Bits? In-Reply-To: <404396ef0905080904i197a79b2k15fe145b622756d8@mail.gmail.com> References: <4A044379.1020406@web.de> <16442B752A06A74AB4D9F9A5FF076E4B01ABAAE9@ELON17P32001A.csfb.cs-group.com> <404396ef0905080851t2b74d53y15bfda6c16c31cdd@mail.gmail.com> <4A045711.5040809@kent.ac.uk> <404396ef0905080904i197a79b2k15fe145b622756d8@mail.gmail.com> Message-ID: <4A0522F6.5090409@web.de> Neil Mitchell wrote: > > [...] > > Which is a shame, having Bits on Bool seems entirely logical, having > Num a superclass of Bits seems a little less clear. > There are two default implementations in Bits bit i = 1 `shiftL` i x `testBit` i = (x .&. bit i) /= 0 which rely on Num (and on the fact that 0 ~= 0..0 and 1 ~= 0..01, which doesn't have to be the case in all Num instances?). But is that worth having Num as superclass? When declaring in instance for Bits you have to implement at least 8 functions anyway so these two IMHO don't really make a difference, do they? //Stephan -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From dagit at codersbase.com Sat May 9 03:06:46 2009 From: dagit at codersbase.com (Jason Dagit) Date: Sat May 9 02:52:05 2009 Subject: [Haskell-cafe] GC In-Reply-To: <4A04A61C.7010107@btinternet.com> References: <87fxfll3ad.fsf@forno.us> <4A02B215.4060902@gmail.com> <4A033E07.1080102@btinternet.com> <200905072221.41786.daniel.is.fischer@web.de> <4A036FB7.4070307@freegeek.org> <4A04A61C.7010107@btinternet.com> Message-ID: On Fri, May 8, 2009 at 2:37 PM, Andrew Coppin wrote: > John Lask wrote: > >> on the other hand a function to release pool memory to the OS down to the >> current active level should (I hope) be easily implementable, and quickly >> incorporated into application where required, whereas arriving at one or >> more automatic deallocation policies would most likely require some >> analysis/trial and error. >> > > I would suggest that trying to do this "automatically" in a way that is > optimal for all applications requires some fairly serious heuristics. > > OTOH, for many Haskell programs it isn't a problem in the first place. > (E.g., if you write something like Darcs which only ever runs for a few > seconds, you barely need GC in the first place.) That's not entirely true. Darcs has a fair number of operations that stream data and hence work well because the RTS can recycle the memory and keep the usage at a constant. I think I see your point and agree in principle though. A similar argument can be applied to laziness. Often times you end up evaluating most or all of the thunks, so what difference did it make? But, I guess it's a bit of an oversimplification in both cases. > I'm just thinking, the application writer probably knows more about their > specific program than the compiler designers do, so it would be nice to be > able to provide hints to the RTS. Definitely. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090509/a2aa7884/attachment.htm From ndmitchell at gmail.com Sat May 9 05:06:11 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sat May 9 04:51:54 2009 Subject: [Haskell-cafe] Generating Haskell with associated types (and kind annotations) In-Reply-To: References: <404396ef0905080849rb5beddcsdd9f500f1983cf6a@mail.gmail.com> Message-ID: <404396ef0905090206j467fe75sf8f94857cedb5c5d@mail.gmail.com> Hi > I guess I should write the "skeleton" of the code I want to generate, > get HSE to parse it, and then replace the parts I want to change of > the AST with what I need? Is there a nicer way (TH-like?) to get the > modified AST into GHC than prettyprinting the AST again and asking GHC > to compile the output file? This package seems to do some of the bits you want. I've added it to my list of packages to look at in the future: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskell-src-meta Thanks Neil From ndmitchell at gmail.com Sat May 9 05:08:13 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sat May 9 04:53:28 2009 Subject: Can HLint help spot space leaks? (was: Re: [Haskell-cafe] Generating Haskell with associated types (and kind annotations)) In-Reply-To: References: Message-ID: <404396ef0905090208r74057279v723add02f9621021@mail.gmail.com> Hi Jason, > Hi Neil, > A bit off-topic, but your post reminded me: ?Does HLint currently help the > user find space leaks? ?For example, does it recommend strict folds instead > of lazy folds? ?I looked at the FAQ but this was not listed. ?I don't really > know how feasible this is. It spots when you use replicateM or mapM, but don't use the result, and should have actually used the _ versions. It doesn't spot foldl s that should be foldl' s - in general you only know that if you have the strictness information, which HLint doesn't. You could add the rule foldl ==> foldl', but it's not in general correct, so it won't be added to the default rule set. Thanks Neil From mads_lindstroem at yahoo.dk Sat May 9 05:36:26 2009 From: mads_lindstroem at yahoo.dk (Mads =?ISO-8859-1?Q?Lindstr=F8m?=) Date: Sat May 9 05:22:02 2009 Subject: [Haskell-cafe] Writing a compiler in Hakell In-Reply-To: References: <999221.11069.qm@web23707.mail.ird.yahoo.com> Message-ID: <1241861786.4762.1.camel@supermule.opasia.dk> Hi Doaitse Doaitse Swierstra wrote: > Dear Rouan, > > on > > http://www.cs.uu.nl/wiki/HUT/WebHome > > you will find a collection of tools which may help you to construct > a > compiler. As an example you will find a Tiger compiler constructed > with the uulib tools and the uuagc attribute grammar system. Tiger > is > the language used in the book series by Andrew Apple. Not that Tiger > is a great language, but the compiler contains an instance of all > the > things that have to be done when writing a compiler. > > Once you like these tools you may take a look at the UHC compiler, > which actually is a series of compilers, starting from a small > language, which is than gradually extended, both with new language > concepts and with new aspects, such as code generation, new forms of > types etc. Here you will also see that writing a compiler for a > language like Haskell is not a small endeavour. > I tried the uu-parsinglib and must admit, that I got a bit frustrated. In my rant below I may sound very negative, but that is not my intention. My intention is to give you my initial impression of the rough spots when trying uu-parsinglib, which you may (or may not) use if you want to make uu-parsinglib more newcomer friendly. First the 55 page document "Combinator Parsing: A Short Tutorial" has, in my mind, some shortcoming: * A 55 page document should have a table of contents. It helps people understand the structure, and makes the document easier to navigate. * It is not really a tutorial! Or at least, not a tutorial that gets you quickly writing parses using uu-parselib. It describes alternative implementation, why something is implemented in a particular way, how something is implemented, ... These are all good things, but not something that helps me get started. They belong in an advanced section. Or maybe it would be better with two documents, with different target audiences. Furthermore, the Tiger example is good. But please provide type signatures for all functions. The signatures may be obvious to you, but for the newcomer they may not be. When I look at the uu-parselib interface [1] it seems very sparse. Compared to Parsec, I miss a lot of the standard combinators [2]. It seems like you have to implement those combinators yourself. Finally, there is no Haddock documentation in uu-parselib. The lack of entry-level documentation and few predefined parsing combinators in uu-parselib do make for a steep learning curve. Kind regards, Mads Lindstr?m [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/uu-parsinglib [2] http://hackage.haskell.org/packages/archive/parsec/3.0.0/doc/html/Text-Parsec-Combinator.html -------------- 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/20090509/3d39e701/attachment.bin From semanticphilosopher at googlemail.com Sat May 9 07:23:24 2009 From: semanticphilosopher at googlemail.com (Neil Davies) Date: Sat May 9 07:09:19 2009 Subject: [Haskell-cafe] Simulation and GHC Thread Scheduling In-Reply-To: <4c44d90b0905081622y20f0d442vb6d47ad1b6ef91de@mail.gmail.com> References: <4c44d90b0905081622y20f0d442vb6d47ad1b6ef91de@mail.gmail.com> Message-ID: Thomas You can build your own scheduler very easily using what is already there. As with any simulation the two things that you need to capture are dependency and resource contention. Haskell does both the dependency stuff beautifully and the resource contention. Using STM you can even get nice compositional properties. All you really have to take care of is how time progresses (if that is the sort of simulation you are in to). Yes, refactor the code, choose an appropriate (monadic) framework to run it in and build a consistent logging/monitoring/measuring model into it - then things work great. Cheers Neil On 9 May 2009, at 00:22, Thomas DuBuisson wrote: > All, > I have a simple Haskell P2P library that I've been playing with in > simulations of 20 to 600 nodes. To run the simulation there is a > Haskell thread (forkIO) for every node in the system, one that starts > up all the nodes and prints the info (so prints aren't mangled), and > one that acts as the router. > > Before its mentioned - I understand the best way forward would be to > refactor the code into IO-less 'algorithm' sections and other sections > that perform the needed IO when I'm not simulating. I know this would > allow me to declare what order each node runs in and would free me > from the scheduler. I'd like to do that if its practical... but! > > None-the-less, here I am saying that there are many interesting little > simulations that could be done without refactoring and the correctness > isn't altered by the order of operations (not if the nodes behave > properly, the slight variation is actually a good test). What I would > like to know is are there any plans for GHC to incorporate > user-definable scheduler? It would be useful in numerous instance > beyond this poor example; I know user scheduling was briefly mentioned > in Li's paper but haven't seen or heard of any interest from others > since then. > > Thomas > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From applebiz89 at hotmail.com Sat May 9 07:54:13 2009 From: applebiz89 at hotmail.com (applebiz89) Date: Sat May 9 07:39:52 2009 Subject: [Haskell-cafe] haskell - main function Message-ID: <23459841.post@talk.nabble.com> Could anyone look at this segment of code; it's not compiling wondering if anyone could correct me as to why. Thanks Code: -- Film as datatype type Title = String type Director = String type Year = Int type Fan = String data Film = Film Title Director Year [Fan] -- List of films testDatabase :: [Film] testDatabase = [(Film "Casino Royale" "Martin Campbell" 2006 ["Garry", "Dave", "Zoe"]) ] becomeFan :: Title -> fanName -> [Film] -> [Film] becomeFan _ _ [] = [] becomeFan Title fanName ((Film Title Director Year fan):xs) | filmName == title = (Film Title Director Year fanName:fan) : xs | otherwise = (Film Title Director Year fan) : becomeFan Title fanName xs main :: [Film] -> IO() main db = do putStr "Hi there! what is your name: " fanName = getLine do putStr "1 = Insert film, 2 = Become a Fan, 3 = The number of fans of a film, 4 = Film released in a year, 5 = Given fan, 6 = Stop : " input = getLine x = read input :: Int if x == 1 then do putStr "Enter film title: " filmTitle <- getLine putStr "Enter director name: " filmDirector <- getLine putStr "Enter release year: " filmYear <- getLine main insertFilm [Title Director Year [Film]] else if x == 2 then do putStr "Enter film title: " filmTitle <- getLine putStr "Enter fan name: " fanName <- getLine main becomeFan [Title fanName] else if x == 3 then do putStr "Enter film title: " filmTitle <- getLine main numberOfFans [Title] else if x == 4 then do putStr "Enter film release year: " filmYear <- getLine main filmsInGivenYear [Year [Film]] else if x == 5 then do putStr "Enter the fan name: " fanName <- getLine main givenUser [fanName [Film]] else if x = 6 then return () -- View this message in context: http://www.nabble.com/haskell---main-function-tp23459841p23459841.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From applebiz89 at hotmail.com Sat May 9 08:48:12 2009 From: applebiz89 at hotmail.com (applebiz89) Date: Sat May 9 08:33:50 2009 Subject: [Haskell-cafe] haskell - main function Message-ID: <23459841.post@talk.nabble.com> Could anyone look at this segment of code; it's not compiling wondering if anyone could correct me as to why. Thanks Code: -- Film as datatype type Title = String type Director = String type Year = Int type Fan = String data Film = Film Title Director Year [Fan] -- List of films testDatabase :: [Film] testDatabase = [(Film "Casino Royale" "Martin Campbell" 2006 ["Garry", "Dave", "Zoe"]) ] becomeFan :: Title -> fanName -> [Film] -> [Film] becomeFan _ _ [] = [] becomeFan Title fanName ((Film Title Director Year fan):xs) | filmName == title = (Film Title Director Year fanName:fan) : xs | otherwise = (Film Title Director Year fan) : becomeFan Title fanName xs main :: [Film] -> IO() main db = do putStr "Hi there! what is your name: " fanName = getLine do putStr "1 = Insert film, 2 = Become a Fan, 3 = The number of fans of a film, 4 = Film released in a year, 5 = Given fan, 6 = Stop : " input = getLine x = read input :: Int if x == 1 then do putStr "Enter film title: " filmTitle <- getLine putStr "Enter director name: " filmDirector <- getLine putStr "Enter release year: " filmYear <- getLine main insertFilm [Title Director Year [Film]] else if x == 2 then do putStr "Enter film title: " filmTitle <- getLine putStr "Enter fan name: " fanName <- getLine main becomeFan [Title fanName] else if x == 3 then do putStr "Enter film title: " filmTitle <- getLine main numberOfFans [Title] else if x == 4 then do putStr "Enter film release year: " filmYear <- getLine main filmsInGivenYear [Year [Film]] else if x == 5 then do putStr "Enter the fan name: " fanName <- getLine main givenUser [fanName [Film]] else if x = 6 then return () -- View this message in context: http://www.nabble.com/haskell---main-function-tp23459841p23459841.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From nccb2 at kent.ac.uk Sat May 9 09:28:07 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Sat May 9 09:12:58 2009 Subject: [Haskell-cafe] Simulation and GHC Thread Scheduling In-Reply-To: <4c44d90b0905081622y20f0d442vb6d47ad1b6ef91de@mail.gmail.com> References: <4c44d90b0905081622y20f0d442vb6d47ad1b6ef91de@mail.gmail.com> Message-ID: <4A0584E7.1060605@kent.ac.uk> > properly, the slight variation is actually a good test). What I would > like to know is are there any plans for GHC to incorporate > user-definable scheduler? What exactly is it that you want from a user-definable scheduler? Do you want co-operative scheduling in your program, or do you want to be able to control the thread-grouping and running order in the GHC runtime? More details of your requirements would help -- I can't quite make out what you need from your email. Thanks, Neil. From jeremy at n-heptane.com Sat May 9 10:42:57 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Sat May 9 10:28:15 2009 Subject: [Haskell-cafe] haskell - main function In-Reply-To: <23459841.post@talk.nabble.com> References: <23459841.post@talk.nabble.com> Message-ID: <878wl6gwwe.wl%jeremy@n-heptane.com> At Sat, 9 May 2009 04:54:13 -0700 (PDT), applebiz89 wrote: > > > Could anyone look at this segment of code; it's not compiling wondering if > anyone could correct me as to why. Thanks There is a ton of things wrong with that code. I have attached a version that at least compiles, but there are still a bunch of things that are wrong. -------------- next part -------------- -- Film as datatype type Title = String type Director = String type Year = Int type Fan = String data Film = Film Title Director Year [Fan] -- List of films testDatabase :: [Film] testDatabase = [(Film "Casino Royale" "Martin Campbell" 2006 ["Garry","Dave", "Zoe"]) ] becomeFan :: Title -> Fan -> [Film] -> [Film] becomeFan _ _ [] = [] becomeFan title' fanName (film@(Film title director year fans) : films) | title == title' = (Film title director year (fanName:fans)) : films | otherwise = film : becomeFan title' fanName films insertFilm = undefined numberOfFans = undefined filmsInGivenYear= undefined givenUser = undefined mainLoop :: [Film] -> IO() mainLoop db = do putStr "Hi there! what is your name: " fanName <- getLine putStr "1 = Insert film, 2 = Become a Fan, 3 = The number of fans of a film, 4 = Film released in a year, 5 = Given fan, 6 = Stop : " input <- getLine let x = read input :: Int if x == 1 then do putStr "Enter film title: " filmTitle <- getLine putStr "Enter director name: " filmDirector <- getLine putStr "Enter release year: " filmYear <- fmap read getLine mainLoop $ insertFilm (Film filmTitle filmDirector filmYear []) db else if x == 2 then do putStr "Enter film title: " filmTitle <- getLine putStr "Enter fan name: " fanName <- getLine mainLoop $ becomeFan filmTitle fanName db else if x == 3 then do putStr "Enter film title: " filmTitle <- getLine mainLoop $ numberOfFans filmTitle db else if x == 4 then do putStr "Enter film release year: " filmYear <- getLine mainLoop $ filmsInGivenYear filmYear db else if x == 5 then do putStr "Enter the fan name: " fanName <- getLine mainLoop $ givenUser fanName db else if x == 6 then return () else return () main :: IO () main = mainLoop testDatabase From mads_lindstroem at yahoo.dk Sat May 9 10:57:12 2009 From: mads_lindstroem at yahoo.dk (Mads =?ISO-8859-1?Q?Lindstr=F8m?=) Date: Sat May 9 10:51:21 2009 Subject: [Haskell-cafe] haskell - main function In-Reply-To: <23459841.post@talk.nabble.com> References: <23459841.post@talk.nabble.com> Message-ID: <1241881032.8103.2.camel@supermule.opasia.dk> Hi applebiz89 wrote: > Could anyone look at this segment of code; it's not compiling wondering if > anyone could correct me as to why. Thanks > > Code: > > -- Film as datatype > type Title = String > type Director = String > type Year = Int > type Fan = String > data Film = Film Title Director Year [Fan] > > -- List of films > > testDatabase :: [Film] > testDatabase = [(Film "Casino Royale" "Martin Campbell" 2006 ["Garry", > "Dave", "Zoe"]) ] > > becomeFan :: Title -> fanName -> [Film] -> [Film] > becomeFan _ _ [] = [] > becomeFan Title fanName ((Film Title Director Year fan):xs) > | filmName == title = (Film Title Director Year fanName:fan) : xs > | otherwise = (Film Title Director Year fan) : becomeFan Title fanName xs > > main :: [Film] -> IO() > main db = > do putStr "Hi there! what is your name: " > fanName = getLine > do putStr "1 = Insert film, 2 = Become a Fan, 3 = The number of fans of > a film, 4 = Film released in a year, 5 = Given fan, 6 = Stop : " > input = getLine > x = read input :: Int > if x == 1 > then do putStr "Enter film title: " > filmTitle <- getLine > putStr "Enter director name: " > filmDirector <- getLine > putStr "Enter release year: " > filmYear <- getLine > main insertFilm [Title Director Year [Film]] > else if x == 2 > then do putStr "Enter film title: " > filmTitle <- getLine > putStr "Enter fan name: " > fanName <- getLine > main becomeFan [Title fanName] > else if x == 3 > then do putStr "Enter film title: " > filmTitle <- getLine > main numberOfFans [Title] > else if x == 4 > then do putStr "Enter film release year: " > filmYear <- getLine > main filmsInGivenYear [Year [Film]] > else if x == 5 > then do putStr "Enter the fan name: " > fanName <- getLine > main givenUser [fanName [Film]] > else if x = 6 > then return () You have an if without an else. You cannot have that. What should the program do when x /= 6. And you write "x = 6" in stead of "x == 6". But generally speaking, you want to include compiler output in "this is not compiling"-messages to haskell-cafe. Regards, Mads Lindstr?m -------------- 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/20090509/030fa4cb/attachment.bin From allbery at ece.cmu.edu Sat May 9 11:38:03 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat May 9 11:26:03 2009 Subject: [Haskell-cafe] is value evaluated? In-Reply-To: <16442B752A06A74AB4D9F9A5FF076E4B01ABAAEE@ELON17P32001A.csfb.cs-group.com> References: <20090508044919.GA13362@ece.utexas.edu><4A03C411.1090703@gmail.com> <4FF5A188-6518-47E3-B3F6-7435B0C37F16@ece.cmu.edu> <16442B752A06A74AB4D9F9A5FF076E4B01ABAAED@ELON17P32001A.csfb.cs-group.com> <26163CA5-8D58-4FBF-AB29-5FA142B4297A@ece.cmu.edu> <16442B752A06A74AB4D9F9A5FF076E4B01ABAAEE@ELON17P32001A.csfb.cs-group.com> Message-ID: On May 8, 2009, at 16:31 , Sittampalam, Ganesh wrote: > Brandon S. Allbery KF8NH wrote: >> Unless it catches exceptions itself (which strikes me as a bad idea; >> it becomes a trivial way to ignore exceptions, leading to bad >> programming practices) either they're handled inside the _|_ (in >> which case it isn't _|_ from the standpoint of our test) or in an >> outer scope (in which case our test produces _|_ from the standpoint >> of the exception handler). > > Surely it just needs to inspect the thunk to decide whether it's _|_ > or > not, rather than entering it? The point is it can never be given a thunk that is _|_ because exception handling will have either converted it to a non-_|_ or shunted past the test. And while my earlier com ent suggested that the test could conceivably itself do exception handling, you're right that all it does is inspect to see if a given thunk has been entered, so in fact exception handling shouldn't apply. In the end, when handed _|_ it can only produce False because a _|_ that has been entered cannot reach the test. -- 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/20090509/7ba35ca6/PGP.bin From duncan.coutts at worc.ox.ac.uk Sat May 9 11:40:43 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat May 9 11:27:09 2009 Subject: [Haskell-cafe] Question concerning Haskell Foundation In-Reply-To: <5ae4f2ba0905071613v510e239ek42ecb9314ceaf63f@mail.gmail.com> References: <5ae4f2ba0905071603m7ecfcd3ap3a187c34ad987043@mail.gmail.com> <20090507230744.GM31370@whirlpool.galois.com> <5ae4f2ba0905071613v510e239ek42ecb9314ceaf63f@mail.gmail.com> Message-ID: <1241883643.26616.22.camel@localhost> On Thu, 2009-05-07 at 18:13 -0500, Vasili I. Galchin wrote: > sorry should read "With Haskell Platform" > > 1) Can we still publish/push up packages to Hackage? E.g. now I am > trying to get Graham Lyle's Swish (semantic web package) cabalized. > > 2) Will Hackage go away? Hackage and the platform are complementary not in competition. In particular, Hackage is the main infrastructure for the Haskell Platform. We rely on platform packages being published on Hackage. The aim is that new quality measures that we want for platform packages to be automated in Hackage where all packages can benefit from the extra information. Duncan From duncan.coutts at worc.ox.ac.uk Sat May 9 11:48:36 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat May 9 11:35:58 2009 Subject: [Haskell-cafe] cabal parse problems In-Reply-To: <5ae4f2ba0905061737l70503256k4ca6dc0fec33208c@mail.gmail.com> References: <5ae4f2ba0905061605l7121bc58kab2f40f36c784874@mail.gmail.com> <20090506230639.GC5132@doses> <5ae4f2ba0905061612k7a13e857v4a88eec8eeaf1521@mail.gmail.com> <5ae4f2ba0905061737l70503256k4ca6dc0fec33208c@mail.gmail.com> Message-ID: <1241884116.26616.35.camel@localhost> On Wed, 2009-05-06 at 19:37 -0500, Vasili I. Galchin wrote: > are them some CLI switches I can enable in order to better determine > what "parse error" is?? The problem is that we're using a parser that has no support for producing parse errors (Text.ParserCombinators.ReadP). The only reason we're using this parser is because it's the only one in the core libraries. Packages like parsec cannot be used in Cabal because Cabal is a core library and parsec is not. For this reason we've been considering just copying another parser module into Cabal so that we can have saner (and quicker) parsing. > Kind regards, Vasili > > On Wed, May 6, 2009 at 6:12 PM, Vasili I. Galchin > wrote: > sorrily nope, Brian ... For what it's worth, Brian was right, you cannot have a trailing comma in a list field. Perhaps there was an additional error in the file that we could not see in the bit you posted. Duncan From duncan.coutts at worc.ox.ac.uk Sat May 9 11:51:56 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat May 9 11:37:55 2009 Subject: [Haskell-cafe] runhaskell CLI parameters In-Reply-To: <5ae4f2ba0905052039tbe5791j53b80863650ffee3@mail.gmail.com> References: <5ae4f2ba0905052039tbe5791j53b80863650ffee3@mail.gmail.com> Message-ID: <1241884316.26616.41.camel@localhost> On Tue, 2009-05-05 at 22:39 -0500, Vasili I. Galchin wrote: > Hello, > > I have forgotten the runhaskell CLI parameters ... sigh. In > particular I want to a "local" build of a set of of package: > > runhaskell Setup.hs configure --user??? > > I just did a "runhaskell -?" which didn't tell me a lot! You may prefer to upgrade to the 'cabal' command line program which replaces the "runhaskell Setup.hs" command line interface. Duncan From thomas.dubuisson at gmail.com Sat May 9 13:51:20 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Sat May 9 13:39:49 2009 Subject: [Haskell-cafe] Simulation and GHC Thread Scheduling In-Reply-To: <4A0584E7.1060605@kent.ac.uk> References: <4c44d90b0905081622y20f0d442vb6d47ad1b6ef91de@mail.gmail.com> <4A0584E7.1060605@kent.ac.uk> Message-ID: <4c44d90b0905091051j4c95853g3b0a9f7b5c8071bc@mail.gmail.com> On Sat, May 9, 2009 at 6:28 AM, Neil Brown wrote: > >> properly, the slight variation is actually a good test). ?What I would >> like to know is are there any plans for GHC to incorporate >> user-definable scheduler? > > What exactly is it that you want from a user-definable scheduler? ?Do you > want co-operative scheduling in your program, or do you want to be able to > control the thread-grouping and running order in the GHC runtime? ?More > details of your requirements would help -- I can't quite make out what you > need from your email. I would like to alter the running order. For example, the router thread should be ran in between every other thread - its the other threads goal in life to send messages so there's probably one ready. Additionally, the older threads should gradually become higher priority (so they run more frequently and/or for longer than new threads). As I acknowledged, this simulation is a poor example, but what this would give me is a bias toward the nodes in the DHT and away from the hundreds of nodes sending join messages that will have high contention and be dropped (there will always be progress, but as with STM there is lots of retrying involved). Thomas From nowgate at yahoo.com Sat May 9 15:31:20 2009 From: nowgate at yahoo.com (michael rice) Date: Sat May 9 15:16:41 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? Message-ID: <727441.97135.qm@web31106.mail.mud.yahoo.com> Why doesn't this work? Michael ================ data Maybe a = Nothing | Just a instance Monad Maybe where ??? return???????? = Just ??? fail?????????? = Nothing ??? Nothing? >>= f = Nothing ??? (Just x) >>= f = f x ?? ? instance MonadPlus Maybe where ??? mzero???????????? = Nothing ??? Nothing `mplus` x = x ??? x `mplus` _?????? = x ================ [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> Just 3 >>= (1+) :1:0: ??? No instance for (Num (Maybe b)) ????? arising from a use of `it' at :1:0-14 ??? Possible fix: add an instance declaration for (Num (Maybe b)) ??? In the first argument of `print', namely `it' ??? In a stmt of a 'do' expression: print it Prelude> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090509/2a559830/attachment.htm From ganesh.sittampalam at credit-suisse.com Sat May 9 15:50:08 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Sat May 9 15:35:38 2009 Subject: [Haskell-cafe] is value evaluated? In-Reply-To: References: <20090508044919.GA13362@ece.utexas.edu><4A03C411.1090703@gmail.com> <4FF5A188-6518-47E3-B3F6-7435B0C37F16@ece.cmu.edu> <16442B752A06A74AB4D9F9A5FF076E4B01ABAAED@ELON17P32001A.csfb.cs-group.com> <26163CA5-8D58-4FBF-AB29-5FA142B4297A@ece.cmu.edu> <16442B752A06A74AB4D9F9A5FF076E4B01ABAAEE@ELON17P32001A.csfb.cs-group.com> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B01ABAAF1@ELON17P32001A.csfb.cs-group.com> Brandon S. Allbery KF8NH wrote: > On May 8, 2009, at 16:31 , Sittampalam, Ganesh wrote: >> Brandon S. Allbery KF8NH wrote: >>> Unless it catches exceptions itself (which strikes me as a bad idea; >>> it becomes a trivial way to ignore exceptions, leading to bad >>> programming practices) either they're handled inside the _|_ (in >>> which case it isn't _|_ from the standpoint of our test) or in an >>> outer scope (in which case our test produces _|_ from the standpoint >>> of the exception handler). >> >> Surely it just needs to inspect the thunk to decide whether it's _|_ >> or not, rather than entering it? > > > The point is it can never be given a thunk that is _|_ because > exception handling will have either converted it to a non-_|_ or > shunted past the test. You can set up a thunk in one place, enter it wrapped in a catch in another place, and then inspect it in a third place, e.g. (somewhat pseudo-code): do let x = if 1==1 then error "foo" else 3 y <- catch (evaluate x) (\_ -> 2) b <- isEvaluated x Cheers, Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From thomas.dubuisson at gmail.com Sat May 9 16:17:54 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Sat May 9 16:03:09 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <727441.97135.qm@web31106.mail.mud.yahoo.com> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> Message-ID: <4c44d90b0905091317h4b2f92daje9b3022463b2cb7d@mail.gmail.com> Because you're looking for: Just 3 >>= return . (+1) or more simply Just 3 >>= Just . (+1) or more generally: return 3 >>= return . (+1) The second argument of (>>=) is supposed to be of type (Monad m => a -> m b) but (+1) ishe of type (Num a => a -> a). Wre is the monad in that? Thomas On Sat, May 9, 2009 at 12:31 PM, michael rice wrote: > Why doesn't this work? > > Michael > > ================ > > data Maybe a = Nothing | Just a > > instance Monad Maybe where > ??? return???????? = Just > ??? fail?????????? = Nothing > ??? Nothing? >>= f = Nothing > ??? (Just x) >>= f = f x > > instance MonadPlus Maybe where > ??? mzero???????????? = Nothing > ??? Nothing `mplus` x = x > ??? x `mplus` _?????? = x > > ================ > > [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> Just 3 >>= (1+) > > :1:0: > ??? No instance for (Num (Maybe b)) > ????? arising from a use of `it' at :1:0-14 > ??? Possible fix: add an instance declaration for (Num (Maybe b)) > ??? In the first argument of `print', namely `it' > ??? In a stmt of a 'do' expression: print it > Prelude> > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From rendel at cs.au.dk Sat May 9 16:18:41 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Sat May 9 16:04:34 2009 Subject: [Haskell-cafe] haskell - main function In-Reply-To: <23459841.post@talk.nabble.com> References: <23459841.post@talk.nabble.com> Message-ID: <4A05E521.2030903@cs.au.dk> applebiz89 wrote: > becomeFan :: Title -> fanName -> [Film] -> [Film] > becomeFan _ _ [] = [] > becomeFan Title fanName ((Film Title Director Year fan):xs) > | filmName == title = (Film Title Director Year fanName:fan) : xs > | otherwise = (Film Title Director Year fan) : becomeFan Title fanName xs In the type signature, you have to use types. In other words, use "Fan" instead of "fanName" in the first line. Variables have to begin with a lowercase letter. In other words, use "title", "director", "year" instead of "Title", "Director", "Year". Regarding the IO: I still propose to get your pure functions to work first, then worry about IO. You can test your code by loading it into ghci. > ghci nameofmyfile.hs If everything works (i.e. no compile errors), you can call your functions at the prompt: > becomeFan "Casine Royale" "apple", testDatabase Now ghci should answer with something like the following: [(Film "Casino Royale" "Martin Campbell" 2006 ["apple", "Garry", "Dave", "Zoe"])] This way, you can test your stuff while working on it. Tillmann From pumpkingod at gmail.com Sat May 9 16:21:01 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Sat May 9 16:06:15 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <727441.97135.qm@web31106.mail.mud.yahoo.com> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> Message-ID: I think you're looking for fmap/liftM here. The type of >>= is: (>>=) :: (Monad m) => m a -> (a -> m b) -> m b so it's trying to make your function (1+) return m b, which in this case should be a Maybe. Clearly, (1+) doesn't return a Maybe, so it breaks. Another options is to do return . (1+) to lift the function into Maybe, but that might be a little much. On Sat, May 9, 2009 at 3:31 PM, michael rice wrote: > Why doesn't this work? > > Michael > > ================ > > data Maybe a = Nothing | Just a > > instance Monad Maybe where > ??? return???????? = Just > ??? fail?????????? = Nothing > ??? Nothing? >>= f = Nothing > ??? (Just x) >>= f = f x > > instance MonadPlus Maybe where > ??? mzero???????????? = Nothing > ??? Nothing `mplus` x = x > ??? x `mplus` _?????? = x > > ================ > > [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> Just 3 >>= (1+) > > :1:0: > ??? No instance for (Num (Maybe b)) > ????? arising from a use of `it' at :1:0-14 > ??? Possible fix: add an instance declaration for (Num (Maybe b)) > ??? In the first argument of `print', namely `it' > ??? In a stmt of a 'do' expression: print it > Prelude> > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From lemming at henning-thielemann.de Sat May 9 16:21:21 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat May 9 16:06:38 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <727441.97135.qm@web31106.mail.mud.yahoo.com> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> Message-ID: On Sat, 9 May 2009, michael rice wrote: > Prelude> Just 3 >>= (1+) fmap (1+) (Just 3) or Just 3 >>= return . (1+) or, with consistent order of functions return . (1+) =<< Just 3 From nccb2 at kent.ac.uk Sat May 9 16:24:19 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Sat May 9 16:08:34 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <727441.97135.qm@web31106.mail.mud.yahoo.com> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> Message-ID: <4A05E673.7020704@kent.ac.uk> Hi, (1+) :: Num a => a -> a For the bind operator, you need something of type a -> Maybe b on the RHS, not simply a -> a. You want one of these instead: fmap (1+) (Just 3) liftM (1+) (Just 3) Alternatively, you may find it useful to define something like: (>>*) = flip liftM so that you can write: Just 3 >>* (1+) which bears a closer resemblance to the bind notation. Thanks, Neil. michael rice wrote: > Why doesn't this work? > > Michael > > ================ > > data Maybe a = Nothing | Just a > > instance Monad Maybe where > return = Just > fail = Nothing > Nothing >>= f = Nothing > (Just x) >>= f = f x > > instance MonadPlus Maybe where > mzero = Nothing > Nothing `mplus` x = x > x `mplus` _ = x > > ================ > > [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> Just 3 >>= (1+) > > :1:0: > No instance for (Num (Maybe b)) > arising from a use of `it' at :1:0-14 > Possible fix: add an instance declaration for (Num (Maybe b)) > In the first argument of `print', namely `it' > In a stmt of a 'do' expression: print it > Prelude> > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From allbery at ece.cmu.edu Sat May 9 16:30:44 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat May 9 16:16:45 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <727441.97135.qm@web31106.mail.mud.yahoo.com> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> Message-ID: <1A418612-6B23-4494-AEAE-7428E0B38027@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/20090509/dcbbb099/PGP.bin From rendel at cs.au.dk Sat May 9 16:36:49 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Sat May 9 16:22:42 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <727441.97135.qm@web31106.mail.mud.yahoo.com> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> Message-ID: <4A05E961.2080909@cs.au.dk> michael rice wrote: > Prelude> Just 3 >>= (1+) Let's check the types. Prelude> :t (>>=) (>>=) :: (Monad m) => m a -> (a -> m b) -> m b Prelude> :t Just 3 Just 3 :: (Num t) => Maybe t Prelude> :t (1 +) (1 +) :: (Num a) => a -> a Renaming the variables in the type of (1 +) gives: (1 +) :: (Num c) => c -> c Since (Just 3) is the first argument of (>>=), we have to unify the types (Maybe t) and (m a). This leads to: m = Maybe t = a Since (1 +) is the second argument of (>>=), we have to unify the types (c -> c) and (a -> m b). This leads to: c = a = m b Since we haven't found any inconsistencies, typechecking succeeded, and we instantiate the types of Just 3, (>>=) and (1 +) to the following types by applying the substituations we found. Just 3 :: Num (Maybe b) => Maybe (Maybe b) (1 +) :: Num (Maybe b) => Maybe b -> Maybe b (>>=) :: Monad Maybe => Maybe (Maybe b) -> (Maybe b -> Maybe b) -> Maybe b And the type of the whole expression is accordingly: Just 3 >>= (1 +) :: (Monad Maybe, Num (Maybe b)) => Maybe b Now ghc looks at the constraints, figures out that Monad Maybe is fine, and complains about Num (Maybe b). Try the fmap function instead, it has the following type: Prelude> :t fmap fmap :: (Functor f) => (a -> b) -> f a -> f b Since every self-respecting Monad is also a Functor, you can use fmap (1 +) (Just 3). Now (a -> b) is unified with (Num a => a -> a), so that the overall type of the function is (Num a => Maybe a) as you would expect. Tillmann From vasyl.pasternak at gmail.com Sat May 9 16:37:43 2009 From: vasyl.pasternak at gmail.com (Vasyl Pasternak) Date: Sat May 9 16:22:56 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <727441.97135.qm@web31106.mail.mud.yahoo.com> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> Message-ID: <8feb08f70905091337k2639bc84wbfb26d76a5598f29@mail.gmail.com> Hi, Haskell expects the function with type (a -> m b) in the right side of (>>=), but you put there function with type (a -> a): try: :t (Just 3 >>=) (Just 3 >>=) :: (Num a) => (a -> Maybe b) -> Maybe b and: :t (1+) (1+) :: (Num a) => a -> a You should put (1+) into Maybe monad, just do return.(1+), so Just 3 >>= return . (1+) will return `Just 4` -- Best regards, Vasyl Pasternak 2009/5/9 michael rice > Why doesn't this work? > > Michael > > ================ > > data Maybe a = Nothing | Just a > > instance Monad Maybe where > return = Just > fail = Nothing > Nothing >>= f = Nothing > (Just x) >>= f = f x > > instance MonadPlus Maybe where > mzero = Nothing > Nothing `mplus` x = x > x `mplus` _ = x > > ================ > > [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> Just 3 >>= (1+) > > :1:0: > No instance for (Num (Maybe b)) > arising from a use of `it' at :1:0-14 > Possible fix: add an instance declaration for (Num (Maybe b)) > In the first argument of `print', namely `it' > In a stmt of a 'do' expression: print it > Prelude> > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090509/2cee2ab1/attachment.htm From alexander.dunlap at gmail.com Sat May 9 16:42:29 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Sat May 9 16:28:02 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <727441.97135.qm@web31106.mail.mud.yahoo.com> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> Message-ID: <57526e770905091342w4fbc0d01hdbb3988491954465@mail.gmail.com> On Sat, May 9, 2009 at 12:31 PM, michael rice wrote: > Why doesn't this work? > > Michael > > ================ > > data Maybe a = Nothing | Just a > > instance Monad Maybe where > ??? return???????? = Just > ??? fail?????????? = Nothing > ??? Nothing? >>= f = Nothing > ??? (Just x) >>= f = f x > > instance MonadPlus Maybe where > ??? mzero???????????? = Nothing > ??? Nothing `mplus` x = x > ??? x `mplus` _?????? = x > > ================ > > [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> Just 3 >>= (1+) > > :1:0: > ??? No instance for (Num (Maybe b)) > ????? arising from a use of `it' at :1:0-14 > ??? Possible fix: add an instance declaration for (Num (Maybe b)) > ??? In the first argument of `print', namely `it' > ??? In a stmt of a 'do' expression: print it > Prelude> > The type of (>>=) is (>>=) :: m a -> (a -> m b) -> m b For the Maybe monad, that specializes to (>>=) :: Maybe a -> (a -> Maybe b) -> Maybe b But when you say Just 3 >>= (+1) this desugars to (>>=) (Just 3) (\x -> x + 1) but the second argument to (>>=) that you have given has the type (\x -> x + 1) :: Num a => a -> a, whereas it needs to return a type of Maybe a to fit the type signature. What you probably want is Just 3 >>= (Just . (+1)) so the second function returns a Maybe value. A nicer way of writing this is fmap (+1) (Just 3), which uses the Functor class. Intuitively, the fmap function applies a function to the inside of a container. All monads can be defined as Functors as well; all Monads in the standard libraries have their functor instances defined. Hope that helps you. Alex From nenekotan at gmail.com Sat May 9 16:46:57 2009 From: nenekotan at gmail.com (Bas van Gijzel) Date: Sat May 9 16:32:13 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <727441.97135.qm@web31106.mail.mud.yahoo.com> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> Message-ID: Hey Michael, If you would look at the type of >>=, it would give (>>=) :: (Monad m) => m a -> (a -> m b) -> m b and specifically in your case: (>>=) :: Maybe a -> (a -> Maybe b) -> Maybe b You are applying Just 3 as first argument, which is correct, but then supply a partially applied function (1+) which is of type Num a => a -> a, while it should be a -> Maybe b. What are you expecting as result? You cannot pull something out of a monad using a bind operator. Maybe you meant something like this? (Just 3) >>= \x -> return (x + 1) Notice how Just 3 is just the Maybe a argument, and \x -> return (x + 1) is the (a -> Maybe b) argument, finally delivering a Just 4 (of type Maybe b). (This is the same as do x <- Just 3 return (x + 1) ) Oh and btw, fail should take an argument (the error string). Good luck, Bas van Gijzel On Sat, May 9, 2009 at 9:31 PM, michael rice wrote: > Why doesn't this work? > > Michael > > ================ > > data Maybe a = Nothing | Just a > > instance Monad Maybe where > return = Just > fail = Nothing > Nothing >>= f = Nothing > (Just x) >>= f = f x > > instance MonadPlus Maybe where > mzero = Nothing > Nothing `mplus` x = x > x `mplus` _ = x > > ================ > > [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> Just 3 >>= (1+) > > :1:0: > No instance for (Num (Maybe b)) > arising from a use of `it' at :1:0-14 > Possible fix: add an instance declaration for (Num (Maybe b)) > In the first argument of `print', namely `it' > In a stmt of a 'do' expression: print it > Prelude> > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090509/c939c494/attachment.htm From miguelimo38 at yandex.ru Sat May 9 16:54:30 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Sat May 9 16:39:56 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <727441.97135.qm@web31106.mail.mud.yahoo.com> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> Message-ID: <68DDBBCE-40B8-4E62-8B79-0279483AE18D@yandex.ru> Types. (>>=) :: Monad m => m a -> (a -> m b) -> m b (1+) :: Num a => a -> a So, the typechecker deduces that 1) "a" is the same as "m b", and 2) "a" (and "m b", therefore) must be of class "Num" Now, Just 3 :: Num t => Maybe t and the typechecker learns from that that "m a" must be the same as "Maybe t", with "t" being of class "Num". This leads to two observations: 3) "m" is "Maybe", and 4) "a" is of class "Num" - the same as (2) above Now, from (1) and (3) it follows that "a" is the same as "Maybe b". (2) lead than to "Maybe b" being of class "Num" - but GHCi doesn't have this instance, and complains. What you've probably meant is something like Just 3 >>= \x -> return (x + 1) or, equivalently, liftM (+1) $ Just 3 On 9 May 2009, at 23:31, michael rice wrote: > Why doesn't this work? > > Michael > > ================ > > data Maybe a = Nothing | Just a > > instance Monad Maybe where > return = Just > fail = Nothing > Nothing >>= f = Nothing > (Just x) >>= f = f x > > instance MonadPlus Maybe where > mzero = Nothing > Nothing `mplus` x = x > x `mplus` _ = x > > ================ > > [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> Just 3 >>= (1+) > > :1:0: > No instance for (Num (Maybe b)) > arising from a use of `it' at :1:0-14 > Possible fix: add an instance declaration for (Num (Maybe b)) > In the first argument of `print', namely `it' > In a stmt of a 'do' expression: print it > Prelude> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From mad.one at gmail.com Sat May 9 16:56:23 2009 From: mad.one at gmail.com (Austin Seipp) Date: Sat May 9 16:41:44 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <727441.97135.qm@web31106.mail.mud.yahoo.com> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> Message-ID: <1241902438-sup-14@existential.local> Excerpts from michael rice's message of Sat May 09 14:31:20 -0500 2009: > Why doesn't this work? > > Michael > > ================ > > data Maybe a = Nothing | Just a > > instance Monad Maybe where > ??? return???????? = Just > ??? fail?????????? = Nothing > ??? Nothing? >>= f = Nothing > ??? (Just x) >>= f = f x > ?? ? > instance MonadPlus Maybe where > ??? mzero???????????? = Nothing > ??? Nothing `mplus` x = x > ??? x `mplus` _?????? = x > > ================ > > [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> Just 3 >>= (1+) > > :1:0: > ??? No instance for (Num (Maybe b)) > ????? arising from a use of `it' at :1:0-14 > ??? Possible fix: add an instance declaration for (Num (Maybe b)) > ??? In the first argument of `print', namely `it' > ??? In a stmt of a 'do' expression: print it > Prelude> > Look at the types: Prelude> :t (>>=) (>>=) :: (Monad m) => m a -> (a -> m b) -> m b Prelude> :t (+1) (+1) :: (Num a) => a -> a Prelude> The return type of '(+1)' in this case should be 'm b' but it instead only returns 'b'. If we tag a return on there, it will work fine: Prelude> Just 3 >>= return . (+1) Just 4 Prelude> Austin From daniel.is.fischer at web.de Sat May 9 17:03:32 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat May 9 16:49:21 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <727441.97135.qm@web31106.mail.mud.yahoo.com> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> Message-ID: <200905092303.33584.daniel.is.fischer@web.de> Am Samstag 09 Mai 2009 21:31:20 schrieb michael rice: > Why doesn't this work? > > Michael > [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> Just 3 >>= (1+) > > :1:0: > ??? No instance for (Num (Maybe b)) > ????? arising from a use of `it' at :1:0-14 > ??? Possible fix: add an instance declaration for (Num (Maybe b)) > ??? In the first argument of `print', namely `it' > ??? In a stmt of a 'do' expression: print it > Prelude> The type of (>>=) is Monad m => m a -> (a -> m b) -> m b, the type of (1 +) is Num n => n -> n. Using (1 +) as the second argument of (>>=), you must unify Num n => n -> n with Monad m => a -> m b the types of the arguments and results must match, so a = n m b = n = a , giving the type (Monad m, Num (m b)) => m b -> m b The first argument of (>>=) is Just 3 :: Num k => Maybe k. That must be unified with m a, giving m = Maybe and a = k. On the other hand we previously found a = m b, so in Just 3 >>= (1 +) the (1 +) has type Num (Maybe b) => Maybe b -> Maybe b and Just 3 has type Num (Maybe b) => Maybe (Maybe b). But ghci can't find an instance Num (Maybe b). You probably wanted fmap (1 +) (Just 3) ~> Just 4 From miguelimo38 at yandex.ru Sat May 9 18:03:39 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Sat May 9 17:49:07 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <1A418612-6B23-4494-AEAE-7428E0B38027@ece.cmu.edu> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> <1A418612-6B23-4494-AEAE-7428E0B38027@ece.cmu.edu> Message-ID: <716249FF-C7D3-4036-8F04-D8C3B5C50267@yandex.ru> On 10 May 2009, at 00:30, Brandon S. Allbery KF8NH wrote: > On May 9, 2009, at 15:31 , michael rice wrote: >> Prelude> Just 3 >>= (1+) > > That (a -> m b) in the middle is what's failing to typecheck. The > error is a bit obtuse because ghci is trying hard to find a way to > do what you want, so it assumes "m" is "(-> r)" (the functor/monad > representing functions, also known as the Reader monad) Ehm? What? I haven't seen the (-> r) monad anywhere near this code. From allbery at ece.cmu.edu Sat May 9 18:16:07 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat May 9 18:01:25 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <716249FF-C7D3-4036-8F04-D8C3B5C50267@yandex.ru> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> <1A418612-6B23-4494-AEAE-7428E0B38027@ece.cmu.edu> <716249FF-C7D3-4036-8F04-D8C3B5C50267@yandex.ru> Message-ID: <96F29989-B186-43CD-8E37-6EE5450C4B7D@ece.cmu.edu> On May 9, 2009, at 18:03 , Miguel Mitrofanov wrote: > On 10 May 2009, at 00:30, Brandon S. Allbery KF8NH wrote: >> On May 9, 2009, at 15:31 , michael rice wrote: >>> Prelude> Just 3 >>= (1+) >> >> That (a -> m b) in the middle is what's failing to typecheck. The >> error is a bit obtuse because ghci is trying hard to find a way to >> do what you want, so it assumes "m" is "(-> r)" (the functor/monad >> representing functions, also known as the Reader monad) > > Ehm? What? I haven't seen the (-> r) monad anywhere near this code. That's the only way I can get the error he got; if it uses Maybe as the monad then why is the Maybe on the *inside* in the error message? Clearly it bound m to something else, and ((->) r) is the only other one I can think of applying there. (Hm, I suppose it could be IO forced by the ghci context, but I didn't think it worked that way.) -- 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/20090509/47ae1bd1/PGP.bin From allbery at ece.cmu.edu Sat May 9 18:21:10 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat May 9 18:06:26 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <96F29989-B186-43CD-8E37-6EE5450C4B7D@ece.cmu.edu> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> <1A418612-6B23-4494-AEAE-7428E0B38027@ece.cmu.edu> <716249FF-C7D3-4036-8F04-D8C3B5C50267@yandex.ru> <96F29989-B186-43CD-8E37-6EE5450C4B7D@ece.cmu.edu> Message-ID: <64BBA47B-B528-43F8-A977-6EACF26B2C9D@ece.cmu.edu> On May 9, 2009, at 18:16 , Brandon S. Allbery KF8NH wrote: > That's the only way I can get the error he got; if it uses Maybe as > the monad then why is the Maybe on the *inside* in the error > message? Clearly it bound m to something else, and ((->) r) is the > only other one I can think of applying there. (Hm, I suppose it > could be IO forced by the ghci context, but I didn't think it worked > that way.) Er, clarifying: it's looking for Num (Maybe a), but the context where Num applies is inside the scope where the Maybe applies (a -> m b has been fixed at Num n => n -> m n). But the error message says ghc is trying to make *n* an instance of Num. -- 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/20090509/34113477/PGP.bin From vigalchin at gmail.com Sat May 9 18:33:16 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Sat May 9 18:18:53 2009 Subject: [Haskell-cafe] cabal parse problems In-Reply-To: <1241884116.26616.35.camel@localhost> References: <5ae4f2ba0905061605l7121bc58kab2f40f36c784874@mail.gmail.com> <20090506230639.GC5132@doses> <5ae4f2ba0905061612k7a13e857v4a88eec8eeaf1521@mail.gmail.com> <5ae4f2ba0905061737l70503256k4ca6dc0fec33208c@mail.gmail.com> <1241884116.26616.35.camel@localhost> Message-ID: <5ae4f2ba0905091533q578e0e1cscaf3f086b45c7b02@mail.gmail.com> Thanks .. very interesting on the cabal "parsers". I somehow got around my problem ... forgot how though. Vasili On Sat, May 9, 2009 at 10:48 AM, Duncan Coutts wrote: > On Wed, 2009-05-06 at 19:37 -0500, Vasili I. Galchin wrote: > > are them some CLI switches I can enable in order to better determine > > what "parse error" is?? > > The problem is that we're using a parser that has no support for > producing parse errors (Text.ParserCombinators.ReadP). The only reason > we're using this parser is because it's the only one in the core > libraries. Packages like parsec cannot be used in Cabal because Cabal is > a core library and parsec is not. > > For this reason we've been considering just copying another parser > module into Cabal so that we can have saner (and quicker) parsing. > > > Kind regards, Vasili > > > > On Wed, May 6, 2009 at 6:12 PM, Vasili I. Galchin > > wrote: > > sorrily nope, Brian ... > > For what it's worth, Brian was right, you cannot have a trailing comma > in a list field. Perhaps there was an additional error in the file that > we could not see in the bit you posted. > > Duncan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090509/06181d77/attachment.htm From thestonetable at gmail.com Sat May 9 20:00:29 2009 From: thestonetable at gmail.com (Cory Knapp) Date: Sat May 9 19:45:44 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <200905092303.33584.daniel.is.fischer@web.de> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> <200905092303.33584.daniel.is.fischer@web.de> Message-ID: <4A06191D.8000900@gmail.com> ... There have been 12 replies to this question, all of which say the same thing. I'm glad we're so happy to help, but does Just 3 >>= return . (+1) Need to be explained by 12 different people? fmap ("trying to"++) $ Just "help" -- :D Cory >> Why doesn't this work? >> >> Michael >> [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> Just 3 >>= (1+) >> >> :1:0: >> No instance for (Num (Maybe b)) >> arising from a use of `it' at :1:0-14 >> Possible fix: add an instance declaration for (Num (Maybe b)) >> In the first argument of `print', namely `it' >> In a stmt of a 'do' expression: print it >> Prelude> >> From wren at freegeek.org Sun May 10 00:23:59 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun May 10 00:09:17 2009 Subject: [Haskell] Re[2]: [Haskell-cafe] Is Haskell a Good Choice for WebApplications? (ANN: Vocabulink) In-Reply-To: <871vr0w0lo.fsf@malde.org> References: <87fxfll3ad.fsf@forno.us> <204746127.20090507001813@gmail.com> <4A036B20.4070301@freegeek.org> <871vr0w0lo.fsf@malde.org> Message-ID: <4A0656DF.7040203@freegeek.org> Ketil Malde wrote: > wren ng thornton writes: > > FWIW, the JVM also fails to release memory resources back to the > > OS. Given all the problems I've seen that one cause for long-running > > processes, I'm definitely in support of correcting any behavior like > > this in the GHC RTS. > > I'm curious what real problems arise from this? As far as I can tell, > virtual memory and overcommit ought to make this (i.e. not releasing > memory back to the OS) mostly harmless. Is this on particular systems > with different properties than your average run-of-the-mill Unix? Consider a process, A, which goes through a cycle of spawning off another process, B, and reaping its output. More specifically, A consumes a lot of memory when B is not running, but then flushes most of it before spawning B and then idles until B is done. Also B consumes a lot of memory (which is always returned to the system each time B is terminated). If A cannot return memory to the system prior to spawning B, this will cause the OS to over-commit memory, which will cause various OSes to either kill the process, start thrashing, or other Bad Things(tm). I'd have to ask my coworker which particular systems caused the most problems, but we target all of Linux, OSX, and Windows for the toolkit that includes both A and B. -- Live well, ~wren From wren at freegeek.org Sun May 10 00:44:58 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun May 10 00:30:18 2009 Subject: [Haskell-cafe] Re: OT: Languages In-Reply-To: <4A046496.8090905@googlemail.com> References: <4A046496.8090905@googlemail.com> Message-ID: <4A065BCA.7080804@freegeek.org> Kalman Noel wrote: > wren ng thornton schrieb: > > Chris Forno (jekor) wrote: > > > That being said, Esperanto, and even Japanese sentence structure perhaps > > > is not as different as an agglutinative language like German. I'll need > > > to study it more to find out. > > Actually, Japanese is agglutinative too (moreso than German is). > > I take it the above calling German agglutinative was sort of a typo, > because well, it isn't, except having many compound words. Indeed. The proliferation of compound words is noteworthy, but it's not generally considered an agglutinative language. From what (very little) German I know compounds tend to be restricted to nouns, as opposed to languages like Turkish, Japanese, Korean,... > Esperanto, on > the other hand, is usually described as agglutinative. I'll take your word for it :) -- Live well, ~wren From allbery at ece.cmu.edu Sun May 10 01:24:43 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun May 10 01:10:32 2009 Subject: [Haskell-cafe] ok, someone check me on this (type unification from the (>>=)/fmap thread) Message-ID: <08624AA3-086B-4EEF-BB10-7061ADEF37D7@ece.cmu.edu> I can't tell where I'm making the mistake here. In the thread where (>>=) and fmap were being confused, the error cited a type (Maybe a) which was supposed to be in typeclass Num. As far as I can tell, if the typechecker gets to the point where Num and Maybe are both present and (m) is Maybe, it has to (1) be focused on the (m b) part of (a -> m b), and therefore (2) must have already unified (a) and (b). But that means (m b) must unify with (Num a => a), which is unified with (b), resulting in the attempt to unify (Num a => a) with (Maybe a); since we get the error about (Maybe a) not being a Num, it must not have gotten there. But that means it can't have related Num to (m a) with (m) bound to Maybe, which is why I assumed it had unified (m) with ((->) r) instead. Can the typechecker really get the Num to the other end of (a -> m b) without also getting the (a) there? Or is it checking for the Num constraint before it has fully evaluated the type of (m b)? I thought typeclass constraints happened later than basic type unification. -- 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/20090510/87f52651/PGP.bin From miguelimo38 at yandex.ru Sun May 10 04:16:11 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Sun May 10 04:01:35 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <4A06191D.8000900@gmail.com> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> <200905092303.33584.daniel.is.fischer@web.de> <4A06191D.8000900@gmail.com> Message-ID: <7D28774C-52AD-4101-8BFB-515B5AF849FC@yandex.ru> On 10 May 2009, at 04:00, Cory Knapp wrote: > ... There have been 12 replies to this question, all of which say > the same thing. Brandon's one was different. And incorrect, which shows that this question isn't completely obvious. > I'm glad we're so happy to help, but does > > Just 3 >>= return . (+1) > > Need to be explained by 12 different people? 1) That's how mail lists work. 2) We are just happy that Michael finally managed to present code which passes the syntax checker. To Michael: no sarcasm here. > > > fmap ("trying to"++) $ Just "help" -- :D > > Cory >>> Why doesn't this work? >>> >>> Michael >>> [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> Just 3 >>= (1+) >>> >>> :1:0: >>> No instance for (Num (Maybe b)) >>> arising from a use of `it' at :1:0-14 >>> Possible fix: add an instance declaration for (Num (Maybe b)) >>> In the first argument of `print', namely `it' >>> In a stmt of a 'do' expression: print it >>> Prelude> >>> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From Sven.Panne at aedion.de Sun May 10 07:50:08 2009 From: Sven.Panne at aedion.de (Sven Panne) Date: Sun May 10 07:35:25 2009 Subject: [Haskell-cafe] Decoupling OpenAL/ALUT packages from OpenGL In-Reply-To: <49FED28D.4060307@comp.leeds.ac.uk> References: <200905031244.04713.Sven.Panne@aedion.de> <49FED28D.4060307@comp.leeds.ac.uk> Message-ID: <200905101350.09012.Sven.Panne@aedion.de> Am Montag, 4. Mai 2009 13:33:33 schrieb David Duke: > Decoupling basic primitives for geometric modelling from OpenGL would be > useful. [...] > Even just data constructors and instances of these within Functor and > Applicative are a useful starting point. [...] I've taken a closer look at the available packages for vector math/linear algebra. They differ in a lot of respects, starting from their representations of vectors and matrices, use of the type system and its extensions, strictness, structure of their type classes, etc. This leads me to the conclusion that I should only lift the data types for vectors and matrices out of the OpenGL package, including only instances for standard type classes like Eq, Ord, Functor, etc. This means that the new package will *not* include type classes for things like scalars, vector spaces, etc. These can be defined by the other packages in their own "type class language". I really fail to see a common ground in this respect, even for basic things: Keeping things H98-compliant is a must for me, so putting things like fundeps or associated types in this new package is a no-go for me. Nevertheless, having a common set of (strict) data types for vector math will probably be very useful, even if it won't fulfill everybody's needs. What standard instances should be defined for those vectors and matrices? Things coming to mind are Eq, Ord, Show, Storable, Typeable1, Functor and Applicative. Have I missed some type classes? Regarding Functor/Applicative: The obvious instances for e.g. a 2-dimensional vertex are: data Vertex2 a = Vertex2 a a instance Functor Vertex2 where fmap f (Vertex2 x y) = Vertex2 (f x) (f y) instance Applicative Vertex2 where pure a = Vertex2 a a Vertex2 f g <*> Vertex2 x y = Vertex2 (f x) (g y) They fulfill all required laws, but are these the only possible instances? If not, are they at least the most "canonical" ones in a given sense? And finally: Does somebody have a real-world example where the Applicative instance is useful? Usages of the Functor instance are much more obvious for me. Cheers, S. From lambda-belka at yandex.ru Sun May 10 09:21:39 2009 From: lambda-belka at yandex.ru (Belka) Date: Sun May 10 09:07:11 2009 Subject: [Haskell-cafe] Classes: functional dependency (type -> value) Message-ID: <23470077.post@talk.nabble.com> Hello, communion people! I seek for your advice in a matter, where it's really hard for me to determine a good programming style. Here's the problem. I'm generalizing multiple authorization procedures to one, using class definition. (if of any interest, the code is in the end.) The problem essense is folowing: ---------------- data SomeRole = Role1 | Role2 | Role3 class SomeClass a b c | a -> b, c where f1 :: ... f2 :: ... ... fn :: ... role :: SomeRole -- <-- here is the problem I want to have a fuctional dependency from a type "a" on a value of *role*, so that I could easily "inspect" the *role* from within any other class members. Is it possible? Or do I rougly violate some style traditions? Some real code using wished feature: --------------------------------------- data AuthentificationPurpose = JustValidateInput | JustGenerateForOutput | ValidateInputAndGenerateForOutput type AuthSucceded = Bool class AuthentificationStructure t_env t_realInput t_assumption t_keySet | t_realInput -> t_assumptionInput, t_keySet where authentificationPurpose :: AuthentificationPurpose makeAssumption :: t_env -> t_realInput -> IO (Either ErrorMessage t_assumption) makeFinalKeySet :: (t_realInput, t_assumption) -> t_keySet validateRealKeySet_with_Assumed :: t_realInput -> t_keySet -> Maybe ErrorMessage tryLogTheValidKey :: t_env -> (t_realInput, t_assumption) -> IO (Maybe ErrorMessage) tryLogTheAuthTry :: t_env -> (t_realInput, t_assumption, AuthSucceded) -> IO (Maybe ErrorMessage) authentificate :: AuthentificationStructure t_env t_realInput t_assumptionInput t_keySet => t_env -> t_businessInput -> IO (Either ErrorMessage (t_assumption, t_keySet)) authentificate env realInput = do err_or_assumption <- makeAssumption env realInput case err_or_assumption of Left err_msg -> return $ Left "Error! Assumption maker failed. Lower level error message: " ++ err_msg Just assumption -> do key_set <- makeFinalKeySet (realInput, assumption) err_or_keyset1 <- case authentificationPurpose of JustGenerateForOutput -> return $ Right key_set JustValidateInput -> do mb_failure <- validateRealKeySet_with_Assumed t_realInput key_set case mb_failure of Just err_msg -> return $ Left "Error! Invalid set of auth keys. Lower level error message: " ++ err_msg Nothing -> return $ Right key_set ValidateInputAndGenerateForOutput err_or_keyset2 <- case err_or_keyset1 of Left err_msg -> return err_or_keyset1 Right key_set -> do mb_failure <- tryLogTheValidKey env (realInput, assumption) case mb_failure of Just err_msg -> return $ Left "Error! Could not log valid key. Lower level error message: " ++ err_msg Nothing -> return err_or_keyset1 mb_failure <- tryLogTheAuthTry env (realInput, assumption, isRight err_or_keyset2) case mb_failure of Just err_msg1 -> case err_or_keyset2 of Left err_msg2 -> return $ Left ("1. " ++ err_msg2 ++ "\n2. " ++ err_msg1) Right _ -> return $ Left err_msg1 Nothing -> case err_or_keyset2 of Left err_msg -> return $ Left err_msg Right key_set -> return $ Right (assumption, key_set) --------------------------------- Best regards, Belka -- View this message in context: http://www.nabble.com/Classes%3A-functional-dependency-%28type--%3E-value%29-tp23470077p23470077.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From max.rabkin at gmail.com Sun May 10 10:04:58 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Sun May 10 09:50:34 2009 Subject: [Haskell-cafe] Re: OT: Languages In-Reply-To: <4A065BCA.7080804@freegeek.org> References: <4A046496.8090905@googlemail.com> <4A065BCA.7080804@freegeek.org> Message-ID: On Sun, May 10, 2009 at 6:44 AM, wren ng thornton wrote: > Kalman Noel wrote: >> Esperanto, on >> the other hand, is usually described as agglutinative. > > I'll take your word for it :) Consider malsanulejestro (the head of a hospital): mal-san-ul-ej-estr-o (un-health-person-place-leader-noun, or leader of the place of unhealthy people). --Max From applebiz89 at hotmail.com Sun May 10 10:30:28 2009 From: applebiz89 at hotmail.com (applebiz89) Date: Sun May 10 10:15:41 2009 Subject: [Haskell-cafe] displaying conetents of a list Message-ID: <23470633.post@talk.nabble.com> I want to write a function to output the entire contents of a list. not sure of how to do so...This is my list i want to output type Title = String type Director = String type Year = Int type Fan = String data Film = Film Title Director Year [Fan] deriving Show -- List of films testDatabase :: [Film] testDatabase = [(Film "Casino Royale" "Martin Campbell" 2006 ["Garry", "Dave", "Zoe"]) ] ------- I know this isnt right but this is what I have so far listFilms :: [Film] -> [Film] listFilms (film@(Film title director year fans) : films) = putStrLn . show film I know to use show and putStrLn but I just don't know how to put them into the function correctly thank you. -- View this message in context: http://www.nabble.com/displaying-conetents-of-a-list-tp23470633p23470633.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From rendel at cs.au.dk Sun May 10 10:33:38 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Sun May 10 10:19:31 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <4A06191D.8000900@gmail.com> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> <200905092303.33584.daniel.is.fischer@web.de> <4A06191D.8000900@gmail.com> Message-ID: <4A06E5C2.5000001@cs.au.dk> Hi Cory, Cory Knapp wrote: > ... There have been 12 replies to this question, all of which say the > same thing. I'm glad we're so happy to help, but does > > Just 3 >>= return . (+1) > > Need to be explained by 12 different people? maybe eleven others have already pointed that out by now, but as far as I know, there is no way to see whether someone else is concurrently answering the same question. And I don't think that all answers were equivalent. Some answer pointed out how to correct the error, while others focused on explaining why the error arises. One answer was wrong. Tillmann From rendel at cs.au.dk Sun May 10 10:53:29 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Sun May 10 10:39:21 2009 Subject: [Haskell-cafe] Re: OT: Languages In-Reply-To: <4A065BCA.7080804@freegeek.org> References: <4A046496.8090905@googlemail.com> <4A065BCA.7080804@freegeek.org> Message-ID: <4A06EA69.5010409@cs.au.dk> wren ng thornton wrote: > Indeed. The proliferation of compound words is noteworthy, but it's not > generally considered an agglutinative language. From what (very little) > German I know compounds tend to be restricted to nouns, as opposed to > languages like Turkish, Japanese, Korean,... Yes, compounds are restricted to nouns in German. But as I understand it, agglutinative relates more to the inflection system than to the lexicon anyway. In German, inflection is usually done by adding a single suffix to the stem, and possibly altering the stem. The single suffix encodes various informations (e.g. number, gender and case for nouns) in a single morpheme. In an agglutinative language, inflection is done by adding one morpheme per information. Tillmann From miguelimo38 at yandex.ru Sun May 10 11:19:47 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Sun May 10 11:05:22 2009 Subject: [Haskell-cafe] ok, someone check me on this (type unification from the (>>=)/fmap thread) In-Reply-To: <08624AA3-086B-4EEF-BB10-7061ADEF37D7@ece.cmu.edu> References: <08624AA3-086B-4EEF-BB10-7061ADEF37D7@ece.cmu.edu> Message-ID: On 10 May 2009, at 09:24, Brandon S. Allbery KF8NH wrote: > I can't tell where I'm making the mistake here. Frankly, I can't do it either, because I don't understand what you're talking about. It seems that you have some idea of how the typechecker works, which is very different from that of mine. I've explained my view on this subject in my response to Michael, and it doesn't involve the ((->) r) monad at all. > In the thread where (>>=) and fmap were being confused, the error > cited a type (Maybe a) which was supposed to be in typeclass Num. > As far as I can tell, if the typechecker gets to the point where Num > and Maybe are both present and (m) is Maybe, it has to (1) be > focused on the (m b) part of (a -> m b), and therefore (2) must have > already unified (a) and (b). But that means (m b) must unify with > (Num a => a), which is unified with (b), resulting in the attempt to > unify (Num a => a) with (Maybe a); since we get the error about > (Maybe a) not being a Num, it must not have gotten there. But that > means it can't have related Num to (m a) with (m) bound to Maybe, > which is why I assumed it had unified (m) with ((->) r) instead. > > Can the typechecker really get the Num to the other end of (a -> m > b) without also getting the (a) there? Or is it checking for the > Num constraint before it has fully evaluated the type of (m b)? I > thought typeclass constraints happened later than basic type > unification. > > -- > 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 > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From rendel at cs.au.dk Sun May 10 11:23:00 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Sun May 10 11:08:51 2009 Subject: [Haskell-cafe] Haskell IO problem In-Reply-To: <23404351.post@talk.nabble.com> References: <23404351.post@talk.nabble.com> Message-ID: <4A06F154.1090706@cs.au.dk> Hi apple, applebiz89 wrote: > // Say I have this as my data type and list of films > data Film = Film String String Int [String] > -- List of films > > testDatabase :: [Film] > testDatabase = [(Film "Casino Royale" "Martin Campbell" 2006 ["Garry", > "Dave", "Zoe"]) ] > > // with functions such as: > > becomeFan :: String -> String -> [Film] -> [Film] > filmsInGivenYear :: Int -> [Film] -> [String] > > // I want to ask the user what function they want to use Once again, it is important to write small blocks of code first. Let's write an IO wrapper around one of the functions, e.g. around filmsInGivenYear: -- Given a films database, this operation asks the user for a year, -- and then prints the names of all the films from that year. doFilmsInGivenYear :: [Film] -> IO () doFilmsInGivenYear films = do -- an action putStrLn "which year?" -- an action which returns a result text <- getLine -- some pure computations let year = read text :: Int let answer = filmsInGivenYear year films -- an action print answer For now, we want main to be just doFilmsInGivenYear using the testDatabase: main :: IO () main = doFilmsInGivenYear films If you compile and run that program, it should ask you for a year, and then print the films of that year. Then it exists, because there are no more actions to do. If you want the program to go on asking you stuff, you can call main again: main :: IO () main = do doFilmsInGivenYear films main If you compile this program and run it, it will run forever and keep asking you about years. (Strg-C should stop it again). *After you have tried that out*, you could try to add code to main to ask the user whether she wants to stop. Tillmann PS. Please don't send questions only to me, I am not your private tutor :) Send to the list instead. PPS. It is really important to compile your program often, and/or test it with ghci. It is much easier to do one small step after another From daniel.is.fischer at web.de Sun May 10 11:39:34 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun May 10 11:25:19 2009 Subject: [Haskell-cafe] Just 3 >>= (1+)? In-Reply-To: <4A06191D.8000900@gmail.com> References: <727441.97135.qm@web31106.mail.mud.yahoo.com> <200905092303.33584.daniel.is.fischer@web.de> <4A06191D.8000900@gmail.com> Message-ID: <200905101739.34961.daniel.is.fischer@web.de> Am Sonntag 10 Mai 2009 02:00:29 schrieb Cory Knapp: > ... There have been 12 replies to this question, all of which say the > same thing. I'm glad we're so happy to help, but does > > Just 3 >>= return . (+1) > > Need to be explained by 12 different people? > > fmap ("trying to"++) $ Just "help" -- :D > > Cory > I guess it's because almost nobody saw any reply to it when writing their own, the mail server seems to be slooow on weekends. The first reply appeared in my mailbox some two hours after I posted mine. I wonder how many people have already answered your post :) From pgavin at gmail.com Sun May 10 11:43:38 2009 From: pgavin at gmail.com (Peter Gavin) Date: Sun May 10 11:28:49 2009 Subject: [Haskell-cafe] ANN: Gtk2HS 0.10.1 released Message-ID: <37df87420905100843l4352ff2fm2ca61c3df91d8125@mail.gmail.com> Hi everyone, I'd like to announce the release of Gtk2HS 0.10.1! This release includes mostly bug fixes and other small improvements. Most notably, GHC 6.10.1 is now supported. The source tarball may be downloaded from: http://sourceforge.net/project/showfiles.php?group_id=49207&package_id=42440 A Windows installer will be provided soon. Thanks to all the contributors! From bulat.ziganshin at gmail.com Sun May 10 11:52:14 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun May 10 11:37:37 2009 Subject: [Haskell-cafe] Re: [Gtk2hs-users] ANN: Gtk2HS 0.10.1 released In-Reply-To: <37df87420905100843l4352ff2fm2ca61c3df91d8125@mail.gmail.com> References: <37df87420905100843l4352ff2fm2ca61c3df91d8125@mail.gmail.com> Message-ID: <1566831531.20090510195214@gmail.com> Hello Peter, Sunday, May 10, 2009, 7:43:38 PM, you wrote: > I'd like to announce the release of Gtk2HS 0.10.1! This release > includes mostly bug fixes and other small improvements. Most notably, > GHC 6.10.1 is now supported. 6.10.2/6.10.3? -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From daniel.is.fischer at web.de Sun May 10 12:04:33 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun May 10 11:50:15 2009 Subject: [Haskell-cafe] ok, someone check me on this (type unification from the (>>=)/fmap thread) In-Reply-To: <08624AA3-086B-4EEF-BB10-7061ADEF37D7@ece.cmu.edu> References: <08624AA3-086B-4EEF-BB10-7061ADEF37D7@ece.cmu.edu> Message-ID: <200905101804.33488.daniel.is.fischer@web.de> Am Sonntag 10 Mai 2009 07:24:43 schrieb Brandon S. Allbery KF8NH: > I can't tell where I'm making the mistake here. > > In the thread where (>>=) and fmap were being confused, the error > cited a type (Maybe a) which was supposed to be in typeclass Num. As > far as I can tell, if the typechecker gets to the point where Num and > Maybe are both present and (m) is Maybe, it has to (1) be focused on > the (m b) part of (a -> m b), and therefore (2) must have already > unified (a) and (b). But that means (m b) must unify with (Num a => > a), which is unified with (b), resulting in the attempt to unify (Num > a => a) with (Maybe a); since we get the error about (Maybe a) not > being a Num, it must not have gotten there. But that means it can't > have related Num to (m a) with (m) bound to Maybe, which is why I > assumed it had unified (m) with ((->) r) instead. > > Can the typechecker really get the Num to the other end of (a -> m b) > without also getting the (a) there? Or is it checking for the Num > constraint before it has fully evaluated the type of (m b)? I thought > typeclass constraints happened later than basic type unification. Just in case it hasn't been answered yet: Just 3 >>= (1+) Just 3 :: (Num n1) => Maybe n1 (>>=) :: (Monad m) => m a -> (a -> m b) -> m b (1+) :: (Num n2) => n2 -> n2 (Just 3 >>=) :: (Num n1) => (n1 -> Maybe b) -> Maybe b Now we must unify the type of (1+) with (Just 3 >>=)'s argument's type, that is (Num n2) => n2 -> n2 with (Num n1) => n1 -> Maybe b n2 = n1 n2 = Maybe b giving (Just 3 >>=) :: (Num (Maybe b)) => (Maybe b -> Maybe b) -> Maybe b Just 3 >>= (1+) :: Num (Maybe b) => Maybe b ================================================= module MaybeNum where import Control.Monad instance Num a => Num (Maybe a) where (+) = liftM2 (+) (-) = liftM2 (-) (*) = liftM2 (*) signum = fmap signum abs = fmap abs negate = fmap negate fromInteger = Just . fromInteger ================================================= *MaybeNum> Just 3 >>= (1+) Just 4 or, weirder: ================================================= instance Num (Maybe Bool) where (+) = liftM2 (/=) (-) = (+) (*) = liftM2 (&&) signum = (`mplus` Just False) abs = signum negate = id fromInteger = Just . odd ================================================= *MaybeNum> Just 3 >>= (1+) :: Maybe Bool Just False From rendel at cs.au.dk Sun May 10 13:01:25 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Sun May 10 12:47:16 2009 Subject: [Haskell-cafe] ok, someone check me on this (type unification from the (>>=)/fmap thread) In-Reply-To: <08624AA3-086B-4EEF-BB10-7061ADEF37D7@ece.cmu.edu> References: <08624AA3-086B-4EEF-BB10-7061ADEF37D7@ece.cmu.edu> Message-ID: <4A070865.1020205@cs.au.dk> Hi, Brandon S. Allbery KF8NH wrote: > I can't tell where I'm making the mistake here. I'm not sure, but I guess you are mixing up some names. Did you make sure that all type variables are distinct before starting to unify? > ... must have already unified (a) and (b) ... Why should it unify a and b? > Can the typechecker really get the Num to the other end of (a -> m b) > without also getting the (a) there? Or is it checking for the Num > constraint before it has fully evaluated the type of (m b)? I > thought typeclass constraints happened later than basic type > unification. I think you can unify without looking at typeclass constraints at all, then apply the resulting substitutions to the original constraints. (As long as there are not functional dependencies involved, at least). Tillmann From lazycat.manatee at gmail.com Sun May 10 12:10:44 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Sun May 10 12:55:13 2009 Subject: [Haskell-cafe] Re: ANN: Gtk2HS 0.10.1 released References: <37df87420905100843l4352ff2fm2ca61c3df91d8125@mail.gmail.com> <1566831531.20090510195214@gmail.com> Message-ID: <878wl57xbv.fsf@ubuntu.domain> Bulat Ziganshin writes: > Hello Peter, > > Sunday, May 10, 2009, 7:43:38 PM, you wrote: > >> I'd like to announce the release of Gtk2HS 0.10.1! This release >> includes mostly bug fixes and other small improvements. Most notably, >> GHC 6.10.1 is now supported. > > 6.10.2/6.10.3? I think 6.10.1 compatible with 6.10.2/6.10.3 6.10.2/6.10.3 just fix some bug of 6.10.1 -- Andy From johan.tibell at gmail.com Sun May 10 13:23:20 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Sun May 10 13:08:31 2009 Subject: [Haskell-cafe] Heads up: Conflicting versions of network-2.2.1 Message-ID: <90889fe70905101023w24758332l4e2171482b4eb1a1@mail.gmail.com> Hi, The version of network-2.2.1 that shipped with GHC 6.10 differs from the one on Hackage [1]. The version that was released with GHC was never uploaded to Hackage and was never tagged in the darcs repository. When making a new release of network I forgot to check the version number on the version of network that shipped with GHC. My appologies. If you want the API additions that are present in network-2.2.1 on Hackage use network-2.2.1.1 instead to make sure that e.g. cabal-install doesn't use the version of network that comes with GHC. In the future there won't be any releases directly from the darcs repo. All releases will be made on Hackage to later be picked up by the Haskell Platform. Cheers, Johan 1. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/network-2.2.1 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090510/f6390d9c/attachment.html From haskell at brecknell.org Sun May 10 17:24:06 2009 From: haskell at brecknell.org (Matthew Brecknell) Date: Sun May 10 17:09:23 2009 Subject: [Haskell-cafe] ok, someone check me on this (type unification from the (>>=)/fmap thread) In-Reply-To: <08624AA3-086B-4EEF-BB10-7061ADEF37D7@ece.cmu.edu> References: <08624AA3-086B-4EEF-BB10-7061ADEF37D7@ece.cmu.edu> Message-ID: <1241990646.8390.6.camel@localhost> Brandon S. Allbery KF8NH wrote: > I can't tell where I'm making the mistake here. In Just 3 >>= (+1), we have, with some alpha conversions to make the unification easier to follow: Just 3 :: Num i => Maybe i -- (1) (>>=) :: m a -> (a -> m b) -> m b -- (2) (+1) :: Num n => n -> n -- (3) Unify (1) with the first argument in (2): Maybe i ~ m a m ~ Maybe -- (4) i ~ a -- (5) Unify the second argument in (2) with (3): (n -> n) ~ (a -> m b) n ~ a -- (6) n ~ m b -- (7) Substitute (4) in (7): n ~ Maybe b -- (8) But we have (Num n), so from (8), we need (Num (Maybe b)). Since there is no such instance, we get the error. Your question seems to be whether some other error should have come up first. >From (5) and (6), we get: n ~ i -- (9) And from (8): i ~ Maybe b -- (10) Again, we have (Num i), so from (10), we need (Num (Maybe b)). Same error, different route. Perhaps you are assuming that i defaults to Integer before the type-checking completes, and are therefore expecting that (10) should produce a unification error before contexts are checked? Regards, Matthew From bugfact at gmail.com Sun May 10 18:08:45 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun May 10 17:53:54 2009 Subject: [Haskell-cafe] Hoogle: converting binary .hoo into text? Message-ID: I would like to use the Hoogle text format in C#. Hoogle on Hackage comes with a bunch of binary *.hoo files. Can these be converted to text/xml? If not, is the binary format documented? I know I can build hoo files using "cabal haddock --hoogle". But doing this on the BASE package (which I need) from Hackage fails (I'm on Windows, using MSYS): configure: creating ./config.status config.status: error: cannot find input file: include/HsBaseConfig.h.in Does anyone have an easy solution? Maybe I just need to switch to Linux to get this working? :-) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090510/bd015d1b/attachment.html From felipe.lessa at gmail.com Sun May 10 18:36:50 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sun May 10 18:22:06 2009 Subject: [HOpenGL] Re: [Haskell-cafe] Decoupling OpenAL/ALUT packages from OpenGL In-Reply-To: <200905101350.09012.Sven.Panne@aedion.de> References: <200905031244.04713.Sven.Panne@aedion.de> <49FED28D.4060307@comp.leeds.ac.uk> <200905101350.09012.Sven.Panne@aedion.de> Message-ID: <20090510223650.GA19242@kira.casa> On Sun, May 10, 2009 at 01:50:08PM +0200, Sven Panne wrote: > Nevertheless, having a common set of (strict) data types for > vector math will probably be very useful, even if it won't > fulfill everybody's needs. I can say that it would be useful at least for Hipmunk, specially being able to pass the same vector between the physics and the graphics code. Also, one suggestion: lots of SPECIALIZE pragmas for Floats and Doubles. Thanks, -- Felipe. From alex.mdc at gmail.com Sun May 10 21:59:18 2009 From: alex.mdc at gmail.com (Alex MDC) Date: Sun May 10 21:44:28 2009 Subject: [Haskell-cafe] displaying conetents of a list In-Reply-To: <23470633.post@talk.nabble.com> References: <23470633.post@talk.nabble.com> Message-ID: <130714cd0905101859s6d2973fao3f42b09a3429e30a@mail.gmail.com> 2009/5/11 applebiz89 > I know to use show and putStrLn but I just don't know how to put them into > the function correctly Well I hope we're not doing your homework for you but... As putStrLn is in the IO monad, listFilms should at least have a signature like this: listFilms :: [Film] -> IO () Now you know you want to call putStrLn on each item in the list. That means you want to join a bunch of functions return IO (). That sounds like a job for sequence_: listFilms films = sequence_ $ map (putStrLn.show) films Or the same thing more verbosely: listFilms [] = return () listFilms (film:films) = do putStrLn (show film) listFilms films Hope that helps, Alex -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090510/44ee10d0/attachment.html From michael at snoyman.com Sun May 10 22:49:01 2009 From: michael at snoyman.com (Michael Snoyman) Date: Sun May 10 22:34:11 2009 Subject: [Haskell-cafe] displaying conetents of a list In-Reply-To: <23470633.post@talk.nabble.com> References: <23470633.post@talk.nabble.com> Message-ID: <29bf512f0905101949y5912069cv9709c2d14b5e124@mail.gmail.com> listFilms = [Film] -> IO () listFilms = putStrLn . show -- point free style listFilms films = putStrLn $ show films listFilms = mapM_ (putStrLn . show) -- put each movie on a separate line, point free style listFilms films = mapM_ (putStrLn . show) films Hope that makes sense... Michael On Sun, May 10, 2009 at 5:30 PM, applebiz89 wrote: > > I want to write a function to output the entire contents of a list. not > sure > of how to do so...This is my list i want to output > > type Title = String > type Director = String > type Year = Int > type Fan = String > > data Film = Film Title Director Year [Fan] deriving Show > > -- List of films > > testDatabase :: [Film] > testDatabase = [(Film "Casino Royale" "Martin Campbell" 2006 ["Garry", > "Dave", "Zoe"]) ] > > ------- > > I know this isnt right but this is what I have so far > > listFilms :: [Film] -> [Film] > listFilms (film@(Film title director year fans) : films) = putStrLn . show > film > > I know to use show and putStrLn but I just don't know how to put them into > the function correctly > > thank you. > -- > View this message in context: > http://www.nabble.com/displaying-conetents-of-a-list-tp23470633p23470633.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090510/1649ea19/attachment.html From pumpkingod at gmail.com Sun May 10 23:42:42 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Tue May 12 04:00:47 2009 Subject: [Haskell-cafe] displaying conetents of a list In-Reply-To: <130714cd0905101859s6d2973fao3f42b09a3429e30a@mail.gmail.com> References: <23470633.post@talk.nabble.com> <130714cd0905101859s6d2973fao3f42b09a3429e30a@mail.gmail.com> Message-ID: Even more succinctly: sequence_ . map is mapM_, and putStrLn . show is print, so you get: mapM_ print films Dan On Sun, May 10, 2009 at 9:59 PM, Alex MDC wrote: > 2009/5/11 applebiz89 >> >> I know to use show and putStrLn but I just don't know how to put them into >> the function correctly > > Well I hope we're not doing your homework for you but... > > As putStrLn is in the IO monad, listFilms should at least have a signature > like this: > > listFilms :: [Film] -> IO () > > Now you know you want to call putStrLn on each item in the list. That means > you want to join a bunch of functions return IO (). That sounds like a job > for sequence_: > > listFilms films = sequence_ $ map (putStrLn.show) films > > Or the same thing more verbosely: > > listFilms [] = return () > listFilms (film:films) > ?= do putStrLn (show film) > ????? listFilms films > > Hope that helps, > Alex > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From rjones at redhat.com Mon May 11 04:52:46 2009 From: rjones at redhat.com (Richard W.M. Jones) Date: Tue May 12 04:04:08 2009 Subject: [Haskell-cafe] [ANNOUNCE] Bindings for libguestfs Message-ID: <20090511085246.GA4476@amd.home.annexia.org> I added some partial bindings for libguestfs[1] here: http://git.et.redhat.com/?p=libguestfs.git;a=blob;f=haskell/Guestfs.hs;hb=HEAD Some very simple example programs which use these bindings: http://git.et.redhat.com/?p=libguestfs.git;a=tree;f=haskell;hb=HEAD Any comments welcome. My Haskell skills are pretty terrible, so I'm sure there are many ways these can be improved. If someone wants to look at binding the rest of the API, then please send me some patches. (Note that the Guestfs.hs file is automatically generated). BTW, I found the documentation on writing FFIs very contradictory and incomplete. For example, I was completely defeated trying to find ways to do simple stuff like passing in integers or returning booleans. *Potentially* Haskell's FFI seems like it might be one of the best out of the languages I've used so far, but it needs way more documentation and examples. Rich. [1] http://et.redhat.com/~rjones/libguestfs/ -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/ From nccb2 at kent.ac.uk Mon May 11 06:04:07 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Tue May 12 04:08:10 2009 Subject: [Haskell-cafe] Decoupling OpenAL/ALUT packages from OpenGL In-Reply-To: <200905101350.09012.Sven.Panne@aedion.de> References: <200905031244.04713.Sven.Panne@aedion.de> <49FED28D.4060307@comp.leeds.ac.uk> <200905101350.09012.Sven.Panne@aedion.de> Message-ID: <4A07F817.9010401@kent.ac.uk> Sven Panne wrote: > Regarding Functor/Applicative: The obvious instances for e.g. a 2-dimensional > vertex are: > > data Vertex2 a = Vertex2 a a > > instance Functor Vertex2 where > fmap f (Vertex2 x y) = Vertex2 (f x) (f y) > > instance Applicative Vertex2 where > pure a = Vertex2 a a > Vertex2 f g <*> Vertex2 x y = Vertex2 (f x) (g y) > > They fulfill all required laws, but are these the only possible instances? If > not, are they at least the most "canonical" ones in a given sense? And > finally: Does somebody have a real-world example where the Applicative > instance is useful? Usages of the Functor instance are much more obvious for > me. > I'd say those are the right instances. Some obvious uses (perhaps more useful for Vector2 than Vertex2, but still) are: liftA2 (+) (Vertex2 1 3) (Vertex2 4 5) == Vertex2 5 8 pure 0 == Vertex2 0 0 The latter being a useful shorthand to get a vertex for the origin. Also, if you define Foldable: foldl1 (+) . liftA2 (*) v w == dotProduct v w The useful thing being that that definition of dotProduct is the same for 2-, 3- and 4- dimensional things, and for vertexes and vectors. So possible additions to your type-class list are Foldable and maybe Traversable (no harm, although I'd have to reach further for an example for this). I guess the tricky decision might be whether to provide a Num instance (again, probably more suitable for Vector2)? instance Num a => Num (Vertex2 a) where (+) = liftA2 (+) (-) = liftA2 (-) (*) = liftA2 (*) abs = fmap abs signum = fmap signum negate = fmap negate fromInteger = pure . fromInteger Even if you don't want to define Num, note how easy having the Applicative instance makes defining some of the operators :-) Thanks, Neil. From jason.dusek at gmail.com Mon May 11 07:29:28 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Tue May 12 04:15:18 2009 Subject: [Haskell-cafe] Classes: functional dependency (type -> value) In-Reply-To: <23470077.post@talk.nabble.com> References: <23470077.post@talk.nabble.com> Message-ID: <42784f260905110429ndee298dqfe205719c6cada56@mail.gmail.com> 2009/05/10 Belka : > Some real code using wished feature: This code has multiple issues: . It is nearly unreadable as formatted. . There are actual errors that would prevent it from compiling (pattern match on `Left` and `Just` in the same `case` expression!). Please amend the code so it is easier to read and test. -- Jason Dusek From djd at comp.leeds.ac.uk Mon May 11 09:30:55 2009 From: djd at comp.leeds.ac.uk (David Duke) Date: Tue May 12 04:21:53 2009 Subject: [Haskell-cafe] Decoupling OpenAL/ALUT packages from OpenGL In-Reply-To: <200905101350.09012.Sven.Panne@aedion.de> References: <200905031244.04713.Sven.Panne@aedion.de> <49FED28D.4060307@comp.leeds.ac.uk> <200905101350.09012.Sven.Panne@aedion.de> Message-ID: <4A08288F.8070709@comp.leeds.ac.uk> Sven, > Am Montag, 4. Mai 2009 13:33:33 schrieb David Duke: > >> Decoupling basic primitives for geometric modelling from OpenGL would be >> useful. [...] >> Even just data constructors and instances of these within Functor and >> Applicative are a useful starting point. [...] >> > This leads me to the conclusion that I should only lift the data types for > vectors and matrices out of the OpenGL package, including only instances for > standard type classes like Eq, Ord, Functor, etc. This means that the new > package will *not* include type classes for things like scalars, vector > spaces, etc. These can be defined by the other packages in their own "type > class language". That seems a reasonable step. If and when consensus does emerge on packaging vector & matrix operations, that could be added as a further package. > Regarding Functor/Applicative: The obvious instances for e.g. a 2-dimensional > vertex are: > > data Vertex2 a = Vertex2 a a > > instance Functor Vertex2 where > fmap f (Vertex2 x y) = Vertex2 (f x) (f y) > > instance Applicative Vertex2 where > pure a = Vertex2 a a > Vertex2 f g <*> Vertex2 x y = Vertex2 (f x) (g y) > > They fulfill all required laws, but are these the only possible instances? If > not, are they at least the most "canonical" ones in a given sense? And > finally: Does somebody have a real-world example where the Applicative > instance is useful? Usages of the Functor instance are much more obvious for > me. > The Vertex constructor and Applicative operators don't seem to admit anything different that is also sensible (unless someone has a use for <*> with function and/or args permuted). As to real-world example, if you interpret a vertex as a (position) vector and want to apply that to another vertex, liftA2 (+) is neat. For working with sampled data, we have something like class Interp b where interpolate :: Float -> b -> b -> b with suitable instances for types in the numeric hierarchy, and then instance (Interp a, Applicative f) => Interp (f a) where interp t = liftA2 (interp t) If vertex is an instance of applicative, we then immediately have interpolation between coordinates (we use it in contour and surface extraction, others may find it useful in animation or distortion). David -- Dr. David Duke E: djd@comp.leeds.ac.uk School of Computing W: www.comp.leeds.ac.uk/djd/ University of Leeds T: +44 113 3436800 Leeds, LS2 9JT, U.K. From bulat.ziganshin at gmail.com Mon May 11 09:53:40 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue May 12 04:23:32 2009 Subject: [Haskell-cafe] Re[2]: [Gtk2hs-users] ANN: Gtk2HS 0.10.1 released In-Reply-To: <37df87420905110640l30af9736waad1568490c5ebb8@mail.gmail.com> References: <37df87420905100843l4352ff2fm2ca61c3df91d8125@mail.gmail.com> <1566831531.20090510195214@gmail.com> <37df87420905110640l30af9736waad1568490c5ebb8@mail.gmail.com> Message-ID: <1122766343.20090511175340@gmail.com> Hello Peter, Monday, May 11, 2009, 5:40:20 PM, you wrote: >>> GHC 6.10.1 is now supported. >> >> 6.10.2/6.10.3? > Yes, those versions are supported as well. GHC 6.10.1 changed the way > finalizers are handled, and as a result, Gtk2HS programs were > crashing. I don't think anything that affects Gtk2HS was changed in > GHC 6.10.[23]. no, you mixed things a bit :) 6.10.1 was out in Nov 2008. gtk2hs 0.10 supports it the change in finalizers was made in 6.10.2, issued in Apr 2009 and BIG THANKS to entire gtk2hs team: i'm really happy to finally get production-level ghc 6.10 together with new gtk2hs -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From nrolle at web.de Mon May 11 10:37:49 2009 From: nrolle at web.de (Nico Rolle) Date: Tue May 12 04:26:57 2009 Subject: [Haskell-cafe] Data.Map lookup signature Message-ID: <45fccde20905110737w49227944l55415612d68ca8f3@mail.gmail.com> Hi everyone. The docs in the web on http://www.haskell.org/ghc/docs define Data.Map.lookup as follows: http://www.haskell.org/ghc/docs lookup :: Ord k => k -> Map k a -> Maybe a but my version of ghci does i like that: Data.Map.lookup :: (Ord k, Monad m) => k -> Data.Map.Map k a -> m a but i need the 1. one. my version of ghci is 6.8.2 regards From lazycat.manatee at gmail.com Mon May 11 10:13:32 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Tue May 12 04:28:30 2009 Subject: [Haskell-cafe] Re: ANN: Gtk2HS 0.10.1 released References: <37df87420905100843l4352ff2fm2ca61c3df91d8125@mail.gmail.com> Message-ID: <87r5yv4tir.fsf@ubuntu.domain> Peter Gavin writes: > Hi everyone, > > I'd like to announce the release of Gtk2HS 0.10.1! This release > includes mostly bug fixes and other small improvements. Most notably, > GHC 6.10.1 is now supported. > > The source tarball may be downloaded from: > > http://sourceforge.net/project/showfiles.php?group_id=49207&package_id=42440 > > A Windows installer will be provided soon. > > Thanks to all the contributors! Now i use gtk2hs develop GUI program, and it's very nice integrate GTK and Haskell. Thanks gtk2hs team! :) Hope gtk2hs will support *all* functional of GTK (newest version) in the feature. -- Andy From lane at downstairspeople.org Mon May 11 12:36:54 2009 From: lane at downstairspeople.org (Christopher Lane Hinson) Date: Tue May 12 04:34:38 2009 Subject: [Haskell-cafe] Fundep Curiosity Message-ID: I've noticed that a large majority of fundeps I see in other people's libraries are written: class C a b | b -> a Where the dependent parameter appears first in the MPTC. Is there a reason for this? AFAIK, there isn't any semantic significance to the order of parameters in an MPTC. Why do many haskellers find this configuration more intuitive? Friendly, --Lane From pumpkingod at gmail.com Mon May 11 13:28:11 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Tue May 12 04:37:04 2009 Subject: [Haskell-cafe] Re: ANN: Gtk2HS 0.10.1 released In-Reply-To: <878wl57xbv.fsf@ubuntu.domain> References: <37df87420905100843l4352ff2fm2ca61c3df91d8125@mail.gmail.com> <1566831531.20090510195214@gmail.com> <878wl57xbv.fsf@ubuntu.domain> Message-ID: I vaguely remember there being some finalizer behavior that changed in 6.10.2 that might affect this package. Not sure though. On Sun, May 10, 2009 at 12:10 PM, Andy Stewart wrote: > Bulat Ziganshin writes: > >> Hello Peter, >> >> Sunday, May 10, 2009, 7:43:38 PM, you wrote: >> >>> I'd like to announce the release of Gtk2HS 0.10.1! ?This release >>> includes mostly bug fixes and other small improvements. Most notably, >>> GHC 6.10.1 is now supported. >> >> 6.10.2/6.10.3? > I think 6.10.1 compatible with 6.10.2/6.10.3 > > 6.10.2/6.10.3 just fix some bug of 6.10.1 > > ?-- Andy > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From nrolle at web.de Mon May 11 13:36:52 2009 From: nrolle at web.de (Nico Rolle) Date: Tue May 12 04:37:29 2009 Subject: [Haskell-cafe] Re: Data.Map lookup signature In-Reply-To: <45fccde20905110737w49227944l55415612d68ca8f3@mail.gmail.com> References: <45fccde20905110737w49227944l55415612d68ca8f3@mail.gmail.com> Message-ID: <45fccde20905111036o5f0b67fapd1b159c81a675e5a@mail.gmail.com> Oh sorry. It was probalby changed in one of the latest versions I downloaded the latest and now i'm finde. 2009/5/11 Nico Rolle : > Hi everyone. > > The docs in the web on http://www.haskell.org/ghc/docs > define Data.Map.lookup as follows: > http://www.haskell.org/ghc/docs > lookup :: Ord k => k -> Map k a -> Maybe a > but my version of ghci does i like that: > Data.Map.lookup :: (Ord k, Monad m) => k -> Data.Map.Map k a -> m a > but i need the 1. one. > my version of ghci is 6.8.2 > regards > From bugfact at gmail.com Mon May 11 13:50:25 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue May 12 04:38:06 2009 Subject: [Haskell-cafe] Hoogle: converting binary .hoo into text? In-Reply-To: <404396ef0905110125w3b6dcb7ah8574123e27d9f64b@mail.gmail.com> References: <404396ef0905110125w3b6dcb7ah8574123e27d9f64b@mail.gmail.com> Message-ID: On Mon, May 11, 2009 at 10:25 AM, Neil Mitchell wrote: > Hi Peter, > > > I would like to use the Hoogle text format in C#. > > Out of curiosity, why? I'm just interested to know what work you're doing. Sure. We're building with a graphical representation of a Haskellish language (a tiny subset of Haskell actually). The target audience is graphical artists and designers. For testing, I would like to populate the library with primitives taken from the Haskell base libraries. I tried using the GHC API for it, but got stuck. I got the advice in #haskell to parse the Hoogle format, which indeed looks simple enough for the task. > Hoogle on Hackage comes with a bunch of binary *.hoo files. Can these be > > converted to text/xml? If not, is the binary format documented? > > The binary format is documented in the code, and there is a show command. > Try: > > hoogle +base --dump > > However the binary format is not an encoding of the text format, it > throws away lots of data, and precomputes interesting tables etc. If > you want the original, the binary is probably not that useful. > > I do have a complete set of text files though. I can upload them to > the Hoogle website, or I can distribute them with the hackage package. > I could just email them to you privately. What seems the best option > for everyone? I'm not everyone but I guess it would be useful in general. From within Haskell, ideally one would just use the GHC API (or Cabal API) to extract all information I guess, but for usage in other languages, an easy to parse format is better no? (maybe even XML, but that is bulky :-) > I know I can build hoo files using "cabal haddock --hoogle". But doing > this > > on the BASE package (which I need) from Hackage fails (I'm on Windows, > using > > MSYS): > > configure: creating ./config.status > > config.status: error: cannot find input file: include/HsBaseConfig.h.in > > Does anyone have an easy solution? Maybe I just need to switch to Linux > to > > get this working? :-) > > I have a small pile of hacks to get the base library building with > Hoogle. You are welcome to look at them (data/generate in the Hoogle > repo). Caution: these hacks may make your eyes bleed, and certainly > won't work for anything but the GHC/base version pair that I last did > it on. > > Thanks > > Neil > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090511/6e5e27d8/attachment.html From ndmitchell at gmail.com Mon May 11 14:03:06 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue May 12 04:38:24 2009 Subject: [Haskell-cafe] Hoogle: converting binary .hoo into text? In-Reply-To: References: <404396ef0905110125w3b6dcb7ah8574123e27d9f64b@mail.gmail.com> Message-ID: <404396ef0905111103h5725e23eu7c3e6704dcd0c634@mail.gmail.com> Hi > Sure. We're building with a graphical representation of a Haskellish > language (a tiny subset of Haskell actually). The target audience is > graphical artists and designers. For testing, I would like to populate the > library with primitives taken from the Haskell base libraries. ?I tried > using the GHC API for it, but got stuck. I got the advice in #haskell to > parse the Hoogle format, which indeed looks simple enough for the task. You might be able to use haskell-src-exts (plus a little bit of preprocessing) to parse the declarations. I deliberately tried to follow Haskell syntax where possible. >> > Hoogle on Hackage comes with a bunch of binary *.hoo files. Can these be >> > converted to text/xml? If not, is the binary format documented? >> >> The binary format is documented in the code, and there is a show command. >> Try: >> >> hoogle +base --dump >> >> However the binary format is not an encoding of the text format, it >> throws away lots of data, and precomputes interesting tables etc. If >> you want the original, the binary is probably not that useful. >> >> I do have a complete set of text files though. I can upload them to >> the Hoogle website, or I can distribute them with the hackage package. >> I could just email them to you privately. What seems the best option >> for everyone? > > I'm not everyone but I guess it would be useful in general. From within > Haskell, ideally one would just use the GHC API (or Cabal API) to extract > all information I guess, but for usage in other languages, an easy to parse > format?is better no??(maybe even XML, but that is bulky :-) Writing a converting from text files to XML is fine by me - Hoogle already has the textual format parser, so if you add a patching adding a dump XML option I'll happily apply. I'll send you the .txt files by private email. It seems like you want them now, but don't care about keeping them up to date, since it's only a demo. Hence fast and quick, but not long term provided, seems a good short-term compromise. Thanks Neil From vigalchin at gmail.com Mon May 11 18:27:26 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Tue May 12 04:49:55 2009 Subject: [Haskell-cafe] caml build Message-ID: <5ae4f2ba0905111527hebf8e95i88df612017522d39@mail.gmail.com> Hello, I have forgotten whether I sent this posting out. Sorry if I did (I didn't see on Haskell cafe archive). I am building Swish and getting an error. I want to follow the progress of "swish build" ... I don't see an additional parameter like verbose mode that will tell which swish component is being built. ??? Regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090511/96a91da2/attachment.html From anton at appsolutions.com Mon May 11 20:43:23 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Tue May 12 04:55:42 2009 Subject: [Haskell-cafe] Kind of confusing Message-ID: <4A08C62B.9080207@appsolutions.com> GHC amused me today with this error (context omitted): Couldn't match kind `(* -> *) -> * -> *' against `?? -> ? -> *' When matching the kinds of `t :: (* -> *) -> * -> *' and `(->) :: ?? -> ? -> *' It was a silly mistake: I had used 'lift' where I intended to use 'liftM'. But I'm thinking Haskell compilers should have some sort of option which, when the ratio of punctuation to alphanumerics in an error message exceeds a certain level, just responds to the user with a more readily comprehensible message such as "WTF, dude?" Serious question: what is the significance of the question mark and double question marks in those signatures, or better yet, where can I read about it? Anton From paulfrancis at friendbliss.com Mon May 11 21:56:38 2009 From: paulfrancis at friendbliss.com (paulfrancis@friendbliss.com) Date: Tue May 12 04:59:31 2009 Subject: [Haskell-cafe] Developing 3 dimensional interactive environments/functional objects Message-ID: <20090511185638.a7fe6210508103e9b2d8ae485714347f.5b5f86b555.wbe@email03.secureserver.net> An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090511/d6e366ef/attachment.html From wren at freegeek.org Mon May 11 21:59:20 2009 From: wren at freegeek.org (wren ng thornton) Date: Tue May 12 04:59:42 2009 Subject: [Haskell-cafe] Re: OT: Languages In-Reply-To: <4A06EA69.5010409@cs.au.dk> References: <4A046496.8090905@googlemail.com> <4A065BCA.7080804@freegeek.org> <4A06EA69.5010409@cs.au.dk> Message-ID: <4A08D7F8.6060001@freegeek.org> Tillmann Rendel wrote: > wren ng thornton wrote: > > Indeed. The proliferation of compound words is noteworthy, but it's > > not generally considered an agglutinative language. From what (very > > little) German I know compounds tend to be restricted to nouns, as > > opposed to languages like Turkish, Japanese, Korean,... > > Yes, compounds are restricted to nouns in German. But as I understand > it, agglutinative relates more to the inflection system than to the > lexicon anyway. In general, I'm not sure I draw a distinction there. What belongs in the grammar vs what belongs in the lexicon is rather fluid and depends on both the language and the theory in question; whereas the phenomenon is, I think, easily identifiable (if not always easily definable). That is, the distinction between agglutinative vs fusional is typological rather than theoretical. The distinction has to do with information content per morpheme (or compositional vs idiomatic information construction). For determining this, root/base morphemes are included just as much as inflectional morphemes. The distinction between what is "root" vs what is "inflection" is a spectrum and not always clear cut, especially in agglutinative languages. In languages like Japanese which lacks spaces, this difficulty is highlighted by the fact that it's not always clear whether something is a "word" or a "phrase" (and hence whether the latter major segment contains base morphemes, or is "only inflection"). Though yes, the distinction is most clearly observed by looking at verbal inflections. And now we're really far off topic :) -- Live well, ~wren From reiner.pope at gmail.com Tue May 12 00:45:59 2009 From: reiner.pope at gmail.com (Reiner Pope) Date: Tue May 12 05:06:03 2009 Subject: [Haskell-cafe] Stream-fusion without the lists Message-ID: <4cf038ee0905112145q2c1dfed2hfdb324e3ba5d85b6@mail.gmail.com> Hi everyone, With stream-fusion, we can write functions which construct and destruct lists, such as (this is the main example from the Stream Fusion paper[1]) f :: Int -> Int f n = sum [k * m | k <- [1..n], m <- [1..k]] and the rewrite rules in stream-fusion replace these operations on lists with fusible operations on the Stream (non-recursive) datatype. In this example, the domain and codomain of the function don't mention the list datatype. There seem to be many functions like this: the lists are being used internally as composable loops rather than as data-structures. The Stream datatype seems to be much better suited to representing loops than the list datatype is. So, instead of programming with the lists, why don't we just use the Stream datatype directly? For example: In Data.Stream (from the stream-fusion package) we can find most of the Prelude list functions but with Stream in all the types instead of []. For example, Data.Stream.sum :: Num a => S.Stream a -> a Using this module, we can rewrite f without mentioning lists. We first need a Monad instance for Data.Stream.Stream: > import qualified Data.List.Stream as S > > instance Monad S.Stream where > return = S.return > (>>=) = S.concatMap Now we can write > f :: Int -> Int > f n = S.sum $ do > k <- S.enumFromToInt 1 n > m <- S.enumFromToInt 1 k > return (k*m) which is essentially the same as the original f, although lacking the syntactic sugar of the list comprehension. To me, it seems that Stream is more sensible data type to use than [] when the algorithm being expressed is just a loop (rather than something which needs a [] as a cache/buffer), for the following reasons: 1. If I am programming with lists and I need some function which I can't express with Prelude functions, I have to write it myself. I will probably lose fusion in this case, because I will write it recursively in terms of lists. On the other hand, if I am programming with Streams, I will write it myself in terms of Streams, and it should be easier to maintain fusion because it won't be recursive. 2. Holding on to a [] too long can cause a space leak. This is not the case for Stream, because a Stream only ever contains one "state". More generally, the memory use of Stream is more easily predictable than that of [], since "running" a Stream only holds on to one "state" at a time, and we often know how big the "state" is. 3. Fusion doesn't rely on rewrite rules firing. I consider this point less significant than the other two. So, thoughts? Do people program with Streams directly? What have I not considered? Cheers, Reiner [1] http://www.cse.unsw.edu.au/~dons/papers/stream-fusion.pdf From nowgate at yahoo.com Tue May 12 01:59:01 2009 From: nowgate at yahoo.com (michael rice) Date: Tue May 12 05:09:23 2009 Subject: [Haskell-cafe] Inferred typing? Message-ID: <945521.33366.qm@web31108.mail.mud.yahoo.com> In the code below, is the type returned by the return functions inferred from the result type in the function type signature, i.e., just change the result type to Maybe Int and the code will return a Maybe monad, (Just 4), instead of a List monad? Michael ========= import Monad fn :: [Int] -> [Int] fn l = mzero `mplus` (return (head l)) `mplus` (return (last l)) ================ *Main> :l test5 [1 of 1] Compiling Main???????????? ( test5.hs, interpreted ) Ok, modules loaded: Main. *Main> fn [4,5,6,7,8] [4,8] *Main> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090512/3b04a5b2/attachment.html From kolar at fit.vutbr.cz Tue May 12 03:04:46 2009 From: kolar at fit.vutbr.cz (=?ISO-8859-2?Q?Du=B9an_Kol=E1=F8?=) Date: Tue May 12 05:11:36 2009 Subject: [Haskell-cafe] OT: Is conference dead? Message-ID: <4A091F8E.7050002@fit.vutbr.cz> Hello all, I'm sorry for the OT post, is the conference dead? I've got no mail since yeasterday afternoon. And that is quite unusual. Best regards, Dusan From anotheraddress at gmx.de Mon May 11 07:05:35 2009 From: anotheraddress at gmx.de (Daniel =?iso-8859-1?q?Sch=FCssler?=) Date: Tue May 12 05:13:30 2009 Subject: [Haskell-cafe] Classes: functional dependency (type -> value) In-Reply-To: <23470077.post@talk.nabble.com> References: <23470077.post@talk.nabble.com> Message-ID: <200905111305.35829.anotheraddress@gmx.de> Hello! The problem is that it's impossible to infer the SomeClass instance from the type SomeRole. If you do "print role", which instance should it use? I can think of two ways around it: -- 1. (dummy parameter) ------------------------------ data SomeRole a = Role1 | Role2 | Role3 deriving Show class SomeClass a where role :: SomeRole a data Foo = Foo data Bar = Bar instance SomeClass Foo where role = Role1 instance SomeClass Bar where role = Role2 main = do print (role :: SomeRole Foo) print (role :: SomeRole Bar) -- 2. (dummy argument) ------------------------------ data SomeRole = Role1 | Role2 | Role3 deriving Show class SomeClass a where role :: a -> SomeRole data Foo = Foo data Bar = Bar instance SomeClass Foo where role _ = Role1 instance SomeClass Bar where role _ = Role2 main = do print (role (undefined :: Foo)) print (role (undefined :: Bar)) ------------------------------ On Sunday 10 May 2009 15:21:39 Belka wrote: > Hello, communion people! > > I seek for your advice in a matter, where it's really hard for me to > determine a good programming style. > Here's the problem. I'm generalizing multiple authorization procedures to > one, using class definition. (if of any interest, the code is in the end.) > The problem essense is folowing: > ---------------- > data SomeRole = Role1 | Role2 | Role3 > > class SomeClass a b c | a -> b, c where > f1 :: ... > f2 :: ... > ... > fn :: ... > role :: SomeRole -- <-- here is the problem > > I want to have a fuctional dependency from a type "a" on a value of *role*, > so that I could easily "inspect" the *role* from within any other class > members. > Is it possible? Or do I rougly violate some style traditions? > > Some real code using wished feature: > --------------------------------------- > data AuthentificationPurpose = JustValidateInput | JustGenerateForOutput | > ValidateInputAndGenerateForOutput > type AuthSucceded = Bool > > class AuthentificationStructure t_env t_realInput t_assumption t_keySet | > t_realInput -> t_assumptionInput, t_keySet where > authentificationPurpose :: AuthentificationPurpose > makeAssumption :: t_env -> t_realInput -> IO (Either ErrorMessage > t_assumption) > makeFinalKeySet :: (t_realInput, t_assumption) -> t_keySet > validateRealKeySet_with_Assumed :: t_realInput -> t_keySet -> Maybe > ErrorMessage > tryLogTheValidKey :: t_env -> (t_realInput, t_assumption) > -> IO (Maybe ErrorMessage) > tryLogTheAuthTry :: t_env -> (t_realInput, t_assumption, > AuthSucceded) -> IO (Maybe ErrorMessage) > > authentificate :: AuthentificationStructure t_env t_realInput > t_assumptionInput t_keySet => t_env -> t_businessInput -> IO (Either > ErrorMessage (t_assumption, t_keySet)) > authentificate env realInput = do err_or_assumption <- makeAssumption env > realInput > case err_or_assumption of > Left err_msg -> return $ Left "Error! > Assumption maker failed. Lower level error message: " ++ err_msg > Just assumption -> do > key_set <- > makeFinalKeySet (realInput, assumption) > err_or_keyset1 <- case > authentificationPurpose of > > JustGenerateForOutput -> return $ Right key_set > > JustValidateInput -> do > > mb_failure <- validateRealKeySet_with_Assumed t_realInput key_set > > case mb_failure of > > Just err_msg -> return $ Left "Error! Invalid set of auth keys. Lower level > error message: " ++ err_msg > > Nothing -> return $ Right key_set > > ValidateInputAndGenerateForOutput > err_or_keyset2 <- case > err_or_keyset1 of > > Left err_msg -> return err_or_keyset1 > > Right key_set -> do > > mb_failure <- tryLogTheValidKey env (realInput, assumption) > > case mb_failure of > > Just err_msg -> return $ Left "Error! Could not log valid key. Lower level > error message: " ++ err_msg > > Nothing -> return err_or_keyset1 > mb_failure <- > tryLogTheAuthTry env (realInput, assumption, isRight err_or_keyset2) > case mb_failure of > Just err_msg1 -> case > err_or_keyset2 of > > Left err_msg2 -> return $ Left ("1. " ++ err_msg2 ++ "\n2. " ++ err_msg1) > > Right _ -> return $ Left err_msg1 > Nothing -> case > err_or_keyset2 of > > Left err_msg -> return $ Left err_msg > > Right key_set -> return $ Right (assumption, key_set) > --------------------------------- > > Best regards, Belka From pgavin at gmail.com Mon May 11 09:40:20 2009 From: pgavin at gmail.com (Peter Gavin) Date: Tue May 12 05:13:38 2009 Subject: [Haskell-cafe] Re: [Gtk2hs-users] ANN: Gtk2HS 0.10.1 released In-Reply-To: <1566831531.20090510195214@gmail.com> References: <37df87420905100843l4352ff2fm2ca61c3df91d8125@mail.gmail.com> <1566831531.20090510195214@gmail.com> Message-ID: <37df87420905110640l30af9736waad1568490c5ebb8@mail.gmail.com> On Sun, May 10, 2009 at 11:52 AM, Bulat Ziganshin wrote: > Hello Peter, > > Sunday, May 10, 2009, 7:43:38 PM, you wrote: > >> I'd like to announce the release of Gtk2HS 0.10.1! ?This release >> includes mostly bug fixes and other small improvements. Most notably, >> GHC 6.10.1 is now supported. > > 6.10.2/6.10.3? > Yes, those versions are supported as well. GHC 6.10.1 changed the way finalizers are handled, and as a result, Gtk2HS programs were crashing. I don't think anything that affects Gtk2HS was changed in GHC 6.10.[23]. Pete From martin.hofmann at uni-bamberg.de Tue May 12 05:38:04 2009 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Tue May 12 05:21:57 2009 Subject: [Haskell-cafe] ANN: AAIP Workshop on ICFP Deadline Extension Message-ID: <1242121084.6096.106.camel@ios.cogsys.wiai.uni-bamberg.de> AAIP Workshop on ICFP Deadline Extension Please note that the submission deadline for the 3rd Workshop on Approaches and Applications of Inductive Programming has been extended to May 25. The workshop takes place for the first time at the 14th ACM SIGPLAN International Conference on Functional Programming (ICFP 2009) in Edinburgh, Scotland. If a sufficient number of high quality papers is submitted, there will be a Post-Workshop Proceedings Volume published at Springer LNCS. The workshop will present three invited speakers from the research area of functional programming who have done excellent work to make use of inductive programming techniques. The full Call for Papers and further information are available at http://www.cogsys.wiai.uni-bamberg.de/aaip09/ Submit to the workshop and help to tighten the link between the functional programming and the inductive programming community! Best regards, Ute Schmid, Rinus Plasmeijer and Emanuel Kitzelmann From marlowsd at gmail.com Tue May 12 06:45:33 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Tue May 12 06:31:10 2009 Subject: [Haskell-cafe] Re: OT: Is conference dead? In-Reply-To: <4A091F8E.7050002@fit.vutbr.cz> References: <4A091F8E.7050002@fit.vutbr.cz> Message-ID: <4A09534D.7060206@gmail.com> On 12/05/2009 08:04, Du?an Kol?? wrote: > > I'm sorry for the OT post, is the conference dead? I've got no mail > since yeasterday afternoon. And that is quite unusual. We had a full disk on haskell.org over the weekend. We freed up some space yesterday, but it seems the lists were still stuck. I've restarted mailman and the mail now seems to be flowing, but there's a large backlog. Cheers, Simon From batterseapower at hotmail.com Tue May 12 07:02:55 2009 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Tue May 12 06:48:22 2009 Subject: [Haskell-cafe] Kind of confusing In-Reply-To: <4A08C62B.9080207@appsolutions.com> References: <4A08C62B.9080207@appsolutions.com> Message-ID: <9d4d38820905120402o65147a7cg68f0bc93128411c5@mail.gmail.com> Hi Anton, AFAIK the only place this is documented is in GHC source code. Please see the section called "Main data types representing Kinds" at http://hackage.haskell.org/packages/archive/ghc/6.10.2/doc/html/Type.html. Basically, they are all members of GHC's internal subkind hierarchy, which is used to distinguish between the representation of types. For example, the "error" function can be instantiated to have the type String -> Int# -> Int# whereas every polymorphic function you write will only be able to be instantiated at lifted types like Int. This reflects the fact that internally the type variable in the type of "error" has (IIRC) kind "?". I don't know why they showed up in your error message! Cheers, Max 2009/5/12 Anton van Straaten : > GHC amused me today with this error (context omitted): > > ? ?Couldn't match kind `(* -> *) -> * -> *' against `?? -> ? -> *' > ? ?When matching the kinds of `t :: (* -> *) -> * -> *' and > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? `(->) :: ?? -> ? -> *' > > It was a silly mistake: I had used 'lift' where I intended to use 'liftM'. > > But I'm thinking Haskell compilers should have some sort of option which, > when the ratio of punctuation to alphanumerics in an error message exceeds a > certain level, just responds to the user with a more readily comprehensible > message such as "WTF, dude?" > > Serious question: what is the significance of the question mark and double > question marks in those signatures, or better yet, where can I read about > it? > > Anton > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From g9ks157k at acme.softbase.org Tue May 12 07:12:48 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Tue May 12 06:58:13 2009 Subject: [darcs-users] [Haskell-cafe] Darcs as undo/redo system? In-Reply-To: References: Message-ID: <200905121312.48917.g9ks157k@acme.softbase.org> Am Freitag, 8. Mai 2009 18:43 schrieb Jason Dagit: > If you wanted to work on this, I would encourage you to read more > about patch theory[1,2,3,4] and also try out libdarcs[5]. Is libdarcs the same as the darcs library package on Hackage (which exports the darcs API)? Best wishes, Wolfgang From barsoap at web.de Tue May 12 07:14:50 2009 From: barsoap at web.de (Achim Schneider) Date: Tue May 12 07:00:24 2009 Subject: [Haskell-cafe] Re: OT: Languages References: <4A046496.8090905@googlemail.com> <4A065BCA.7080804@freegeek.org> <4A06EA69.5010409@cs.au.dk> <4A08D7F8.6060001@freegeek.org> Message-ID: <20090512131450.501ad83d@solaris> wren ng thornton wrote: > That is, the distinction between agglutinative vs > fusional is typological rather than theoretical. > > Though yes, the distinction is most clearly observed by looking at > verbal inflections. And now we're really far off topic :) > No, we aren't. A couple of days ago, I considered replacing a couple of highly regular function definitions by three lists and two calls to <*>, but didn't do it as I would still have to name the resulting functions by hand, to use them, and TH seemed utter overkill. -- (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 May 12 07:24:16 2009 From: barsoap at web.de (Achim Schneider) Date: Tue May 12 07:10:01 2009 Subject: [Haskell-cafe] Re: Inferred typing? References: <945521.33366.qm@web31108.mail.mud.yahoo.com> Message-ID: <20090512132416.6df0bd83@solaris> michael rice wrote: > In the code below, is the type returned by the return functions > inferred from the result type in the function type signature, i.e., > just change the result type to Maybe Int and the code will return a > Maybe monad, (Just 4), instead of a List monad? > Yes. Prelude> :m Control.Monad Prelude Control.Monad> let fn l = mzero `mplus` (return (head l)) `mplus` (return (last l)) Prelude Control.Monad> fn [1,3] :: Maybe Int Just 1 Prelude Control.Monad> fn [1,3] :: Maybe Float Just 1.0 Prelude Control.Monad> fn [1,2,3] :: [Int] [1,3] -- (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 Tue May 12 07:32:23 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Tue May 12 07:20:24 2009 Subject: [Haskell-cafe] Re: Classes: functional dependency (type -> value) In-Reply-To: <23470077.post@talk.nabble.com> References: <23470077.post@talk.nabble.com> Message-ID: Belka wrote: > Hello, communion people! > > I seek for your advice in a matter, where it's really hard for me to > determine a good programming style. > Here's the problem. I'm generalizing multiple authorization procedures to > one, using class definition. (if of any interest, the code is in the end.) > The problem essense is folowing: > ---------------- > data SomeRole = Role1 | Role2 | Role3 > > class SomeClass a b c | a -> b, c where > f1 :: ... > f2 :: ... > ... > fn :: ... > role :: SomeRole -- <-- here is the problem > > I want to have a fuctional dependency from a type "a" on a value of *role*, > so that I could easily "inspect" the *role* from within any other class > members. > Is it possible? Or do I rougly violate some style traditions? The problem is that when you write role there is no way to choose the right instance? That is, where does the compiler get a, b, c from when looking just at an invocation of role ? Therefore, the type of role has to involve a , for example as in class SomeClass a b c ... where ... role :: a -> SomeRole and used as role (undefined :: Foo) That being said, I think that type classes are not what you want here. I suggest to simply use a regular data type data SomeThing a b c = SomeThing { f1 :: ... , f2 :: ... ... , fn :: ... , role :: SomeRole } Remember that f1, f2, ... can be functions, this is a functional language, after all! "Instances" are then simply a concrete value, like for example thething :: SomeThing Foo Bar Baz thething = SomeThing { f1 = id , f2 = filter (>3) . map length , ... , role = Role1 } Regards, apfelmus -- http://apfelmus.nfshost.com From rl at cse.unsw.edu.au Tue May 12 07:39:40 2009 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Tue May 12 07:25:01 2009 Subject: [Haskell-cafe] Stream-fusion without the lists In-Reply-To: <4cf038ee0905112145q2c1dfed2hfdb324e3ba5d85b6@mail.gmail.com> References: <4cf038ee0905112145q2c1dfed2hfdb324e3ba5d85b6@mail.gmail.com> Message-ID: <179DE459-B966-4B14-B1B7-534745E385CD@cse.unsw.edu.au> On 12/05/2009, at 14:45, Reiner Pope wrote: > The Stream datatype seems to be much better suited to representing > loops than the list datatype is. So, instead of programming with the > lists, why don't we just use the Stream datatype directly? I think the main reason is that streams don't store data and therefore don't support sharing. That is, in let xs = map f ys in (sum xs, product xs) the elements of xs will be computed once if it is a list but twice if it is a stream. Roman From g9ks157k at acme.softbase.org Tue May 12 07:41:06 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Tue May 12 07:26:23 2009 Subject: [Haskell-cafe] commending "Design concepts in programming languages" In-Reply-To: <200905081431.09883.daniel.is.fischer@web.de> References: <5e0214850904291029gd68128bofccf9691c400adf4@mail.gmail.com> <200905081323.09106.g9ks157k@acme.softbase.org> <200905081431.09883.daniel.is.fischer@web.de> Message-ID: <200905121341.06138.g9ks157k@acme.softbase.org> Am Freitag, 8. Mai 2009 14:31 schrieb Daniel Fischer: > Though I had no contact with algebraists in the 1980s, I also hadn?t. However, nowadays I have contact with someone who was an algebraist in the 1980s. It?s my boss (professor), by the way. :-) > > I think, also category theorists often wrote (write?) composition with > > the first morphism on the left, i.e., ?the other way round?. > > Yeah, I heard that, too. It's a field where the advantages of postfix > notation show clearly and a young one, so for them it was relatively easy > to switch. However, I fear that all those other mathematicians who define f . g = \x -> f(g(x), have made the category theorists switch to this suboptimal notation (first morphism on the right). At least, I cannot remember seeing the other notation (first morphism on the left) in category theory literature so far. It?s just that my above-mentioned professor told me that category theorists would use the first-morphism-on-the-left notation. Best wishes, Wolfgang From byorgey at seas.upenn.edu Tue May 12 07:50:51 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Tue May 12 07:36:04 2009 Subject: [Haskell-cafe] Inferred typing? In-Reply-To: <945521.33366.qm@web31108.mail.mud.yahoo.com> References: <945521.33366.qm@web31108.mail.mud.yahoo.com> Message-ID: <20090512115051.GA3497@seas.upenn.edu> On Mon, May 11, 2009 at 10:59:01PM -0700, michael rice wrote: > In the code below, is the type returned by the return functions inferred from > the result type in the function type signature, i.e., just change the result > type to Maybe Int and the code will return a Maybe monad, (Just 4), instead of > a List monad? Indeed, it is. Try it! =) -Brent From byorgey at seas.upenn.edu Tue May 12 08:15:02 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Tue May 12 08:01:03 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 117 - May 12, 2009 Message-ID: <20090512121502.GA6538@seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090512 Issue 117 - May 12, 2009 --------------------------------------------------------------------------- Welcome to issue 117 of HWN, a newsletter covering developments in the [1]Haskell community. The Haskell Platform is here! Announcements The Haskell Platform. Don Stewart [2]announced the first release of the [3]Haskell Platform: a single, standard Haskell distribution for every system. The Haskell Platform is a blessed library and tool suite for Haskell culled from Hackage, along with installers for a wide variety of systems. It saves developers work picking and choosing the best Haskell libraries and tools to use for a task. GHC version 6.10.3. Ian Lynagh [4]announced the release of [5]GHC 6.10.3. This release contains a handful of bugfixes relative to 6.10.2 and better line editing support in GHCi, so updating is recommend. See the [6]release notes for more details. Bindings for libguestfs. Richard W.M. Jones [7]announced some [8]partial bindings for [9]libguestfs. Heads up: Conflicting versions of network-2.2.1. Johan Tibell [10]announced a heads-up that the version of network-2.2.1 that shipped with GHC 6.10 differs from the one on Hackage. If you want the API additions that are present in network-2.2.1 on Hackage, be sure to use network-2.2.1.1 instead. hpc-strobe-0.1: Hpc-generated strobes for a running Haskell program. Thorkil Naur [11]announced the initial release of [12]hpc-strobe, a rudimentary library that demonstrates the possibility of using Hpc (Haskell Program Coverage) to inspect the state of a running Haskell program. hpc-strobe uses the basic machinery provided by Hpc to produce multiple tix files, also called strobes, representing the coverage at different times while the program is running. By subtracting such two tix files, again using Hpc machinery, a tix file representing the expressions used between the times of recording the subtracted tix files is produced. This may be used, for example, to get a better idea of what a long-running program is doing. It could also be used as a profiling tool, getting information about how many times individual expressions are used. BUG FIX release of regex-tdfa-1.1.2. ChrisK [13]announced version 1.1.2 of [14]regex-tdfa, a bug-fix release. Silkworm game. Duane Johnson [15]announced the release of [16]Silkworm, a game written in Haskell using [17]Hipmunk and GLFW. Discussion Platform policy question: API compatibility in minor releases. Duncan Coutts began a [18]discussion on versioning policies for major and minor releases, for packages included in the Haskell Platform. See also the [19]newly started discussion on the purpose of Haskell Platform releases. Blog noise [20]Haskell news from the [21]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Magnus Therning: [22]Vim haskellmode packaged for Arch. * Manuel M T Chakravarty: [23]Instant Generics: Fast and Easy.. * Bjorn Buckwalter: [24]May 2009 HCAR Submissions. * Gtk2HS: [25]Gtk2HS 0.10.1 Released. * Magnus Therning: [26]Arch and Haskell, on little snag. * Mikael Vejdemo Johansson (DrSyzygy): [27]Gr?bner bases for operads - Or "What I did in my vacation". * Mads Lindstr?m: [28]WxGeneric 0.6.0. * Osfameron: [29]Is currying monadic?. * James Iry: [30]A Brief, Incomplete, and Mostly Wrong History of Programming Languages. * Duane Johnson: [31]Visualizing Typed Functions. * Well-Typed.Com: [32]Next steps for the Haskell Platform. * Don Stewart (dons): [33]The Haskell Platform. * Luke Palmer: [34]Lazy Partial Evaluation. * Christopher Lane Hinson: [35]Vec is Good. * LHC Team: [36]Constructor specialization and laziness.. * Lee Pike: [37]An Atomic Fibonacci Server: Exploring the Atom (Haskell) DSL. * John Van Enk: [38]Atom & Arduino :: First Program (pt. 2). * >>> Chris Forno: [39]Is Haskell a Good Choice for Web Applications?. * >>> Sparky: [40]Haskell and Eclipse [Part 2]. * >>> Brit Butler: [41]Playing with Haskell. * Duane Johnson: [42]Silkworm Game written in Haskell. * Matthew Podwysocki: [43]Functional Composition and Partial Application . * >>> Takashi: [44]A Prolog In Haskell. * >>> mokehehe: [45]Using DirectX from Haskell. * >>> mokehehe: [46]AO bench in Haskell. Quotes of the Week * jfredett: My haskell-spider senses were tingling, I just overshot RT and went for the Halting Problem. * NeilBrown: I heard that if you chant "I don't think this can be done in Haskell" three times in front of a text editor, Don Stewart appears and implements it in one line... * bos: The last couple of times I've wanted a book like that, I wrote the book myself. It's a very effective way to get the book you want, compared to wishing. * edwardk: {-# LANGUAGE time to pay the cutting edge typing features tax #-} * SPJ: Haha this is good news, I have slipped functional programming into your brain without you realising it is something very weird. * EvilTerran: writing machine code by hand on tape with a magnetised needle looks good compared to PHP :P * Athas: I like Lisp for its extreme expressivity, but I think it's easier to make Haskell more powerful, than to make Lisp more statically safe. * roconnor: I can't wait for the Density Comonad chapter of "learn you a haskell" About the Haskell Weekly News New editions are posted to [47]the Haskell mailing list as well as to [48]the Haskell Sequence and [49]Planet Haskell. [50]RSS is also available, and headlines appear on [51]haskell.org. To help create new editions of this newsletter, please see the information on [52]how to contribute. Send stories to byorgey at cis dot upenn dot edu. The darcs repository is available at darcs get [53]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://article.gmane.org/gmane.comp.lang.haskell.cafe/58095 3. http://hackage.haskell.org/platform/ 4. http://article.gmane.org/gmane.comp.lang.haskell.general/17178 5. http://www.haskell.org/ghc/ 6. http://haskell.org/ghc/docs/6.10.3/html/users_guide/release-6-10-3.html 7. http://article.gmane.org/gmane.comp.lang.haskell.cafe/58358 8. http://git.et.redhat.com/?p=libguestfs.git;a=blob;f=haskell/Guestfs.hs;hb=HEAD 9. http://et.redhat.com/~rjones/libguestfs/ 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/58349 11. http://article.gmane.org/gmane.comp.lang.haskell.cafe/58286 12. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hpc%2Dstrobe 13. http://article.gmane.org/gmane.comp.lang.haskell.cafe/58067 14. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-tdfa 15. http://article.gmane.org/gmane.comp.lang.haskell.cafe/57886 16. http://blog.inquirylabs.com/2009/05/02/silkworm-game-written-in-haskell/ 17. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Hipmunk 18. http://thread.gmane.org/gmane.comp.lang.haskell.libraries/11001 19. http://thread.gmane.org/gmane.comp.lang.haskell.libraries/11035 20. http://planet.haskell.org/ 21. http://haskell.org/haskellwiki/Blog_articles 22. http://therning.org/magnus/archives/617 23. http://justtesting.org/post/106219682 24. http://flygdynamikern.blogspot.com/2009/05/may-2009-hcar-submissions.html 25. http://haskell.org/gtk2hs/archives/2009/05/10/gtk2hs-0101-released/ 26. http://therning.org/magnus/archives/599 27. http://blog.mikael.johanssons.org/archive/2009/05/grobner-bases-for-operads-or-what-i-did-in-my-vacation/ 28. http://lindstroem.wordpress.com/2009/05/08/wxgeneric-0-6-0/ 29. http://greenokapi.net/blog/2009/05/07/is-currying-monadic/ 30. http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html 31. http://blog.inquirylabs.com/2009/05/07/visualizing-typed-functions/ 32. http://blog.well-typed.com/2009/05/next-steps-for-the-haskell-platform/ 33. http://donsbot.wordpress.com/2009/05/06/the-haskell-platform/ 34. http://lukepalmer.wordpress.com/2009/05/04/lazy-partial-evaluation/ 35. http://blog.downstairspeople.org/2009/05/05/vec-is-good/ 36. http://lhc-compiler.blogspot.com/2009/05/constructor-specialization-and-laziness.html 37. http://leepike.wordpress.com/2009/05/05/an-atomic-fibonacci-server-exploring-the-atom-haskell-dsl/ 38. http://blog.sw17ch.com/wordpress/?p=111 39. http://jekor.com/article/is-haskell-a-good-choice-for-web-applications 40. http://sdasrath.blogspot.com/2009/05/20090402-haskell-and-eclipse-part-2.html 41. http://redlinernotes.com/blog/?p=937 42. http://blog.inquirylabs.com/2009/05/02/silkworm-game-written-in-haskell/ 43. http://weblogs.asp.net/podwysocki/archive/2009/05/01/functional-composition-and-partial-application.aspx 44. http://propella.blogspot.com/2009/04/prolog-in-haskell.html 45. http://mokehehe.blogspot.com/ 46. http://mokehehe.blogspot.com/2009/04/ao-bench-in-haskell.html 47. http://www.haskell.org/mailman/listinfo/haskell 48. http://sequence.complete.org/ 49. http://planet.haskell.org/ 50. http://sequence.complete.org/node/feed 51. http://haskell.org/ 52. http://haskell.org/haskellwiki/HWN 53. http://code.haskell.org/~byorgey/code/hwn/ From nicolas.pouillard at gmail.com Tue May 12 08:23:42 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Tue May 12 08:10:18 2009 Subject: [Haskell-cafe] caml build In-Reply-To: <5ae4f2ba0905111527hebf8e95i88df612017522d39@mail.gmail.com> References: <5ae4f2ba0905111527hebf8e95i88df612017522d39@mail.gmail.com> Message-ID: <1242130982-sup-5203@ausone.inria.fr> Excerpts from Vasili I. Galchin's message of Tue May 12 00:27:26 +0200 2009: > Hello, > > I have forgotten whether I sent this posting out. Sorry if I did (I > didn't see on Haskell cafe archive). > > I am building Swish and getting an error. I want to follow the > progress of "swish build" ... I don't see an additional parameter like > verbose mode that will tell which swish component is being built. ??? I don't get the relation with the subject of your post, can you elaborate? Best regards, -- Nicolas Pouillard From daniel.is.fischer at web.de Tue May 12 08:41:04 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue May 12 08:27:23 2009 Subject: [Haskell-cafe] Fundep Curiosity In-Reply-To: References: Message-ID: <200905121441.04152.daniel.is.fischer@web.de> Am Montag 11 Mai 2009 18:36:54 schrieb Christopher Lane Hinson: > I've noticed that a large majority of fundeps I see in other people's > libraries are written: > > class C a b | b -> a > > Where the dependent parameter appears first in the MPTC. Is there a > reason for this? Yes. Generalised newtype deriving (perhaps others, but that's what jumped at me). Consider class MonadState s m | m -> s where ... newtype State s a = State { runState :: s -> (a,s) } instance Monad (State s) where ... instance MonadState s (State s) where ... newtype MySpecialState s a = MSS (State (s,Int) a) deriving (Monad, MonadState (s,Int)) > > AFAIK, there isn't any semantic significance to the order of parameters in > an MPTC. Why do many haskellers find this configuration more intuitive? > > Friendly, > --Lane From daniel.is.fischer at web.de Tue May 12 08:50:26 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue May 12 08:36:38 2009 Subject: [Haskell-cafe] Inferred typing? In-Reply-To: <945521.33366.qm@web31108.mail.mud.yahoo.com> References: <945521.33366.qm@web31108.mail.mud.yahoo.com> Message-ID: <200905121450.26217.daniel.is.fischer@web.de> Am Dienstag 12 Mai 2009 07:59:01 schrieb michael rice: > In the code below, is the type returned by the return functions inferred > from the result type in the function type signature, i.e., just change the > result type to Maybe Int and the code will return a Maybe monad, (Just 4), > instead of a List monad? You can find out such things yourself, just remove the type signature and ask ghci/hugs what they think: *MType> :t fn fn :: (MonadPlus m) => [a] -> m a > > Michael > > ========= > > import Monad > > fn :: [Int] -> [Int] > fn l = mzero `mplus` (return (head l)) `mplus` (return (last l)) > > ================ > > *Main> :l test5 > [1 of 1] Compiling Main???????????? ( test5.hs, interpreted ) > Ok, modules loaded: Main. > *Main> fn [4,5,6,7,8] > [4,8] > *Main> From daniel.is.fischer at web.de Tue May 12 09:00:42 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue May 12 08:46:46 2009 Subject: [Haskell-cafe] OT: Is conference dead? In-Reply-To: <4A091F8E.7050002@fit.vutbr.cz> References: <4A091F8E.7050002@fit.vutbr.cz> Message-ID: <200905121500.43085.daniel.is.fischer@web.de> Am Dienstag 12 Mai 2009 09:04:46 schrieb Du?an Kol??: > Hello all, > > I'm sorry for the OT post, is the conference dead? I've got no mail > since yeasterday afternoon. And that is quite unusual. I didn't get anything yesterday afternoon either. On Saturday, posts reached my mailbox typically one hour after sending, Sunday it was 2+ hours, yesterday noon I got what was sent up to 8am GMT, nothing after that. Today things are much delayed again. It seems the mail server at haskell.org is seriously acting up. Does anybody know whom one can ask to look into it? > > Best regards, > > Dusan > From flippa at flippac.org Tue May 12 09:09:35 2009 From: flippa at flippac.org (Philippa Cowderoy) Date: Tue May 12 08:55:03 2009 Subject: [Haskell-cafe] Kind of confusing In-Reply-To: <4A08C62B.9080207@appsolutions.com> References: <4A08C62B.9080207@appsolutions.com> Message-ID: <1242133775.4525.3.camel@flippa-eee> On Mon, 2009-05-11 at 20:43 -0400, Anton van Straaten wrote: > Serious question: what is the significance of the question mark and > double question marks in those signatures, or better yet, where can I > read about it? > I've forgotten where to find the details (try the GHC manual if you haven't already?), but IIRC they're part of how GHC handles boxing. -- Philippa Cowderoy From briqueabraque at yahoo.com Tue May 12 10:05:41 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=EDcio?=) Date: Tue May 12 09:52:21 2009 Subject: [Haskell-cafe] List of exports of a module - are there alternatives? Message-ID: Hi, When we want to list which declarations are exported by a module we do: module Mod ( list of exports ) where ... Are there propositions to alternatives to that (I could not find one)? Like, say, add a "do export" or "do not export" tag to declarations we want to (not) export? (I think something like that could be nice when we have modules with 200 declarations and just a few are (not) going to be exported.) Thanks, Maur?cio From david.m.carter at gmail.com Tue May 12 10:16:43 2009 From: david.m.carter at gmail.com (David Carter) Date: Tue May 12 10:02:42 2009 Subject: [Haskell-cafe] Problem with text and text-icu packages Message-ID: <5a1362990905120716m201c0ed0gc496795491a9268e@mail.gmail.com> Hi, I'm struggling with text-0.1 and text-icu-0.1, as announced at http://www.serpentine.com/blog/2009/02/27/finally-fast-unicode-support-for-haskell/ The code in http://pastebin.com/m7d8d9f91 is intended to read in a UTF-8 file a1.txt, reverse it twice, and write it out to another UTF-8 file a2.txt, which I would have thought should make a2.txt identical to a1.txt. Mostly it is, but sometimes it isn't, e.g.: % echo a > a1.txt % tryicu # <- my code % cat a2.txt ?? Specifically, a1.txt contains bytes 97 and 10, while a2.txt contains bytes 224 160 139 237 144 164. Have I misconstrued things, or is this a bug? I am running ghc 6.10.2 and ICU 4.0.1 on SuSE. Thanks for any help David From rendel at cs.au.dk Tue May 12 10:33:53 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Tue May 12 10:18:53 2009 Subject: [Haskell-cafe] Fundep Curiosity In-Reply-To: References: Message-ID: <4A0988D1.8090006@cs.au.dk> Christopher Lane Hinson wrote: > I've noticed that a large majority of fundeps I see in other people's > libraries are written: > > class C a b | b -> a > > Where the dependent parameter appears first in the MPTC. Is there a > reason for this? > > AFAIK, there isn't any semantic significance to the order of parameters > in an MPTC. Why do many haskellers find this configuration more intuitive? The order of parameters in an MPTC is significant if you want to use newtype deriving, which can only be used with the last parameter, by explicitly providing all other parameters. Tillmann From dons at galois.com Tue May 12 11:18:08 2009 From: dons at galois.com (Don Stewart) Date: Tue May 12 11:05:32 2009 Subject: [Haskell-cafe] [ANNOUNCE] Bindings for libguestfs In-Reply-To: <20090511085246.GA4476@amd.home.annexia.org> References: <20090511085246.GA4476@amd.home.annexia.org> Message-ID: <20090512151808.GB17347@whirlpool.galois.com> rjones: > I added some partial bindings for libguestfs[1] here: > > http://git.et.redhat.com/?p=libguestfs.git;a=blob;f=haskell/Guestfs.hs;hb=HEAD > > Some very simple example programs which use these bindings: > > http://git.et.redhat.com/?p=libguestfs.git;a=tree;f=haskell;hb=HEAD > > Any comments welcome. My Haskell skills are pretty terrible, so I'm > sure there are many ways these can be improved. > > If someone wants to look at binding the rest of the API, then please > send me some patches. (Note that the Guestfs.hs file is automatically > generated). Very cool. Are you likely to upload to hackage? > BTW, I found the documentation on writing FFIs very contradictory and > incomplete. For example, I was completely defeated trying to find > ways to do simple stuff like passing in integers or returning > booleans. *Potentially* Haskell's FFI seems like it might be one of > the best out of the languages I've used so far, but it needs way more > documentation and examples. Perhaps read the FFI chapter of RWH (online?) What resources were you using to grok the FFI? Cheers, Don From icfp.publicity at googlemail.com Tue May 12 11:23:01 2009 From: icfp.publicity at googlemail.com (Matthew Fluet (ICFP Publicity Chair)) Date: Tue May 12 11:08:19 2009 Subject: [Haskell-cafe] International Summer School on Advances in Programming Languages (precedes ICFP'09) Message-ID: <53ff55480905120823w5515493p3aa4fed21afd9ad7@mail.gmail.com> International Summer School on Advances in Programming Languages 25th-28th August, 2009 Heriot-Watt University, Edinburgh, Scotland http://www.macs.hw.ac.uk/~greg/ISS-AiPL Overview ~~~~~~~~ This four-day residential International Summer School on Advances in Programming Languages has a major theme of Concurrency, Distribution, and Multicore. Intended primarily for postgraduate research students, the School offers lectures and practical sessions on an engaging blend of cutting edge theoretical and practical techniques from international experts. The Summer School is supported by the Scottish Informatics and Computer Science Alliance (http://www.sicsa.ac.uk/), a Scottish Funding Council Research Pool. Participants from SICSA member institutions may attend at no cost. Confirmed Topics/Speakers * Static and dynamic languages, Prof Philip Wadler, University of Edinburgh * Compiler technology for data-parallel languages, Dr Sven-Bodo Scholz, University of Hertfordshire * New applications of parametricity, Dr Janis Voigtlander, Technical University of Dresden * Automatic vectorising compilation, Dr Paul Cockshott, University of Glasgow * Foundational aspects of size analysis, Prof Marko van Eekelen / Dr Olha Shakaravska, Radboud University Nijmegen * Context oriented programming, Dr Pascal Costanza, Vrije Universiteit Brussels * Multi-core programming, Dr Phil Trinder, Heriot-Watt University * Multi-core compilation, Dr Alastair Donaldson, Codeplay Software Ltd * Principles and Applications of Refinement Types, Dr Andrew D. Gordon, Microsoft Research, Cambridge * Resource aware programming in Hume, Prof Greg Michaelson, Heriot-Watt University / Prof Kevin Hammond, University of St Andrews * Haskell concurrency & parallelism, Dr Satnam Singh, Microsoft Research, Cambridge Location ~~~~~~~~ The Summer School is at Heriot-Watt University's Riccarton campus, set in pleasant parkland to the west of Edinburgh, with easy access to the airport, city and central Scotland (http://www.hw.ac.uk/welcome/directions.htm). The Summer School immediately precedes the 2009 International Conference on Functional Programming (http://www.cs.nott.ac.uk/~gmh/icfp09.html) and takes place during the Edinburgh International Festival (http://www.eif.co.uk/) , and the associated Edinburgh Festival Fringe (http://www.edfringe.com/) and Edinburgh International Book Festival (http://www.edbookfest.co.uk/) Steering Committee ~~~~~~~~~~~~~~~~~~ Prof Prof Greg Michaelson, Heriot-Watt University (Convenor), Prof Kevin Hammond, University of St Andrews Dr Patricia Johann, University of Strathclyde Prof Philip Wadler, University of Edinburgh Fee ~~~ Full rate: ?400; (free for SICSA students) Includes: four nights single room, en-suite accommodation with breakfast, lunch and dinner, plus coffee breaks and session materials. Day rate: ?200; (free for SICSA students) Includes: lunch, coffee breaks, session materials Registration of Interest ~~~~~~~~~~~~~~~~~~~~~~~~ If you are interested in attending the International Summer School, please complete the form available from (http://www.macs.hw.ac.uk/~greg/ISS-AiPL/ISS-AiPL%20register.doc) or below, and return it to: ********** International Summer School on Advances in Programming Languages 25th-28th August, 2009 Heriot-Watt University, Edinburgh, Scotland Registration of Interest Name: Address: Email: Phone: SICSA Uni: Yes / No Rate: Full / Day Accessibility requirements: Dietary requirements: Return to: ISS-AiPL-register@macs.hw.ac.uk ********** From dons at galois.com Tue May 12 11:21:04 2009 From: dons at galois.com (Don Stewart) Date: Tue May 12 11:08:30 2009 Subject: [Haskell-cafe] Developing 3 dimensional interactive environments/functional objects In-Reply-To: <20090511185638.a7fe6210508103e9b2d8ae485714347f.5b5f86b555.wbe@email03.secureserver.net> References: <20090511185638.a7fe6210508103e9b2d8ae485714347f.5b5f86b555.wbe@email03.secureserver.net> Message-ID: <20090512152104.GC17347@whirlpool.galois.com> paulfrancis: > Does any programmer on this mailing list have experience with developing 3 > dimensional interactive environments/functional objects within them, au Second > Life? Is Haskell useful for such an endeavor? Mm.. Anygma http://www.anygma.com/JobOfferA.html gamr7 http://www.gamr7.com/ Both use Haskell to some extent. From rjones at redhat.com Tue May 12 11:47:48 2009 From: rjones at redhat.com (Richard W.M. Jones) Date: Tue May 12 11:33:35 2009 Subject: [Haskell-cafe] [ANNOUNCE] Bindings for libguestfs In-Reply-To: <20090512151808.GB17347@whirlpool.galois.com> References: <20090511085246.GA4476@amd.home.annexia.org> <20090512151808.GB17347@whirlpool.galois.com> Message-ID: <20090512154748.GA14274@amd.home.annexia.org> On Tue, May 12, 2009 at 08:18:08AM -0700, Don Stewart wrote: > rjones: > > I added some partial bindings for libguestfs[1] here: > > > > http://git.et.redhat.com/?p=libguestfs.git;a=blob;f=haskell/Guestfs.hs;hb=HEAD > > > > Some very simple example programs which use these bindings: > > > > http://git.et.redhat.com/?p=libguestfs.git;a=tree;f=haskell;hb=HEAD > > > > Any comments welcome. My Haskell skills are pretty terrible, so I'm > > sure there are many ways these can be improved. > > > > If someone wants to look at binding the rest of the API, then please > > send me some patches. (Note that the Guestfs.hs file is automatically > > generated). > > Very cool. Are you likely to upload to hackage? I think it should be a bit more complete before uploading it. It only covers about half the interface. > > BTW, I found the documentation on writing FFIs very contradictory and > > incomplete. For example, I was completely defeated trying to find > > ways to do simple stuff like passing in integers or returning > > booleans. *Potentially* Haskell's FFI seems like it might be one of > > the best out of the languages I've used so far, but it needs way more > > documentation and examples. > > Perhaps read the FFI chapter of RWH (online?) > > What resources were you using to grok the FFI? Well, Real World Haskell was one of the resources: http://book.realworldhaskell.org/read/interfacing-with-c-the-ffi.html (And it's fine, one of the better resources as an introduction. But not thorough enough to cover the booleans / returning complex structs problems I had). The others, as I remember it, were: http://www.haskell.org/haskellwiki/FFI_Introduction http://www.haskell.org/haskellwiki/FFICookBook (Made me think it was simple, but doesn't really cover much once I got down to the details) http://www.cse.unsw.edu.au/~chak/haskell/ffi/ & the documentation for 'Foreign' etc in the Haddock-generated library docs. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/ From dons at galois.com Tue May 12 12:00:27 2009 From: dons at galois.com (Don Stewart) Date: Tue May 12 11:47:29 2009 Subject: [Haskell-cafe] [ANNOUNCE] Bindings for libguestfs In-Reply-To: <20090512154748.GA14274@amd.home.annexia.org> References: <20090511085246.GA4476@amd.home.annexia.org> <20090512151808.GB17347@whirlpool.galois.com> <20090512154748.GA14274@amd.home.annexia.org> Message-ID: <20090512160027.GA19450@whirlpool.galois.com> rjones: > On Tue, May 12, 2009 at 08:18:08AM -0700, Don Stewart wrote: > > rjones: > > > I added some partial bindings for libguestfs[1] here: > > > > > > http://git.et.redhat.com/?p=libguestfs.git;a=blob;f=haskell/Guestfs.hs;hb=HEAD > > > > > > Some very simple example programs which use these bindings: > > > > > > http://git.et.redhat.com/?p=libguestfs.git;a=tree;f=haskell;hb=HEAD > > > > > > Any comments welcome. My Haskell skills are pretty terrible, so I'm > > > sure there are many ways these can be improved. > > > > > > If someone wants to look at binding the rest of the API, then please > > > send me some patches. (Note that the Guestfs.hs file is automatically > > > generated). > > > > Very cool. Are you likely to upload to hackage? > > I think it should be a bit more complete before uploading it. It only > covers about half the interface. > > > > BTW, I found the documentation on writing FFIs very contradictory and > > > incomplete. For example, I was completely defeated trying to find > > > ways to do simple stuff like passing in integers or returning > > > booleans. *Potentially* Haskell's FFI seems like it might be one of > > > the best out of the languages I've used so far, but it needs way more > > > documentation and examples. > > > > Perhaps read the FFI chapter of RWH (online?) > > > > What resources were you using to grok the FFI? > > Well, Real World Haskell was one of the resources: > > http://book.realworldhaskell.org/read/interfacing-with-c-the-ffi.html > > (And it's fine, one of the better resources as an introduction. But > not thorough enough to cover the booleans / returning complex structs > problems I had). > > The others, as I remember it, were: > > http://www.haskell.org/haskellwiki/FFI_Introduction > http://www.haskell.org/haskellwiki/FFICookBook > > (Made me think it was simple, but doesn't really cover much once I got > down to the details) > > http://www.cse.unsw.edu.au/~chak/haskell/ffi/ > > & the documentation for 'Foreign' etc in the Haddock-generated library > docs. Very good. I wonder if /you/ could note down (maybe on the wiki) the things you need to work out - then we would have a tutorial from someone learning on the job. That could then be fleshed out into a fuller tutorial? -- Donn From ganesh.sittampalam at credit-suisse.com Tue May 12 12:12:16 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Tue May 12 11:58:57 2009 Subject: [darcs-users] [Haskell-cafe] Darcs as undo/redo system? In-Reply-To: <200905121312.48917.g9ks157k@acme.softbase.org> References: <200905121312.48917.g9ks157k@acme.softbase.org> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B01ABAAFE@ELON17P32001A.csfb.cs-group.com> Wolfgang Jeltsch wrote: > Am Freitag, 8. Mai 2009 18:43 schrieb Jason Dagit: >> If you wanted to work on this, I would encourage you to read more >> about patch theory[1,2,3,4] and also try out libdarcs[5]. > > Is libdarcs the same as the darcs library package on Hackage (which > exports the darcs API)? Yes. Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From danielkcook at gmail.com Tue May 12 12:18:55 2009 From: danielkcook at gmail.com (Dan) Date: Tue May 12 12:04:37 2009 Subject: [Haskell-cafe] haskell & cuda? Message-ID: <4A09A16F.3020809@gmail.com> Hi, Does anyone know if there's a compiler from Data-Parallel Haskell to GPU code? I saw a paper on it a while back, but Google hasn't turned up any code. Cheers, - Dan -------------- next part -------------- A non-text attachment was scrubbed... Name: danielkcook.vcf Type: text/x-vcard Size: 157 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090512/1e20281c/danielkcook.vcf From wagner.andrew at gmail.com Tue May 12 12:54:57 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Tue May 12 12:40:18 2009 Subject: [Haskell-cafe] Structural sharing in haskell data structures? Message-ID: So I've been reading a lot about a (relatively) new language called Clojure. One of its goals is to make concurrency easier via a built-in home-grown STM. Anyway, one of the ways it tries to do this is to have completely immutable data structures. Every time I read a tutorial about this in Clojure, it says "...yes, it sounds awful to think that your whole data structure gets copied every time you want to make a change to it, but it's sane because of a technique called structural sharing". Yet every time I hear immutability talked about in Haskell, what I hear is "...yes, it sounds awful to think that your whole data structure gets copied every time you want to make a change to it, but it's sane because of laziness...unless you need the whole data structure...". So I'm just curious, does GHC use structural sharing or something similar? Do other implementations? Does it matter? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090512/4e32950b/attachment.html From applebiz89 at hotmail.com Tue May 12 12:59:47 2009 From: applebiz89 at hotmail.com (applebiz89) Date: Tue May 12 12:45:05 2009 Subject: [Haskell-cafe] Main function error Message-ID: <23506481.post@talk.nabble.com> I have compiled each function independently and they have compiled the only problem is the main function.. I keep getting the error 'films not defined' and I am not sure why [code] type Title = String type Director = String type Year = Int type Fan = String data Film = Film Title Director Year [Fan] deriving Show -- List of films testDatabase :: [Film] testDatabase = [ (Film "Casino Royale" "Martin Campbell" 2006 ["Garry", "Dave", "Zoe"])] -- Function filmsInGivenYear :: Year -> [Film] -> [String] filmsInGivenYear year' films = [ title | (Film title director year fans) <- films, year == year'] doFilmsInGivenYear :: [Film] -> IO () doFilmsInGivenYear films = do putStrLn "which year?" text <- getLine let year' = read text :: Int let answer = filmsInGivenYear year' films print answer main :: IO () main = do doFilmsInGivenYear films main [/code] if the other functions are compiling without this error im not sure as to why the main function does not compile because of the films...any light on this? Thanks -- View this message in context: http://www.nabble.com/Main-function-error-tp23506481p23506481.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From dons at galois.com Tue May 12 12:59:01 2009 From: dons at galois.com (Don Stewart) Date: Tue May 12 12:45:39 2009 Subject: [Haskell-cafe] Stream-fusion without the lists In-Reply-To: <179DE459-B966-4B14-B1B7-534745E385CD@cse.unsw.edu.au> References: <4cf038ee0905112145q2c1dfed2hfdb324e3ba5d85b6@mail.gmail.com> <179DE459-B966-4B14-B1B7-534745E385CD@cse.unsw.edu.au> Message-ID: <20090512165901.GB19645@whirlpool.galois.com> rl: > On 12/05/2009, at 14:45, Reiner Pope wrote: > >> The Stream datatype seems to be much better suited to representing >> loops than the list datatype is. So, instead of programming with the >> lists, why don't we just use the Stream datatype directly? > > I think the main reason is that streams don't store data and therefore > don't support sharing. That is, in > > let xs = map f ys in (sum xs, product xs) > > the elements of xs will be computed once if it is a list but twice if it > is a stream. > The other issue is reminding developers to preserve stream invariants, so as not to break the heavy duty rewriting that's going to happen to their code. Still, if someone finds a use for it, proceed! -- Don From max.rabkin at gmail.com Tue May 12 13:56:56 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Tue May 12 13:42:53 2009 Subject: [Haskell-cafe] Stream-fusion without the lists In-Reply-To: <179DE459-B966-4B14-B1B7-534745E385CD@cse.unsw.edu.au> References: <4cf038ee0905112145q2c1dfed2hfdb324e3ba5d85b6@mail.gmail.com> <179DE459-B966-4B14-B1B7-534745E385CD@cse.unsw.edu.au> Message-ID: On Tue, May 12, 2009 at 1:39 PM, Roman Leshchinskiy wrote: > let xs = map f ys in (sum xs, product xs) > > the elements of xs will be computed once if it is a list but twice if it is > a stream. If you're using lists for loops rather than data, that's what you want (what you probably really want is cfoldl' ((,) <$> sumF <*> productF) xs, in terms of combinable folds). > Roman --Max From max.rabkin at gmail.com Tue May 12 14:04:06 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Tue May 12 13:49:50 2009 Subject: [Haskell-cafe] commending "Design concepts in programming languages" In-Reply-To: <200905121341.06138.g9ks157k@acme.softbase.org> References: <5e0214850904291029gd68128bofccf9691c400adf4@mail.gmail.com> <200905081323.09106.g9ks157k@acme.softbase.org> <200905081431.09883.daniel.is.fischer@web.de> <200905121341.06138.g9ks157k@acme.softbase.org> Message-ID: On Tue, May 12, 2009 at 1:41 PM, Wolfgang Jeltsch wrote: > At least, I cannot > remember seeing the other notation (first morphism on the left) in category > theory literature so far. It?s just that my above-mentioned professor told me > that category theorists would use the first-morphism-on-the-left notation. I've seen the notation f;g for g.f somewhere (and Wikipedia mentions it). I think it's less ambiguous than just fg (which I've seen for f.g too), but in Haskell we have the option of >>>. A flipped application might be nice to go with it. How about >$> ? --Max From nowgate at yahoo.com Tue May 12 14:08:11 2009 From: nowgate at yahoo.com (michael rice) Date: Tue May 12 13:53:35 2009 Subject: [Haskell-cafe] Inferred typing? Message-ID: <293136.77564.qm@web31105.mail.mud.yahoo.com> I was looking at some code and couldn't figure out how it was returning a list since there were no list constructors present. Thanks! Michael --- On Tue, 5/12/09, Brent Yorgey wrote: From: Brent Yorgey Subject: Re: [Haskell-cafe] Inferred typing? To: haskell-cafe@haskell.org Date: Tuesday, May 12, 2009, 7:50 AM On Mon, May 11, 2009 at 10:59:01PM -0700, michael rice wrote: > In the code below, is the type returned by the return functions inferred from > the result type in the function type signature, i.e., just change the result > type to Maybe Int and the code will return a Maybe monad, (Just 4), instead of > a List monad? Indeed, it is.? Try it! =) -Brent _______________________________________________ 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/20090512/85402a69/attachment.html From andrewcoppin at btinternet.com Tue May 12 14:25:09 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Tue May 12 14:10:23 2009 Subject: [Haskell-cafe] Stream-fusion without the lists In-Reply-To: <179DE459-B966-4B14-B1B7-534745E385CD@cse.unsw.edu.au> References: <4cf038ee0905112145q2c1dfed2hfdb324e3ba5d85b6@mail.gmail.com> <179DE459-B966-4B14-B1B7-534745E385CD@cse.unsw.edu.au> Message-ID: <4A09BF05.1080609@btinternet.com> Roman Leshchinskiy wrote: > On 12/05/2009, at 14:45, Reiner Pope wrote: > >> The Stream datatype seems to be much better suited to representing >> loops than the list datatype is. So, instead of programming with the >> lists, why don't we just use the Stream datatype directly? This is more or less the conclusion I came to myself the other day when I sat down and tried to implement stream fusion myself (just for giggles). > I think the main reason is that streams don't store data and therefore > don't support sharing. That is, in > > let xs = map f ys in (sum xs, product xs) > > the elements of xs will be computed once if it is a list but twice if > it is a stream. ...and I hadn't thought of this part! ;-) From haskell at colquitt.org Tue May 12 15:11:32 2009 From: haskell at colquitt.org (John Dorsey) Date: Tue May 12 14:56:51 2009 Subject: [Haskell-cafe] [ANNOUNCE] Bindings for libguestfs In-Reply-To: <20090511085246.GA4476@amd.home.annexia.org> References: <20090511085246.GA4476@amd.home.annexia.org> Message-ID: <20090512191132.GG3278@colquitt.org> Richard, > I added some partial bindings for libguestfs[1] here: > http://git.et.redhat.com/?p=libguestfs.git;a=blob;f=haskell/Guestfs.hs;hb=HEAD Terrific! Partial bindings are great. Thanks for releasing it. I haven't taken the time to look at your code, but... > BTW, I found the documentation on writing FFIs very contradictory and > incomplete. For example, I was completely defeated trying to find > ways to do simple stuff like passing in integers or returning > booleans. *Potentially* Haskell's FFI seems like it might be one of > the best out of the languages I've used so far, but it needs way more > documentation and examples. Can you be more specific about what needs improvement? I wrote a partial Haskell binding for Net-SNMP recently, and I got along pretty well using the API docs at http://www.haskell.org/ghc/docs/latest/html/libraries/index.html, and an example in RWH using hsc2hs. What did you see that was contradictory? Regards, John From miguelimo38 at yandex.ru Tue May 12 15:43:41 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Tue May 12 15:29:27 2009 Subject: [Haskell-cafe] List of exports of a module - are there alternatives? In-Reply-To: References: Message-ID: I think that it's not nice to export 200 declarations from a single module. On 12 May 2009, at 18:05, Maur?cio wrote: > Hi, > > When we want to list which declarations are exported by a module > we do: > > module Mod ( list of exports ) where ... > > Are there propositions to alternatives to that (I could not > find one)? Like, say, add a "do export" or "do not export" > tag to declarations we want to (not) export? > > (I think something like that could be nice when we have modules > with 200 declarations and just a few are (not) going to be > exported.) > > Thanks, > Maur?cio > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From wagner.andrew at gmail.com Tue May 12 15:51:17 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Tue May 12 15:37:39 2009 Subject: [Haskell-cafe] List of exports of a module - are there alternatives? In-Reply-To: References: Message-ID: On Tue, May 12, 2009 at 10:05 AM, Maur?cio wrote: > (I think something like that could be nice when we have modules > with 200 declarations and just a few are (not) going to be > exported.) > > Thanks, > Maur?cio > > Uh, show me such a module, and I'll show you a module that's quite bloated and desperately needs to be refactored. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090512/9e4deba3/attachment.html From ryani.spam at gmail.com Tue May 12 16:12:38 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue May 12 16:00:47 2009 Subject: [Haskell-cafe] Data.Map lookup signature In-Reply-To: <45fccde20905110737w49227944l55415612d68ca8f3@mail.gmail.com> References: <45fccde20905110737w49227944l55415612d68ca8f3@mail.gmail.com> Message-ID: <2f9b2d30905121312m28a3d158j44dcccdb8dc11312@mail.gmail.com> Maybe is an instance of Monad; the second signature is just more general than the first. class Monad m where return :: a -> m a (>>=) :: m a -> (a -> m b) -> m b fail :: String -> m a Map lookup only uses "return" and "fail"; for Maybe these are defined as follows: return x = Just x fail s = Nothing So it's really the same thing. -- ryan On Mon, May 11, 2009 at 8:37 AM, Nico Rolle wrote: > Hi everyone. > > The docs in the web on http://www.haskell.org/ghc/docs > define Data.Map.lookup as follows: > http://www.haskell.org/ghc/docs > lookup :: Ord k => k -> Map k a -> Maybe a > but my version of ghci does i like that: > Data.Map.lookup :: (Ord k, Monad m) => k -> Data.Map.Map k a -> m a > but i need the 1. one. > my version of ghci is 6.8.2 > regards > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ryani.spam at gmail.com Tue May 12 16:16:43 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue May 12 16:01:50 2009 Subject: [Haskell-cafe] Stream-fusion without the lists In-Reply-To: <179DE459-B966-4B14-B1B7-534745E385CD@cse.unsw.edu.au> References: <4cf038ee0905112145q2c1dfed2hfdb324e3ba5d85b6@mail.gmail.com> <179DE459-B966-4B14-B1B7-534745E385CD@cse.unsw.edu.au> Message-ID: <2f9b2d30905121316j4c59bfbfq466f535f354f4bf@mail.gmail.com> Sure, but this definition leaks space, which I think is one of the points that Reiner made. -- ryan On Tue, May 12, 2009 at 5:39 AM, Roman Leshchinskiy wrote: > On 12/05/2009, at 14:45, Reiner Pope wrote: > >> The Stream datatype seems to be much better suited to representing >> loops than the list datatype is. So, instead of programming with the >> lists, why don't we just use the Stream datatype directly? > > I think the main reason is that streams don't store data and therefore don't > support sharing. That is, in > > let xs = map f ys in (sum xs, product xs) > > the elements of xs will be computed once if it is a list but twice if it is > a stream. > > Roman > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ryani.spam at gmail.com Tue May 12 16:12:38 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue May 12 16:04:37 2009 Subject: [Haskell-cafe] Data.Map lookup signature In-Reply-To: <45fccde20905110737w49227944l55415612d68ca8f3@mail.gmail.com> References: <45fccde20905110737w49227944l55415612d68ca8f3@mail.gmail.com> Message-ID: <2f9b2d30905121312m28a3d158j44dcccdb8dc11312@mail.gmail.com> Maybe is an instance of Monad; the second signature is just more general than the first. class Monad m where return :: a -> m a (>>=) :: m a -> (a -> m b) -> m b fail :: String -> m a Map lookup only uses "return" and "fail"; for Maybe these are defined as follows: return x = Just x fail s = Nothing So it's really the same thing. -- ryan On Mon, May 11, 2009 at 8:37 AM, Nico Rolle wrote: > Hi everyone. > > The docs in the web on http://www.haskell.org/ghc/docs > define Data.Map.lookup as follows: > http://www.haskell.org/ghc/docs > lookup :: Ord k => k -> Map k a -> Maybe a > but my version of ghci does i like that: > Data.Map.lookup :: (Ord k, Monad m) => k -> Data.Map.Map k a -> m a > but i need the 1. one. > my version of ghci is 6.8.2 > regards > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From xj2106 at columbia.edu Tue May 12 16:59:36 2009 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Tue May 12 16:45:17 2009 Subject: [Haskell-cafe] IO trouble Message-ID: <873abat4uf.fsf@columbia.edu> Hi, I can't really describe it in the subject. So let me try to do it here. I have two functions > f :: a -> b > g :: (a -> b) -> c -> d and I use them as > gf :: c -> d > gf = g f Now I want to handle exceptions in f and redefine f as in f' > f' :: a -> IO (Either e b) So my question is how to define gf' now to use f' instead of f? > gf' :: c -> IO (Either e d) Thanks in advance. Xiao-Yong -- c/* __o/* <\ * (__ */\ < From dons at galois.com Tue May 12 16:58:56 2009 From: dons at galois.com (Don Stewart) Date: Tue May 12 16:45:37 2009 Subject: [Haskell-cafe] haskell & cuda? In-Reply-To: <4A09A16F.3020809@gmail.com> References: <4A09A16F.3020809@gmail.com> Message-ID: <20090512205856.GT19645@whirlpool.galois.com> Lee, Chakravarty et al Data Parallelism in Haskell : ICFP PC Portland 2009 http://bit.ly/17EQcl The other thing to look for is Obsidian, from Chalmers danielkcook: > Hi, > > Does anyone know if there's a compiler from Data-Parallel Haskell to GPU > code? I saw a paper on it a while back, but Google hasn't turned up any > code. > > Cheers, > - Dan > begin:vcard > fn:Daniel K. Cook > n:Cook;Daniel K. > email;internet:danielkcook@gmail.com > tel;cell:+44 (0) 7949 125 491 > x-mozilla-html:TRUE > version:2.1 > end:vcard > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From vigalchin at gmail.com Tue May 12 17:23:51 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Tue May 12 17:16:07 2009 Subject: [Haskell-cafe] caml build In-Reply-To: <1242130982-sup-5203@ausone.inria.fr> References: <5ae4f2ba0905111527hebf8e95i88df612017522d39@mail.gmail.com> <1242130982-sup-5203@ausone.inria.fr> Message-ID: <5ae4f2ba0905121423k12df07f1k63b06506dc3de884@mail.gmail.com> Hi Nicolas, I am starting a "caml build". I want line by line which module is being built so when I get an error I have a context to reason about to fix the problem. Got it? Regards, Vasili On Tue, May 12, 2009 at 7:23 AM, Nicolas Pouillard < nicolas.pouillard@gmail.com> wrote: > Excerpts from Vasili I. Galchin's message of Tue May 12 00:27:26 +0200 > 2009: > > Hello, > > > > I have forgotten whether I sent this posting out. Sorry if I did (I > > didn't see on Haskell cafe archive). > > > > I am building Swish and getting an error. I want to follow the > > progress of "swish build" ... I don't see an additional parameter like > > verbose mode that will tell which swish component is being built. ??? > > I don't get the relation with the subject of your post, can you elaborate? > > Best regards, > > -- > Nicolas Pouillard > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090512/9fe0cf81/attachment.html From dons at galois.com Tue May 12 17:33:32 2009 From: dons at galois.com (Don Stewart) Date: Tue May 12 17:20:25 2009 Subject: [Haskell-cafe] Structural sharing in haskell data structures? In-Reply-To: References: Message-ID: <20090512213332.GW19645@whirlpool.galois.com> wagner.andrew: > So I've been reading a lot about a (relatively) new language called Clojure. > One of its goals is to make concurrency easier via a built-in home-grown STM. > Anyway, one of the ways it tries to do this is to have completely immutable > data structures. Every time I read a tutorial about this in Clojure, it says > "...yes, it sounds awful to think that your whole data structure gets copied > every time you want to make a change to it, but it's sane because of a > technique called structural sharing". Yet every time I hear immutability talked > about in Haskell, what I hear is "...yes, it sounds awful to think that your > whole data structure gets copied every time you want to make a change to it, > but it's sane because of laziness...unless you need the whole data > structure...". So I'm just curious, does GHC use structural sharing or > something similar? Do other implementations? Does it matter? Purity allows our data structures to have a lot of sharing. This is separate to laziness. Laziness lets us build up interesting structures that have unusual sharing. Actually, what kind of persistant structures does Clojure have at this stage? I was under the impression they were reusing Java data structures. E.g. some of the nicer ones on hackage are zippers, patricia tries, finger trees, which I can't imaging have been ported. -- Don From tswaterman at gmail.com Tue May 12 17:36:50 2009 From: tswaterman at gmail.com (Scott A. Waterman) Date: Tue May 12 17:22:01 2009 Subject: [Haskell-cafe] haskell & cuda? In-Reply-To: <4A09A16F.3020809@gmail.com> References: <4A09A16F.3020809@gmail.com> Message-ID: <01CD1FF8-7B25-46C4-9E9D-FAA43AC1FD25@gmail.com> Try reaching Manuel Chakravarty, http://justtesting.org/ and his colleague Sean Lee at Galois. Slides from his talk on GPU.gen : Just gave my talk on "Data Parallelism in Haskell" at PSU; here the slides: http://bit.ly/17EQcl and slides from an earlier Galois talk: http://www.galois.com/blog/2008/08/29/gpugen-bringing-the-power-of-gpus-into-the-haskell-world/ --ts On May 12, 2009, at 9:18 AM, Dan wrote: > Hi, > > Does anyone know if there's a compiler from Data-Parallel Haskell to > GPU code? I saw a paper on it a while back, but Google hasn't > turned up any code. > > Cheers, > - Dan > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jochem at functor.nl Tue May 12 17:39:56 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Tue May 12 17:25:08 2009 Subject: [Haskell-cafe] Main function error In-Reply-To: <23506481.post@talk.nabble.com> References: <23506481.post@talk.nabble.com> Message-ID: <4A09ECAC.60105@functor.nl> applebiz89 wrote: > main :: IO () > main = do > doFilmsInGivenYear films > main You pass as argument to 'doFilmsInGivenYear' the value 'films', which is not defined. Instead, I think you meant 'testDatabase'. All the best, -- Jochem Berndsen | jochem@functor.nl GPG: 0xE6FABFAB From bos at serpentine.com Tue May 12 17:47:16 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Tue May 12 17:32:53 2009 Subject: [Haskell-cafe] Problem with text and text-icu packages In-Reply-To: <5a1362990905120716m201c0ed0gc496795491a9268e@mail.gmail.com> References: <5a1362990905120716m201c0ed0gc496795491a9268e@mail.gmail.com> Message-ID: On Tue, May 12, 2009 at 7:16 AM, David Carter wrote: > Specifically, a1.txt contains bytes 97 and 10, while a2.txt contains > bytes 224 160 139 237 144 164. > > Have I misconstrued things, or is this a bug? > It's probably a bug, and it has (I hope) already been found and fixed. Please try the darcs version of text instead: http://code.haskell.org/text/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090512/7382a33e/attachment.html From tswaterman at gmail.com Tue May 12 17:49:05 2009 From: tswaterman at gmail.com (Scott A. Waterman) Date: Tue May 12 17:34:13 2009 Subject: [Haskell-cafe] haskell & cuda? In-Reply-To: <01CD1FF8-7B25-46C4-9E9D-FAA43AC1FD25@gmail.com> References: <4A09A16F.3020809@gmail.com> <01CD1FF8-7B25-46C4-9E9D-FAA43AC1FD25@gmail.com> Message-ID: <59F4702A-2CBA-41A1-BBE1-A18FA3DB9E8E@gmail.com> Sean and Manuel are both at Univ. New South Wales http://www.cse.unsw.edu.au/~seanl/ http://www.cse.unsw.edu.au/~chak/ On May 12, 2009, at 2:36 PM, Scott A. Waterman wrote: > Try reaching Manuel Chakravarty, http://justtesting.org/ > and his colleague Sean Lee at Galois. > > Slides from his talk on GPU.gen : > Just gave my talk on "Data Parallelism in Haskell" at PSU; here the > slides: http://bit.ly/17EQcl > > and slides from an earlier Galois talk: > http://www.galois.com/blog/2008/08/29/gpugen-bringing-the-power-of-gpus-into-the-haskell-world/ > > > --ts > > On May 12, 2009, at 9:18 AM, Dan wrote: > >> Hi, >> >> Does anyone know if there's a compiler from Data-Parallel Haskell >> to GPU code? I saw a paper on it a while back, but Google hasn't >> turned up any code. >> >> Cheers, >> - Dan >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > From danielkcook at gmail.com Tue May 12 17:54:01 2009 From: danielkcook at gmail.com (Dan) Date: Tue May 12 17:39:34 2009 Subject: [Haskell-cafe] haskell & cuda? In-Reply-To: <01CD1FF8-7B25-46C4-9E9D-FAA43AC1FD25@gmail.com> References: <4A09A16F.3020809@gmail.com> <01CD1FF8-7B25-46C4-9E9D-FAA43AC1FD25@gmail.com> Message-ID: <4A09EFF9.8070905@gmail.com> Doesn't look like there's code out there - will try e-mailing the authors of the various papers/presentations. This e-mail also counts as an open plea to those compiler wizards working on this stuff: feel free to put beta buggy versions of your code online :) Thanks, - Dan Scott A. Waterman wrote: > Try reaching Manuel Chakravarty, http://justtesting.org/ > and his colleague Sean Lee at Galois. > > Slides from his talk on GPU.gen : > Just gave my talk on "Data Parallelism in Haskell" at PSU; here the > slides: http://bit.ly/17EQcl > > and slides from an earlier Galois talk: > http://www.galois.com/blog/2008/08/29/gpugen-bringing-the-power-of-gpus-into-the-haskell-world/ > > > > --ts > > On May 12, 2009, at 9:18 AM, Dan wrote: > >> Hi, >> >> Does anyone know if there's a compiler from Data-Parallel Haskell to >> GPU code? I saw a paper on it a while back, but Google hasn't turned >> up any code. >> >> Cheers, >> - Dan >> _______________________________________________ >> 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: danielkcook.vcf Type: text/x-vcard Size: 157 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090512/b1781074/danielkcook.vcf From wagner.andrew at gmail.com Tue May 12 18:02:09 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Tue May 12 17:47:20 2009 Subject: [Haskell-cafe] Structural sharing in haskell data structures? In-Reply-To: <20090512213332.GW19645@whirlpool.galois.com> References: <20090512213332.GW19645@whirlpool.galois.com> Message-ID: > > Purity allows our data structures to have a lot of sharing. > This is separate to laziness. > Ah, so haskell does do it. Interesting that it so rarely comes up, whereas it's frequently mentioned in clojure. > > Laziness lets us build up interesting structures that have unusual > sharing. > > Actually, what kind of persistant structures does Clojure have at this > stage? I was under the impression they were reusing Java data > structures. E.g. some of the nicer ones on hackage are zippers, patricia > tries, finger trees, which I can't imaging have been ported. > It has some built-in persistent data structures: lists, vectors (arrays), maps, and sets. It also has strong interoperability with Java, so that any existing Java library can easily be used in Clojure code. In some ways, that makes it a VERY mature language already. > -- Don > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090512/ce6cf377/attachment.html From dons at galois.com Tue May 12 18:06:15 2009 From: dons at galois.com (Don Stewart) Date: Tue May 12 17:52:51 2009 Subject: [Haskell-cafe] Structural sharing in haskell data structures? In-Reply-To: References: <20090512213332.GW19645@whirlpool.galois.com> Message-ID: <20090512220615.GX19645@whirlpool.galois.com> wagner.andrew: > Purity allows our data structures to have a lot of sharing. > This is separate to laziness. > > > Ah, so haskell does do it. Interesting that it so rarely comes up, whereas it's > frequently mentioned in clojure. I think it is just assumed, since that's been the case for 20 years or more now. Sharing is kind of exciting to the ex-Java people looking at Clojure, I guess, since it's a new idea. So they talk about it. > Laziness lets us build up interesting structures that have unusual > sharing. > > Actually, what kind of persistant structures does Clojure have at this > stage? I was under the impression they were reusing Java data > structures. E.g. some of the nicer ones on hackage are zippers, patricia > tries, finger trees, which I can't imaging have been ported. > > It has some built-in persistent data structures: lists, vectors (arrays), maps, > and sets. It also has strong interoperability with Java, so that any existing > Java library can easily be used in Clojure code. In some ways, that makes it a > VERY mature language already. Certainly the JVM and its libraries are mature. Looks like yet another example of tech incubation in Haskell, then dispersal outwards to other langs. The more the better. -- Don From vanenkj at gmail.com Tue May 12 18:10:14 2009 From: vanenkj at gmail.com (John Van Enk) Date: Tue May 12 17:55:35 2009 Subject: [Haskell-cafe] Main function error In-Reply-To: <23506481.post@talk.nabble.com> References: <23506481.post@talk.nabble.com> Message-ID: What would you expect the program to output? You probably mean 'testDatabase' instead of 'films'. /jve On Tue, May 12, 2009 at 12:59 PM, applebiz89 wrote: > > I have compiled each function independently and they have compiled the only > problem is the main function.. > > I keep getting the error 'films not defined' and I am not sure why > > [code] > > type Title = String > type Director = String > type Year = Int > type Fan = String > > data Film = Film Title Director Year [Fan] deriving Show > > -- List of films > > testDatabase :: [Film] > testDatabase = [ (Film "Casino Royale" "Martin Campbell" 2006 ["Garry", > "Dave", "Zoe"])] > > -- Function > > filmsInGivenYear :: Year -> [Film] -> [String] > filmsInGivenYear year' films = [ title | (Film title director year fans) <- > films, year == year'] > > doFilmsInGivenYear :: [Film] -> IO () > doFilmsInGivenYear films = do putStrLn "which year?" > text <- getLine > let year' = read text :: Int > let answer = filmsInGivenYear year' films > print answer > > main :: IO () > main = do > doFilmsInGivenYear films > main > > [/code] > > if the other functions are compiling without this error im not sure as to > why the main function does not compile because of the films...any light on > this? > > Thanks > -- > View this message in context: > http://www.nabble.com/Main-function-error-tp23506481p23506481.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090512/fcddf5f4/attachment.html From alexander.dunlap at gmail.com Tue May 12 18:06:31 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Tue May 12 17:58:18 2009 Subject: [Haskell-cafe] Main function error In-Reply-To: <23506481.post@talk.nabble.com> References: <23506481.post@talk.nabble.com> Message-ID: <57526e770905121506i3509dbd6xb5a885bc3ab6e55@mail.gmail.com> On Tue, May 12, 2009 at 9:59 AM, applebiz89 wrote: > > I have compiled each function independently and they have compiled the only > problem is the main function.. > > I keep getting the error 'films not defined' and I am not sure why > > [code] > > type Title = String > type Director = String > type Year = Int > type Fan = String > > data Film = Film Title Director Year [Fan] deriving Show > > -- List of films > > testDatabase :: [Film] > testDatabase = [ (Film "Casino Royale" "Martin Campbell" 2006 ["Garry", > "Dave", "Zoe"])] > > -- Function > > filmsInGivenYear :: Year -> [Film] -> [String] > filmsInGivenYear year' films = [ title | (Film title director year fans) <- > films, year == year'] > > doFilmsInGivenYear :: [Film] -> IO () > doFilmsInGivenYear films ?= do putStrLn "which year?" > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? text <- getLine > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? let year' = read text :: Int > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? let answer = filmsInGivenYear year' films > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? print answer > > main :: IO () > main = do > ? ? ? ? doFilmsInGivenYear films > ? ? ? ? main > > [/code] > > if the other functions are compiling without this error im not sure as to > why the main function does not compile because of the films...any light on > this? > > Thanks When you say 'doFilmsInGivenYear films', where does the variable 'films' come from? It's not defined anywhere in your program. That's what the compiler is complaining about. Alex From daniel.is.fischer at web.de Tue May 12 18:17:36 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue May 12 18:03:23 2009 Subject: [Haskell-cafe] Main function error In-Reply-To: <23506481.post@talk.nabble.com> References: <23506481.post@talk.nabble.com> Message-ID: <200905130017.36834.daniel.is.fischer@web.de> Am Dienstag 12 Mai 2009 18:59:47 schrieb applebiz89: > I have compiled each function independently and they have compiled the only > problem is the main function.. > > I keep getting the error 'films not defined' and I am not sure why > > [code] > > type Title = String > type Director = String > type Year = Int > type Fan = String > > data Film = Film Title Director Year [Fan] deriving Show > > -- List of films > > testDatabase :: [Film] > testDatabase = [ (Film "Casino Royale" "Martin Campbell" 2006 ["Garry", > "Dave", "Zoe"])] > > -- Function > > filmsInGivenYear :: Year -> [Film] -> [String] > filmsInGivenYear year' films = [ title | (Film title director year fans) <- > films, year == year'] > > doFilmsInGivenYear :: [Film] -> IO () > doFilmsInGivenYear films = do putStrLn "which year?" > text <- getLine > let year' = read text :: Int > let answer = filmsInGivenYear year' films > print answer > > main :: IO () > main = do > doFilmsInGivenYear films > main There is no top level definition of films in your module, main doesn't take any parameter, so films is not in scope in main. You probably meant testDatabase. However, main is not good even if you fix that, because every iteration of main, you work on the same database, you can't add new films or fans to films. You should do something like main :: IO () main = loop testDatabase loop db = do actionToRun <- selectAction newDB <- actionToRun db loop newDB selectAction = do putStrLn $ "Select action to run:\n 1-print films from given year\n 2-add fan for some film\n ..." ln <- getLine let n = read ln act = case n of 1 -> doFilmsInGivenYear 2 -> becomeFan .... return act doFilmInGivenYear :: [Film] -> IO [Film] doFilmInGivenYear films = do .... (your code) return films becomeFan :: [Film] -> IO [Film] becomeFan films = do who <- ask for name of fan whichFilm <- ask for film let newFilms = makeFan who whichFilm films return newFilms then you can alter your database and have the modified database available in the next iteration of loop. > > [/code] > > if the other functions are compiling without this error im not sure as to > why the main function does not compile because of the films...any light on > this? The other functions receive films as a parameter. > > Thanks From bugfact at gmail.com Tue May 12 18:24:45 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue May 12 18:09:54 2009 Subject: [Haskell-cafe] Developing 3 dimensional interactive environments/functional objects In-Reply-To: <20090512152104.GC17347@whirlpool.galois.com> References: <20090511185638.a7fe6210508103e9b2d8ae485714347f.5b5f86b555.wbe@email03.secureserver.net> <20090512152104.GC17347@whirlpool.galois.com> Message-ID: You might want to contact the author of RogueStar GL http://roguestar.downstairspeople.org/ On Tue, May 12, 2009 at 5:21 PM, Don Stewart wrote: > paulfrancis: > > Does any programmer on this mailing list have experience with > developing 3 > > dimensional interactive environments/functional objects within them, au > Second > > Life? Is Haskell useful for such an endeavor? > > Mm.. > > Anygma > http://www.anygma.com/JobOfferA.html > > gamr7 > http://www.gamr7.com/ > > Both use Haskell to some extent. > _______________________________________________ > 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/20090512/6a0c86d4/attachment.html From roconnor at theorem.ca Tue May 12 19:03:03 2009 From: roconnor at theorem.ca (roconnor@theorem.ca) Date: Tue May 12 18:48:26 2009 Subject: [Haskell-cafe] Removing mtl from the Haskell Platform Message-ID: I wanted to pass this idea around the cafe to get some thoughts before submitting a trac on this topic. I'd like to see the mtl removed from the Haskell Platform. The mtl was a tremendous step forward when it was developed. However, we have learned a few things about monad transformers since the development of the mtl, and it is time that we moved forward. There are at least 3 significant problem with the mtl. 1) `pass' should not be a member functions of the MonadWriter class. It is my understanding that there is no `MonadWriter w m => MonadWriter w (ContT s m)' instance because the `pass' function cannot be implemented. I'm also highly suspicious of some other methods too (I'm looking at you `local'). 2) The `StateT s (Cont r a)' instance of callCC is wrong. The paper on modular monad transformers describes why this is wrong. 3) I am told by many people that the order of the state and value pair in `State' is backwards. Actually, I'm not entirely sure what the issue is here, but I trust the people who say this. I think that use of the mtl should be deprecated so that we move on to improved monad transformer libraries. Having the mtl in the Haskell Platform does the opposite by further entrenching its use, possibly to the point where we may not be able to get rid of it for years. If I had to recommend a replace library, I would pick monadLib. However, there are other libraries, such as the mmtl and transformers and it's related packages that I haven't looked at, and may also make fine replacements for the mtl. -- Russell O'Connor ``All talk about `theft,''' the general counsel of the American Graphophone Company wrote, ``is the merest claptrap, for there exists no property in ideas musical, literary or artistic, except as defined by statute.'' From pumpkingod at gmail.com Tue May 12 19:18:51 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Tue May 12 19:09:51 2009 Subject: [Haskell-cafe] List of exports of a module - are there alternatives? In-Reply-To: References: Message-ID: I would like to see this too. Maybe just a private keyword that would make everything after it invisible to the outside (or until a public keyword appeared)? On Tue, May 12, 2009 at 10:05 AM, Maur?cio wrote: > Hi, > > When we want to list which declarations are exported by a module > we do: > > module Mod ( list of exports ) where ... > > Are there propositions to alternatives to that (I could not > find one)? Like, say, add a "do export" or "do not export" > tag to declarations we want to (not) export? > > (I think something like that could be nice when we have modules > with 200 declarations and just a few are (not) going to be > exported.) > > Thanks, > Maur?cio > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From rendel at cs.au.dk Tue May 12 19:25:55 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Tue May 12 19:11:46 2009 Subject: [Haskell-cafe] Structural sharing in haskell data structures? In-Reply-To: References: Message-ID: <4A0A0583.3030609@cs.au.dk> Hi, Andrew Wagner wrote: > So I'm just curious, does GHC use > structural sharing or something similar? Structural sharing is not a feature of implementations, but of libraries. Consider this example: -- a function to "change" the head of a list replaceHead y xs = y : tail xs -- a big list xs = [1..10000] -- two new list with changed head ys = replaceHead 42 xs zs = replaceHead 27 xs -- the length of our lists n = length xs + length ys + length zs In this example, n will be 30000, but even after evaluation xs, ys and zs, we have only 10002 cons cells allocated, because 9999 cons cells are shared between xs, ys and zs. This happens automatically in every language with references or pointers. However, it is only sane to do with immutable data structures, so programmers have to add extra code to explicitly avoid structural sharing in impure languages. Another example: xs = 1 : xs This list is infinite, but we have only one cons cell allocated. Tillmann From rendel at cs.au.dk Tue May 12 19:29:24 2009 From: rendel at cs.au.dk (Tillmann Rendel) Date: Tue May 12 19:15:16 2009 Subject: [Haskell-cafe] Main function error In-Reply-To: <23506481.post@talk.nabble.com> References: <23506481.post@talk.nabble.com> Message-ID: <4A0A0654.7040403@cs.au.dk> applebiz89 wrote: > I have compiled each function independently and they have compiled the only > problem is the main function.. > > I keep getting the error 'films not defined' and I am not sure why Well, because it is not defined :) > type Title = String > type Director = String > type Year = Int > type Fan = String > > data Film = Film Title Director Year [Fan] deriving Show > > -- List of films > > testDatabase :: [Film] > testDatabase = [ (Film "Casino Royale" "Martin Campbell" 2006 ["Garry", > "Dave", "Zoe"])] > > -- Function > > filmsInGivenYear :: Year -> [Film] -> [String] > filmsInGivenYear year' films = [ title | (Film title director year fans) <- > films, year == year'] > > doFilmsInGivenYear :: [Film] -> IO () > doFilmsInGivenYear films = do putStrLn "which year?" > text <- getLine > let year' = read text :: Int > let answer = filmsInGivenYear year' films > print answer > > main :: IO () > main = do At this point, the following names are defined: - testDatabase - filmsInGivenYear - doFilmsInGivenYear - main - (and names from libraries) > doFilmsInGivenYear films > main Here you use three names: - doFilmsInGivenYear (ok, is defined) - films (oups, not defined) - main (ok, is defined) So ghc tries to figure out what you mean with films, and fails, because it was not defined. Try using one of the defined names instead of films. Tillmann From la at iki.fi Tue May 12 20:45:24 2009 From: la at iki.fi (Lauri Alanko) Date: Tue May 12 20:32:24 2009 Subject: [Haskell-cafe] IO trouble In-Reply-To: <873abat4uf.fsf@columbia.edu> References: <873abat4uf.fsf@columbia.edu> Message-ID: <20090513004524.GA13768@cs.helsinki.fi> On Tue, May 12, 2009 at 04:59:36PM -0400, Xiao-Yong Jin wrote: > > f :: a -> b > > g :: (a -> b) -> c -> d > > gf :: c -> d > > gf = g f > > Now I want to handle exceptions in f and redefine f as in f' > > > f' :: a -> IO (Either e b) > > So my question is how to define gf' now to use f' instead of > f? > > > gf' :: c -> IO (Either e d) Use Control.Monad.Error.ErrorT, it's exactly for this. You have to "monadize" g to be able to pass f' as an argument to it. f' :: a -> ErrorT e IO b g' :: Monad m => (a -> m b) -> c -> m d gf' :: c -> ErrorT e IO d gf' = g' f' Here "e" should be some fixed instance of Error. HTH. Lauri From trentbuck at gmail.com Tue May 12 20:55:01 2009 From: trentbuck at gmail.com (Trent W. Buck) Date: Tue May 12 20:40:11 2009 Subject: [Haskell-cafe] Darcs as undo/redo system? References: <200905121312.48917.g9ks157k@acme.softbase.org> Message-ID: <30skj96cuy.fsf@alexlance.com> Wolfgang Jeltsch writes: > Am Freitag, 8. Mai 2009 18:43 schrieb Jason Dagit: >> If you wanted to work on this, I would encourage you to read more >> about patch theory[1,2,3,4] and also try out libdarcs[5]. > > Is libdarcs the same as the darcs library package on Hackage (which exports > the darcs API)? The Darcs package (both on Hackage and elsewhere) builds two things: the darcs(1) binary, and libHSdarcs. The latter is what Jason was referring to. Note that currently it just exposes all our internal functions, rather than providing a coherent (or stable!) API. From derek.a.elkins at gmail.com Tue May 12 21:05:41 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Tue May 12 20:51:58 2009 Subject: [Haskell-cafe] Kind of confusing In-Reply-To: <1242133775.4525.3.camel@flippa-eee> References: <4A08C62B.9080207@appsolutions.com> <1242133775.4525.3.camel@flippa-eee> Message-ID: <1242176741.27132.2.camel@derek-laptop> On Tue, 2009-05-12 at 14:09 +0100, Philippa Cowderoy wrote: > On Mon, 2009-05-11 at 20:43 -0400, Anton van Straaten wrote: > > Serious question: what is the significance of the question mark and > > double question marks in those signatures, or better yet, where can I > > read about it? > > > > I've forgotten where to find the details (try the GHC manual if you > haven't already?), but IIRC they're part of how GHC handles boxing. > http://hackage.haskell.org/trac/ghc/wiki/IntermediateTypes From dmehrtash at gmail.com Tue May 12 22:11:10 2009 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Tue May 12 21:57:41 2009 Subject: [Haskell-cafe] forall vs "=>" Message-ID: What is the difference between forall as in: runST:: ( forall s. STs a) -> a and the "=>" as in evalStateT:: Monadm => StateTs m a -> s -> m a thanks daryoush -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090512/adfb1003/attachment.html From chak at cse.unsw.edu.au Wed May 13 00:05:38 2009 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Tue May 12 23:52:05 2009 Subject: [Haskell-cafe] haskell & cuda? In-Reply-To: <4A09EFF9.8070905@gmail.com> References: <4A09A16F.3020809@gmail.com> <01CD1FF8-7B25-46C4-9E9D-FAA43AC1FD25@gmail.com> <4A09EFF9.8070905@gmail.com> Message-ID: Dan: > Doesn't look like there's code out there - will try e-mailing the > authors of the various papers/presentations. We haven't made any code available yet, but we are planning to do so before ICFP this year. > This e-mail also counts as an open plea to those compiler wizards > working on this stuff: feel free to put beta buggy versions of your > code online :) It's not so much the beta bugginess as the several times completely ripping apart and putting together in different ways that prevented us from putting code out. Once we put something out, it becomes harder to change the API, too, and we are still changing the design of that around. Anyway, thanks for the interest. Manuel > Scott A. Waterman wrote: >> Try reaching Manuel Chakravarty, http://justtesting.org/ >> and his colleague Sean Lee at Galois. >> >> Slides from his talk on GPU.gen : >> Just gave my talk on "Data Parallelism in Haskell" at PSU; here >> the slides: http://bit.ly/17EQcl >> >> and slides from an earlier Galois talk: >> http://www.galois.com/blog/2008/08/29/gpugen-bringing-the-power-of-gpus-into-the-haskell-world/ >> >> >> --ts >> >> On May 12, 2009, at 9:18 AM, Dan wrote: >> >>> Hi, >>> >>> Does anyone know if there's a compiler from Data-Parallel Haskell >>> to GPU code? I saw a paper on it a while back, but Google hasn't >>> turned up any code. >>> >>> Cheers, >>> - Dan From wren at freegeek.org Wed May 13 00:19:23 2009 From: wren at freegeek.org (wren ng thornton) Date: Wed May 13 00:05:03 2009 Subject: [Haskell-cafe] Structural sharing in haskell data structures? In-Reply-To: <20090512220615.GX19645@whirlpool.galois.com> References: <20090512213332.GW19645@whirlpool.galois.com> <20090512220615.GX19645@whirlpool.galois.com> Message-ID: <4A0A4A4B.6080705@freegeek.org> Don Stewart wrote: > wagner.andrew: > > > Purity allows our data structures to have a lot of sharing. > > > This is separate to laziness. > > > > Ah, so haskell does do it. Interesting that it so rarely comes up, whereas it's > > frequently mentioned in clojure. > > I think it is just assumed, since that's been the case for 20 years or > more now. Sharing is kind of exciting to the ex-Java people looking at > Clojure, I guess, since it's a new idea. So they talk about it. So far as I know, all immutable languages do it. Like Don, I think the reason it's emphasized so much in Clojure is because of trying to convert the Java crowd and introducing them to immutability. With mutable languages you have to clone _everything_ for fear of later changes affecting earlier copies. Because of this, folks used to mutable languages often erroneously suppose that immutable languages do the same thing. There's a lot of FUD in the mainstream about declarative/immutable/functional languages and their performance behavior. The idea is simple and you can do it in mutable languages perfectly well (clone the changed part of the spine, point to old substructure) so long as you're careful not to do mutation, e.g. by marking everything "final". You don't see it as much in mutable languages because people get squeamish about the first step: clone the changed spine; they'd much rather mutate it. In heavily GCed languages like Haskell allocation and collection is cheap, so we don't mind too much; but in Java and the like, both allocation and collection are expensive so the idea of cheap throwaway objects is foreign. -- Live well, ~wren From wren at freegeek.org Wed May 13 00:47:38 2009 From: wren at freegeek.org (wren ng thornton) Date: Wed May 13 00:33:29 2009 Subject: [Haskell-cafe] Removing mtl from the Haskell Platform In-Reply-To: References: Message-ID: <4A0A50EA.5010403@freegeek.org> roconnor@theorem.ca wrote: > I wanted to pass this idea around the cafe to get some thoughts before > submitting a trac on this topic. > > I'd like to see the mtl removed from the Haskell Platform. > > The mtl was a tremendous step forward when it was developed. However, > we have learned a few things about monad transformers since the > development of the mtl, and it is time that we moved forward. I would welcome a newer cleaner library to replace mtl. One caveat, in terms of the HP is that I'd like to see one clear alternative be blessed, instead of listing the alternatives. I think a big part of the reason many people have stuck with mtl is that they lack sufficient knowledge to be able to look at all the options and know which is the best and why, so they choose the one that is familiar. This is similar to the Parsec problem. At the time it was introduced it was a major step forward, but these days there are a number of issues people consistently complain about. There's a large set of parser combinator libraries out there, but no one of them is clearly superior so people stick with what is familiar. > 3) I am told by many people that the order of the state and value pair > in `State' is backwards. Actually, I'm not entirely sure what the issue > is here, but I trust the people who say this. Lacking type-level functions like flip, we can define the Functor ((,) s) easier than the reverse. This pretties type signatures up significantly when we start composing things[1] and doing other type-level programming. This is also the ordering used in dependently typed languages (replacing (->) with \Pi and (,) with \Sigma). Et cetera. The current order makes the definition of (>>=) appear very marginally prettier, but it makes type signatures much uglier everywhere it's used. [1] e.g. State s = Reader s . Writer s = (->) s . (,) s = /\a. s->(s,a) -- Live well, ~wren From vigalchin at gmail.com Wed May 13 01:17:06 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Wed May 13 01:05:00 2009 Subject: [Haskell-cafe] question on the Prelude .. vis-a-vis Message-ID: <5ae4f2ba0905122217s45bd8461yfa8703354195a6cc@mail.gmail.com> Hello, I am seriously punching my way to build Swish via .cabal ... My head is totally to the wall .... punch .. punch ..... Graham Lyle has written some seriously beautiful code .... I am trying to get to adhere to contemporary Haskell namespace convention ..... I still awaiting response from Graham vis-a-vis posting on Hackage ... I strongly think that in bioinformatics and also oil/gas industry(<< I am stuck here everyday ;^)) that Swish is a strong arena of discussion! In any case .. there are some issues: 1) I strongly suspect that in Swish 0.2.1 that some of Graham's libaries are already superseded by the Haskell prelude , e.g. HUnit, Parsec(!!!), his Sort directory/library .. Don ...please 2) Graham wrote a deterministic finite automaton ..... which is giving some grieve namespace-wise ..... please see following Swish/HaskellRDF/Dfa/Dfa.lhs:1:0: Failed to load interface for `Prelude': it is a member of package base, which is hidden vigalchin here is a fragement of Dfa.lhs: > {-# OPTIONS -fglasgow-exts #-} > {-# OPTIONS -fallow-undecidable-instances #-} > module Swish.HaskellRDF.Dfa.Dfa ( > Re(..), > matchRe, > matchRe2 > ) where > {- ???? > import Control.Monad.Identity > import Control.Monad.Reader > import Control.Monad.State > import Data.FiniteMap > import List > import Data.Array > -} import IOExts The type of a regular expression. > data Re t "Dfa.lhs" 609 lines, 18871 characters Very kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090513/dff6959f/attachment.html From colin at colina.demon.co.uk Wed May 13 01:28:49 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Wed May 13 01:14:51 2009 Subject: [Haskell-cafe] List of exports of a module - are there alternatives? In-Reply-To: (Andrew Wagner's message of "Tue\, 12 May 2009 15\:51\:17 -0400") References: Message-ID: >>>>> "Andrew" == Andrew Wagner writes: Andrew> Uh, show me such a module, and I'll show you a module Andrew> that's quite bloated and desperately needs to be Andrew> refactored. How about a module that provides the official Unicode names for each character? -- Colin Adams Preston Lancashire From wren at freegeek.org Wed May 13 02:05:32 2009 From: wren at freegeek.org (wren ng thornton) Date: Wed May 13 01:51:23 2009 Subject: [Haskell-cafe] forall vs "=>" In-Reply-To: References: Message-ID: <4A0A632C.60108@freegeek.org> Daryoush Mehrtash wrote: > What is the difference between forall as in: > > runST :: (forall s. ST s a) -> a > > and the "=>" as in > > evalStateT :: Monad m => StateT s m a -> s -> m a The forall is Rank-2 polymorphism (the argument must be polymorphic in s). The => is for typeclass constraints (restricting the Rank-1 polymorphism on m, but not so far as to make it monomorphic). Or did you have another question in mind? -- Live well, ~wren From bulat.ziganshin at gmail.com Wed May 13 02:44:04 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed May 13 02:31:31 2009 Subject: [Haskell-cafe] forall vs "=>" In-Reply-To: References: Message-ID: <1178968227.20090513104404@gmail.com> Hello Daryoush, Wednesday, May 13, 2009, 6:11:10 AM, you wrote: > runST :: (forall s. ST s a) -> a > evalStateT :: Monad m => StateT s m a -> s -> m a these are quite opposite things. later means that you should pass some value of Monad class (well, in this case it's StateT value whose type is limited to Monad in second argument) first means that you should pass *polymorphic* value - i.e. value valid for *any* s thta's even more exiting is that evalStateT is example of polymorphic value - it's a function that can process any Monad value but definitely it will be easier to start with simpler examples. let's see: length :: forall a. [a] -> Int it's, like evalStateT, polymorphic function - it can process lists of any type. more specific polymorphic functions may have class constraints: sum :: (forall a. Num a) => [a] -> a that may be reduced down to: sum :: (Num a) => [a] -> a now let's write a function that may accept *any* function with the type as length: rank2_function :: (forall a. [a] -> Int) -> Int -> Int rank2_function f 1 = f "test" rank2_function f 2 = f [1..3] -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ganesh.sittampalam at credit-suisse.com Wed May 13 03:04:52 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Wed May 13 02:51:11 2009 Subject: [Haskell-cafe] Removing mtl from the Haskell Platform In-Reply-To: References: Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B01ABAB01@ELON17P32001A.csfb.cs-group.com> roconnor@theorem.ca wrote: > I think that use of the mtl should be deprecated so that we move on > to improved monad transformer libraries. Having the mtl in the > Haskell Platform does the opposite by further entrenching its use, > possibly to the point where we may not be able to get rid of it for > years. > > If I had to recommend a replace library, I would pick monadLib. > However, there are other libraries, such as the mmtl and transformers > and it's related packages that I haven't looked at, and may also make > fine replacements for the mtl. We've discussed replacing it with transformers+monads-fd+an mtl compatiblity layer on libraries@. Ross and I plan to propose doing this for the second release of the platform - it's not fair to disrupt the first release at this stage. transformers+monads-fd is quite a small evolution over mtl - it factors out the fundeps into a separate package, tightens up some of the class constraints, and makes State = StateT Identity etc rather than a separate type. Even this breaks a few packages, but doing anything more substantial would be quite disruptive. That's not to say that we shouldn't do it, though. I guess the libraries@ list will continue to be the place that such decisions get made, but I think it's a bit up in the air at the moment. Cheers, Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From emax at chalmers.se Wed May 13 03:09:46 2009 From: emax at chalmers.se (Emil Axelsson) Date: Wed May 13 02:55:07 2009 Subject: [Haskell-cafe] ANN: Bookshelf Message-ID: <4A0A723A.9000603@chalmers.se> This is the first release of Bookshelf, a simple document organizer with some wiki functionality. Documents in a directory tree are displayed as a set of HTML pages. Documents in Markdown format are converted to HTML automatically using Pandoc. The manual http://www.cs.chalmers.se/~emax/bookshelf/Manual.shelf.html describes the full functionality. Bookshelf is available on Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Bookshelf or through its Darcs repository: http://www.cs.chalmers.se/~emax/darcs/Bookshelf/ I'm not aware of any bugs. I hope it works on Windows, but I haven't tested. Cheers, / Emil From voigt at tcs.inf.tu-dresden.de Wed May 13 03:21:09 2009 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Wed May 13 03:06:54 2009 Subject: [Haskell-cafe] 2nd Call For Papers: APLAS 2009 (Korea, Dec 14-16, 2009) Message-ID: <4A0A74E5.8090203@tcs.inf.tu-dresden.de> =============================================================== CALL FOR PAPERS The Seventh Asian Symposium on Programming Languages and Systems (APLAS 2009) Seoul, December 14-16, 2009 http://ropas.snu.ac.kr/aplas09/ =============================================================== APLAS aims at stimulating programming language research by providing a forum for the presentation of recent results and the exchange of ideas and experience in topics concerned with programming languages and systems. APLAS is based in Asia, but is an international forum that serves the worldwide programming languages community. The APLAS series is sponsored by the Asian Association for Foundation of Software (AAFS), which has recently been founded by Asian researchers in cooperation with many researchers from Europe and the USA. The past formal APLAS symposiums were successfully held in Bangalore (2008, India), Singapore (2007), Sydney (2006, Australia), Tsukuba (2005, Japan), Taipei (2004, Taiwan) and Beijing (2003, China) after three informal workshops held in Shanghai (2002, China), Daejeon (2001, Korea) and Singapore (2000). Proceedings of the past symposiums were published in Springer-Verlag's LNCS 2895, 3302, 3780, 4279, and 5356. TOPICS: The symposium is devoted to both foundational and practical issues in programming languages and systems. Papers are solicited on, but not limited, to the following topics: * semantics, logics, foundational theory * type systems, language design * program analysis, optimization, transformation * software security, safety, verification * compiler systems, interpreters, abstract machines * domain-specific languages and systems * programming tools and environments INVITED SPEAKERS: TBA IMPORTANT DATES: Abstract Deadline: June 8 (Monday), 2009 Paper Submission Deadline: 24:00 AM (in Samoan Time), June 15 (Monday), 2009 Author Notification: August 17, 2009 Camera Ready: September 14, 2009 Conference: December 14-16, 2009 SUBMISSIONS INFORMATION: Papers should be submitted electronically online via the conference submission web page at URL . Acceptable formats are PostScript or PDF, viewable by Ghostview or Adobe Reader. Submissions should not exceed 16 pages in LNCS format, including bibliography and figures. Submitted papers will be judged on the basis of significance, relevance, correctness, originality, and clarity. They should clearly identify what has been accomplished and why it is significant. Submitted papers must be unpublished and not submitted for publication elsewhere. The proceedings of the symposium is planned to be published as a volume in Springer-Verlag's Lecture Notes in Computer Science series. Authors of selected papers will be invited after the symposium to submit a full version for publication in a special issue of New Generation Computing. GENERAL CHAIR Kwangkeun Yi (Seoul National University, Korea) PROGRAM CHAIR Zhenjiang Hu (National Institute of Inforamtics, Japan) PROGRAM COMMITTEE Manuel M. T. Chakravarty (University of New South Wales, Australia) Wei-Ngan Chin (National University of Singapore, Singapore) Nate Foster (University of Pennsylvania, USA) Ralf Hinze (Oxford University, United Kingdom) Zhenjiang Hu (National Institute of Informatics, Japan), Chair Ik-Soon Kim (Electronics and Telecommunications Research Institute, Korea) Julia Lawall (DIKU, Denmark) Sebastian Maneth (NICTA and University of New South Wales, Australia) Sungwoo Park (Pohang University of Science and Technology, Korea) G. Ramalingam (Microsoft Research, India) Peter Thiemann (University of Freiburg, Germany) Kazushige Terui (Kyoto University, Japan) Janis Voigtl?nder (Technical University of Dresden, Germany) Chung-chieh Shan (Rutgers University, USA) Kazunori Ueda (Waseda University, Japan) Bow-Yaw Wang (Academia Sinica, Taiwan) Jianjun Zhao (Shanghai Jiaotong University, China) POSTER SESSION CHAIR Kiminori Matsuzaki (University of Tokyo, Japan) From deb at pudlak.name Wed May 13 03:36:42 2009 From: deb at pudlak.name (Petr Pudlak) Date: Wed May 13 03:23:22 2009 Subject: [Haskell-cafe] Functional Reactive Web Application Framework? Message-ID: <20090513073641.GA10387@pudlak.name> Hi, I've been learning Haskell for a few months, and it has influenced my thinking about programs quite a lot. Most of my current work is creating complex web applications. Naturally, I was thinking about how to make rich internet applications (and GUI apps in general) in an (utmost :-)) functional way. Recently I found out the concepts of functional reactive programming , which supersede and generalize my ideas. My question is: "Is there a FRP web application framework, or perhaps an effort to create one?" If not, I'd be willing to start such a project, but since I'm not very experienced Haskell programmer, I'd most likely need some help from somebody more experienced. If somebody would be interested, my ideas go as follows: Handling events in GUI/RIA applications can be very tedious, especially for complex applications. Instead, I'd prefer something like that: 1) Abstract what a user wants to see using a structured datatype, specifically tailored for the application. You may imagine it as something like a structured URL. This can be then viewed as a FRP behavior -- a function of the user's request depending on time. 2) The data that will be displayed on the page are a function of this structured user request and an environment, which is usually database. This is again a behavior. 3) Finally, the resulting page is a function of the data (again a behavior). 4) User actions that change the application state (update the database) could be viewed as FRP events. So instead of handling tons of events, the programmer would construct the application mostly by composing behaviors. Only state-changing user actions would be handled as events. Does anybody see these ideas as useful? Constructive criticism is welcomed. Best regards, Petr From nicolas.pouillard at gmail.com Wed May 13 03:42:25 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Wed May 13 03:28:52 2009 Subject: [Haskell-cafe] caml build In-Reply-To: <5ae4f2ba0905121423k12df07f1k63b06506dc3de884@mail.gmail.com> References: <5ae4f2ba0905111527hebf8e95i88df612017522d39@mail.gmail.com> <1242130982-sup-5203@ausone.inria.fr> <5ae4f2ba0905121423k12df07f1k63b06506dc3de884@mail.gmail.com> Message-ID: <1242200514-sup-7185@ausone.local> Excerpts from Vasili I. Galchin's message of Tue May 12 23:23:51 +0200 2009: > Hi Nicolas, > > I am starting a "caml build". I want line by line which module is > being built so when I get an error I have a context to reason about to fix > the problem. Got it? Maybe you mean "cabal build" ? > On Tue, May 12, 2009 at 7:23 AM, Nicolas Pouillard < > nicolas.pouillard@gmail.com> wrote: > > > Excerpts from Vasili I. Galchin's message of Tue May 12 00:27:26 +0200 > > 2009: > > > Hello, > > > > > > I have forgotten whether I sent this posting out. Sorry if I did (I > > > didn't see on Haskell cafe archive). > > > > > > I am building Swish and getting an error. I want to follow the > > > progress of "swish build" ... I don't see an additional parameter like > > > verbose mode that will tell which swish component is being built. ??? > > > > I don't get the relation with the subject of your post, can you elaborate? > > > > Best regards, > > > > -- > > Nicolas Pouillard > > -- Nicolas Pouillard From nicolas.pouillard at gmail.com Wed May 13 03:44:28 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Wed May 13 03:30:46 2009 Subject: [Haskell-cafe] question on the Prelude .. vis-a-vis In-Reply-To: <5ae4f2ba0905122217s45bd8461yfa8703354195a6cc@mail.gmail.com> References: <5ae4f2ba0905122217s45bd8461yfa8703354195a6cc@mail.gmail.com> Message-ID: <1242200608-sup-3268@ausone.local> Excerpts from Vasili I. Galchin's message of Wed May 13 07:17:06 +0200 2009: > Hello, > > I am seriously punching my way to build Swish via .cabal ... My head > is totally to the wall .... punch .. punch ..... [...] > Swish/HaskellRDF/Dfa/Dfa.lhs:1:0: > Failed to load interface for `Prelude': > it is a member of package base, which is hidden You want to add 'base' to the 'Build-Depends:' field of the cabal file. -- Nicolas Pouillard From slehuitouze at telisma.com Wed May 13 03:54:32 2009 From: slehuitouze at telisma.com (Serge LE HUITOUZE) Date: Wed May 13 03:40:09 2009 Subject: [Haskell-cafe] Building 'text-icu-0.1' on Windows Message-ID: Hi there, I fail to build text-icu-0.1 on Windows, and would appreciate some help... Thanks in advance! Let me describe what I've done so for, and what results I got: First, I got a version of ICU on my machine, specifically unzipping the file "icu4c-4_0_1-Win32-msvc8.zip" from http://icu-project.org/download/4.0.html. This made me having ICU stuff at location "C:\HaskellStuff\icu\icu", as witnessed below: >> C:\HaskellStuff\icu\icu>dir << 30/04/2009 16:08 . << 30/04/2009 16:08 .. << 30/04/2009 16:51 bin << 30/04/2009 16:08 include << 30/04/2009 16:36 lib << 14/01/2009 22:48 2 032 license.html After downloading and untaring "text-icu-0.1", I tried to configure, typing in: >> C:\HaskellStuff\pkg\text-icu-0.1>runhaskell Setup configure << Configuring text-icu-0.1... << Setup: Missing dependencies on foreign libraries: << * Missing C libraries: icui18n, icuuc, icudata << This problem can usually be solved by installing the system packages that << provide these libraries (you may need the "-dev" versions). If the libraries << are already installed but in a non-standard location then you can use the << flags --extra-include-dirs= and --extra-lib-dirs= to specify where they are. OK, let's restart with appropriate values for said flags! >> C:\HaskellStuff\pkg\text-icu-0.1>runhaskell Setup configure >> --extra-include-dirs=C:\HaskellStuff\icu\icu\include >> --extra-lib-dirs=C:\HaskellStuff\icu\icu\lib << Configuring text-icu-0.1... And then proceed with the building per se: >> C:\HaskellStuff\pkg\text-icu-0.1>runhaskell Setup build << Preprocessing library text-icu-0.1... << In file included from C:/HaskellStuff/icu/icu/include/unicode/umachine.h:47, << from C:/HaskellStuff/icu/icu/include/unicode/utypes.h:36, << from Data\Text\ICU\Error.hsc:148: << C:/HaskellStuff/icu/icu/include/unicode/pwin32.h:120: << error: redefinition of typedef 'int8_t' << C:/ghc/ghc-6.10.1/include/mingw/stdint.h:27: << error: previous declaration of 'int8_t' was here << ... << ... (a bunch of similar messages for other type aliases, e.g. 'uint8_t') << ... << compiling dist\build\Data\Text\ICU\Error_hsc_make.c failed << command was: C:\ghc\ghc-6.10.1\gcc.exe -c -BC:\ghc\ghc-6.10.1\gcc-lib << -IC:\ghc\ghc-6.10.1\include\mingw -D__GLASGOW_HASKELL__=610 << -IC:\HaskellStuff\icu\icu\include << -IC:\ghc\ghc-6.10.1\bytestring-0.9.1.4\include << -IC:\ghc\ghc-6.10.1\base-4.0.0.0\include << -IC:\ghc\ghc-6.10.1/include << -IPAPI_INCLUDE_DIR dist\build\Data\Text\ICU\Error_hsc_make.c << -o dist\build\Data\Text\ICU\Error_hsc_make.o << << C:\HaskellStuff\pkg\text-icu-0.1> The "mingw/stdint.h" file contains a series of lines of this style: << << typedef signed char int8_t; Whereas, the "unicode/pwin32.h" file contains contains stuff like: << << /* Define whether inttypes.h is available */ << #ifndef U_HAVE_INTTYPES_H << #define U_HAVE_INTTYPES_H 0 << #endif << ... << << /* Determines whether specific types are available */ << #ifndef U_HAVE_INT8_T << #define U_HAVE_INT8_T U_HAVE_INTTYPES_H << #endif << ... << << /* If your platform does not have the header, you may << need to edit the typedefs below. */ << #if U_HAVE_INTTYPES_H << #include << #else /* U_HAVE_INTTYPES_H */ << << #if ! U_HAVE_INT8_T << typedef signed char int8_t; << #endif << ... << #endif So, do I need to explicitely change the icu include file? And in which way? Any other solution/suggestion? Best regards. --Serge -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090513/61b07266/attachment.html From ketil at malde.org Wed May 13 04:24:46 2009 From: ketil at malde.org (Ketil Malde) Date: Wed May 13 04:10:07 2009 Subject: The HP and PackedString (was: Re: [Haskell-cafe] Removing mtl from the Haskell Platform) In-Reply-To: <4A0A50EA.5010403@freegeek.org> (wren ng thornton's message of "Wed\, 13 May 2009 00\:47\:38 -0400") References: <4A0A50EA.5010403@freegeek.org> Message-ID: <877i0lbeb5.fsf_-_@malde.org> Not of the same gravity as mtl, but I was a bit surprised to see that PackedString was included, in spite of it being marked as deprecated on Hackage. Presumably, this is because some other library depends on this, but I think platform-blessing a deprecated library is a strange thing to do. If the functionality cannot be replaced in the dependent, could it be an option to simply integrate the PS functionality? Or should it be de-deprecated? wren ng thornton writes: > [..] in terms of the HP is that I'd like to see one clear > alternative be > blessed, instead of listing the alternatives. FWIW, I strongly agree with this. -k -- If I haven't seen further, it is by standing in the footprints of giants From voigt at tcs.inf.tu-dresden.de Wed May 13 04:50:44 2009 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Wed May 13 04:36:04 2009 Subject: [Haskell-cafe] Re: [Haskell] International Summer School on Advances in Programming Languages (precedes ICFP'09) In-Reply-To: <53ff55480905120823w5515493p3aa4fed21afd9ad7@mail.gmail.com> References: <53ff55480905120823w5515493p3aa4fed21afd9ad7@mail.gmail.com> Message-ID: <4A0A89E4.5050302@tcs.inf.tu-dresden.de> Note that potential participants in the below summer school should pre-register their interest *now*. The organizers need that information to go ahead with the planning. Matthew Fluet (ICFP Publicity Chair) wrote: > International Summer School on Advances in Programming Languages > 25th-28th August, 2009 > Heriot-Watt University, Edinburgh, Scotland > http://www.macs.hw.ac.uk/~greg/ISS-AiPL > > > Overview > ~~~~~~~~ > > This four-day residential International Summer School on Advances in > Programming Languages has a major theme of Concurrency, Distribution, > and Multicore. Intended primarily for postgraduate research students, > the School offers lectures and practical sessions on an engaging blend > of cutting edge theoretical and practical techniques from > international experts. > > The Summer School is supported by the Scottish Informatics and > Computer Science Alliance (http://www.sicsa.ac.uk/), a Scottish > Funding Council Research Pool. Participants from SICSA member > institutions may attend at no cost. > > Confirmed Topics/Speakers > > * Static and dynamic languages, > Prof Philip Wadler, University of Edinburgh > * Compiler technology for data-parallel languages, > Dr Sven-Bodo Scholz, University of Hertfordshire > * New applications of parametricity, > Dr Janis Voigtlander, Technical University of Dresden > * Automatic vectorising compilation, > Dr Paul Cockshott, University of Glasgow > * Foundational aspects of size analysis, > Prof Marko van Eekelen / Dr Olha Shakaravska, Radboud University Nijmegen > * Context oriented programming, > Dr Pascal Costanza, Vrije Universiteit Brussels > * Multi-core programming, > Dr Phil Trinder, Heriot-Watt University > * Multi-core compilation, > Dr Alastair Donaldson, Codeplay Software Ltd > * Principles and Applications of Refinement Types, > Dr Andrew D. Gordon, Microsoft Research, Cambridge > * Resource aware programming in Hume, > Prof Greg Michaelson, Heriot-Watt University / Prof Kevin Hammond, > University of St Andrews > * Haskell concurrency & parallelism, > Dr Satnam Singh, Microsoft Research, Cambridge > > > Location > ~~~~~~~~ > > The Summer School is at Heriot-Watt University's Riccarton campus, set > in pleasant parkland to the west of Edinburgh, with easy access to the > airport, city and central Scotland > (http://www.hw.ac.uk/welcome/directions.htm). > > The Summer School immediately precedes the 2009 International > Conference on Functional Programming > (http://www.cs.nott.ac.uk/~gmh/icfp09.html) and takes place during the > Edinburgh International Festival (http://www.eif.co.uk/) , and the > associated Edinburgh Festival Fringe (http://www.edfringe.com/) and > Edinburgh International Book Festival (http://www.edbookfest.co.uk/) > > > Steering Committee > ~~~~~~~~~~~~~~~~~~ > > Prof Prof Greg Michaelson, Heriot-Watt University (Convenor), > > Prof Kevin Hammond, University of St Andrews > Dr Patricia Johann, University of Strathclyde > Prof Philip Wadler, University of Edinburgh > > > Fee > ~~~ > > Full rate: ?400; (free for SICSA students) > Includes: four nights single room, en-suite accommodation with > breakfast, lunch and dinner, plus coffee breaks and session materials. > > Day rate: ?200; (free for SICSA students) > Includes: lunch, coffee breaks, session materials > > > Registration of Interest > ~~~~~~~~~~~~~~~~~~~~~~~~ > > If you are interested in attending the International Summer School, > please complete the form available from > (http://www.macs.hw.ac.uk/~greg/ISS-AiPL/ISS-AiPL%20register.doc) or > below, and return it to: > > > ********** > International Summer School on Advances in Programming Languages > 25th-28th August, 2009 > Heriot-Watt University, Edinburgh, Scotland > > Registration of Interest > > Name: > Address: > Email: > Phone: > SICSA Uni: Yes / No > Rate: Full / Day > Accessibility requirements: > Dietary requirements: > > Return to: ISS-AiPL-register@macs.hw.ac.uk > ********** > _______________________________________________ > Haskell mailing list > Haskell@haskell.org > http://www.haskell.org/mailman/listinfo/haskell > From wrwills at gmail.com Wed May 13 05:09:48 2009 From: wrwills at gmail.com (Robert Wills) Date: Wed May 13 04:55:12 2009 Subject: [Haskell-cafe] Functional Reactive Web Application Framework? In-Reply-To: <20090513073641.GA10387@pudlak.name> References: <20090513073641.GA10387@pudlak.name> Message-ID: The only web-oriented frp framework that I know of is Flapjax http://www.flapjax-lang.org/ Flapjax is javascript so possibly there could be a way to integrate it into Haskell using HJavascript? Maybe it could even be integrated into Happstack? I'm also quite new to Haskell. -Rob From noteed at gmail.com Wed May 13 05:13:46 2009 From: noteed at gmail.com (minh thu) Date: Wed May 13 04:59:11 2009 Subject: [Haskell-cafe] Functional Reactive Web Application Framework? In-Reply-To: References: <20090513073641.GA10387@pudlak.name> Message-ID: <40a414c20905130213v5f15cc13hc7423504b8db2591@mail.gmail.com> 2009/5/13 Robert Wills : > The only web-oriented frp framework that I know of is Flapjax > http://www.flapjax-lang.org/ > > Flapjax is javascript so possibly there could be a way to integrate it > into Haskell using HJavascript? Maybe it could even be integrated > into Happstack? > > I'm also quite new to Haskell. > > -Rob > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > There is this link posted on reddit... http://ambassadortothecomputers.blogspot.com/2009/04/functional-reactive-ajax-in-ocaml.html http://www.reddit.com/r/programming/comments/8jqgn/monadic_functional_reactive_ajax_in_ocaml/ Cheers, Thu From reiner.pope at gmail.com Wed May 13 05:27:05 2009 From: reiner.pope at gmail.com (Reiner Pope) Date: Wed May 13 05:12:19 2009 Subject: [Haskell-cafe] Stream-fusion without the lists In-Reply-To: <20090512165901.GB19645@whirlpool.galois.com> References: <4cf038ee0905112145q2c1dfed2hfdb324e3ba5d85b6@mail.gmail.com> <179DE459-B966-4B14-B1B7-534745E385CD@cse.unsw.edu.au> <20090512165901.GB19645@whirlpool.galois.com> Message-ID: <4cf038ee0905130227ob7832aagfdac625ab4df46d0@mail.gmail.com> 2009/5/13 Don Stewart : > rl: >> On 12/05/2009, at 14:45, Reiner Pope wrote: >> >>> The Stream datatype seems to be much better suited to representing >>> loops than the list datatype is. So, instead of programming with the >>> lists, why don't we just use the Stream datatype directly? >> >> I think the main reason is that streams don't store data and therefore >> don't support sharing. That is, in >> >> let xs = map f ys in (sum xs, product xs) >> >> the elements of xs will be computed once if it is a list but twice if it >> is a stream. >> > > The other issue is reminding developers to preserve stream invariants, > so as not to break the heavy duty rewriting that's going to happen to > their code. > Can you elaborate on this please? I've only seen a few invariants mentioned when reading the Stream Fusion paper and the stream-fusion source code. They are: 1. 'Skip' values should have no semantic significance. 2. Don't construct bottom Streams. However, this seems to only apply when the fusion rewrite rule is applied, which is not the case I am talking about. Cheers, Reiner From nccb2 at kent.ac.uk Wed May 13 06:23:16 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Wed May 13 06:09:03 2009 Subject: [Haskell-cafe] List of exports of a module - are there alternatives? In-Reply-To: References: Message-ID: <4A0A9F94.20409@kent.ac.uk> Maur?cio wrote: > Hi, > > When we want to list which declarations are exported by a module > we do: > > module Mod ( list of exports ) where ... > > Are there propositions to alternatives to that (I could not > find one)? Like, say, add a "do export" or "do not export" > tag to declarations we want to (not) export? > Unfortunately, I don't think so. Which is a shame, as I do sometimes find myself wanting: module Mod hiding (someInternalHelperFunction) where which would seem to logically fit (we have explicit lists and hiding for import, why not both for export?). Leaving aside the arguments about 200 exports, even for 20 exports it would sometimes be cleaner to write the above to hide one, than to spell out the other 19 in an export list. Neil. From Malcolm.Wallace at cs.york.ac.uk Wed May 13 06:25:42 2009 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Wed May 13 06:15:05 2009 Subject: [Haskell-cafe] question on the Prelude .. vis-a-vis In-Reply-To: <5ae4f2ba0905122217s45bd8461yfa8703354195a6cc@mail.gmail.com> References: <5ae4f2ba0905122217s45bd8461yfa8703354195a6cc@mail.gmail.com> Message-ID: <20090513112542.648d5372.Malcolm.Wallace@cs.york.ac.uk> "Vasili I. Galchin" wrote: > Graham Lyle has written some seriously beautiful code .... That would be Graham _Klyne_. > 1) I strongly suspect that in Swish 0.2.1 that some of Graham's > libaries are already superseded by the Haskell prelude , e.g. HUnit, > Parsec(!!!), his Sort directory/library Graham includes in his source distribution a full (but out-of-date) copy of Parsec and HUnit. I would recommend to remove them, and depend on released Hackage versions (probably both 1.0 or thereabouts). The Sort library came from Ralf Hinze http://www.informatik.uni-bonn.de/~ralf/software.html It has not been cabalised or uploaded to Hackage. > > {-# OPTIONS -fglasgow-exts #-} Should become {-# LANGUAGE ... #-} where the "..." needs to be determined by experimentation. > > import Control.Monad.Identity > > import Control.Monad.Reader > > import Control.Monad.State These are in package mtl. > > import Data.FiniteMap Data.FiniteMap no longer exists - it was superseded by Data.Map. The two APIs are similar, except that the order of arguments is generally reversed. Regards, Malcolm From miguelimo38 at yandex.ru Wed May 13 06:31:00 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Wed May 13 06:17:47 2009 Subject: [Haskell-cafe] List of exports of a module - are there alternatives? In-Reply-To: <4A0A9F94.20409@kent.ac.uk> References: <4A0A9F94.20409@kent.ac.uk> Message-ID: <4A0AA164.8020204@yandex.ru> Neil Brown wrote on 13.05.2009 14:23: > Leaving aside the arguments about > 200 exports, even for 20 exports it would sometimes be cleaner to write > the above to hide one, than to spell out the other 19 in an export list. Note that Haddock orders exports according to the export list, not to an order of definition. Also, you can have (sub)sections in documentation using an export list only. Therefore, it's still better to have an export list, even if you export 19 functions and hide one. From rjones at redhat.com Wed May 13 06:40:07 2009 From: rjones at redhat.com (Richard W.M. Jones) Date: Wed May 13 06:25:21 2009 Subject: [Haskell-cafe] [ANNOUNCE] Bindings for libguestfs In-Reply-To: <20090512191132.GG3278@colquitt.org> References: <20090511085246.GA4476@amd.home.annexia.org> <20090512191132.GG3278@colquitt.org> Message-ID: <20090513104007.GA22702@amd.home.annexia.org> On Tue, May 12, 2009 at 03:11:32PM -0400, John Dorsey wrote: > Richard, > > > I added some partial bindings for libguestfs[1] here: > > http://git.et.redhat.com/?p=libguestfs.git;a=blob;f=haskell/Guestfs.hs;hb=HEAD > > Terrific! Partial bindings are great. Thanks for releasing it. I haven't > taken the time to look at your code, but... > > > BTW, I found the documentation on writing FFIs very contradictory and > > incomplete. For example, I was completely defeated trying to find > > ways to do simple stuff like passing in integers or returning > > booleans. *Potentially* Haskell's FFI seems like it might be one of > > the best out of the languages I've used so far, but it needs way more > > documentation and examples. > > Can you be more specific about what needs improvement? > > I wrote a partial Haskell binding for Net-SNMP recently, and I got along > pretty well using the API docs at > http://www.haskell.org/ghc/docs/latest/html/libraries/index.html, and an > example in RWH using hsc2hs. I guess it's easier if one is more used to Haskell (see my .sig) > What did you see that was contradictory? Specific things would be: Recommendation to use 'throwDyn' to throw exceptions, yet this function doesn't exist in my version of GHC. In fact, none of the code here: http://www.haskell.org/haskellwiki/FFICookBook#Raising_and_handling_exceptions works in GHC at all, as far as I could tell. No good examples available on how to use ForeignPtr. Yet I'd argue that almost any non-trivial modern C library bindings will have some concept of an opaque object, so this is the most vital example. (The examples in RWH ch 17 weren't enough for me). I'd really like to know what parameters and return types are permissible for 'foreign import ccall' statements. By trial and error I found out. How do I convert to/from booleans? How do I really use C structures? Real examples, please. How can I free a C string that is returned from a 'caller frees' C function? Does Foreign.Marshall.Alloc.free work for this? Again, reflecting my own inexperience with Haskell, I found 'withCString', 'maybeWith', 'withMany', 'withArray0' etc to be both undocumented and extremely confusing to use. How do I specify a 64 bit int? Using 'Int64#' just causes syntax errors. What's a good emacs editing mode for Haskell code? My emacs thinks Haskell code is LISP ... Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 75 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora From arjun at cs.brown.edu Wed May 13 06:46:45 2009 From: arjun at cs.brown.edu (Arjun Guha) Date: Wed May 13 06:31:52 2009 Subject: [Haskell-cafe] Functional Reactive Web Application Framework? In-Reply-To: References: <20090513073641.GA10387@pudlak.name> Message-ID: > Flapjax is javascript so possibly there could be a way to integrate it > into Haskell using HJavascript? ?Maybe it could even be integrated > into Happstack? The Flapjax compiler is written in Haskell, so that might help. I assume you want to write FRP in a Haskell-embedded DSL and generate FRP'd JavaScript. If you wish to use Flapjax as a supporting library I'd be glad to help. Arjun From nccb2 at kent.ac.uk Wed May 13 07:01:08 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Wed May 13 06:46:20 2009 Subject: [Haskell-cafe] Removing mtl from the Haskell Platform In-Reply-To: <16442B752A06A74AB4D9F9A5FF076E4B01ABAB01@ELON17P32001A.csfb.cs-group.com> References: <16442B752A06A74AB4D9F9A5FF076E4B01ABAB01@ELON17P32001A.csfb.cs-group.com> Message-ID: <4A0AA874.6050805@kent.ac.uk> Sittampalam, Ganesh wrote: > We've discussed replacing it with transformers+monads-fd+an mtl > compatiblity layer on libraries@. Ross and I plan to propose doing this > for the second release of the platform - it's not fair to disrupt the > first release at this stage. > > transformers+monads-fd is quite a small evolution over mtl - it factors > out the fundeps into a separate package, tightens up some of the class > constraints, and makes State = StateT Identity etc rather than a > separate type. Even this breaks a few packages, but doing anything more > substantial would be quite disruptive. That's not to say that we > shouldn't do it, though. For those of us wishing to target applications to the Haskell platform (e.g. our software works on Haskell Platform 2009.2, 2009.8, etc) will there be an easy way to determine which Haskell platform is currently installed so that we can accommodate any such incompatible changes? E.g. if Haskell platform = 2009.2 then use libraries mtl, parsec and #define HP_VERSION 200902, if Haskell platform = 2009.8 then use libraries transformers+monads-fd, parsec-compatibility, and #define HP_VERSION 200908. Or am I looking at things the wrong way, and we should instead just use autoconf-like tests for individual libraries, regardless of the platform (if they have mtl, use mtl and #define USE_MTL, otherwise try transformers+monads-fd, otherwise error)? Thanks, Neil. From claus.reinke at talk21.com Wed May 13 07:13:50 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Wed May 13 06:59:00 2009 Subject: [Haskell-cafe] Functional Reactive Web Application Framework? References: <20090513073641.GA10387@pudlak.name> Message-ID: >I assume you want to write FRP in a Haskell-embedded DSL and generate >FRP'd JavaScript. If you wish to use Flapjax as a supporting library >I'd be glad to help. I'm curious: how difficult is it nowadays for in-page JavaScript to control the evolution of its surrouding page, FRP-style? I used to do something like that, but with VRML+JavaScript instead of HTML +JavaScript (there's a screencast for those without VRML viewer;-): http://community.haskell.org/~claus/FunWorlds/VRML/ and I found that mapping FRP style behaviours and events wasn't the problem (though VRML has better support for this than HTML), the problem was gaining the same advantages one would have from embedding FRP in a functional language. Problems included scoping, linking dynamically created material with enclosing scope (JavaScript being in strings with scopes separate from the enclosing VRML, VRML to be created dynamically also via strings, also in their own scope) From claus.reinke at talk21.com Wed May 13 07:20:08 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Wed May 13 07:05:17 2009 Subject: [Haskell-cafe] Functional Reactive Web Application Framework? Message-ID: <3910409246CB4D1696801AC5D1826B1B@cr3lt> oops, sorry, keyboard accident > >I assume you want to write FRP in a Haskell-embedded DSL and generate >>FRP'd JavaScript. If you wish to use Flapjax as a supporting library >>I'd be glad to help. > > I'm curious: how difficult is it nowadays for in-page JavaScript to > control the evolution of its surrouding page, FRP-style? I used to > do something like that, but with VRML+JavaScript instead of HTML > +JavaScript (there's a screencast for those without VRML viewer;-): > > http://community.haskell.org/~claus/FunWorlds/VRML/ > > and I found that mapping FRP style behaviours and events wasn't > the problem (though VRML has better support for this than HTML), > the problem was gaining the same advantages one would have from > embedding FRP in a functional language. Problems included scoping, > linking dynamically created material with enclosing scope (JavaScript > being in strings with scopes separate from the enclosing VRML, > VRML to be created dynamically also via strings, also in their own > scope) This became particularly obvious for dynamic recursion of reactive behaviours, somewhat like page n = `until` (keypress `then` (\key-> page n)) How are such things handled in Flapjax, if it follows the embedded compiler approach? Claus From duncan.coutts at worc.ox.ac.uk Wed May 13 07:30:33 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed May 13 07:15:57 2009 Subject: [Haskell-cafe] Removing mtl from the Haskell Platform In-Reply-To: <4A0AA874.6050805@kent.ac.uk> References: <16442B752A06A74AB4D9F9A5FF076E4B01ABAB01@ELON17P32001A.csfb.cs-group.com> <4A0AA874.6050805@kent.ac.uk> Message-ID: <1242214233.20743.4359.camel@localhost> On Wed, 2009-05-13 at 12:01 +0100, Neil Brown wrote: > Sittampalam, Ganesh wrote: > > We've discussed replacing it with transformers+monads-fd+an mtl > > compatiblity layer on libraries@. Ross and I plan to propose doing this > > for the second release of the platform - it's not fair to disrupt the > > first release at this stage. > > > > transformers+monads-fd is quite a small evolution over mtl - it factors > > out the fundeps into a separate package, tightens up some of the class > > constraints, and makes State = StateT Identity etc rather than a > > separate type. Even this breaks a few packages, but doing anything more > > substantial would be quite disruptive. That's not to say that we > > shouldn't do it, though. > > For those of us wishing to target applications to the Haskell platform > (e.g. our software works on Haskell Platform 2009.2, 2009.8, etc) will > there be an easy way to determine which Haskell platform is currently > installed so that we can accommodate any such incompatible changes? > E.g. if Haskell platform = 2009.2 then use libraries mtl, parsec and > #define HP_VERSION 200902, if Haskell platform = 2009.8 then use > libraries transformers+monads-fd, parsec-compatibility, and #define > HP_VERSION 200908. There are already cpp macros to enable to determine if your package is being compiled using one library or another and to do conditional compilation on the version. There is no additional mechanism planned for the platform as a whole (because there is nothing to enforce that an end user picks a set of dependencies that is consistent with a platform release). Duncan From duncan.coutts at worc.ox.ac.uk Wed May 13 07:33:13 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed May 13 07:18:39 2009 Subject: The HP and PackedString (was: Re: [Haskell-cafe] Removing mtl from the Haskell Platform) In-Reply-To: <877i0lbeb5.fsf_-_@malde.org> References: <4A0A50EA.5010403@freegeek.org> <877i0lbeb5.fsf_-_@malde.org> Message-ID: <1242214393.20743.4365.camel@localhost> On Wed, 2009-05-13 at 10:24 +0200, Ketil Malde wrote: > Not of the same gravity as mtl, but I was a bit surprised to see that > PackedString was included, in spite of it being marked as deprecated > on Hackage. TemplateHaskell still uses it. There was not a lot we could do for the first release. Similarly for old-time. > Presumably, this is because some other library depends on this, but I > think platform-blessing a deprecated library is a strange thing to > do. If the functionality cannot be replaced in the dependent, could > it be an option to simply integrate the PS functionality? That's not possible as it is part of the interface. > Or should it be de-deprecated? I think it should remain deprecated and we should work on the replacement so that TH can switch its dependency. Duncan From bulat.ziganshin at gmail.com Wed May 13 07:37:52 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed May 13 07:23:17 2009 Subject: The HP and PackedString (was: Re: [Haskell-cafe] Removing mtl from the Haskell Platform) In-Reply-To: <1242214393.20743.4365.camel@localhost> References: <4A0A50EA.5010403@freegeek.org> <877i0lbeb5.fsf_-_@malde.org> <1242214393.20743.4365.camel@localhost> Message-ID: <37113624.20090513153752@gmail.com> Hello Duncan, Wednesday, May 13, 2009, 3:33:13 PM, you wrote: > I think it should remain deprecated and we should work on the > replacement so that TH can switch its dependency. TH isn't high-performance package and i think that it should just switch to use of String -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From jmaessen at alum.mit.edu Wed May 13 07:43:03 2009 From: jmaessen at alum.mit.edu (Jan-Willem Maessen) Date: Wed May 13 07:28:18 2009 Subject: [Haskell-cafe] Structural sharing in haskell data structures? In-Reply-To: <4A0A4A4B.6080705@freegeek.org> References: <20090512213332.GW19645@whirlpool.galois.com> <20090512220615.GX19645@whirlpool.galois.com> <4A0A4A4B.6080705@freegeek.org> Message-ID: I wanted to clear up one misconception here... On May 13, 2009, at 12:19 AM, wren ng thornton wrote: > In heavily GCed languages like Haskell allocation and collection is > cheap, so we don't mind too much; but in Java and the like, both > allocation and collection are expensive so the idea of cheap > throwaway objects is foreign. Not true! If you look at the internals of Clojure, you'll discover they're using trees with *very* wide fanout (eg fanout-64 leaf trees for lists). Why? Because it's so cheap to allocate and GC these structures! By using shallow-but-wide trees we reduce the cost of indexing and accessing list elements. I suspect you'd still be hard- pressed to support this kind of allocation behavior in any of the present Haskell implementations, and Haskell implementations of the same kinds of structures have limited fanout to 2-4 elements or so. Now, if only the Clojure structures supported efficient concatenation... -Jan-Willem Maessen > > -- > Live well, > ~wren > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From greenrd at greenrd.org Wed May 13 07:45:57 2009 From: greenrd at greenrd.org (Robin Green) Date: Wed May 13 07:31:09 2009 Subject: The HP and PackedString (was: Re: [Haskell-cafe] Removing mtl from the Haskell Platform) In-Reply-To: <37113624.20090513153752@gmail.com> References: <4A0A50EA.5010403@freegeek.org> <877i0lbeb5.fsf_-_@malde.org> <1242214393.20743.4365.camel@localhost> <37113624.20090513153752@gmail.com> Message-ID: <20090513124557.56577be1@greenrd.org> On Wed, 13 May 2009 15:37:52 +0400 Bulat Ziganshin wrote: > Hello Duncan, > > Wednesday, May 13, 2009, 3:33:13 PM, you wrote: > > > I think it should remain deprecated and we should work on the > > replacement so that TH can switch its dependency. > > TH isn't high-performance package and i think that it should just > switch to use of String I don't agree. TH can sometimes slow down a build considerably. I don't want to see it getting even slower. -- Robin From bulat.ziganshin at gmail.com Wed May 13 07:50:51 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed May 13 07:36:10 2009 Subject: The HP and PackedString (was: Re: [Haskell-cafe] Removing mtl from the Haskell Platform) In-Reply-To: <20090513124557.56577be1@greenrd.org> References: <4A0A50EA.5010403@freegeek.org> <877i0lbeb5.fsf_-_@malde.org> <1242214393.20743.4365.camel@localhost> <37113624.20090513153752@gmail.com> <20090513124557.56577be1@greenrd.org> Message-ID: <1173922033.20090513155051@gmail.com> Hello Robin, Wednesday, May 13, 2009, 3:45:57 PM, you wrote: >> TH isn't high-performance package and i think that it should just >> switch to use of String > I don't agree. TH can sometimes slow down a build considerably. I don't > want to see it getting even slower. i think GHC compile times is the reason rather than execution of TH scripts -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From duncan.coutts at worc.ox.ac.uk Wed May 13 08:07:56 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed May 13 07:53:27 2009 Subject: The HP and PackedString (was: Re: [Haskell-cafe] Removing mtl from the Haskell Platform) In-Reply-To: <37113624.20090513153752@gmail.com> References: <4A0A50EA.5010403@freegeek.org> <877i0lbeb5.fsf_-_@malde.org> <1242214393.20743.4365.camel@localhost> <37113624.20090513153752@gmail.com> Message-ID: <1242216476.20743.4403.camel@localhost> On Wed, 2009-05-13 at 15:37 +0400, Bulat Ziganshin wrote: > Hello Duncan, > > Wednesday, May 13, 2009, 3:33:13 PM, you wrote: > > > I think it should remain deprecated and we should work on the > > replacement so that TH can switch its dependency. > > TH isn't high-performance package and i think that it should just > switch to use of String That's a reasonable proposal for the next major release of the platform. Please do propose it on the libraries list and see if we can get a consensus. Duncan From arjun at cs.brown.edu Wed May 13 08:30:58 2009 From: arjun at cs.brown.edu (Arjun Guha) Date: Wed May 13 08:16:10 2009 Subject: [Haskell-cafe] Functional Reactive Web Application Framework? In-Reply-To: <3910409246CB4D1696801AC5D1826B1B@cr3lt> References: <3910409246CB4D1696801AC5D1826B1B@cr3lt> Message-ID: > This became particularly obvious for dynamic recursion of reactive > behaviours, somewhat like > ?page n = `until` (keypress `then` (\key-> page n)) We have this function, which permits patterns like the one above: http://www.flapjax-lang.org/docs/#tagRec tagRec does not permit mutual recursion. We've considered writing a generalization that does. But, it's almost easier to imperatively close the loop. Arjun From xj2106 at columbia.edu Wed May 13 08:32:17 2009 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Wed May 13 08:17:30 2009 Subject: [Haskell-cafe] IO trouble In-Reply-To: <20090513004524.GA13768@cs.helsinki.fi> (Lauri Alanko's message of "Wed, 13 May 2009 03:45:24 +0300") References: <873abat4uf.fsf@columbia.edu> <20090513004524.GA13768@cs.helsinki.fi> Message-ID: <87r5ytrxny.fsf@columbia.edu> Lauri Alanko writes: > On Tue, May 12, 2009 at 04:59:36PM -0400, Xiao-Yong Jin wrote: >> > f :: a -> b >> > g :: (a -> b) -> c -> d > >> > gf :: c -> d >> > gf = g f >> >> Now I want to handle exceptions in f and redefine f as in f' >> >> > f' :: a -> IO (Either e b) >> >> So my question is how to define gf' now to use f' instead of >> f? >> >> > gf' :: c -> IO (Either e d) > > Use Control.Monad.Error.ErrorT, it's exactly for this. You have to > "monadize" g to be able to pass f' as an argument to it. > > f' :: a -> ErrorT e IO b > g' :: Monad m => (a -> m b) -> c -> m d > gf' :: c -> ErrorT e IO d > gf' = g' f' So there is no way to do it without "monadize" g to g', is it? Big trouble, sigh. -- c/* __o/* <\ * (__ */\ < From gwern0 at gmail.com Wed May 13 08:37:03 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Wed May 13 08:22:09 2009 Subject: [Haskell-cafe] question on the Prelude .. vis-a-vis In-Reply-To: <20090513112542.648d5372.Malcolm.Wallace@cs.york.ac.uk> References: <5ae4f2ba0905122217s45bd8461yfa8703354195a6cc@mail.gmail.com> <20090513112542.648d5372.Malcolm.Wallace@cs.york.ac.uk> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Wed, May 13, 2009 at 6:25 AM, Malcolm Wallace wrote: ... >> > import Data.FiniteMap -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAkoKvusACgkQvpDo5Pfl1oK6kACfUzsOoMmfYrxegcnSUtluXZF8 G4gAn1AS66xWzHzzt/A1mfIQg8HTF7d2 =rwt5 -----END PGP SIGNATURE----- > > Data.FiniteMap no longer exists - it was superseded by Data.Map. > The two APIs are similar, except that the order of arguments is > generally reversed. > > Regards, > ? ?Malcolm But if he's feeling lazy, he can use http://hackage.haskell.org/cgi-bin/hackage-scripts/package/FiniteMap -- gwern From gwern0 at gmail.com Wed May 13 08:41:24 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Wed May 13 08:32:45 2009 Subject: The HP and PackedString (was: Re: [Haskell-cafe] Removing mtl from the Haskell Platform) In-Reply-To: <20090513124557.56577be1@greenrd.org> References: <4A0A50EA.5010403@freegeek.org> <877i0lbeb5.fsf_-_@malde.org> <1242214393.20743.4365.camel@localhost> <37113624.20090513153752@gmail.com> <20090513124557.56577be1@greenrd.org> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Wed, May 13, 2009 at 7:45 AM, Robin Green wrote: > I don't agree. TH can sometimes slow down a build considerably. I don't > want to see it getting even slower. I once switched TH to Strings. All the uses are trivial, and the encoded strings so small I found myself wondering whether bytestring/packedstring might not be slower than regular string. Certainly, I didn't notice any significant slowdown. - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAkoKv/AACgkQvpDo5Pfl1oLNKgCdEKH0nT/6f3lni7QtjUr4Rfwv NAAAn0J+ZBgwYchGVDTbfnhxhuS5dvep =KtIG -----END PGP SIGNATURE----- From wagner.andrew at gmail.com Wed May 13 08:58:57 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Wed May 13 08:44:05 2009 Subject: [Haskell-cafe] Structural sharing in haskell data structures? In-Reply-To: <4A0A4A4B.6080705@freegeek.org> References: <20090512213332.GW19645@whirlpool.galois.com> <20090512220615.GX19645@whirlpool.galois.com> <4A0A4A4B.6080705@freegeek.org> Message-ID: > > So far as I know, all immutable languages do it. Like Don, I think the > reason it's emphasized so much in Clojure is because of trying to convert > the Java crowd and introducing them to immutability. With mutable languages > you have to clone _everything_ for fear of later changes affecting earlier > copies. Because of this, folks used to mutable languages often erroneously > suppose that immutable languages do the same thing. There's a lot of FUD in > the mainstream about declarative/immutable/functional languages and their > performance behavior. > > The idea is simple and you can do it in mutable languages perfectly well > (clone the changed part of the spine, point to old substructure) so long as > you're careful not to do mutation, e.g. by marking everything "final". You > don't see it as much in mutable languages because people get squeamish about > the first step: clone the changed spine; they'd much rather mutate it. In > heavily GCed languages like Haskell allocation and collection is cheap, so > we don't mind too much; but in Java and the like, both allocation and > collection are expensive so the idea of cheap throwaway objects is foreign. > Are you guys saying that the Clojure target audience is current Java programmers, whereas Haskell's is people who already do functional, immutable programming? Because how long the technique has been used, or how widespread it's used, is irrelevant when trying to convince someone who doesn't have experience with immutable data structures that it's not completely insane. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090513/a0746fc2/attachment.html From peteg42 at gmail.com Wed May 13 09:15:24 2009 From: peteg42 at gmail.com (Peter Gammie) Date: Wed May 13 09:00:36 2009 Subject: [Haskell-cafe] [ANNOUNCE] Bindings for libguestfs In-Reply-To: <20090513104007.GA22702@amd.home.annexia.org> References: <20090511085246.GA4476@amd.home.annexia.org> <20090512191132.GG3278@colquitt.org> <20090513104007.GA22702@amd.home.annexia.org> Message-ID: <536C7F69-CD9D-4004-9DDD-3743B78CD27F@gmail.com> Richard, I remember having similar problems to you when trying to use the FFI. The following comments are suggestions as to what helps in practice, and not a claim that the situation can't be improved. On 13/05/2009, at 8:40 PM, Richard W.M. Jones wrote: > Specific things would be: > > Recommendation to use 'throwDyn' to throw exceptions, yet this > function doesn't exist in my version of GHC. In fact, none of the > code here: > > http://www.haskell.org/haskellwiki/FFICookBook#Raising_and_handling_exceptions > > works in GHC at all, as far as I could tell. The shifting exceptions story is a PITA. Compatibility is the price of progress. > No good examples available on how to use ForeignPtr. Yet I'd argue > that almost any non-trivial modern C library bindings will have some > concept of an opaque object, so this is the most vital example. (The > examples in RWH ch 17 weren't enough for me). I'd suggest you download a mature library binding close to what you want to do and ape that. For example: 1. got lots of C structures? look at a GTK binding. 2. got a fairly imperative API? look at a database binding, or HOpenGL. 3. got a fairly pure API? look at a BDD or numerical package binding. and so forth. The FFI itself is intended to be minimal, just enough to do the job. The idea was that extra tools (most prominently hsc2hs and c2hs, historically greencard) would support large bindings. It's funny you say "opaque object". ForeignPtr only handles pointers. In one library I relied on, the opaque objects were represented with ints. It'd be nice to track arbitrary values the way that ForeignPtr tracks C pointers. > I'd really like to know what parameters and return types are > permissible for 'foreign import ccall' statements. By trial and error > I found out. Is the FFI spec unclear on this point? > How do I convert to/from booleans? Can you use the methods of the Enum class? > How do I really use C structures? Real examples, please. I'd suggest looking into c2hs. Even if you don't use it, the code it generates is quite illuminating, especially how it pushes values between C and Haskell. > How can I free a C string that is returned from a 'caller frees' C > function? Does Foreign.Marshall.Alloc.free work for this? This is tricky. Rather than give you a definite answer, I'd suggest you check with the FFI spec. IIRC in principle the FFI's malloc/free could be distinct from those in C land, but in practice (GHC) they coincide. > Again, reflecting my own inexperience with Haskell, I found > 'withCString', 'maybeWith', 'withMany', 'withArray0' etc to be both > undocumented and extremely confusing to use. They're documented in the FFI spec. Granted using them is not necessarily intuitive, which is where looking at existing code might help. > How do I specify a 64 bit int? Using 'Int64#' just causes syntax > errors. Did you look into the Data.Word library? > What's a good emacs editing mode for Haskell code? My emacs thinks > Haskell code is LISP ... There's been a Haskell mode for at least a decade now. It's packaged with every emacs I've used in the past few years. http://www.haskell.org/haskell-mode/ To editorialise a bit, I think the original FFI spec is very clearly written, and the contradictions you allude to lie in fact in the more recent wiki writeups; the Haskell specs are lucid and intended to be usable, and not just by the compiler writers. One last gotcha: be very careful about strictness if you're trying to graft a pure API onto the library. Hope this helps! cheers peter From lemming at henning-thielemann.de Wed May 13 09:33:56 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed May 13 09:19:06 2009 Subject: [Haskell-cafe] Stream-fusion without the lists In-Reply-To: <4cf038ee0905112145q2c1dfed2hfdb324e3ba5d85b6@mail.gmail.com> References: <4cf038ee0905112145q2c1dfed2hfdb324e3ba5d85b6@mail.gmail.com> Message-ID: On Tue, 12 May 2009, Reiner Pope wrote: > So, thoughts? Do people program with Streams directly? What have I not > considered? Yes, for signal processing I sometimes use my custom Streams data type that misses the Skip constructor since I do not use 'filter' functions: http://darcs.haskell.org/synthesizer/src/Synthesizer/State/Signal.hs It has however the problem, that sharing is not possible. In order to get sharing, too, I introduced an arrow for causal processes: http://darcs.haskell.org/synthesizer/src-4/Synthesizer/Causal/Process.hs (Note that Hudak et.al. have independently developed a theory on causal processes.) From leimy2k at gmail.com Wed May 13 11:11:05 2009 From: leimy2k at gmail.com (David Leimbach) Date: Wed May 13 10:56:24 2009 Subject: [Haskell-cafe] Removing mtl from the Haskell Platform In-Reply-To: References: Message-ID: <3e1162e60905130811w4626c834r3cf503f79657da49@mail.gmail.com> Nothing controversial said here... I'm just agreeing with Russel. On Tue, May 12, 2009 at 4:03 PM, wrote: > I wanted to pass this idea around the cafe to get some thoughts before > submitting a trac on this topic. > > I'd like to see the mtl removed from the Haskell Platform. > > The mtl was a tremendous step forward when it was developed. However, we > have learned a few things about monad transformers since the development of > the mtl, and it is time that we moved forward. > > There are at least 3 significant problem with the mtl. > > 1) `pass' should not be a member functions of the MonadWriter class. It is > my understanding that there is no `MonadWriter w m => MonadWriter w (ContT s > m)' instance because the `pass' function cannot be implemented. I'm also > highly suspicious of some other methods too (I'm looking at you `local'). > > 2) The `StateT s (Cont r a)' instance of callCC is wrong. The paper on > modular monad transformers > describes why this is wrong. > > 3) I am told by many people that the order of the state and value pair in > `State' is backwards. Actually, I'm not entirely sure what the issue is > here, but I trust the people who say this. > > I think that use of the mtl should be deprecated so that we move on to > improved monad transformer libraries. Having the mtl in the Haskell > Platform does the opposite by further entrenching its use, possibly to the > point where we may not be able to get rid of it for years. > > If I had to recommend a replace library, I would pick monadLib. However, > there are other libraries, such as the mmtl and transformers and it's > related packages that I haven't looked at, and may also make fine > replacements for the mtl. > > -- > Russell O'Connor > ``All talk about `theft,''' the general counsel of the American Graphophone > Company wrote, ``is the merest claptrap, for there exists no property in > ideas musical, literary or artistic, except as defined by statute.'' > _______________________________________________ > 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/20090513/102db35f/attachment.html From dons at galois.com Wed May 13 11:52:30 2009 From: dons at galois.com (Don Stewart) Date: Wed May 13 11:39:52 2009 Subject: The HP and PackedString (was: Re: [Haskell-cafe] Removing mtl from the Haskell Platform) In-Reply-To: <877i0lbeb5.fsf_-_@malde.org> References: <4A0A50EA.5010403@freegeek.org> <877i0lbeb5.fsf_-_@malde.org> Message-ID: <20090513155230.GD21997@whirlpool.galois.com> ketil: > > Not of the same gravity as mtl, but I was a bit surprised to see that > PackedString was included, in spite of it being marked as deprecated > on Hackage. Ketil, I would encourage you to open a ticket on the platform wiki summarising the state of the packedstring issue. -- Don From ross at soi.city.ac.uk Wed May 13 11:54:17 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Wed May 13 11:40:31 2009 Subject: [Haskell-cafe] Removing mtl from the Haskell Platform In-Reply-To: <16442B752A06A74AB4D9F9A5FF076E4B01ABAB01@ELON17P32001A.csfb.cs-group.com> References: <16442B752A06A74AB4D9F9A5FF076E4B01ABAB01@ELON17P32001A.csfb.cs-group.com> Message-ID: <20090513155417.GA7691@soi.city.ac.uk> On Wed, May 13, 2009 at 08:04:52AM +0100, Sittampalam, Ganesh wrote: > We've discussed replacing it with transformers+monads-fd+an mtl > compatiblity layer on libraries@. Ross and I plan to propose doing this > for the second release of the platform - it's not fair to disrupt the > first release at this stage. > > transformers+monads-fd is quite a small evolution over mtl - it factors > out the fundeps into a separate package, tightens up some of the class > constraints, and makes State = StateT Identity etc rather than a > separate type. Even this breaks a few packages, but doing anything more > substantial would be quite disruptive. That's not to say that we > shouldn't do it, though. Indeed it is a conservative step, but splitting the transformers from the classes makes it easier to experiment with replacements for the classes while retaining a degree of interoperability. Of the issues listed, 1) and 2) are in the type class package (e.g. transformers exports functions for both liftings of callCC). I'm not sure what is meant by 3). From vigalchin at gmail.com Wed May 13 12:21:55 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Wed May 13 12:07:23 2009 Subject: [Haskell-cafe] caml build In-Reply-To: <1242200514-sup-7185@ausone.local> References: <5ae4f2ba0905111527hebf8e95i88df612017522d39@mail.gmail.com> <1242130982-sup-5203@ausone.inria.fr> <5ae4f2ba0905121423k12df07f1k63b06506dc3de884@mail.gmail.com> <1242200514-sup-7185@ausone.local> Message-ID: <5ae4f2ba0905130921u78cd97a5uc898635d867a1bd7@mail.gmail.com> Hello, I did a "cabal build -?" and discovered -v/--version. Vasili On Wed, May 13, 2009 at 2:42 AM, Nicolas Pouillard < nicolas.pouillard@gmail.com> wrote: > Excerpts from Vasili I. Galchin's message of Tue May 12 23:23:51 +0200 > 2009: > > Hi Nicolas, > > > > I am starting a "caml build". I want line by line which module is > > being built so when I get an error I have a context to reason about to > fix > > the problem. Got it? > > Maybe you mean "cabal build" ? > > > On Tue, May 12, 2009 at 7:23 AM, Nicolas Pouillard < > > nicolas.pouillard@gmail.com> wrote: > > > > > Excerpts from Vasili I. Galchin's message of Tue May 12 00:27:26 +0200 > > > 2009: > > > > Hello, > > > > > > > > I have forgotten whether I sent this posting out. Sorry if I > did (I > > > > didn't see on Haskell cafe archive). > > > > > > > > I am building Swish and getting an error. I want to follow the > > > > progress of "swish build" ... I don't see an additional parameter > like > > > > verbose mode that will tell which swish component is being built. ??? > > > > > > I don't get the relation with the subject of your post, can you > elaborate? > > > > > > Best regards, > > > > > > -- > > > Nicolas Pouillard > > > > > -- > Nicolas Pouillard > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090513/a19c928a/attachment.html From dav.vire+haskell at gmail.com Wed May 13 12:41:58 2009 From: dav.vire+haskell at gmail.com (david48) Date: Wed May 13 12:27:19 2009 Subject: [Haskell-cafe] Qt declarative UI Message-ID: <4c88418c0905130941p25521237n338e98358a88547c@mail.gmail.com> I thought that it might interest some people : http://labs.trolltech.com/page/Projects/Graphics/Kinetic/DeclarativeUI From vigalchin at gmail.com Wed May 13 12:48:34 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Wed May 13 12:33:43 2009 Subject: [Haskell-cafe] caml build In-Reply-To: <1242232149-sup-8618@ausone.local> References: <5ae4f2ba0905111527hebf8e95i88df612017522d39@mail.gmail.com> <1242130982-sup-5203@ausone.inria.fr> <5ae4f2ba0905121423k12df07f1k63b06506dc3de884@mail.gmail.com> <1242200514-sup-7185@ausone.local> <5ae4f2ba0905130921u78cd97a5uc898635d867a1bd7@mail.gmail.com> <1242232149-sup-8618@ausone.local> Message-ID: <5ae4f2ba0905130948r146d0007ma600fa52dc793a49@mail.gmail.com> oops ... yes. On Wed, May 13, 2009 at 11:29 AM, Nicolas Pouillard < nicolas.pouillard@gmail.com> wrote: > Excerpts from Vasili I. Galchin's message of Wed May 13 18:21:55 +0200 > 2009: > > Hello, > > > > I did a "cabal build -?" and discovered -v/--version. > > So **caml** build was a typo right ? > > > > > Vasili > > > > On Wed, May 13, 2009 at 2:42 AM, Nicolas Pouillard < > > nicolas.pouillard@gmail.com> wrote: > > > > > Excerpts from Vasili I. Galchin's message of Tue May 12 23:23:51 +0200 > > > 2009: > > > > Hi Nicolas, > > > > > > > > I am starting a "caml build". I want line by line which module > is > > > > being built so when I get an error I have a context to reason about > to > > > fix > > > > the problem. Got it? > > > > > > Maybe you mean "cabal build" ? > > > > > > > On Tue, May 12, 2009 at 7:23 AM, Nicolas Pouillard < > > > > nicolas.pouillard@gmail.com> wrote: > > > > > > > > > Excerpts from Vasili I. Galchin's message of Tue May 12 00:27:26 > +0200 > > > > > 2009: > > > > > > Hello, > > > > > > > > > > > > I have forgotten whether I sent this posting out. Sorry if > I > > > did (I > > > > > > didn't see on Haskell cafe archive). > > > > > > > > > > > > I am building Swish and getting an error. I want to follow > the > > > > > > progress of "swish build" ... I don't see an additional parameter > > > like > > > > > > verbose mode that will tell which swish component is being built. > ??? > > > > > > > > > > I don't get the relation with the subject of your post, can you > > > elaborate? > > > > > > > > > > Best regards, > > > > > > > > > > -- > > > > > Nicolas Pouillard > > > > > > > > > > > -- > > > Nicolas Pouillard > > > > > -- > Nicolas Pouillard > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090513/8280a7c6/attachment.html From mail at justinbogner.com Wed May 13 12:59:57 2009 From: mail at justinbogner.com (mail@justinbogner.com) Date: Wed May 13 12:45:16 2009 Subject: [Haskell-cafe] Re: ANN: Bookshelf References: <4A0A723A.9000603@chalmers.se> Message-ID: <87tz3p6ir6.fsf@justinbogner.com> Emil Axelsson writes: > This is the first release of Bookshelf, a simple document organizer > with some wiki functionality. Documents in a directory tree are > displayed as a set of HTML pages. Documents in Markdown format are > converted to HTML automatically using Pandoc. The manual > > http://www.cs.chalmers.se/~emax/bookshelf/Manual.shelf.html > > describes the full functionality. It would probably be a good idea to include the markdown functionality in your demonstration, since it's one of the more interesting features. This looks pretty neat though, good work! From nrolle at web.de Wed May 13 13:06:12 2009 From: nrolle at web.de (Nico Rolle) Date: Wed May 13 12:51:20 2009 Subject: [Haskell-cafe] Data.Map.Map Pattern Matching Message-ID: <45fccde20905131006v71b89022od36759d8dd80dab8@mail.gmail.com> Hi I tried this but it diddn't work in ghci: import qualified Data.Map as Map test :: Map.Map [Int] [[Int]] -> Bool test (fromList[((i:is), (j:js))]) = [i] == j i get the : "Parse error in pattern Failed." error. regards From max.rabkin at gmail.com Wed May 13 13:15:51 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Wed May 13 13:01:22 2009 Subject: [Haskell-cafe] Data.Map.Map Pattern Matching In-Reply-To: <45fccde20905131006v71b89022od36759d8dd80dab8@mail.gmail.com> References: <45fccde20905131006v71b89022od36759d8dd80dab8@mail.gmail.com> Message-ID: On Wed, May 13, 2009 at 7:06 PM, Nico Rolle wrote: > Hi > > I tried this but it diddn't work in ghci: > > import qualified Data.Map as Map > > test :: Map.Map [Int] [[Int]] -> Bool > test (fromList[((i:is), (j:js))]) = [i] == j > > i get the : "Parse error in pattern > Failed." error. fromList is an ordinary function. Pattern-matching only works on constructors (unless you use view patterns [see http://hackage.haskell.org/trac/ghc/wiki/ViewPatterns]). --Max From jochem at functor.nl Wed May 13 13:52:01 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Wed May 13 13:37:14 2009 Subject: [Haskell-cafe] Data.Map.Map Pattern Matching In-Reply-To: <45fccde20905131006v71b89022od36759d8dd80dab8@mail.gmail.com> References: <45fccde20905131006v71b89022od36759d8dd80dab8@mail.gmail.com> Message-ID: <4A0B08C1.4020302@functor.nl> Nico Rolle wrote: > Hi > > I tried this but it diddn't work in ghci: > > import qualified Data.Map as Map > > test :: Map.Map [Int] [[Int]] -> Bool > test (fromList[((i:is), (j:js))]) = [i] == j > > i get the : "Parse error in pattern > Failed." error. Pattern matching only works on constructors (and view patterns, but they are a bit more advanced.) I'm not sure what you are trying to accomplish, could you elaborate? Cheers, -- Jochem Berndsen | jochem@functor.nl GPG: 0xE6FABFAB From danielkcook at gmail.com Wed May 13 14:35:48 2009 From: danielkcook at gmail.com (Dan) Date: Wed May 13 14:21:28 2009 Subject: [Haskell-cafe] ghc ./configure stalls on docbook DTD Message-ID: <4A0B1304.7060401@gmail.com> Hi, Not sure if this is the right place to ask. GHC 6.10.3 source dist: ./configure takes about 10 minutes to look for DocBook DTD and another 10 to look for DocBook XSL directory. I was writing this e-mail thinking it had completely crashed. Any reason why it's so ridiculously slow? A look at 'top' says the CPU is mostly idle during this time, but xmllint is running. Mac OS X uname -a: Darwin 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 CookBook:ghc-6.10.3 dan$ ./configure checking build system type... i386-apple-darwin9.6.0 checking host system type... i386-apple-darwin9.6.0 checking target system type... i386-apple-darwin9.6.0 Canonicalised to: i386-apple-darwin [blah blah blah] checking for xmllint... /usr/bin/xmllint checking for DocBook DTD... (blocks for ages) -------------- next part -------------- A non-text attachment was scrubbed... Name: danielkcook.vcf Type: text/x-vcard Size: 157 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090513/7c364516/danielkcook.vcf From donnie at darthik.com Wed May 13 14:53:15 2009 From: donnie at darthik.com (Donnie Jones) Date: Wed May 13 14:38:35 2009 Subject: [Haskell-cafe] ghc ./configure stalls on docbook DTD In-Reply-To: <4A0B1304.7060401@gmail.com> References: <4A0B1304.7060401@gmail.com> Message-ID: Hello Dan, Best place to ask is glasgow-haskell-users@haskell.org since that is the GHC users list. I have CC'd your email to the GHC user list. Cheers. -- Donnie Jones On Wed, May 13, 2009 at 1:35 PM, Dan wrote: > Hi, > > Not sure if this is the right place to ask. > GHC 6.10.3 source dist: ./configure takes about 10 minutes to look for > DocBook DTD and another 10 to look for DocBook XSL directory. ?I was writing > this e-mail thinking it had completely crashed. ?Any reason why it's so > ridiculously slow? A look at 'top' says the CPU is mostly idle during this > time, but xmllint is running. > > Mac OS X > > uname -a: Darwin 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST > 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 > > CookBook:ghc-6.10.3 dan$ ./configure > checking build system type... i386-apple-darwin9.6.0 > checking host system type... i386-apple-darwin9.6.0 > checking target system type... i386-apple-darwin9.6.0 > Canonicalised to: i386-apple-darwin > [blah blah blah] > checking for xmllint... /usr/bin/xmllint > checking for DocBook DTD... > (blocks for ages) > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From deb at pudlak.name Wed May 13 15:22:27 2009 From: deb at pudlak.name (Petr Pudlak) Date: Wed May 13 15:07:46 2009 Subject: [Haskell-cafe] Functional Reactive Web Application Framework? In-Reply-To: References: <20090513073641.GA10387@pudlak.name> Message-ID: <20090513192227.GA19255@pudlak.name> On Wed, May 13, 2009 at 06:46:45AM -0400, Arjun Guha wrote: > > Flapjax is javascript so possibly there could be a way to integrate it > > into Haskell using HJavascript? ?Maybe it could even be integrated > > into Happstack? > > The Flapjax compiler is written in Haskell, so that might help. > > I assume you want to write FRP in a Haskell-embedded DSL and generate > FRP'd JavaScript. If you wish to use Flapjax as a supporting library > I'd be glad to help. > > Arjun Actually, I wanted to use Flapjax as the base for client-side programming. I didn't think about combining Flapjax with HJavaScript, this is quite a good idea. However, this would is just one part of what I'd like to have. No doubt many things can be done on the client, but more serious work or database operations must be done on the server anyway. Ideally, I'd like to spare a programmer from: * Working with HTML (unless explicitly desired); Instead, I'd prefer to compose the pages from components, either predefined or user-defined. This could be done for example using DSL in Haskell. The components could be both lightweight (almost HTML), or heavyweight like "menu", "toolbar" etc. * Transferring data between a server/client. Especially using FRP, this might be done very neatly I suppose. An event stream or a behavior could be transferred seamlessly by the framework from the client to the server and vice versa. The programmer would only see behaviors on either side. I've been working with the ZK framework lately, and it has many nice features. For example, composing pages from high-level components, the possibility to separate the layout of the pages form the controlling code, or sparing a programmer from working with HTML and HTTP requests - everything is done just by manipulating component objects and handling events. However, it's not functional at all. I believe FRP would be much better solution than classical event handling. And secondly, it's in Java, which is nothing bad (actually my code is in Scala), just it's not Haskell. Happsstack looks good, though I didn't have time to study it. Thanks for the links for OCAML JavaScript FRP, it looks iteresting too. Petr From briqueabraque at yahoo.com Wed May 13 17:20:23 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=EDcio?=) Date: Wed May 13 17:07:04 2009 Subject: [Haskell-cafe] Re: List of exports of a module - are there alternatives? In-Reply-To: References: Message-ID: I would like a keyword we could add to a single declaration, like: hidden a :: Int -> Int a = (...) The 200 names is not the best example. It's more a question of proportion: if you export 5 declarations in a module with 20, it's OK, but if you export 19 declarations in a module of 20 maintenance can be painfull to your eyes, going up and down into your file to check if the list is correct. Maur?cio > I would like to see this too. Maybe just a private keyword that would > make everything after it invisible to the outside (or until a public > keyword appeared)? > >> Are there propositions to alternatives to that (I could not >> find one)? Like, say, add a "do export" or "do not export" >> tag to declarations we want to (not) export? >> >> (I think something like that could be nice when we have modules >> with 200 declarations and just a few are (not) going to be >> exported.) From mdmkolbe at gmail.com Wed May 13 17:57:08 2009 From: mdmkolbe at gmail.com (Michael D. Adams) Date: Wed May 13 17:43:20 2009 Subject: [Haskell-cafe] Performance Problem with Typeable Message-ID: I'm not sure where this should be reported, but I think I've found a significant asymptotic performance problem with Data.Typeable. In the attached code, sum2 runs much slower than either sum1 or sum3. It should be linear but it seems to slow down quadratically (i.e. doubling "len" quadruples the time for sum2). Here is an example run: $ ghc --make -O3 CastSpeed.hs $ ./CastSpeed 20000 gsum1 Result: 200010000 Time(sec): 7.999e-3 Result: 200010000 Time(sec): 0.0 Result: 200010000 Time(sec): 1.0e-3 gsum2 Result: 200010000 Time(sec): 1.483774 Result: 200010000 Time(sec): 1.477776 Result: 200010000 Time(sec): 1.523768 gsum3 Result: 200010000 Time(sec): 5.999e-3 Result: 200010000 Time(sec): 0.0 Result: 200010000 Time(sec): 0.0 The only difference between sum1 and sum2 is that sum2 wraps a singleton list around each element (i.e. the cast is to [Int] instead of Int). The only difference between sum2 and sum3 is that sum3 uses an unchecked cast (unsafeCoerce) instead of a checked cast. This problem seems to crop up only for those types which are made up of a type constructor applied to an argument (e.g. "[]" applied to "Int"). Because of sum3 runs fast, I suspect that something is going wrong with the "typeOf" call in a checked cast, and because sum1 runs fast I suspect that what is going wrong is the call to appKey that is called from mkAppTy that is called from typeOfDefault that is called from the Typeable instance for [Int] (i.e. instance (Typeable1 s, Typeable a) => Typeable (s a)). This is a bit of speculation and I don't have hard evidence for that being the source of the problems, but tests that I have run (not listed here) are strongly suggestive of appKey being the culprit. Michael D. Adams mdmkolbe@gmail.com -------------- next part -------------- A non-text attachment was scrubbed... Name: CastSpeed.hs Type: text/x-haskell Size: 1024 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090513/8288fe5f/CastSpeed.bin From ttencate at gmail.com Wed May 13 18:04:42 2009 From: ttencate at gmail.com (Thomas ten Cate) Date: Wed May 13 17:50:21 2009 Subject: [Haskell-cafe] GSoC project for EclipseFP Message-ID: Hi all, I'm happy to announce that my Google Summer of Code project proposal, titled "Extend EclipseFP functionality for Haskell", has been accepted! This means that I will be working on EclipseFP during the upcoming months. For the uninitiated, EclipseFP is a plugin for the Eclipse IDE that makes Haskell support possible. Currently it is fairly limited, but I hope to bring it to a state in which I can start using it for some larger projects of my own. "Live" type checking and type inference, and all that jazz. This will be powered by the Scion library by Thomas Schilling (nominolo), who is also my GSoC mentor. More information is on my new blog: http://eclipsefp.wordpress.com/ Cheers, Thomas From dagit at codersbase.com Wed May 13 18:13:32 2009 From: dagit at codersbase.com (Jason Dagit) Date: Wed May 13 17:58:33 2009 Subject: [Haskell-cafe] GSoC project for EclipseFP In-Reply-To: References: Message-ID: On Wed, May 13, 2009 at 3:04 PM, Thomas ten Cate wrote: > Hi all, > > I'm happy to announce that my Google Summer of Code project proposal, > titled "Extend EclipseFP functionality for Haskell", has been > accepted! This means that I will be working on EclipseFP during the > upcoming months. > > For the uninitiated, EclipseFP is a plugin for the Eclipse IDE that > makes Haskell support possible. Currently it is fairly limited, but I > hope to bring it to a state in which I can start using it for some > larger projects of my own. "Live" type checking and type inference, > and all that jazz. This will be powered by the Scion library by Thomas > Schilling (nominolo), who is also my GSoC mentor. You should use the darcs source code as a test case :) Congrats and good luck! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090513/6cdd830e/attachment.html From dons at galois.com Wed May 13 18:30:05 2009 From: dons at galois.com (Don Stewart) Date: Wed May 13 18:17:08 2009 Subject: [Haskell-cafe] Functional Reactive Web Application Framework? In-Reply-To: References: <20090513073641.GA10387@pudlak.name> Message-ID: <20090513223005.GL24620@whirlpool.galois.com> wrwills: > The only web-oriented frp framework that I know of is Flapjax > http://www.flapjax-lang.org/ > > Flapjax is javascript so possibly there could be a way to integrate it > into Haskell using HJavascript? Maybe it could even be integrated > into Happstack? > > I'm also quite new to Haskell. Isn't the flapjax compiler implemented in Haskell? -- Don From dons at galois.com Wed May 13 18:31:00 2009 From: dons at galois.com (Don Stewart) Date: Wed May 13 18:17:38 2009 Subject: The HP and PackedString (was: Re: [Haskell-cafe] Removing mtl from the Haskell Platform) In-Reply-To: References: <4A0A50EA.5010403@freegeek.org> <877i0lbeb5.fsf_-_@malde.org> <1242214393.20743.4365.camel@localhost> <37113624.20090513153752@gmail.com> <20090513124557.56577be1@greenrd.org> Message-ID: <20090513223100.GM24620@whirlpool.galois.com> gwern0: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA512 > > On Wed, May 13, 2009 at 7:45 AM, Robin Green wrote: > > I don't agree. TH can sometimes slow down a build considerably. I don't > > want to see it getting even slower. > > I once switched TH to Strings. All the uses are trivial, and the > encoded strings so small I found myself wondering whether > bytestring/packedstring might not be slower than regular string. > > Certainly, I didn't notice any significant slowdown. Do you have a patch? From lemming at henning-thielemann.de Wed May 13 18:57:38 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed May 13 18:43:07 2009 Subject: [Haskell-cafe] Fundep Curiosity In-Reply-To: References: Message-ID: <4A0B5062.3040208@henning-thielemann.de> Christopher Lane Hinson schrieb: > > I've noticed that a large majority of fundeps I see in other people's > libraries are written: > > class C a b | b -> a > > Where the dependent parameter appears first in the MPTC. Is there a > reason for this? > > AFAIK, there isn't any semantic significance to the order of parameters > in an MPTC. Why do many haskellers find this configuration more intuitive? It's consistent with good style parameter ordering of functions: http://www.haskell.org/haskellwiki/Parameter_order From wren at freegeek.org Wed May 13 18:58:00 2009 From: wren at freegeek.org (wren ng thornton) Date: Wed May 13 18:43:32 2009 Subject: [Haskell-cafe] Structural sharing in haskell data structures? In-Reply-To: References: <20090512213332.GW19645@whirlpool.galois.com> <20090512220615.GX19645@whirlpool.galois.com> <4A0A4A4B.6080705@freegeek.org> Message-ID: <4A0B5078.6010200@freegeek.org> Jan-Willem Maessen wrote: > I wanted to clear up one misconception here... > > wren ng thornton wrote: > > In heavily GCed languages like Haskell allocation and collection is > > cheap, so we don't mind too much; but in Java and the like, both > > allocation and collection are expensive so the idea of cheap throwaway > > objects is foreign. > > Not true! I was speaking of Java, not Clojure. I believe the costs in Java are well documented, though I don't know enough about the JVM to know where the blame belongs. (All I know of Clojure is that it's a Lisp-like on the JVM :) > If you look at the internals of Clojure, you'll discover > they're using trees with *very* wide fanout (eg fanout-64 leaf trees for > lists). Why? Because it's so cheap to allocate and GC these > structures! By using shallow-but-wide trees we reduce the cost of > indexing and accessing list elements. I suspect you'd still be > hard-pressed to support this kind of allocation behavior in any of the > present Haskell implementations, and Haskell implementations of the same > kinds of structures have limited fanout to 2-4 elements or so. I was under the impression that the reason datastructures in Haskell tend to be limited to 4-fanout had more to do with the cleanliness of the implementations--- pattern matching on 64-wide cells is quite ugly, as is dealing with the proliferation of corner cases for complex structures like finger trees, patricia trees, etc. The use of view patterns could clean this up significantly. On the other hand, we do have things like lazy ByteStrings and UVector which do have wide fanouts. -- Live well, ~wren From dons at galois.com Wed May 13 18:58:30 2009 From: dons at galois.com (Don Stewart) Date: Wed May 13 18:45:47 2009 Subject: [Haskell-cafe] Structural sharing in haskell data structures? In-Reply-To: <4A0B5078.6010200@freegeek.org> References: <20090512213332.GW19645@whirlpool.galois.com> <20090512220615.GX19645@whirlpool.galois.com> <4A0A4A4B.6080705@freegeek.org> <4A0B5078.6010200@freegeek.org> Message-ID: <20090513225830.GA25908@whirlpool.galois.com> wren: > Jan-Willem Maessen wrote: >> I wanted to clear up one misconception here... >> >> wren ng thornton wrote: >> > In heavily GCed languages like Haskell allocation and collection is >> > cheap, so we don't mind too much; but in Java and the like, both > >> allocation and collection are expensive so the idea of cheap throwaway >> > objects is foreign. >> >> Not true! > > I was speaking of Java, not Clojure. I believe the costs in Java are > well documented, though I don't know enough about the JVM to know where > the blame belongs. (All I know of Clojure is that it's a Lisp-like on > the JVM :) > > >> If you look at the internals of Clojure, you'll discover they're using >> trees with *very* wide fanout (eg fanout-64 leaf trees for lists). >> Why? Because it's so cheap to allocate and GC these structures! By >> using shallow-but-wide trees we reduce the cost of indexing and >> accessing list elements. I suspect you'd still be hard-pressed to >> support this kind of allocation behavior in any of the present Haskell >> implementations, and Haskell implementations of the same kinds of >> structures have limited fanout to 2-4 elements or so. > > I was under the impression that the reason datastructures in Haskell > tend to be limited to 4-fanout had more to do with the cleanliness of > the implementations--- pattern matching on 64-wide cells is quite ugly, > as is dealing with the proliferation of corner cases for complex > structures like finger trees, patricia trees, etc. The use of view > patterns could clean this up significantly. On the other hand, we do > have things like lazy ByteStrings and UVector which do have wide fanouts. > Yes, agreed. This is the first I've heard of a penalty for fan out. More details please! -- Don From lemming at henning-thielemann.de Wed May 13 19:15:30 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed May 13 19:00:39 2009 Subject: [Haskell-cafe] List of exports of a module - are there alternatives? In-Reply-To: <4A0AA164.8020204@yandex.ru> References: <4A0A9F94.20409@kent.ac.uk> <4A0AA164.8020204@yandex.ru> Message-ID: <4A0B5492.3010101@henning-thielemann.de> Miguel Mitrofanov schrieb: > > Neil Brown wrote on 13.05.2009 14:23: >> Leaving aside the arguments about 200 exports, even for 20 exports it >> would sometimes be cleaner to write the above to hide one, than to >> spell out the other 19 in an export list. > > Note that Haddock orders exports according to the export list, not to an > order of definition. Also, you can have (sub)sections in documentation > using an export list only. Therefore, it's still better to have an > export list, even if you export 19 functions and hide one. You can move the few non-exported functions to a hidden module. (hope there are no dependencies on exported functions) From wren at freegeek.org Wed May 13 19:44:28 2009 From: wren at freegeek.org (wren ng thornton) Date: Wed May 13 19:30:24 2009 Subject: [Haskell-cafe] Re: List of exports of a module - are there alternatives? In-Reply-To: References: Message-ID: <4A0B5B5C.4020106@freegeek.org> Maur?cio wrote: > I would like a keyword we could add to a single declaration, > like: > > hidden a :: Int -> Int > a = (...) > > The 200 names is not the best example. It's more a question of > proportion: if you export 5 declarations in a module with 20, > it's OK, but if you export 19 declarations in a module of 20 > maintenance can be painfull to your eyes, going up and down > into your file to check if the list is correct. It sounds like what you (may) want is a refactoring browser which can annotate definitions for whether they're exported or not. This would solve the maintenance issue without the need for a language change. I don't know whether Leksah[1] or Yi[2] can do this, but if not it should be easy to add and it's a reasonable feature to request. Everyone agrees that the module system in Haskell98+HierarchicalModules is the weakest thing we could get away with at the time, and also that it's in need of serious redesign now that we have large scale projects which are straining those boundaries. However, as with the other folks on this thread, I don't think that a new keyword is the proper path for extending the design. Too ad-hoc, too Java/C++ like, it just doesn't have the feel of a fluent, principled, modular, extensible design. [1] http://leksah.org/ [2] http://www.haskell.org/haskellwiki/Yi -- Live well, ~wren From alexander.dunlap at gmail.com Wed May 13 19:46:02 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Wed May 13 19:31:23 2009 Subject: [Haskell-cafe] Building 'text-icu-0.1' on Windows In-Reply-To: References: Message-ID: <57526e770905131646k5c071cbdq4b2002029105f58a@mail.gmail.com> On Wed, May 13, 2009 at 12:54 AM, Serge LE HUITOUZE wrote: > Hi there, > > I fail to build text-icu-0.1 on Windows, and would appreciate some help... > Thanks in advance! > > Let me describe what I've done so for, and what results I got: > > First, I got a version of ICU on my machine, specifically unzipping the > file "icu4c-4_0_1-Win32-msvc8.zip" from > http://icu-project.org/download/4.0.html. > This made me having ICU stuff at location "C:\HaskellStuff\icu\icu", as > witnessed below: > >>> C:\HaskellStuff\icu\icu>dir > << 30/04/2009? 16:08??? ????????? . > << 30/04/2009? 16:08??? ????????? .. > << 30/04/2009? 16:51??? ????????? bin > << 30/04/2009? 16:08??? ????????? include > << 30/04/2009? 16:36??? ????????? lib > << 14/01/2009? 22:48???????????? 2?032 license.html > > After downloading and untaring "text-icu-0.1", I tried to configure, typing > in: > >>> C:\HaskellStuff\pkg\text-icu-0.1>runhaskell Setup configure > << Configuring text-icu-0.1... > << Setup: Missing dependencies on foreign libraries: > << * Missing C libraries: icui18n, icuuc, icudata > << This problem can usually be solved by installing the system packages that > << provide these libraries (you may need the "-dev" versions). If the > libraries > << are already installed but in a non-standard location then you can use the > << flags --extra-include-dirs= and --extra-lib-dirs= to specify where they > are. > > OK, let's restart with appropriate values for said flags! > >>> C:\HaskellStuff\pkg\text-icu-0.1>runhaskell Setup configure >>>??? --extra-include-dirs=C:\HaskellStuff\icu\icu\include >>>??? --extra-lib-dirs=C:\HaskellStuff\icu\icu\lib > << Configuring text-icu-0.1... > > And then proceed with the building per se: > >>> C:\HaskellStuff\pkg\text-icu-0.1>runhaskell Setup build > << Preprocessing library text-icu-0.1... > << In file included from > C:/HaskellStuff/icu/icu/include/unicode/umachine.h:47, > < C:/HaskellStuff/icu/icu/include/unicode/utypes.h:36, > < << C:/HaskellStuff/icu/icu/include/unicode/pwin32.h:120: > < << C:/ghc/ghc-6.10.1/include/mingw/stdint.h:27: > < < < < << compiling dist\build\Data\Text\ICU\Error_hsc_make.c failed > << command was: C:\ghc\ghc-6.10.1\gcc.exe -c -BC:\ghc\ghc-6.10.1\gcc-lib > < -D__GLASGOW_HASKELL__=610 > < < < < < dist\build\Data\Text\ICU\Error_hsc_make.c > < << > << C:\HaskellStuff\pkg\text-icu-0.1> > > The "mingw/stdint.h" file contains a series of lines of this style: > << > << typedef signed char int8_t; > > Whereas, the "unicode/pwin32.h" file contains contains stuff like: > << > << /* Define whether inttypes.h is available */ > << #ifndef U_HAVE_INTTYPES_H > << #define U_HAVE_INTTYPES_H 0 > << #endif > << ... > << > << /* Determines whether specific types are available */ > << #ifndef U_HAVE_INT8_T > << #define U_HAVE_INT8_T U_HAVE_INTTYPES_H > << #endif > << ... > << > << /* If your platform does not have the header, you may > < << #if U_HAVE_INTTYPES_H > << #include > << #else /* U_HAVE_INTTYPES_H */ > << > << #if ! U_HAVE_INT8_T > << typedef signed char int8_t; > << #endif > << ... > << #endif > > So, do I need to explicitely change the icu include file? > And in which way? > > Any other solution/suggestion? > > Best regards. > > --Serge > This isn't really helpful, but I received similar errors when trying to build icu-text on Windows. It seemed like the problem was that GHC's headers defined some of the symbols that were also defined in ICU...I don't know how to fix this though. Alex From relapse.dev at gmx.com Wed May 13 19:51:28 2009 From: relapse.dev at gmx.com (Neal Alexander) Date: Wed May 13 19:36:55 2009 Subject: [Haskell-cafe] Re: ANN: priority-sync-0.1.0.1: Cooperative task prioritization. In-Reply-To: References: Message-ID: Christopher Lane Hinson wrote: > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/priority-sync > > $ cabal install priority-sync > > git clone http://www.downstairspeople.org/git/priority-sync.git > > Feedback will be greatly appreciated. This package is a spin-off from > my work on roguestar, where I need to do significant background > processing while retaining enough resources to perform smooth animation. > > The following is the front-page documentation for the package. > > In a simple use case, we want to run some expensive tasks in prioritized > order, so that only one task is running on each CPU (or hardware thread) > at any time. For this simple case, four operations are needed: > simpleTaskPool, schedule, claim, and startQueue. > > let expensiveTask = threadDelay 1000000 > pool <- simpleTaskPool > forkIO $ claim Acquire (schedule pool 1) $ putStrLn "Task 1 started . . > ." >> expensiveTask >> putStrLn "Task 1 completed." > forkIO $ claim Acquire (schedule pool 3) $ putStrLn "Task 3 started . . > ." >> expensiveTask >> putStrLn "Task 3 completed." > forkIO $ claim Acquire (schedule pool 2) $ putStrLn "Task 2 started . . > ." >> expensiveTask >> putStrLn "Task 2 completed." > threadDelay 100000 -- contrive to wait for all tasks to become enqueued > putStrLn "Starting pool: " > startQueue pool > threadDelay 4000000 -- contrive to wait for all tasks to become dequeued > > A TaskPool combines Rooms and Queues in an efficient easy-to-use-interface. > > Rooms provide fully reentrant synchronization to any number of threads > based on arbitrary resource constraints. For example, the Room from a > simpleTaskPool is constrained by GHC.numCapabilities. > > Queues provide task prioritization. A Queue systematically examines (to > a configurable depth) all waiting threads with their priorities and > resource constraints and wakes the most eagerly prioritized thread whose > constraints can be satisfied. > > TaskPools are not thread pools. The concept is similar to IO Completion > Ports. There are no worker threads. If a number of threads are waiting, > the thread that is most likely to be processed next is woken and > temporarily serves as a working thread. > > Rooms, Queues, and TaskPools are backed by carefully written STM > (software transactional memory) transactions. > > A salient feature is that, because any thread can participate, a > TaskPool supports both bound threads and threads created with forkOnIO. > > Friendly, > --Lane Is 'claim' the only way to execute tasks? Lets say you create a task pool for 1 hardware thread. pool <- newTaskPool fast_queue_configuration 1 () If a task blocks/sleeps while holding a claim, none of the other tasks can run right? Is it possible to create a task pool for 2 hardware threads having one task dominate 1 CPU (render thread), and have other tasks multiplex IO on the other CPU __without stalling each other when blocked__? What happens if you release the room claim before blocking in IO? Does the thread schedule on a random CPU? From lane at downstairspeople.org Wed May 13 20:58:20 2009 From: lane at downstairspeople.org (Christopher Lane Hinson) Date: Wed May 13 20:44:12 2009 Subject: [Haskell-cafe] Re: ANN: priority-sync-0.1.0.1: Cooperative task prioritization. In-Reply-To: References: Message-ID: > Is 'claim' the only way to execute tasks? > > Lets say you create a task pool for 1 hardware thread. > > pool <- newTaskPool fast_queue_configuration 1 () > > If a task blocks/sleeps while holding a claim, none of the other tasks can > run right? Correct, but you can wrap the blocking call inside claim Release {- . . . -} to release the claim temporarilty. > Is it possible to create a task pool for 2 hardware threads having one task > dominate 1 CPU (render thread), and have other tasks multiplex IO on the > other CPU __without stalling each other when blocked__? What happens if you > release the room claim before blocking in IO? Does the thread schedule on a > random CPU? priority-sync only controls access to abstract Rooms that, in the motivating example, represent the resource limitation of the number of hardware threads. Tasks run inside their calling thread, on a CPU dictated by the RTS, so just use forkOnIO to create a thread that is locked to a specific capability if that's really what you want. priority-sync won't be aware that you're doing this. In your case, you may want to allow the rendering thread to run outside of the task pool, and create a room of size (max 1 $ numCapabilities-1) for all of the worker threads. Then wrap all relevant blocking calls as described above (if this is prohibitively combersome, please advise me). Another possibility, if the rendering thread is from something like a GLUT callback, is to have the rendering thread claim the Room using the Unconstrained context. Then you will likely end up with more threads claiming the room than the size of the Room, but the rendering thread will never be made to wait, and the Room will continue to block the worker threads until it has returned to within it's configured constraints. Friendly, --Lane From gwern0 at gmail.com Wed May 13 21:56:55 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Wed May 13 21:42:45 2009 Subject: The HP and PackedString (was: Re: [Haskell-cafe] Removing mtl from the Haskell Platform) In-Reply-To: <20090513223100.GM24620@whirlpool.galois.com> References: <4A0A50EA.5010403@freegeek.org> <877i0lbeb5.fsf_-_@malde.org> <1242214393.20743.4365.camel@localhost> <37113624.20090513153752@gmail.com> <20090513124557.56577be1@greenrd.org> <20090513223100.GM24620@whirlpool.galois.com> Message-ID: On Wed, May 13, 2009 at 6:31 PM, Don Stewart wrote: > Do you have a patch? No. This was a while ago, and the changes really are trivial. I thought about submitting it, but it seemed to me that the change could only be useful when people upgrade their entire compiler/library infrastructure - link errors otherwise - and I wasn't sure it was worth paddling upstream libraries@. -- gwern From jason.dusek at gmail.com Wed May 13 23:45:54 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed May 13 23:32:52 2009 Subject: [Haskell-cafe] forall vs "=>" In-Reply-To: References: Message-ID: <42784f260905132045o58a2b8fbs5cd4b25c5b634ab@mail.gmail.com> 2009/05/12 Daryoush Mehrtash : > runST :: (forall s. ST s a) -> a The `forall` here has a rather elaborate purpose. > evalStateT :: Monad m => StateT s m a -> s -> m a "Where `m` is in `Monad`, we have... Let's put in the "hidden `forall`": evalStateT :: forall s m a. (Monad m) => StateT s m a -> s -> m a The `(Monad m)` is our "class context" -- it tells us that `m` must have an implementation for `Monad`. The `forall` is simple quantification (type signatures are implicitly universally quantified). Looking at your first example, let's put in the hidden `forall`: runST :: forall a. (forall s. ST s a) -> a This is a little fancy. It tells us that for a given `a`, `runST` must accept a stateful computation with a state of any type whatsoever; hence we can not return the type of the state as the result of the computation. My explanation makes short work of an interesting topic; using class contexts is quite a bit more common than using tricky `forall`s. The important thing to seed is that the `=>` introduces a class constraint/condition on our type signature. You can imagine that it is always there: id :: forall a. () => a -> a You can read `=>` as "entails". Then `() =>` is "the universe entails..." and `(Monad m) =>` is "the universe with `m` in `Monad` entails..." -- Jason Dusek From heringtonlacey at mindspring.com Thu May 14 00:53:12 2009 From: heringtonlacey at mindspring.com (Dean Herington) Date: Thu May 14 00:39:50 2009 Subject: [Haskell-cafe] hsffig and duplicate typedef declarations Message-ID: I have a large body of C/C++ code at work that I'd like to be able to access from Haskell via FFI. Because the interface to this code is broad, hsffig would seem to be ideal for the task. I've run across one serious hitch, though. The existing #include file graph is complicated and ends up declaring some typedefs multiple times (albeit in consistent ways). While gcc (for example) rejects such practice, the Windows C compiler we're using accepts it. Does anyone know how feasible it would be to get hsffig to accept such practice as well? I've started looking at the hsffig code (and discovered that the C grammar hsffig uses seems to get confused by duplicate typedefs), but thought I'd ask the list in parallel with my further study. Thanks. Dean From dons at galois.com Thu May 14 00:59:39 2009 From: dons at galois.com (Don Stewart) Date: Thu May 14 00:46:14 2009 Subject: [Haskell-cafe] hsffig and duplicate typedef declarations In-Reply-To: References: Message-ID: <20090514045939.GA27066@whirlpool.galois.com> heringtonlacey: > I have a large body of C/C++ code at work that I'd like to be able to > access from Haskell via FFI. Because the interface to this code is > broad, hsffig would seem to be ideal for the task. > > I've run across one serious hitch, though. The existing #include file > graph is complicated and ends up declaring some typedefs multiple times > (albeit in consistent ways). While gcc (for example) rejects such > practice, the Windows C compiler we're using accepts it. Does anyone know > how feasible it would be to get hsffig to accept such practice as well? > I've started looking at the hsffig code (and discovered that the C > grammar hsffig uses seems to get confused by duplicate typedefs), but > thought I'd ask the list in parallel with my further study. Have you looked at c2hs? (I'm not sure how familiar people are with hsffig, but Dimitry Golubovsky can probably comment) -- Don From heringtonlacey at mindspring.com Thu May 14 01:10:40 2009 From: heringtonlacey at mindspring.com (Dean Herington) Date: Thu May 14 00:56:09 2009 Subject: [Haskell-cafe] hsffig and duplicate typedef declarations In-Reply-To: <20090514045939.GA27066@whirlpool.galois.com> References: <20090514045939.GA27066@whirlpool.galois.com> Message-ID: At 9:59 PM -0700 5/13/09, Don Stewart wrote: >heringtonlacey: >> I have a large body of C/C++ code at work that I'd like to be able to >> access from Haskell via FFI. Because the interface to this code is >> broad, hsffig would seem to be ideal for the task. >> >> I've run across one serious hitch, though. The existing #include file >> graph is complicated and ends up declaring some typedefs multiple times >> (albeit in consistent ways). While gcc (for example) rejects such >> practice, the Windows C compiler we're using accepts it. Does anyone know >> how feasible it would be to get hsffig to accept such practice as well? >> I've started looking at the hsffig code (and discovered that the C >> grammar hsffig uses seems to get confused by duplicate typedefs), but >> thought I'd ask the list in parallel with my further study. > >Have you looked at c2hs? (I'm not sure how familiar people are with >hsffig, but Dimitry Golubovsky can probably comment) > >-- Don Yes, I started this journey with c2hs. Then I moved to hsc2hs, which appeared to be a "standardized" version of the same approach. But my interface consists of hundreds (maybe thousands) of #defines, structs, typedefs, etc., so I quickly tired of the boilerplate wrapping code, modest as it is. Dean From dons at galois.com Thu May 14 01:12:46 2009 From: dons at galois.com (Don Stewart) Date: Thu May 14 00:59:23 2009 Subject: [Haskell-cafe] hsffig and duplicate typedef declarations In-Reply-To: References: <20090514045939.GA27066@whirlpool.galois.com> Message-ID: <20090514051246.GA27116@whirlpool.galois.com> heringtonlacey: > At 9:59 PM -0700 5/13/09, Don Stewart wrote: >> heringtonlacey: >>> I have a large body of C/C++ code at work that I'd like to be able >>> to access from Haskell via FFI. Because the interface to this code >>> is broad, hsffig would seem to be ideal for the task. >>> >>> I've run across one serious hitch, though. The existing #include file >>> graph is complicated and ends up declaring some typedefs multiple times >>> (albeit in consistent ways). While gcc (for example) rejects such >>> practice, the Windows C compiler we're using accepts it. Does anyone know >>> how feasible it would be to get hsffig to accept such practice as >>> well? I've started looking at the hsffig code (and discovered that >>> the C >>> grammar hsffig uses seems to get confused by duplicate typedefs), but >>> thought I'd ask the list in parallel with my further study. >> >> Have you looked at c2hs? (I'm not sure how familiar people are with >> hsffig, but Dimitry Golubovsky can probably comment) >> >> -- Don > > Yes, I started this journey with c2hs. Then I moved to hsc2hs, which > appeared to be a "standardized" version of the same approach. But my > interface consists of hundreds (maybe thousands) of #defines, structs, > typedefs, etc., so I quickly tired of the boilerplate wrapping code, > modest as it is. hsc2hs is much simpler than c2hs. In particular, it processes the header files (unlike hsc2hs) to work out the appropriate type. I'd be interesting to hear how you go with hsffig (and you should contact the author!). -- Don From emax at chalmers.se Thu May 14 01:29:31 2009 From: emax at chalmers.se (Emil Axelsson) Date: Thu May 14 01:14:49 2009 Subject: [Haskell-cafe] ANN: Bookshelf In-Reply-To: <4A0A723A.9000603@chalmers.se> References: <4A0A723A.9000603@chalmers.se> Message-ID: <4A0BAC3B.7000209@chalmers.se> I've added a missing source file (and the documentation files) to Hackage. Hope it works now... Also, if anyone tries it on Windows, please let me know if it works. If not, patches are welcome. / Emil Emil Axelsson skrev: > This is the first release of Bookshelf, a simple document organizer with > some wiki functionality. Documents in a directory tree are displayed as > a set of HTML pages. Documents in Markdown format are converted to HTML > automatically using Pandoc. The manual > > http://www.cs.chalmers.se/~emax/bookshelf/Manual.shelf.html > > describes the full functionality. > > Bookshelf is available on Hackage: > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Bookshelf > > or through its Darcs repository: > > http://www.cs.chalmers.se/~emax/darcs/Bookshelf/ > > I'm not aware of any bugs. > > I hope it works on Windows, but I haven't tested. > > Cheers, > > / Emil > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From emax at chalmers.se Thu May 14 01:30:53 2009 From: emax at chalmers.se (Emil Axelsson) Date: Thu May 14 01:16:05 2009 Subject: [Haskell-cafe] Re: ANN: Bookshelf In-Reply-To: <87tz3p6ir6.fsf@justinbogner.com> References: <4A0A723A.9000603@chalmers.se> <87tz3p6ir6.fsf@justinbogner.com> Message-ID: <4A0BAC8D.6080509@chalmers.se> mail@justinbogner.com skrev: > Emil Axelsson writes: >> This is the first release of Bookshelf, a simple document organizer >> with some wiki functionality. Documents in a directory tree are >> displayed as a set of HTML pages. Documents in Markdown format are >> converted to HTML automatically using Pandoc. The manual >> >> http://www.cs.chalmers.se/~emax/bookshelf/Manual.shelf.html >> >> describes the full functionality. > > It would probably be a good idea to include the markdown functionality > in your demonstration, since it's one of the more interesting > features. This looks pretty neat though, good work! But did you see that the manual itself was generated from markdown? At the top of the page, there's a link to the source: http://www.cs.chalmers.se/~emax/bookshelf/Manual.shelf Anyway, I added some minimal markdown demonstration to the file Documentation/Test/Notes.shelf. If you have any suggestions, let me know. / Emil From heringtonlacey at mindspring.com Thu May 14 01:40:08 2009 From: heringtonlacey at mindspring.com (Dean Herington) Date: Thu May 14 01:25:21 2009 Subject: [Haskell-cafe] hsffig and duplicate typedef declarations In-Reply-To: <20090514051246.GA27116@whirlpool.galois.com> References: <20090514045939.GA27066@whirlpool.galois.com> <20090514051246.GA27116@whirlpool.galois.com> Message-ID: At 10:12 PM -0700 5/13/09, Don Stewart wrote: >heringtonlacey: >> At 9:59 PM -0700 5/13/09, Don Stewart wrote: >>> heringtonlacey: >>>> I have a large body of C/C++ code at work that I'd like to be able >>>> to access from Haskell via FFI. Because the interface to this code >>>> is broad, hsffig would seem to be ideal for the task. >>>> >>>> I've run across one serious hitch, though. The existing #include file >>>> graph is complicated and ends up declaring some typedefs multiple times >>>> (albeit in consistent ways). While gcc (for example) rejects such >>>> practice, the Windows C compiler we're using accepts it. Does anyone know >>>> how feasible it would be to get hsffig to accept such practice as >>>> well? I've started looking at the hsffig code (and discovered that >>>> the C >>>> grammar hsffig uses seems to get confused by duplicate typedefs), but >>>> thought I'd ask the list in parallel with my further study. >>> >>> Have you looked at c2hs? (I'm not sure how familiar people are with >>> hsffig, but Dimitry Golubovsky can probably comment) >>> >>> -- Don >> >> Yes, I started this journey with c2hs. Then I moved to hsc2hs, which >> appeared to be a "standardized" version of the same approach. But my >> interface consists of hundreds (maybe thousands) of #defines, structs, >> typedefs, etc., so I quickly tired of the boilerplate wrapping code, >> modest as it is. > >hsc2hs is much simpler than c2hs. In particular, it processes the header >files (unlike hsc2hs) to work out the appropriate type. Yes, but both c2hs and hsc2hs require the (normally modest but for this situation burdensome) wrapping code. hsffig would produce a (huge) Haskell module with all the interface components available. (In fact I have some concern about the module being too big.) A big win for me would be the ability to write concise code to drill down through nested C structures returned by the foreign functions (without having to process each such module through c2hs or hsc2hs). >I'd be interesting to hear how you go with hsffig (and you should >contact the author!). I'll let the list know how it goes, and will certainly be in touch with Dimitry. Thanks. Dean From vigalchin at gmail.com Thu May 14 01:36:29 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Thu May 14 01:31:06 2009 Subject: [Haskell-cafe] question on the Prelude .. vis-a-vis In-Reply-To: <1242200608-sup-3268@ausone.local> References: <5ae4f2ba0905122217s45bd8461yfa8703354195a6cc@mail.gmail.com> <1242200608-sup-3268@ausone.local> Message-ID: <5ae4f2ba0905132236g6d0a57f4l3a65949cb16db689@mail.gmail.com> thanks, Nicolai. Vasili On Wed, May 13, 2009 at 2:44 AM, Nicolas Pouillard < nicolas.pouillard@gmail.com> wrote: > Excerpts from Vasili I. Galchin's message of Wed May 13 07:17:06 +0200 > 2009: > > Hello, > > > > I am seriously punching my way to build Swish via .cabal ... My > head > > is totally to the wall .... punch .. punch ..... > > [...] > > > Swish/HaskellRDF/Dfa/Dfa.lhs:1:0: > > Failed to load interface for `Prelude': > > it is a member of package base, which is hidden > > You want to add 'base' to the 'Build-Depends:' field of the cabal file. > > -- > Nicolas Pouillard > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090514/c3bea629/attachment.html From schlepptop at henning-thielemann.de Thu May 14 03:28:01 2009 From: schlepptop at henning-thielemann.de (Henning Thielemann) Date: Thu May 14 03:13:51 2009 Subject: [Haskell-cafe] IO trouble In-Reply-To: <87r5ytrxny.fsf@columbia.edu> References: <873abat4uf.fsf@columbia.edu> <20090513004524.GA13768@cs.helsinki.fi> <87r5ytrxny.fsf@columbia.edu> Message-ID: <4A0BC801.6030700@henning-thielemann.de> Xiao-Yong Jin schrieb: > Lauri Alanko writes: > >> On Tue, May 12, 2009 at 04:59:36PM -0400, Xiao-Yong Jin wrote: >>>> f :: a -> b >>>> g :: (a -> b) -> c -> d >>>> gf :: c -> d >>>> gf = g f >>> Now I want to handle exceptions in f and redefine f as in f' >>> >>>> f' :: a -> IO (Either e b) >>> So my question is how to define gf' now to use f' instead of >>> f? >>> >>>> gf' :: c -> IO (Either e d) >> Use Control.Monad.Error.ErrorT, it's exactly for this. You have to >> "monadize" g to be able to pass f' as an argument to it. >> >> f' :: a -> ErrorT e IO b >> g' :: Monad m => (a -> m b) -> c -> m d >> gf' :: c -> ErrorT e IO d >> gf' = g' f' > > So there is no way to do it without "monadize" g to g', is > it? Big trouble, sigh. Sure, but I'm afraid that gets more complicated. Btw. you can also use ExceptionalT and Exceptional from explicit-exception package, which does not require a constraint on the exception type. From g9ks157k at acme.softbase.org Thu May 14 03:43:57 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Thu May 14 03:30:12 2009 Subject: [darcs-users] [Haskell-cafe] Darcs as undo/redo system? In-Reply-To: <30skj96cuy.fsf@alexlance.com> References: <200905121312.48917.g9ks157k@acme.softbase.org> <30skj96cuy.fsf@alexlance.com> Message-ID: <200905140943.57352.g9ks157k@acme.softbase.org> Am Mittwoch, 13. Mai 2009 02:55 schrieb Trent W. Buck: > Wolfgang Jeltsch writes: > > Am Freitag, 8. Mai 2009 18:43 schrieb Jason Dagit: > >> If you wanted to work on this, I would encourage you to read more > >> about patch theory[1,2,3,4] and also try out libdarcs[5]. > > > > Is libdarcs the same as the darcs library package on Hackage (which > > exports the darcs API)? > > The Darcs package (both on Hackage and elsewhere) builds two things: the > darcs(1) binary, and libHSdarcs. The latter is what Jason was referring > to. Note that currently it just exposes all our internal functions, > rather than providing a coherent (or stable!) API. I know. My students, who worked on a darcs GUI frontend, already experienced this. ;-) Best wishes, Wolfgang From g9ks157k at acme.softbase.org Thu May 14 04:14:48 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Thu May 14 04:00:05 2009 Subject: [Haskell-cafe] Removing mtl from the Haskell Platform In-Reply-To: References: Message-ID: <200905141014.48231.g9ks157k@acme.softbase.org> Am Mittwoch, 13. Mai 2009 01:03 schrieb roconnor@theorem.ca: > I wanted to pass this idea around the cafe to get some thoughts before > submitting a trac on this topic. > > I'd like to see the mtl removed from the Haskell Platform. > > The mtl was a tremendous step forward when it was developed. However, we > have learned a few things about monad transformers since the development > of the mtl, and it is time that we moved forward. > > There are at least 3 significant problem with the mtl. > > 1) `pass' should not be a member functions of the MonadWriter class. It > is my understanding that there is no `MonadWriter w m => MonadWriter w > (ContT s m)' instance because the `pass' function cannot be implemented. > I'm also highly suspicious of some other methods too (I'm looking at you > `local'). > > 2) The `StateT s (Cont r a)' instance of callCC is wrong. The paper on > modular monad transformers > describes why this is > wrong. > > 3) I am told by many people that the order of the state and value pair in > `State' is backwards. Actually, I'm not entirely sure what the issue is > here, but I trust the people who say this. 4) The identifiers State and StateT are flawed. Something of value State s a doesn?t denote a state but a state transformer or however you want to name it. Best wishes, Wolfgang From rjones at redhat.com Thu May 14 04:29:28 2009 From: rjones at redhat.com (Richard W.M. Jones) Date: Thu May 14 04:14:44 2009 Subject: [Haskell-cafe] [ANNOUNCE] Bindings for libguestfs In-Reply-To: <536C7F69-CD9D-4004-9DDD-3743B78CD27F@gmail.com> References: <20090511085246.GA4476@amd.home.annexia.org> <20090512191132.GG3278@colquitt.org> <20090513104007.GA22702@amd.home.annexia.org> <536C7F69-CD9D-4004-9DDD-3743B78CD27F@gmail.com> Message-ID: <20090514082928.GA24679@amd.home.annexia.org> On Wed, May 13, 2009 at 11:15:24PM +1000, Peter Gammie wrote: > Hope this helps! Thanks for your honest & helpful answer. I think I will try again at compiling c2hs so I can look at the code that it generates. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/ From ttencate at gmail.com Thu May 14 04:44:01 2009 From: ttencate at gmail.com (Thomas ten Cate) Date: Thu May 14 04:29:35 2009 Subject: [Haskell-cafe] Removing mtl from the Haskell Platform In-Reply-To: <200905141014.48231.g9ks157k@acme.softbase.org> References: <200905141014.48231.g9ks157k@acme.softbase.org> Message-ID: On Thu, May 14, 2009 at 10:14, Wolfgang Jeltsch wrote: > 4) The identifiers State and StateT are flawed. Something of value State s a > doesn?t denote a state but a state transformer or however you want to name > it. A "state monad", i.e. a monad containing a state? If you use it in a sentence in that way, the name State makes sense. "StateTransformer" or something like that would lead to much confusion with the "state transformer transformer" that is currently called StateT. I don't really see a good alternative to the name State, and a good thing about it is that it is short. Oh, bikesheds ought to be brown, of course. Cheers, Thomas From wrwills at gmail.com Thu May 14 05:25:01 2009 From: wrwills at gmail.com (Robert Wills) Date: Thu May 14 05:10:24 2009 Subject: [Haskell-cafe] Functional Reactive Web Application Framework? In-Reply-To: <20090513223005.GL24620@whirlpool.galois.com> References: <20090513073641.GA10387@pudlak.name> <20090513223005.GL24620@whirlpool.galois.com> Message-ID: Yes, I didn't realise that until Arjun mentioned that. I'm going to try to find some time to look more closely at Flapjax... -Rob On Wed, May 13, 2009 at 11:30 PM, Don Stewart wrote: > wrwills: >> The ?only web-oriented frp framework that I know of is Flapjax >> http://www.flapjax-lang.org/ >> >> Flapjax is javascript so possibly there could be a way to integrate it >> into Haskell using HJavascript? ?Maybe it could even be integrated >> into Happstack? >> >> I'm also quite new to Haskell. > > Isn't the flapjax compiler implemented in Haskell? > > -- Don > From vladimir.v.ivanov at gmail.com Thu May 14 06:41:02 2009 From: vladimir.v.ivanov at gmail.com (Vladimir Ivanov) Date: Thu May 14 06:32:17 2009 Subject: [Haskell-cafe] Structural sharing in haskell data structures? In-Reply-To: <4A0B5078.6010200@freegeek.org> References: <20090512213332.GW19645@whirlpool.galois.com> <20090512220615.GX19645@whirlpool.galois.com> <4A0A4A4B.6080705@freegeek.org> <4A0B5078.6010200@freegeek.org> Message-ID: <8062e1720905140341k11bcb403l3990e6874dab0eb@mail.gmail.com> Wren, It's not true for Java either. The idea of "cheap throw-away objects" isn't foreign for modern JVMs. GC favors short-lived immutable objects since: - all collectors are generational; - GC cycle duration is proportional to the size of live objects, not the heap size; - object allocation is _very_ cheap, even in parallel; Moreover, many advanced techniques are used in JVM GCs: - there are parallel & concurrent collectors; - adaptive ergonomics (e.g. heap resizing, according to some goals on collection duration); There are problems with functional languages on top of JVM, but GC isn't among them. If you are interested in current work, you may look at mlvm project [1]. -- vi [1] http://openjdk.java.net/projects/mlvm/ On Thu, May 14, 2009 at 2:58 AM, wren ng thornton wrote: > Jan-Willem Maessen wrote: >> >> I wanted to clear up one misconception here... >> >> wren ng thornton wrote: >> > In heavily GCed languages like Haskell allocation and collection is > >> > cheap, so we don't mind too much; but in Java and the like, both > >> > allocation and collection are expensive so the idea of cheap throwaway > >> > objects is foreign. >> >> Not true! > > I was speaking of Java, not Clojure. I believe the costs in Java are well > documented, though I don't know enough about the JVM to know where the blame > belongs. (All I know of Clojure is that it's a Lisp-like on the JVM :) > > >> If you look at the internals of Clojure, you'll discover they're using >> trees with *very* wide fanout (eg fanout-64 leaf trees for lists). ?Why? >> ?Because it's so cheap to allocate and GC these structures! ?By using >> shallow-but-wide trees we reduce the cost of indexing and accessing list >> elements. ?I suspect you'd still be hard-pressed to support this kind of >> allocation behavior in any of the present Haskell implementations, and >> Haskell implementations of the same kinds of structures have limited fanout >> to 2-4 elements or so. > > I was under the impression that the reason datastructures in Haskell tend to > be limited to 4-fanout had more to do with the cleanliness of the > implementations--- pattern matching on 64-wide cells is quite ugly, as is > dealing with the proliferation of corner cases for complex structures like > finger trees, patricia trees, etc. The use of view patterns could clean this > up significantly. On the other hand, we do have things like lazy ByteStrings > and UVector which do have wide fanouts. > > -- > Live well, > ~wren > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From simonpj at microsoft.com Thu May 14 06:53:50 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Thu May 14 06:44:53 2009 Subject: [Haskell-cafe] Fun with type functions Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C337FBFCC84E@EA-EXMSG-C334.europe.corp.microsoft.com> Friends Ken, Oleg, and I have been working on a tutorial paper about type families (aka associated data types, or type functions). It's in draft at the moment, and we'd really appreciate feedback that would help us improve it. Here it is: http://haskell.org/haskellwiki/Simonpj/Talk:FunWithTypeFuns Thank you! Simon From wrwills at gmail.com Thu May 14 07:51:03 2009 From: wrwills at gmail.com (Robert Wills) Date: Thu May 14 07:36:50 2009 Subject: [Haskell-cafe] haskellnet Message-ID: Hello, Yesterday I found myself wanting to clear out a spam-ridden pop account without downloading all the messages. Rather than just using Python's poplib, I thought I might look for a haskell solution and came across Haskellnet: http://darcs.haskell.org/SoC/haskellnet/ I ended up spending much of the afternoon getting it to compile and much of last night trying to get the pop library to actually work (the 'strip' method produced exceptions). It was a good learning experience (this was helpful: http://donsbot.wordpress.com/2007/11/14/no-more-exceptions-debugging-haskell-code-with-ghci/). I'm writing here because I'm wondering whether it would be worthwhile putting it up on hackage? From searching this list, there seem to have been a few times when people have stumbled across it but got frustrated when it didn't compile. If so, what's the protocol? Is the original author, Jun Mukai, still around? Thanks, Rob From jmaessen at alum.mit.edu Thu May 14 09:03:30 2009 From: jmaessen at alum.mit.edu (Jan-Willem Maessen) Date: Thu May 14 08:51:49 2009 Subject: [Haskell-cafe] Structural sharing in haskell data structures? In-Reply-To: <4A0B5078.6010200@freegeek.org> References: <20090512213332.GW19645@whirlpool.galois.com> <20090512220615.GX19645@whirlpool.galois.com> <4A0A4A4B.6080705@freegeek.org> <4A0B5078.6010200@freegeek.org> Message-ID: <059CC686-2836-42A4-952E-11AE7334DF32@alum.mit.edu> On May 13, 2009, at 6:58 PM, wren ng thornton wrote: > Jan-Willem Maessen wrote: >> I wanted to clear up one misconception here... >> wren ng thornton wrote: >> > In heavily GCed languages like Haskell allocation and collection >> is > cheap, so we don't mind too much; but in Java and the like, >> both > allocation and collection are expensive so the idea of cheap >> throwaway > objects is foreign. >> Not true! > > I was speaking of Java, not Clojure. I believe the costs in Java are > well documented, though I don't know enough about the JVM to know > where the blame belongs. (All I know of Clojure is that it's a Lisp- > like on the JVM :) I think you're missing the point here: the code I refer to below *is in Java* and is running on a standard JVM; the "costs" you refer to simply don't exist! As Vladimir Ivanov points out, and as Rich Hickey is happy to observe in his talks on Clojure, the JVM handles allocation-intensive garbage-intensive programs very well. >> If you look at the internals of Clojure, you'll discover they're >> using trees with *very* wide fanout (eg fanout-64 leaf trees for >> lists). Why? Because it's so cheap to allocate and GC these >> structures! By using shallow-but-wide trees we reduce the cost of >> indexing and accessing list elements. I suspect you'd still be >> hard-pressed to support this kind of allocation behavior in any of >> the present Haskell implementations, and Haskell implementations of >> the same kinds of structures have limited fanout to 2-4 elements or >> so. > > I was under the impression that the reason datastructures in Haskell > tend to be limited to 4-fanout had more to do with the cleanliness > of the implementations--- pattern matching on 64-wide cells is quite > ugly, as is dealing with the proliferation of corner cases for > complex structures like finger trees, patricia trees, etc. The use > of view patterns could clean this up significantly. On the other > hand, we do have things like lazy ByteStrings and UVector which do > have wide fanouts. Hmm, I think neither of the data structures you name actually support both O(lg n) indexing and O(lg n) cons or append. That said, your point is well taken, so let's instead state it as a challenge: Can you, oh Haskellers, implement a fast, wide-fanout (say >= 8) tree- based sequence implementation in Haskell, which supports at-least-log- time indexing and at-least-log-time cons with a large base for the logarithm? Can you do it without turning off array bounds checking (either by using unsafe operations or low-level peeking and poking) and without using an algebraic data type with O(f) constructors for fanout of f? You can turn off bounds checks if your program encodes static guarantees that indices cannot be out of bounds (there are a couple of libraries to do this). The spirit here is "Work in Haskell with safe operations and no FFI except through safe libraries, but otherwise use any extensions you like." I actually think this *is* doable, but it touches a few areas where Haskell doesn't presently do well (the bounds checking in particular is a challenge). I threw in the bounds checking when I realized that in fact the equivalent Java code is always bounds checked, and these bounds checks are then optimized away where possible. Actually, I'd *love* to see an *in*efficient solution to eliminating as many bounds checks as possible! -Jan > > > -- > Live well, > ~wren > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ndmitchell at gmail.com Thu May 14 09:37:11 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Thu May 14 09:23:54 2009 Subject: [Haskell-cafe] haskellnet In-Reply-To: References: Message-ID: <404396ef0905140637w45018f36m3d2f69c2b1e16650@mail.gmail.com> Hi Email the original author, if you can. Ideally work with them to upload a working version to hackage. If they're not interested hopefully they'll make you the new maintainer. If you can't contact them, just upload a new version anyway - as long as it's done for the benefit of the community and not with malicious intent, everyone is happy. And please do make sure you upload something working, I imagine this will be very useful to lots of people! Thanks for your efforts Neil On Thu, May 14, 2009 at 12:51 PM, Robert Wills wrote: > Hello, > > Yesterday I found myself wanting to clear out a spam-ridden pop > account without downloading all the messages. Rather than just using > Python's poplib, I thought I might look for a haskell solution and > came across Haskellnet: > http://darcs.haskell.org/SoC/haskellnet/ > > I ended up spending much of the afternoon getting it to compile and > much of last night trying to get the pop library to actually work (the > 'strip' method produced exceptions). ?It was a good learning > experience (this was helpful: > http://donsbot.wordpress.com/2007/11/14/no-more-exceptions-debugging-haskell-code-with-ghci/). > > I'm writing here because I'm wondering whether it would be worthwhile > putting it up on hackage? From searching this list, there seem to have > been a few times when people have stumbled across it but got > frustrated when it didn't compile. ?If so, what's the protocol? Is the > original author, Jun Mukai, still around? > > Thanks, > Rob > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From vxc at Cs.Nott.AC.UK Thu May 14 10:06:57 2009 From: vxc at Cs.Nott.AC.UK (vxc@Cs.Nott.AC.UK) Date: Thu May 14 09:56:34 2009 Subject: [Haskell-cafe] PhD position in Nottingham Message-ID: <200905141506.aa09609@pat.Cs.Nott.AC.UK> PhD position in Type Theory at Nottingham ----------------------------------------- A new PhD position is available in the Functional Programming Laboratory at the University of Nottingham. The topic of research for the project is "Programming and Reasoning with Infinite Structures": it consists in the theoretical study and development of software tools for coinductive types and structured corecursion. The candidate must be a UK resident with an excellent degree in Computer Science or Mathematics at MSc (preferred) or BSc level (first class or equivalent). The applicant should have a good background in mathematical logic, theoretical computer science or functional programming. (S)he should be interested doing research in type theory, constructive mathematics, category theory and foundations of formal reasoning. We offer: PhD place with living expenses (standard UK level) for 3 years. The grants also provide laptops and travel expenses for conference and workshop visits. Nottingham University provides a vibrant research environment in the Functional Programming Laboratory. Deadline for applications: 20 June 2009. Send a cover letter and your CV to Venanzio Capretta (vxc@cs.nott.ac.uk). Please contact me for any additional information that you need. This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. From duncan.coutts at worc.ox.ac.uk Thu May 14 10:17:08 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu May 14 10:02:48 2009 Subject: [Haskell-cafe] Structural sharing in haskell data structures? In-Reply-To: <059CC686-2836-42A4-952E-11AE7334DF32@alum.mit.edu> References: <20090512213332.GW19645@whirlpool.galois.com> <20090512220615.GX19645@whirlpool.galois.com> <4A0A4A4B.6080705@freegeek.org> <4A0B5078.6010200@freegeek.org> <059CC686-2836-42A4-952E-11AE7334DF32@alum.mit.edu> Message-ID: <1242310628.20743.6274.camel@localhost> On Thu, 2009-05-14 at 09:03 -0400, Jan-Willem Maessen wrote: > Hmm, I think neither of the data structures you name actually support > both O(lg n) indexing and O(lg n) cons or append. That said, your > point is well taken, so let's instead state it as a challenge: > > Can you, oh Haskellers, implement a fast, wide-fanout (say >= 8) tree- > based sequence implementation in Haskell, which supports at-least-log- > time indexing and at-least-log-time cons with a large base for the > logarithm? Can you do it without turning off array bounds checking > (either by using unsafe operations or low-level peeking and poking) > and without using an algebraic data type with O(f) constructors for > fanout of f? You can turn off bounds checks if your program encodes > static guarantees that indices cannot be out of bounds (there are a > couple of libraries to do this). Can we motivate the restriction of not using multiple constructors? If we're only talking about a fanout of 8 then it doesn't look like a problem. It sounds like you're really asking for an array but without wanting to say so explicitly. Perhaps you should ask for a variable fanout or a fanout of something bigger like 32 (and presumably these requirements could be justified too?). Duncan From jmaessen at alum.mit.edu Thu May 14 10:30:35 2009 From: jmaessen at alum.mit.edu (Jan-Willem Maessen) Date: Thu May 14 10:16:03 2009 Subject: [Haskell-cafe] Structural sharing in haskell data structures? In-Reply-To: <1242310628.20743.6274.camel@localhost> References: <20090512213332.GW19645@whirlpool.galois.com> <20090512220615.GX19645@whirlpool.galois.com> <4A0A4A4B.6080705@freegeek.org> <4A0B5078.6010200@freegeek.org> <059CC686-2836-42A4-952E-11AE7334DF32@alum.mit.edu> <1242310628.20743.6274.camel@localhost> Message-ID: <9401716F-7343-4E83-A9D3-FAD8BF620175@alum.mit.edu> On May 14, 2009, at 10:17 AM, Duncan Coutts wrote: > On Thu, 2009-05-14 at 09:03 -0400, Jan-Willem Maessen wrote: > >> Hmm, I think neither of the data structures you name actually support >> both O(lg n) indexing and O(lg n) cons or append. That said, your >> point is well taken, so let's instead state it as a challenge: >> >> Can you, oh Haskellers, implement a fast, wide-fanout (say >= 8) >> tree- >> based sequence implementation in Haskell, which supports at-least- >> log- >> time indexing and at-least-log-time cons with a large base for the >> logarithm? Can you do it without turning off array bounds checking >> (either by using unsafe operations or low-level peeking and poking) >> and without using an algebraic data type with O(f) constructors for >> fanout of f? You can turn off bounds checks if your program encodes >> static guarantees that indices cannot be out of bounds (there are a >> couple of libraries to do this). > > Can we motivate the restriction of not using multiple constructors? If > we're only talking about a fanout of 8 then it doesn't look like a > problem. I actually expect this will cause some fairly nasty code bloat, but I'm happy to be proven wrong. :-) > It sounds like you're really asking for an array but without > wanting to say so explicitly. Perhaps you should ask for a variable > fanout or a fanout of something bigger like 32 (and presumably these > requirements could be justified too?). Wide fanout seems fair. -Jan > > > Duncan > From simonpj at microsoft.com Thu May 14 10:59:29 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Thu May 14 10:45:12 2009 Subject: [Haskell-cafe] Performance Problem with Typeable In-Reply-To: References: Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C337FBFCCAE0@EA-EXMSG-C334.europe.corp.microsoft.com> Interesting. Would anyone care to make a Trac ticket for this (with "perf bug" as the ticket kind), and (if at all possible) do some investigation to see what is going on? Many thanks Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On | Behalf Of Michael D. Adams | Sent: 13 May 2009 22:57 | To: Haskell Cafe | Subject: [Haskell-cafe] Performance Problem with Typeable | | I'm not sure where this should be reported, but I think I've found a | significant asymptotic performance problem with Data.Typeable. In the | attached code, sum2 runs much slower than either sum1 or sum3. It | should be linear but it seems to slow down quadratically (i.e. | doubling "len" quadruples the time for sum2). Here is an example run: | | $ ghc --make -O3 CastSpeed.hs | $ ./CastSpeed 20000 | gsum1 | Result: 200010000 | Time(sec): 7.999e-3 | Result: 200010000 | Time(sec): 0.0 | Result: 200010000 | Time(sec): 1.0e-3 | | gsum2 | Result: 200010000 | Time(sec): 1.483774 | Result: 200010000 | Time(sec): 1.477776 | Result: 200010000 | Time(sec): 1.523768 | | gsum3 | Result: 200010000 | Time(sec): 5.999e-3 | Result: 200010000 | Time(sec): 0.0 | Result: 200010000 | Time(sec): 0.0 | | The only difference between sum1 and sum2 is that sum2 wraps a | singleton list around each element (i.e. the cast is to [Int] instead | of Int). The only difference between sum2 and sum3 is that sum3 uses | an unchecked cast (unsafeCoerce) instead of a checked cast. This | problem seems to crop up only for those types which are made up of a | type constructor applied to an argument (e.g. "[]" applied to "Int"). | | Because of sum3 runs fast, I suspect that something is going wrong | with the "typeOf" call in a checked cast, and because sum1 runs fast I | suspect that what is going wrong is the call to appKey that is called | from mkAppTy that is called from typeOfDefault that is called from the | Typeable instance for [Int] (i.e. instance (Typeable1 s, Typeable a) | => Typeable (s a)). This is a bit of speculation and I don't have | hard evidence for that being the source of the problems, but tests | that I have run (not listed here) are strongly suggestive of appKey | being the culprit. | | Michael D. Adams | mdmkolbe@gmail.com From paulfrancis at friendbliss.com Thu May 14 11:07:49 2009 From: paulfrancis at friendbliss.com (paulfrancis@friendbliss.com) Date: Thu May 14 10:53:11 2009 Subject: [Haskell-cafe] Developing 3 dimensional interactive environments/functional objects Message-ID: <20090514080749.a7fe6210508103e9b2d8ae485714347f.0cab579e5d.wbe@email03.secureserver.net> An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090514/de2e7c9d/attachment.html From jmaessen at alum.mit.edu Thu May 14 11:21:21 2009 From: jmaessen at alum.mit.edu (Jan-Willem Maessen) Date: Thu May 14 12:01:41 2009 Subject: [Haskell-cafe] Structural sharing in haskell data structures? In-Reply-To: <200905141101.30809.dan.doel@gmail.com> References: <4A0B5078.6010200@freegeek.org> <059CC686-2836-42A4-952E-11AE7334DF32@alum.mit.edu> <200905141101.30809.dan.doel@gmail.com> Message-ID: <6E82E4E3-0615-4B51-A062-2748CFA1522B@alum.mit.edu> On May 14, 2009, at 11:01 AM, Dan Doel wrote: > On Thursday 14 May 2009 9:03:30 am Jan-Willem Maessen wrote: >> Hmm, I think neither of the data structures you name actually support >> both O(lg n) indexing and O(lg n) cons or append. That said, your >> point is well taken, so let's instead state it as a challenge: > > Data.Sequence has O(log n) index, concatenation, update, take, drop > and > splitAt, and O(1) cons, snoc, and viewing at both ends, according to > the > documentation. Yes. But large sequences end up being quite deep. Can a wide-fanout version be made that is actually faster? Note that the effective fanout of Hinze's finger trees is approximately e; consider effective fanouts of e^2 to e^4 (which may require substantially higher maximum fanout). -Jan > -- Dan From dan.doel at gmail.com Thu May 14 11:01:29 2009 From: dan.doel at gmail.com (Dan Doel) Date: Thu May 14 12:51:14 2009 Subject: [Haskell-cafe] Structural sharing in haskell data structures? In-Reply-To: <059CC686-2836-42A4-952E-11AE7334DF32@alum.mit.edu> References: <4A0B5078.6010200@freegeek.org> <059CC686-2836-42A4-952E-11AE7334DF32@alum.mit.edu> Message-ID: <200905141101.30809.dan.doel@gmail.com> On Thursday 14 May 2009 9:03:30 am Jan-Willem Maessen wrote: > Hmm, I think neither of the data structures you name actually support > both O(lg n) indexing and O(lg n) cons or append. That said, your > point is well taken, so let's instead state it as a challenge: Data.Sequence has O(log n) index, concatenation, update, take, drop and splitAt, and O(1) cons, snoc, and viewing at both ends, according to the documentation. -- Dan From golubovsky at gmail.com Thu May 14 13:18:08 2009 From: golubovsky at gmail.com (Dimitry Golubovsky) Date: Thu May 14 13:03:49 2009 Subject: [Haskell-cafe] hsffig and duplicate typedef declarations Message-ID: Dean, I am not sure how HSFFIG would deal with duplicate typedefs (I'm afraid you get error from gcc when processing hsc2hs output). In case you haven't seen this, I put a repo for HSFFIG here recently: http://code.haskell.org/hsffig/ Before running "cabal install" run make at the toplevel of the repo first. I have fixed some glitches recently, and adjusted both hsffig and ffipkg to work with contemporary GHC and Cabal (at least 1.6.0.x). I'd be glad to get any feedback on HSFFIG. E-mail me to "golubovsky at gmail dot com". Thanks. -- Dimitry Golubovsky Anywhere on the Web From bos at serpentine.com Thu May 14 13:18:31 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Thu May 14 13:04:15 2009 Subject: [Haskell-cafe] Building 'text-icu-0.1' on Windows In-Reply-To: <57526e770905131646k5c071cbdq4b2002029105f58a@mail.gmail.com> References: <57526e770905131646k5c071cbdq4b2002029105f58a@mail.gmail.com> Message-ID: On Wed, May 13, 2009 at 4:46 PM, Alexander Dunlap < alexander.dunlap@gmail.com> wrote: > This isn't really helpful, but I received similar errors when trying > to build icu-text on Windows If one of you has the time to dig into this and send a patch that corrects the problem, I'd welcome the help. As I'm sure you can tell, I developed text-icu on Unix, and I don't have regular enough Windows access to make debugging this a quick and easy matter. Thanks, B. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090514/c494a606/attachment.html From dons at galois.com Thu May 14 13:18:59 2009 From: dons at galois.com (Don Stewart) Date: Thu May 14 13:05:57 2009 Subject: [Haskell-cafe] Structural sharing in haskell data structures? In-Reply-To: <6E82E4E3-0615-4B51-A062-2748CFA1522B@alum.mit.edu> References: <4A0B5078.6010200@freegeek.org> <059CC686-2836-42A4-952E-11AE7334DF32@alum.mit.edu> <200905141101.30809.dan.doel@gmail.com> <6E82E4E3-0615-4B51-A062-2748CFA1522B@alum.mit.edu> Message-ID: <20090514171859.GD29655@whirlpool.galois.com> jmaessen: > > On May 14, 2009, at 11:01 AM, Dan Doel wrote: > >> On Thursday 14 May 2009 9:03:30 am Jan-Willem Maessen wrote: >>> Hmm, I think neither of the data structures you name actually support >>> both O(lg n) indexing and O(lg n) cons or append. That said, your >>> point is well taken, so let's instead state it as a challenge: >> >> Data.Sequence has O(log n) index, concatenation, update, take, drop >> and >> splitAt, and O(1) cons, snoc, and viewing at both ends, according to >> the >> documentation. > > Yes. But large sequences end up being quite deep. Can a wide-fanout > version be made that is actually faster? Note that the effective fanout > of Hinze's finger trees is approximately e; consider effective fanouts of > e^2 to e^4 (which may require substantially higher maximum fanout). Ah, so I see what Jan's asking for (I think). During the hackathon a number of us were experimenting with associated types to flatten groups of nodes in Data.Map (by unpacking them into the constructor). We were playing with fan out of up to 16 (while preserving pattern matching that makes it look like the original constructors). Good speedups followed, thanks to the improved data density. Here's a video (first part is about visualizing heap structures): http://vimeo.com/4258084 -- Don From bos at serpentine.com Thu May 14 13:25:48 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Thu May 14 13:11:32 2009 Subject: [Haskell-cafe] Building 'text-icu-0.1' on Windows In-Reply-To: References: <57526e770905131646k5c071cbdq4b2002029105f58a@mail.gmail.com> Message-ID: On Thu, May 14, 2009 at 10:18 AM, Bryan O'Sullivan wrote: > > If one of you has the time to dig into this and send a patch that corrects > the problem, I'd welcome the help. As I'm sure you can tell, I developed > text-icu on Unix, and I don't have regular enough Windows access to make > debugging this a quick and easy matter. > > By the way, if you run into problems building or using text or text-icu, please file a ticket here: http://trac.haskell.org/text/newticket -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090514/91bb41ee/attachment.html From j.romildo at gmail.com Thu May 14 14:58:18 2009 From: j.romildo at gmail.com (=?ISO-8859-1?Q?Jos=E9_Romildo_Malaquias?=) Date: Thu May 14 14:46:39 2009 Subject: [Haskell-cafe] Pretty printing a tree Message-ID: <416a2ab0905141158y235b2ae2ha37ee4c5ec3c51d@mail.gmail.com> Hello. I would like to pretty print a tree in a way that its structure is easily perceived. For instance, consider the declarations: data Node a = Node a [Node a] type Tree a = [ Node a ] t = [ Node "a" [ Node "b" [] , Node "c" [ Node "c1" [] , Node "c2" [] ] , Node "d" [ Node "d1" [ Node "d1a" [] ] , Node "d2" [] ] ] ] Then the resulting of pretty printing the given tree would be something like the following: a | +-------------+ | | | b c d | | +---+ +---+ | | | | c1 c2 d1 d2 | d1a There is the module Text.PrettyPrint.HughesPJ, but it lacks examples on how to use the pretty print combinators, and it is not well docomented. I would like to see solutions for this problem, or clues on how to solve it. Regards, Jos? Romildo From wagner.andrew at gmail.com Thu May 14 15:00:08 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Thu May 14 14:47:37 2009 Subject: [Haskell-cafe] Pretty printing a tree In-Reply-To: <416a2ab0905141158y235b2ae2ha37ee4c5ec3c51d@mail.gmail.com> References: <416a2ab0905141158y235b2ae2ha37ee4c5ec3c51d@mail.gmail.com> Message-ID: Perhaps drawTree on http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Tree.html 2009/5/14 Jos? Romildo Malaquias > Hello. > > I would like to pretty print a tree in a way that its structure is > easily perceived. > > For instance, consider the declarations: > > data Node a = Node a [Node a] > > type Tree a = [ Node a ] > > t = [ Node "a" [ Node "b" [] > , Node "c" [ Node "c1" [] > , Node "c2" [] ] > , Node "d" [ Node "d1" [ Node "d1a" [] ] > , Node "d2" [] ] ] ] > > Then the resulting of pretty printing the given tree would be something > like the following: > > a > | > +-------------+ > | | | > b c d > | | > +---+ +---+ > | | | | > c1 c2 d1 d2 > | > d1a > > There is the module Text.PrettyPrint.HughesPJ, but it lacks examples on > how to use the pretty print combinators, and it is not well docomented. > > I would like to see solutions for this problem, or clues on how to solve > it. > > Regards, > > Jos? Romildo > _______________________________________________ > 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/20090514/1e28df6f/attachment.html From dev at mobileink.com Thu May 14 15:32:34 2009 From: dev at mobileink.com (Gregg Reynolds) Date: Thu May 14 15:19:15 2009 Subject: [Haskell-cafe] commending "Design concepts in programming languages" In-Reply-To: References: <5e0214850904291029gd68128bofccf9691c400adf4@mail.gmail.com> <200905081323.09106.g9ks157k@acme.softbase.org> <200905081431.09883.daniel.is.fischer@web.de> <200905121341.06138.g9ks157k@acme.softbase.org> Message-ID: <75cc17ac0905141232le91c41ra264f999b7344bcf@mail.gmail.com> On Tue, May 12, 2009 at 1:04 PM, Max Rabkin wrote: > On Tue, May 12, 2009 at 1:41 PM, Wolfgang Jeltsch > wrote: >> At least, I cannot >> remember seeing the other notation (first morphism on the left) in category >> theory literature so far. It?s just that my above-mentioned professor told me >> that category theorists would use the first-morphism-on-the-left notation. > > I've seen the notation f;g for g.f somewhere (and Wikipedia mentions > it). I think it's less ambiguous than just fg (which I've seen for f.g > too), but in Haskell we have the option of >>>. A flipped application > might be nice to go with it. How about >$> ? FYI: Unicode U+2A3E Zed notation relational composition (small circle over a 9) Examples at http://staff.washington.edu/jon/z/toolkit.html#pair3 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090514/a0ab2a52/attachment.html From dmehrtash at gmail.com Thu May 14 16:37:17 2009 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Thu May 14 16:24:01 2009 Subject: [Haskell-cafe] looking for suggestion on pattern matching problem Message-ID: I am trying to analyze a list of items (say integers) for longest matches on patterns and their location on the list. One catch is that pattern may be defined in terms of other patterns. Example of patterns would be the any sequence of increasing numbers, or sequence of increasing numbers followed by upto 5 zeros then followed by any odd digits. I don't know much about the actual patterns, but would like to be able to define EDSL for composing the patterns and an execution environment to actually find the patterns. I like to find out various ways I can structure the problem and its trade offs. I appreciate any books, articles, suggestions, papers, etc on this type of problems. Thanks, Daryoush -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090514/b6ae3d9c/attachment.html From vigalchin at gmail.com Thu May 14 16:51:16 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Thu May 14 16:37:02 2009 Subject: [Haskell-cafe] "hiddenness" Message-ID: <5ae4f2ba0905141351t5569871drbc6624d203a322ad@mail.gmail.com> Hello, When I am compiling a module, I get "Could not find module 'Control.Module.State': it is a member of package mtl-1.1.0.2, which is hidden" 1) What is the efficacy of "hiddenness"? 2) I have forgotten what tool I run to expose a package. ?? 3) In another vein, the code is using Data.Finitemap ... so I guess I must "darcs" install this? Regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090514/778aade3/attachment.html From max.rabkin at gmail.com Thu May 14 16:56:20 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Thu May 14 16:42:09 2009 Subject: [Haskell-cafe] "hiddenness" In-Reply-To: <5ae4f2ba0905141351t5569871drbc6624d203a322ad@mail.gmail.com> References: <5ae4f2ba0905141351t5569871drbc6624d203a322ad@mail.gmail.com> Message-ID: On Thu, May 14, 2009 at 10:51 PM, Vasili I. Galchin wrote: > Hello, > > ???? When I am compiling a module, I get "Could not find module > 'Control.Module.State': > ????????????????????????????????????????????????????????????????? it is a > member of package mtl-1.1.0.2, which is hidden" > > ???? 1) What is the efficacy of "hiddenness"? As I understand it, the purpose is two-fold. Firstly, if you have multiple versions a package (or multiple packages containing the same module), you can hide the ones not in use. Second, it ensures you have declared all dependencies. > ???? 2) I have forgotten what tool I run to expose a package. ?? I've only ever had this when working with Cabal, where I have missed a dependency. In this case, it looks like you have an undeclared dependency on mtl. I'm not sure whether this arises in the non-Cabal case. > ???? 3) In another vein, the code is using Data.Finitemap ... so I guess I > must "darcs" install this? I believe it was just uploaded to Hackage (it's obsolete, but useful for getting old code to run). HTH, Max From vigalchin at gmail.com Thu May 14 17:04:23 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Thu May 14 16:49:56 2009 Subject: [Haskell-cafe] "hiddenness" In-Reply-To: References: <5ae4f2ba0905141351t5569871drbc6624d203a322ad@mail.gmail.com> Message-ID: <5ae4f2ba0905141404o14656206n7ff1e244200c1614@mail.gmail.com> oh ... yes .. my .cabal file is incomplete! Thanks, Max. Vasili On Thu, May 14, 2009 at 3:56 PM, Max Rabkin wrote: > On Thu, May 14, 2009 at 10:51 PM, Vasili I. Galchin > wrote: > > Hello, > > > > When I am compiling a module, I get "Could not find module > > 'Control.Module.State': > > it is a > > member of package mtl-1.1.0.2, which is hidden" > > > > 1) What is the efficacy of "hiddenness"? > > As I understand it, the purpose is two-fold. Firstly, if you have > multiple versions a package (or multiple packages containing the same > module), you can hide the ones not in use. Second, it ensures you have > declared all dependencies. > > > 2) I have forgotten what tool I run to expose a package. ?? > > I've only ever had this when working with Cabal, where I have missed a > dependency. In this case, it looks like you have an undeclared > dependency on mtl. I'm not sure whether this arises in the non-Cabal > case. > > > 3) In another vein, the code is using Data.Finitemap ... so I guess > I > > must "darcs" install this? > > I believe it was just uploaded to Hackage (it's obsolete, but useful > for getting old code to run). > > HTH, > Max > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090514/449a3403/attachment.html From paul at cogito.org.uk Thu May 14 17:16:49 2009 From: paul at cogito.org.uk (Paul Johnson) Date: Thu May 14 17:02:08 2009 Subject: [Haskell-cafe] looking for suggestion on pattern matching problem In-Reply-To: References: Message-ID: <4A0C8A41.7020800@cogito.org.uk> Sounds like you need regular expressions applied to the string representation, although the "sequence of increasing numbers" is not something any of the standard regexp packages do. So you will have to roll your own. Alternatively you could use one of the parsing libraries to "parse" the string and define "sequence of increasing numbers" using a stateful parser. Paul. Daryoush Mehrtash wrote: > I am trying to analyze a list of items (say integers) for longest > matches on patterns and their location on the list. One catch is that > pattern may be defined in terms of other patterns. Example of > patterns would be the any sequence of increasing numbers, or sequence > of increasing numbers followed by upto 5 zeros then followed by any > odd digits. > > I don't know much about the actual patterns, but would like to be able > to define EDSL for composing the patterns and an execution environment > to actually find the patterns. > > I like to find out various ways I can structure the problem and its > trade offs. I appreciate any books, articles, suggestions, papers, > etc on this type of problems. > > Thanks, > > Daryoush > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From byorgey at seas.upenn.edu Thu May 14 17:31:15 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Thu May 14 17:16:16 2009 Subject: [Haskell-cafe] Pretty printing a tree In-Reply-To: <416a2ab0905141158y235b2ae2ha37ee4c5ec3c51d@mail.gmail.com> References: <416a2ab0905141158y235b2ae2ha37ee4c5ec3c51d@mail.gmail.com> Message-ID: <20090514213115.GB22067@seas.upenn.edu> On Thu, May 14, 2009 at 03:58:18PM -0300, Jos? Romildo Malaquias wrote: > > Then the resulting of pretty printing the given tree would be something > like the following: > > a > | > +-------------+ > | | | > b c d > | | > +---+ +---+ > | | | | > c1 c2 d1 d2 > | > d1a > > There is the module Text.PrettyPrint.HughesPJ, but it lacks examples on > how to use the pretty print combinators, and it is not well docomented. Text.PrettyPrint.HughesPJ is actually not a good tool for this, since it is for pretty-printing line-oriented material (i.e. source code). I actually have a library I was developing a while ago to do the sort of pretty-printing/layout of text that you're looking for, using a box model similar to that of TeX, but I never released it. Hopefully I'll get around to polishing and releasing it this summer. -Brent From lane at downstairspeople.org Thu May 14 17:43:08 2009 From: lane at downstairspeople.org (Christopher Lane Hinson) Date: Thu May 14 17:28:09 2009 Subject: [Haskell-cafe] looking for suggestion on pattern matching problem In-Reply-To: References: Message-ID: Parsec 3 should be able to handle this pretty easily. It can parse any data structure that implements it's Stream class. Friendly, --Lane On Thu, 14 May 2009, Daryoush Mehrtash wrote: > I am trying to analyze a list of items (say integers) for longest matches on patterns and their location on the list.? One catch is that pattern may be defined in terms of other > patterns.?? ? Example of patterns would be the any sequence of increasing numbers, or sequence of increasing numbers followed by upto 5 zeros then followed by any odd digits. ? > > I don't know much about the actual patterns, but would like to be able to define EDSL for composing the patterns and an execution environment to actually find the patterns. > > I like to find out various ways I can structure the problem and its trade offs.? I appreciate any? books, articles, suggestions, papers, etc on this type of problems. > > Thanks, > > Daryoush > > From leimy2k at gmail.com Thu May 14 22:52:29 2009 From: leimy2k at gmail.com (David Leimbach) Date: Thu May 14 22:39:40 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding Message-ID: <3e1162e60905141952x2a58fa43oe27ee43e7bc66e69@mail.gmail.com> I actually need little endian encoding... wondering if anyone else hit this with Data.Binary. (because I'm working with Bell Lab's 9P protocol which does encode things on the network in little-endian order). Anyone got some "tricks" for this? Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090514/8fcf836e/attachment.html From dons at galois.com Thu May 14 23:40:17 2009 From: dons at galois.com (Don Stewart) Date: Thu May 14 23:27:33 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding In-Reply-To: <3e1162e60905141952x2a58fa43oe27ee43e7bc66e69@mail.gmail.com> References: <3e1162e60905141952x2a58fa43oe27ee43e7bc66e69@mail.gmail.com> Message-ID: <20090515034017.GD31768@whirlpool.galois.com> leimy2k: > I actually need little endian encoding... wondering if anyone else hit this > with Data.Binary. (because I'm working with Bell Lab's 9P protocol which does > encode things on the network in little-endian order). > > Anyone got some "tricks" for this? Yes! There are big, little and host-endian primitives in the Get/Put monads. http://hackage.haskell.org/packages/archive/binary/0.5.0.1/doc/html/Data-Binary-Put.html#v%3AputWord16le You can use these to build encoders directly. Cheers, Don From leimy2k at gmail.com Thu May 14 23:46:10 2009 From: leimy2k at gmail.com (David Leimbach) Date: Thu May 14 23:31:33 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding In-Reply-To: <20090515034017.GD31768@whirlpool.galois.com> References: <3e1162e60905141952x2a58fa43oe27ee43e7bc66e69@mail.gmail.com> <20090515034017.GD31768@whirlpool.galois.com> Message-ID: <3e1162e60905142046y78d8d4a4je8b1b9b75eb55099@mail.gmail.com> On Thu, May 14, 2009 at 8:40 PM, Don Stewart wrote: > leimy2k: > > I actually need little endian encoding... wondering if anyone else hit > this > > with Data.Binary. (because I'm working with Bell Lab's 9P protocol which > does > > encode things on the network in little-endian order). > > > > Anyone got some "tricks" for this? > > Yes! > There are big, little and host-endian primitives in the Get/Put monads. > > > http://hackage.haskell.org/packages/archive/binary/0.5.0.1/doc/html/Data-Binary-Put.html#v%3AputWord16le > > You can use these to build encoders directly. Cool... I just have to write my own encoder and decoder now. As a request could we get encodeLe decodeLe for a later version of this library? :-) That'd be totally awesome. > > > Cheers, > Don > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090514/ff04e606/attachment.html From dons at galois.com Thu May 14 23:46:10 2009 From: dons at galois.com (Don Stewart) Date: Thu May 14 23:32:31 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding In-Reply-To: <3e1162e60905142046y78d8d4a4je8b1b9b75eb55099@mail.gmail.com> References: <3e1162e60905141952x2a58fa43oe27ee43e7bc66e69@mail.gmail.com> <20090515034017.GD31768@whirlpool.galois.com> <3e1162e60905142046y78d8d4a4je8b1b9b75eb55099@mail.gmail.com> Message-ID: <20090515034610.GE31768@whirlpool.galois.com> leimy2k: > > > On Thu, May 14, 2009 at 8:40 PM, Don Stewart wrote: > > leimy2k: > > I actually need little endian encoding... wondering if anyone else hit > this > > with Data.Binary. (because I'm working with Bell Lab's 9P protocol which > does > > encode things on the network in little-endian order). > > > > Anyone got some "tricks" for this? > > Yes! > There are big, little and host-endian primitives in the Get/Put monads. > > http://hackage.haskell.org/packages/archive/binary/0.5.0.1/doc/html/ > Data-Binary-Put.html#v%3AputWord16le > > You can use these to build encoders directly. > > > Cool... I just have to write my own encoder and decoder now. > > As a request could we get encodeLe decodeLe for a later version of this > library? :-) That'd be totally awesome. Oh, you mean entirely different instances for all the current ones, that use LE encodings? -- Don From leimy2k at gmail.com Thu May 14 23:51:46 2009 From: leimy2k at gmail.com (David Leimbach) Date: Thu May 14 23:36:43 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding In-Reply-To: <20090515034610.GE31768@whirlpool.galois.com> References: <3e1162e60905141952x2a58fa43oe27ee43e7bc66e69@mail.gmail.com> <20090515034017.GD31768@whirlpool.galois.com> <3e1162e60905142046y78d8d4a4je8b1b9b75eb55099@mail.gmail.com> <20090515034610.GE31768@whirlpool.galois.com> Message-ID: <3e1162e60905142051l5b285bb7p2ffe2fc3ded51e39@mail.gmail.com> On Thu, May 14, 2009 at 8:46 PM, Don Stewart wrote: > leimy2k: > > > > > > On Thu, May 14, 2009 at 8:40 PM, Don Stewart wrote: > > > > leimy2k: > > > I actually need little endian encoding... wondering if anyone else > hit > > this > > > with Data.Binary. (because I'm working with Bell Lab's 9P protocol > which > > does > > > encode things on the network in little-endian order). > > > > > > Anyone got some "tricks" for this? > > > > Yes! > > There are big, little and host-endian primitives in the Get/Put > monads. > > > > > http://hackage.haskell.org/packages/archive/binary/0.5.0.1/doc/html/ > > Data-Binary-Put.html#v%3AputWord16le > > > > You can use these to build encoders directly. > > > > > > Cool... I just have to write my own encoder and decoder now. > > > > As a request could we get encodeLe decodeLe for a later version of this > > library? :-) That'd be totally awesome. > > Oh, you mean entirely different instances for all the current ones, that > use LE encodings? > Well the library is leaning towards "Network Byte Order" in that it has encode/decode that only encode/decode for Big Endian. Us folks who have to do little endian all now have to write our own encoding/decoding :-) I'm speaking specifically of the encode/decode functions. I have no idea how they're implemented. Are you saying that encode is doing something really simple and the default encodings for things just happen to be big endian? If so, then I understand the pain.... but it still means I have to roll my own :-) I guess if one must choose, big endian kind of makes sense, except that the whole world is little endian now, except for networks :-) (No one *really* cares about anything but x86 anyway these days right?) I'm only half-kidding. > > -- Don > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090514/51448033/attachment-0001.html From dons at galois.com Thu May 14 23:54:37 2009 From: dons at galois.com (Don Stewart) Date: Thu May 14 23:41:00 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding In-Reply-To: <3e1162e60905142051l5b285bb7p2ffe2fc3ded51e39@mail.gmail.com> References: <3e1162e60905141952x2a58fa43oe27ee43e7bc66e69@mail.gmail.com> <20090515034017.GD31768@whirlpool.galois.com> <3e1162e60905142046y78d8d4a4je8b1b9b75eb55099@mail.gmail.com> <20090515034610.GE31768@whirlpool.galois.com> <3e1162e60905142051l5b285bb7p2ffe2fc3ded51e39@mail.gmail.com> Message-ID: <20090515035437.GF31768@whirlpool.galois.com> > I'm speaking specifically of the encode/decode functions. I have no idea how > they're implemented. > > Are you saying that encode is doing something really simple and the default > encodings for things just happen to be big endian? If so, then I understand > the pain.... but it still means I have to roll my own :-) I guess if one must > choose, big endian kind of makes sense, except that the whole world is little > endian now, except for networks :-) (No one *really* cares about anything but > x86 anyway these days right?) Oh, 'encode' has type: encode :: Binary a => a -> ByteString it just encodes with the default instances, which are all network order: http://en.wikipedia.org/wiki/Endianness#Endianness_in_networking -- Don From leimy2k at gmail.com Thu May 14 23:57:37 2009 From: leimy2k at gmail.com (David Leimbach) Date: Thu May 14 23:44:42 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding In-Reply-To: <20090515035437.GF31768@whirlpool.galois.com> References: <3e1162e60905141952x2a58fa43oe27ee43e7bc66e69@mail.gmail.com> <20090515034017.GD31768@whirlpool.galois.com> <3e1162e60905142046y78d8d4a4je8b1b9b75eb55099@mail.gmail.com> <20090515034610.GE31768@whirlpool.galois.com> <3e1162e60905142051l5b285bb7p2ffe2fc3ded51e39@mail.gmail.com> <20090515035437.GF31768@whirlpool.galois.com> Message-ID: <3e1162e60905142057u51f31009id58c981795c9d99f@mail.gmail.com> On Thu, May 14, 2009 at 8:54 PM, Don Stewart wrote: > > I'm speaking specifically of the encode/decode functions. I have no idea > how > > they're implemented. > > > > Are you saying that encode is doing something really simple and the > default > > encodings for things just happen to be big endian? If so, then I > understand > > the pain.... but it still means I have to roll my own :-) I guess if one > must > > choose, big endian kind of makes sense, except that the whole world is > little > > endian now, except for networks :-) (No one *really* cares about > anything but > > x86 anyway these days right?) > > Oh, 'encode' has type: > > encode :: Binary a => a -> ByteString > > it just encodes with the default instances, which are all network order: > > http://en.wikipedia.org/wiki/Endianness#Endianness_in_networking > Yeah I understand that Big Endian == Network Byte Order... which would be true, if I wasn't talking about Plan 9's 9P protocol which specifies little endian bytes on the wire (as far as I can tell anyway from the man page). Dave > > -- Don > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090514/307595fb/attachment.html From leimy2k at gmail.com Thu May 14 23:57:37 2009 From: leimy2k at gmail.com (David Leimbach) Date: Thu May 14 23:51:50 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding In-Reply-To: <20090515035437.GF31768@whirlpool.galois.com> References: <3e1162e60905141952x2a58fa43oe27ee43e7bc66e69@mail.gmail.com> <20090515034017.GD31768@whirlpool.galois.com> <3e1162e60905142046y78d8d4a4je8b1b9b75eb55099@mail.gmail.com> <20090515034610.GE31768@whirlpool.galois.com> <3e1162e60905142051l5b285bb7p2ffe2fc3ded51e39@mail.gmail.com> <20090515035437.GF31768@whirlpool.galois.com> Message-ID: <3e1162e60905142057u51f31009id58c981795c9d99f@mail.gmail.com> On Thu, May 14, 2009 at 8:54 PM, Don Stewart wrote: > > I'm speaking specifically of the encode/decode functions. I have no idea > how > > they're implemented. > > > > Are you saying that encode is doing something really simple and the > default > > encodings for things just happen to be big endian? If so, then I > understand > > the pain.... but it still means I have to roll my own :-) I guess if one > must > > choose, big endian kind of makes sense, except that the whole world is > little > > endian now, except for networks :-) (No one *really* cares about > anything but > > x86 anyway these days right?) > > Oh, 'encode' has type: > > encode :: Binary a => a -> ByteString > > it just encodes with the default instances, which are all network order: > > http://en.wikipedia.org/wiki/Endianness#Endianness_in_networking > Yeah I understand that Big Endian == Network Byte Order... which would be true, if I wasn't talking about Plan 9's 9P protocol which specifies little endian bytes on the wire (as far as I can tell anyway from the man page). Dave > > -- Don > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090514/307595fb/attachment-0001.html From leimy2k at gmail.com Fri May 15 00:10:38 2009 From: leimy2k at gmail.com (David Leimbach) Date: Thu May 14 23:55:36 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding In-Reply-To: <3e1162e60905142057u51f31009id58c981795c9d99f@mail.gmail.com> References: <3e1162e60905141952x2a58fa43oe27ee43e7bc66e69@mail.gmail.com> <20090515034017.GD31768@whirlpool.galois.com> <3e1162e60905142046y78d8d4a4je8b1b9b75eb55099@mail.gmail.com> <20090515034610.GE31768@whirlpool.galois.com> <3e1162e60905142051l5b285bb7p2ffe2fc3ded51e39@mail.gmail.com> <20090515035437.GF31768@whirlpool.galois.com> <3e1162e60905142057u51f31009id58c981795c9d99f@mail.gmail.com> Message-ID: <3e1162e60905142110k7d83d71an58a71f5ab14eab6e@mail.gmail.com> On Thu, May 14, 2009 at 8:57 PM, David Leimbach wrote: > > > On Thu, May 14, 2009 at 8:54 PM, Don Stewart wrote: > >> > I'm speaking specifically of the encode/decode functions. I have no >> idea how >> > they're implemented. >> > >> > Are you saying that encode is doing something really simple and the >> default >> > encodings for things just happen to be big endian? If so, then I >> understand >> > the pain.... but it still means I have to roll my own :-) I guess if >> one must >> > choose, big endian kind of makes sense, except that the whole world is >> little >> > endian now, except for networks :-) (No one *really* cares about >> anything but >> > x86 anyway these days right?) >> >> Oh, 'encode' has type: >> >> encode :: Binary a => a -> ByteString >> >> it just encodes with the default instances, which are all network order: >> >> http://en.wikipedia.org/wiki/Endianness#Endianness_in_networking >> > > Yeah I understand that Big Endian == Network Byte Order... which would be > true, if I wasn't talking about Plan 9's 9P protocol which specifies little > endian bytes on the wire (as far as I can tell anyway from the man page). > > Dave > FYI here's what I've ended up trying to write to negotiate the "version" of a 9p server: main = withSocketsDo $ do ainfo <- getAddrInfo Nothing (Just "127.0.0.1") (Just "6872") -- hardcoded for now, it's an IRC filesystem server let a = head ainfo sock <- socket AF_INET Stream defaultProtocol connect sock (addrAddress a) sendAll sock $ (toLazyByteString (putWord32le (fromIntegral (16 ::Int32)))) sendAll sock $ (encode (100 ::Int8)) sendAll sock $ (toLazyByteString (putWord32le (fromIntegral (1024 ::Int32)))) sendAll sock $ (encode (C.pack "9P2000")) I feel like I should use wireshark or something to watch the bytes :-) I'm not feeling very sure about this. > >> >> -- Don >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090514/6ea7f271/attachment.html From leimy2k at gmail.com Thu May 14 23:57:37 2009 From: leimy2k at gmail.com (David Leimbach) Date: Fri May 15 00:07:48 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding In-Reply-To: <20090515035437.GF31768@whirlpool.galois.com> References: <3e1162e60905141952x2a58fa43oe27ee43e7bc66e69@mail.gmail.com> <20090515034017.GD31768@whirlpool.galois.com> <3e1162e60905142046y78d8d4a4je8b1b9b75eb55099@mail.gmail.com> <20090515034610.GE31768@whirlpool.galois.com> <3e1162e60905142051l5b285bb7p2ffe2fc3ded51e39@mail.gmail.com> <20090515035437.GF31768@whirlpool.galois.com> Message-ID: <3e1162e60905142057u51f31009id58c981795c9d99f@mail.gmail.com> On Thu, May 14, 2009 at 8:54 PM, Don Stewart wrote: > > I'm speaking specifically of the encode/decode functions. I have no idea > how > > they're implemented. > > > > Are you saying that encode is doing something really simple and the > default > > encodings for things just happen to be big endian? If so, then I > understand > > the pain.... but it still means I have to roll my own :-) I guess if one > must > > choose, big endian kind of makes sense, except that the whole world is > little > > endian now, except for networks :-) (No one *really* cares about > anything but > > x86 anyway these days right?) > > Oh, 'encode' has type: > > encode :: Binary a => a -> ByteString > > it just encodes with the default instances, which are all network order: > > http://en.wikipedia.org/wiki/Endianness#Endianness_in_networking > Yeah I understand that Big Endian == Network Byte Order... which would be true, if I wasn't talking about Plan 9's 9P protocol which specifies little endian bytes on the wire (as far as I can tell anyway from the man page). Dave > > -- Don > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090515/307595fb/attachment.html From leimy2k at gmail.com Fri May 15 00:18:03 2009 From: leimy2k at gmail.com (David Leimbach) Date: Fri May 15 00:10:09 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding In-Reply-To: <3e1162e60905142110k7d83d71an58a71f5ab14eab6e@mail.gmail.com> References: <3e1162e60905141952x2a58fa43oe27ee43e7bc66e69@mail.gmail.com> <20090515034017.GD31768@whirlpool.galois.com> <3e1162e60905142046y78d8d4a4je8b1b9b75eb55099@mail.gmail.com> <20090515034610.GE31768@whirlpool.galois.com> <3e1162e60905142051l5b285bb7p2ffe2fc3ded51e39@mail.gmail.com> <20090515035437.GF31768@whirlpool.galois.com> <3e1162e60905142057u51f31009id58c981795c9d99f@mail.gmail.com> <3e1162e60905142110k7d83d71an58a71f5ab14eab6e@mail.gmail.com> Message-ID: <3e1162e60905142118x3216f6b9g8a09e102192b853@mail.gmail.com> On Thu, May 14, 2009 at 9:10 PM, David Leimbach wrote: > > > On Thu, May 14, 2009 at 8:57 PM, David Leimbach wrote: > >> >> >> On Thu, May 14, 2009 at 8:54 PM, Don Stewart wrote: >> >>> > I'm speaking specifically of the encode/decode functions. I have no >>> idea how >>> > they're implemented. >>> > >>> > Are you saying that encode is doing something really simple and the >>> default >>> > encodings for things just happen to be big endian? If so, then I >>> understand >>> > the pain.... but it still means I have to roll my own :-) I guess if >>> one must >>> > choose, big endian kind of makes sense, except that the whole world is >>> little >>> > endian now, except for networks :-) (No one *really* cares about >>> anything but >>> > x86 anyway these days right?) >>> >>> Oh, 'encode' has type: >>> >>> encode :: Binary a => a -> ByteString >>> >>> it just encodes with the default instances, which are all network order: >>> >>> http://en.wikipedia.org/wiki/Endianness#Endianness_in_networking >>> >> >> Yeah I understand that Big Endian == Network Byte Order... which would be >> true, if I wasn't talking about Plan 9's 9P protocol which specifies little >> endian bytes on the wire (as far as I can tell anyway from the man page). >> >> Dave >> > > FYI here's what I've ended up trying to write to negotiate the "version" of > a 9p server: > > main = withSocketsDo $ > do > ainfo <- getAddrInfo Nothing (Just "127.0.0.1") (Just "6872") -- > hardcoded for now, it's an IRC filesystem server > let a = head ainfo > sock <- socket AF_INET Stream defaultProtocol > connect sock (addrAddress a) > sendAll sock $ (toLazyByteString (putWord32le (fromIntegral (16 > ::Int32)))) > sendAll sock $ (encode (100 ::Int8)) > sendAll sock $ (toLazyByteString (putWord32le (fromIntegral (1024 > ::Int32)))) > sendAll sock $ (encode (C.pack "9P2000")) > > I totally forgot the tag part of 9p.... ugh. I think I should probably just go to bed now. > > I feel like I should use wireshark or something to watch the bytes :-) I'm > not feeling very sure about this. > > >> >>> >>> -- Don >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090515/dc6e8a82/attachment.html From timd at macquarie.com.au Fri May 15 00:30:14 2009 From: timd at macquarie.com.au (Tim Docker) Date: Fri May 15 00:15:13 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding In-Reply-To: <3e1162e60905142057u51f31009id58c981795c9d99f@mail.gmail.com> References: <3e1162e60905141952x2a58fa43oe27ee43e7bc66e69@mail.gmail.com><20090515034017.GD31768@whirlpool.galois.com><3e1162e60905142046y78d8d4a4je8b1b9b75eb55099@mail.gmail.com><20090515034610.GE31768@whirlpool.galois.com><3e1162e60905142051l5b285bb7p2ffe2fc3ded51e39@mail.gmail.com><20090515035437.GF31768@whirlpool.galois.com> <3e1162e60905142057u51f31009id58c981795c9d99f@mail.gmail.com> Message-ID: <7CA1B7BF2916F0418CAB6E705BC1224A375341@ntsydexm04.pc.internal.macquarie.com> On a related matter, I am using Data.Binary to serialise data from haskell for use from other languages. The Data.Binary encoding of a Double is a long integer for the mantissa, and an int for the exponent. This doesn't work too well for interacting with other languages as I'd need to have an arbitrary precision int type there to decode/encode. The CORBA CDR standard encodes doubles in a big ended fashion like this (excuse my possibly incorrect ascii art): | byte | msb lsb | |------+---------------------------| | 0 | S E6 E0 | | 1 | E10 E9 E8 E7 F3 F2 F1 F0 | | 2 | F11 F4 | | 3 | F19 F12 | | 4 | F27 F20 | | 5 | F35 F28 | | 6 | F43 F36 | | 7 | F51 F44 | Up until now, my code is pure haskell. Is it possible to get at the internal bits of a Double/CDouble in ghc? Or Should I use the FFI and write C to encode something like the above? Tim ________________________________ From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of David Leimbach Sent: Friday, 15 May 2009 1:58 PM To: Don Stewart Cc: Haskell Cafe Subject: Re: [Haskell-cafe] Data.Binary and little endian encoding On Thu, May 14, 2009 at 8:54 PM, Don Stewart wrote: > I'm speaking specifically of the encode/decode functions. I have no idea how > they're implemented. > > Are you saying that encode is doing something really simple and the default > encodings for things just happen to be big endian? If so, then I understand > the pain.... but it still means I have to roll my own :-) I guess if one must > choose, big endian kind of makes sense, except that the whole world is little > endian now, except for networks :-) (No one *really* cares about anything but > x86 anyway these days right?) Oh, 'encode' has type: encode :: Binary a => a -> ByteString it just encodes with the default instances, which are all network order: http://en.wikipedia.org/wiki/Endianness#Endianness_in_networking Yeah I understand that Big Endian == Network Byte Order... which would be true, if I wasn't talking about Plan 9's 9P protocol which specifies little endian bytes on the wire (as far as I can tell anyway from the man page). Dave -- Don From vigalchin at gmail.com Fri May 15 00:30:56 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Fri May 15 00:21:44 2009 Subject: [Haskell-cafe] I have forgotten .. my bad Message-ID: <5ae4f2ba0905142130g6a142743wc794a278ad3f2fe5@mail.gmail.com> Hello, darcs get --init ....?????? I want to pull down Data.FiniteMap. I have forgotten the path to Hackage .. I tried .... sudo darcs get http://hackage.haskell.org/ Data.FiniteMap [sudo] password for vigalchin: Invalid repository: http://hackage.haskell.org darcs failed: Failed to download URL http://hackage.haskell.org/_darcs/inventory : HTTP error (404?) ?? Obviously the code I am cabalizing needs to be "upgraded"(i.e. not using deprecated packages) but first I want it to build! Thanks, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090515/f76c025a/attachment.html From dons at galois.com Fri May 15 00:37:22 2009 From: dons at galois.com (Don Stewart) Date: Fri May 15 00:23:43 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding In-Reply-To: <7CA1B7BF2916F0418CAB6E705BC1224A375341@ntsydexm04.pc.internal.macquarie.com> References: <3e1162e60905142057u51f31009id58c981795c9d99f@mail.gmail.com> <7CA1B7BF2916F0418CAB6E705BC1224A375341@ntsydexm04.pc.internal.macquarie.com> Message-ID: <20090515043722.GG31768@whirlpool.galois.com> timd: > On a related matter, I am using Data.Binary to serialise data from > haskell > for use from other languages. The Data.Binary encoding of a Double is a > long > integer for the mantissa, and an int for the exponent. This doesn't > work too well for interacting with other languages as I'd need to have > an arbitrary precision int type there to decode/encode. The CORBA CDR > standard encodes doubles in a big ended fashion like this (excuse my > possibly incorrect ascii art): > > > | byte | msb lsb | > |------+---------------------------| > | 0 | S E6 E0 | > | 1 | E10 E9 E8 E7 F3 F2 F1 F0 | > | 2 | F11 F4 | > | 3 | F19 F12 | > | 4 | F27 F20 | > | 5 | F35 F28 | > | 6 | F43 F36 | > | 7 | F51 F44 | > > Up until now, my code is pure haskell. Is it possible to get at the > internal bits of a Double/CDouble in ghc? Or Should I use the FFI and > write C to encode something like the above? Yep, it's possible, just not portably so. Google for Data.Binary IEEE discussions. From martin.hofmann at uni-bamberg.de Fri May 15 04:09:09 2009 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Fri May 15 03:53:22 2009 Subject: [Haskell-cafe] conflicting variable definitions in pattern Message-ID: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> It is pretty clear, that the following is not a valid Haskell pattern: foo (x:x:xs) = x:xs My questions is _why_ this is not allowed. IMHO, the semantics should be clear: The pattern is expected to succeed, iff 'x' is each time bound to the same term. Isn't this allowed, because this would require a strict evaluation of the 'x' variables? Thanks, Martin From miguelimo38 at yandex.ru Fri May 15 04:09:34 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Fri May 15 03:55:19 2009 Subject: [Haskell-cafe] conflicting variable definitions in pattern In-Reply-To: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> References: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <4A0D233E.4090202@yandex.ru> What would you expect foo [id, \x -> x] to be? Martin Hofmann wrote on 15.05.2009 12:09: > It is pretty clear, that the following is not a valid Haskell pattern: > > foo (x:x:xs) = x:xs > > My questions is _why_ this is not allowed. IMHO, the semantics should be > clear: The pattern is expected to succeed, iff 'x' is each time bound to > the same term. > > Isn't this allowed, because this would require a strict evaluation of > the 'x' variables? > > Thanks, > > Martin > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From voigt at tcs.inf.tu-dresden.de Fri May 15 04:10:53 2009 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Fri May 15 03:55:58 2009 Subject: [Haskell-cafe] conflicting variable definitions in pattern In-Reply-To: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> References: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <4A0D238D.9080903@tcs.inf.tu-dresden.de> Martin Hofmann wrote: > It is pretty clear, that the following is not a valid Haskell pattern: > > foo (x:x:xs) = x:xs > > My questions is _why_ this is not allowed. IMHO, the semantics should be > clear: The pattern is expected to succeed, iff 'x' is each time bound to > the same term. > > Isn't this allowed, because this would require a strict evaluation of > the 'x' variables? One reason is: What if the list were a list of functions? How would you decide "sameness" of lambda-terms? By investigating their in-memory representations? By trying to prove that they denote the same mathematical function? Ciao, Janis. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From ganesh.sittampalam at credit-suisse.com Fri May 15 04:11:18 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Fri May 15 04:03:08 2009 Subject: [Haskell-cafe] conflicting variable definitions in pattern In-Reply-To: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> References: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B01ABAB23@ELON17P32001A.csfb.cs-group.com> Martin Hofmann wrote: > It is pretty clear, that the following is not a valid Haskell pattern: > > foo (x:x:xs) = x:xs > > My questions is _why_ this is not allowed. IMHO, the semantics should > be > clear: The pattern is expected to succeed, iff 'x' is each time bound > to the same term. How do you define the "same term"? One natural way of compiling it would be to foo (x:y:xs) | x == y = x:xs but then pattern matching can introduce Eq constraints which some might see as a bit odd. > Isn't this allowed, because this would require a strict evaluation of > the 'x' variables? The translation into == would probably introduce some strictness, for most implementations of Eq. I don't think this is a huge problem in itself. Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From slucas at dsic.upv.es Fri May 15 04:17:49 2009 From: slucas at dsic.upv.es (Salvador Lucas) Date: Fri May 15 04:06:41 2009 Subject: [Haskell-cafe] conflicting variable definitions in pattern In-Reply-To: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> References: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <4A0D252D.30000@dsic.upv.es> Dear Martin, I think that the (practical) reason is avoiding equality checks during pattern matching. For instance, how do you evaluate this: foo ((+1):(1+):[]) ? Both expressions in the first and second entries of the list are semantically equivalent, but from an operational point of view, you have to ensure the equality of two functions over an infinite domain (of integer numbers). Best regards, Salvador. Martin Hofmann escribi?: > It is pretty clear, that the following is not a valid Haskell pattern: > > foo (x:x:xs) = x:xs > > My questions is _why_ this is not allowed. IMHO, the semantics should be > clear: The pattern is expected to succeed, iff 'x' is each time bound to > the same term. > > Isn't this allowed, because this would require a strict evaluation of > the 'x' variables? > > Thanks, > > Martin > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From wren at freegeek.org Fri May 15 04:33:52 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri May 15 04:19:52 2009 Subject: [Haskell-cafe] Pretty printing a tree In-Reply-To: <416a2ab0905141158y235b2ae2ha37ee4c5ec3c51d@mail.gmail.com> References: <416a2ab0905141158y235b2ae2ha37ee4c5ec3c51d@mail.gmail.com> Message-ID: <4A0D28F0.60609@freegeek.org> Jos? Romildo Malaquias wrote: > Hello. > > I would like to pretty print a tree in a way that its structure is > easily perceived. > > For instance, consider the declarations: > > data Node a = Node a [Node a] > > type Tree a = [ Node a ] > > t = [ Node "a" [ Node "b" [] > , Node "c" [ Node "c1" [] > , Node "c2" [] ] > , Node "d" [ Node "d1" [ Node "d1a" [] ] > , Node "d2" [] ] ] ] > > Then the resulting of pretty printing the given tree would be something > like the following: > > a > | > +-------------+ > | | | > b c d > | | > +---+ +---+ > | | | | > c1 c2 d1 d2 > | > d1a If you're just curious about how one would write such a thing, you can look at Data.Trie.Internal.showTrie[1]--- it's horizontal rather than vertical, and it doesn't center labels above their children, but it should give you a starting idea. Data.Map and Data.IntMap also have examples (showTree, showTreeWith) which are a bit simpler. This is a common homework assignment (because it's a great exercise!) though I haven't seen any prepackaged generic solutions. Perhaps we need more enterprising students :) [1] http://community.haskell.org/~wren/bytestring-trie/src/Data/Trie/Internal.hs -- Live well, ~wren From ekirpichov at gmail.com Fri May 15 04:34:21 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Fri May 15 04:20:02 2009 Subject: [Haskell-cafe] conflicting variable definitions in pattern In-Reply-To: <4A0D252D.30000@dsic.upv.es> References: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> <4A0D252D.30000@dsic.upv.es> Message-ID: <5e0214850905150134j596b3526r2a0cd8cec0f7b2da@mail.gmail.com> Why, then, not permit such definitions only for members of Eq? My thoughts: - because it will break an important invariant indicated by Martin, namely the one that says that pattern variables are not forced - it will make efficient compilation of pattern matching much harder - it will make the termination behavior of pattern matching dependent not only on the term being matched, but also on how Eq is implemented for that type - it will make the very rules of evaluation for pattern matching much more complex, fragile and hard to understand: in what order should the equated parts be evaluated? That influences termination behavior, so it is important. In what order should equality comparisons be performed in f (Node a (Leaf b a) (Node a))) = b ? 2009/5/15 Salvador Lucas : > Dear Martin, > > I think that the (practical) reason is avoiding equality checks during > pattern matching. > > For instance, how do you evaluate this: > > ?foo ((+1):(1+):[]) ? ?? > > Both expressions in the first and second entries of the list are > semantically equivalent, > but from an operational point of view, you have to ensure the equality of > two functions > over an infinite domain (of integer numbers). > > Best regards, > > Salvador. > > > Martin Hofmann escribi?: >> >> It is pretty clear, that the following is not a valid Haskell pattern: >> >> foo (x:x:xs) = x:xs >> >> My questions is _why_ this is not allowed. IMHO, the semantics should be >> clear: The pattern is expected to succeed, iff 'x' is each time bound to >> the same term. >> Isn't this allowed, because this would require a strict evaluation of >> the 'x' variables? >> >> Thanks, >> >> Martin >> >> _______________________________________________ >> 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 ithika at gmail.com Fri May 15 04:54:56 2009 From: ithika at gmail.com (Dougal Stanton) Date: Fri May 15 04:40:34 2009 Subject: [Haskell-cafe] I have forgotten .. my bad In-Reply-To: <5ae4f2ba0905142130g6a142743wc794a278ad3f2fe5@mail.gmail.com> References: <5ae4f2ba0905142130g6a142743wc794a278ad3f2fe5@mail.gmail.com> Message-ID: <2d3641330905150154p4c186be8yfc30311511fe9250@mail.gmail.com> On Fri, May 15, 2009 at 5:30 AM, Vasili I. Galchin wrote: > Hello, > > ?????? darcs get --init ....?????? I want to pull down Data.FiniteMap. I > have forgotten the path to Hackage .. I tried .... > > ?sudo darcs get http://hackage.haskell.org/ Data.FiniteMap > [sudo] password for vigalchin: > Invalid repository:? http://hackage.haskell.org > > darcs failed:? Failed to download URL > http://hackage.haskell.org/_darcs/inventory : HTTP error (404?) > > ?? > > Obviously the code I am cabalizing needs to be "upgraded"(i.e. not using > deprecated packages) but first I want it to build! If you want to install something from Hackage, use $ cabal install foo If you want to grab the source $ darcs get --partial path/to/repo (Omit the --partial flag if you want the full source tree, but if you're not intending to do serious work on the source it's probably not worth it.) >From the error message above you appear to be "darcs get"ting the root directory of the hackage server, which isn't a valid repository. Cheers, D -- Dougal Stanton dougal@dougalstanton.net // http://www.dougalstanton.net From conor at strictlypositive.org Fri May 15 05:00:40 2009 From: conor at strictlypositive.org (Conor McBride) Date: Fri May 15 04:45:42 2009 Subject: [Haskell-cafe] conflicting variable definitions in pattern In-Reply-To: <16442B752A06A74AB4D9F9A5FF076E4B01ABAB23@ELON17P32001A.csfb.cs-group.com> References: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> <16442B752A06A74AB4D9F9A5FF076E4B01ABAB23@ELON17P32001A.csfb.cs-group.com> Message-ID: <87236504-1586-4354-B79A-D37A782DF87D@strictlypositive.org> Hi On 15 May 2009, at 09:11, Sittampalam, Ganesh wrote: > Martin Hofmann wrote: >> It is pretty clear, that the following is not a valid Haskell >> pattern: >> >> foo (x:x:xs) = x:xs >> >> My questions is _why_ this is not allowed. IMHO, the semantics should >> be >> clear: The pattern is expected to succeed, iff 'x' is each time bound >> to the same term. That's what my daddy did in 1970. It was an extension of LISP with pattern matching. He used EQUAL. That makes me one of the few functional programmers who's had this feature taken away from them. I'm not weeping, but I do miss it. > > How do you define the "same term"? > > One natural way of compiling it would be to > > foo (x:y:xs) | x == y = x:xs > > but then pattern matching can introduce Eq constraints which some > might > see as a bit odd. Doesn't seem that odd to me. Plenty of other language features come with constraints attached. > >> Isn't this allowed, because this would require a strict evaluation of >> the 'x' variables? > > The translation into == would probably introduce some strictness, for > most implementations of Eq. I don't think this is a huge problem in > itself. There's some conceptual ugliness in that such a mechanism *relies* on fall-through. In principle a sequence of guardless patterns can always be fleshed out (at some cost) to disjoint patterns. What precisely covers the case disjoint from (x, x)? This is fixable if one stops quibbling about guardlessness, or even if one adds inequality patterns. One certainly needs a convention about the order in which things happen: delaying equality tests until after constructor matching --- effectively the guard translation --- seems sensible and preserves the existing compilation regime. Otherwise, repeated pattern variables get (==)-tested, linear ones are lazy. Meanwhile, yes the semantics depends on the implementation of (==), but what's new? That's true of do too. The guard translation: linearize the pattern, introducing new vars for all but the leftmost occurrence of repeated vars. For each new x' made from x, add a guard x == x'. The new guards should come in the same order as the new variables and stand before any other guards present. Presumably one can already cook up an ugly version of this with view patterns ((x ==) -> True). It seems to me that the only questions of substance remaining is whether improved clarity in normal usage is worth a little more translational overhead to unpick what's wrong when weird things happen, and whether any such gain is worth the effort in implementation. I miss lots of stuff from when I was a kid. I used to write elem x (_ ++ x : _) = True elem _ _ = False and think that was cool. How dumb was I? Cheers Conor From jwlato at gmail.com Fri May 15 05:16:58 2009 From: jwlato at gmail.com (John Lato) Date: Fri May 15 05:01:56 2009 Subject: [Haskell-cafe] Re: Data.Binary and little endian encoding Message-ID: <9979e72e0905150216y182ec2e8rdb80ad574d16d799@mail.gmail.com> leimy2k: > On Thu, May 14, 2009 at 8:46 PM, Don Stewart wrote: > >> leimy2k: >> > >> > >> > On Thu, May 14, 2009 at 8:40 PM, Don Stewart wrote: >> > >> > ? ? leimy2k: >> > ? ? > I actually need little endian encoding... wondering if anyone else >> hit >> > ? ? this >> > ? ? > with Data.Binary. (because I'm working with Bell Lab's 9P protocol >> which >> > ? ? does >> > ? ? > encode things on the network in little-endian order). >> > ? ? > >> > ? ? > Anyone got some "tricks" for this? >> > >> > ? ? Yes! >> > ? ? There are big, little and host-endian primitives in the Get/Put >> monads. >> > >> > >> http://hackage.haskell.org/packages/archive/binary/0.5.0.1/doc/html/ >> > ? ? Data-Binary-Put.html#v%3AputWord16le >> > >> > ? ? You can use these to build encoders directly. >> > >> > >> > Cool... I just have to write my own encoder and decoder now. >> > >> > As a request could we get encodeLe decodeLe for a later version of this >> > library? ?:-) ?That'd be totally awesome. >> >> Oh, you mean entirely different instances for all the current ones, that >> use LE encodings? >> > > Well the library is leaning towards "Network Byte Order" in that it has > encode/decode that only encode/decode for Big Endian. > > Us folks who have to do little endian all now have to write our own > encoding/decoding :-) > > I'm speaking specifically of the encode/decode functions. ?I have no idea > how they're implemented. The encode/decode functions just call the runGet/runPut functions for whatever is being encoded or decoded to combined with the get/put functions from the Binary instance. The endian-ness is entirely determined by the Binary instance for the data type you're encoding/decoding, not anything in the encode/decode functions themselves. For data types you define, you can make the Binary instance LE standard (although it may not be a good idea) by using the little-endian primitives Don mentioned. For built-in types, if you want to use a different endian-ness, you can make new get/put functions then call runGet/runPut on those directly. You won't be able to redefine the Binary instances, but if you'll be doing this with a lot of different types you could make your own BinaryLE class like this: class BinaryLE t where putLE :: t -> Put getLE :: Get t encodeLE :: BinaryLE a => a -> ByteString encodeLE = runPut . putLE decodeLE :: BinaryLE a => ByteString -> a decodeLE = runGet getLE I've done some work with Binary and little-endian, and this bias never really bothered me (I think it's actually a host-endian bias, could be mistaken). I was using my own data types so I had to make my own custom Binary instances, which I would have had to do anyway. The data format specified little-endian, so making the Binary instance LE-standard seemed appropriate. You'd only need to re-make custom get/put functions if you're using types that already have Binary instances, and you intend to manipulate the data outside of Haskell. Does that describe your situation? John From dagit at codersbase.com Fri May 15 05:32:54 2009 From: dagit at codersbase.com (Jason Dagit) Date: Fri May 15 05:18:30 2009 Subject: [Haskell-cafe] I have forgotten .. my bad In-Reply-To: <5ae4f2ba0905142130g6a142743wc794a278ad3f2fe5@mail.gmail.com> References: <5ae4f2ba0905142130g6a142743wc794a278ad3f2fe5@mail.gmail.com> Message-ID: On Thu, May 14, 2009 at 9:30 PM, Vasili I. Galchin wrote: > Hello, > > ?????? darcs get --init ....?????? I want to pull down Data.FiniteMap. I > have forgotten the path to Hackage .. I tried .... > > ?sudo darcs get http://hackage.haskell.org/ Data.FiniteMap > [sudo] password for vigalchin: I don't know what your machine is configured like, but I'm rather surprised to see you use 'sudo' with darcs. In case you're not already familiar with the purpose of sudo, I'll explain. The purpose is to give the command the same privileges as root, the super user. Effectively, you're giving darcs full range over your computer. Although, this should be harmless in the case of darcs, it is usually a bad idea to give commands superuser privileges unless they really need it :) Good luck! Jason From wren at freegeek.org Fri May 15 05:47:23 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri May 15 05:32:23 2009 Subject: [Haskell-cafe] conflicting variable definitions in pattern In-Reply-To: <87236504-1586-4354-B79A-D37A782DF87D@strictlypositive.org> References: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> <16442B752A06A74AB4D9F9A5FF076E4B01ABAB23@ELON17P32001A.csfb.cs-group.com> <87236504-1586-4354-B79A-D37A782DF87D@strictlypositive.org> Message-ID: <4A0D3A2B.7080500@freegeek.org> Conor McBride wrote: > Hi > > Sittampalam, Ganesh wrote: > > Martin Hofmann wrote: > > > It is pretty clear, that the following is not a valid Haskell pattern: > > > > > > foo (x:x:xs) = x:xs > > > > > > My questions is _why_ this is not allowed. IMHO, the semantics should > > > be > > > clear: The pattern is expected to succeed, iff 'x' is each time bound > > > to the same term. > > That's what my daddy did in 1970. It was an extension of > LISP with pattern matching. He used EQUAL. That makes me > one of the few functional programmers who's had this > feature taken away from them. I'm not weeping, but I do > miss it. On the one hand, unification is awesome; on the other hand, pattern matching is simple. The nice thing about the simplicity is that it's easy to compile into efficient code, and it's easy to explain/understand. Unification has all sorts of unfortunate consequences[1] and it's much harder to explain to the uninitiated. Curry[2] has features like this, but then it has full backtracking-search logic programming. It might be interesting to see if a more restricted form is useful in Haskell, though it should be an optional feature IMO so that it can be disabled for guaranteed-efficient patterns and typo detection. [1] e.g. optimal factoring of an unordered set of Prolog terms is NP-complete. For a fixed ordering there are good algorithms, and Haskell has fixed ordering due to the semantics of overlapping patterns, but this should still give some clues about what lurks beneath. [2] http://www.curry-language.org/ > > How do you define the "same term"? > > > > One natural way of compiling it would be to > > > > foo (x:y:xs) | x == y = x:xs > > > > but then pattern matching can introduce Eq constraints which some might > > see as a bit odd. > > Doesn't seem that odd to me. Plenty of other language features > come with constraints attached. Another option is to use structural matching all the way down. This has the benefit of not calling user-defined code, though it has the disadvantages of not matching heterogeneous but semantically-equal values. Of course, by removing the Eq constraint this also re-raises the specter of comparing functions. But it's a good Devil's Advocate definition to bear in mind. -- Live well, ~wren From claus.reinke at talk21.com Fri May 15 05:54:29 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Fri May 15 05:39:32 2009 Subject: [Haskell-cafe] conflicting variable definitions in pattern References: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de><16442B752A06A74AB4D9F9A5FF076E4B01ABAB23@ELON17P32001A.csfb.cs-group.com> <87236504-1586-4354-B79A-D37A782DF87D@strictlypositive.org> Message-ID: > I miss lots of stuff from when I was a kid. I used to write > > elem x (_ ++ x : _) = True > elem _ _ = False > > and think that was cool. How dumb was I? Yeah, the Kiel Reduction Language had similarly expressive and fun pattern matching, with subsequence matching and backtracking if the guard failed. Of course, these days, you could use view patterns for the simpler cases, but it doesn't look quite as nice: elem x (break (==x) -> (_, _:_)) = True elem _ _ = False and gets ugly enough to spoil the fun quickly: -- lookup key (_++((key,value):_)) = Just value lookup key (break ((==key).fst) -> (_ , (_,value):_)) = Just value lookup _ _ = Nothing Also, view patterns don't handle match failure by an implicit Monad, let alone MonadPlus, so one often has to insert an explicit Maybe, and there is no backtracking:-( Claus -- Nostalgia isn't what it used to be [source: ?] From ganesh.sittampalam at credit-suisse.com Fri May 15 06:30:38 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Fri May 15 06:16:03 2009 Subject: [Haskell-cafe] conflicting variable definitions in pattern In-Reply-To: <87236504-1586-4354-B79A-D37A782DF87D@strictlypositive.org> References: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de><16442B752A06A74AB4D9F9A5FF076E4B01ABAB23@ELON17P32001A.csfb.cs-group.com> <87236504-1586-4354-B79A-D37A782DF87D@strictlypositive.org> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B01ABAB28@ELON17P32001A.csfb.cs-group.com> Conor McBride wrote: > On 15 May 2009, at 09:11, Sittampalam, Ganesh wrote: >> >> but then pattern matching can introduce Eq constraints which some >> might see as a bit odd. > > Doesn't seem that odd to me. Plenty of other language features come > with constraints attached. It's the introduction of a constraint from tweaking a pattern that is odd, I think. By way of precedent H98 rejected this kind of idea in favour of putting 'fail' into Monad. Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From duncan.coutts at worc.ox.ac.uk Fri May 15 06:48:37 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri May 15 06:33:52 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding In-Reply-To: <3e1162e60905142046y78d8d4a4je8b1b9b75eb55099@mail.gmail.com> References: <3e1162e60905141952x2a58fa43oe27ee43e7bc66e69@mail.gmail.com> <20090515034017.GD31768@whirlpool.galois.com> <3e1162e60905142046y78d8d4a4je8b1b9b75eb55099@mail.gmail.com> Message-ID: <1242384517.20743.7868.camel@localhost> On Thu, 2009-05-14 at 20:46 -0700, David Leimbach wrote: > > > On Thu, May 14, 2009 at 8:40 PM, Don Stewart wrote: > leimy2k: > > > I actually need little endian encoding... wondering if > anyone else hit this > > with Data.Binary. (because I'm working with Bell Lab's 9P > protocol which does > > encode things on the network in little-endian order). > > > > Anyone got some "tricks" for this? > > > Yes! > There are big, little and host-endian primitives in the > Get/Put monads. > > > http://hackage.haskell.org/packages/archive/binary/0.5.0.1/doc/html/Data-Binary-Put.html#v%3AputWord16le > > You can use these to build encoders directly. > > > Cool... I just have to write my own encoder and decoder now. > > > As a request could we get encodeLe decodeLe for a later version of > this library? :-) That'd be totally awesome. The thing you're missing (and which admittedly is not clear) is that the binary package has two parts. One is a layer where you get full control over the binary representation. The other is a portable serialisation layer for pickling and unpickling Haskell values. That pickling layer (ie the Binary class) is not for working with externally-defined binary formats. It might seem like we could co-opt the Binary class for this purpose eg by parametrising by a dozen things like endian, padding, etc etc but I don't think it scales or is sufficiently flexible (and it'd be slow). What is missing in the binary package is a nice set of combinators for using the low level layer to easily construct parsers for externally-defined formats. That's what you'd want for your P9 protocol. To reduce confusion we should also split the Haskell picking layer from the lower layer. This has been on our TODO list for some time. It needs to be done pretty carefully however and we've not really had the time. Duncan From lennart at augustsson.net Fri May 15 07:07:50 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Fri May 15 06:52:46 2009 Subject: [Haskell-cafe] conflicting variable definitions in pattern In-Reply-To: <16442B752A06A74AB4D9F9A5FF076E4B01ABAB28@ELON17P32001A.csfb.cs-group.com> References: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> <16442B752A06A74AB4D9F9A5FF076E4B01ABAB23@ELON17P32001A.csfb.cs-group.com> <87236504-1586-4354-B79A-D37A782DF87D@strictlypositive.org> <16442B752A06A74AB4D9F9A5FF076E4B01ABAB28@ELON17P32001A.csfb.cs-group.com> Message-ID: In the original language design the Haskell committee considered allowing multiple occurrences of the same variable in a pattern (with the suggested equality tests), but it was rejected in favour of simplicity. -- Lennart On Fri, May 15, 2009 at 11:30 AM, Sittampalam, Ganesh wrote: > Conor McBride wrote: >> On 15 May 2009, at 09:11, Sittampalam, Ganesh wrote: >>> >>> but then pattern matching can introduce Eq constraints which some >>> might see as a bit odd. >> >> Doesn't seem that odd to me. Plenty of other language features come >> with constraints attached. > > It's the introduction of a constraint from tweaking a pattern that is > odd, I think. By way of precedent H98 rejected this kind of idea in > favour of putting 'fail' into Monad. > > Ganesh > > =============================================================================== > ?Please access the attached hyperlink for an important electronic communications disclaimer: > ?http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html > ?=============================================================================== > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From conor at strictlypositive.org Fri May 15 08:19:04 2009 From: conor at strictlypositive.org (Conor McBride) Date: Fri May 15 08:03:59 2009 Subject: [Haskell-cafe] conflicting variable definitions in pattern In-Reply-To: References: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> <16442B752A06A74AB4D9F9A5FF076E4B01ABAB23@ELON17P32001A.csfb.cs-group.com> <87236504-1586-4354-B79A-D37A782DF87D@strictlypositive.org> <16442B752A06A74AB4D9F9A5FF076E4B01ABAB28@ELON17P32001A.csfb.cs-group.com> Message-ID: <1206CFE7-0D13-43D0-BD9D-AF04A061782D@strictlypositive.org> On 15 May 2009, at 12:07, Lennart Augustsson wrote: > In the original language design the Haskell committee considered > allowing multiple occurrences of the same variable in a pattern (with > the suggested equality tests), but it was rejected in favour of > simplicity. Simplicity for whom, is the question? My point is only that there's no technical horror to the proposal. It's just that, given guards, the benefit (in simplicity of program comprehension) of nonlinear patterns over explicit == is noticeable but hardly spectacular. Rumblings about funny termination behaviour, equality for functions, and the complexity of unification (which isn't the proposal anyway) are wide of the mark. This is just an ordinary cost-versus-benefit issue. My guess is that if this feature were already in, few would be campaigning to remove it. (By all means step up and say why!) As it's not in, it has to compete with other priorities: I'm mildly positive about nonlinear patterns, but there are more important concerns. Frankly, the worst consequence I've had from Haskell's pattern linearity was just my father's derision. He quite naturally complained that his programs had lost some of their simplicity. All the best Conor From miguelimo38 at yandex.ru Fri May 15 08:28:00 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Fri May 15 08:13:31 2009 Subject: [Haskell-cafe] conflicting variable definitions in pattern In-Reply-To: <1206CFE7-0D13-43D0-BD9D-AF04A061782D@strictlypositive.org> References: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> <16442B752A06A74AB4D9F9A5FF076E4B01ABAB23@ELON17P32001A.csfb.cs-group.com> <87236504-1586-4354-B79A-D37A782DF87D@strictlypositive.org> <16442B752A06A74AB4D9F9A5FF076E4B01ABAB28@ELON17P32001A.csfb.cs-group.com> <1206CFE7-0D13-43D0-BD9D-AF04A061782D@strictlypositive.org> Message-ID: <4A0D5FD0.1010301@yandex.ru> Conor McBride wrote on 15.05.2009 16:19: > My guess is that if this feature were already in, few would be campaigning to remove it. You're probably right. For example, I'm not compaigning to remove multiple inheritance (from non-abstract classes) from C++. But I still think it's an ugly feature, it'd be better not to have it, it's encouraging bad design etc. The same for this Eq-patterns. BTW, why stop on (x:x:xs)? Let's use patterns like (x:factorial(x):xs), or (factorial(x):x:xs), or (factorial(x):xs)... No, wait, the last pattern would be impossible to compile. But I think you've got the point. From matthias.goergens at googlemail.com Fri May 15 09:02:25 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Fri May 15 08:47:21 2009 Subject: [Haskell-cafe] Pretty printing a tree In-Reply-To: <4A0D28F0.60609@freegeek.org> References: <416a2ab0905141158y235b2ae2ha37ee4c5ec3c51d@mail.gmail.com> <4A0D28F0.60609@freegeek.org> Message-ID: Hello, Or --- if you just want pretty trees and you are not confined to the command line: You can generate GraphViz code and use that program to draw your tree in PostScript. (There is also a GraphViz-package, but generating the code yourself is easy.) Matthias. From lennart at augustsson.net Fri May 15 09:05:50 2009 From: lennart at augustsson.net (Lennart Augustsson) Date: Fri May 15 08:50:46 2009 Subject: [Haskell-cafe] conflicting variable definitions in pattern In-Reply-To: <1206CFE7-0D13-43D0-BD9D-AF04A061782D@strictlypositive.org> References: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> <16442B752A06A74AB4D9F9A5FF076E4B01ABAB23@ELON17P32001A.csfb.cs-group.com> <87236504-1586-4354-B79A-D37A782DF87D@strictlypositive.org> <16442B752A06A74AB4D9F9A5FF076E4B01ABAB28@ELON17P32001A.csfb.cs-group.com> <1206CFE7-0D13-43D0-BD9D-AF04A061782D@strictlypositive.org> Message-ID: Simplicity of pattern matching semantics, not of implementation (we all knew how to implement it). Miranda had non-linear patterns, but nobody really argued for them in Haskell. If Haskell had them, I'd not argue to have them removed, but nor will I argue to add them. -- Lennart On Fri, May 15, 2009 at 1:19 PM, Conor McBride wrote: > > On 15 May 2009, at 12:07, Lennart Augustsson wrote: > >> In the original language design the Haskell committee considered >> allowing multiple occurrences of the same variable in a pattern (with >> the suggested equality tests), but it was rejected in favour of >> simplicity. > > Simplicity for whom, is the question? My point is > only that there's no technical horror to the proposal. > It's just that, given guards, the benefit (in simplicity > of program comprehension) of nonlinear patterns over > explicit == is noticeable but hardly spectacular. > > Rumblings about funny termination behaviour, equality > for functions, and the complexity of unification (which > isn't the proposal anyway) are wide of the mark. This > is just an ordinary cost-versus-benefit issue. My guess > is that if this feature were already in, few would be > campaigning to remove it. (By all means step up and say > why!) As it's not in, it has to compete with other > priorities: I'm mildly positive about nonlinear > patterns, but there are more important concerns. > > Frankly, the worst consequence I've had from Haskell's > pattern linearity was just my father's derision. He > quite naturally complained that his programs had lost > some of their simplicity. > > All the best > > Conor > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From briqueabraque at yahoo.com Fri May 15 09:25:29 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=EDcio?=) Date: Fri May 15 09:10:44 2009 Subject: [Haskell-cafe] Problem with haddock importing definition Message-ID: Hi, I have a situation like this: module A imports R (a newtype declaration) from module B, and lists it in its (module A) export list. Documentation for R is included by haddock in documentation for module A, as I want. However, if my package exposes only module A, documentation for R desapears. So: if my .cabal file lists A and B in 'exposed-modules', documentation for R is included in A documentation. If I remove B from 'exposed-modules', R documentation in A desapears. Do you know what should I do? Thanks, Maur?cio From marcot at holoscopio.com Fri May 15 09:52:25 2009 From: marcot at holoscopio.com (Marco =?ISO-8859-1?Q?T=FAlio?= Gontijo e Silva) Date: Fri May 15 09:38:01 2009 Subject: [Haskell-cafe] #haskell.pt IRC channel Message-ID: <1242395545.18742.167.camel@zezinho> Hello, I'd like to invite all Portuguese speakers haskellers to join #haskell.pt in irc.freenode.net. I added it to the list in http://www.haskell.org/haskellwiki/IRC_channel . Greetings. -- marcot http://marcot.iaaeee.org/ From icfp.publicity at googlemail.com Fri May 15 11:29:30 2009 From: icfp.publicity at googlemail.com (Matthew Fluet (ICFP Publicity Chair)) Date: Fri May 15 11:14:25 2009 Subject: [Haskell-cafe] ICFP09 Accepted Papers Message-ID: <53ff55480905150829y2de04849w5c74d38caa76e5e4@mail.gmail.com> Accepted Papers ICFP 2009: International Conference on Functional Programming Edinburgh, Scotland, 31 August - 2 September 2009 http://www.cs.nott.ac.uk/~gmh/icfp09.html The ICFP 2009 Program Chair and Committee are pleased to announce that the following papers have been accepted for the conference. Additional information regarding the final program, invited speakers, and registration will be forthcoming. However, the Local Arrangements Co-Chairs would like to remind participants of the following: * ICFP'09 coincides with the final week of the Edinburgh International Festival, one of the premier arts and cultural festivals in the world. The opportunity to attend the Festival is a plus! Due to the popularity of Edinburgh during the festival period, we recommend booking accommodation early. More details regarding accommodation may be obtained from the ICFP 2009 Local Arrangements webpage: http://www.haskell.org/haskellwiki/ICFP_2009_Local_Arrangements Accepted papers ~~~~~~~~~~~~~~~ A CONCURRENT ML LIBRARY IN CONCURRENT HASKELL Avik Chaudhuri A THEORY OF TYPED COERCIONS AND ITS APPLICATIONS Nikhil Swamy, Michael Hicks and Gavin Bierman A UNIVERSE OF BINDING AND COMPUTATION Daniel Licata and Robert Harper ATTRIBUTE GRAMMARS FLY FIRST-CLASS: HOW TO DO ASPECT ORIENTED PROGRAMMING IN HASKELL Marcos Viera, S. Doaitse Swierstra and Wouter S. Swierstra AUTOMATICALLY RESTFUL WEB APPLICATIONS OR, MARKING MODULAR SERIALIZABLE CONTINUATIONS Jay McCarthy BEAUTIFUL DIFFERENTIATION Conal Elliott BIORTHOGONALITY, STEP-INDEXING AND COMPILER CORRECTNESS Nick Benton and Chung-Kil Hur CAUSAL COMMUTATIVE ARROWS AND THEIR OPTIMIZATION Hai Liu, Eric Cheng and Paul Hudak COMPLETE AND DECIDABLE TYPE INFERENCE FOR GADTS Tom Schrijvers, Simon Peyton Jones, Martin Sulzmann and Dimitrios Vytiniotis CONTROL-FLOW ANALYSIS OF FUNCTION CALLS AND RETURNS BY ABSTRACT INTERPRETATION Jan Midtgaard and Thomas P. Jensen EDUCATIONAL PEARL: FUN FOR FRESHMEN KIDS Matthias Felleisen, Robert Bruce Findler, Matthew Flatt and Shriram Krishnamurthi EFFECTIVE INTERACTIVE PROOFS FOR HIGHER-ORDER IMPERATIVE PROGRAMS Adam Chlipala, Gregory Malecha, Greg Morrisett, Avraham Shinnar and Ryan Wisnesky EXPERIENCE REPORT: EMBEDDED, PARALLEL COMPUTER-VISION WITH A FUNCTIONAL DSL Ryan Newton and Teresa Ko EXPERIENCE REPORT: HASKELL IN THE REALWORLD Curt Sampson EXPERIENCE REPORT: OCAML FOR AN INDUSTRIAL-STRENGTH STATIC ANALYSIS FRAMEWORK Pascal Cuoq and Julien Signoles EXPERIENCE REPORT: OCSIGEN, A WEB PROGRAMMING FRAMEWORK Vincent Balat, J?r?me Vouillon and Boris Yakobowski EXPERIENCE REPORT: SEL4 -- FORMALLY VERIFYING A HIGH-PERFORMANCE MICROKERNEL Gerwin Klein, Philip Derrin and Kevin Elphinstone FINDING RACE CONDITIONS IN ERLANG WITH QUICKCHECK AND PULSE Koen Claessen, Michal Palka, Nicholas Smallbone, John Hughes, Hans Svensson, Thomas Arts and Ulf Wiger FREE THEOREMS INVOLVING TYPE CONSTRUCTOR CLASSES Janis Voigtlaender GENERIC PROGRAMMING WITH FIXED POINTS FOR MUTUALLY RECURSIVE DATATYPES Alexey Rodriguez, Stefan Holdermans, Andres L?h and Johan Jeuring IDENTIFYING QUERY INCOMPATIBILITIES WITH EVOLVING XML SCHEMAS Pierre Geneves, Nabil Layaida and Vincent Quint IMPLEMENTING FIRST-CLASS POLYMORPHIC DELIMITED CONTINUATIONS BY A TYPE-DIRECTED SELECTIVE CPS-TRANSFORM Tiark Rompf, Ingo Maier and Martin Odersky LA TOUR D'HANO? Ralf Hinze NON-PARAMETRIC PARAMETRICITY Georg Neis, Derek Dreyer and Andreas Rossberg OXENSTORED: AN EFFICIENT HIERARCHICAL AND TRANSACTIONAL DATABASE USING FUNCTIONAL PROGRAMMING WITH REFERENCE CELL COMPARISONS Thomas Gazagnaire and Vincent Hanquez PARALLEL CONCURRENT ML John Reppy, Claudio Russo and Yingqi Xiao PARTIAL MEMOIZATION OF CONCURRENCY AND COMMUNICATION Suresh Jagannathan, KC Sivaramakrishnan and Lukasz Ziarek PURELY FUNCTIONAL LAZY NON-DETERMINISTIC PROGRAMMING Sebastian Fischer, Oleg Kiselyov and Chung-chieh Shan RUNTIME SUPPORT FOR MULTICORE HASKELL Simon Marlow, Simon Peyton Jones and Satnam Singh SAFE FUNCTIONAL REACTIVE PROGRAMMING THROUGH DEPENDENT TYPES Neil Sculthorpe and Henrik Nilsson SCRIBBLE: CLOSING THE BOOK ON AD HOC DOCUMENTATION TOOLS Matthew Flatt, Eli Barzilay and Robert Bruce Findler USING OBJECTIVE CAML TO DEVELOP SAFETY-CRITICAL EMBEDDED TOOL IN A CERTIFICATION FRAMEWORK Bruno Pagano, Olivier Andrieu, Thomas Moniot, Benjamin Canou, Emmanuel Chailloux, Philippe Wang, Pascal Manoury and Jean-Louis Colaco From leimy2k at gmail.com Fri May 15 12:02:30 2009 From: leimy2k at gmail.com (David Leimbach) Date: Fri May 15 11:47:24 2009 Subject: [Haskell-cafe] Re: Data.Binary and little endian encoding In-Reply-To: <9979e72e0905150216y182ec2e8rdb80ad574d16d799@mail.gmail.com> References: <9979e72e0905150216y182ec2e8rdb80ad574d16d799@mail.gmail.com> Message-ID: <3e1162e60905150902t24948ae2w3e51a52b90b0b323@mail.gmail.com> This approach looks like it'd work just fine. On Fri, May 15, 2009 at 2:16 AM, John Lato wrote: > leimy2k: > > On Thu, May 14, 2009 at 8:46 PM, Don Stewart wrote: > > > >> leimy2k: > >> > > >> > > >> > On Thu, May 14, 2009 at 8:40 PM, Don Stewart wrote: > >> > > >> > leimy2k: > >> > > I actually need little endian encoding... wondering if anyone > else > >> hit > >> > this > >> > > with Data.Binary. (because I'm working with Bell Lab's 9P > protocol > >> which > >> > does > >> > > encode things on the network in little-endian order). > >> > > > >> > > Anyone got some "tricks" for this? > >> > > >> > Yes! > >> > There are big, little and host-endian primitives in the Get/Put > >> monads. > >> > > >> > > >> http://hackage.haskell.org/packages/archive/binary/0.5.0.1/doc/html/ > >> > Data-Binary-Put.html#v%3AputWord16le > >> > > >> > You can use these to build encoders directly. > >> > > >> > > >> > Cool... I just have to write my own encoder and decoder now. > >> > > >> > As a request could we get encodeLe decodeLe for a later version of > this > >> > library? :-) That'd be totally awesome. > >> > >> Oh, you mean entirely different instances for all the current ones, that > >> use LE encodings? > >> > > > > Well the library is leaning towards "Network Byte Order" in that it has > > encode/decode that only encode/decode for Big Endian. > > > > Us folks who have to do little endian all now have to write our own > > encoding/decoding :-) > > > > I'm speaking specifically of the encode/decode functions. I have no idea > > how they're implemented. > > The encode/decode functions just call the runGet/runPut functions for > whatever is being encoded or decoded to combined with the get/put > functions from the Binary instance. The endian-ness is entirely > determined by the Binary instance for the data type you're > encoding/decoding, not anything in the encode/decode functions > themselves. > > For data types you define, you can make the Binary instance LE > standard (although it may not be a good idea) by using the > little-endian primitives Don mentioned. For built-in types, if you > want to use a different endian-ness, you can make new get/put > functions then call runGet/runPut on those directly. You won't be > able to redefine the Binary instances, but if you'll be doing this > with a lot of different types you could make your own BinaryLE class > like this: > > class BinaryLE t where > putLE :: t -> Put > getLE :: Get t > > encodeLE :: BinaryLE a => a -> ByteString > encodeLE = runPut . putLE > > decodeLE :: BinaryLE a => ByteString -> a > decodeLE = runGet getLE > > I've done some work with Binary and little-endian, and this bias never > really bothered me (I think it's actually a host-endian bias, could be > mistaken). I was using my own data types so I had to make my own > custom Binary instances, which I would have had to do anyway. The > data format specified little-endian, so making the Binary instance > LE-standard seemed appropriate. > > You'd only need to re-make custom get/put functions if you're using > types that already have Binary instances, and you intend to manipulate > the data outside of Haskell. Does that describe your situation? > > 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/20090515/77fcefbe/attachment.html From jno at di.uminho.pt Fri May 15 12:14:50 2009 From: jno at di.uminho.pt (J.N. Oliveira) Date: Fri May 15 11:59:48 2009 Subject: [Haskell-cafe] TFM09: Last CFP (Formal Methods Week, Eindhoven, November 6th 2009) In-Reply-To: <4F764709-722D-4A3D-8EBE-6E075468A59F@di.uminho.pt> References: <6C84A9A8-448D-4BB0-8ECC-733F94618113@di.uminho.pt> <149AF668-5B86-483E-AE4A-31FCB41FAEA3@di.uminho.pt> <751CA11B-C480-4AFD-95EE-341977956B22@di.uminho.pt> <783CB463-70DA-42BB-AA3E-6FEF6D060992@di.uminho.pt> <439928F0-2402-47CA-B9D5-5DBC115FD385@di.uminho.pt> <835D2796-8A7B-4175-AD45-699D28FFC48D@di.uminho.pt> <03D358AB-5CB3-4A1F-B544-D36339BCCAE3@di.uminho.pt> <7AE5C171-EEE6-4ADB-B4F2-24A9F3F95D41@di.uminho.pt> <68F7244E-664C-4B9D-9E53-F57958930A11@di.uminho.pt> <7E9C7D41-AB35-4180-A392-8D650B71A6DA@di.uminho.pt> <295278A7-C8E3-4E98-8D3D-77C436712748@di.uminho.pt> <1ED014F0-F9EF-409A-B36B-11CAD163DA3D@di.uminho.pt> <120310DA-2030-4FA4-9F61-FD4EE51A9C06@di.uminho.pt> <3E535BF5-5F17-4892-8A5D-F8CFB25815A5@di.uminho.pt> <0C688277-C9C2-4420-9002-ADC0DE3DA8A0@di.uminho.pt> <0A1D2802-85F4-4E08-BD46-F84159CAA7CE@di.uminho.pt> <67668AEE-3079-4FEF-8F81-53D0B1866D15@di.uminho.pt> <15B086F0-E97B-43E1-8983-FB2DBAB96CC6@di.uminho.pt> <3C50371D-C0D2-4949-8FEE-00BECC5EBB02@di.uminho.pt> <21A48681-B072-482B-8AAF-54E6C6A5010F@di.uminho.pt> <2342BF13-0034-4F4A-AA4C-EC1CA055CDF1@di.uminho.pt> <663BCC4D-1B19-4E84-8614-AE316270B3C3@di.uminho.pt> <64A8B902-7DA5-4284-A4A8-18D6874CA069@di.uminho.pt> <6AC8F250-5C37-4593-BCBD-144AB137C75D@di.uminho.pt> <1FB8BC34-C683-4850-8FA6-DA12D9743D5E@di.uminho.pt> <8093D19D-B78D-4D7C-A2FF-FAE182EC67AE@di.uminho.pt> <61E3A078-D722-47E9-AC4F-A2610969CE13@di.uminho.pt> <485E9D1C-AF99-4B8E-B8DA-F45997FD26F0@di.uminho.pt> <10B841BC-C0B9-4186-A8B4-D3CFFFCB8116@di.uminho.pt> <5023897F-1EAE-4E3A-95FF-BAB39FAD9445@di.uminho.pt> <342EB496-47B1-42EA-B133-2DBB1BB074F5@di.uminho.pt> <45FDA14E-EB10-44BD-980D-2FED948F4C9B@di.uminho.pt> <47D23ACA-946B-451C-88D5-D5D2970B32AF@di.uminho.pt> <6E227144-4B6B-4824-999C-CD77F1DD7FBE@di.uminho.pt> <0C08ACFB-8E18-44D0-9AA4-D4D4AA45A89B@di.uminho.pt> <569643E0-59FF-485D-B4B8-AD4D7C559424@di.uminho.pt> <4F764709-722D-4A3D-8EBE-6E075468A59F@di.uminho.pt> Message-ID: TFM2009 2nd Int. FME Conference on Teaching Formal Methods "Widening Access to Formal Methods" Friday, November 6th 2009, co-located with FM2009 : 16th International Symposium on Formal Methods Eindhoven, the Netherlands, November 2 - November 6, 2009 CALL FOR PAPERS (URL: http://www.di.uminho.pt/tfm09) 1. About the conference ----------------------- Ten years after the First World Formal Methods Congress (FM'99) in Toulouse, formal methods communities from all over the world will once again have an opportunity to come together. As part of the First Formal Methods Week event surrounding the FM2009 conference in Eindhoven, Formal Methods Europe will be organizing TFM2009, the Second International Conference on Teaching Formal Methods. The conference will serve as a forum to explore the successes and failures of Formal Methods (FM) education, and to promote cooperative projects to further education and training in FMs. We would like to provide a forum for lecturers, teachers, and industrial partners to discuss their experience, present their pedagogical methodologies, and explore best practices. TFM2009 follows in a series of recent events on teaching formal methods, including: two BCS-FACS TFM workshops (Oxford in 2003, and London in 2006), the TFM 2004 conference in Ghent (with proceedings published as Springer LNCS Volume 3294), the FM-Ed 2006 workshop (Hamilton, co-located with FM'06), FORMED (Budapest, at ETAPS 2008), FMET 2008 (Kitakyushu 2008, co-located with ICFEM), etc. 2. Topics of interest --------------------- Formal methods (FM) have an important role to play in the development of complex computing systems - a role acknowledged in industrial standards such as IEC 61508 and ISO/IEC 15408, and in the increasing use of precise modeling notations, semantic markup languages, and model-driven techniques. There is a growing need for software engineers who can work effectively with simple, mathematical abstractions, and with practical notions of inference and proof. However, there is little clear guidance ? for educators, for managers, or for the engineers themselves ? as to what might comprise a basic education in FM. Neither the present IEEE/ACM Software Engineering Body of Knowledge (SWEBOK) nor the forthcoming Graduate Software Engineering Reference Curriculum (GSWERC) provide the kind of specific information that teachers and practitioners need to establish an adequate, balanced programme of learning in FM. Original contributions are solicited that provide insight, opinions, and suggestions for courses of action regarding the teaching FMs, including but not limited to the following aspects: * experiences of teaching FMs, both successful and unsuccessful; * educational resources including the use of books, case studies and the internet; * the education of weak and mathphobic students; * the integration, or otherwise, of FMs into the curriculum, including contributions to the definition of a Formal Methods Body of Knowledge (FMBOK); * the advantages of FM-trained graduates in the workplace; * changing attitudes towards FMs in students, academic staff and practitioners; * the necessary mathematical background. The conference proceedings will be published by Springer-Verlag in the LNCS series. Submissions may be up to 20 pages long using Springer's LNCS format. 3. Important dates ------------------ Please put the following dates in your diary: Submission deadline May 25, 2009 Notification of acceptance July 6, 2009 Final version August 3, 2009 4. How to submit ---------------- Papers for TFM2009 will be processed through the EasyChair conference management system.To submit your paper, please visit: http://www.easychair.org/conferences/?conf=tfm2009 5. Invited speakers ------------------- To be announced 6. Programme Committee ---------------------- Izzat Alsmadi (North Dakota State University, USA) Dines Bjorner (IIMM Institute, Denmark) Eerke Boiten (University of Kent, UK) Raymond Boute (Universiteit Gent, Belgium) Andrew Butterfield (Trinity College, Dublin) Jim Davies (University of Oxford, UK) David Duce (Oxford Brookes University, UK) John Fitzgerald (University of Newcastle upon Tyne, UK) Jeremy Gibbons (University of Oxford, UK) Randolph Johnson (National Security Agency, USA) Michael Mac an Airchinnigh (Trinity College, Dublin) Dino Mandrioli (Politecnico di Milano, Italy) Jose Oliveira (Universidade do Minho, Portugal) Kees Pronk (Technische Universiteit Delft, NL) Bernhard Schaetz (Tecnical University of Munique, Germany) Wolfgang Schreiner (Johannes Kepler University Linz, Austria) Simao Melo de Sousa (Universidade da Beira Interior, Portugal) Kenji Taguchi (National Institute of Informatics, Japan) Jeannette Wing (Carnegie-Mellon University, USA) 7. Sponsorship ---------------------- TFM2009 is supported by FME, the Formal Methods Europe Association -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090515/8cfa6d80/attachment.html From vigalchin at gmail.com Fri May 15 12:29:44 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Fri May 15 12:15:52 2009 Subject: [Haskell-cafe] I have forgotten .. my bad In-Reply-To: References: <5ae4f2ba0905142130g6a142743wc794a278ad3f2fe5@mail.gmail.com> Message-ID: <5ae4f2ba0905150929g6882d0b2o378c740cad9f4074@mail.gmail.com> I mean what is the path to Hackage repo? Vasili On Fri, May 15, 2009 at 4:32 AM, Jason Dagit wrote: > On Thu, May 14, 2009 at 9:30 PM, Vasili I. Galchin > wrote: > > Hello, > > > > darcs get --init ....?????? I want to pull down Data.FiniteMap. I > > have forgotten the path to Hackage .. I tried .... > > > > sudo darcs get http://hackage.haskell.org/ Data.FiniteMap > > [sudo] password for vigalchin: > > I don't know what your machine is configured like, but I'm rather > surprised to see you use 'sudo' with darcs. In case you're not > already familiar with the purpose of sudo, I'll explain. The purpose > is to give the command the same privileges as root, the super user. > Effectively, you're giving darcs full range over your computer. > Although, this should be harmless in the case of darcs, it is usually > a bad idea to give commands superuser privileges unless they really > need it :) > > Good luck! > Jason > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090515/d8f1b65a/attachment.html From benjovi at gmx.net Fri May 15 12:51:13 2009 From: benjovi at gmx.net (Benedikt Huber) Date: Fri May 15 12:36:16 2009 Subject: [Haskell-cafe] Re: I have forgotten .. my bad In-Reply-To: <5ae4f2ba0905142130g6a142743wc794a278ad3f2fe5@mail.gmail.com> References: <5ae4f2ba0905142130g6a142743wc794a278ad3f2fe5@mail.gmail.com> Message-ID: <4A0D9D81.9000008@gmx.net> Vasili I. Galchin schrieb: > Hello, > > darcs get --init ....?????? I want to pull down Data.FiniteMap. I > have forgotten the path to Hackage .. I tried .... Hi Vasili, Hackage does not host the darcs repositories. You can get the FinitMap's source code via > cabal unpack FiniteMap though. benedikt > > sudo darcs get http://hackage.haskell.org/ Data.FiniteMap > [sudo] password for vigalchin: > Invalid repository: http://hackage.haskell.org > > darcs failed: Failed to download URL > http://hackage.haskell.org/_darcs/inventory : HTTP error (404?) > > ?? > > Obviously the code I am cabalizing needs to be "upgraded"(i.e. not using > deprecated packages) but first I want it to build! > > > Thanks, > > Vasili > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From leimy2k at gmail.com Fri May 15 13:42:14 2009 From: leimy2k at gmail.com (David Leimbach) Date: Fri May 15 13:27:07 2009 Subject: [Haskell-cafe] Don't play with your monads... Message-ID: <3e1162e60905151042x6f759420o6c7cb70094af06a7@mail.gmail.com> eventually you'll go bind. Sorry couldn't resist. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090515/079c2184/attachment.html From es at ertes.de Fri May 15 15:27:30 2009 From: es at ertes.de (Ertugrul Soeylemez) Date: Fri May 15 15:12:41 2009 Subject: [Haskell-cafe] Re: Don't play with your monads... References: <3e1162e60905151042x6f759420o6c7cb70094af06a7@mail.gmail.com> Message-ID: <20090515212730.02a8d0e0@tritium.xx> David Leimbach wrote: > eventually you'll go bind. > Sorry couldn't resist. I'd rather go pure joyn. Greets, Ertugrul. -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/ From sergio.urinovsky at gmail.com Fri May 15 16:14:42 2009 From: sergio.urinovsky at gmail.com (Sergio Urinovsky) Date: Fri May 15 15:59:39 2009 Subject: [Haskell-cafe] ANN: RESTng 0.1 + RedHandlers 0.1 (request handlers) + YuiGrids 0.1 (yahoo grids) Message-ID: <628d7e880905151314w39aaf8a4k34491b19df525a33@mail.gmail.com> I'd like to announce the release of 3 new packages in hackage developed for a RESTful web framework called RESTng. They are experimental, the framework is incomplete and we are currently not actively developing it. There are several interesting features so we have decided to release them to share the ideas. *RESTng:* A framework for writing RESTful applications. Features that may be of interest are: * Resource presentation with annotations (implemented with Grids): Resources are annotated with related data and all ends in boxes using grids. i.e., an annotation for a book resource could be its author (the author resource), and also their comments, so the book, the author and their comments are shown in boxes. Annotations can have arbitrary data, but there are some generic ones already available. * Hierarchical URLs are automatically handled. i.e.: Can easily define that a book resource "has many" chapters, then these actions are defined: GET http://site/book/3/chapter/1 (get the chapter 1 of book with id 3) GET http://site/book/3/chapter/new (get a form for filling data for the new chapter for book with id 3) POST http://site/book/3/chapter/new (create a new chapter for the book with id 3) and so on for updates, list and delete actions * ORM generates tables from haskell records (currently only PostgreSQL is supported in the ORM). * Associations "has many" defined for models. Making available functions to query for the parent and children so you don't have to make the SQL query. * Associations can be polymorphic so a comment can be associated to different resources types. A record for a comment on a book, another for a comment on a post. * Tags, Ratings, Comments, Users and login and CMS-like form fields validations supported. *YuiGrids:* * Containers and boxes with layout hints are specified. i.e: - Box A: in left side bar, near the bottom, with this content .... - Container B: in the main part of the page, near the top, with 3 columns and these let's say 14 boxes inside ... (including Box C) - Box C: in the left column of three, with this other content ... * Tries to satisfy the layout hints. Not allways possible, i.e: if every box has layout hint to go near the bottom, some of them will go at the top. * Boxes can have CSS specifications. * All is rendered into Yahoo grids (http://developer.yahoo.com/yui/grids). Currently, the YuiGrids uses own contextual html combinators are also implemented in this package (called CxML here) instead of Text.XHtml for keeping track of html parts like inline CSSs to be rendered at the head. This can be improved to use the standard Text.XHtml library. *RedHandlers:* It is another HTTP request handlers library to build standalone web apps. * They deal with request data as usual. * There are also combinators for mapping part of the URL to public folders in the file system. * And one for sending files efficiently in the response (a fork of the HTTP library was necessary for this, included here). -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090515/4e062cc9/attachment.html From lemming at henning-thielemann.de Fri May 15 17:01:06 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri May 15 16:46:02 2009 Subject: [Haskell-cafe] GSoC project for EclipseFP In-Reply-To: References: Message-ID: On Thu, 14 May 2009, Thomas ten Cate wrote: > I'm happy to announce that my Google Summer of Code project proposal, > titled "Extend EclipseFP functionality for Haskell", has been > accepted! This means that I will be working on EclipseFP during the > upcoming months. Great news! From nowgate at yahoo.com Fri May 15 19:17:28 2009 From: nowgate at yahoo.com (michael rice) Date: Fri May 15 19:02:22 2009 Subject: [Haskell-cafe] Example code won't compile Message-ID: <693217.85551.qm@web31107.mail.mud.yahoo.com> Why won't this code compile? Michael ======================= {- Author:???? Jeff Newbern ?? Maintainer: Jeff Newbern ?? Time-stamp: ?? License:??? GPL -} {- DESCRIPTION Example 14 - Using the IO monad Usage: Compile the code to produce a poor replacement for ?????? the standard Unix "tr" command. Try: cat file | ./ex14 "aeiou" "X" ???? cat file | ./ex14 " " "_" ???? ./ex14 "abc" -} import Monad import System import IO import Control.Monad.Error -- translate char in set1 to corresponding char in set2 translate :: String -> String -> Char -> Char translate []???? _????? c = c translate (x:xs) []???? c = if x == c then ' ' else translate xs []? c translate (x:xs) [y]??? c = if x == c then? y? else translate xs [y] c translate (x:xs) (y:ys) c = if x == c then? y? else translate xs ys? c -- translate an entire string translateString :: String -> String -> String -> String translateString set1 set2 str = map (translate set1 set2) str usage :: IOError -> IO () usage e = do putStrLn "Usage: ex14 set1 set2" ???????????? putStrLn "Translates characters in set1 on stdin to the corresponding" ???????????? putStrLn "characters from set2 and writes the translation to stdout." -- translates stdin to stdout based on commandline arguments main :: IO () main = (do [set1,set2] <- getArgs ?????????? contents??? <- hGetContents stdin ?????????? putStr $ translateString set1 set2 contents) ?????? `catchError` usage -- END OF FILE ===================================== [michael@localhost ~]$ ghc ex14.hs -o ex14 ex14.o: In function `rF8_info': (.text+0x48): undefined reference to `mtlzm1zi1zi0zi2_ControlziMonadziError_zdf17_closure' ex14.o: In function `sGp_info': (.text+0x861): undefined reference to `mtlzm1zi1zi0zi2_ControlziMonadziError_zdf17_closure' ex14.o: In function `sGp_info': (.text+0x91d): undefined reference to `__stginit_mtlzm1zi1zi0zi2_ControlziMonadziError_' ex14.o: In function `rF8_info': (.text+0x50): undefined reference to `mtlzm1zi1zi0zi2_ControlziMonadziErrorziClass_zdp1MonadError_info' ex14.o: In function `sGp_info': (.text+0x869): undefined reference to `mtlzm1zi1zi0zi2_ControlziMonadziErrorziClass_catchError_info' ex14.o: In function `rF8_srt': (.data+0x0): undefined reference to `mtlzm1zi1zi0zi2_ControlziMonadziError_zdf17_closure' ex14.o: In function `Main_main_srt': (.data+0x6c): undefined reference to `mtlzm1zi1zi0zi2_ControlziMonadziError_zdf17_closure' collect2: ld returned 1 exit status [michael@localhost ~]$ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090515/c86ac583/attachment-0001.html From dons at galois.com Fri May 15 19:18:25 2009 From: dons at galois.com (Don Stewart) Date: Fri May 15 19:04:44 2009 Subject: [Haskell-cafe] Example code won't compile In-Reply-To: <693217.85551.qm@web31107.mail.mud.yahoo.com> References: <693217.85551.qm@web31107.mail.mud.yahoo.com> Message-ID: <20090515231824.GU2968@whirlpool.galois.com> nowgate: > Why won't this code compile? > [michael@localhost ~]$ ghc ex14.hs -o ex14 Missing --make I'd also add -O2, but I'm like that. -- Don From nowgate at yahoo.com Fri May 15 19:50:16 2009 From: nowgate at yahoo.com (michael rice) Date: Fri May 15 19:35:10 2009 Subject: [Haskell-cafe] Example code won't compile Message-ID: <940941.87073.qm@web31103.mail.mud.yahoo.com> This example compiles fine without --make. What's the difference? Michael ================== {- Author:???? Jeff Newbern ?? Maintainer: Jeff Newbern ?? Time-stamp: ?? License:??? GPL -} {- DESCRIPTION Example 13 - Using the List monad Usage: Compile the code and execute the resulting program ?????? with various arguments.? Each argument will produce ?????? a list of possible parses of the argument as a decimal ?????? number, a hexadecimal number or a word. Try: ./ex13 34 f3 bean ???? ./ex13 food f00d ???? ./ex13 beef 10 "n!" ???? ./ex13 "why?" "(punctuation)" -} import Monad import System import Char -- we can parse three different types of terms data Parsed = Digit Integer | Hex Integer | Word String deriving Show -- attempts to add a character to the parsed representation of a hex digit parseHexDigit :: Parsed -> Char -> [Parsed] parseHexDigit (Hex n) c = if isHexDigit c then ??????????????????????????? return (Hex ((n*16) + (toInteger (digitToInt c)))) ??? ??? ????????? else ??????????????????????????? mzero parseHexDigit _?????? _ = mzero -- attempts to add a character to the parsed representation of a decimal digit parseDigit :: Parsed -> Char -> [Parsed] parseDigit (Digit n) c = if isDigit c then ?????????????????????????? return (Digit ((n*10) + (toInteger (digitToInt c)))) ???????????????????????? else ?????????????????????????? mzero parseDigit _???????? _ = mzero ??? ??? ?? -- attempts to add a character to the parsed representation of a word parseWord :: Parsed -> Char -> [Parsed] parseWord (Word s) c = if isAlpha c then ???????????????????????? return (Word (s ++ [c])) ?????????????????????? else ???????????????????????? mzero parseWord _??????? _ = mzero -- tries to parse the digit as a hex value, a decimal value and a word -- the result is a list of possible parses parse :: Parsed -> Char -> [Parsed] parse p c = (parseHexDigit p c) `mplus` (parseDigit p c) `mplus` (parseWord p c) -- parse an entire String and return a list of the possible parsed values parseArg :: String -> [Parsed] parseArg s = do init <- (return (Hex 0)) `mplus` (return (Digit 0)) `mplus` (return (Word "")) ??????????????? foldM parse init s -- show the original string and all possible parses for the string showResult :: String -> IO () showResult s = do putStr s ????????????????? putStr ": " ????????????????? print (parseArg s) -- prints possible parsed values for command-line arguments main :: IO () main = do args <- getArgs ????????? mapM_ showResult args -- END OF FILE --- On Fri, 5/15/09, Lennart Augustsson wrote: From: Lennart Augustsson Subject: Re: [Haskell-cafe] Example code won't compile To: "michael rice" Cc: "haskell-cafe@haskell.org" Date: Friday, May 15, 2009, 7:25 PM --make ?? -- Lennart (iPhone) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090515/c752766d/attachment.html From gtener at gmail.com Fri May 15 21:55:12 2009 From: gtener at gmail.com (=?UTF-8?Q?Krzysztof_Skrz=C4=99tnicki?=) Date: Fri May 15 21:40:06 2009 Subject: [Haskell-cafe] Example code won't compile In-Reply-To: <940941.87073.qm@web31103.mail.mud.yahoo.com> References: <940941.87073.qm@web31103.mail.mud.yahoo.com> Message-ID: <220e47b40905151855h3fd8bec4t438218356a059676@mail.gmail.com> The one important line is > import Control.Monad.Error It adds dependancy on mtl package, which is not used by default (contrary to 'base' package, which includes Monad, System and IO modules). With --make GHC adds it automatically. Therefore $ ghc -package mtl ex14.hs compiles fine. I'd recommend using --make. In rare occasions when there is a namespace clash between packages one can simply hide offending packages or specify preferred ones. Best regards Christopher Skrz?tnicki From wren at freegeek.org Fri May 15 22:54:32 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri May 15 22:39:26 2009 Subject: [Haskell-cafe] conflicting variable definitions in pattern In-Reply-To: <1206CFE7-0D13-43D0-BD9D-AF04A061782D@strictlypositive.org> References: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> <16442B752A06A74AB4D9F9A5FF076E4B01ABAB23@ELON17P32001A.csfb.cs-group.com> <87236504-1586-4354-B79A-D37A782DF87D@strictlypositive.org> <16442B752A06A74AB4D9F9A5FF076E4B01ABAB28@ELON17P32001A.csfb.cs-group.com> <1206CFE7-0D13-43D0-BD9D-AF04A061782D@strictlypositive.org> Message-ID: <4A0E2AE8.8070003@freegeek.org> Conor McBride wrote: > Rumblings about funny termination behaviour, equality > for functions, and the complexity of unification (which > isn't the proposal anyway) But unification is what you get by adding non-linearity. Sure, all terms are ground; would you prefer I said "testing for membership in an element of the RATEG class"? For more ickiness about RATEG, it's not closed under compliment and the emptiness problem is undecidable (so dead code elimination can't always work). Even restricting to the closed subset (aka "tree-automata with (dis-)equality constraints") leaves emptiness undecidable, though there are a couple still more restricted classes that are decidable. cf ch.4 of TATA -- Live well, ~wren From jason.dusek at gmail.com Fri May 15 23:08:07 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri May 15 22:53:01 2009 Subject: [Haskell-cafe] conflicting variable definitions in pattern In-Reply-To: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> References: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <42784f260905152008n4fc3d3den237b867045d13bac@mail.gmail.com> Algebraic datatypes are built and unpacked with constructors. Pattern matching is just a way to use these constructors. This is distinct from the kind of unification/validation that happens in logic languages like Prolog. There is no special list constructor for when the first two items are equal. -- Jason Dusek From nowgate at yahoo.com Fri May 15 23:27:26 2009 From: nowgate at yahoo.com (michael rice) Date: Fri May 15 23:12:20 2009 Subject: [Haskell-cafe] Example code won't compile Message-ID: <71719.19432.qm@web31108.mail.mud.yahoo.com> OK. Thanks, everyone. Michael --- On Fri, 5/15/09, Krzysztof Skrz?tnicki wrote: From: Krzysztof Skrz?tnicki Subject: Re: [Haskell-cafe] Example code won't compile To: "michael rice" Cc: "Lennart Augustsson" , "haskell-cafe@haskell.org" Date: Friday, May 15, 2009, 9:55 PM The one important line is > import Control.Monad.Error It adds dependancy on mtl package, which is not used by default (contrary to 'base' package, which includes Monad, System and IO modules). With --make GHC adds it automatically. Therefore $ ghc -package mtl ex14.hs compiles fine. I'd recommend using --make. In rare occasions when there is a namespace clash between packages one can simply hide offending packages or specify preferred ones. Best regards Christopher Skrz?tnicki -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090515/7bf4ac5b/attachment.html From vigalchin at gmail.com Sat May 16 01:58:19 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Sat May 16 01:43:11 2009 Subject: [Haskell-cafe] Data.FiniteMap deprecrated Message-ID: <5ae4f2ba0905152258y12dfd28bw11d367969ea833ef@mail.gmail.com> Hello, http://hackage.haskell.org/cgi-bin/hackage-scripts/package/FiniteMap ... since this is deprecated what is the orthodox way to implement "finite map"?? Thanks, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090516/525c0a94/attachment.html From dons at galois.com Sat May 16 02:05:38 2009 From: dons at galois.com (Don Stewart) Date: Sat May 16 01:51:56 2009 Subject: [Haskell-cafe] Data.FiniteMap deprecrated In-Reply-To: <5ae4f2ba0905152258y12dfd28bw11d367969ea833ef@mail.gmail.com> References: <5ae4f2ba0905152258y12dfd28bw11d367969ea833ef@mail.gmail.com> Message-ID: <20090516060538.GA5264@whirlpool.galois.com> Data.Map in the containers library. vigalchin: > Hello, > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/FiniteMap ... > since this is deprecated what is the orthodox way to implement "finite map"?? > > Thanks, > > Vasili > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From er.9999 at yahoo.com.cn Sat May 16 02:10:49 2009 From: er.9999 at yahoo.com.cn (yu yang) Date: Sat May 16 01:55:45 2009 Subject: [Haskell-cafe] help :type class? Message-ID: <888294.23550.qm@web15008.mail.cnb.yahoo.com> Does anyone have an idea how to use an instance to list all the functions of type? Thank you!? ___________________________________________________________ ????????????????? http://card.mail.cn.yahoo.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090516/3a69ac4a/attachment.html From ekirpichov at gmail.com Sat May 16 02:39:25 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sat May 16 02:24:21 2009 Subject: [Haskell-cafe] help :type class? In-Reply-To: <888294.23550.qm@web15008.mail.cnb.yahoo.com> References: <888294.23550.qm@web15008.mail.cnb.yahoo.com> Message-ID: <5e0214850905152339k5169277w94dd205131934908@mail.gmail.com> How about hoogle? 2009/5/16 yu yang : > Does anyone have an idea how to use an instance to list all the functions of > type? Thank you! > ________________________________ > ????????????????? > _______________________________________________ > 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 Sat May 16 04:24:25 2009 From: dagit at codersbase.com (Jason Dagit) Date: Sat May 16 04:09:20 2009 Subject: [Haskell-cafe] help :type class? In-Reply-To: <888294.23550.qm@web15008.mail.cnb.yahoo.com> References: <888294.23550.qm@web15008.mail.cnb.yahoo.com> Message-ID: On Fri, May 15, 2009 at 11:10 PM, yu yang wrote: > Does anyone have an idea how to use an instance to list all the functions of > type? Thank you! Perhaps :i inside of ghci? Jason From conor at strictlypositive.org Sat May 16 06:44:02 2009 From: conor at strictlypositive.org (Conor McBride) Date: Sat May 16 06:28:52 2009 Subject: [Haskell-cafe] conflicting variable definitions in pattern In-Reply-To: <4A0E2AE8.8070003@freegeek.org> References: <1242374949.6214.16.camel@ios.cogsys.wiai.uni-bamberg.de> <16442B752A06A74AB4D9F9A5FF076E4B01ABAB23@ELON17P32001A.csfb.cs-group.com> <87236504-1586-4354-B79A-D37A782DF87D@strictlypositive.org> <16442B752A06A74AB4D9F9A5FF076E4B01ABAB28@ELON17P32001A.csfb.cs-group.com> <1206CFE7-0D13-43D0-BD9D-AF04A061782D@strictlypositive.org> <4A0E2AE8.8070003@freegeek.org> Message-ID: <64FEC5B9-FAB9-413D-9F24-8B142AEF2E42@strictlypositive.org> On 16 May 2009, at 03:54, wren ng thornton wrote: > Conor McBride wrote: >> Rumblings about funny termination behaviour, equality >> for functions, and the complexity of unification (which >> isn't the proposal anyway) > > But unification is what you get by adding non-linearity. Hang on a minute: we're solving for sb in sb(p)=v not in sb(s)=sb(t)... > Sure, all terms are ground; ...which makes it a rather special and degenerate and unawesome case of unification: the kind of unification you don't need a unification algorithm to solve. > would you prefer I said "testing for membership in an element of the > RATEG class"? I'm not familiar with that terminology, but I'll check out the link. > For more ickiness about RATEG, it's not closed under compliment and > the emptiness problem is undecidable (so dead code elimination can't > always work). Even restricting to the closed subset (aka "tree- > automata with (dis-)equality constraints") leaves emptiness > undecidable, though there are a couple still more restricted classes > that are decidable. > > cf ch.4 of TATA Let's be clear. The suggestion is only that a slightly more compact notation be permitted for functionality already available via guards or view patterns. It cannot introduce any dead code elimination problems which are not already present. I'm sorry, but I just don't see the bogeyman here. All the best Conor From alexey.skladnoy at gmail.com Sat May 16 06:46:23 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Sat May 16 07:33:31 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding In-Reply-To: <3e1162e60905141952x2a58fa43oe27ee43e7bc66e69@mail.gmail.com> References: <3e1162e60905141952x2a58fa43oe27ee43e7bc66e69@mail.gmail.com> Message-ID: <200905161446.24506.alexey.skladnoy@gmail.com> On Friday 15 May 2009 06:52:29 David Leimbach wrote: > I actually need little endian encoding... wondering if anyone else hit this > with Data.Binary. (because I'm working with Bell Lab's 9P protocol which > does encode things on the network in little-endian order). > Anyone got some "tricks" for this? > > Dave You could just define data type and Binary instance for 9P messages. Something like this: P9Message = Tversion { tag :: Word16, msize :: Word32, version :: String } | ... instance Binary P9Message where put (Tverstion t m v) = putWord16le t >> putWord32le m >> put v -- and so on... get = do length <- getWord32le id <- getWord16le case is of p9TMessage -> do ... There are a lot of boilerplate code thought... BTW could you say what do you want to do with 9P? I tried to play with it using libixp library but without any success. It was mainly to understand how does it works and how can it be used. From gue.schmidt at web.de Sat May 16 10:18:39 2009 From: gue.schmidt at web.de (=?UTF-8?B?R8O8wp9udGhlciBTY2htaWR0?=) Date: Sat May 16 10:03:47 2009 Subject: [Haskell-cafe] GUIs, FRP, (Delimited) Continuations and Zippers Message-ID: Hi all, In my app, there is one part which has a rather complicated GUI logic, it involves n drop downs with n choices each. Whenever the current selection in one of the drop downs changes by user interaction, the other (n-1) drop downs need to be notified and their item list need to possible change too. Now I have managed to code all this and it actually behaves correctly. But I'm also using tons of IORefs and tons of bookkeeping code for it. While I'd not be ashamed to show any other part of my code to another Haskeller, this part of the code is the most clumsiest I've ever written. And I have no clue if that piece of code *can* be written in any other way, ie. without the tons of IORefs and bookkeeping. The GUI library is WXHaskell. In the last few days I read up on Conal Elliotts FRP stuff (reactive) but also on Olegs ZFS (Zippers, Delimited Continuations), the latter leaving me totally baffled. Could either of those approaches (FRP / Delimited Continuations) be a solution for implementing complex GUI code? G?nther From Sven.Panne at aedion.de Sat May 16 11:18:07 2009 From: Sven.Panne at aedion.de (Sven Panne) Date: Sat May 16 11:03:01 2009 Subject: [Haskell-cafe] Decoupling OpenAL/ALUT packages from OpenGL In-Reply-To: <4A07F817.9010401@kent.ac.uk> References: <200905101350.09012.Sven.Panne@aedion.de> <4A07F817.9010401@kent.ac.uk> Message-ID: <200905161718.07787.Sven.Panne@aedion.de> Am Montag, 11. Mai 2009 12:04:07 schrieb Neil Brown: > [...] So possible additions to your type-class list are Foldable and maybe > Traversable (no harm, although I'd have to reach further for an example > for this). I guess the tricky decision might be whether to provide a > Num instance (again, probably more suitable for Vector2)? [...] OK, I've added a bunch of instances for all vertex attribute types in the OpenGL 2.2.3.0 package. Let me know if there are standard classes for which you would like to see instances, too. I've deliberately omitted instances for Num, because they are not correct from a mathematical point of view: You can't e.g. add two points (only a point and a vector), the difference between two points is not a point (it's a vector), etc. Cheers, S. From alexander.dunlap at gmail.com Sat May 16 12:33:30 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Sat May 16 12:24:46 2009 Subject: [Haskell-cafe] Building 'text-icu-0.1' on Windows In-Reply-To: References: <57526e770905131646k5c071cbdq4b2002029105f58a@mail.gmail.com> Message-ID: <57526e770905160933jef0bc31ja21716801b3ffb52@mail.gmail.com> On Thu, May 14, 2009 at 10:25 AM, Bryan O'Sullivan wrote: > On Thu, May 14, 2009 at 10:18 AM, Bryan O'Sullivan > wrote: >> >> If one of you has the time to dig into this and send a patch that corrects >> the problem, I'd welcome the help. As I'm sure you can tell, I developed >> text-icu on Unix, and I don't have regular enough Windows access to make >> debugging this a quick and easy matter. >> > By the way, if you run into problems building or using text or text-icu, > please file a ticket here: http://trac.haskell.org/text/newticket > Hi, I've attached a patch that fixes the build on Windows. It also doesn't seem to break the build on my Linux box. However, the patch basically consists of removing an #include statement and removing some library dependencies (which for some reason don't exist in the Windows distribution of ICU), so I don't know if it would break something else. The library compiles without warnings with the patch applied, though. Maybe Serge could test the patch on his machine? Thanks, Alex -------------- next part -------------- A non-text attachment was scrubbed... Name: fix-windows-build.dpatch Type: application/octet-stream Size: 902 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090516/d3be0d1c/fix-windows-build.obj From lambda-belka at yandex.ru Sat May 16 13:22:54 2009 From: lambda-belka at yandex.ru (Belka) Date: Sat May 16 13:07:45 2009 Subject: [Haskell-cafe] typeclasses comprehension problems: situation classes? Message-ID: <23575951.post@talk.nabble.com> Hello, cafe visitors! I'm trying to learn Haskell typeclasses, - about how to use them, - but can't handle some conceptiual problems, which confuses me a lot. I took one real problem (ErrorInfo gragual gathering), to tackle it in my studies: I have a class of situations: there is an object, and it gets cumulatively filled (or updated) with content. The code is in the end - it consists of 3 versions: 1. My first try. Fast written, based on intuitive understanding. Failed. 2. The second try - exploring an open world assumption. I hoped this would set me on the right path. Failure. 3. Surrendered to compiler - statisfied all it's requirements. This code looks absurd to me: parameter-never-to-be-used, unwanted-defaults. Compiler accepted this one though. Problems: 1. How to define *fillerRole* correctly, so that it depends on the type-value of "src_t"? 2. How to define *initFillable* correctly, so that it depends only on the type-value "filled_t", which is specified by the context of evaluation? 3. What are my misconcepts in the use of Haskell typeclasses here? 4. Maybe I should distinguish *situation class* (as this one), as something unavailable in Haskell? This assumption is the last one to make... I'd rather belive, that there is something I'm not aware of (for a considerably long time already) in Haskell. A lack of some programming technique Please, Help! Regards, Belka ==TRY=1===DOESN'T=COMPILE================================================== {-# LANGUAGE MultiParamTypeClasses #-} class FillsConsideringRoles src_t filled_t role_t where initFillable :: filled_t fillerRole :: role_t fill :: src_t -> filled_t -> filled_t ------------------------------------------------------------ data Role = Role1 | Role2 deriving (Show) data FillableObject = FillableObject { foData1 :: Maybe (Int, Role) , foData2 :: Maybe (Int, Role) } deriving (Show) newEmptyFillableObject :: FillableObject newEmptyFillableObject = FillableObject Nothing Nothing data Constructor1 = Constructor1 Int data Constructor2 = Constructor2 Int instance FillsConsideringRoles Constructor1 FillableObject Role where initFillable = newEmptyFillableObject fillerRole = Role1 fill c fo = let (Constructor1 i) = c in fo { foData1 = Just (i, fillerRole) } instance FillsConsideringRoles Constructor2 FillableObject Role where initFillable = newEmptyFillableObject fillerRole = Role2 fill c fo = let (Constructor2 i) = c in fo { foData2 = Just (i, fillerRole) } main = putStrLn $ show $ fill c2 $ fill c1 initFillable where c1 = Constructor1 76 c2 = Constructor2 43 ==TRY=1==[END]=================================================== ==TRY=2===DOESN'T=COMPILE======================================== {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE OverlappingInstances #-} class FillsConsideringRoles src_t filled_t role_t where initFillable :: filled_t fillerRole :: role_t fill :: src_t -> filled_t -> filled_t ---------------------------------------------------------------------- data Role = DefaultRole | Role1 | Role2 deriving (Show) data FillableObject = FillableObject { foData1 :: Maybe (Int, Role) , foData2 :: Maybe (Int, Role) } deriving (Show) newEmptyFillableObject :: FillableObject newEmptyFillableObject = FillableObject Nothing Nothing data Constructor1 = Constructor1 Int data Constructor2 = Constructor2 Int instance FillsConsideringRoles filler_t filled_t Role where fillerRole = DefaultRole instance FillsConsideringRoles Constructor2 filled_t Role where fillerRole = Role2 instance FillsConsideringRoles Constructor1 filled_t Role where fillerRole = Role1 instance FillsConsideringRoles filler_t FillableObject role_t where initFillable = newEmptyFillableObject instance FillsConsideringRoles Constructor1 FillableObject Role where fill c fo = let (Constructor1 i) = c in fo { foData1 = Just (i, fillerRole) } instance FillsConsideringRoles Constructor2 FillableObject Role where fill c fo = let (Constructor2 i) = c in fo { foData2 = Just (i, fillerRole) } main = putStrLn $ show $ fill c2 $ fill c1 initFillable where c1 = Constructor1 76 c2 = Constructor2 43 ==TRY=2==[END]=================================================== ==TRY=3===WORKS================================================= {-# LANGUAGE MultiParamTypeClasses #-} class FillsConsideringRoles src_t filled_t role_t where initFillable :: ((),src_t, role_t) -> filled_t fillerRole :: ((),src_t, filled_t) -> role_t fill :: ((),role_t) -> src_t -> filled_t -> filled_t ------------------------------------------------------------ data Role = DefaultRole | Role1 | Role2 deriving (Show) data FillableObject = FillableObject { foData1 :: Maybe (Int, Role) , foData2 :: Maybe (Int, Role) } deriving (Show) newEmptyFillableObject :: FillableObject newEmptyFillableObject = FillableObject Nothing Nothing data Constructor1 = Constructor1 Int data Constructor2 = Constructor2 Int instance FillsConsideringRoles Constructor1 FillableObject Role where initFillable _ = newEmptyFillableObject fillerRole _ = Role1 fill _ c fo = let (Constructor1 i) = c in fo { foData1 = Just (i, fillerRole ((), c, fo)) } instance FillsConsideringRoles Constructor2 FillableObject Role where initFillable _ = newEmptyFillableObject fillerRole _ = Role2 fill _ c fo = let (Constructor2 i) = c in fo { foData2 = Just (i, fillerRole ((), c, fo)) } main = putStrLn $ show $ fill ((), DefaultRole) c2 $ fill ((), DefaultRole) c1 ((initFillable ((), Constructor1 (-1), DefaultRole)) :: FillableObject) where c1 = Constructor1 76 c2 = Constructor2 43 ==TRY=3==[END]=================================================== -- View this message in context: http://www.nabble.com/typeclasses-comprehension-problems%3A-situation-classes--tp23575951p23575951.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From bulat.ziganshin at gmail.com Sat May 16 13:57:36 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat May 16 13:42:34 2009 Subject: [Haskell-cafe] typeclasses comprehension problems: situation classes? In-Reply-To: <23575951.post@talk.nabble.com> References: <23575951.post@talk.nabble.com> Message-ID: <769047163.20090516215736@gmail.com> Hello Belka, Saturday, May 16, 2009, 9:22:54 PM, you wrote: > I'm trying to learn Haskell typeclasses, - about how to use them, - but am i correctly understood that you've started learning type classes with multi-parameter ones? this may be a bit too brave, especially for a woman :D i suggest you to read first http://haskell.org/haskellwiki/OOP_vs_type_classes about MPTC - you may find great intro in ghc manual, but anyway i suggest to start with single-parameter ones -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From johanj at cs.uu.nl Sat May 16 14:04:55 2009 From: johanj at cs.uu.nl (Johan Jeuring) Date: Sat May 16 13:49:47 2009 Subject: [Haskell-cafe] Foldable for BNFC generated tree In-Reply-To: <7b501d5c0905041606j28426548y829c050c29ebc372@mail.gmail.com> References: <7b501d5c0905031147n24a5ec46jea3926da78d61498@mail.gmail.com> <49FE9F87.6020208@van.steenbergen.nl> <7b501d5c0905041606j28426548y829c050c29ebc372@mail.gmail.com> Message-ID: <0F5108A2-D659-4BD4-8B87-AB7E2025783D@cs.uu.nl> Hi Deniz, >> Deniz Dogan wrote: >>> >>> So, basically I'd like some sort of folding functionality for these >>> data types, without having to hack the lexer/parser myself >>> (parameterising the data types), because as I said they're being >>> generated by BNFC. >> >> What exactly do you mean by folding functionality? Folding as in the >> Foldable type class applies to containers, which your data type >> isn't. >> Perhaps you're looking for generic programming? >> >> There are several good GP libraries out there: >> >> * EMGM: http://www.cs.uu.nl/wiki/GenericProgramming/EMGM >> * Uniplate: http://community.haskell.org/~ndm/uniplate/ >> * SYB: http://www.cs.vu.nl/boilerplate/ >> >> See also Neil Mitchell's blog for some examples: >> http://neilmitchell.blogspot.com/2009/03/concise-generic-queries.html > > You're right, what I was asking for didn't make much sense... I was > really looking for GP. If I interpret your question correctly, you want a fold for a set of mutually recursive datatypes without type parameters. This function is available in the generic programming library multirec: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/multirec Kind reagrds, Johan Jeuring From thestonetable at gmail.com Sat May 16 15:00:53 2009 From: thestonetable at gmail.com (Cory Knapp) Date: Sat May 16 14:45:55 2009 Subject: [Haskell-cafe] Graphs and graph algorithms? Message-ID: <4A0F0D65.5070600@gmail.com> Hey, Besides fgl, are there any graph libraries in Haskell that are still maintained? Are there other papers (or books) besides Erwig's that I could use to understand how graph algorithms have been implemented in functional languages? Has anything even been published on the topic since Erwig's paper? Thanks, Cory From magnus at therning.org Sat May 16 15:04:32 2009 From: magnus at therning.org (Magnus Therning) Date: Sat May 16 14:49:34 2009 Subject: [Haskell-cafe] typeclasses comprehension problems: situation classes? In-Reply-To: <769047163.20090516215736@gmail.com> References: <23575951.post@talk.nabble.com> <769047163.20090516215736@gmail.com> Message-ID: <4A0F0E40.2060807@therning.org> Bulat Ziganshin wrote: > Hello Belka, > > Saturday, May 16, 2009, 9:22:54 PM, you wrote: > >> I'm trying to learn Haskell typeclasses, - about how to use them, - but > > am i correctly understood that you've started learning type classes > with multi-parameter ones? this may be a bit too brave, especially for > a woman :D Oh, I'd say that holds for men even more :-) It surely did hold for the man writing this. (Oh, and may I suggest that we all are careful with the gender jokes on the list, no matter how well-intended and even if we know the woman in question. It's simply too easy to mis-interpret on a medium with a bandwidth like email.) /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090516/18790c73/signature.bin From dons at galois.com Sat May 16 15:08:49 2009 From: dons at galois.com (Don Stewart) Date: Sat May 16 14:55:12 2009 Subject: [Haskell-cafe] Graphs and graph algorithms? In-Reply-To: <4A0F0D65.5070600@gmail.com> References: <4A0F0D65.5070600@gmail.com> Message-ID: <20090516190849.GB7920@whirlpool.galois.com> thestonetable: > Hey, > > Besides fgl, are there any graph libraries in Haskell that are still > maintained? Are there other papers (or books) besides Erwig's that I > could use to understand how graph algorithms have been implemented in > functional languages? > Has anything even been published on the topic since Erwig's paper? > I think fgl is pretty much the main work on purely functional graphs, though Data.Graph ships in the containers package (Launchbury et al). A quick google also turned up: http://www.osl.iu.edu/research/comparing/haskell_readme.html which would be worth uploading to hackage... We don't seem to have a binding to any of the foreign language libs for very large graphs. -- Don From tracy.wadleigh at gmail.com Sat May 16 16:07:49 2009 From: tracy.wadleigh at gmail.com (Tracy Wadleigh) Date: Sat May 16 15:52:41 2009 Subject: [Haskell-cafe] Graphs and graph algorithms? In-Reply-To: <20090516190849.GB7920@whirlpool.galois.com> References: <4A0F0D65.5070600@gmail.com> <20090516190849.GB7920@whirlpool.galois.com> Message-ID: > > We don't seem to have a binding to any of the foreign language libs for > very large graphs. > > Do you know of any stand-out libraries in this regard worth binding? When I looked in to this last year, the best I could find was the boost library. It depends very heavily on template meta-programming, though, so it wouldn't really be bindable with any of the generality that it has in its native C++. I ask because I'm doing a lot of graph stuff in Haskell right now, and I might be willing to put in the effort to do the binding--especially while I still have c2hs syntax fresh in the brain: I just finished a complete re-write of the mathlink library (brings Haskell to Mathematica -- announcement to follow shortly). --Tracy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090516/8ca3e00b/attachment.html From phunge0 at hotmail.com Sat May 16 18:08:07 2009 From: phunge0 at hotmail.com (Brian Bloniarz) Date: Sat May 16 17:52:59 2009 Subject: [Haskell-cafe] Request for feedback: HaskellDB + HList Message-ID: Hi, It's come time to share something that I've been playing around with recently: a branch of HaskellDB which replaces the home-grown Record code with HList records. It's definitely not ready for primetime, but I thought it'd be a good time to post the code and solicit some feedback from the community. HaskellDB the concept is very promising, but IMHO the code still falls short of that promise. Hopefully this is a small step in the right direction -- the advantages of using HList: * Shared implementation of extensible records * Additional features from HList * Better error messages for record misuse * "Lacks" predicates * Simpler code As an example of how this can be better, a DB insert looks like so: > insert db table $ constantRecord $ > film .=. "Munchie" .*. > director .=. Just "Jim Wynorski" .*. > emptyRecord The columns need not appear in the same order as in the database. If you forget a column, you'll get "error: No instance for (Fail (FieldNotFound (Proxy Director)))" rather than an opaque error. Using the new "insertOpt" function, Maybe columns will default to Nothing rather than needing to be specified. The details: I haven't updated everything, but there's enough to run test/TestCases.hs under Postgresql. TestCases is probably the best place to look for examples of the new syntax for now. HList had name conflicts with HaskellDB's SQL expression language ((.*.), (.++.), etc.) My temporary band-aid is to move the expression functions to Database.HaskellDB.SqlExpr, and require people to import qualified. The Attr type is gone, columns labels are untyped now. I also replaced a few instances of primitive type-level recursion with HMap/HMapOut. This makes the code simpler, and the type signatures more complex -- type families would help a lot here, I think. Feedback welcome! You can find my darcs tree at: http://mysite.verizon.net/vzewxzuh/sitebuildercontent/sitebuilderfiles/haskelldb-hlist-20090516.tar.gz It also requires minor changes to HList, available at: http://mysite.verizon.net/vzewxzuh/sitebuildercontent/sitebuilderfiles/hlist-20090516.tar.gz I'll talk to the HList people about getting those merged. Thanks! Brian Bloniarz _________________________________________________________________ Hotmail? has a new way to see what's up with your friends. http://windowslive.com/Tutorial/Hotmail/WhatsNew?ocid=TXT_TAGLM_WL_HM_Tutorial_WhatsNew1_052009 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090516/040c26a2/attachment.html From gdweber at indiana.edu Sat May 16 19:07:55 2009 From: gdweber at indiana.edu (Gregory D. Weber) Date: Sat May 16 18:52:50 2009 Subject: [Haskell-cafe] Linkage errors in scenegraph Message-ID: <20090516230754.GA32509@squirrel.localdomain> I'd like to get the scenegraph package (http://hackage.haskell.org/cgi-bin/hackage-scripts/package/scenegraph) to work, but am encountering linkage errors. I installed scenegraph 0.1.0.1 for ghc-6.10.1 on Fedora 10 Linux. # runghc Setup configure --prefix=/opt # runghc Setup build # runghc Setup install Then I created this little program based on the example at http://www.haskell.org/haskellwiki/SceneGraph (in file SGTest.hs): module Main where import Graphics.SceneGraph import Control.Monad.Identity main :: IO () main = runScene $ osgt $ myScene myScene :: OSGT Identity SceneNode myScene = cube 0.5 `colour` Green `scale` v1x 40 `translate` vy 2 <+> camera `translate` vy (-10) <+> light `translate` vz 10 Then I compiled it and got a long list of linker errors; here are the first few lines: ghc --make SGTest Linking SGTest ... /opt/lib/scenegraph-0.1.0.1/ghc-6.10.1/libHSscenegraph-0.1.0.1.a(Basic__210.o): In function `sdE1_info': (.text+0x8d): undefined reference to `scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_translateM_closure' /opt/lib/scenegraph-0.1.0.1/ghc-6.10.1/libHSscenegraph-0.1.0.1.a(Basic__210.o): In function `scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziBasic_translate_srt': (.data+0x0): undefined reference to `scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_translateM_closure' /opt/lib/scenegraph-0.1.0.1/ghc-6.10.1/libHSscenegraph-0.1.0.1.a(Basic__207.o): In function `sdDq_info': (.text+0x7e): undefined reference to `scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_scaleM_info' /opt/lib/scenegraph-0.1.0.1/ghc-6.10.1/libHSscenegraph-0.1.0.1.a(Basic__207.o): In function `scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziBasic_scale_srt': (.data+0x0): undefined reference to `scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_scaleM_closure' /opt/lib/scenegraph-0.1.0.1/ghc-6.10.1/libHSscenegraph-0.1.0.1.a(Basic__491.o):(.text+0x27): undefined reference to `__stginit_scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziUtils_' Also with this command, same result but a lot more detail: ghc --make -v -package scenegraph SGTest With -v, the output includes gcc -v -o SGTest -DDONT_WANT_WIN32_DLL_SUPPORT SGTest.o -L/opt/lib/scenegraph-0.1.0.1/ghc-6.10.1 -L/opt/lib/hmatrix-0.5.1.1/ghc-6.10.1 -L/opt/lib/storable-complex-0.2/ghc-6.10.1 ... -lHSscenegraph-0.1.0.1 -lHShmatrix-0.5.1.1 -lgsl -llapack -lHSstorable-complex-0.2 -lHSQuickCheck-1.2.0.0 ... which seems to show that the proper -L and -l options are included. If I'm decoding the first "undefined reference" symbol -- (.text+0x8d): undefined reference to `scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_translateM_closure' -- correctly, then the missing symbol is in the scenegraph-0.1.0.1 package, in module Graphics.SceneGraph.Matrix, and is associated with the translateM function defined in that module. I looked for this symbol with nm: # pwd /opt/lib/scenegraph-0.1.0.1/ghc-6.10.1 # nm HSscenegraph-0.1.0.1.o | grep translateM U scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_translateM_closure U scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_translateM_info # nm libHSscenegraph-0.1.0.1.a | grep translateM U scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_translateM_closure U scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_translateM_info but I understand the "U" means that it is referenced by some other function in these files, but is undefined in them. Since the module Graphics.SceneGraph.Matrix does not declare any exports, I thought that might be the reason the symbol was undefined. But looking back at the Haskell 98 language definition, I found that the absence of an export declaration in a module means that all the symbols of the module are exported. Also, I notice that in the cabal file for scenegraph, the list of exposed modules Exposed-Modules: Graphics.SceneGraph, Graphics.SceneGraph.Basic, Graphics.SceneGraph.Vector, Graphics.SceneGraph.Render, Graphics.SceneGraph.SimpleViewport, Graphics.SceneGraph.GraphViz, Graphics.SceneGraph.Library, Graphics.SceneGraph.Dump, Graphics.SceneGraph.Textures does not include Graphics.SceneGraph.Matrix, but that should only mean that I can't call functions of that module directly -- not that the other SceneGraph modules can't call them -- right? So, why is this symbol undefined? And how can I get it to work? Oh by the way: I can actually use this package if I move into its src directory, add a main function to Examples.hs, and compile and run it right there. Just can't use it as an installed library, it seems. -- ___ ___ __ _ / _ \ / _ \| | | | Gregory D. Weber, Associate Professor / /_\// / | | | /\ | | Indiana University East / /_\\/ /__| | |/ \| | http://mypage.iu.edu/~gdweber/ \____/\_____/\___/\__/ Tel. (765) 973-8420; FAX (765) 973-8550 From vigalchin at gmail.com Sat May 16 19:44:11 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Sat May 16 19:36:10 2009 Subject: [Haskell-cafe] Data.FiniteMap deprecrated In-Reply-To: <5e0214850905152305g4a0443fbvd2ef8e5bfbc7e4e8@mail.gmail.com> References: <5ae4f2ba0905152258y12dfd28bw11d367969ea833ef@mail.gmail.com> <5e0214850905152305g4a0443fbvd2ef8e5bfbc7e4e8@mail.gmail.com> Message-ID: <5ae4f2ba0905161644v4d4c381dgadec3319430d298c@mail.gmail.com> Yevgeni, I am specifying "base" as a Cabal dependency ... dumb question ... I have forgotten whether I need to import Data.Map also? Vasili On Sat, May 16, 2009 at 1:05 AM, Eugene Kirpichov wrote: > It's Data.Map. It's in the base package. > > 2009/5/16 Vasili I. Galchin : > > Hello, > > > > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/FiniteMap > > ... since this is deprecated what is the orthodox way to implement > "finite > > map"?? > > > > Thanks, > > > > Vasili > > > > _______________________________________________ > > 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/20090516/f2d4b820/attachment.html From alexander.dunlap at gmail.com Sat May 16 19:57:42 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Sat May 16 19:42:53 2009 Subject: [Haskell-cafe] Data.FiniteMap deprecrated In-Reply-To: <5ae4f2ba0905161644v4d4c381dgadec3319430d298c@mail.gmail.com> References: <5ae4f2ba0905152258y12dfd28bw11d367969ea833ef@mail.gmail.com> <5e0214850905152305g4a0443fbvd2ef8e5bfbc7e4e8@mail.gmail.com> <5ae4f2ba0905161644v4d4c381dgadec3319430d298c@mail.gmail.com> Message-ID: <57526e770905161657o2b02555fva0e13c328840ee87@mail.gmail.com> You need to include the "containers" package in your cabal file. Alex On Sat, May 16, 2009 at 4:44 PM, Vasili I. Galchin wrote: > Yevgeni, > > ???? I am specifying "base" as a Cabal dependency ...? dumb question ... I > have forgotten whether I need to import Data.Map also? > > Vasili > > On Sat, May 16, 2009 at 1:05 AM, Eugene Kirpichov > wrote: >> >> It's Data.Map. It's in the base package. >> >> 2009/5/16 Vasili I. Galchin : >> > Hello, >> > >> > >> > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/FiniteMap >> > ... since this is deprecated what is the orthodox way to implement >> > "finite >> > map"?? >> > >> > Thanks, >> > >> > Vasili >> > >> > _______________________________________________ >> > 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 vigalchin at gmail.com Sat May 16 20:03:29 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Sat May 16 19:48:19 2009 Subject: [Haskell-cafe] Data.FiniteMap deprecrated In-Reply-To: <57526e770905161657o2b02555fva0e13c328840ee87@mail.gmail.com> References: <5ae4f2ba0905152258y12dfd28bw11d367969ea833ef@mail.gmail.com> <5e0214850905152305g4a0443fbvd2ef8e5bfbc7e4e8@mail.gmail.com> <5ae4f2ba0905161644v4d4c381dgadec3319430d298c@mail.gmail.com> <57526e770905161657o2b02555fva0e13c328840ee87@mail.gmail.com> Message-ID: <5ae4f2ba0905161703x248713dai40cd894db8fe0a11@mail.gmail.com> yeah .... I do .... ghc can't find the "Map" constructor ...... also in another module Parsec is being used ... I have parsec as a dependecy in my cabal file and I also have an "import Text.Parsec" but ghc "could not find module Text.Parsec". ??? Thanks, Vasili On Sat, May 16, 2009 at 6:57 PM, Alexander Dunlap < alexander.dunlap@gmail.com> wrote: > You need to include the "containers" package in your cabal file. > > Alex > > On Sat, May 16, 2009 at 4:44 PM, Vasili I. Galchin > wrote: > > Yevgeni, > > > > I am specifying "base" as a Cabal dependency ... dumb question ... > I > > have forgotten whether I need to import Data.Map also? > > > > Vasili > > > > On Sat, May 16, 2009 at 1:05 AM, Eugene Kirpichov > > wrote: > >> > >> It's Data.Map. It's in the base package. > >> > >> 2009/5/16 Vasili I. Galchin : > >> > Hello, > >> > > >> > > >> > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/FiniteMap > >> > ... since this is deprecated what is the orthodox way to implement > >> > "finite > >> > map"?? > >> > > >> > Thanks, > >> > > >> > Vasili > >> > > >> > _______________________________________________ > >> > 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 > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090516/765596c6/attachment.html From alexander.dunlap at gmail.com Sat May 16 20:21:14 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Sat May 16 20:07:11 2009 Subject: [Haskell-cafe] Data.FiniteMap deprecrated In-Reply-To: <5ae4f2ba0905161703x248713dai40cd894db8fe0a11@mail.gmail.com> References: <5ae4f2ba0905152258y12dfd28bw11d367969ea833ef@mail.gmail.com> <5e0214850905152305g4a0443fbvd2ef8e5bfbc7e4e8@mail.gmail.com> <5ae4f2ba0905161644v4d4c381dgadec3319430d298c@mail.gmail.com> <57526e770905161657o2b02555fva0e13c328840ee87@mail.gmail.com> <5ae4f2ba0905161703x248713dai40cd894db8fe0a11@mail.gmail.com> Message-ID: <57526e770905161721v594d2ab5w6989b8c053e3d083@mail.gmail.com> You need to import Data.Map in any file you use Map in. Which version of Parsec are you using? Versions before 3.0.0 do not have a module called Text.Parsec, the module is Text.ParserCombinators.Parsec (or something like that). Alex On Sat, May 16, 2009 at 5:03 PM, Vasili I. Galchin wrote: > yeah .... I do .... ghc can't find the "Map" constructor ...... > > also in another module Parsec is being used ... I have parsec as a dependecy > in my cabal file and I also have an "import Text.Parsec" but ghc "could not > find module Text.Parsec". ??? > > Thanks, Vasili > > On Sat, May 16, 2009 at 6:57 PM, Alexander Dunlap > wrote: >> >> You need to include the "containers" package in your cabal file. >> >> Alex >> >> On Sat, May 16, 2009 at 4:44 PM, Vasili I. Galchin >> wrote: >> > Yevgeni, >> > >> > ???? I am specifying "base" as a Cabal dependency ...? dumb question ... >> > I >> > have forgotten whether I need to import Data.Map also? >> > >> > Vasili >> > >> > On Sat, May 16, 2009 at 1:05 AM, Eugene Kirpichov >> > wrote: >> >> >> >> It's Data.Map. It's in the base package. >> >> >> >> 2009/5/16 Vasili I. Galchin : >> >> > Hello, >> >> > >> >> > >> >> > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/FiniteMap >> >> > ... since this is deprecated what is the orthodox way to implement >> >> > "finite >> >> > map"?? >> >> > >> >> > Thanks, >> >> > >> >> > Vasili >> >> > >> >> > _______________________________________________ >> >> > 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 byorgey at seas.upenn.edu Sat May 16 21:32:23 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat May 16 21:17:14 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 118 - May 16, 2009 Message-ID: <20090517013223.GA7220@seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090516 Issue 118 - May 16, 2009 --------------------------------------------------------------------------- Welcome to issue 118 of HWN, a newsletter covering developments in the [1]Haskell community. Welcome to the Google Summer of Code special edition! I asked each of the five students with accepted GSoC projects to describe what they plan to work on. You'll find their descriptions below, with links to their blogs. And keep watching this space: as I did last summer, I plan to provide readers of the HWN with weekly updates on the progress of the GSoC projects. Google Summer of Code Haddock improvements! Isaac Dupree is [2]working on improvements to [3]Haddock. "Besides the various inevitable small fixes/improvements, my specific projects are to make cross-package documentation work, and to refactor the comment-parsing out of GHC and into the Haddock code-base." EclipseFP. Thomas Ten Cate will be [4]working on EclipseFP: "Compared to more mainstream languages, Haskell has surprisingly poor IDE support, even though its static typing system allows for much more help from the IDE than in the case of dynamic languages. For the Java language, a very mature and powerful IDE exists in the form of Eclipse. A plugin for Haskell support in Eclipse, called EclipseFP, is in the works, but its development has been standing still for some time. I will bring EclipseFP to a more usable state. For this, I will use the Scion IDE library, which interfaces with the GHC API, so that more advanced features like type inference become possible. I will also add support for Cabal. Hopefully, this type of IDE support will lead to greater acceptance and use of Haskell, and be useful for development as well as education." Improving the Haskell space profiling experience. Gergely Patai's [5]project will be focused on space profiling: "At the present moment, heap profiling Haskell programs means analysing logs off-line, using conversion tools to visualise data. However, instead of generating graphs with hp2ps, it should be possible to present the data in a graphical application in real time, which is useful while developing interactive applications, and it should also be made easier to export profiler output in different formats. The aim of the project is to create a set of tools that make heap profiling of Haskell programs easier in various ways. In particular, the following components are planned: a library to process profiler output in an efficient way and make it easily accessible for other tools in the future; a real-time visualiser (most likely using OpenGL); some kind of history manager to keep track of profiling data and make it possible to perform a comparative analysis of performance between different versions of your program; a maintainable and extensible replacement for hp2ps; and converters to provide input for other profiling tools." haskell-src-exts -> haskell-src. Niklas Broberg: "My [6]project, dubbed 'haskell-src-exts -> haskell-src' is really two projects in one wrapping. The first milestone is to bring my haskell-src-exts library to the point where it can supersede the old haskell-src library as the de facto package for haskell source manipulation. The main problem that I need to solve is to implement a scheme that lets the user decide what extensions to recognize when parsing a source document. Currently, haskell-src-exts assumes all extensions are always on, which means that some valid H98 programs will be incorrectly parsed due to stolen syntax by e.g. Template Haskell. The second milestone is to extend the focus from source code to full source documents, and implement a scheme for handling comments as well. The ultimate goal here is to have (pretty . parse) == id, to allow haskell-src-exts to be run on source documents without changing them. This would open up for some really interesting applications, in particular refactoring tools that could automatically apply transformations to a source document while still preserving comments." darcs. Last but not least, Petr Rockai will be [7]working on improvements to [8]darcs: "My project revolves around the idea of fast darcs for medium and large repositories. Three are quite a few haskellers who use darcs in their day to day (haskell) work. A fair number of hackage packages is maintained in darcs. Even though many of these repositories are of a relatively modest size, there is a number of relatively large real-world darcs repositories out there. The primary target of the project is to improve scalability of darcs for large working trees. This should help those users with existing large darcs repositories, as well as encourage people to use darcs for larger projects, whenever the development model fits. I intend to make the darcs working tree handling comparably fast to git. And then, git is written in C, hand-tuned for a specific operating system. And unlike mercurial, I do not plan to introduce a C library for low level routines. So let's prove that Haskell is up to the challenge." Announcements 2009.2.1: version freeze for Haskell Platform approaching on Monday. Don Stewart [9]announced that the last chance to propose bug fix version bumps to be included in the first minor release (2009.2.1) of the [10]Haskell Platform is Monday. Please ensure that, as maintainer for one of the 2009.2.x series of packages, any bug fixes are in place by Monday, or they'll be bumped to the next platform release. OpenGL 2.2.3.0. Sven Panne [11]announced the release of a new version of the [12]OpenGL package. This is a feature release, containing a number of changes and additions. Programming in Haskell -- solutions to exercises. Graham Hutton [13]announced that solutions to the exercises from "Programming in Haskell" are now [14]available online. Bookshelf. Emil Axelsson [15]announced the first release of [16]Bookshelf, a simple document organizer with some wiki functionality. Documents in a directory tree are displayed as a set of HTML pages. Documents in Markdown format are converted to HTML automatically using Pandoc. Request for feedback: HaskellDB + HList. Brian Bloniarz [17]requested feedback on a branch of [18]HaskellDB which replaces the home-grown Record code with HList records. RESTng 0.1 + RedHandlers 0.1 (request handlers) + YuiGrids 0.1 (yahoo grids). Sergio Urinovsky [19]announced the release of three new packages developed for a RESTful web framework called RESTng: [20]RESTng, [21]redHandlers, and [22]yuiGrid. #haskell.pt IRC channel. Marco T?lio Gontijo e Silva [23]announced the formation of the #haskell.pt channel on irc.freenode.net for Portuguese-speaking Haskellers. Fun with type functions. Simon Peyton-Jones [24]requested feedback on a [25]draft tutorial paper about type families (aka associated data types, or type functions). Discussion conflicting variable definitions in pattern. Martin Hofmann [26]asked about the possibility of repeated variables in patterns, resulting in an interesting discussion. Removing mtl from the Haskell Platform. Russell O'Connor began a [27]discussion around the possibility of removing the mtl package from the Haskell Platform, and replacing it with something more modern. Jobs PhD position in Nottingham. vxc [28]announced the availability of a new PhD position in the Functional Programming Laboratory at the University of Nottingham. The topic of research for the project is "Programming and Reasoning with Infinite Structures": it consists in the theoretical study and development of software tools for coinductive types and structured corecursion. Blog noise [29]Haskell news from the [30]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Leif Frenzel: [31]EclipseFP is going to be reloaded. * Tom Schrijvers: [32]Dictionaries: Eager or Lazy Type Class Witnesses?. Can type class dictionaries be optimized by treating them strictly? * Real-World Haskell: [33]RWH Now In The Kindle Store. * JP Moresmau: [34]Adding a Writer Monad transformer. * Ketil Malde: [35]Using a phantom type to label different kinds of sequences. * Ivan Lazar Miljenovic: [36]Functions All The Way Down. Ivan's talk on lambda calculus. * Thomas M. DuBuisson: [37]Fun with Distributed Hash Tables. Distributed hash tables in Haskell. * Darcs: [38]darcs joins the Software Freedom Conservancy. * Mark Wassell: [39]Just Grapefruit. Mark's first impressions of the Grapefruit library. * Roman Cheplyaka: [40]LambdaCube accepted to JSSP. Jane Street is funding development of the LambdaCube 3D rendering engine. * >>> Joel Neely: [41]BuilderBuilder: The Model in Haskell. * Brandon Simmons: [42]directory-tree module released. * >>> Sadek Drobi: [43]Paul Hudak on Haskell. An interview with Paul Hudak. * >>> dayvan cowboy: [44]Blast from the past: a stochastic monad in Haskell. * Matthew Podwysocki: [45]Type Classes Are The Secret Sauce . * Remco Niemeijer: [46]Programming Praxis - Priority Queues. A priority queue implementation using a leftist heap. * >>> Y. Liang: [47]A Lambda Calculus Interpreter in Haskell. Quotes of the Week * seydar: what's the nick of the drug addict who wrote learn you a haskell? and i mean that in the best possible way. * roconnor: String is kinda a poor data type for strings. * kyevan: I had a haskell-related dream last night. Sorta. I was beaten up by some kids because I tried to go somewhere my type didn't match, apparently. * edwardk: Haskell 98 is the Windows 98 of standards ;) * PhilipWadler: I'm delighted to learn that "a monad is a monoid in the category of endofunctors"---anyone know where I can find a good tutorial? * David Leimbach: Don't play with your monads... eventually you'll go bind. About the Haskell Weekly News New editions are posted to [48]the Haskell mailing list as well as to [49]the Haskell Sequence and [50]Planet Haskell. [51]RSS is also available, and headlines appear on [52]haskell.org. To help create new editions of this newsletter, please see the information on [53]how to contribute. Send stories to byorgey at cis dot upenn dot edu. The darcs repository is available at darcs get [54]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://haddock2009.wordpress.com/ 3. http://www.haskell.org/haddock/ 4. http://eclipsefp.wordpress.com/ 5. http://just-bottom.blogspot.com/ 6. http://nibrofun.blogspot.com/ 7. http://web.mornfall.net/tag/darcs.html 8. http://darcs.net/ 9. http://article.gmane.org/gmane.comp.lang.haskell.libraries/11120 10. http://trac.haskell.org/haskell-platform/ 11. http://article.gmane.org/gmane.comp.lang.haskell.general/17194 12. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/OpenGL 13. http://article.gmane.org/gmane.comp.lang.haskell.general/17193 14. http://www.cs.nott.ac.uk/~gmh/book.html 15. http://article.gmane.org/gmane.comp.lang.haskell.general/17182 16. http://www.cs.chalmers.se/~emax/bookshelf/Manual.shelf.html 17. http://article.gmane.org/gmane.comp.lang.haskell.cafe/58615 18. http://haskelldb.sourceforge.net/ 19. http://article.gmane.org/gmane.comp.lang.haskell.cafe/58589 20. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/RESTng 21. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/redHandlers 22. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/yuiGrid 23. http://article.gmane.org/gmane.comp.lang.haskell.cafe/58581 24. http://article.gmane.org/gmane.comp.lang.haskell.cafe/58522 25. http://haskell.org/haskellwiki/Simonpj/Talk:FunWithTypeFuns 26. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/58560 27. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/58430 28. http://article.gmane.org/gmane.comp.lang.haskell.cafe/58526 29. http://planet.haskell.org/ 30. http://haskell.org/haskellwiki/Blog_articles 31. http://cohatoe.blogspot.com/2009/05/eclipsefp-is-going-to-be-reloaded.html 32. http://tomschrijvers.blogspot.com/2009/05/dictionaries-eager-or-lazy-type-class.html 33. http://www.realworldhaskell.org/blog/2009/05/15/rwh-now-in-the-kindle-store/ 34. http://jpmoresmau.blogspot.com/2009/05/adding-writer-monad-transformer.html 35. http://blog.malde.org/index.php/2009/05/14/using-a-phantom-type-to-label-different-kinds-of-sequences/ 36. http://ivanmiljenovic.wordpress.com/2009/05/14/functions-all-the-way-down/ 37. http://tommd.wordpress.com/2009/05/13/fun-with-distributed-hash-tables/ 38. http://blog.darcs.net/2009/05/darcs-joins-software-freedom.html 39. http://www.poundstone.org/blog/?p=165 40. http://physics-dph.blogspot.com/2009/05/lambdacube-accepted-to-jssp.html 41. http://joelneely.wordpress.com/2009/05/09/builderbuilder-the-model-in-haskell/ 42. http://coder.bsimmons.name/blog/2009/05/directory-tree-module-released/ 43. http://www.infoq.com/interviews/paul-hudak-haskell-Qcon-SF-08 44. http://dayvancowboy.org/2009/05/08/blast-from-the-past-a-stochastic-monad-in-haskell/ 45. http://codebetter.com/blogs/matthew.podwysocki/archive/2009/05/08/type-classes-are-the-secret-sauce.aspx 46. http://bonsaicode.wordpress.com/2009/05/05/programming-praxis-priority-queues/ 47. http://yiopposite.blogspot.com/2009/05/lambda-calculus-interpreter-in-haskell.html 48. http://www.haskell.org/mailman/listinfo/haskell 49. http://sequence.complete.org/ 50. http://planet.haskell.org/ 51. http://sequence.complete.org/node/feed 52. http://haskell.org/ 53. http://haskell.org/haskellwiki/HWN 54. http://code.haskell.org/~byorgey/code/hwn/ From vigalchin at gmail.com Sun May 17 02:32:23 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Sun May 17 02:17:13 2009 Subject: [Haskell-cafe] Haskell philosophy question Message-ID: <5ae4f2ba0905162332q6d8563ebpee6a2a00ad362f49@mail.gmail.com> Hello, I am confused between Haskell as delineated in the Haskell Report VS ghc "pragmas" which extend Haskell beyond the Haskell Report. I am sure I am not the first to ask. Caveat: on my part, I am not against innovation/extensions, but I don't like to see language "bloat". This is not a negative/pegorative statement .... just a challenging one. Kind regards, vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090517/8d724121/attachment.html From allbery at ece.cmu.edu Sun May 17 02:42:52 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sun May 17 02:27:59 2009 Subject: [Haskell-cafe] Haskell philosophy question In-Reply-To: <5ae4f2ba0905162332q6d8563ebpee6a2a00ad362f49@mail.gmail.com> References: <5ae4f2ba0905162332q6d8563ebpee6a2a00ad362f49@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/20090517/5eccaf5e/PGP.bin From dominic at steinitz.org Sun May 17 04:17:04 2009 From: dominic at steinitz.org (Dominic Steinitz) Date: Sun May 17 03:03:45 2009 Subject: [Haskell-cafe] Cabal, Time & GHC 6.10.2 Message-ID: <4A0FC800.1070909@steinitz.org> I get > dom@linux-6ofq:~/asn1> runghc Setup.hs configure > Configuring PER-0.0.20... > Setup.hs: At least the following dependencies are missing: > time -any && -any but I have time > dom@linux-6ofq:~/asn1> ghc-pkg list | grep time > old-locale-1.0.0.1, old-time-1.0.0.2, packedstring-0.1.0.1, > time-1.1.2.4 I think I can see why cabal isn't finding it: > ghc-pkg dump --global | grep time-1.1.2.4 finds nothing and I believe that is what cabal uses to find things. What's not clear is what I do to fix things. Go back to 6.10.1? Thanks, Dominic. > dom@linux-6ofq:~/asn1> ghc --version > The Glorious Glasgow Haskell Compilation System, version 6.10.2 > dom@linux-6ofq:~/asn1> ghc-pkg --version > GHC package manager version 6.10.2 Here's my .cabal file. > Name: PER > Version: 0.0.20 > License: BSD3 > Author: Dominic Steinitz > Maintainer: dominic.steinitz@blueyonder.co.uk > Copyright: Dominic Steinitz 2003 - 2009 > Stability: Alpha > Category: Language > Homepage: http://www.haskell.org/asn1 > Synopsis: ASN.1 PER support for Haskell > Description: A formal and executable specification of the Packed Encoding Rules (PER) > for ASN.1 > build-depends: binary-strict == 0.4.2, > bytestring, > mtl, > containers, > time, > pretty, > base > build-type: custom > > Exposed-Modules: Language.ASN1.PER.Integer > Language.ASN1.PER.GenerateC > > Executable: PERTest > Main-Is: PERTest.hs From colin at colina.demon.co.uk Sun May 17 04:17:11 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sun May 17 04:02:00 2009 Subject: [Haskell-cafe] Can't install happs-tutorial because syb-with-class fails to install Message-ID: Data/Generics/SYB/WithClass/Derive.hs:187:26: Couldn't match expected type `Pred' against inferred type `Type' Expected type: PredQ Inferred type: TypeQ In the first argument of `map', namely `dataCxt' In the first argument of `(++)', namely `map dataCxt dataCxtTypes' Data/Generics/SYB/WithClass/Derive.hs:198:36: Couldn't match expected type `Pred' against inferred type `Type' Expected type: Q Pred Inferred type: TypeQ In the expression: conT 'Data `appT` typ In the first argument of `map', namely `(\ typ -> conT 'Data `appT` typ)' Data/Generics/SYB/WithClass/Derive.hs:227:38: Couldn't match expected type `Name' against inferred type `TyVarBndr' Expected type: [Name] Inferred type: [TyVarBndr] In the expression: ps In the first argument of `return', namely `(n, ps, map conA cs)' cabal: Error: some packages failed to install: syb-with-class-0.5.1 failed during the building phase. The exception was: exit: ExitFailure 1 -- Colin Adams Preston Lancashire From duncan.coutts at worc.ox.ac.uk Sun May 17 04:59:38 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun May 17 04:44:46 2009 Subject: [Haskell-cafe] Cabal, Time & GHC 6.10.2 In-Reply-To: <4A0FC800.1070909@steinitz.org> References: <4A0FC800.1070909@steinitz.org> Message-ID: <1242550778.20960.19.camel@localhost> On Sun, 2009-05-17 at 09:17 +0100, Dominic Steinitz wrote: > I get > > > dom@linux-6ofq:~/asn1> runghc Setup.hs configure > > Configuring PER-0.0.20... > > Setup.hs: At least the following dependencies are missing: > > time -any && -any > > but I have time > > > dom@linux-6ofq:~/asn1> ghc-pkg list | grep time > > old-locale-1.0.0.1, old-time-1.0.0.2, packedstring-0.1.0.1, > > time-1.1.2.4 > > I think I can see why cabal isn't finding it: > > > ghc-pkg dump --global | grep time-1.1.2.4 > > finds nothing and I believe that is what cabal uses to find things. The default for "runghc Setup.hs configure" is --global, but the default for "cabal configure" is --user. So if you're using the "cabal" program to install packages, then you can also us it to configure other packages. If for you need to use the runghc Setup.hs interface (e.g. in some system build scripts) and you want it to pick up packages from the user package db then use the --user flag. If you're constantly having to use the runghc Setup.hs interface and doing per-user installs is a pain then you can set the default for the cabal program to be global installs in the cabal config file (~/.cabal/config). I'll add this issue to the FAQ, it come up enough. If anyone else reading would like to eliminate this FAQ, then implementing this ticket is the answer: suggest use of --user if configure fails with missing deps that are in the user db http://hackage.haskell.org/trac/hackage/ticket/384 Duncan From Sven.Panne at aedion.de Sun May 17 06:21:08 2009 From: Sven.Panne at aedion.de (Sven Panne) Date: Sun May 17 06:06:02 2009 Subject: [Haskell-cafe] Linkage errors in scenegraph In-Reply-To: <20090516230754.GA32509@squirrel.localdomain> References: <20090516230754.GA32509@squirrel.localdomain> Message-ID: <200905171221.09100.Sven.Panne@aedion.de> Am Sonntag, 17. Mai 2009 01:07:55 schrieb Gregory D. Weber: > I'd like to get the scenegraph package > (http://hackage.haskell.org/cgi-bin/hackage-scripts/package/scenegraph) > to work, but am encountering linkage errors. > [...] > Also, I notice that in the cabal file for scenegraph, the > list of exposed modules > > Exposed-Modules: Graphics.SceneGraph, > Graphics.SceneGraph.Basic, > Graphics.SceneGraph.Vector, > Graphics.SceneGraph.Render, > Graphics.SceneGraph.SimpleViewport, > Graphics.SceneGraph.GraphViz, > Graphics.SceneGraph.Library, > Graphics.SceneGraph.Dump, > Graphics.SceneGraph.Textures > > does not include Graphics.SceneGraph.Matrix, but that should only mean > that I can't call functions of that module directly -- not that the > other SceneGraph modules can't call them -- right? [...] That basically means that the scenegraph package is broken. ;-) Internal modules have to be listed in "other-modules:", a section the Cabal file doesn't contain. As a quick fix, you can add all missing modules in this section, but this should of course be fixed in the official package, too. http://www.haskell.org/cabal/release/cabal-latest/doc/users- guide/authors.html#buildinfo Cheers, S. From Sven.Panne at aedion.de Sun May 17 07:04:43 2009 From: Sven.Panne at aedion.de (Sven Panne) Date: Sun May 17 06:49:38 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding In-Reply-To: <20090515043722.GG31768@whirlpool.galois.com> References: <3e1162e60905142057u51f31009id58c981795c9d99f@mail.gmail.com> <7CA1B7BF2916F0418CAB6E705BC1224A375341@ntsydexm04.pc.internal.macquarie.com> <20090515043722.GG31768@whirlpool.galois.com> Message-ID: <200905171304.43292.Sven.Panne@aedion.de> Am Freitag, 15. Mai 2009 06:37:22 schrieb Don Stewart: > timd: > > On a related matter, I am using Data.Binary to serialise data from > > haskell for use from other languages. [...] > [...] > Yep, it's possible, just not portably so. Google for Data.Binary IEEE > discussions. I think this topic pops up over and over again, and the proposed "solutions" are no solutions at all, neither from a performance point of view, nor from an ease of use point of view. Proposing insane bit fiddling by hand when all one technically needs is often a "peek" or "poke" amounts to simply ignoring an API problem. ;-) I think most problems can be fixed in a rather pragmatic way by adding a few functions to the binary package: Add to Data.Binary.Builder: putFloatIEEEbe :: Float -> Builder putDoubleIEEEbe :: Double -> Builder putFloatIEEEle :: Float -> Builder putDoubleIEEEle :: Double -> Builder putFloatIEEEhost :: Float -> Builder putDoubleIEEEhost :: Double -> Builder Add to Data.Binary.Get: getFloatIEEEbe :: Get Float getDoubleIEEEbe :: Get Double getFloatIEEEle :: Get Float getDoubleIEEEle :: Get Double getFloatIEEEhost :: Get Float getDoubleIEEEhost :: Get Double Add to Data.Binary.Put: putFloatIEEEbe :: Float -> Put putDoubleIEEEbe :: Double -> Put putFloatIEEEle :: Float -> Put putDoubleIEEEle :: Double -> Put putFloatIEEEhost :: Float -> Put putDoubleIEEEhost :: Double -> Put The *host functions are basically peek/poke for most platforms. The *le/*be functions can use peek/poke if the endianess matches (compile time decision) *and* the alignment is OK for the given platform (runtime decision). Non-IEEE platforms always have to do the bit fiddling internally, but all this is hidden behind the above API. IIRC I have proposed something similar 1-2 years ago, but I can't remember any reason why this hasn't been implemented. Any comments on the above functions? One final remarks: I think the low level functions of the binary package should really keep the notions of "endianess" and "alignment constraints" separate, something which isn't done currently: The *host functions have alignment restrictions, the *be/*le functions don't. There is no good reason for this non-orthogonality. Cheers, S. From colin at colina.demon.co.uk Sun May 17 07:19:34 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sun May 17 07:04:24 2009 Subject: [Haskell-cafe] Can't install happs-tutorial because syb-with-class fails to install In-Reply-To: (Colin Paul Adams's message of "Sun\, 17 May 2009 09\:17\:11 +0100") References: Message-ID: False alarm. It compiles OK with ghc 6.10.3. The failure was with ghc 6.11.20090404. -- Colin Adams Preston Lancashire From dons at galois.com Sun May 17 09:08:29 2009 From: dons at galois.com (Don Stewart) Date: Sun May 17 08:54:49 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding In-Reply-To: <200905171304.43292.Sven.Panne@aedion.de> References: <3e1162e60905142057u51f31009id58c981795c9d99f@mail.gmail.com> <7CA1B7BF2916F0418CAB6E705BC1224A375341@ntsydexm04.pc.internal.macquarie.com> <20090515043722.GG31768@whirlpool.galois.com> <200905171304.43292.Sven.Panne@aedion.de> Message-ID: <20090517130829.GA11021@whirlpool.galois.com> Sven.Panne: > Am Freitag, 15. Mai 2009 06:37:22 schrieb Don Stewart: > > timd: > > > On a related matter, I am using Data.Binary to serialise data from > > > haskell for use from other languages. [...] > > [...] > > Yep, it's possible, just not portably so. Google for Data.Binary IEEE > > discussions. > > I think this topic pops up over and over again, and the proposed "solutions" > are no solutions at all, neither from a performance point of view, nor from an > ease of use point of view. Proposing insane bit fiddling by hand when all one > technically needs is often a "peek" or "poke" amounts to simply ignoring an > API problem. ;-) > > I think most problems can be fixed in a rather pragmatic way by adding a few > functions to the binary package: > > Add to Data.Binary.Builder: > > putFloatIEEEbe :: Float -> Builder > putDoubleIEEEbe :: Double -> Builder > putFloatIEEEle :: Float -> Builder > putDoubleIEEEle :: Double -> Builder > putFloatIEEEhost :: Float -> Builder > putDoubleIEEEhost :: Double -> Builder > > Add to Data.Binary.Get: > > getFloatIEEEbe :: Get Float > getDoubleIEEEbe :: Get Double > getFloatIEEEle :: Get Float > getDoubleIEEEle :: Get Double > getFloatIEEEhost :: Get Float > getDoubleIEEEhost :: Get Double > > Add to Data.Binary.Put: > > putFloatIEEEbe :: Float -> Put > putDoubleIEEEbe :: Double -> Put > putFloatIEEEle :: Float -> Put > putDoubleIEEEle :: Double -> Put > putFloatIEEEhost :: Float -> Put > putDoubleIEEEhost :: Double -> Put > > The *host functions are basically peek/poke for most platforms. The *le/*be > functions can use peek/poke if the endianess matches (compile time decision) > *and* the alignment is OK for the given platform (runtime decision). Non-IEEE > platforms always have to do the bit fiddling internally, but all this is > hidden behind the above API. > > IIRC I have proposed something similar 1-2 years ago, but I can't remember any > reason why this hasn't been implemented. Any comments on the above functions? Patches are welcome. > One final remarks: I think the low level functions of the binary package > should really keep the notions of "endianess" and "alignment constraints" > separate, something which isn't done currently: The *host functions have > alignment restrictions, the *be/*le functions don't. There is no good reason > for this non-orthogonality. That seems reasonable. -- Don From dons at galois.com Sun May 17 09:16:56 2009 From: dons at galois.com (Don Stewart) Date: Sun May 17 09:03:12 2009 Subject: [Haskell-cafe] Re: Haskell philosophy question In-Reply-To: <5ae4f2ba0905162332q6d8563ebpee6a2a00ad362f49@mail.gmail.com> References: <5ae4f2ba0905162332q6d8563ebpee6a2a00ad362f49@mail.gmail.com> Message-ID: <20090517131656.GB11057@whirlpool.galois.com> vigalchin: > Hello, > > I am confused between Haskell as delineated in the Haskell Report VS ghc > "pragmas" which extend Haskell beyond the Haskell Report. I am sure I am not > the first to ask. Caveat: on my part, I am not against innovation/extensions, > but I don't like to see language "bloat". This is not a negative/pegorative > statement .... just a challenging one. They add new features, which are useful for determining what features are useful :) -- Don From nowgate at yahoo.com Sun May 17 09:25:45 2009 From: nowgate at yahoo.com (michael rice) Date: Sun May 17 09:10:34 2009 Subject: [Haskell-cafe] Building a better dog house? Message-ID: <545876.48952.qm@web31102.mail.mud.yahoo.com> I was just looking at my UML (Unified Modeling Language) User Guide and discovered this: "The number of object-oriented methods increased from fewer than 10 to more than 50 during the period between 1989 and 1994." pg. xviii, Booch, Rumbaugh, Jacobson, 1999 Is there a modeling methodology recommended for functional languages? Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090517/1fa5ed6a/attachment.html From jason.dusek at gmail.com Sun May 17 09:45:25 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Sun May 17 09:30:14 2009 Subject: [Haskell-cafe] Re: [Haskell] [ANN] Safe Lazy IO in Haskell In-Reply-To: <1237574414-sup-7006@ausone.local> References: <1237574414-sup-7006@ausone.local> Message-ID: <42784f260905170645n6316a654me1ecf21a60b3de2@mail.gmail.com> From the documentation: " LI could be a strict monad and a strict applicative functor. However it is not a lazy monad nor a lazy applicative functor as required Haskell. Hopefully it is a lazy (pointed) functor at least. I'd like to understand this better -- how is LI incompatible with being a lazy monad, exactly? -- Jason Dusek From jon.fairbairn at cl.cam.ac.uk Sun May 17 10:49:02 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Sun May 17 10:34:06 2009 Subject: [Haskell-cafe] Re: Haskell philosophy question References: <5ae4f2ba0905162332q6d8563ebpee6a2a00ad362f49@mail.gmail.com> Message-ID: "Vasili I. Galchin" writes: > Hello, > > ???? I am confused between Haskell as delineated in the Haskell Report VS > ghc "pragmas" which extend Haskell beyond the Haskell Report. Pragmas are part of the report, and while I agree that using them for extensions is stretching the meaning a bit, it's clearly the best way of doing it -- they're not supposed to change the semantics of the language as defined, but it doesn't say anything about what they do to stuff that isn't part of the language. > I am sure I am not the first to ask. Caveat: on my part, I > am not against innovation/extensions, but I don't like to > see language "bloat". Me neither, but many of the extensions are for things that hadn't been invented (or perhaps finalised, such as heirarchical modules, IIRC) when the standard was written, and which make the language more expressive, which is a worthwhile aim. Among the stated aims of Haskell was to be a platform for language development. Pragmas keep the experimental stuff separate from the stuff one can rely on because it's part of H98. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From keithshep at gmail.com Sun May 17 11:07:29 2009 From: keithshep at gmail.com (Keith Sheppard) Date: Sun May 17 10:52:20 2009 Subject: [Haskell-cafe] ANN: TxtSushi 0.1 Message-ID: <92e42b740905170807w7693d6c1s6d178f3f7d624dbb@mail.gmail.com> Hello Haskell Cafe I have released the first version of TxtSushi which is a collection of command line utils (written in haskell of course) for processing tab-delimited and CSV files. It includes a util for doing SQL SELECTs on flat files. This is my first haskell project and feedback of all kinds is appreciated. Home Page: http://www.keithsheppard.name/txt-sushi Darcs Repository: http://patch-tag.com/r/txt-sushi/home Issue Tracking: http://code.google.com/p/txt-sushi I would like to say thanks to the haskell-beginners contributors, the author of "Learn you a Haskell" and the author of the parsec library all of which were very helpful. Regards Keith From ekirpichov at gmail.com Sun May 17 11:36:47 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sun May 17 11:21:39 2009 Subject: [Haskell-cafe] ANN: TxtSushi 0.1 In-Reply-To: <92e42b740905170807w7693d6c1s6d178f3f7d624dbb@mail.gmail.com> References: <92e42b740905170807w7693d6c1s6d178f3f7d624dbb@mail.gmail.com> Message-ID: <5e0214850905170836u6c04f5fasb32cef98d3697b72@mail.gmail.com> This is crazy cool! I will now use your project as an example of what one can do as his first project in Haskell; I think doing SQL on CSV files definitely counts as a huge success story! 2009/5/17 Keith Sheppard : > Hello Haskell Cafe > > I have released the first version of TxtSushi which is a collection of > command line utils (written in haskell of course) for processing > tab-delimited and CSV files. It includes a util for doing SQL SELECTs > on flat files. This is my first haskell project and feedback of all > kinds is appreciated. > > Home Page: http://www.keithsheppard.name/txt-sushi > Darcs Repository: http://patch-tag.com/r/txt-sushi/home > Issue Tracking: http://code.google.com/p/txt-sushi > > I would like to say thanks to the haskell-beginners contributors, the > author of "Learn you a Haskell" and the author of the parsec library > all of which were very helpful. > > Regards > Keith > _______________________________________________ > 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 jochem at functor.nl Sun May 17 11:49:52 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Sun May 17 11:34:46 2009 Subject: [Haskell-cafe] ANN: TxtSushi 0.1 In-Reply-To: <92e42b740905170807w7693d6c1s6d178f3f7d624dbb@mail.gmail.com> References: <92e42b740905170807w7693d6c1s6d178f3f7d624dbb@mail.gmail.com> Message-ID: <4A103220.6040107@functor.nl> Keith Sheppard wrote: > I have released the first version of TxtSushi which is a collection of > command line utils (written in haskell of course) for processing > tab-delimited and CSV files. It includes a util for doing SQL SELECTs > on flat files. This is my first haskell project and feedback of all > kinds is appreciated. > > Home Page: http://www.keithsheppard.name/txt-sushi > Darcs Repository: http://patch-tag.com/r/txt-sushi/home > Issue Tracking: http://code.google.com/p/txt-sushi Nice! Have you considered putting this on Hackage? That is most useful for users of your code. I saw you already cabalized the code, so it should suffice to upload it. Cheers -- Jochem Berndsen | jochem@functor.nl GPG: 0xE6FABFAB From ekirpichov at gmail.com Sun May 17 11:53:02 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sun May 17 11:37:53 2009 Subject: [Haskell-cafe] ANN: TxtSushi 0.1 In-Reply-To: <92e42b740905170807w7693d6c1s6d178f3f7d624dbb@mail.gmail.com> References: <92e42b740905170807w7693d6c1s6d178f3f7d624dbb@mail.gmail.com> Message-ID: <5e0214850905170853n1f5bf61as823691cffeb5827@mail.gmail.com> By the way: As I see from the sources, your code uses external sort? But using String's much defeats the purpose of it, anyway, because their performance is so bad that if you feed your program a file that is larger than can be sorted in memory, sorting it externally using String's will anyway take much more time then you are likely to be comfortable waiting. You should consider switching to ByteString's, and beware memory leaks. 2009/5/17 Keith Sheppard : > Hello Haskell Cafe > > I have released the first version of TxtSushi which is a collection of > command line utils (written in haskell of course) for processing > tab-delimited and CSV files. It includes a util for doing SQL SELECTs > on flat files. This is my first haskell project and feedback of all > kinds is appreciated. > > Home Page: http://www.keithsheppard.name/txt-sushi > Darcs Repository: http://patch-tag.com/r/txt-sushi/home > Issue Tracking: http://code.google.com/p/txt-sushi > > I would like to say thanks to the haskell-beginners contributors, the > author of "Learn you a Haskell" and the author of the parsec library > all of which were very helpful. > > Regards > Keith > _______________________________________________ > 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 keithshep at gmail.com Sun May 17 12:08:32 2009 From: keithshep at gmail.com (Keith Sheppard) Date: Sun May 17 11:53:22 2009 Subject: [Haskell-cafe] ANN: TxtSushi 0.1 In-Reply-To: <5e0214850905170853n1f5bf61as823691cffeb5827@mail.gmail.com> References: <92e42b740905170807w7693d6c1s6d178f3f7d624dbb@mail.gmail.com> <5e0214850905170853n1f5bf61as823691cffeb5827@mail.gmail.com> Message-ID: <92e42b740905170908q6affa6f1tb5bbd96ee4bcc3b3@mail.gmail.com> Thanks for the encouraging reply! By the way, I was part way through writing my own code for external sorting which I don't actually use yet except from some test executable (joincol.hs). I'm very glad to see that there is already a library that does this though, so in my next version I will dump the custom code and use the external sort package. Also I will look into making the switch to ByteStrings. Thanks Keith On Sun, May 17, 2009 at 11:53 AM, Eugene Kirpichov wrote: > By the way: As I see from the sources, your code uses external sort? > But using String's much defeats the purpose of it, anyway, because > their performance is so bad that if you feed your program a file that > is larger than can be sorted in memory, sorting it externally using > String's will anyway take much more time then you are likely to be > comfortable waiting. You should consider switching to ByteString's, > and beware memory leaks. > > 2009/5/17 Keith Sheppard : >> Hello Haskell Cafe >> >> I have released the first version of TxtSushi which is a collection of >> command line utils (written in haskell of course) for processing >> tab-delimited and CSV files. It includes a util for doing SQL SELECTs >> on flat files. This is my first haskell project and feedback of all >> kinds is appreciated. >> >> Home Page: http://www.keithsheppard.name/txt-sushi >> Darcs Repository: http://patch-tag.com/r/txt-sushi/home >> Issue Tracking: http://code.google.com/p/txt-sushi >> >> I would like to say thanks to the haskell-beginners contributors, the >> author of "Learn you a Haskell" and the author of the parsec library >> all of which were very helpful. >> >> Regards >> Keith >> _______________________________________________ >> 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 keithshep at gmail.com Sun May 17 12:10:40 2009 From: keithshep at gmail.com (Keith Sheppard) Date: Sun May 17 11:55:29 2009 Subject: [Haskell-cafe] ANN: TxtSushi 0.1 In-Reply-To: <4A103220.6040107@functor.nl> References: <92e42b740905170807w7693d6c1s6d178f3f7d624dbb@mail.gmail.com> <4A103220.6040107@functor.nl> Message-ID: <92e42b740905170910p6466c34as9e4c83fcee372aea@mail.gmail.com> Thanks! Good advice, I will do that. On Sun, May 17, 2009 at 11:49 AM, Jochem Berndsen wrote: > Keith Sheppard wrote: >> I have released the first version of TxtSushi which is a collection of >> command line utils (written in haskell of course) for processing >> tab-delimited and CSV files. It includes a util for doing SQL SELECTs >> on flat files. This is my first haskell project and feedback of all >> kinds is appreciated. >> >> Home Page: http://www.keithsheppard.name/txt-sushi >> Darcs Repository: http://patch-tag.com/r/txt-sushi/home >> Issue Tracking: http://code.google.com/p/txt-sushi > > Nice! Have you considered putting this on Hackage? That is most useful > for users of your code. I saw you already cabalized the code, so it > should suffice to upload it. > > Cheers > > -- > Jochem Berndsen | jochem@functor.nl > GPG: 0xE6FABFAB > From ekirpichov at gmail.com Sun May 17 15:10:12 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sun May 17 14:55:00 2009 Subject: [Haskell-cafe] Free theorems for dependent types? Message-ID: <5e0214850905171210i22183345w99b6a395da234236@mail.gmail.com> Hello, Is there any research on applying free theorems / parametricity to type systems more complex than System F; namely, Fomega, or calculus of constructions and alike? This seems very promising to me for the following reason: Take the free theorem for 'sort::(a->a->Bool)->[a]->[a]'. The theorem could possibly be a lot more powerful if there were a way to encode in the type of 'sort' that it accepts a reflexive transitive antisymmetric predicate, but the only way to express that is with dependent types. Looks like the only thing one needs to add to System F is the relational translation rule for a dependent product; but I haven't tried doing it myself. -- Eugene Kirpichov Web IR developer, market.yandex.ru From paul at cogito.org.uk Sun May 17 15:26:41 2009 From: paul at cogito.org.uk (Paul Johnson) Date: Sun May 17 15:11:31 2009 Subject: [Haskell-cafe] Building a better dog house? In-Reply-To: <545876.48952.qm@web31102.mail.mud.yahoo.com> References: <545876.48952.qm@web31102.mail.mud.yahoo.com> Message-ID: <4A1064F1.80706@cogito.org.uk> michael rice wrote: > I was just looking at my UML (Unified Modeling Language) User Guide > and discovered this: > > "The number of object-oriented methods increased from fewer than 10 to > more than 50 during the period between 1989 and 1994." pg. xviii, > Booch, Rumbaugh, Jacobson, 1999 > > Is there a modeling methodology recommended for functional languages? > > Michael > > UML of course is not a methodology, its a language. "Rational Unified Process" (RUP) is a methodology. There is no recommended methodology for functional programming, but large chunks of RUP and most similar methodologies have little to do with OO programming, and therefore could be used as-is. All the project planning, configuration management, requirements management and so on will work just fine. When it comes to the software design in functional languages I find it best to start by looking for a domain analysis of the problem (something that RUP includes as well, if I recall correctly). Then try to translate that domain analysis into an embedded domain specific language (EDSL). Ideally the EDSL should allow you to describe anything that is physically or logically possible in the domain, but nothing that is impossible. Then you can go ahead and create your software by translating the requirements directly into the EDSL. Paul. From greenrd at greenrd.org Sun May 17 15:41:02 2009 From: greenrd at greenrd.org (Robin Green) Date: Sun May 17 15:25:52 2009 Subject: [Haskell-cafe] Free theorems for dependent types? In-Reply-To: <5e0214850905171210i22183345w99b6a395da234236@mail.gmail.com> References: <5e0214850905171210i22183345w99b6a395da234236@mail.gmail.com> Message-ID: <20090517204102.2fda2218@greenrd.org> On Sun, 17 May 2009 23:10:12 +0400 Eugene Kirpichov wrote: > Is there any research on applying free theorems / parametricity to > type systems more complex than System F; namely, Fomega, or calculus > of constructions and alike? Yes. I did some research into it as part of my master's thesis, the final version of which is not quite ready yet. Basically, free theorems in the Calculus of Constructions can be substantially more complicated, because they have to exclude certain dependent types in order to be valid. So much so that I do not think that they are necessarily worthwhile to use in proofs. But that is just an intuition, and I have not done enough different kinds of proofs to state this with any confidence. -- Robin From ekirpichov at gmail.com Sun May 17 15:48:27 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sun May 17 15:33:17 2009 Subject: [Haskell-cafe] Free theorems for dependent types? In-Reply-To: <20090517204102.2fda2218@greenrd.org> References: <5e0214850905171210i22183345w99b6a395da234236@mail.gmail.com> <20090517204102.2fda2218@greenrd.org> Message-ID: <5e0214850905171248n563c0832r93f76dce83a1d9d3@mail.gmail.com> I'm glad that someone is doing research in that direction! Are your results so far applicable to create a free theorem for that example with sortBy? 2009/5/17 Robin Green : > On Sun, 17 May 2009 23:10:12 +0400 > Eugene Kirpichov wrote: > >> Is there any research on applying free theorems / parametricity to >> type systems more complex than System F; namely, Fomega, or calculus >> of constructions and alike? > > Yes. I did some research into it as part of my master's thesis, the > final version of which is not quite ready yet. > > Basically, free theorems in the Calculus of Constructions can be > substantially more complicated, because they have to exclude certain > dependent types in order to be valid. So much so that I do not think > that they are necessarily worthwhile to use in proofs. But that is just > an intuition, and I have not done enough different kinds of proofs to > state this with any confidence. > > -- > Robin > _______________________________________________ > 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 Sun May 17 16:44:06 2009 From: nowgate at yahoo.com (michael rice) Date: Sun May 17 16:28:54 2009 Subject: [Haskell-cafe] Building a better dog house? Message-ID: <388690.33116.qm@web31101.mail.mud.yahoo.com> Hi Paul, ?I've been away from software design for more than a decade and have fallen behind on what's currently being used. I wasn't even aware of RUP. Thanks for the info. Michael --- On Sun, 5/17/09, Paul Johnson wrote: From: Paul Johnson Subject: Re: [Haskell-cafe] Building a better dog house? To: "michael rice" Cc: haskell-cafe@haskell.org Date: Sunday, May 17, 2009, 3:26 PM michael rice wrote: > I was just looking at my UML (Unified Modeling Language) User Guide and discovered this: > > "The number of object-oriented methods increased from fewer than 10 to more than 50 during the period between 1989 and 1994." pg. xviii, Booch, Rumbaugh, Jacobson, 1999 > > Is there a modeling methodology recommended for functional languages? > > Michael > > UML of course is not a methodology, its a language.? "Rational Unified Process" (RUP) is a methodology. There is no recommended methodology for functional programming, but large chunks of RUP and most similar methodologies have little to do with OO programming, and therefore could be used as-is.? All the project planning, configuration management, requirements management and so on will work just fine. When it comes to the software design in functional languages I find it best to start by looking for a domain analysis of the problem (something that RUP includes as well, if I recall correctly).? Then try to translate that domain analysis into an embedded domain specific language (EDSL).? Ideally the EDSL should allow you to describe anything that is physically or logically possible in the domain, but nothing that is impossible.? Then you can go ahead and create your software by translating the requirements directly into the EDSL. Paul. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090517/f6180b8e/attachment.html From tracy.wadleigh at gmail.com Sun May 17 21:00:24 2009 From: tracy.wadleigh at gmail.com (Tracy Wadleigh) Date: Sun May 17 20:45:11 2009 Subject: [Haskell-cafe] ANNOUNCE: mathlink-2.0.0.3 In-Reply-To: <20090518005510.GF13246@whirlpool.galois.com> References: <20090518005510.GF13246@whirlpool.galois.com> Message-ID: Already posted to the Haskell list but dons suggested I post to the cafe, as well... All: mathlink is a library for writing Mathematica packages in Haskell. One simply writes some functions of type: (MLGet a, MLPut b) => a -> IO b and provides a package specification in a simple DSL that mimics that of Mathematica's mprep utility. The result is a program that exposes functions that can be called from Mathematica. This is a complete rewrite of my original implementation and more closely captures the functionality I originally intended. I've only tested it on my own platform (64-bit Linux), but I've taken pains to make sure the code should run on any platform. (The only real issue in the code is picking the right functions to call when marshaling Ints.) Please report any tweaks required to get it to work on your platform. (That is, of course, only if, in fact, there are any other users out there. Right now, as far as I know, I'm it.) I'd also just like to hear from any Haskellers out there that also use Mathematica on a regular basis. Ping me if you're one. --Tracy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090517/0c44eb2c/attachment.html From jfredett at gmail.com Sun May 17 22:51:38 2009 From: jfredett at gmail.com (Joe Fredette) Date: Sun May 17 22:36:23 2009 Subject: [Haskell-cafe] Free theorems for dependent types? In-Reply-To: <5e0214850905171210i22183345w99b6a395da234236@mail.gmail.com> References: <5e0214850905171210i22183345w99b6a395da234236@mail.gmail.com> Message-ID: <4A10CD3A.2090806@gmail.com> This word has piqued my interest, I've hear it tossed around the community quite a bit, but never fully understood what it meant. What exactly is a 'free theorem'? Eugene Kirpichov wrote: > Hello, > > Is there any research on applying free theorems / parametricity to > type systems more complex than System F; namely, Fomega, or calculus > of constructions and alike? > > This seems very promising to me for the following reason: Take the > free theorem for 'sort::(a->a->Bool)->[a]->[a]'. The theorem could > possibly be a lot more powerful if there were a way to encode in the > type of 'sort' that it accepts a reflexive transitive antisymmetric > predicate, but the only way to express that is with dependent types. > > Looks like the only thing one needs to add to System F is the > relational translation rule for a dependent product; but I haven't > tried doing it myself. > > -------------- 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/20090517/1206f280/jfredett.vcf From ryani.spam at gmail.com Sun May 17 23:52:32 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sun May 17 23:37:18 2009 Subject: [Haskell-cafe] Free theorems for dependent types? In-Reply-To: <4A10CD3A.2090806@gmail.com> References: <5e0214850905171210i22183345w99b6a395da234236@mail.gmail.com> <4A10CD3A.2090806@gmail.com> Message-ID: <2f9b2d30905172052s3f4402d2v113d44ae65c3bdc7@mail.gmail.com> Free theorem's are theorems about functions that rely only on parametricity. For example, consider any function f with the type forall a. a -> a >From its type, I can tell you directly that this theorem holds: forall g :: A -> B, x :: A, f (g x) = g (f x) (Note that the f on the left is B -> B, the f on the right is A -> A). The term was popularized by Philip Wadler, in his paper "Theorems for Free!" [1]. He noticed that many of the properties of functions that one likes to prove come "for free" from their parametric type. For example, it's useful to know that reverse (map fromEnum xs) == map fromEnum (reverse xs) But this theorem comes for free from the type of reverse! Given any - f :: forall a. [a] -> [a] - g :: A -> B - xs :: [A] we have the free theorem - f (map g xs) = map g (f xs). What this is saying is that any function (forall a. [a] -> [a]) can't do a whole lot; it can inspect the structure of the list it has been given, and rearrange, duplicate, and/or remove some elements. But the output list can only contain elements from the input list, without inspecting the elements themselves. Therefore, if f [1,2,3] == [1,1,2] then f "abc" == "aab" and f [True, True, False] == [True, True, True] and f [ [], [1], [1,2] ] == [ [], [], [1,2] ] and so on. Therefore mapping some pure function over the result can be done before or after applying f; and we don't have to know *anything* about f, aside from its type, to prove this. -- ryan [1] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.38.9875 On Sun, May 17, 2009 at 7:51 PM, Joe Fredette wrote: > This word has piqued my interest, I've hear it tossed around the community > quite a bit, but never fully understood what it meant. What exactly is a > 'free theorem'? > > Eugene Kirpichov wrote: >> >> Hello, >> >> Is there any research on applying free theorems / parametricity to >> type systems more complex than System F; namely, Fomega, or calculus >> of constructions and alike? >> >> This seems very promising to me for the following reason: Take the >> free theorem for 'sort::(a->a->Bool)->[a]->[a]'. The theorem could >> possibly be a lot more powerful if there were a way to encode in the >> type of 'sort' that it accepts a reflexive transitive antisymmetric >> predicate, but the only way to express that is with dependent types. >> >> Looks like the only thing one needs to add to System F is the >> relational translation rule for a dependent product; but I haven't >> tried doing it myself. >> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From mpm at alumni.caltech.edu Mon May 18 00:44:42 2009 From: mpm at alumni.caltech.edu (Michael P Mossey) Date: Mon May 18 00:29:31 2009 Subject: [Haskell-cafe] tips on using monads Message-ID: <4A10E7BA.6020603@alumni.caltech.edu> I've got one of those algorithms which "threatens to march off the right edge" (in the words of Goerzen et al). I need something like a State or Maybe monad, but this is inside the IO monad. So I presume I need StateT or MaybeT. However, I'm still (slowly) learning about monads from first principles. I thought I might present my code and get some pointers... maybe someone could actually show me how to rewrite it, which would be a neat way to see MaybeT and StateT in action. I'm hoping to get anything from a one-line response to a rewrite of my code. Anything will help. Here's the program: {- This is a program which starts with a document containing "notes" about software requirements (in a particular format) and puts them into a database. Notes include details such as the "source" of the requirement (who gave it), the topic(s) to which it pertains, the date, etc. I have written a parser to take a text document typed up by me during a meeting and parse it into a NoteRecord structure. Here is the structure: -} data NoteRecord = NoteRecord { recordSource :: String, -- Name of person who gave req. recordDate :: [Int], -- Date in [,,] recordSourceType :: String, -- "meeting", "phone", "email", etc. recordBugNum :: Maybe Int, -- Bugzilla # (if relevant) recordTopics :: [String], -- list of official topics pertaining recordText :: String } -- the text of the note itself deriving (Show) {- One other wrinkle. The source (person name) and topic must be one of a set of pre-determined strings. A person has an official full name which is stored in the database. Topics also have official descriptive strings. If I wasn't clever, then the note, as I type it up, must have the exact name and topic. But I hate trying to remember things like that. So I have implemented a "fuzzy string match" system so that I can type part of someone's name (or even misspell it) or part of a topic string, and the system will find the best match to an official string. In pseudocode, the function to insert a note in the database must do this: This function starts with a NoteRecord. - If text already exists in the database, give an error and skip to end. - Fuzzy-match strings to topics and source. - If no potential match can be found to some of topics or source, give error and skip to end. - Ask user to confirm if the matched topics and source look okay. - if user says no, skip to end. - Actually insert the record. -} insertNote :: NoteRecord -> Connection -> IO () insertNote nr conn = do -- Check if it exists in the database already. status <- checkPreExistingText nr conn if status then putStrLn "Skipping... text exists already." else do -- Find best fit for all topics and source. -- See type signatures below. bestFitTopics <- fitTopics nr conn bestFitSource <- fitSource nr conn case any isNothing bestFitTopics of True -> putStrLn "Error... some topic couldn't be matched." False -> case bestFitSource of Nothing -> putStrLn "Error.. source couldn't be matched." _ -> do b <- isUserOkay nr bestFitTopics bestFitSource if b then do -- Create a new NoteRecord with matched -- and validated topics/source. nrValidated = nr { recordTopics = bestFitTopics , recordSource = bestFitSource } insertRow nrValidated conn else putStrLn "Abort due to user request." checkPreExistingText :: NoteRecord -> Connection -> Bool -- There are multiple topics in the NoteRecord. For each one, -- find the best fuzzy match, or indicate if there is no plausible -- match at all. fitTopics :: NoteRecord -> Connection -> [Maybe String] -- There is one source. Try to find fuzzy match. fitSource :: NoteRecord -> Connection -> Maybe String -- Present user with all fuzzy matches and get a yes/no response if it's -- okay to proceed. isUserOkay :: NoteRecord -> [Maybe String] -> Maybe String -> Bool -- Do actual insert into database. insertRow :: NoteRecord -> Connection -> IO () From ekirpichov at gmail.com Mon May 18 01:21:15 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Mon May 18 01:06:03 2009 Subject: [Haskell-cafe] ANNOUNCE: mathlink-2.0.0.3 In-Reply-To: References: <20090518005510.GF13246@whirlpool.galois.com> Message-ID: <5e0214850905172221t28e192a9g9699a9a1b5adb7ee@mail.gmail.com> Hi, I'm a Haskeller that uses Mathematica on a regular basis; it's one of my favourite tools. So - thanks for your work, I'll use it whenever applicable. However, during compilation I get an error that ml.h is not found, even after I added Mathematica's include dirs to Include-Dirs. Since that seems to be not a Mathematica's file (it doesn't exist in my Mathematica directories), I conclude that it might be a file that is missing from the package. Is that actually so? 2009/5/18 Tracy Wadleigh : > Already posted to the Haskell list but dons suggested I post to the cafe, as > well... > > All: > > mathlink is a library for writing Mathematica packages in Haskell. > > One simply writes some functions of type: > > (MLGet a, MLPut b) => a -> IO b > > and provides a package specification in a simple DSL that mimics that of > Mathematica's mprep utility. The result is a program that exposes functions > that can be called from Mathematica. > > This is a complete rewrite of my original implementation and more closely > captures the functionality I originally intended. > > I've only tested it on my own platform (64-bit Linux), but I've taken pains > to make sure the code should run on any platform. (The only real issue in > the code is picking the right functions to call when marshaling Ints.) > Please report any tweaks required to get it to work on your platform. (That > is, of course, only if, in fact, there are any other users out there. Right > now, as far as I know, I'm it.) > > I'd also just like to hear from any Haskellers out there that also use > Mathematica on a regular basis. Ping me if you're one. > > --Tracy > > _______________________________________________ > 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 jno at di.uminho.pt Mon May 18 04:29:36 2009 From: jno at di.uminho.pt (J.N. Oliveira) Date: Mon May 18 04:14:25 2009 Subject: [Haskell-cafe] TFM09: Last CFP (FMWeek, Eindhoven, November 6th 2009) In-Reply-To: References: <6C84A9A8-448 D-4BB0-8ECC-733F94618113@di.uminho.pt><149AF668-5B86-483E-AE4A-31FCB41FAEA3 @di.uminho.pt><751CA11B- C480-4AFD-95EE-341977956B22@di.uminho.pt><783CB463-70DA-42BB-AA3E-6FEF6D060 992@di.uminho.pt><439928F0-2402-47CA-B9D5-5DBC115FD385@di.uminho.pt><835D2796-8A7B-4175-AD45-699D28 FFC48D@di.uminho.pt><03D 358AB-5CB3-4A1F-B544-D36339BCCAE3@di.uminho.pt><7AE5C171-EEE6-4ADB-B4F2-24A9F3F95D41@di.uminho.pt>< 68F7244E-664C-4B9D-9E53-F57958930A11@di.uminho.pt><7E9C7D41-AB35-4180-A392- 8D650B71A6DA@di.uminho.pt><295278A7-C8E3-4E98-8D3D-77C436712748@di.uminho.p t><1ED014F0-F9EF-409A-B3 6B-11CAD163DA3D@di.uminho.pt><120310DA-2030-4FA4-9F61-FD4EE51A9C06@di.uminho.pt><3E535BF5-5F17-4892-8A5D-F8CFB25815A5@di.um inho.pt><0C688277-C9C2-4420-9002-ADC0DE3DA8A0@di.uminho.pt><0A1D2802-85F 4-4E08-BD46-F84159CAA7CE@di.uminho.pt><67668AEE-3079-4FEF-8F81-53D0B1866D15 @di.uminho.pt><15B086F0-E97B-43E1-8983-FB2DBAB96CC6@di.uminho.pt><3C50371D- C0D2-4949-8FEE-00BECC5EBB02@di.uminho.pt><21A48681-B072-482B-8AAF-54E6C6A50 10F@di.uminho.pt><2342BF13-0034-4F4A-AA4C-EC1CA055CDF1@di.uminho.pt><663BCC4D-1B19-4E84-8614-AE3162 70B3C3@di.uminho.pt><64A8B902-7DA5-4284-A4A8-18D6874CA069@di.uminho.pt>< 6AC8F250-5C37-4593-BCBD-144AB137C75D@di.uminho.pt><1FB8BC34-C683-4850-8FA6- DA12D9743D5E@di.uminho.pt><8093D19D-B78D-4D7C-A2FF-FAE182EC67AE@di.uminho.pt><61E3A078-D722-47E9-AC4F-A2610969CE13@di.uminh o.pt><485E9D1C-AF99-4B8E -B8DA-F45997FD26F0@di.uminho.pt><10B841BC-C0B9-4 186-A8B4-D3CFFFCB8116@di.uminho.pt><5023897F-1EAE-4E3A-95FF-BAB39FAD9445@di.uminho.pt><342EB496-47B 1-42EA-B133-2DBB1BB074F5@di.uminho.pt><45FDA14E-EB10-44BD-980D-2FED948F4C9B @di.uminho.pt><47D23ACA-946B-451C-88D5-D5D2970B32AF@di.uminho.pt><6E227144-4B6B-4824-999C-CD77F1DD7 FBE@di.uminho.pt><0C08ACFB-8E18-44D0-9AA4-D4D4AA45A89B@di.uminho.pt><569643 E0-59FF-485D-B4B8-AD4D7C559424@di.uminho.pt><4F764709-722D-4A3D-8EBE-6E0754 68A59F@di.uminho.pt><7EE29FC8-9919-4E51-9B50-78730C0135F0@di.uminho.pt><334 109B6-D1F4-4E8C-9126-FAA1F82A338A@di.uminho.pt>< F4718175-D928-4C3C-B227-29959780AAB1@di.uminho.pt><9E502612-BBA9-4790-9E1F- FB0B7DD401DA@di.uminho.pt><4ECB4CC8-0D4C-44F4-8989-9FD151F94C60@di.uminho.p t><7D9A143F-4130-4A1C-9F42-E6930C40E45C@di.uminho.pt><50459F00-3336-43A4-93 06-3F1562B30126@di.uminho.pt><922009BB-947C-4ACA-BCBF-3EA097AEA75B@di.uminh o.pt><25020DE3-1883-4536-A828-F3D47B037D13@di.uminho.pt><7957DE07-DA89-493D-9D3B-ABDC8634E261@di.um inho.pt><2A25BA26-05D0-4C6E-AAD6-4D6CD504CD53@di.uminho.pt><2E4EA128-9A2F-4 419-90B5-5484551024E3@di.uminho.pt><41BDFDDF-0964-4AF6-B2C7-39C61623C18F@di .uminho.pt> Message-ID: TFM2009 2nd Int. FME Conference on Teaching Formal Methods "Widening Access to Formal Methods" Friday, November 6th 2009, co-located with FM2009 : 16th International Symposium on Formal Methods Eindhoven, the Netherlands, November 2 - November 6, 2009 CALL FOR PAPERS (URL: http://www.di.uminho.pt/tfm09) 1. About the conference ----------------------- Ten years after the First World Formal Methods Congress (FM'99) in Toulouse, formal methods communities from all over the world will once again have an opportunity to come together. As part of the First Formal Methods Week event surrounding the FM2009 conference in Eindhoven, Formal Methods Europe will be organizing TFM2009, the Second International Conference on Teaching Formal Methods. The conference will serve as a forum to explore the successes and failures of Formal Methods (FM) education, and to promote cooperative projects to further education and training in FMs. We would like to provide a forum for lecturers, teachers, and industrial partners to discuss their experience, present their pedagogical methodologies, and explore best practices. TFM2009 follows in a series of recent events on teaching formal methods, including: two BCS-FACS TFM workshops (Oxford in 2003, and London in 2006), the TFM 2004 conference in Ghent (with proceedings published as Springer LNCS Volume 3294), the FM-Ed 2006 workshop (Hamilton, co-located with FM'06), FORMED (Budapest, at ETAPS 2008), FMET 2008 (Kitakyushu 2008, co-located with ICFEM), etc. 2. Topics of interest --------------------- Formal methods (FM) have an important role to play in the development of complex computing systems - a role acknowledged in industrial standards such as IEC 61508 and ISO/IEC 15408, and in the increasing use of precise modeling notations, semantic markup languages, and model-driven techniques. There is a growing need for software engineers who can work effectively with simple, mathematical abstractions, and with practical notions of inference and proof. However, there is little clear guidance ? for educators, for managers, or for the engineers themselves ? as to what might comprise a basic education in FM. Neither the present IEEE/ACM Software Engineering Body of Knowledge (SWEBOK) nor the forthcoming Graduate Software Engineering Reference Curriculum (GSWERC) provide the kind of specific information that teachers and practitioners need to establish an adequate, balanced programme of learning in FM. Original contributions are solicited that provide insight, opinions, and suggestions for courses of action regarding the teaching FMs, including but not limited to the following aspects: * experiences of teaching FMs, both successful and unsuccessful; * educational resources including the use of books, case studies and the internet; * the education of weak and mathphobic students; * the integration, or otherwise, of FMs into the curriculum, including contributions to the definition of a Formal Methods Body of Knowledge (FMBOK); * the advantages of FM-trained graduates in the workplace; * changing attitudes towards FMs in students, academic staff and practitioners; * the necessary mathematical background. The conference proceedings will be published by Springer-Verlag in the LNCS series. Submissions may be up to 20 pages long using Springer's LNCS format. 3. Important dates ------------------ Please put the following dates in your diary: Submission deadline May 25, 2009 Notification of acceptance July 6, 2009 Final version August 3, 2009 4. How to submit ---------------- Papers for TFM2009 will be processed through the EasyChair conference management system. To submit your paper, please visit: http://www.easychair.org/conferences/?conf=tfm2009 5. Invited speakers ------------------- To be announced 6. Programme Committee ---------------------- Izzat Alsmadi (North Dakota State University, USA) Dines Bjorner (IIMM Institute, Denmark) Eerke Boiten (University of Kent, UK) Raymond Boute (Universiteit Gent, Belgium) Andrew Butterfield (Trinity College, Dublin) Jim Davies (University of Oxford, UK) David Duce (Oxford Brookes University, UK) John Fitzgerald (University of Newcastle upon Tyne, UK) Jeremy Gibbons (University of Oxford, UK) Randolph Johnson (National Security Agency, USA) Michael Mac an Airchinnigh (Trinity College, Dublin) Dino Mandrioli (Politecnico di Milano, Italy) Jose Oliveira (Universidade do Minho, Portugal) Kees Pronk (Technische Universiteit Delft, NL) Bernhard Schaetz (Tecnical University of Munique, Germany) Wolfgang Schreiner (Johannes Kepler University Linz, Austria) Simao Melo de Sousa (Universidade da Beira Interior, Portugal) Kenji Taguchi (National Institute of Informatics, Japan) Jeannette Wing (Carnegie-Mellon University, USA) 7. Sponsorship ---------------------- TFM2009 is supported by FME, the Formal Methods Europe Association -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/af91fd74/attachment.html From ndmitchell at gmail.com Mon May 18 04:48:28 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon May 18 04:33:17 2009 Subject: [Haskell-cafe] community.haskell.org and code.haskell.org problems Message-ID: <404396ef0905180148l22e4c89te08bc62620e57f15@mail.gmail.com> Hi, I regularly (almost daily) have problems reaching both community and code.haskell.org, getting 500 server error messages. I've decided to make all my Haskell code available on community, which means that when it goes down, I can't access my repos - which is not great. Is there a reason for the poor reliability of these servers? Can anything be done to improve them? I'm very grateful for the availability of the service, but I know of servers running on Windows laptops which have far higher uptime :-) Thanks Neil From conor at strictlypositive.org Mon May 18 04:57:07 2009 From: conor at strictlypositive.org (Conor McBride) Date: Mon May 18 04:41:56 2009 Subject: [Haskell-cafe] Free theorems for dependent types? In-Reply-To: <5e0214850905171248n563c0832r93f76dce83a1d9d3@mail.gmail.com> References: <5e0214850905171210i22183345w99b6a395da234236@mail.gmail.com> <20090517204102.2fda2218@greenrd.org> <5e0214850905171248n563c0832r93f76dce83a1d9d3@mail.gmail.com> Message-ID: Hi Questions of parametricity in dependent types are made more complex by the way in which the "Pi-type" (x : S) -> T corresponds to universal quantification. It's good to think of this type as a very large product, tupling up individual T's for each possible x you can distinguish by observation. "For all x" here means "For each individual x". By contrast, your typical universally quantified type forall x. t gives you fantastic guarantees of ignorance about x! It's really a kind of intersection. "For all x" here means "For a minimally understood x" --- your program should work even when x is replaced by a cardboard cutout rather than an actual whatever-it-is, and this guarantees the uniformity of operation which free theorems exploit. I'm reminded of the Douglas Adams line "We demand rigidly defined areas of doubt and uncertainty.". In the dependent case, how much uniformity you get depends on what observations are permitted on the domain. So what's needed, to get more theorems out, is a richer language of controlled ignorance. There are useful developments: (1) Barras and Bernardo have been working on a dependent type system which has both of the above foralls, but distinguishes them. As you would hope, the uniform forall, its lambda, and application get erased between typechecking and execution. We should be hopeful for parametricity results as a consequence. (2) Altenkirch, Morris, Oury, and I have found a way (two, in fact, and there's the rub) to deliver quotient structures, which should allow us to specify more precisely which observations are available on a given set. Hopefully, this will facilitate parametric reasoning --- if you can only test this, you're bound to respect that, etc. My favourite example is the recursion principle on *unordered* pairs of numbers (N*N/2). uRec : (P : N*N/2 -> Set) -> ((y : N) -> P (Zero, y)) -> ((xy : N*N/2) -> P xy -> P (map Suc xy)) -> (xy : N*N/2) -> P xy Given an unordered pair of natural numbers, either one is Zero or both are Suc, right? You can define some of our favourite operators this way. add = uRec (\ _ -> N) (\ y -> y) (\ _ -> Suc . Suc) max = uRec (\ _ -> N) (\ y -> y) (\ _ -> Suc) min = uRec (\ _ -> N) (\ y -> y) (\ _ -> id) (==) = uRec (\ _ -> Bool) isZero (\ _ -> id) I leave multiplication as an exercise. The fact that these operators are commutative is baked into their type. To sum up, the fact that dependent types are good at reflection makes them bad at parametricity, but there's plenty of work in progress aimed at the kind of information hiding which parametricity can then exploit. There are good reasons to be optimistic here. All the best Conor From nccb2 at kent.ac.uk Mon May 18 06:08:41 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Mon May 18 05:53:27 2009 Subject: [Haskell-cafe] tips on using monads In-Reply-To: <4A10E7BA.6020603@alumni.caltech.edu> References: <4A10E7BA.6020603@alumni.caltech.edu> Message-ID: <4A1133A9.9020307@kent.ac.uk> Michael P Mossey wrote: > I've got one of those algorithms which "threatens to march off the > right edge" (in the words of Goerzen et al). I need something like a > State or Maybe monad, but this is inside the IO monad. So I presume I > need StateT or MaybeT. However, I'm still (slowly) learning about > monads from first principles. I thought I might present my code and > get some pointers... maybe someone could actually show me how to > rewrite it, which would be a neat way to see MaybeT and StateT in > action. I'm hoping to get anything from a one-line response to a > rewrite of my code. Anything will help. Here's a version using ErrorT from mtl. I added some missing IO bits on your types; the type error that remains is for you to fix :-) With ErrorT you can use throwError when you want to break out of the block and give back an error, which seems to fit what you were doing. The downside is you have to add all these liftIO bits wherever you do a plain IO computation. insertNote :: NoteRecord -> Connection -> IO () insertNote nr conn = either putStrLn return =<< runErrorT (do -- Check if it exists in the database already. status <- liftIO $ checkPreExistingText nr conn when status $ throwError "Skipping... text exists already." -- Find best fit for all topics and source. -- See type signatures below. bestFitTopics <- liftIO $ fitTopics nr conn bestFitSource <- liftIO $ fitSource nr conn case any isNothing bestFitTopics of True -> throwError "Error... some topic couldn't be matched." False -> case bestFitSource of Nothing -> throwError "Error.. source couldn't be matched." _ -> do b <- liftIO $ isUserOkay nr bestFitTopics bestFitSource when (not b) $ throwError "Abort due to user request." -- Create a new NoteRecord with matched -- and validated topics/source. let nrValidated = nr { recordTopics = bestFitTopics , recordSource = bestFitSource } liftIO $ insertRow nrValidated conn ) checkPreExistingText :: NoteRecord -> Connection -> IO Bool fitTopics :: NoteRecord -> Connection -> IO [Maybe String] fitSource :: NoteRecord -> Connection -> IO (Maybe String) isUserOkay :: NoteRecord -> [Maybe String] -> Maybe String -> IO Bool insertRow :: NoteRecord -> Connection -> IO () Thanks, Neil. From ndmitchell at gmail.com Mon May 18 06:38:09 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon May 18 06:22:55 2009 Subject: [Haskell-cafe] community.haskell.org and code.haskell.org problems Message-ID: <404396ef0905180338v1477ec54r1cff5214eed5b10d@mail.gmail.com> Hi, I regularly (almost daily) have problems reaching both community and code.haskell.org, getting 500 server error messages. I've decided to make all my Haskell code available on community, which means that when it goes down, I can't access my repos - which is not great. Is there a reason for the poor reliability of these servers? Can anything be done to improve them? I know of servers running on Windows laptops which have far higher uptime :-) Thanks Neil From marlowsd at gmail.com Mon May 18 07:09:12 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Mon May 18 06:54:03 2009 Subject: [Haskell-cafe] ghc ./configure stalls on docbook DTD In-Reply-To: References: <4A0B1304.7060401@gmail.com> Message-ID: <4A1141D8.8070505@gmail.com> On 13/05/2009 19:53, Donnie Jones wrote: > Hello Dan, > > Best place to ask is glasgow-haskell-users@haskell.org since that is > the GHC users list. > I have CC'd your email to the GHC user list. > > Cheers. > -- > Donnie Jones > > On Wed, May 13, 2009 at 1:35 PM, Dan wrote: >> Hi, >> >> Not sure if this is the right place to ask. >> GHC 6.10.3 source dist: ./configure takes about 10 minutes to look for >> DocBook DTD and another 10 to look for DocBook XSL directory. I was writing >> this e-mail thinking it had completely crashed. Any reason why it's so >> ridiculously slow? A look at 'top' says the CPU is mostly idle during this >> time, but xmllint is running. I have the following complaint from Roman in my inbox, which I think is about the same thing: > one big nuisance when building ghc is that configure tries to connect > to the internet. The culprit is the FP_GEN_DOCBOOK_XML macro in > aclocal.m4 which is used when checking for DocBook DTD. It generates > an XML file which references http://www.oasis-open.org/docbook/xml/4.2 > /docbookx.dtd and then runs xmllint which, naturally, wants to load > the dtd. Depending on the quality of my internet connection and on > the availability of oasis-open.org this check sometimes (infrequently > but very annoyingly) takes up to a 2 or 3 minutes for me. Given that > the DTD in question can be freely copied, why not redistribute it > with ghc? > Another www reference is in FP_GEN_FO (to > http://www.w3.org/1999/XSL/Format) but that never seems to bite me. I know almost but not quite exactly nothing about how to find DTDs. But I do recall that Duncan mentioned to me recently that there's a much better way to do this - Duncan? Cheers, Simon From claus.reinke at talk21.com Mon May 18 07:20:25 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon May 18 07:05:18 2009 Subject: [Haskell-cafe] tips on using monads References: <4A10E7BA.6020603@alumni.caltech.edu> Message-ID: <6AE44F3342CD4196981458A075BB769B@cr3lt> > I've got one of those algorithms which "threatens to march off the right edge" (in the words of > Goerzen et al). I need something like a State or Maybe monad, but this is inside the IO monad. So > I presume I need StateT or MaybeT. However, I'm still (slowly) learning about monads from first > principles. I thought I might present my code and get some pointers... maybe someone could > actually show me how to rewrite it, which would be a neat way to see MaybeT and StateT in action. > I'm hoping to get anything from a one-line response to a rewrite of my code. Anything will help. Perhaps this is useful: http://www.haskell.org/haskellwiki/Equational_reasoning_examples#Coding_style:_indentation_creep_with_nested_Maybe Claus From lemming at henning-thielemann.de Mon May 18 07:31:54 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon May 18 07:16:08 2009 Subject: [Haskell-cafe] Haskell philosophy question In-Reply-To: <5ae4f2ba0905162332q6d8563ebpee6a2a00ad362f49@mail.gmail.com> References: <5ae4f2ba0905162332q6d8563ebpee6a2a00ad362f49@mail.gmail.com> Message-ID: <4A11472A.7020102@henning-thielemann.de> Vasili I. Galchin schrieb: > Hello, > > I am confused between Haskell as delineated in the Haskell Report > VS ghc "pragmas" which extend Haskell beyond the Haskell Report. I am > sure I am not the first to ask. Caveat: on my part, I am not against > innovation/extensions, but I don't like to see language "bloat". This is > not a negative/pegorative statement .... just a challenging one. http://www.haskell.org/haskellwiki/Use_of_language_extensions From marlowsd at gmail.com Mon May 18 08:07:56 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Mon May 18 07:52:45 2009 Subject: [Haskell-cafe] Re: The HP and PackedString In-Reply-To: <1242216476.20743.4403.camel@localhost> References: <4A0A50EA.5010403@freegeek.org> <877i0lbeb5.fsf_-_@malde.org> <1242214393.20743.4365.camel@localhost> <37113624.20090513153752@gmail.com> <1242216476.20743.4403.camel@localhost> Message-ID: <4A114F9C.4080608@gmail.com> On 13/05/2009 13:07, Duncan Coutts wrote: > On Wed, 2009-05-13 at 15:37 +0400, Bulat Ziganshin wrote: >> Hello Duncan, >> >> Wednesday, May 13, 2009, 3:33:13 PM, you wrote: >> >>> I think it should remain deprecated and we should work on the >>> replacement so that TH can switch its dependency. >> TH isn't high-performance package and i think that it should just >> switch to use of String > > That's a reasonable proposal for the next major release of the platform. > Please do propose it on the libraries list and see if we can get a > consensus. I'll do the proposal - I've just made the change locally, I'll validate and then make a patch for comments. Cheers, Simon From kenneth.hoste at ugent.be Mon May 18 08:37:51 2009 From: kenneth.hoste at ugent.be (Kenneth Hoste) Date: Mon May 18 08:23:11 2009 Subject: [Haskell-cafe] fast Eucl. dist. - Haskell vs C Message-ID: Hello, For a while now, I've been trying to come up with a fast Haskell-only function which implements Euclidean distance in n-dimensional space. So far, I've been disappointed by the performance of my best effort in Haskell, compared to C. I'm hoping some of the Haskell experts and/or performance gurus on this list can help me out on resolving this, and also maybe shed some light on some strange (imho) things I've run into. My current best try uses the uvector package, has two 'vectors' of type (UArr Double) as input, and relies on the sumU and zipWithU functions which use streaming to compute the result: dist_fast :: UArr Double -> UArr Double -> Double dist_fast p1 p2 = sumDs `seq` sqrt sumDs where sumDs = sumU ds ds = zipWithU euclidean p1 p2 euclidean x y = d*d where d = x-y I've been benchmarking this function against various alternatives using the MicroBench [1] package, which allows to get accurate timings of single function calls. I've also mimicked the MicroBench approach in pure C, to get comparable timings for a C-only implementation. The C-only function is quite straightforward: double dist(int dim, double* p1, double* p2){ int i; double d = 0.0; for(i=0; i < dim; i++){ d += (p1[i] - p2[i])*(p1[i] - p2[i]); } return sqrt(d); } (Note that the optimizer takes care of the p1-p2 operation appearing twice in the code). All code is attached if you'd like to play around with it. All numbers reported below are using GHC 6.10.2 and gcc 4.3.3 on Linux/x86. The compilation details can be found in the Makefile attached, but in short, I'm using -O2 -fexcess-precision or -O2 -fexcess-precision -fvia-C -optc-O3 with GHC, and -O3 with gcc. -------------- next part -------------- A non-text attachment was scrubbed... Name: Dist.hs Type: application/octet-stream Size: 1840 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/34a658ee/Dist.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: microbench_dist.c Type: application/octet-stream Size: 2480 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/34a658ee/microbench_dist.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: microbench_dist.hs Type: application/octet-stream Size: 4823 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/34a658ee/microbench_dist-0001.obj -------------- next part -------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: dist_c.c Type: application/octet-stream Size: 229 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/34a658ee/dist_c.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: dist_c.h Type: application/octet-stream Size: 44 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/34a658ee/dist_c-0001.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: Makefile Type: application/octet-stream Size: 544 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/34a658ee/Makefile.obj -------------- next part -------------- Now the bad news: for small dimensions, e.g. 2D/3D-space, the dist_fast function is 70-240x slower than a pure C implementation, depending on the architecture. For example, in 2D-space on an Intel Pentium 4 (3.0GHz, 1M L2 cache), a single call to dist_fast takes about 1.75 microseconds (or 0.00000175s), while a call to dist_c (C implementation of Eucl. dist), takes about 0.025 microseconds (70x slowdown). On a Core 2 2.5GHz with 6MB L2 this maps to 1.9 and 0.008 microseconds, resp. (i.e. 240x slower), while on a Core i7 2.66GHz with 8MB L2 the numbers are 1.53 and 0.011 microseconds (i.e. 140x slower). For larger dimensions, the gap becomes less big, but is still worrying: 10D: 40-110x; 100D: 10-17x; >1kD: 2.5x-6x. I'm mostly interested in the range 10D to 100D, so seeing that Haskell is over 10x and up to 100x slower than C is kind of making me cry. I've tried some things to improve on this without much luck, on the contrary: *) Marking dist_fast for inlining makes things worse; in general the inlined version is 2x slower for low dimensionality, and even 5x slower for larger dimensionality. This was somewhat surprising to me... *) In a moment of weakness, I used the Foreign Function Interface to call the dist_c C-only implementation from Haskell. Unfortunately, there seems to be a lot of overhead in calling dist_c from Haskell. Most of the performance gain from using C melts away, and sometimes the performance of the FFI'd dist_c is 15-30% worse than the native dist_fast version (especially at low dimensionality). Only for the largest dimensionalities (10k-100kD), the FFI'd version reaches the performance of the native C approach. But, since I'm mostly interested in the 10-100D range, this is of little use to me. One thing I noticed is that compiling through C using -fvia-C -optc-O3 might be a bad idea, depending on your system. On an Intel Pentium 4 system, -fvia-C -optc-O3 was giving me a speedup of up 70% (large dim.), while on Core 2 and Core i7 it resulted in a slowdown of 15-20% ! I was using roughly equal versions of GCC with this, i.e. a self-bootstrapped GCC 4.3.x. So, my question to the list if simple: how can I get better performance out of a Haskell-only approach? Any comments/suggestions are highly appreciated. I'd prefer a Haskell-only approach, but my main concern is speed. The Euclidean distance function will be used quite heavily in various tools. I currently have a C-version of some of the tools, but the amount of code that is needed for those tools is becoming ridiculously big. I believe using Haskell will allow me to come up with a more easy to maintain code base. However, I don't want to pay a huge price for this in terms of performance. greetings, Kenneth [1] MicroBench: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/microbench -- Kenneth Hoste Paris research group - ELIS - Ghent University, Belgium email: kenneth.hoste@elis.ugent.be website: http://www.elis.ugent.be/~kehoste blog: http://boegel.kejo.be From claus.reinke at talk21.com Mon May 18 09:28:25 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon May 18 09:13:17 2009 Subject: [Haskell-cafe] fast Eucl. dist. - Haskell vs C References: Message-ID: > My current best try uses the uvector package, has two 'vectors' of type > (UArr Double) as input, and relies on the sumU and zipWithU functions > which use streaming to compute the result: > > dist_fast :: UArr Double -> UArr Double -> Double > dist_fast p1 p2 = sumDs `seq` sqrt sumDs > where > sumDs = sumU ds > ds = zipWithU euclidean p1 p2 > euclidean x y = d*d > where > d = x-y You'll probably want to make sure that 'euclidian' is specialized to the types you need (here 'Double'), not used overloaded for 'Num a=>a' (check -ddump-tc, or -ddump-simpl output). After that, unrolling the fused fold loop (uvector internal) might help a bit, but isn't there yet: http://hackage.haskell.org/trac/ghc/ticket/3123 http://hackage.haskell.org/trac/ghc/wiki/Inlining And even if that gets implemented, it doesn't apply directly to your case, where the loop is in a library, but you might want to control its unrolling in your client code. Having the loop unrolled by a default factor (8x or so) should help for loops like this, with little computation. Claus From dons at galois.com Mon May 18 09:50:15 2009 From: dons at galois.com (Don Stewart) Date: Mon May 18 09:36:31 2009 Subject: [Haskell-cafe] fast Eucl. dist. - Haskell vs C In-Reply-To: References: Message-ID: <20090518135015.GA16089@whirlpool.galois.com> kenneth.hoste: > Hello, > > For a while now, I've been trying to come up with a fast Haskell-only > function which implements Euclidean distance in n-dimensional space. > > So far, I've been disappointed by the performance of my best effort > in Haskell, compared to C. I'm hoping some of the Haskell experts > and/or performance gurus on this list can help me out on resolving this, > and also maybe shed some light on some strange (imho) things I've run > into. > > My current best try uses the uvector package, has two 'vectors' of type > (UArr Double) as input, and relies on the sumU and zipWithU functions > which use streaming to compute the result: > > dist_fast :: UArr Double -> UArr Double -> Double > dist_fast p1 p2 = sumDs `seq` sqrt sumDs > where > sumDs = sumU ds > ds = zipWithU euclidean p1 p2 > euclidean x y = d*d > where > d = x-y The problem in your uvector code is the use of lists, rather than uvector generators. Replace [1..n] with enumFromTo: import Control.Monad import System.Environment import System.IO import Data.Array.Vector dist :: UArr Double -> UArr Double -> Double dist p1 p2 = sumU (zipWithU euclidean p1 p2) where euclidean x y = d*d where d = x-y main = do [dim] <- map read `fmap` getArgs print $ dist (enumFromToFracU 1.0 dim) (enumFromToFracU 1.0 dim) Now the entire thiing will fuse to a loop. $s$wfold_s1RR :: Double# -> Double# -> Double# -> Double# $s$wfold_s1RR = \ (sc_s1RH :: Double#) (sc1_s1RI :: Double#) (sc2_s1RJ :: Double#) -> case >## sc1_s1RI a5_s1QR of wild4_a1tn { False -> case >## sc_s1RH a5_s1QR of wild5_X1vx { False -> let { x1_a1Jg [ALWAYS Just L] :: Double# x1_a1Jg = -## sc1_s1RI sc_s1RH } in $s$wfold_s1RR (+## sc_s1RH 1.0) (+## sc1_s1RI 1.0) (+## sc2_s1RJ (*## x1_a1Jg x1_a1Jg)); True -> sc2_s1RJ }; True -> sc2_s1RJ }; } in case $s$wfold_s1RR 1.0 1.0 0.0 of ww_s1QH { __DEFAULT -> a19 (D# ww_s1QH) and this assembly: $ ghc -O2 -fvia-C -optc-O3 s1T9_info: movsd 5(%rbx), %xmm7 ucomisd %xmm7, %xmm6 ja .L15 ucomisd %xmm7, %xmm5 jbe .L18 .L14: .L15: movsd (%rbp), %xmm5 leaq 8(%rbp), %rbp jmp *(%rbp) .L18: movapd %xmm6, %xmm7 subsd %xmm5, %xmm7 mulsd %xmm7, %xmm7 addsd (%rbp), %xmm7 movsd %xmm7, (%rbp) movsd .LC0(%rip), %xmm7 addsd %xmm7, %xmm5 addsd %xmm7, %xmm6 jmp s1T9_info Which I'd wager will match the C, which has to allocate the two arrays (GHC essentially decides it doesn't need the arrays any more. -- Don From gue.schmidt at web.de Mon May 18 10:25:35 2009 From: gue.schmidt at web.de (=?UTF-8?B?R8O8wp9udGhlciBTY2htaWR0?=) Date: Mon May 18 10:10:32 2009 Subject: [Haskell-cafe] Trying to Express Constraints using a data structure Message-ID: Hi all, I'm trying to express a constraint using a data structure. Let's say I'd want to express a "mapping" of a to b, c to b, d to b and e to f. A mapping can also be from a to a, b to b and so on. The constraint is that one cannot map a to b if b was already "mapped" to let's say c. I'd like to express this constraint in a data structure, but haven't figured out how, yet. Any suggestions? G?nther From vanenkj at gmail.com Mon May 18 11:16:17 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon May 18 11:01:04 2009 Subject: [Haskell-cafe] Haskell in 3 Slides Message-ID: Hi all, I'm giving a presentation to an IEEE group on Embedded DSL's and Haskell at the end of June. I need a 3 to 4 slide introduction to Haskell. What suggestions does the community have? Is such a short intro possible? It just needs to introduce the basics so I can show some code without alienating the audience. I'm hoping some one else has attempted this before, but if not, some boiler plate slides could be useful for every one! -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/65904e68/attachment.html From ekirpichov at gmail.com Mon May 18 11:19:11 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Mon May 18 11:03:57 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: References: Message-ID: <5e0214850905180819v56eb986x9c26fad9f069e5ca@mail.gmail.com> Just please don't show them qsort and fibonacci! 2009/5/18 John Van Enk : > Hi all, > > I'm giving a presentation to an IEEE group on Embedded DSL's and Haskell at > the end of June. I need a 3 to 4 slide introduction to Haskell. What > suggestions does the community have? Is such a short intro possible? > > It just needs to introduce the basics so I can show some code without > alienating the audience. I'm hoping some one else has attempted this before, > but if not, some boiler plate slides could be useful for every one! > -- > /jve > > _______________________________________________ > 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 dons at galois.com Mon May 18 11:18:23 2009 From: dons at galois.com (Don Stewart) Date: Mon May 18 11:04:38 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: References: Message-ID: <20090518151823.GC16322@whirlpool.galois.com> vanenkj: > Hi all, > > I'm giving a presentation to an IEEE group on Embedded DSL's and Haskell at the > end of June. I need a 3 to 4 slide introduction to Haskell. What suggestions > does the community have? Is such a short intro possible? > > It just needs to introduce the basics so I can show some code without > alienating the audience. I'm hoping some one else has attempted this before, > but if not, some boiler plate slides could be useful for every one! Boil down SimonPJ's OSCON talk? "A taste of Haskell" http://research.microsoft.com/en-us/um/people/simonpj/papers/haskell-tutorial/index.htm From sam.martin at geomerics.com Mon May 18 11:17:30 2009 From: sam.martin at geomerics.com (Sam Martin) Date: Mon May 18 11:05:41 2009 Subject: [Haskell-cafe] de-sugared code? (branch from: fast Eucl. dist. - Haskell vs C) References: <20090518135015.GA16089@whirlpool.galois.com> Message-ID: Hi Don (and cafe), Given the example you just posted, is there a simple way to generate the de-sugared haskell / core / STG / labelled-assembly versions of a piece of haskell code? For instance, how did you generate the content below? I guess this is the core language version? I'm a C/C++ coder and looking for the equivalent of "Show Disassembly". Cheers, Sam -----Original Message----- From: haskell-cafe-bounces@haskell.org on behalf of Don Stewart Sent: Mon 18/05/2009 14:50 To: Kenneth Hoste Cc: Haskell Cafe mailing list Subject: Re: [Haskell-cafe] fast Eucl. dist. - Haskell vs C kenneth.hoste: > Hello, > > For a while now, I've been trying to come up with a fast Haskell-only > function which implements Euclidean distance in n-dimensional space. > > So far, I've been disappointed by the performance of my best effort > in Haskell, compared to C. I'm hoping some of the Haskell experts > and/or performance gurus on this list can help me out on resolving this, > and also maybe shed some light on some strange (imho) things I've run > into. > > My current best try uses the uvector package, has two 'vectors' of type > (UArr Double) as input, and relies on the sumU and zipWithU functions > which use streaming to compute the result: > > dist_fast :: UArr Double -> UArr Double -> Double > dist_fast p1 p2 = sumDs `seq` sqrt sumDs > where > sumDs = sumU ds > ds = zipWithU euclidean p1 p2 > euclidean x y = d*d > where > d = x-y The problem in your uvector code is the use of lists, rather than uvector generators. Replace [1..n] with enumFromTo: import Control.Monad import System.Environment import System.IO import Data.Array.Vector dist :: UArr Double -> UArr Double -> Double dist p1 p2 = sumU (zipWithU euclidean p1 p2) where euclidean x y = d*d where d = x-y main = do [dim] <- map read `fmap` getArgs print $ dist (enumFromToFracU 1.0 dim) (enumFromToFracU 1.0 dim) Now the entire thiing will fuse to a loop. $s$wfold_s1RR :: Double# -> Double# -> Double# -> Double# $s$wfold_s1RR = \ (sc_s1RH :: Double#) (sc1_s1RI :: Double#) (sc2_s1RJ :: Double#) -> case >## sc1_s1RI a5_s1QR of wild4_a1tn { False -> case >## sc_s1RH a5_s1QR of wild5_X1vx { False -> let { x1_a1Jg [ALWAYS Just L] :: Double# x1_a1Jg = -## sc1_s1RI sc_s1RH } in $s$wfold_s1RR (+## sc_s1RH 1.0) (+## sc1_s1RI 1.0) (+## sc2_s1RJ (*## x1_a1Jg x1_a1Jg)); True -> sc2_s1RJ }; True -> sc2_s1RJ }; } in case $s$wfold_s1RR 1.0 1.0 0.0 of ww_s1QH { __DEFAULT -> a19 (D# ww_s1QH) and this assembly: $ ghc -O2 -fvia-C -optc-O3 s1T9_info: movsd 5(%rbx), %xmm7 ucomisd %xmm7, %xmm6 ja .L15 ucomisd %xmm7, %xmm5 jbe .L18 .L14: .L15: movsd (%rbp), %xmm5 leaq 8(%rbp), %rbp jmp *(%rbp) .L18: movapd %xmm6, %xmm7 subsd %xmm5, %xmm7 mulsd %xmm7, %xmm7 addsd (%rbp), %xmm7 movsd %xmm7, (%rbp) movsd .LC0(%rip), %xmm7 addsd %xmm7, %xmm5 addsd %xmm7, %xmm6 jmp s1T9_info Which I'd wager will match the C, which has to allocate the two arrays (GHC essentially decides it doesn't need the arrays any more. -- Don _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/f2c20d37/attachment.html From ekirpichov at gmail.com Mon May 18 11:22:25 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Mon May 18 11:07:12 2009 Subject: [Haskell-cafe] de-sugared code? (branch from: fast Eucl. dist. - Haskell vs C) In-Reply-To: References: <20090518135015.GA16089@whirlpool.galois.com> Message-ID: <5e0214850905180822g7b131390ndaa25829728fc73@mail.gmail.com> That's the output of ghc -ddump-simpl. 2009/5/18 Sam Martin : > Hi Don (and cafe), > > Given the example you just posted, is there a simple way to generate the > de-sugared haskell / core / STG / labelled-assembly versions of a piece of > haskell code? For instance, how did you generate the content below? I guess > this is the core language version? > > I'm a C/C++ coder and looking for the equivalent of "Show Disassembly". > > Cheers, > Sam > > -----Original Message----- > From: haskell-cafe-bounces@haskell.org on behalf of Don Stewart > Sent: Mon 18/05/2009 14:50 > To: Kenneth Hoste > Cc: Haskell Cafe mailing list > Subject: Re: [Haskell-cafe] fast Eucl. dist. - Haskell vs C > > kenneth.hoste: >> Hello, >> >> For a while now, I've been trying to come up with a fast Haskell-only >> function which implements Euclidean distance in n-dimensional space. >> >> So far, I've been disappointed by the performance of my best effort >> in Haskell, compared to C. I'm hoping some of the Haskell experts >> and/or performance gurus on this list can help me out on resolving this, >> and also maybe shed some light on some strange (imho) things I've run >> into. >> >> My current best try uses the uvector package, has two 'vectors' of type >> (UArr Double)? as input, and relies on the sumU and zipWithU functions >> which use streaming to compute the result: >> >> dist_fast :: UArr Double -> UArr Double -> Double >> dist_fast p1 p2 = sumDs `seq` sqrt sumDs >>???????? where >>???????????????? sumDs???????? = sumU ds >>???????????????? ds??????????? = zipWithU euclidean p1 p2 >>???????????????? euclidean x y = d*d >>???????????????????????? where >>???????????????????????????????? d = x-y > > The problem in your uvector code is the use of lists, rather than uvector > generators. Replace [1..n] with enumFromTo: > > ??? import Control.Monad > ??? import System.Environment > ??? import System.IO > ??? import Data.Array.Vector > > ??? dist :: UArr Double -> UArr Double -> Double > ??? dist p1 p2 = sumU (zipWithU euclidean p1 p2) > ??????? where > ??????????? euclidean x y = d*d where d = x-y > > ??? main = do > ??????? [dim] <- map read `fmap` getArgs > > ??????? print $ > ????????? dist > ??????????? (enumFromToFracU 1.0 dim) > ??????????? (enumFromToFracU 1.0 dim) > > Now the entire thiing will fuse to a loop. > > ????????? $s$wfold_s1RR :: Double# -> Double# -> Double# -> Double# > > ????????? $s$wfold_s1RR = > ??????????? \ (sc_s1RH :: Double#) > ????????????? (sc1_s1RI :: Double#) > ????????????? (sc2_s1RJ :: Double#) -> > ????????????? case >## sc1_s1RI a5_s1QR of wild4_a1tn { > ??????????????? False -> > ????????????????? case >## sc_s1RH a5_s1QR of wild5_X1vx { > ??????????????????? False -> > ????????????????????? let { > ??????????????????????? x1_a1Jg [ALWAYS Just L] :: Double# > > ??????????????????????? x1_a1Jg = -## sc1_s1RI sc_s1RH } in > ????????????????????? $s$wfold_s1RR > ??????????????????????? (+## sc_s1RH 1.0) > ??????????????????????? (+## sc1_s1RI 1.0) > ??????????????????????? (+## sc2_s1RJ (*## x1_a1Jg x1_a1Jg)); > ??????????????????? True -> sc2_s1RJ > ????????????????? }; > ??????????????? True -> sc2_s1RJ > ????????????? }; } in > ??????? case $s$wfold_s1RR 1.0 1.0 0.0 of ww_s1QH { __DEFAULT -> > ??????? a19 (D# ww_s1QH) > > and this assembly: > > ??? $ ghc -O2 -fvia-C -optc-O3 > > ????? s1T9_info: > ????????? movsd?????? 5(%rbx), %xmm7 > ????????? ucomisd???? %xmm7, %xmm6 > ????????? ja? .L15 > ????????? ucomisd???? %xmm7, %xmm5 > ????????? jbe .L18 > ??????? .L14: > ??????? .L15: > ????????? movsd?????? (%rbp), %xmm5 > ????????? leaq??????? 8(%rbp), %rbp > ????????? jmp *(%rbp) > ??????? .L18: > ????????? movapd????? %xmm6, %xmm7 > ????????? subsd?????? %xmm5, %xmm7 > ????????? mulsd?????? %xmm7, %xmm7 > ????????? addsd?????? (%rbp), %xmm7 > ????????? movsd?????? %xmm7, (%rbp) > ????????? movsd?????? .LC0(%rip), %xmm7 > ????????? addsd?????? %xmm7, %xmm5 > ????????? addsd?????? %xmm7, %xmm6 > ????????? jmp s1T9_info > > Which I'd wager will match the C, which has to allocate the two arrays (GHC > essentially decides it doesn't need the arrays any more. > > -- Don > _______________________________________________ > 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 dons at galois.com Mon May 18 11:21:25 2009 From: dons at galois.com (Don Stewart) Date: Mon May 18 11:07:45 2009 Subject: [Haskell-cafe] Re: de-sugared code? (branch from: fast Eucl. dist. - Haskell vs C) In-Reply-To: References: <20090518135015.GA16089@whirlpool.galois.com> Message-ID: <20090518152125.GE16322@whirlpool.galois.com> Yes, I use the ghc-core tool: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ghc-core sam.martin: > Hi Don (and cafe), > > Given the example you just posted, is there a simple way to generate the > de-sugared haskell / core / STG / labelled-assembly versions of a piece of > haskell code? For instance, how did you generate the content below? I guess > this is the core language version? > > I'm a C/C++ coder and looking for the equivalent of "Show Disassembly". > > Cheers, > Sam > > -----Original Message----- > From: haskell-cafe-bounces@haskell.org on behalf of Don Stewart > Sent: Mon 18/05/2009 14:50 > To: Kenneth Hoste > Cc: Haskell Cafe mailing list > Subject: Re: [Haskell-cafe] fast Eucl. dist. - Haskell vs C > > kenneth.hoste: > > Hello, > > > > For a while now, I've been trying to come up with a fast Haskell-only > > function which implements Euclidean distance in n-dimensional space. > > > > So far, I've been disappointed by the performance of my best effort > > in Haskell, compared to C. I'm hoping some of the Haskell experts > > and/or performance gurus on this list can help me out on resolving this, > > and also maybe shed some light on some strange (imho) things I've run > > into. > > > > My current best try uses the uvector package, has two 'vectors' of type > > (UArr Double) as input, and relies on the sumU and zipWithU functions > > which use streaming to compute the result: > > > > dist_fast :: UArr Double -> UArr Double -> Double > > dist_fast p1 p2 = sumDs `seq` sqrt sumDs > > where > > sumDs = sumU ds > > ds = zipWithU euclidean p1 p2 > > euclidean x y = d*d > > where > > d = x-y > > The problem in your uvector code is the use of lists, rather than uvector > generators. Replace [1..n] with enumFromTo: > > import Control.Monad > import System.Environment > import System.IO > import Data.Array.Vector > > dist :: UArr Double -> UArr Double -> Double > dist p1 p2 = sumU (zipWithU euclidean p1 p2) > where > euclidean x y = d*d where d = x-y > > main = do > [dim] <- map read `fmap` getArgs > > print $ > dist > (enumFromToFracU 1.0 dim) > (enumFromToFracU 1.0 dim) > > Now the entire thiing will fuse to a loop. > > $s$wfold_s1RR :: Double# -> Double# -> Double# -> Double# > > $s$wfold_s1RR = > \ (sc_s1RH :: Double#) > (sc1_s1RI :: Double#) > (sc2_s1RJ :: Double#) -> > case >## sc1_s1RI a5_s1QR of wild4_a1tn { > False -> > case >## sc_s1RH a5_s1QR of wild5_X1vx { > False -> > let { > x1_a1Jg [ALWAYS Just L] :: Double# > > x1_a1Jg = -## sc1_s1RI sc_s1RH } in > $s$wfold_s1RR > (+## sc_s1RH 1.0) > (+## sc1_s1RI 1.0) > (+## sc2_s1RJ (*## x1_a1Jg x1_a1Jg)); > True -> sc2_s1RJ > }; > True -> sc2_s1RJ > }; } in > case $s$wfold_s1RR 1.0 1.0 0.0 of ww_s1QH { __DEFAULT -> > a19 (D# ww_s1QH) > > and this assembly: > > $ ghc -O2 -fvia-C -optc-O3 > > s1T9_info: > movsd 5(%rbx), %xmm7 > ucomisd %xmm7, %xmm6 > ja .L15 > ucomisd %xmm7, %xmm5 > jbe .L18 > .L14: > .L15: > movsd (%rbp), %xmm5 > leaq 8(%rbp), %rbp > jmp *(%rbp) > .L18: > movapd %xmm6, %xmm7 > subsd %xmm5, %xmm7 > mulsd %xmm7, %xmm7 > addsd (%rbp), %xmm7 > movsd %xmm7, (%rbp) > movsd .LC0(%rip), %xmm7 > addsd %xmm7, %xmm5 > addsd %xmm7, %xmm6 > jmp s1T9_info > > Which I'd wager will match the C, which has to allocate the two arrays (GHC > essentially decides it doesn't need the arrays any more. > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From sam.martin at geomerics.com Mon May 18 11:29:58 2009 From: sam.martin at geomerics.com (Sam Martin) Date: Mon May 18 11:15:12 2009 Subject: [Haskell-cafe] RE: de-sugared code? (branch from: fast Eucl. dist. - Haskell vs C) References: <20090518135015.GA16089@whirlpool.galois.com> <20090518152125.GE16322@whirlpool.galois.com> Message-ID: Brilliant! Thanks. -----Original Message----- From: Don Stewart [mailto:dons@galois.com] Sent: Mon 18/05/2009 16:21 To: Sam Martin Cc: Kenneth Hoste; Haskell Cafe mailing list Subject: Re: de-sugared code? (branch from: fast Eucl. dist. - Haskell vs C) Yes, I use the ghc-core tool: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ghc-core sam.martin: > Hi Don (and cafe), > > Given the example you just posted, is there a simple way to generate the > de-sugared haskell / core / STG / labelled-assembly versions of a piece of > haskell code? For instance, how did you generate the content below? I guess > this is the core language version? > > I'm a C/C++ coder and looking for the equivalent of "Show Disassembly". > > Cheers, > Sam > > -----Original Message----- > From: haskell-cafe-bounces@haskell.org on behalf of Don Stewart > Sent: Mon 18/05/2009 14:50 > To: Kenneth Hoste > Cc: Haskell Cafe mailing list > Subject: Re: [Haskell-cafe] fast Eucl. dist. - Haskell vs C > > kenneth.hoste: > > Hello, > > > > For a while now, I've been trying to come up with a fast Haskell-only > > function which implements Euclidean distance in n-dimensional space. > > > > So far, I've been disappointed by the performance of my best effort > > in Haskell, compared to C. I'm hoping some of the Haskell experts > > and/or performance gurus on this list can help me out on resolving this, > > and also maybe shed some light on some strange (imho) things I've run > > into. > > > > My current best try uses the uvector package, has two 'vectors' of type > > (UArr Double) as input, and relies on the sumU and zipWithU functions > > which use streaming to compute the result: > > > > dist_fast :: UArr Double -> UArr Double -> Double > > dist_fast p1 p2 = sumDs `seq` sqrt sumDs > > where > > sumDs = sumU ds > > ds = zipWithU euclidean p1 p2 > > euclidean x y = d*d > > where > > d = x-y > > The problem in your uvector code is the use of lists, rather than uvector > generators. Replace [1..n] with enumFromTo: > > import Control.Monad > import System.Environment > import System.IO > import Data.Array.Vector > > dist :: UArr Double -> UArr Double -> Double > dist p1 p2 = sumU (zipWithU euclidean p1 p2) > where > euclidean x y = d*d where d = x-y > > main = do > [dim] <- map read `fmap` getArgs > > print $ > dist > (enumFromToFracU 1.0 dim) > (enumFromToFracU 1.0 dim) > > Now the entire thiing will fuse to a loop. > > $s$wfold_s1RR :: Double# -> Double# -> Double# -> Double# > > $s$wfold_s1RR = > \ (sc_s1RH :: Double#) > (sc1_s1RI :: Double#) > (sc2_s1RJ :: Double#) -> > case >## sc1_s1RI a5_s1QR of wild4_a1tn { > False -> > case >## sc_s1RH a5_s1QR of wild5_X1vx { > False -> > let { > x1_a1Jg [ALWAYS Just L] :: Double# > > x1_a1Jg = -## sc1_s1RI sc_s1RH } in > $s$wfold_s1RR > (+## sc_s1RH 1.0) > (+## sc1_s1RI 1.0) > (+## sc2_s1RJ (*## x1_a1Jg x1_a1Jg)); > True -> sc2_s1RJ > }; > True -> sc2_s1RJ > }; } in > case $s$wfold_s1RR 1.0 1.0 0.0 of ww_s1QH { __DEFAULT -> > a19 (D# ww_s1QH) > > and this assembly: > > $ ghc -O2 -fvia-C -optc-O3 > > s1T9_info: > movsd 5(%rbx), %xmm7 > ucomisd %xmm7, %xmm6 > ja .L15 > ucomisd %xmm7, %xmm5 > jbe .L18 > .L14: > .L15: > movsd (%rbp), %xmm5 > leaq 8(%rbp), %rbp > jmp *(%rbp) > .L18: > movapd %xmm6, %xmm7 > subsd %xmm5, %xmm7 > mulsd %xmm7, %xmm7 > addsd (%rbp), %xmm7 > movsd %xmm7, (%rbp) > movsd .LC0(%rip), %xmm7 > addsd %xmm7, %xmm5 > addsd %xmm7, %xmm6 > jmp s1T9_info > > Which I'd wager will match the C, which has to allocate the two arrays (GHC > essentially decides it doesn't need the arrays any more. > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/1596ca8a/attachment.html From claus.reinke at talk21.com Mon May 18 11:43:57 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon May 18 11:28:51 2009 Subject: [Haskell-cafe] fast Eucl. dist. - Haskell vs C References: Message-ID: <2205C681F88A4663B4EC3CD4717C976A@cr3lt> >> dist_fast :: UArr Double -> UArr Double -> Double >> dist_fast p1 p2 = sumDs `seq` sqrt sumDs >> where >> sumDs = sumU ds >> ds = zipWithU euclidean p1 p2 >> euclidean x y = d*d >> where >> d = x-y > > You'll probably want to make sure that 'euclidian' is specialized to > the types you need (here 'Double'), not used overloaded for 'Num a=>a' > (check -ddump-tc, or -ddump-simpl output). Sorry about that misdirection - as it happened, I was looking at the tc output for 'dist_fast' (euclidean :: forall a. (Num a) => a -> a -> a), but the simpl output for 'dist_fast_inline' .., which uses things like __inline_me .. case Dist.sumU (Dist.$wzipWithU .. GHC.Num.- @ GHC.Types.Double GHC.Float.$f9 x_aLt y_aLv Once I actually add a 'dist_fast_inline_caller', that indirection disappears in the inlined code, just as it does for dist_fast itself. dist_fast_inlined_caller :: UArr Double -> UArr Double -> Bool dist_fast_inlined_caller p1 p2 = dist_fast_inlined p1 p2 > 2 However, in the simpl output for 'dist_fast_inline_caller', the 'sumU' and 'zipWithU' still don't seem to be fused - Don? Claus From leimy2k at gmail.com Mon May 18 11:56:06 2009 From: leimy2k at gmail.com (David Leimbach) Date: Mon May 18 11:40:52 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: References: Message-ID: <3e1162e60905180856w53173f73i388cb7acbcfb00dc@mail.gmail.com> Use an incredibly small font. On Mon, May 18, 2009 at 8:16 AM, John Van Enk wrote: > Hi all, > > I'm giving a presentation to an IEEE group on Embedded DSL's and Haskell at > the end of June. I need a 3 to 4 slide introduction to Haskell. What > suggestions does the community have? Is such a short intro possible? > > It just needs to introduce the basics so I can show some code without > alienating the audience. I'm hoping some one else has attempted this before, > but if not, some boiler plate slides could be useful for every one! > > -- > /jve > > _______________________________________________ > 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/20090518/6379ec67/attachment.html From dons at galois.com Mon May 18 11:55:05 2009 From: dons at galois.com (Don Stewart) Date: Mon May 18 11:41:17 2009 Subject: [Haskell-cafe] fast Eucl. dist. - Haskell vs C In-Reply-To: <2205C681F88A4663B4EC3CD4717C976A@cr3lt> References: <2205C681F88A4663B4EC3CD4717C976A@cr3lt> Message-ID: <20090518155505.GH16322@whirlpool.galois.com> claus.reinke: >>> dist_fast :: UArr Double -> UArr Double -> Double >>> dist_fast p1 p2 = sumDs `seq` sqrt sumDs >>> where >>> sumDs = sumU ds >>> ds = zipWithU euclidean p1 p2 >>> euclidean x y = d*d >>> where >>> d = x-y >> >> You'll probably want to make sure that 'euclidian' is specialized to >> the types you need (here 'Double'), not used overloaded for 'Num a=>a' >> (check -ddump-tc, or -ddump-simpl output). > > Sorry about that misdirection - as it happened, I was looking at the tc > output for 'dist_fast' (euclidean :: forall a. (Num a) => a -> a -> a), > but the simpl output for 'dist_fast_inline' .., which uses things like > > __inline_me .. > case Dist.sumU (Dist.$wzipWithU .. > GHC.Num.- @ GHC.Types.Double GHC.Float.$f9 x_aLt y_aLv > > Once I actually add a 'dist_fast_inline_caller', that indirection > disappears in the inlined code, just as it does for dist_fast itself. > > dist_fast_inlined_caller :: UArr Double -> UArr Double -> Bool > dist_fast_inlined_caller p1 p2 = dist_fast_inlined p1 p2 > 2 > > However, in the simpl output for 'dist_fast_inline_caller', the > 'sumU' and 'zipWithU' still don't seem to be fused - Don? All the 'seq's and so on should be unnecessary, and even so, I still get the expected fusion: import Control.Monad import System.Environment import System.IO import Data.Array.Vector {- dist :: UArr Double -> UArr Double -> Double dist p1 p2 = sumU (zipWithU euclidean p1 p2) where euclidean x y = d*d where d = x-y -} main = do [dim] <- map read `fmap` getArgs print $ dist_fast_inlined (enumFromToFracU 1.0 dim) (enumFromToFracU 1.0 dim) dist_fast_inlined :: UArr Double -> UArr Double -> Double {-# INLINE dist_fast_inlined #-} dist_fast_inlined p1 p2 = sumDs `seq` sqrt sumDs where sumDs = sumU ds ds = zipWithU euclidean p1 p2 euclidean x y = d*d where d = x-y {- 19 RuleFired 2 /## 3 SC:$wfold0 5 int2Double# 1 map 1 mapList 3 streamU/unstreamU 2 truncate/Double->Int 1 unpack 1 unpack-list $s$wfold_s1TB :: Double# -> Double# -> Double# -> Double# -} From donnie at darthik.com Mon May 18 12:19:37 2009 From: donnie at darthik.com (Donnie Jones) Date: Mon May 18 12:04:23 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: <3e1162e60905180856w53173f73i388cb7acbcfb00dc@mail.gmail.com> References: <3e1162e60905180856w53173f73i388cb7acbcfb00dc@mail.gmail.com> Message-ID: Use an incredibly small font AND Haskell FRP [1] to zoom and enlarge the font as you move your mouse over the text. ;) 1. http://en.wikipedia.org/wiki/Functional_reactive_programming -- Donnie Jones On Mon, May 18, 2009 at 10:56 AM, David Leimbach wrote: > Use an incredibly small font. > > On Mon, May 18, 2009 at 8:16 AM, John Van Enk wrote: >> >> Hi all, >> >> I'm giving a presentation to an IEEE group on Embedded DSL's and Haskell >> at the end of June. I need a 3 to 4 slide introduction to Haskell. What >> suggestions does the community have? Is such a short intro possible? >> >> It just needs to introduce the basics so I can show some code without >> alienating the audience. I'm hoping some one else has attempted this before, >> but if not, some boiler plate slides could be useful for every one! >> -- >> /jve >> >> _______________________________________________ >> 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 Steve.Schuldenzucker at web.de Mon May 18 12:24:48 2009 From: Steve.Schuldenzucker at web.de (Steffen Schuldenzucker) Date: Mon May 18 12:10:52 2009 Subject: [Haskell-cafe] Trying to Express Constraints using a data structure In-Reply-To: References: Message-ID: <20090518162448.GA5543@gandalf.mittelerde> On 16:25 Mon 18 May , G??nther Schmidt wrote: > Hi all, > > I'm trying to express a constraint using a data structure. > > Let's say I'd want to express a "mapping" of a to b, c to b, d to b and e > to f. > > A mapping can also be from a to a, b to b and so on. > > The constraint is that one cannot map a to b if b was already "mapped" to > let's say c. > > I'd like to express this constraint in a data structure, but haven't > figured out how, yet. Hum, there was that paper where they developed a DSL for GPU computations. I remember there was the problem that GPUs can't compute "maps of maps" and they solved it using a data structure: http://www.cse.unsw.edu.au/~chak/papers/LCGK09.html Hope that helps. Steffen From jfredett at gmail.com Mon May 18 12:29:36 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon May 18 12:14:28 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: <3e1162e60905180856w53173f73i388cb7acbcfb00dc@mail.gmail.com> References: <3e1162e60905180856w53173f73i388cb7acbcfb00dc@mail.gmail.com> Message-ID: <4A118CF0.8070803@gmail.com> While an incredibly small font is a clever option, a more serious suggestion may be as follows. 3-4 slides imply 3-4 topics, so the question is what are the 3-4 biggest topics in haskell? I would think they would be: * Purity/Referential Transparency * Lazy Evaluation * Strong Typing + Type Classes * Monads Assuming you have, say, 10-15 minutes for the talk, and the people there are versed with imperative programming and maybe have some experience in functional programming, you can probably jump over each of those slides in about a minute, just enough to touch the subject. I also assume that you don't need to fit the whole presentation in 3-4 slides, if you do, then .... yah. /Joe David Leimbach wrote: > Use an incredibly small font. > > On Mon, May 18, 2009 at 8:16 AM, John Van Enk > wrote: > > Hi all, > > I'm giving a presentation to an IEEE group on Embedded DSL's and > Haskell at the end of June. I need a 3 to 4 slide introduction to > Haskell. What suggestions does the community have? Is such a short > intro possible? > > It just needs to introduce the basics so I can show some code > without alienating the audience. I'm hoping some one else has > attempted this before, but if not, some boiler plate slides could > be useful for every one! > > -- > /jve > > _______________________________________________ > 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 -------------- 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/20090518/3b1bbec2/jfredett.vcf From vanenkj at gmail.com Mon May 18 12:36:58 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon May 18 12:21:43 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: <4A118CF0.8070803@gmail.com> References: <3e1162e60905180856w53173f73i388cb7acbcfb00dc@mail.gmail.com> <4A118CF0.8070803@gmail.com> Message-ID: Thanks Joe, Your assumption is correct--the whole presentation will be longer. I wanted to use 3 or 4 slides to introduce the language and the balance for the interesting stuff. :P /jve PS to Joe: I will not forget to reply to all. I will not forget to reply to all. I will not forget to reply to all. There, hopefully I won't forget any more. :) On Mon, May 18, 2009 at 12:29 PM, Joe Fredette wrote: > While an incredibly small font is a clever option, a more serious > suggestion may be as follows. > > 3-4 slides imply 3-4 topics, so the question is what are the 3-4 biggest > topics in haskell? I would think they would be: > > * Purity/Referential Transparency > * Lazy Evaluation > * Strong Typing + Type Classes > * Monads > > Assuming you have, say, 10-15 minutes for the talk, and the people there > are versed with imperative programming and maybe have some experience in > functional programming, you can probably jump over each of those slides in > about a minute, just enough to touch the subject. > > I also assume that you don't need to fit the whole presentation in 3-4 > slides, if you do, then .... yah. > > > /Joe > > > David Leimbach wrote: > >> Use an incredibly small font. >> >> On Mon, May 18, 2009 at 8:16 AM, John Van Enk > vanenkj@gmail.com>> wrote: >> >> Hi all, >> I'm giving a presentation to an IEEE group on Embedded DSL's and >> Haskell at the end of June. I need a 3 to 4 slide introduction to >> Haskell. What suggestions does the community have? Is such a short >> intro possible? >> It just needs to introduce the basics so I can show some code >> without alienating the audience. I'm hoping some one else has >> attempted this before, but if not, some boiler plate slides could >> be useful for every one! >> >> -- /jve >> >> _______________________________________________ >> 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 >> >> > -- /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/dc4f12f2/attachment.html From wagner.andrew at gmail.com Mon May 18 12:40:13 2009 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Mon May 18 12:25:46 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: References: <3e1162e60905180856w53173f73i388cb7acbcfb00dc@mail.gmail.com> <4A118CF0.8070803@gmail.com> Message-ID: Don't forget to include higher-order functions in one of those important points. On Mon, May 18, 2009 at 12:36 PM, John Van Enk wrote: > Thanks Joe, > > Your assumption is correct--the whole presentation will be longer. I wanted > to use 3 or 4 slides to introduce the language and the balance for the > interesting stuff. :P > > /jve > > PS to Joe: I will not forget to reply to all. I will not forget to reply to > all. I will not forget to reply to all. There, hopefully I won't forget any > more. :) > > On Mon, May 18, 2009 at 12:29 PM, Joe Fredette wrote: > >> While an incredibly small font is a clever option, a more serious >> suggestion may be as follows. >> >> 3-4 slides imply 3-4 topics, so the question is what are the 3-4 biggest >> topics in haskell? I would think they would be: >> >> * Purity/Referential Transparency >> * Lazy Evaluation >> * Strong Typing + Type Classes >> * Monads >> >> Assuming you have, say, 10-15 minutes for the talk, and the people there >> are versed with imperative programming and maybe have some experience in >> functional programming, you can probably jump over each of those slides in >> about a minute, just enough to touch the subject. >> >> I also assume that you don't need to fit the whole presentation in 3-4 >> slides, if you do, then .... yah. >> >> >> /Joe >> >> >> David Leimbach wrote: >> >>> Use an incredibly small font. >>> >>> On Mon, May 18, 2009 at 8:16 AM, John Van Enk >> vanenkj@gmail.com>> wrote: >>> >>> Hi all, >>> I'm giving a presentation to an IEEE group on Embedded DSL's and >>> Haskell at the end of June. I need a 3 to 4 slide introduction to >>> Haskell. What suggestions does the community have? Is such a short >>> intro possible? >>> It just needs to introduce the basics so I can show some code >>> without alienating the audience. I'm hoping some one else has >>> attempted this before, but if not, some boiler plate slides could >>> be useful for every one! >>> >>> -- /jve >>> >>> _______________________________________________ >>> 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 >>> >>> >> > > > -- > /jve > > _______________________________________________ > 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/20090518/f09b690b/attachment.html From ekirpichov at gmail.com Mon May 18 12:45:44 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Mon May 18 12:30:30 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: <4A118CF0.8070803@gmail.com> References: <3e1162e60905180856w53173f73i388cb7acbcfb00dc@mail.gmail.com> <4A118CF0.8070803@gmail.com> Message-ID: <5e0214850905180945i3af2729cyf533cf426f0b35f3@mail.gmail.com> Actually, I don't think it's a good idea to introduce monads on one of the 3-4 slides. While it *is* a core concept, it's not one of the advertising "bullet points"; and 1 slide is not enough to show what *use* monads are, let alone what they actually *are*. I'd probably suggest you to show something parallelism-related on that slide: for example, STM. Showing an "atomically do foo" and saying "And here, we atomically do foo" may turn out impressive :) And yes, of course HOF's. Also, on the Strong Typing slide, probably you could fit in an algebraic datatype and a smallish function over it in pattern-matched style. 2009/5/18 Joe Fredette : > While an incredibly small font is a clever option, a more serious suggestion > may be as follows. > > 3-4 slides imply 3-4 topics, so the question is what are the 3-4 biggest > topics in haskell? I would think they would be: > > * Purity/Referential Transparency > * Lazy Evaluation > * Strong Typing + Type Classes > * Monads > > Assuming you have, say, 10-15 minutes for the talk, and the people there are > versed with imperative programming and maybe have some experience in > functional programming, you can probably jump over each of those slides in > about a minute, just enough to touch the subject. > > I also assume that you don't need to fit the whole presentation in 3-4 > slides, if you do, then .... yah. > > > /Joe > > > David Leimbach wrote: >> >> Use an incredibly small font. >> >> On Mon, May 18, 2009 at 8:16 AM, John Van Enk > > wrote: >> >> ? ?Hi all, >> ? ? ? ?I'm giving a presentation to an IEEE group on Embedded DSL's and >> ? ?Haskell at the end of June. I need a 3 to 4 slide introduction to >> ? ?Haskell. What suggestions does the community have? Is such a short >> ? ?intro possible? >> ? ? ? ?It just needs to introduce the basics so I can show some code >> ? ?without alienating the audience. I'm hoping some one else has >> ? ?attempted this before, but if not, some boiler plate slides could >> ? ?be useful for every one! >> >> ? ?-- ? ?/jve >> >> ? ?_______________________________________________ >> ? ?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 > > -- Eugene Kirpichov Web IR developer, market.yandex.ru From Sven.Panne at aedion.de Mon May 18 12:48:48 2009 From: Sven.Panne at aedion.de (Sven Panne) Date: Mon May 18 12:33:35 2009 Subject: [Haskell-cafe] Data.Binary and little endian encoding In-Reply-To: <20090517130829.GA11021@whirlpool.galois.com> References: <3e1162e60905142057u51f31009id58c981795c9d99f@mail.gmail.com> <200905171304.43292.Sven.Panne@aedion.de> <20090517130829.GA11021@whirlpool.galois.com> Message-ID: <200905181848.49015.Sven.Panne@aedion.de> Am Sonntag, 17. Mai 2009 15:08:29 schrieb Don Stewart: > Sven.Panne: > > [...] > > I think most problems can be fixed in a rather pragmatic way by adding a > > few functions to the binary package: > [...] > Patches are welcome. Attached. A few remarks: * This is only a quick and mildly tested implementation of the IEEE functions, especially NaNs, infinities and denormalized numbers are untested. These problems could totally be avoided if we can coerce representations directly, changing only their interpretation. * The *host functions assume an IEEE platform, but this can easily be changed (see comments). * Perhaps one can use unsafeCoerce for word32ToFloat and friends, but I haven't checked this. * I've seen a few "{- INLINE -}" comments. Is this really wanted or only a typo? * A comment about using peek/poke for the *le/*be functions is wrong, because this would introduce alignment constraints on some platforms. I think the main point is to provide a nice and efficient API, hiding all the dirty stuff in the implementation. > > One final remarks: I think the low level functions of the binary package > > should really keep the notions of "endianess" and "alignment constraints" > > separate, something which isn't done currently: The *host functions have > > alignment restrictions, the *be/*le functions don't. There is no good > > reason for this non-orthogonality. > > That seems reasonable. There are various ways to achieve this, but the most obvious way leads to a combinatorial explosion of functions: * 3 (LE/BE/host) * 2 (aligned/unaligned) Furthermore, it would be good to split the binary package into the 2 layers already discussed first, then it is perhaps a bit clearer what a nice API would look like. I think it would be best to shift this API design discussion to the libraries list. Cheers, S. -------------- next part -------------- A non-text attachment was scrubbed... Name: ieee.patch Type: text/x-patch Size: 11053 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/2a4783ca/ieee.bin From ryani.spam at gmail.com Mon May 18 12:49:21 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon May 18 12:34:07 2009 Subject: [Haskell-cafe] tips on using monads In-Reply-To: <4A1133A9.9020307@kent.ac.uk> References: <4A10E7BA.6020603@alumni.caltech.edu> <4A1133A9.9020307@kent.ac.uk> Message-ID: <2f9b2d30905180949t64ef80cdhd8aad94757478438@mail.gmail.com> On Mon, May 18, 2009 at 3:08 AM, Neil Brown wrote: > With ErrorT you can use throwError when you want to break out of the > block and give back an error, which seems to fit what you were doing. Of course, now that you are using throwError, you can remove a lot of the extra indentation: > insertNote :: NoteRecord -> Connection -> IO () > insertNote nr conn = either putStrLn return =<< runErrorT > ?(do -- Check if it exists in the database already. > ? ? ?status <- liftIO $ checkPreExistingText nr conn > ? ? ?when status $ throwError "Skipping... text exists already." > ? ? ?-- Find best fit for all topics and source. > ? ? ?-- See type signatures below. > ? ? ?bestFitTopics <- liftIO $ fitTopics nr conn > ? ? ?bestFitSource <- liftIO $ fitSource nr conn > ? ? ?when (any isNothing bestFitTopics) $ throwError "Error... some topic couldn't be matched." > ? ? ?when (isNothing bestFitSource) $ throwError "Error.. source couldn't be matched." > ? ? ?b <- liftIO $ isUserOkay nr bestFitTopics bestFitSource > ? ? ?when (not b) $ throwError "Abort due to user request." > ? ? ?-- Create a new NoteRecord with matched > ? ? ?-- and validated topics/source. > ? ? ?let nrValidated = nr { recordTopics = bestFitTopics, recordSource = bestFitSource } > ? ? ?liftIO $ insertRow nrValidated conn > ?) -- ryan From claus.reinke at talk21.com Mon May 18 12:58:50 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon May 18 12:43:42 2009 Subject: [Haskell-cafe] tips on using monads References: <4A10E7BA.6020603@alumni.caltech.edu> <6AE44F3342CD4196981458A075BB769B@cr3lt> <4A1185ED.7080009@alumni.caltech.edu> Message-ID: >>> I've got one of those algorithms which "threatens to march off the right edge" (in the words of >>> Goerzen et al). I need something like a State or Maybe monad, but this is inside the IO monad. >>> So I presume I need StateT or MaybeT. However, I'm still (sdlowly) learning about monads from >>> first principles. I thought I might present my code and get some pointers... maybe someone could >>> actually show me how to rewrite it, which would be a neat way to see MaybeT and StateT in >>> action. I'm hoping to get anything from a one-line response to a rewrite of my code. Anything >>> will help. >> >> Perhaps this is useful: >> http://www.haskell.org/haskellwiki/Equational_reasoning_examples#Coding_style:_indentation_creep_with_nested_Maybe > I can't quite tell--is that example in the IO monad? Part of my difficulty is that I'm inside IO. > I know how to do this with Maybe, except that I have to combine Maybe and IO (use MaybeT?) It was in the GHC.Conc.STM monad, so yes, it used a MaybeT and Control.Monad.Trans.MonadTrans's lift (btw, the MonadTrans docs only point to [1], but [2] might also be of interest, if rather more compact/terse). Claus [1] http://web.cecs.pdx.edu/~mpj/pubs/springschool.html [2] http://web.cecs.pdx.edu/~mpj/pubs/modinterp.html From jefferson.r.heard at gmail.com Mon May 18 13:31:20 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Mon May 18 13:16:11 2009 Subject: [Haskell-cafe] ANN: Hieroglyph-2.21 and buster, buster-gtk, and buster-network-2.0 Message-ID: <4165d3a70905181031sdc60a3dkb1e5f413e12e174d@mail.gmail.com> Tons of relevant changes. Almost too many to count... Buster: - Fixed performance and bugs in buster, - split out buster, buster-network, and buster-gtk to make it easier to only build components of the system. - Added new functions in buster for selection and debugging. - Added behaviours in App.Behaviours.PrintEvents for printing only based on Group / Source / Name - Changed name to "ename" (for 'event name') - Added Association Lists to the buster EData type (EAssoc, EAssocL) - future now requires the bus to be passed as the first argument Hieroglyph - OpenGL-backended interactive buster is now functional and high performance if not complete. - Added "Dots" primitive for showing lots of points for things like scatterplots - Got rid of creating Attributes objects in favor of modifying common attributes with combinators; the combinators themselves have the same name as the old attributes, but they are mostly undocumented otherwise because I haven't had time yet. They are found in Graphics.Rendering.Hieroglyph.Visual - Got rid of greater/less detail combinator - Text now takes Text.PrettyPrint.Doc instead of String as the str, accepts Pango markup language, and uses full Layout functionality from Pango, including UTF-8 display. Added Pango markup combinators for Text.PrettyPrint.Docs, mark, bold, bigger, italic, strikethrough, subscript, superscript, smaller, monospace, underline, and span. See Pango documentation for their effect. - Points and Rects are now sensible instances of Num, Fractional, and Ord - Large scenes are now faster overall - Added object naming combinator to support object selection I will have more deails and examples on the blog soon... -- Jeff From nicolas.pouillard at gmail.com Mon May 18 13:30:08 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Mon May 18 13:16:19 2009 Subject: [Haskell-cafe] Re: [Haskell] [ANN] Safe Lazy IO in Haskell In-Reply-To: <42784f260905170645n6316a654me1ecf21a60b3de2@mail.gmail.com> References: <1237574414-sup-7006@ausone.local> <42784f260905170645n6316a654me1ecf21a60b3de2@mail.gmail.com> Message-ID: <1242667496-sup-9738@ausone.local> Excerpts from Jason Dusek's message of Sun May 17 15:45:25 +0200 2009: > From the documentation: > > " LI could be a strict monad and a strict applicative functor. > However it is not a lazy monad nor a lazy applicative > functor as required Haskell. Hopefully it is a lazy > (pointed) functor at least. The type I would need for bind is this one: (>>=) :: NFData sa => LI sa -> (sa -> LI b) -> LI b And because of the NFData constraint this type bind is less general than the required one. BTW this operator is exported as (!>>=) by System.IO.Lazy.Input.Extra. By using the rmonad we could add this NFData constraint, but that's not like having a Monad instance directly. Best regards, -- Nicolas Pouillard From jfredett at gmail.com Mon May 18 13:29:47 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon May 18 13:21:42 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: <5e0214850905180945i3af2729cyf533cf426f0b35f3@mail.gmail.com> References: <3e1162e60905180856w53173f73i388cb7acbcfb00dc@mail.gmail.com> <4A118CF0.8070803@gmail.com> <5e0214850905180945i3af2729cyf533cf426f0b35f3@mail.gmail.com> Message-ID: <4A119B0B.7080708@gmail.com> Well, since the topic was EDSLs, and those generally involve monads (at least from what I've seen), it might be wise to touch on them. However, perhaps the fourth slide would just be a catchall? HOFs, some STM/Monad stuff, etc? The topics I suggested just seem to me to be the 4 core concepts you must understand to use haskell effectively. /joe Eugene Kirpichov wrote: > Actually, I don't think it's a good idea to introduce monads on one of > the 3-4 slides. While it *is* a core concept, it's not one of the > advertising "bullet points"; and 1 slide is not enough to show what > *use* monads are, let alone what they actually *are*. > > I'd probably suggest you to show something parallelism-related on that > slide: for example, STM. Showing an "atomically do foo" and saying > "And here, we atomically do foo" may turn out impressive :) > > And yes, of course HOF's. > > Also, on the Strong Typing slide, probably you could fit in an > algebraic datatype and a smallish function over it in pattern-matched > style. > > 2009/5/18 Joe Fredette : > >> While an incredibly small font is a clever option, a more serious suggestion >> may be as follows. >> >> 3-4 slides imply 3-4 topics, so the question is what are the 3-4 biggest >> topics in haskell? I would think they would be: >> >> * Purity/Referential Transparency >> * Lazy Evaluation >> * Strong Typing + Type Classes >> * Monads >> >> Assuming you have, say, 10-15 minutes for the talk, and the people there are >> versed with imperative programming and maybe have some experience in >> functional programming, you can probably jump over each of those slides in >> about a minute, just enough to touch the subject. >> >> I also assume that you don't need to fit the whole presentation in 3-4 >> slides, if you do, then .... yah. >> >> >> /Joe >> >> >> David Leimbach wrote: >> >>> Use an incredibly small font. >>> >>> On Mon, May 18, 2009 at 8:16 AM, John Van Enk >> > wrote: >>> >>> Hi all, >>> I'm giving a presentation to an IEEE group on Embedded DSL's and >>> Haskell at the end of June. I need a 3 to 4 slide introduction to >>> Haskell. What suggestions does the community have? Is such a short >>> intro possible? >>> It just needs to introduce the basics so I can show some code >>> without alienating the audience. I'm hoping some one else has >>> attempted this before, but if not, some boiler plate slides could >>> be useful for every one! >>> >>> -- /jve >>> >>> _______________________________________________ >>> 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 -------------- 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/20090518/39e9d7bc/jfredett.vcf From miguelimo38 at yandex.ru Mon May 18 13:41:56 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon May 18 13:26:44 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: <4A118CF0.8070803@gmail.com> References: <3e1162e60905180856w53173f73i388cb7acbcfb00dc@mail.gmail.com> <4A118CF0.8070803@gmail.com> Message-ID: On 18 May 2009, at 20:29, Joe Fredette wrote: > While an incredibly small font is a clever option, a more serious > suggestion may be as follows. > > 3-4 slides imply 3-4 topics, so the question is what are the 3-4 > biggest topics in haskell? I would think they would be: > > * Purity/Referential Transparency > * Lazy Evaluation > * Strong Typing + Type Classes > * Monads I'd say monads are not of that importance; parametric polymorphism may be a better choice. > > > Assuming you have, say, 10-15 minutes for the talk, and the people > there are versed with imperative programming and maybe have some > experience in functional programming, you can probably jump over > each of those slides in about a minute, just enough to touch the > subject. > > I also assume that you don't need to fit the whole presentation in > 3-4 slides, if you do, then .... yah. > > > /Joe > > > David Leimbach wrote: >> Use an incredibly small font. >> >> On Mon, May 18, 2009 at 8:16 AM, John Van Enk > >> wrote: >> >> Hi all, >> I'm giving a presentation to an IEEE group on Embedded >> DSL's and >> Haskell at the end of June. I need a 3 to 4 slide introduction to >> Haskell. What suggestions does the community have? Is such a short >> intro possible? >> It just needs to introduce the basics so I can show some code >> without alienating the audience. I'm hoping some one else has >> attempted this before, but if not, some boiler plate slides could >> be useful for every one! >> >> -- /jve >> >> _______________________________________________ >> 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 dons at galois.com Mon May 18 14:05:07 2009 From: dons at galois.com (Don Stewart) Date: Mon May 18 13:51:23 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: <4A118CF0.8070803@gmail.com> References: <3e1162e60905180856w53173f73i388cb7acbcfb00dc@mail.gmail.com> <4A118CF0.8070803@gmail.com> Message-ID: <20090518180507.GA17204@whirlpool.galois.com> jfredett: > While an incredibly small font is a clever option, a more serious > suggestion may be as follows. > > 3-4 slides imply 3-4 topics, so the question is what are the 3-4 biggest > topics in haskell? I would think they would be: > > * Purity/Referential Transparency > * Lazy Evaluation > * Strong Typing + Type Classes > * Monads Parallelism From dons at galois.com Mon May 18 14:06:22 2009 From: dons at galois.com (Don Stewart) Date: Mon May 18 13:52:35 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: <5e0214850905180945i3af2729cyf533cf426f0b35f3@mail.gmail.com> References: <3e1162e60905180856w53173f73i388cb7acbcfb00dc@mail.gmail.com> <4A118CF0.8070803@gmail.com> <5e0214850905180945i3af2729cyf533cf426f0b35f3@mail.gmail.com> Message-ID: <20090518180621.GB17204@whirlpool.galois.com> ekirpichov: > Actually, I don't think it's a good idea to introduce monads on one of > the 3-4 slides. While it *is* a core concept, it's not one of the > advertising "bullet points"; and 1 slide is not enough to show what > *use* monads are, let alone what they actually *are*. > > I'd probably suggest you to show something parallelism-related on that > slide: for example, STM. Showing an "atomically do foo" and saying > "And here, we atomically do foo" may turn out impressive :) > Exactly: focus on what the user wants to do (e.g. write multicore code, write safe code, write code quickly), not how that is achieved: "bounded parametric polymorphism" or "monads" From adam.turoff at gmail.com Mon May 18 14:22:37 2009 From: adam.turoff at gmail.com (Adam Turoff) Date: Mon May 18 14:07:24 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: <20090518180621.GB17204@whirlpool.galois.com> References: <3e1162e60905180856w53173f73i388cb7acbcfb00dc@mail.gmail.com> <4A118CF0.8070803@gmail.com> <5e0214850905180945i3af2729cyf533cf426f0b35f3@mail.gmail.com> <20090518180621.GB17204@whirlpool.galois.com> Message-ID: On Mon, May 18, 2009 at 2:06 PM, Don Stewart wrote: > Exactly: focus on what the user wants to do (e.g. write multicore code, > write safe code, write code quickly), not how that is achieved: > "bounded parametric polymorphism" or "monads" Parametric polymorphism is a big win, and highlights something a user wants to do. A *shallow* overview (one bullet, one function) might fit. Off the top of my head: incr :: (Num a) => a -> a incr = (+ 1) Writing that operation in other languages is either (a) repeated for every numeric type or (b) not typesafe. Haskell is one of the few that delivers both, and that is worth underscoring. And it gives you an opportunity to wave your hands and talk about type inferencing without wasting room on a slide. Don is right. Forget the details. Cover the capabilities, not the mechanics. -- Adam From dons at galois.com Mon May 18 14:29:10 2009 From: dons at galois.com (Don Stewart) Date: Mon May 18 14:15:28 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: References: <3e1162e60905180856w53173f73i388cb7acbcfb00dc@mail.gmail.com> <4A118CF0.8070803@gmail.com> <5e0214850905180945i3af2729cyf533cf426f0b35f3@mail.gmail.com> <20090518180621.GB17204@whirlpool.galois.com> Message-ID: <20090518182910.GC17204@whirlpool.galois.com> adam.turoff: > On Mon, May 18, 2009 at 2:06 PM, Don Stewart wrote: > > Exactly: focus on what the user wants to do (e.g. write multicore code, > > write safe code, write code quickly), not how that is achieved: > > "bounded parametric polymorphism" or "monads" > > Parametric polymorphism is a big win, and highlights something > a user wants to do. A *shallow* overview (one bullet, one > function) might fit. Off the top of my head: > > incr :: (Num a) => a -> a > incr = (+ 1) > > Writing that operation in other languages is either (a) repeated for > every numeric type or (b) not typesafe. Haskell is one of the few > that delivers both, and that is worth underscoring. And it gives > you an opportunity to wave your hands and talk about type > inferencing without wasting room on a slide. > Right, so talk about "Reuse!" (polymorphism) , "Productivity" (type inference) "Performance" (static typing + optimizer) -- Don From ekirpichov at gmail.com Mon May 18 14:33:06 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Mon May 18 14:17:55 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: <20090518182910.GC17204@whirlpool.galois.com> References: <3e1162e60905180856w53173f73i388cb7acbcfb00dc@mail.gmail.com> <4A118CF0.8070803@gmail.com> <5e0214850905180945i3af2729cyf533cf426f0b35f3@mail.gmail.com> <20090518180621.GB17204@whirlpool.galois.com> <20090518182910.GC17204@whirlpool.galois.com> Message-ID: <5e0214850905181133h2487f77mb380f4b1d035318@mail.gmail.com> The main bullet point is missing: Correctness. How could we have forgotten quickcheck? > quickCheck (\xs -> sort (sort xs) == sort xs) OK, 100 tests passed. 2009/5/18 Don Stewart : > adam.turoff: >> On Mon, May 18, 2009 at 2:06 PM, Don Stewart wrote: >> > Exactly: focus on what the user wants to do (e.g. write multicore code, >> > write safe code, write code quickly), not how that is achieved: >> > "bounded parametric polymorphism" or "monads" >> >> Parametric polymorphism is a big win, and highlights something >> a user wants to do. ?A *shallow* overview (one bullet, one >> function) might fit. ?Off the top of my head: >> >> ? incr :: (Num a) => a -> a >> ? incr = (+ 1) >> >> Writing that operation in other languages is either (a) repeated for >> every numeric type or (b) not typesafe. ?Haskell is one of the few >> that delivers both, and that is worth underscoring. ?And it gives >> you an opportunity to wave your hands and talk about type >> inferencing without wasting room on a slide. >> > > Right, so talk about "Reuse!" (polymorphism) , "Productivity" (type > inference) "Performance" (static typing + optimizer) > > -- Don > _______________________________________________ > 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 claus.reinke at talk21.com Mon May 18 14:33:07 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon May 18 14:18:05 2009 Subject: [Haskell-cafe] fast Eucl. dist. - Haskell vs C References: <2205C681F88A4663B4EC3CD4717C976A@cr3lt> <20090518155505.GH16322@whirlpool.galois.com> Message-ID: >> Once I actually add a 'dist_fast_inline_caller', that indirection >> disappears in the inlined code, just as it does for dist_fast itself. >> >> dist_fast_inlined_caller :: UArr Double -> UArr Double -> Bool >> dist_fast_inlined_caller p1 p2 = dist_fast_inlined p1 p2 > 2 >> >> However, in the simpl output for 'dist_fast_inline_caller', the >> 'sumU' and 'zipWithU' still don't seem to be fused - Don? > > All the 'seq's and so on should be unnecessary, and even so, I still get > the expected fusion: As I said, I don't get the fusion if I just add the function above to the original Dist.hs, export it and compile the module with '-c -O2 -ddump-simpl': Dist.dist_fast_inlined_caller = \ (w1_s1nb :: Data.Array.Vector.UArr.UArr GHC.Types.Double) (w2_s1nc :: Data.Array.Vector.UArr.UArr GHC.Types.Double) -> case (Dist.$wzipWithU Dist.lvl2 w1_s1nb w2_s1nc) `cast` (trans Data.Array.Vector.UArr.TFCo:R56:UArr Data.Array.Vector.UArr.NTCo:R56:UArr :: Data.Array.Vector.UArr.UArr GHC.Types.Double ~ Data.Array.Vector.Prim.BUArr.BUArr GHC.Types.Double) of _ { Data.Array.Vector.Prim.BUArr.BUArr ipv_s1lb ipv1_s1lc ipv2_s1ld -> letrec { $wfold_s1nN :: GHC.Prim.Double# -> GHC.Prim.Int# -> GHC.Prim.Double# LclId [Arity 2 Str: DmdType LL] $wfold_s1nN = \ (ww_s1mZ :: GHC.Prim.Double#) (ww1_s1n3 :: GHC.Prim.Int#) -> case GHC.Prim.==# ww1_s1n3 ipv1_s1lc of _ { GHC.Bool.False -> $wfold_s1nN (GHC.Prim.+## ww_s1mZ (GHC.Prim.indexDoubleArray# ipv2_s1ld (GHC.Prim.+# ipv_s1lb ww1_s1n3))) (GHC.Prim.+# ww1_s1n3 1); GHC.Bool.True -> ww_s1mZ }; } in case $wfold_s1nN 0.0 0 of ww_s1n7 { __DEFAULT -> GHC.Prim.>## (GHC.Prim.sqrtDouble# ww_s1n7) 2.0 } } Claus From dons at galois.com Mon May 18 14:34:15 2009 From: dons at galois.com (Don Stewart) Date: Mon May 18 14:20:28 2009 Subject: [Haskell-cafe] fast Eucl. dist. - Haskell vs C In-Reply-To: References: <20090518155505.GH16322@whirlpool.galois.com> Message-ID: <20090518183415.GD17204@whirlpool.galois.com> claus.reinke: >>> Once I actually add a 'dist_fast_inline_caller', that indirection >>> disappears in the inlined code, just as it does for dist_fast itself. >>> >>> dist_fast_inlined_caller :: UArr Double -> UArr Double -> Bool >>> dist_fast_inlined_caller p1 p2 = dist_fast_inlined p1 p2 > 2 >>> >>> However, in the simpl output for 'dist_fast_inline_caller', the >>> 'sumU' and 'zipWithU' still don't seem to be fused - Don? >> >> All the 'seq's and so on should be unnecessary, and even so, I still get >> the expected fusion: > > As I said, I don't get the fusion if I just add the function above to the > original Dist.hs, export it and compile the module with '-c -O2 > -ddump-simpl': I can't reproduce this. Does the complete program fragment I posted earlier yield the desired result? -- Don From claus.reinke at talk21.com Mon May 18 14:54:24 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon May 18 14:39:19 2009 Subject: [Haskell-cafe] fast Eucl. dist. - Haskell vs C References: <20090518155505.GH16322@whirlpool.galois.com> <20090518183415.GD17204@whirlpool.galois.com> Message-ID: <57EFA41AFF2E49F29DC91A6461005D3F@cr3lt> >> As I said, I don't get the fusion if I just add the function above to the >> original Dist.hs, export it and compile the module with '-c -O2 >> -ddump-simpl': > > I can't reproduce this. Interesting. I'm using ghc 6.11.20090320 (windows), uvector-0.1.0.3. I attach the modified Dist.hs and its simpl output, created via: ghc -c Dist.hs -O2 -ddump-tc -ddump-simpl-stats -ddump-simpl > Dist.dumps Perhaps others can confirm the effect? Note that the 'dist_fast' in the same module does get fused, so it is not likely an options issue. I still suspect that the inlining of the 'Dist.zipWith' wrapper in the 'dist_fast_inlined' '__inline_me' has some significance - it is odd to see inlined code in an '__inline_me' and the fusion rule won't trigger on 'Dist.sumU . Dist.$wzipWithU', right? > Does the complete program fragment I posted earlier yield the desired > result? Yes. Note that the original poster also reported slowdown from use of 'dist_fast_inlined'. Claus -------------- next part -------------- A non-text attachment was scrubbed... Name: Dist.dumps Type: application/octet-stream Size: 17732 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/ddf12018/Dist.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: Dist.hs Type: application/octet-stream Size: 1986 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/ddf12018/Dist-0001.obj From ryani.spam at gmail.com Mon May 18 16:57:04 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon May 18 16:41:49 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: <5e0214850905181133h2487f77mb380f4b1d035318@mail.gmail.com> References: <3e1162e60905180856w53173f73i388cb7acbcfb00dc@mail.gmail.com> <4A118CF0.8070803@gmail.com> <5e0214850905180945i3af2729cyf533cf426f0b35f3@mail.gmail.com> <20090518180621.GB17204@whirlpool.galois.com> <20090518182910.GC17204@whirlpool.galois.com> <5e0214850905181133h2487f77mb380f4b1d035318@mail.gmail.com> Message-ID: <2f9b2d30905181357v493f21cem40d297a059a67831@mail.gmail.com> On Mon, May 18, 2009 at 11:33 AM, Eugene Kirpichov wrote: > The main bullet point is missing: Correctness. > > How could we have forgotten quickcheck? > >> quickCheck (\xs -> sort (sort xs) == sort xs) > OK, 100 tests passed. I like this, but given that you have a whole slide, I might write this: isSorted :: Ord a => [a] -> Bool isSorted [] = True isSorted [x] = True isSorted (x:y:rest) = x <= y && isSorted (y:rest) > quickCheck (\xs -> isSorted (sort xs)) OK, 100 tests passed. Or, if you want to lead into a talk about fusion and/or higher order functions: isSorted [] = True isSorted (x:xs) = snd $ foldl' check (head x, True) xs where check (prevElem, restSorted) thisElem = (thisElem, prevElem <= thisElem && restSorted) -- ryan From taralx at gmail.com Mon May 18 18:05:39 2009 From: taralx at gmail.com (Taral) Date: Mon May 18 17:50:43 2009 Subject: [Haskell-cafe] Re: [Haskell] [ANN] Safe Lazy IO in Haskell In-Reply-To: <1242667496-sup-9738@ausone.local> References: <1237574414-sup-7006@ausone.local> <42784f260905170645n6316a654me1ecf21a60b3de2@mail.gmail.com> <1242667496-sup-9738@ausone.local> Message-ID: On Mon, May 18, 2009 at 10:30 AM, Nicolas Pouillard wrote: > The type I would need for bind is this one: > > ?(>>=) :: NFData sa => LI sa -> (sa -> LI b) -> LI b Will this do? (>>=) :: (NFData sa, NFData b) => LI sa -> (sa -> LI b) -> LI b -- Taral "Please let me know if there's any further trouble I can give you." -- Unknown From vigalchin at gmail.com Mon May 18 18:34:40 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Mon May 18 18:48:06 2009 Subject: [Haskell-cafe] old Hugs libraries? Message-ID: <5ae4f2ba0905181534x437f131v6271e17b92a735e4@mail.gmail.com> Hello, Do newSTArray, readSTArray, writeSTArray, etc. belong to an old deprecated Hugs library/module? If so, what is the Haskell 98 replacement? Thanks, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/2a49c9e1/attachment.html From nowgate at yahoo.com Mon May 18 21:19:21 2009 From: nowgate at yahoo.com (michael rice) Date: Mon May 18 21:04:07 2009 Subject: [Haskell-cafe] showing a user defined type Message-ID: <381640.4213.qm@web31101.mail.mud.yahoo.com> I've been playing around with "The Little MLer" (pg. 95, 96) to try to improve my understanding of types. I can ask ML: ? - ints(0); val it = Link (1,fn) : chain - and Haskell: *Main> :t ints 0 ints 0 :: Chain *Main> ints 0 :1:0: ??? No instance for (Show Chain) ????? arising from a use of `print' at :1:0-5 ??? Possible fix: add an instance declaration for (Show Chain) ??? In a stmt of a 'do' expression: print it *Main> I think I need to write a show function for type Chain but not sure how to proceed. Michael =============== ;;ML datatype chain = ? Link of (int * (int -> chain)) fun ints(n) ? = Link(n + 1, ints) ;;Haskell data Chain = Link Int (Int -> Chain) ints :: Int -> Chain ints n = Link (n+1) ints -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/9f4367bc/attachment.html From nowgate at yahoo.com Mon May 18 21:20:58 2009 From: nowgate at yahoo.com (michael rice) Date: Mon May 18 21:05:43 2009 Subject: [Haskell-cafe] showing a user defined type Message-ID: <822841.11181.qm@web31102.mail.mud.yahoo.com> I've been playing around with "The Little MLer" (pg. 95, 96) to try to improve my understanding of types. I can ask ML: ? - ints(0); val it = Link (1,fn) : chain - and Haskell: *Main> :t ints 0 ints 0 :: Chain *Main> ints 0 :1:0: ??? No instance for (Show Chain) ????? arising from a use of `print' at :1:0-5 ??? Possible fix: add an instance declaration for (Show Chain) ??? In a stmt of a 'do' expression: print it *Main> I think I need to write a show function for type Chain but not sure how to proceed. Michael =============== ;;ML datatype chain = ? Link of (int * (int -> chain)) fun ints(n) ? = Link(n + 1, ints) ;;Haskell data Chain = Link Int (Int -> Chain) ints :: Int -> Chain ints n = Link (n+1) ints -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/b3a2d01d/attachment.html From allbery at ece.cmu.edu Mon May 18 21:33:53 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon May 18 21:19:09 2009 Subject: [Haskell-cafe] old Hugs libraries? In-Reply-To: <5ae4f2ba0905181534x437f131v6271e17b92a735e4@mail.gmail.com> References: <5ae4f2ba0905181534x437f131v6271e17b92a735e4@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/20090518/87237833/PGP.bin From allbery at ece.cmu.edu Mon May 18 21:36:05 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon May 18 21:20:56 2009 Subject: [Haskell-cafe] showing a user defined type In-Reply-To: <381640.4213.qm@web31101.mail.mud.yahoo.com> References: <381640.4213.qm@web31101.mail.mud.yahoo.com> Message-ID: <3EBF9246-C867-48D6-B88F-8CE4F2F1917B@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/20090518/332c39ce/PGP.bin From ryani.spam at gmail.com Mon May 18 22:02:00 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon May 18 21:46:44 2009 Subject: [Haskell-cafe] showing a user defined type In-Reply-To: <3EBF9246-C867-48D6-B88F-8CE4F2F1917B@ece.cmu.edu> References: <381640.4213.qm@web31101.mail.mud.yahoo.com> <3EBF9246-C867-48D6-B88F-8CE4F2F1917B@ece.cmu.edu> Message-ID: <2f9b2d30905181902k12368ec1ye9cb203fa693d560@mail.gmail.com> Unfortunately, you can't derive Show on Chain as defined, because it contains a function: > data Chain = Link Int (Int -> Chain) You can write this: > instance Show Chain where > show (Link n _) = "Link " ++ show n ++ " " Or you can make a dummy "Show" instance for functions: > instance Show (a -> b) where show _ = "" > data Chain = Link Int (Int -> Chain) deriving Show One question: Do you expect to ever call the function with a different value? For example: otherChain :: Chain otherChain = case (ints 0) of Link _ f -> f 100 If not, you can replace Chain entirely by [Int], due to laziness, something that's not possible in ML. (Although you can get the same result in ML by using (int * (() -> chain)) instead. -- ryan On Mon, May 18, 2009 at 6:36 PM, Brandon S. Allbery KF8NH wrote: > On May 18, 2009, at 21:19 , michael rice wrote: > > *Main> :t ints 0 > ints 0 :: Chain > *Main> ints 0 > > :1:0: > ??? No instance for (Show Chain) > > In general, you want to append > ?? ?deriving Show > to your types. ?You may also want to be able to input them in ghci, so > instead say > ?? ?deriving (Show, Read) > -- > 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 > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From dave at zednenem.com Mon May 18 22:26:02 2009 From: dave at zednenem.com (David Menendez) Date: Mon May 18 22:10:47 2009 Subject: [Haskell-cafe] showing a user defined type In-Reply-To: <2f9b2d30905181902k12368ec1ye9cb203fa693d560@mail.gmail.com> References: <381640.4213.qm@web31101.mail.mud.yahoo.com> <3EBF9246-C867-48D6-B88F-8CE4F2F1917B@ece.cmu.edu> <2f9b2d30905181902k12368ec1ye9cb203fa693d560@mail.gmail.com> Message-ID: <49a77b7a0905181926r5ade66afy8060091600a610ad@mail.gmail.com> On Mon, May 18, 2009 at 10:02 PM, Ryan Ingram wrote: > Unfortunately, you can't derive Show on Chain as defined, because it > contains a function: Sure you can. I just tried the following, and it compiled without complaints. > import Text.Show.Functions > > data Chain = Link Int (Int -> Chain) deriving (Show) The usual warnings about orphan instances apply, but the purpose of the Text.Show.Functions module is to provide a standard Show instance for functions so that libraries (e.g., QuickCheck) don't declare conflicting instances. -- Dave Menendez From dave at zednenem.com Mon May 18 22:41:14 2009 From: dave at zednenem.com (David Menendez) Date: Mon May 18 22:25:58 2009 Subject: [Haskell-cafe] old Hugs libraries? In-Reply-To: <5ae4f2ba0905181534x437f131v6271e17b92a735e4@mail.gmail.com> References: <5ae4f2ba0905181534x437f131v6271e17b92a735e4@mail.gmail.com> Message-ID: <49a77b7a0905181941o41aa7688u1c68a5163090dd5c@mail.gmail.com> On Mon, May 18, 2009 at 6:34 PM, Vasili I. Galchin wrote: > Hello, > > ????? Do newSTArray, readSTArray, writeSTArray, etc. belong to an old > deprecated Hugs library/module? If so, what is the Haskell 98 replacement? I don't know about Haskell 98, but I think the modern solution is to use newArray, readArray, and writeArray from Data.Array.MArray. There are more details at . -- Dave Menendez From phunge0 at hotmail.com Mon May 18 23:50:11 2009 From: phunge0 at hotmail.com (Brian Bloniarz) Date: Mon May 18 23:34:56 2009 Subject: [Haskell-cafe] Request for feedback: HaskellDB + HList In-Reply-To: References: Message-ID: _________________________________________________________________ Insert movie times and more without leaving Hotmail?. http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd1_052009 From vigalchin at gmail.com Tue May 19 00:12:07 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Mon May 18 23:56:50 2009 Subject: [Haskell-cafe] old Hugs libraries? In-Reply-To: <49a77b7a0905181941o41aa7688u1c68a5163090dd5c@mail.gmail.com> References: <5ae4f2ba0905181534x437f131v6271e17b92a735e4@mail.gmail.com> <49a77b7a0905181941o41aa7688u1c68a5163090dd5c@mail.gmail.com> Message-ID: <5ae4f2ba0905182112o30d14f0et26dceb77ab2d5f91@mail.gmail.com> thank to all respondents! Vasili On Mon, May 18, 2009 at 9:41 PM, David Menendez wrote: > On Mon, May 18, 2009 at 6:34 PM, Vasili I. Galchin > wrote: > > Hello, > > > > Do newSTArray, readSTArray, writeSTArray, etc. belong to an old > > deprecated Hugs library/module? If so, what is the Haskell 98 > replacement? > > I don't know about Haskell 98, but I think the modern solution is to > use newArray, readArray, and writeArray from Data.Array.MArray. > > There are more details at . > > -- > Dave Menendez > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090518/5c584a0d/attachment.html From vigalchin at gmail.com Tue May 19 00:52:38 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Tue May 19 00:37:23 2009 Subject: [Haskell-cafe] Lawvere papers Message-ID: <5ae4f2ba0905182152x31dfaf9em8327e3ccdea98a1e@mail.gmail.com> Hello, I know that some Lawvere papers are available on TAC, but is there a list of all Lawvere papers online and where? Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090519/92cf459e/attachment.html From ryani.spam at gmail.com Tue May 19 01:06:39 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue May 19 00:51:48 2009 Subject: [Haskell-cafe] Re: [Haskell] [ANN] Safe Lazy IO in Haskell In-Reply-To: References: <1237574414-sup-7006@ausone.local> <42784f260905170645n6316a654me1ecf21a60b3de2@mail.gmail.com> <1242667496-sup-9738@ausone.local> Message-ID: <2f9b2d30905182206g4451c67as468c0f85fa2a62cc@mail.gmail.com> On Mon, May 18, 2009 at 3:05 PM, Taral wrote: > Will this do? > > (>>=) :: (NFData sa, NFData b) => LI sa -> (sa -> LI b) -> LI b No, the problem is that >>= on monads has no constraints, it must have the type > LI a -> (a -> LI b) -> LI b This is a common problem with trying to use do-notation; there are some cases where you can't make the object an instance of Monad. The same problem holds for Data.Set; you'd can write setBind :: Ord b => Set a -> (a -> Set b) -> Set b setBind m f = unions (map f $ toList m) but there is no way to use setBind for a definition of >>= -- ryan From z_axis at 163.com Tue May 19 01:07:41 2009 From: z_axis at 163.com (z_axis) Date: Tue May 19 00:52:25 2009 Subject: [Haskell-cafe] How to use Data.ByteString ? Message-ID: <6247530.99671242709661054.JavaMail.coremail@app176.163.com> Hi, friends the following function works well rollDice n = getStdRandom (randomR (1,n)) :: IO Int now i want to use /dev/random to produce better random number, but it doesnot work rollDice_t n = do hd <- openFile "/dev/random" ReadMode v <- B.hGet hd 1 return (v `mod` n) + 1 No instance for (Integral B.ByteString) arising from a use of `mod' at Money.hs:15:12-20 Possible fix: add an instance declaration for (Integral B.ByteString) In the first argument of `return', namely `(v `mod` n)' In the first argument of `(+)', namely `return (v `mod` n)' In the expression: return (v `mod` n) + 1 then how to use the ByteString properly ? Sincerely! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090519/6b3fae95/attachment.html From allbery at ece.cmu.edu Tue May 19 01:13:25 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue May 19 00:58:25 2009 Subject: [Haskell-cafe] How to use Data.ByteString ? In-Reply-To: <6247530.99671242709661054.JavaMail.coremail@app176.163.com> References: <6247530.99671242709661054.JavaMail.coremail@app176.163.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/20090519/0b4c39e0/PGP.bin From thomas.dubuisson at gmail.com Tue May 19 01:20:52 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Tue May 19 01:06:13 2009 Subject: [Haskell-cafe] How to use Data.ByteString ? In-Reply-To: References: <6247530.99671242709661054.JavaMail.coremail@app176.163.com> Message-ID: <4c44d90b0905182220n4d5962ecsbd54fb5de3b7a16e@mail.gmail.com> On Mon, May 18, 2009 at 10:13 PM, Brandon S. Allbery KF8NH wrote: > On May 19, 2009, at 01:07 , z_axis wrote: > > rollDice_t n = do > ??? hd <- openFile "/dev/random" ReadMode > ??? v <-? B.hGet hd 1 > ??? return (v `mod` n) + 1 > > ?No instance for (Integral B.ByteString) > > You can't just read a binary string and have it interpreted as a number; you > want to use Data.Binary to extract an Int (or whatever) from the ByteString. > ?The same would apply with legacy Strings; in Haskell, String, ByteString, > and Int are distinct types and there is no automatic casting. ?In fact I'm > not quite sure why you thought that should work; even Perl would make you > unpack(), and C would require you to use an appropriately-aligned buffer and > unsafely cast the (char *) to an (int *). More so, you appear to only be getting one byte from your random number source, so that really limits the range of numbers this function can produce. Also, the error you are getting is more to do with ambigious types because there is a typeclass implied and you didn't add any type annotations yourself. Suggestions: 1) Use Data.ByteString.Lazy 2) Read the file, and don't forget to close it - or rework how you intend to get randoms (a better solution!) 3) Use 'decode' form Data.Binary and add a type signature to get an Int, Word32, or some such. 4) Apply mod and return Thomas From dagit at codersbase.com Tue May 19 01:42:40 2009 From: dagit at codersbase.com (Jason Dagit) Date: Tue May 19 01:27:24 2009 Subject: [Haskell-cafe] How to use Data.ByteString ? In-Reply-To: References: <6247530.99671242709661054.JavaMail.coremail@app176.163.com> Message-ID: On Mon, May 18, 2009 at 10:13 PM, Brandon S. Allbery KF8NH wrote: > On May 19, 2009, at 01:07 , z_axis wrote: > > rollDice_t n = do > ??? hd <- openFile "/dev/random" ReadMode > ??? v <-? B.hGet hd 1 > ??? return (v `mod` n) + 1 > > ?No instance for (Integral B.ByteString) > > You can't just read a binary string and have it interpreted as a number; you > want to use Data.Binary to extract an Int (or whatever) from the ByteString. > ?The same would apply with legacy Strings; in Haskell, String, ByteString, > and Int are distinct types and there is no automatic casting. ?In fact I'm > not quite sure why you thought that should work; even Perl would make you > unpack(), and C would require you to use an appropriately-aligned buffer and > unsafely cast the (char *) to an (int *). I just want to add that, this wouldn't stop Visual Basic! I've often seen this bit of scary code in VB: Dim i as Integer = 5 If i = "5" Then ' Do something, because 5 = "5" End If The designers of VB were quite odd though. I frequently find that VB violates the assumptions I make about programming languages (the logical "And" operation isn't short-circuit logic!). Jason From miguelimo38 at yandex.ru Tue May 19 01:34:54 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Tue May 19 02:03:41 2009 Subject: [Haskell-cafe] Re: [Haskell] [ANN] Safe Lazy IO in Haskell In-Reply-To: <2f9b2d30905182206g4451c67as468c0f85fa2a62cc@mail.gmail.com> References: <1237574414-sup-7006@ausone.local> <42784f260905170645n6316a654me1ecf21a60b3de2@mail.gmail.com> <1242667496-sup-9738@ausone.local> <2f9b2d30905182206g4451c67as468c0f85fa2a62cc@mail.gmail.com> Message-ID: On 19 May 2009, at 09:06, Ryan Ingram wrote: > This is a common problem with trying to use do-notation; there are > some cases where you can't make the object an instance of Monad. The > same problem holds for Data.Set; you'd can write > > setBind :: Ord b => Set a -> (a -> Set b) -> Set b > setBind m f = unions (map f $ toList m) > > but there is no way to use setBind for a definition of >>= You can use a continuation trick. From leledumbo_cool at yahoo.co.id Tue May 19 02:28:41 2009 From: leledumbo_cool at yahoo.co.id (leledumbo) Date: Tue May 19 02:13:24 2009 Subject: [Haskell-cafe] Expression parsing problem Message-ID: <23610457.post@talk.nabble.com> I'm writing a paper as a replacement for writing exam and decided to write a simple compiler (got a little experience with it). However, I got trouble in parsing expression. The grammar: expression = "get" | [ "+" | "-" ] term { ( "+" | "-" ) term } term = factor { ( "*" | "/" ) factor } factor = IDENTIFIER | VALUE | "(" expression ")" I can't make term parse, for instance "1 * 2 / 3" (the number is not important, identifier is also accepted). It stops after parsing 2, i.e. only the first multiplication is parsed. Interchanging * and / gives the same result, only differs in operation. Whichever got encountered first will be parsed. The same problem also arises from expression, where it can't parse "1 + 2 - 3". Both problems are identical, but I can't figure out what's wrong (don't count the optional +/- before term in expression, I haven't done it yet). Sorry, but I'm lack of knowledge about Monad. I know it can be done better with it, but I need to learn a lot about it, while I don't have enough time (only 2 weeks). Below are necessary definitions for the parser (some taken from the scanner). For testing purpose, please try: expression [("1",Value),("+",Plus),("2",Value),("-",Minus),("3",Value),("EOF",EOF)] term [("1",Value),("*",Times),("2",Value),("/",Slash),("3",Value),("EOF",EOF)] expression [("1",Value),("-",Minus),("2",Value),("+",Plus),("3",Value),("EOF",EOF)] term [("1",Value),("/",Slash),("2",Value),("*",Times),("3",Value),("EOF",EOF)] > data Token = Identifier | OpenBlock | CloseBlock | SemiColon | Slash | > Equals | OpenBrace | CloseBrace | Minus | Times | > Plus | Nil | Value | Var | Const | > Put | Get | Comma | EOF > deriving (Show,Eq) > type Symbol = (String,Token) > type ASL = [Symbol] > type ParseFunc = ASL -> (ASL,[String]) > expression :: ParseFunc > expression (h:s) > | snd h == Get = (s,["IN"]) > | op `elem` [Plus,Minus] = (s2,r1 ++ r2 ++ [operation op]) > | otherwise = (s1,r1) > where (s1,r1) = term (h:s) > (s2,r2) = term $ tail s1 > op = if s1 /= [] then snd $ head s1 else Nil > expression s = (s,[]) > term :: ParseFunc > term s = if op `elem` [Times,Slash] > then (s2,r1 ++ r2 ++ [operation op]) > else (s1,r1) > where (s1,r1) = factor s > (s2,r2) = factor $ tail s1 > op = if s1 /= [] then snd $ head s1 else Nil > factor :: ParseFunc > factor ((id,Identifier):s) = (s,["LOAD " ++ id]) > factor ((val,Value):s) = (s,["PUSH " ++ val]) > factor (("(",OpenBrace):s) = if head s1 == (")",CloseBrace) > then (tail s1,r1) > else error $ "\")\" expected, got" ++ (show $ fst $ head s1) > where (s1,r1) = expression s > factor s = (s,[]) -- View this message in context: http://www.nabble.com/Expression-parsing-problem-tp23610457p23610457.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From jason.dusek at gmail.com Tue May 19 02:23:27 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Tue May 19 02:13:39 2009 Subject: [Haskell-cafe] Re: [Haskell] [ANN] Safe Lazy IO in Haskell In-Reply-To: References: <1237574414-sup-7006@ausone.local> <42784f260905170645n6316a654me1ecf21a60b3de2@mail.gmail.com> <1242667496-sup-9738@ausone.local> <2f9b2d30905182206g4451c67as468c0f85fa2a62cc@mail.gmail.com> Message-ID: <42784f260905182323w21b10d63k17b3ab6c255c56c2@mail.gmail.com> 2009/05/18 Miguel Mitrofanov : > On 19 May 2009, at 09:06, Ryan Ingram wrote: > >> This is a common problem with trying to use do-notation; there are >> some cases where you can't make the object an instance of Monad. ?The >> same problem holds for Data.Set; you'd can write >> >> setBind :: Ord b => Set a -> (a -> Set b) -> Set b >> setBind m f = unions (map f $ toList m) >> >> but there is no way to use setBind for a definition of >>= > > You can use a continuation trick. Trick? -- Jason Dusek From taralx at gmail.com Tue May 19 02:32:03 2009 From: taralx at gmail.com (Taral) Date: Tue May 19 02:17:06 2009 Subject: [Haskell-cafe] Re: [Haskell] [ANN] Safe Lazy IO in Haskell In-Reply-To: <2f9b2d30905182206g4451c67as468c0f85fa2a62cc@mail.gmail.com> References: <1237574414-sup-7006@ausone.local> <42784f260905170645n6316a654me1ecf21a60b3de2@mail.gmail.com> <1242667496-sup-9738@ausone.local> <2f9b2d30905182206g4451c67as468c0f85fa2a62cc@mail.gmail.com> Message-ID: On Mon, May 18, 2009 at 10:06 PM, Ryan Ingram wrote: > On Mon, May 18, 2009 at 3:05 PM, Taral wrote: >> Will this do? >> >> (>>=) :: (NFData sa, NFData b) => LI sa -> (sa -> LI b) -> LI b > > No, the problem is that >>= on monads has no constraints, it must have the type >> LI a -> (a -> LI b) -> LI b I'm pretty sure you can do something like: newtype LIMonad x = NFData x => LI x -- Taral "Please let me know if there's any further trouble I can give you." -- Unknown From allbery at ece.cmu.edu Tue May 19 02:46:56 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue May 19 02:32:08 2009 Subject: [Haskell-cafe] How to use Data.ByteString ? In-Reply-To: References: <6247530.99671242709661054.JavaMail.coremail@app176.163.com> Message-ID: <5B36B7A8-86F0-4400-AA9A-A1ABD3B0C58C@ece.cmu.edu> On May 19, 2009, at 01:42 , Jason Dagit wrote: > I've often seen this bit of scary code in VB: > Dim i as Integer = 5 > If i = "5" Then > ' Do something, because 5 = "5" > End If Sure, that works in Perl too. But the equivalent case here would be chr$(5), not "5". -- 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/20090519/a87c95bf/PGP.bin From kenneth.hoste at ugent.be Tue May 19 03:19:23 2009 From: kenneth.hoste at ugent.be (Kenneth Hoste) Date: Tue May 19 03:04:12 2009 Subject: [Haskell-cafe] fast Eucl. dist. - Haskell vs C In-Reply-To: References: Message-ID: On May 18, 2009, at 15:28 , Claus Reinke wrote: >> My current best try uses the uvector package, has two 'vectors' of >> type >> (UArr Double) as input, and relies on the sumU and zipWithU >> functions >> which use streaming to compute the result: >> dist_fast :: UArr Double -> UArr Double -> Double >> dist_fast p1 p2 = sumDs `seq` sqrt sumDs >> where >> sumDs = sumU ds >> ds = zipWithU euclidean p1 p2 >> euclidean x y = d*d >> where >> d = x-y > > You'll probably want to make sure that 'euclidian' is specialized to > the types you need (here 'Double'), not used overloaded for 'Num a=>a' > (check -ddump-tc, or -ddump-simpl output). I understand from your later post that is was in fact specialized, but how do I make sure it _is_ specialized? Can I just add a type signature in the dist_fast definition for euclidean, or should I define euclidean outside of dist_fast, with an explicit type signature? If the latter, won't that hurt performance? Or should marking it INLINE take care of that? > After that, unrolling the fused fold loop (uvector internal) might > help > a bit, but isn't there yet: > > http://hackage.haskell.org/trac/ghc/ticket/3123 > http://hackage.haskell.org/trac/ghc/wiki/Inlining > > And even if that gets implemented, it doesn't apply directly to your > case, where the loop is in a library, but you might want to control > its > unrolling in your client code. Having the loop unrolled by a default > factor (8x or so) should help for loops like this, with little > computation. This seems rather serious, and might be one of the bigger reasons why I'm getting nowhere close to C in terms of performance... The loop body is ridiculously small, so it would make sense to unroll it somewhat to help avoid the loop overhead. However, it seems like GHC isn't able to do that now. Is there any way to unroll the loop myself, to speed things up? Seems hard, because I'm using uvector... K. -- Kenneth Hoste Paris research group - ELIS - Ghent University, Belgium email: kenneth.hoste@elis.ugent.be website: http://www.elis.ugent.be/~kehoste blog: http://boegel.kejo.be From kenneth.hoste at ugent.be Tue May 19 03:38:27 2009 From: kenneth.hoste at ugent.be (Kenneth Hoste) Date: Tue May 19 03:23:20 2009 Subject: [Haskell-cafe] fast Eucl. dist. - Haskell vs C In-Reply-To: <57EFA41AFF2E49F29DC91A6461005D3F@cr3lt> References: <20090518155505.GH16322@whirlpool.galois.com> <20090518183415.GD17204@whirlpool.galois.com> <57EFA41AFF2E49F29DC91A6461005D3F@cr3lt> Message-ID: On May 18, 2009, at 20:54 , Claus Reinke wrote: >>> As I said, I don't get the fusion if I just add the function above >>> to the original Dist.hs, export it and compile the module with '-c >>> -O2 -ddump-simpl': >> I can't reproduce this. > > Interesting. I'm using ghc 6.11.20090320 (windows), uvector-0.1.0.3. > I attach the modified Dist.hs and its simpl output, created via: > > ghc -c Dist.hs -O2 -ddump-tc -ddump-simpl-stats -ddump-simpl > > Dist.dumps > > Perhaps others can confirm the effect? Note that the 'dist_fast' in > the same module does get fused, so it is not likely an options > issue. I still suspect that the inlining of the 'Dist.zipWith' > wrapper in the 'dist_fast_inlined' > '__inline_me' has some significance - it is odd to see inlined code > in an > '__inline_me' and the fusion rule won't trigger on 'Dist.sumU . Dist. > $wzipWithU', > right? As far as I can tell, the dist_fast_inlined doesn't get fused, i.e. I'm seeing zipWithU and sumU being used in it, which is not the case in dist_fast. This is on OS X/PowerPC, using GHC 6.10.1. >> Does the complete program fragment I posted earlier yield the desired >> result? > > Yes. Note that the original poster also reported slowdown from > use of 'dist_fast_inlined'. Don, you were defining dist inside the main module, while in our case the dist functions are defined in a seperate Dist.hs module... Would that matter? K. -- Kenneth Hoste Paris research group - ELIS - Ghent University, Belgium email: kenneth.hoste@elis.ugent.be website: http://www.elis.ugent.be/~kehoste blog: http://boegel.kejo.be From lemming at henning-thielemann.de Tue May 19 03:46:15 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue May 19 03:31:10 2009 Subject: [Haskell-cafe] Re: [Haskell] [ANN] Safe Lazy IO in Haskell In-Reply-To: <1242667496-sup-9738@ausone.local> References: <1237574414-sup-7006@ausone.local> <42784f260905170645n6316a654me1ecf21a60b3de2@mail.gmail.com> <1242667496-sup-9738@ausone.local> Message-ID: On Mon, 18 May 2009, Nicolas Pouillard wrote: > Excerpts from Jason Dusek's message of Sun May 17 15:45:25 +0200 2009: >> From the documentation: >> >> " LI could be a strict monad and a strict applicative functor. >> However it is not a lazy monad nor a lazy applicative >> functor as required Haskell. Hopefully it is a lazy >> (pointed) functor at least. > > The type I would need for bind is this one: > > (>>=) :: NFData sa => LI sa -> (sa -> LI b) -> LI b > > And because of the NFData constraint this type bind is less general than the > required one. Looks very similar to the operator I need for binding with respect to asynchronous exceptions: bind :: (Monoid a, Monad m) => ExceptionalT e m a -> (a -> ExceptionalT e m b) -> ExceptionalT e m b From malcolm.wallace at cs.york.ac.uk Tue May 19 03:54:54 2009 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Tue May 19 03:39:38 2009 Subject: [Haskell-cafe] Expression parsing problem In-Reply-To: <23610457.post@talk.nabble.com> References: <23610457.post@talk.nabble.com> Message-ID: <63AF3FEB-1553-4511-B848-6B0C538ED39E@cs.york.ac.uk> > The grammar: > expression = "get" | [ "+" | "-" ] term { ( "+" | "-" ) term } > term = factor { ( "*" | "/" ) factor } > factor = IDENTIFIER | VALUE | "(" expression ")" > > I can't make term parse, for instance "1 * 2 / 3" Indeed, the grammar does not admit "1*2/3" as a sentence of that language although it will admit "(1*2)/3" or "1*(2/3)". If you wish to allow sequences of infix operators without bracketting, then examples of the standard grammar for this can be found by searching the web for "expression term factor", e.g. http://en.wikipedia.org/wiki/Syntax_diagram suggests: expression ::= term | term "+" expression term ::= factor | factor "*" term factor ::= constant | variable | "(" expression ")" Regards, Malcolm From oleg at okmij.org Tue May 19 03:58:53 2009 From: oleg at okmij.org (oleg@okmij.org) Date: Tue May 19 03:44:27 2009 Subject: [Haskell-cafe] GUIs, FRP, (Delimited) Continuations and Zippers Message-ID: <20090519075853.9250B17832@Adric.metnet.navy.mil> > Could either of those approaches (FRP / Delimited Continuations) be a > solution for implementing complex GUI code? I think the answer is generally yes; I have tried writing a user interface which has a form with several controls; a change in one control may affect all other controls on the form (or change the form). I have tried it for a particular GUI: the web page -- displayed in a browser interacting with a CGI script. The choice of CGI was deliberate because it is harder than FastCGI: it requires the ability to save the state of the interaction. The continuation must outlive its process. The point I was trying to make is that the GUI is programmed as if it were a uncursed console application: you send one question, get a reply, send another question, etc. With a GUI, questions are sent in parallel and answers are delivered in any order; yet the programmer can still think he deals with a regular console application; as if the interaction never happens and the program merely reads the data from a file. http://okmij.org/ftp/Computation/Continuations.html#shift-cgi It was done in OCaml though (because OCaml has native persistent delimited continuations). From nicolas.pouillard at gmail.com Tue May 19 03:59:30 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Tue May 19 03:45:27 2009 Subject: [Haskell-cafe] Re: [Haskell] [ANN] Safe Lazy IO in Haskell In-Reply-To: References: <1237574414-sup-7006@ausone.local> <42784f260905170645n6316a654me1ecf21a60b3de2@mail.gmail.com> <1242667496-sup-9738@ausone.local> Message-ID: <1242719779-sup-6628@ausone.inria.fr> Excerpts from Taral's message of Tue May 19 00:05:39 +0200 2009: > On Mon, May 18, 2009 at 10:30 AM, Nicolas Pouillard > wrote: > > The type I would need for bind is this one: > > > > ?(>>=) :: NFData sa => LI sa -> (sa -> LI b) -> LI b > > Will this do? > > (>>=) :: (NFData sa, NFData b) => LI sa -> (sa -> LI b) -> LI b No this one would be too strict. In particular functions are not member of NFData (and for good reasons) and we may want to have LI values holding non "forcable" values. However I got your idea and it can be useful. Thanks, -- Nicolas Pouillard From leledumbo_cool at yahoo.co.id Tue May 19 04:06:33 2009 From: leledumbo_cool at yahoo.co.id (leledumbo) Date: Tue May 19 03:51:17 2009 Subject: [Haskell-cafe] Expression parsing problem In-Reply-To: <63AF3FEB-1553-4511-B848-6B0C538ED39E@cs.york.ac.uk> References: <23610457.post@talk.nabble.com> <63AF3FEB-1553-4511-B848-6B0C538ED39E@cs.york.ac.uk> Message-ID: <23611617.post@talk.nabble.com> > Indeed, the grammar does not admit "1*2/3" as a sentence ... Huh? Why not? "1 * 2 / 3" should match factor "*" factor "/" factor. Remember that { } is repetition, so it should be able to handle such term. > expression ::= term | term "+" expression > term ::= factor | factor "*" term > factor ::= constant | variable | "(" expression ")" Oh, left recursion. Well, it should be easy to transform: expression ::= term | moreTerm term ::= factor | moreFactor moreTerm ::= term "+" expression factor ::= constant | variable | "(" expression ")" moreFactor := factor "*" term correct? -- View this message in context: http://www.nabble.com/Expression-parsing-problem-tp23610457p23611617.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ryani.spam at gmail.com Tue May 19 04:23:01 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue May 19 04:07:45 2009 Subject: [Haskell-cafe] Re: [Haskell] [ANN] Safe Lazy IO in Haskell In-Reply-To: References: <1237574414-sup-7006@ausone.local> <42784f260905170645n6316a654me1ecf21a60b3de2@mail.gmail.com> <1242667496-sup-9738@ausone.local> Message-ID: <2f9b2d30905190123w2671dce9m9a60650a8cc2d90e@mail.gmail.com> To be fair, you can do this with some extensions; I first saw this in a paper on Oleg's site [1]. Here's some sample code: {-# LANGUAGE NoImplicitPrelude, TypeFamilies, MultiParamTypeClasses #-} module SetMonad where import qualified Data.Set as S import qualified Prelude as P (Monad, (>>=), (>>), return, fail) import Prelude hiding (Monad, (>>=), (>>), return, fail) class ConstrainedPoint pa where type PointElem pa return :: PointElem pa -> pa class ConstrainedBind ma mb where type BindElem ma (>>=) :: ma -> (BindElem ma -> mb) -> mb (>>) :: ma -> mb -> mb m >> n = m >>= const n class ConstrainedFail pa where fail :: String -> pa instance ConstrainedPoint (S.Set a) where type PointElem (S.Set a) = a return = S.singleton instance Ord b => ConstrainedBind (S.Set a) (S.Set b) where type BindElem (S.Set a) = a m >>= f = S.unions $ map f $ S.toList m test :: S.Set Int test = do x <- S.fromList [1,2,3] y <- S.fromList [1,2,3] return (x+y) -- ghci> test -- fromList [2,3,4,5,6] -- ryan [1] http://www.okmij.org/ftp/Haskell/types.html#restricted-datatypes On Tue, May 19, 2009 at 12:46 AM, Henning Thielemann wrote: > > On Mon, 18 May 2009, Nicolas Pouillard wrote: > >> Excerpts from Jason Dusek's message of Sun May 17 15:45:25 +0200 2009: >>> >>> ?From the documentation: >>> >>> ?" ?LI could be a strict monad and a strict applicative functor. >>> ? ?However it is not a lazy monad nor a lazy applicative >>> ? ?functor as required Haskell. Hopefully it is a lazy >>> ? ?(pointed) functor at least. >> >> The type I would need for bind is this one: >> >> ?(>>=) :: NFData sa => LI sa -> (sa -> LI b) -> LI b >> >> And because of the NFData constraint this type bind is less general than >> the >> required one. > > Looks very similar to the operator I need for binding with respect to > asynchronous exceptions: > > bind :: (Monoid a, Monad m) => > ? ExceptionalT e m a -> (a -> ExceptionalT e m b) -> ExceptionalT e m b > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ryani.spam at gmail.com Tue May 19 04:28:05 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue May 19 04:12:50 2009 Subject: [Haskell-cafe] Re: [Haskell] [ANN] Safe Lazy IO in Haskell In-Reply-To: <2f9b2d30905190123w2671dce9m9a60650a8cc2d90e@mail.gmail.com> References: <1237574414-sup-7006@ausone.local> <42784f260905170645n6316a654me1ecf21a60b3de2@mail.gmail.com> <1242667496-sup-9738@ausone.local> <2f9b2d30905190123w2671dce9m9a60650a8cc2d90e@mail.gmail.com> Message-ID: <2f9b2d30905190128m54a35520ha9fd704a25185880@mail.gmail.com> Minor addition, optimize >> (I couldn't help myself!) -- ryan > instance Ord b => ConstrainedBind (S.Set a) (S.Set b) where > type BindElem (S.Set a) = a > m >>= f = S.unions $ map f $ S.toList m > m >> n = if S.null m then S.empty else n From miguelimo38 at yandex.ru Tue May 19 03:54:50 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Tue May 19 04:14:37 2009 Subject: [Haskell-cafe] Re: [Haskell] [ANN] Safe Lazy IO in Haskell In-Reply-To: <42784f260905182323w21b10d63k17b3ab6c255c56c2@mail.gmail.com> References: <1237574414-sup-7006@ausone.local> <42784f260905170645n6316a654me1ecf21a60b3de2@mail.gmail.com> <1242667496-sup-9738@ausone.local> <2f9b2d30905182206g4451c67as468c0f85fa2a62cc@mail.gmail.com> <42784f260905182323w21b10d63k17b3ab6c255c56c2@mail.gmail.com> Message-ID: <4A1265CA.5030200@yandex.ru> I've posted it once or twice. newtype C m r a = C ((a -> m r) -> m r) It's a monad, regardless of whether m is one or not. If you have something like "return" and "bind", but not exactly the same, you can make "casting" functions m a -> C m r a and backwards. Jason Dusek wrote on 19.05.2009 10:23: > 2009/05/18 Miguel Mitrofanov : >> On 19 May 2009, at 09:06, Ryan Ingram wrote: >> >>> This is a common problem with trying to use do-notation; there are >>> some cases where you can't make the object an instance of Monad. The >>> same problem holds for Data.Set; you'd can write >>> >>> setBind :: Ord b => Set a -> (a -> Set b) -> Set b >>> setBind m f = unions (map f $ toList m) >>> >>> but there is no way to use setBind for a definition of >>= >> You can use a continuation trick. > > Trick? > > -- > Jason Dusek > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From nicolas.pouillard at gmail.com Tue May 19 04:30:10 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Tue May 19 04:16:08 2009 Subject: [Haskell-cafe] Re: [Haskell] [ANN] Safe Lazy IO in Haskell In-Reply-To: <2f9b2d30905190123w2671dce9m9a60650a8cc2d90e@mail.gmail.com> References: <1237574414-sup-7006@ausone.local> <42784f260905170645n6316a654me1ecf21a60b3de2@mail.gmail.com> <1242667496-sup-9738@ausone.local> <2f9b2d30905190123w2671dce9m9a60650a8cc2d90e@mail.gmail.com> Message-ID: <1242721769-sup-7190@ausone.inria.fr> Excerpts from Ryan Ingram's message of Tue May 19 10:23:01 +0200 2009: > To be fair, you can do this with some extensions; I first saw this in > a paper on Oleg's site [1]. Here's some sample code: This seems like the same trick as the rmonad package: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/rmonad -- Nicolas Pouillard From ryani.spam at gmail.com Tue May 19 04:41:16 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue May 19 04:26:00 2009 Subject: [Haskell-cafe] Expression parsing problem In-Reply-To: <23610457.post@talk.nabble.com> References: <23610457.post@talk.nabble.com> Message-ID: <2f9b2d30905190141m43f3ac95j9eeab9b090f44ecd@mail.gmail.com> Why is Symbol = (String, Token)? A more sensible token type would include values in the Value constructor and string identifiers in the Identifier constructor; the strings in everything else seem redundant. A more pure/monadic parser would have a type like this: data Result a = Error String | OK [a] newtype Parser a = Parser (ASL -> Result (ASL, a)) Try to write these functions: return :: a -> Parser a (>>=) :: Parser a -> (a -> Parser b) -> Parser b Next write some simple state modification: token :: Parser Token (or, if you insist on your symbol type) token :: Parser Symbol expect :: Token -> Parser () Then build on these to write: expression :: Parser Expression term :: Parser Expression factor :: Parser Expression for some suitable type Expression Good luck, sounds like a tough but interesting project! -- ryan On Mon, May 18, 2009 at 11:28 PM, leledumbo wrote: > > I'm writing a paper as a replacement for writing exam and decided to write > a simple compiler (got a little experience with it). However, I got trouble > in parsing expression. > > The grammar: > expression ?= "get" | [ "+" | "-" ] term { ( "+" | "-" ) term } > ?term ? ? ?= factor { ( "*" | "/" ) factor } > ? ?factor ?= IDENTIFIER | VALUE | "(" expression ")" > > I can't make term parse, for instance "1 * 2 / 3" (the number is not > important, > identifier is also accepted). It stops after parsing 2, i.e. only the first > multiplication is parsed. Interchanging * and / gives the same result, only > differs in operation. Whichever got encountered first will be parsed. > > The same problem also arises from expression, where it can't parse "1 + 2 - > 3". > Both problems are identical, but I can't figure out what's wrong (don't > count > the optional +/- before term in expression, I haven't done it yet). > > Sorry, but I'm lack of knowledge about Monad. I know it can be done better > with it, > but I need to learn a lot about it, while I don't have enough time (only 2 > weeks). > > Below are necessary definitions for the parser (some taken from the > scanner). > > For testing purpose, please try: > expression > [("1",Value),("+",Plus),("2",Value),("-",Minus),("3",Value),("EOF",EOF)] > term > [("1",Value),("*",Times),("2",Value),("/",Slash),("3",Value),("EOF",EOF)] > expression > [("1",Value),("-",Minus),("2",Value),("+",Plus),("3",Value),("EOF",EOF)] > term > [("1",Value),("/",Slash),("2",Value),("*",Times),("3",Value),("EOF",EOF)] > >> data Token = Identifier | OpenBlock | CloseBlock | SemiColon | Slash | >> ? ? ? ? ? ? ? ?Equals ? | OpenBrace | CloseBrace | ? Minus ? | Times | >> ? ? ? ? ? ? ? ? Plus ? ?| ? ?Nil ? ?| ? Value ? ?| ? ?Var ? ?| Const | >> ? ? ? ? ? ? ? ? Put ? ? | ? ?Get ? ?| ? Comma ? ?| ? ?EOF >> ? ? ? ? ? ? ?deriving (Show,Eq) > >> type Symbol = (String,Token) >> type ASL ? ?= [Symbol] > > >> type ParseFunc = ASL -> (ASL,[String]) > >> expression :: ParseFunc >> expression (h:s) >> ? | snd h == Get ? ? ? ? ? = (s,["IN"]) >> ? | op `elem` [Plus,Minus] = (s2,r1 ++ r2 ++ [operation op]) >> ? | otherwise ? ? ? ? ? ? ?= (s1,r1) >> ? where (s1,r1) = term (h:s) >> ? ? ? ? (s2,r2) = term $ tail s1 >> ? ? ? ? op ? ? ?= if s1 /= [] then snd $ head s1 else Nil >> expression s ? ?= (s,[]) > >> term :: ParseFunc >> term s = if op `elem` [Times,Slash] >> ? then (s2,r1 ++ r2 ++ [operation op]) >> ? else (s1,r1) >> ? where (s1,r1) = factor s >> ? ? ? ? (s2,r2) = factor $ tail s1 >> ? ? ? ? op ? ? ?= if s1 /= [] then snd $ head s1 else Nil > >> factor :: ParseFunc >> factor ((id,Identifier):s) = (s,["LOAD " ++ id]) >> factor ((val,Value):s) ? ? = (s,["PUSH " ++ val]) >> factor (("(",OpenBrace):s) = if head s1 == (")",CloseBrace) >> ? then (tail s1,r1) >> ? else error $ "\")\" expected, got" ++ (show $ fst $ head s1) >> ? where (s1,r1) = expression s >> factor s = (s,[]) > > -- > View this message in context: http://www.nabble.com/Expression-parsing-problem-tp23610457p23610457.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 ganesh.sittampalam at credit-suisse.com Tue May 19 04:50:48 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Tue May 19 04:35:52 2009 Subject: [Haskell-cafe] Re: [Haskell] [ANN] Safe Lazy IO in Haskell In-Reply-To: <1242721769-sup-7190@ausone.inria.fr> References: <1237574414-sup-7006@ausone.local><42784f260905170645n6316a654me1ecf21a60b3de2@mail.gmail.com><1242667496-sup-9738@ausone.local><2f9b2d30905190123w2671dce9m9a60650a8cc2d90e@mail.gmail.com> <1242721769-sup-7190@ausone.inria.fr> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B01ABAB41@ELON17P32001A.csfb.cs-group.com> Nicolas Pouillard wrote: > Excerpts from Ryan Ingram's message of Tue May 19 10:23:01 +0200 2009: >> To be fair, you can do this with some extensions; I first saw this in >> a paper on Oleg's site [1]. Here's some sample code: > > This seems like the same trick as the rmonad package: > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/rmonad It's similar, but rmonad uses an associated datatype to wrap up the constraint, and doesn't split the Monad class up into separate pieces (which generally makes type inference harder). rmonad also supplies an embedding to turn any restricted monad into a normal monad at the cost of using embed/unEmbed to get into and out of the embedding. Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From leledumbo_cool at yahoo.co.id Tue May 19 05:21:49 2009 From: leledumbo_cool at yahoo.co.id (leledumbo) Date: Tue May 19 05:06:32 2009 Subject: [Haskell-cafe] Expression parsing problem In-Reply-To: <2f9b2d30905190141m43f3ac95j9eeab9b090f44ecd@mail.gmail.com> References: <23610457.post@talk.nabble.com> <2f9b2d30905190141m43f3ac95j9eeab9b090f44ecd@mail.gmail.com> Message-ID: <23612618.post@talk.nabble.com> > Why is Symbol = (String, Token)? A more sensible token type would > include values in the Value constructor and string identifiers in the > Identifier constructor; the strings in everything else seem redundant. Surely you didn't read my original post, do you? I have a very limited knowledge of Monad and I try to find a solution using my current skills because the due date is within two weeks. Therefore, I don't think I can create a Monadic parser for this. -- View this message in context: http://www.nabble.com/Expression-parsing-problem-tp23610457p23612618.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ryani.spam at gmail.com Tue May 19 05:30:52 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue May 19 05:15:35 2009 Subject: [Haskell-cafe] Re: [Haskell] [ANN] Safe Lazy IO in Haskell In-Reply-To: <4A1265CA.5030200@yandex.ru> References: <1237574414-sup-7006@ausone.local> <42784f260905170645n6316a654me1ecf21a60b3de2@mail.gmail.com> <1242667496-sup-9738@ausone.local> <2f9b2d30905182206g4451c67as468c0f85fa2a62cc@mail.gmail.com> <42784f260905182323w21b10d63k17b3ab6c255c56c2@mail.gmail.com> <4A1265CA.5030200@yandex.ru> Message-ID: <2f9b2d30905190230p34b58170p7c68e6006be8a577@mail.gmail.com> On Tue, May 19, 2009 at 12:54 AM, Miguel Mitrofanov wrote: > I've posted it once or twice. > > newtype C m r a = C ((a -> m r) -> m r) > > It's a monad, regardless of whether m is one or not. If you have something > like "return" and "bind", but not exactly the same, you can make "casting" > functions > > m a -> C m r a > > and backwards. This isn't great, though. Consider this (slightly generalized) version: > newtype CpsM c t a = CpsM { unCpsM :: forall b. c b -> (a -> t b) -> t b } We can easily make this a monad for any c & t: > instance Monad (CpsM c t) where > return x = CpsM $ \_ k -> k x > m >>= f = CpsM $ \c k -> unCpsM m c $ \x -> unCpsM (f x) c k Here's a useful one: > -- reify Ord constraint in a data structure > data OrdConstraint a where > HasOrd :: Ord a => OrdConstraint a > type M = CpsM OrdConstraint S.Set along with your "casting" functions: > liftS :: S.Set a -> M a > liftS s = CpsM $ \c@HasOrd k -> S.unions $ map k $ S.toList s > runS :: Ord a => M a -> S.Set a > runS m = unCpsM m HasOrd S.singleton Now consider this code: > inner = do > x <- liftS (S.fromList [1..3]) > y <- liftS (S.fromList [1..3]) > return (x+y) > outer = do > x <- inner > y <- inner > return (x+y) If you evaluate (runS outer), eventually you get to a state like this: = let f x = inner >>= \y -> return (x+y) g x2 = liftS (S.fromList [1..3]) >>= \y2 -> return (x2+y2) h = HasOrd k = \a2 -> unCpsM (g a2) h $ \a -> unCpsM (f a) h S.singleton in S.unions $ map k [1,2,3] which, after all the evaluation, leads to this: = S.unions [S.fromList [4,5,6,7,8,9,10], S.fromList [5,6,7,8,9,10,11], S.fromList [6,7,8,9,10,11,12]] We didn't really do any better than if we just stuck everything in a list and converted to a set at the end! Compare to the result of the same code using the restricted monad solution (in this case runS = id, liftS = id): inner >>= \x -> inner >>= \y -> return (x+y) = (Set [1,2,3] >>= \x -> Set [1,2,3] >>= \y -> return (x+y)) >>= \x -> inner >>= \y -> return (x+y) = (S.unions (map (\x -> Set [1,2,3] >>= \y -> return (x+y)) [1,2,3])) >>= \x -> inner >>= \y -> return (x+y) = S.unions [Set [2,3,4], Set [3,4,5], Set [4,5,6]] >>= \x -> inner >>= \y -> return (x+y) = Set [2,3,4,5,6] >>= \x -> inner >>= \y -> return (x+y) Notice how we've already snipped off a bunch of the computation that the continuation-based version ran; the left-associated >>= let us pre-collapse parts of the set down, which we will never do until the end of the CPS version. (This is obvious if you notice that in the CPS version, the only HasOrd getting passed around is for the final result type; we never call S.unions at any intermediate type!) Of course, you can manually cache the result yourself by wrapping "inner": > cacheS = liftS . runS > inner_cached = cacheS inner A version of "outer" using this version has the same behavior as the non-CPS version. But it sucks to have to insert the equivalent of "optimize this please" everywhere in your code :) -- ryan > > Jason Dusek wrote on 19.05.2009 10:23: >> >> 2009/05/18 Miguel Mitrofanov : >>> >>> On 19 May 2009, at 09:06, Ryan Ingram wrote: >>> >>>> This is a common problem with trying to use do-notation; there are >>>> some cases where you can't make the object an instance of Monad. ?The >>>> same problem holds for Data.Set; you'd can write >>>> >>>> setBind :: Ord b => Set a -> (a -> Set b) -> Set b >>>> setBind m f = unions (map f $ toList m) >>>> >>>> but there is no way to use setBind for a definition of >>= >>> >>> You can use a continuation trick. >> >> ?Trick? >> >> -- >> Jason Dusek >> _______________________________________________ >> 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 g9ks157k at acme.softbase.org Tue May 19 05:30:52 2009 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Tue May 19 05:15:43 2009 Subject: [Haskell-cafe] GUIs, FRP, (Delimited) Continuations and Zippers In-Reply-To: References: Message-ID: <200905191130.52982.g9ks157k@acme.softbase.org> Am Samstag, 16. Mai 2009 16:18 schrieb G??nther Schmidt: > Hi all, > > In my app, there is one part which has a rather complicated GUI logic, > it involves n drop downs with n choices each. > > Whenever the current selection in one of the drop downs changes by user > interaction, the other (n-1) drop downs need to be notified and their > item list need to possible change too. > > Now I have managed to code all this and it actually behaves correctly. > But I'm also using tons of IORefs and tons of bookkeeping code for it. > While I'd not be ashamed to show any other part of my code to another > Haskeller, this part of the code is the most clumsiest I've ever written. > > And I have no clue if that piece of code *can* be written in any other > way, ie. without the tons of IORefs and bookkeeping. > > The GUI library is WXHaskell. > > In the last few days I read up on Conal Elliotts FRP stuff (reactive) > but also on Olegs ZFS (Zippers, Delimited Continuations), the latter > leaving me totally baffled. > > Could either of those approaches (FRP / Delimited Continuations) be a > solution for implementing complex GUI code? > > G?nther Hello G?nther, FRP can definitely help you a lot for these kinds of problems. You have n widgets where each widget outputs a discrete signal (event (stream)) of requests from the user. These are transformed and combined to form signals (behaviors) that describe the contents of the n widgets over time. Have you looked at Grapefruit? It?s an FRP library, I?m developing, which already has integrated GUI support. If you want to try it out, better take the darcs version instead of the released version since there have been some important developments since the release date. You find Grapefruit?s homepage here: . If you have questions, please ask. Best wishes, Wolfgang From tom at lokhorst.eu Tue May 19 05:35:45 2009 From: tom at lokhorst.eu (Tom Lokhorst) Date: Tue May 19 05:20:52 2009 Subject: [Haskell-cafe] Re: Haskell-Cafe Digest, Vol 69, Issue 38 In-Reply-To: <20090519050618.CC92A32453D@www.haskell.org> References: <20090519050618.CC92A32453D@www.haskell.org> Message-ID: <317ca7670905190235x288d86dne8cde6ccefdb0cf8@mail.gmail.com> These QuickCheck properties don't really test your sort function. The `a' type variable will be instantiated to (). So you will test with lists of units, like so: ghci> quickCheck (\xs -> isSorted (reverse xs)) OK, passed 100 tests. This can be simply solved by added a more specific type signature: isSorted :: [Int] -> Bool Surly, if the sort function works for Ints, it'll work for any Ord a. - Tom > ---------- Forwarded message ---------- > From:?Ryan Ingram > To:?Eugene Kirpichov > Date:?Mon, 18 May 2009 13:57:04 -0700 > Subject:?Re: [Haskell-cafe] Haskell in 3 Slides > On Mon, May 18, 2009 at 11:33 AM, Eugene Kirpichov wrote: >> The main bullet point is missing: Correctness. >> >> How could we have forgotten quickcheck? >> >>> quickCheck (\xs -> sort (sort xs) == sort xs) >> OK, 100 tests passed. > > I like this, but given that you have a whole slide, I might write this: > > isSorted :: Ord a => [a] -> Bool > isSorted [] = True > isSorted [x] = True > isSorted (x:y:rest) = x <= y && isSorted (y:rest) > >> quickCheck (\xs -> isSorted (sort xs)) > OK, 100 tests passed. > > Or, if you want to lead into a talk about fusion and/or higher order functions: > > isSorted [] = True > isSorted (x:xs) = snd $ foldl' check (head x, True) xs where > ? ?check (prevElem, restSorted) thisElem = (thisElem, prevElem <= > thisElem && restSorted) > > ?-- ryan > From ryani.spam at gmail.com Tue May 19 05:38:41 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue May 19 05:23:24 2009 Subject: [Haskell-cafe] Expression parsing problem In-Reply-To: <23612618.post@talk.nabble.com> References: <23610457.post@talk.nabble.com> <2f9b2d30905190141m43f3ac95j9eeab9b090f44ecd@mail.gmail.com> <23612618.post@talk.nabble.com> Message-ID: <2f9b2d30905190238v13303b08x4bb743343e3acdd7@mail.gmail.com> > Surely you didn't read my original post, do you? I have a very limited > knowledge of Monad and I try to find a solution using my current skills > because the due date is within two weeks. Therefore, I don't think I can > create a Monadic parser for this. I think you're giving up way too easily. My claim is that learning to make a monadic parser would actually be *faster* than implementing it this way, and you'll be a better programmer at the end of it. There's a great functional pearl on this at http://www.cs.nott.ac.uk/~gmh/bib.html#pearl ; you do yourself a disservice if you don't read it. It's only 7 pages! -- ryan From leledumbo_cool at yahoo.co.id Tue May 19 07:03:19 2009 From: leledumbo_cool at yahoo.co.id (leledumbo) Date: Tue May 19 06:48:03 2009 Subject: [Haskell-cafe] Expression parsing problem In-Reply-To: <2f9b2d30905190238v13303b08x4bb743343e3acdd7@mail.gmail.com> References: <23610457.post@talk.nabble.com> <2f9b2d30905190141m43f3ac95j9eeab9b090f44ecd@mail.gmail.com> <23612618.post@talk.nabble.com> <2f9b2d30905190238v13303b08x4bb743343e3acdd7@mail.gmail.com> Message-ID: <23614011.post@talk.nabble.com> I hope you're right. 7 pages... 1-2 nights should be enough. Thanks for all. -- View this message in context: http://www.nabble.com/Expression-parsing-problem-tp23610457p23614011.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From anotheraddress at gmx.de Tue May 19 07:24:02 2009 From: anotheraddress at gmx.de (Daniel =?iso-8859-1?q?Sch=FCssler?=) Date: Tue May 19 07:08:46 2009 Subject: [Haskell-cafe] fast Eucl. dist. - Haskell vs C Message-ID: <200905191324.02225.anotheraddress@gmx.de> Hello! On Monday 18 May 2009 14:37:51 Kenneth Hoste wrote: > I'm mostly interested in the range 10D to 100D is the dimension known at compile-time? Then you could consider Template Haskell. I wrote up some code for generating the vector types and vector subtraction/inner product below, HTH. One problem is that I'm using a typeclass and apparently you can't make {-# SPECIALISE #-} pragmas with TH, so let's hope it is automatically specialised by GHC. Greetings, Daniel TH.hs ------------------ {-# LANGUAGE TemplateHaskell #-} {-# OPTIONS -fglasgow-exts #-} module TH where import Language.Haskell.TH import Control.Monad -- Non-TH stuff class InnerProductSpace v r | v -> r where innerProduct :: v -> v -> r class AbGroup v where minus :: v -> v -> v euclidean x y = case minus x y of z -> sqrt $! innerProduct z z -- TH noContext :: Q Cxt noContext = return [] strict :: Q Type -> StrictTypeQ strict = liftM ((,) IsStrict) makeVectors :: Int -- ^ Dimension -> Q Type -- ^ Component type, assumed to be a 'Num' -> String -- ^ Name for the generated type -> Q [Dec] makeVectors n ctyp name0 = do -- let's assume ctyp = Double, name = Vector for the comments -- generate names for the variables we will need xs <- replicateM n (newName "x") ys <- replicateM n (newName "y") let name = mkName name0 -- shorthands for arithmetic expressions; the first takes expressions, -- the others take variable names sumE e1 e2 = infixE (Just e1) [|(+)|] (Just e2) varDiffE e1 e2 = infixE (Just (varE e1)) [|(-)|] (Just (varE e2)) varProdE e1 e2 = infixE (Just (varE e1)) [|(*)|] (Just (varE e2)) conPat vars = conP name (fmap varP vars) -- > data Vector = Vector !Double ... !Double theDataD = dataD noContext name [] -- no context, no params [normalC name (replicate n (strict ctyp))] [''Eq,''Ord,''Show] -- 'deriving' clause innerProdD = -- > instance InnerProductSpace Vector Double where ... instanceD noContext ( conT ''InnerProductSpace `appT` conT name `appT` ctyp) -- > innerProduct = ... [valD (varP 'innerProduct) (normalB -- \(Vector x1 x2 ... xn) (Vector y1 y2 ... yn) -> (lamE [conPat xs, conPat ys] -- x1*y1 + .... + xn*yn + 0 (foldl sumE [|0|] $ zipWith varProdE xs ys) )) [] -- no 'where' clause ] abGroupD = instanceD noContext ( conT ''AbGroup `appT` conT name) -- > minus = ... [valD (varP 'minus) (normalB -- \(Vector x1 x2 ... xn) (Vector y1 y2 ... yn) -> (lamE [conPat xs, conPat ys] -- Vector (x1-y1) ... (xn-yn) (foldl appE (conE name) $ zipWith varDiffE xs ys) )) [] -- no 'where' clause ] sequence [theDataD,innerProdD,abGroupD] Main.hs ------------------ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE MultiParamTypeClasses #-} module Main where import TH $(makeVectors 3 [t|Double|] "Vec3") main = print $ euclidean (Vec3 1 1 1) (Vec3 0 0 0) From claus.reinke at talk21.com Tue May 19 07:30:00 2009 From: claus.reinke at talk21.com (Claus Reinke) Date: Tue May 19 07:14:54 2009 Subject: [Haskell-cafe] fast Eucl. dist. - Haskell vs C References: Message-ID: <45464A3A161E415B83FC7624405A8B9F@cr3lt> > I understand from your later post that is was in fact specialized, but > how do I make sure it _is_ specialized? -ddump-tc seems to give the generalized type, so it seems you'd need to look at the -ddump-simpl output if you want to know whether a local function is specialized. http://www.haskell.org/haskellwiki/Performance/GHC#Looking_at_the_Core > Can I just add a type signature in the dist_fast definition for euclidean, If you need it at exactly one type, that is the simplest way. There's also the SPECIALIZE pragma http://www.haskell.org/ghc/docs/latest/html/users_guide/pragmas.html#specialize-pragma and for local and non-exported functions '-O' should enable auto-specialization http://www.haskell.org/ghc/docs/latest/html/users_guide/faster.html > >> After that, unrolling the fused fold loop (uvector internal) might >> help a bit, but isn't there yet: >> >> http://hackage.haskell.org/trac/ghc/ticket/3123 >> http://hackage.haskell.org/trac/ghc/wiki/Inlining >> >> And even if that gets implemented, it doesn't apply directly to your >> case, where the loop is in a library, but you might want to control >> its unrolling in your client code. Having the loop unrolled by a default >> factor (8x or so) should help for loops like this, with little >> computation. > > This seems rather serious, and might be one of the bigger reasons why > I'm getting nowhere close to C in terms of performance... You should be able to get near (a small factor) without it, but not having it leaves a substantial gap in performance, especially for simple loop bodies (there is also the case of enabling fusion over multiple loop iterations, but that may call for proper fix-point fusion). > The loop body is ridiculously small, so it would make sense to > unroll it somewhat to help avoid the loop overhead. > However, it seems like GHC isn't able to do that now. Apart from the links above, the new backend also has relevant TODO items: http://hackage.haskell.org/trac/ghc/wiki/BackEndNotes > Is there any way to unroll the loop myself, to speed things up? > Seems hard, because I'm using uvector... You could 'cabal unpack' uvector, hand-unroll the core loop all its operations get fused into, then reinstall the modified package.. (perhaps that should be a package configuration option, at least until GHC gets loop or recursion unrolling - since this would be a temporary workaround, it would probably not be worth it to have multiple package versions with different unroll factors; if this actually helps uvector users with performance in practice, they could suggest it as a patch). Claus From anotheraddress at gmx.de Tue May 19 07:47:08 2009 From: anotheraddress at gmx.de (Daniel =?iso-8859-1?q?Sch=FCssler?=) Date: Tue May 19 07:31:59 2009 Subject: [Haskell-cafe] fast Eucl. dist. - Haskell vs C In-Reply-To: <200905191324.02225.anotheraddress@gmx.de> References: <200905191324.02225.anotheraddress@gmx.de> Message-ID: <200905191347.08251.anotheraddress@gmx.de> Hi, meh, I just realised that there is no sensible way to actually introduce/eliminate the generated types. I'm attaching a revised version with fromList/toList functions. Maybe the vector type should be polymorphic and be an instance of Functor, Monad and Foldable? But then we really depend on specialisation. Greetings, Daniel -------------- next part -------------- {-# LANGUAGE TemplateHaskell #-} {-# OPTIONS -fglasgow-exts #-} module TH where import Language.Haskell.TH import Control.Monad -- Non-TH stuff class InnerProductSpace v r | v -> r where innerProduct :: v -> v -> r class AbGroup v where minus :: v -> v -> v class FromToList v r | v -> r where fromList :: [r] -> Maybe v toList :: v -> [r] euclidean x y = case minus x y of z -> sqrt $! innerProduct z z -- TH noContext :: Q Cxt noContext = return [] strict :: Q Type -> StrictTypeQ strict = liftM ((,) IsStrict) makeVectors :: Int -- ^ Dimension -> Q Type -- ^ Component type, assumed to be a 'Num' -> String -- ^ Name for the generated type -> Q [Dec] makeVectors n ctyp name0 = do -- let's assume ctyp = Double, name = Vector for the comments -- generate names for the variables we will need xs <- replicateM n (newName "x") ys <- replicateM n (newName "y") lst <- newName "list" let name = mkName name0 -- shorthands for arithmetic expressions; the first takes expressions, -- the others take variable names sumE e1 e2 = infixE (Just e1) [|(+)|] (Just e2) varDiffE e1 e2 = infixE (Just (varE e1)) [|(-)|] (Just (varE e2)) varProdE e1 e2 = infixE (Just (varE e1)) [|(*)|] (Just (varE e2)) conPat vars = conP name (fmap varP vars) -- > data Vector = Vector !Double ... !Double theDataD = dataD noContext name [] -- no context, no params [normalC name (replicate n (strict ctyp))] [''Eq,''Ord,''Show] -- 'deriving' clause innerProdD = -- > instance InnerProductSpace Vector Double where ... instanceD noContext ( conT ''InnerProductSpace `appT` conT name `appT` ctyp) -- > innerProduct = ... [valD (varP 'innerProduct) (normalB -- \(Vector x1 x2 ... xn) (Vector y1 y2 ... yn) -> (lamE [conPat xs, conPat ys] -- x1*y1 + .... + xn*yn + 0 (foldl sumE [|0|] $ zipWith varProdE xs ys) )) [] -- no 'where' clause ] abGroupD = instanceD noContext ( conT ''AbGroup `appT` conT name) -- > minus = ... [valD (varP 'minus) (normalB -- \(Vector x1 x2 ... xn) (Vector y1 y2 ... yn) -> (lamE [conPat xs, conPat ys] -- Vector (x1-y1) ... (xn-yn) (foldl appE (conE name) $ zipWith varDiffE xs ys) )) [] -- no 'where' clause ] fromToListD = instanceD noContext ( conT ''FromToList `appT` conT name `appT` ctyp) [ funD 'fromList [ clause [listP $ fmap varP xs] (normalB ([|Just|] `appE` (foldl appE (conE name) $ fmap varE xs))) [] , clause [wildP] (normalB [|Nothing|]) [] -- wrong number of elements ] , funD 'toList [ clause [conPat xs] (normalB (listE (fmap varE xs))) []] ] sequence [theDataD,innerProdD,abGroupD,fromToListD] From loup.vaillant at gmail.com Tue May 19 08:23:11 2009 From: loup.vaillant at gmail.com (Loup Vaillant) Date: Tue May 19 08:07:57 2009 Subject: [Haskell-cafe] Expression parsing problem In-Reply-To: <23611617.post@talk.nabble.com> References: <23610457.post@talk.nabble.com> <63AF3FEB-1553-4511-B848-6B0C538ED39E@cs.york.ac.uk> <23611617.post@talk.nabble.com> Message-ID: <6f9f8f4a0905190523k429d6522je227f2130e69385d@mail.gmail.com> Hello, 2009/5/19 leledumbo : >> expression ::= term | term "+" expression >> term ::= factor | factor "*" term >> factor ::= constant | variable | "(" expression ")" > > Oh, left recursion. Well, it should be easy to transform: > > expression ::= term | moreTerm > term ::= factor | moreFactor > moreTerm ::= term "+" expression > factor ::= constant | variable | "(" expression ")" > moreFactor := factor "*" term > > correct? I think not. See for instance: > expression ::= term | moreTerm > moreTerm ::= term "+" expression An expression begins by a term or a moreTerm? which itself begins by a term. You still have the left recursion problem, I think. What you mean was probably that: expression ::= term moreTerm term ::= factor moreFactor factor ::= constant | variable | "(" expression ")" moreTerm ::= "+" expression | nothing moreFactor ::= "*" expression | nothing nothing ::= Unfortunately, if this work (I'm not entirely sure), it is right associative. Example of parsing left associative operators can be found on the net, however. Finally, I strongly suggest you to take a look at the Parsec library [1] (unless you can't?). It provide a "buildExpressionParser" function which takes care of associativity and precedence for you. [1] http://legacy.cs.uu.nl/daan/download/parsec/parsec.html From kenneth.hoste at ugent.be Tue May 19 09:14:01 2009 From: kenneth.hoste at ugent.be (Kenneth Hoste) Date: Tue May 19 08:58:57 2009 Subject: [Haskell-cafe] fast Eucl. dist. - Haskell vs C In-Reply-To: <200905191324.02225.anotheraddress@gmx.de> References: <200905191324.02225.anotheraddress@gmx.de> Message-ID: On May 19, 2009, at 13:24 , Daniel Sch?ssler wrote: > Hello! > > On Monday 18 May 2009 14:37:51 Kenneth Hoste wrote: >> I'm mostly interested in the range 10D to 100D > > is the dimension known at compile-time? Then you could consider > Template > Haskell. In general, no. :-) It will be known for some applications, but not for others. I'm more and more amazed what comes into play just to implement something simple like n-dim. Euclidean distance relatively fast using Haskell. It seems to me that GHC is missing several critical optimizations (yes, I know, patches welcome) to enable it to emit fast code for HPC applications. I'm still a big fan of Haskell, for a variety of reasons, but it seems like it's not ready yet for the task I had in mind, which is a shame. Just to be clear, this isn't a flame bait post or anything, just my 2 cents. K. > I wrote up some code for generating the vector types and vector > subtraction/inner product below, HTH. One problem is that I'm using a > typeclass and apparently you can't make {-# SPECIALISE #-} pragmas > with TH, > so let's hope it is automatically specialised by GHC. > > Greetings, > Daniel > > TH.hs > ------------------ > > > {-# LANGUAGE TemplateHaskell #-} > {-# OPTIONS -fglasgow-exts #-} > > module TH where > > import Language.Haskell.TH > import Control.Monad > > -- Non-TH stuff > class InnerProductSpace v r | v -> r where > innerProduct :: v -> v -> r > > class AbGroup v where > minus :: v -> v -> v > > euclidean x y = case minus x y of > z -> sqrt $! innerProduct z z > > -- TH > noContext :: Q Cxt > noContext = return [] > strict :: Q Type -> StrictTypeQ > strict = liftM ((,) IsStrict) > > makeVectors :: Int -- ^ Dimension > -> Q Type -- ^ Component type, assumed to be a 'Num' > -> String -- ^ Name for the generated type > -> Q [Dec] > makeVectors n ctyp name0 = do > -- let's assume ctyp = Double, name = Vector for the comments > > -- generate names for the variables we will need > xs <- replicateM n (newName "x") > ys <- replicateM n (newName "y") > > let > name = mkName name0 > > -- shorthands for arithmetic expressions; the first takes > expressions, > -- the others take variable names > sumE e1 e2 = infixE (Just e1) [|(+)|] (Just e2) > varDiffE e1 e2 = infixE (Just (varE e1)) [|(-)|] (Just (varE > e2)) > varProdE e1 e2 = infixE (Just (varE e1)) [|(*)|] (Just (varE > e2)) > > > conPat vars = conP name (fmap varP vars) > > -- > data Vector = Vector !Double ... !Double > theDataD = > dataD noContext name [] -- no context, no params > [normalC name (replicate n (strict ctyp))] > [''Eq,''Ord,''Show] -- 'deriving' clause > > innerProdD = > -- > instance InnerProductSpace Vector Double where ... > instanceD noContext ( conT ''InnerProductSpace > `appT` conT name > `appT` ctyp) > -- > innerProduct = ... > [valD > (varP 'innerProduct) > (normalB > -- \(Vector x1 x2 ... xn) (Vector y1 y2 ... yn) > -> > (lamE [conPat xs, conPat ys] > -- x1*y1 + .... + xn*yn + 0 > (foldl sumE [|0|] $ > zipWith varProdE xs ys) > )) > > [] -- no 'where' clause > ] > > abGroupD = > instanceD noContext ( conT ''AbGroup > `appT` conT name) > -- > minus = ... > [valD > (varP 'minus) > (normalB > -- \(Vector x1 x2 ... xn) (Vector y1 y2 ... yn) > -> > (lamE [conPat xs, conPat ys] > -- Vector (x1-y1) ... (xn-yn) > (foldl appE (conE name) $ > zipWith varDiffE xs ys) > )) > > [] -- no 'where' clause > ] > > > sequence [theDataD,innerProdD,abGroupD] > > > > Main.hs > ------------------ > {-# LANGUAGE TemplateHaskell #-} > {-# LANGUAGE MultiParamTypeClasses #-} > > module Main where > > import TH > > $(makeVectors 3 [t|Double|] "Vec3") > > main = print $ euclidean (Vec3 1 1 1) (Vec3 0 0 0) > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Kenneth Hoste Paris research group - ELIS - Ghent University, Belgium email: kenneth.hoste@elis.ugent.be website: http://www.elis.ugent.be/~kehoste blog: http://boegel.kejo.be From nowgate at yahoo.com Tue May 19 10:07:30 2009 From: nowgate at yahoo.com (michael rice) Date: Tue May 19 09:52:12 2009 Subject: [Haskell-cafe] showing a user defined type Message-ID: <510777.67717.qm@web31101.mail.mud.yahoo.com> Thanks. I had put together something similar to your first suggestion but tried to use PutStrLn(Show...). I'd also thought of your second suggestion about a dummy show for functions. A little further along in "The Little MLer" the ints function is replaced by other functions like primes and fibs, which also return Links: fun primes(n) ? = if is_prime(n+1) ?then Link(n+1,primes) ?else primes(n+1) fun fibs(n)(m) ? = Link(n+m,fibs(m)) which are passed to chain_item: fun chain_item(n,Link(i,f)) ? = if eq_int(n,1) ? then i ? else chain_item(n-1,f(i)) which can be called to request the nth (12th) prime number beginning at 1. - chain_item(12,primes(1)); GC #0.0.0.1.3.61:?? (1 ms) val it = 37 : int - So I guess the answer to your question about whether the function is ever called with a different value may be, yes. Michael --- On Mon, 5/18/09, Ryan Ingram wrote: From: Ryan Ingram Subject: Re: [Haskell-cafe] showing a user defined type To: "Brandon S. Allbery KF8NH" Cc: "michael rice" , haskell-cafe@haskell.org Date: Monday, May 18, 2009, 10:02 PM Unfortunately, you can't derive Show on Chain as defined, because it contains a function: > data Chain = Link Int (Int -> Chain) You can write this: > instance Show Chain where >? ? show (Link n _) = "Link " ++ show n ++ " " Or you can make a dummy "Show" instance for functions: > instance Show (a -> b) where show _ = "" > data Chain = Link Int (Int -> Chain) deriving Show One question: Do you expect to ever call the function with a different value?? For example: otherChain :: Chain otherChain = case (ints 0) of Link _ f -> f 100 If not, you can replace Chain entirely by [Int], due to laziness, something that's not possible in ML.? (Although you can get the same result in ML by using (int * (() -> chain)) instead. ? -- ryan On Mon, May 18, 2009 at 6:36 PM, Brandon S. Allbery KF8NH wrote: > On May 18, 2009, at 21:19 , michael rice wrote: > > *Main> :t ints 0 > ints 0 :: Chain > *Main> ints 0 > > :1:0: > ??? No instance for (Show Chain) > > In general, you want to append > ?? ?deriving Show > to your types. ?You may also want to be able to input them in ghci, so > instead say > ?? ?deriving (Show, Read) > -- > 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 > > > _______________________________________________ > 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/20090519/37fa0cb0/attachment.html From nowgate at yahoo.com Tue May 19 10:16:40 2009 From: nowgate at yahoo.com (michael rice) Date: Tue May 19 10:01:25 2009 Subject: [Haskell-cafe] showing a user defined type Message-ID: <688749.71088.qm@web31102.mail.mud.yahoo.com> Cool! Is there *anything* Haskell *can't* do? Michael --- On Mon, 5/18/09, David Menendez wrote: From: David Menendez Subject: Re: [Haskell-cafe] showing a user defined type To: "Ryan Ingram" Cc: haskell-cafe@haskell.org Date: Monday, May 18, 2009, 10:26 PM On Mon, May 18, 2009 at 10:02 PM, Ryan Ingram wrote: > Unfortunately, you can't derive Show on Chain as defined, because it > contains a function: Sure you can. I just tried the following, and it compiled without complaints. > import Text.Show.Functions > > data Chain = Link Int (Int -> Chain) deriving (Show) The usual warnings about orphan instances apply, but the purpose of the Text.Show.Functions module is to provide a standard Show instance for functions so that libraries (e.g., QuickCheck) don't declare conflicting instances. -- 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/20090519/051e8004/attachment.html From chaddai.fouche at gmail.com Tue May 19 10:20:33 2009 From: chaddai.fouche at gmail.com (=?UTF-8?B?Q2hhZGRhw68gRm91Y2jDqQ==?=) Date: Tue May 19 10:05:16 2009 Subject: [Haskell-cafe] How to use Data.ByteString ? In-Reply-To: <5B36B7A8-86F0-4400-AA9A-A1ABD3B0C58C@ece.cmu.edu> References: <6247530.99671242709661054.JavaMail.coremail@app176.163.com> <5B36B7A8-86F0-4400-AA9A-A1ABD3B0C58C@ece.cmu.edu> Message-ID: On Tue, May 19, 2009 at 8:46 AM, Brandon S. Allbery KF8NH wrote: > On May 19, 2009, at 01:42 , Jason Dagit wrote: >> >> I've often seen this bit of scary code in VB: >> Dim i as Integer = 5 >> If i = "5" Then >> ?' Do something, because 5 = "5" >> End If > > Sure, that works in Perl too. That's because in numeric context Perl convert strings into numbers, so even 5 == "5 coffees" would be true... But 5 eq "5 coffees" wouldn't since eq force a string context and 5 is converted to "5" which is not string-equal to "5 coffees". Perl is all about context and is coherent in its weirdness, whereas VB is pretty screwed IIRC. -- Jeda? From phunge0 at hotmail.com Tue May 19 10:23:24 2009 From: phunge0 at hotmail.com (Brian Bloniarz) Date: Tue May 19 10:08:07 2009 Subject: [Haskell-cafe] Request for feedback: HaskellDB + HList In-Reply-To: References: Message-ID: Hi Justin, I updated my changes to apply against that repo, thanks for the pointer. Cool to see new changes to haskelldb, especially all the new unit tests! You can find my updated repo at: http://patch-tag.com/r/haskelldb-hlist Re-reading your email now, I see you asked for a patch, but seeing patch-tag for the first time I got excited and uploaded a whole new repo, whoops. Anyway, I had to do some minor surgery to update to the new version -- everything compiles, but I haven't tested much beyond that yet. Let me know if you have any questions. Thanks, -Brian > I like the direction you are going. I looked into using HList a year > or so ago and I wasn't quite up to it. The latest (unreleased) > version of HaskellDB is on patch-tag at > http://patch-tag.com/r/haskelldb/snapshot/current/content/pretty. > Would you mind creating a patch file against that for easier review? I > won't commit it until you say its ready but I'd like to see what > changes you have made. > > No announcement has been made but I took over maintainership from > Bjorn a few months ago. I hope to get a 1.0 release of HaskellDB out > this summer, and having something new like this in it would be pretty > sweet. > > On Sat, May 16, 2009 at 3:08 PM, Brian Bloniarz wrote: > > Hi, > > > > It's come time to share something that I've been playing around with > > recently: > > a branch of HaskellDB which replaces the home-grown Record code with HList > > records. It's definitely not ready for primetime, but I thought it'd be a > > good > > time to post the code and solicit some feedback from the community. > > > > HaskellDB the concept is very promising, but IMHO the code still falls short > > of that promise. Hopefully this is a small step in the right direction -- > > the > > advantages of using HList: > > * Shared implementation of extensible records > > * Additional features from HList > > * Better error messages for record misuse > > * "Lacks" predicates > > * Simpler code > > > > As an example of how this can be better, a DB insert looks like so: > >> insert db table $ constantRecord $ > >> film .=. "Munchie" .*. > >> director .=. Just "Jim Wynorski" .*. > >> emptyRecord > > The columns need not appear in the same order as in the database. If you > > forget > > a column, you'll get "error: No instance for (Fail (FieldNotFound (Proxy > > Director)))" > > rather than an opaque error. Using the new "insertOpt" function, Maybe > > columns > > will default to Nothing rather than needing to be specified. > > > > The details: > > > > I haven't updated everything, but there's enough to run test/TestCases.hs > > under Postgresql. TestCases is probably the best place to look for examples > > of > > the new syntax for now. > > > > HList had name conflicts with HaskellDB's SQL expression language > > ((.*.), (.++.), etc.) My temporary band-aid is to move the expression > > functions > > to Database.HaskellDB.SqlExpr, and require people to import qualified. > > > > The Attr type is gone, columns labels are untyped now. I also replaced a > > few instances of primitive type-level recursion with HMap/HMapOut. This > > makes > > the code simpler, and the type signatures more complex -- type families > > would > > help a lot here, I think. > > > > Feedback welcome! You can find my darcs tree at: > > > > http://mysite.verizon.net/vzewxzuh/sitebuildercontent/sitebuilderfiles/haskelldb-hlist-20090516.tar.gz > > It also requires minor changes to HList, available at: > > > > http://mysite.verizon.net/vzewxzuh/sitebuildercontent/sitebuilderfiles/hlist-20090516.tar.gz > > I'll talk to the HList people about getting those merged. > > > > Thanks! > > > > Brian Bloniarz > > > > > > ________________________________ > > Hotmail? has a new way to see what's up with your friends. Check it out. > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > _________________________________________________________________ Hotmail? has ever-growing storage! Don?t worry about storage limits. http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage1_052009 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090519/5949fe21/attachment.html From miguelimo38 at yandex.ru Tue May 19 10:26:52 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Tue May 19 10:14:22 2009 Subject: [Haskell-cafe] showing a user defined type In-Reply-To: <688749.71088.qm@web31102.mail.mud.yahoo.com> References: <688749.71088.qm@web31102.mail.mud.yahoo.com> Message-ID: <4A12C1AC.608@yandex.ru> michael rice wrote on 19.05.2009 18:16: > Cool! > > Is there *anything* Haskell *can't* do? Well, I haven't found a way to emulate polymorphics kinds yet, and I feel like I need them. Other than than - probably no. > > Michael > > --- On *Mon, 5/18/09, David Menendez //* wrote: > > > From: David Menendez > Subject: Re: [Haskell-cafe] showing a user defined type > To: "Ryan Ingram" > Cc: haskell-cafe@haskell.org > Date: Monday, May 18, 2009, 10:26 PM > > On Mon, May 18, 2009 at 10:02 PM, Ryan Ingram > wrote: > > Unfortunately, you can't derive Show on Chain as defined, because it > > contains a function: > > Sure you can. I just tried the following, and it compiled without > complaints. > > > import Text.Show.Functions > > > > data Chain = Link Int (Int -> Chain) deriving (Show) > > The usual warnings about orphan instances apply, but the purpose of > the Text.Show.Functions module is to provide a standard Show instance > for functions so that libraries (e.g., QuickCheck) don't declare > conflicting instances. > > -- > Dave Menendez > > > > _______________________________________________ > 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 leimy2k at gmail.com Tue May 19 14:33:27 2009 From: leimy2k at gmail.com (David Leimbach) Date: Tue May 19 14:18:11 2009 Subject: [Haskell-cafe] Question about IO, interact functions, Message-ID: <3e1162e60905191133t71b0af3ag3f5ef27af1ed9eea@mail.gmail.com> main = interact (unlines . lines) This *appears* to somewhat reliably get me functionality that looks like take a line of input, and print it out. Is this behavior something I can rely on working? I like the idea that lines can pull lines lazily from "getContents" which lazily consume the input. But I'm concerned that relying on a pure function like "unlines . lines" to sequence IO is a bit too implicit in nature. I really like the idea of doing things through functions like Interact in that they appear to allow me to keep most of my code pure, but if I can't get the IO sequencing I want to be guaranteed to work, I suppose I'll have to dive back into "imperative IO" land that I get from the IO Monad. Should I feel guilty for doing so? :-) Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090519/04d1fb77/attachment.html From jason.dusek at gmail.com Tue May 19 14:37:34 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Tue May 19 14:22:27 2009 Subject: [Haskell-cafe] Question about IO, interact functions, In-Reply-To: <3e1162e60905191133t71b0af3ag3f5ef27af1ed9eea@mail.gmail.com> References: <3e1162e60905191133t71b0af3ag3f5ef27af1ed9eea@mail.gmail.com> Message-ID: <42784f260905191137t2c07ab77jc6ecefd16b5cef0e@mail.gmail.com> 2009/05/19 David Leimbach : > ...I'm concerned that relying on a pure function like > "unlines . lines" to sequence IO is a bit too implicit in nature. You aren't relying on `unlines . lines` to do the sequencing; you're relying on them to process a string. That the characters of the string come in order has everything to do with `getContents`, which is trustworthy. -- Jason Dusek From ryani.spam at gmail.com Tue May 19 14:40:55 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue May 19 14:25:36 2009 Subject: [Haskell-cafe] showing a user defined type In-Reply-To: <510777.67717.qm@web31101.mail.mud.yahoo.com> References: <510777.67717.qm@web31101.mail.mud.yahoo.com> Message-ID: <2f9b2d30905191140w1b45adafj91f35aa8212f02aa@mail.gmail.com> On Tue, May 19, 2009 at 7:07 AM, michael rice wrote: > A little further along in "The Little MLer" the ints function is replaced by > other functions like primes and fibs, which also return Links: > > fun primes(n) > ? = if is_prime(n+1) > ?then Link(n+1,primes) > ?else primes(n+1) > > fun fibs(n)(m) > ? = Link(n+m,fibs(m)) > > which are passed to chain_item: > > fun chain_item(n,Link(i,f)) > ? = if eq_int(n,1) > ? then i > ? else chain_item(n-1,f(i)) > > which can be called to request the nth (12th) prime number beginning at 1. > > - chain_item(12,primes(1)); > GC #0.0.0.1.3.61:?? (1 ms) > val it = 37 : int > - > > So I guess the answer to your question about whether the function is ever > called with a different value may be, yes. Actually, it's not calling it with another value; notice that chain_item calls f(i), with i coming directly from the chain. Consider this alternate definition: (I'm not sure the syntax is exactly right, but you get the idea) datatype chain = Link of (int * ( unit -> chain )) fun intsFrom(n) = fun unit => (n, intsFrom (n+1)) fun ints(n) = intsFrom n () Now you *can't* call the function embedded in the link with another value. fun chain_item(n,Link(i,f)) = if eq_int(n,1) then i else chain_item(n-1,f unit) And this type for "chain" is almost the same as [Int] in Haskell, due to laziness. -- ryan From es at ertes.de Tue May 19 14:56:22 2009 From: es at ertes.de (Ertugrul Soeylemez) Date: Tue May 19 14:41:18 2009 Subject: [Haskell-cafe] Re: Question about IO, interact functions, References: <3e1162e60905191133t71b0af3ag3f5ef27af1ed9eea@mail.gmail.com> Message-ID: <20090519205622.10b41084@tritium.xx> David Leimbach wrote: > main = interact (unlines . lines) > This *appears* to somewhat reliably get me functionality that looks like > take a line of input, and print it out. > > Is this behavior something I can rely on working? > > I like the idea that lines can pull lines lazily from "getContents" > which lazily consume the input. But I'm concerned that relying on a > pure function like "unlines . lines" to sequence IO is a bit too > implicit in nature. As Jason pointed out, you're relying on getContents. Your little function composition "unlines . lines" will do nothing at all in most cases, although in some configurations it may replace line feed representations. What you're really relying on is the buffering method used by 'stdin' and 'stdout'. If you want to make sure, use the following: import System.IO main :: IO () main = do mapM_ (`hSetBuffering` LineBuffering) [stdin, stdout] iterate f > I really like the idea of doing things through functions like Interact > in that they appear to allow me to keep most of my code pure, but if I > can't get the IO sequencing I want to be guaranteed to work, I suppose > I'll have to dive back into "imperative IO" land that I get from the > IO Monad. > > Should I feel guilty for doing so? :-) Not always. Especially when writing concurrent code for things like servers, I usually write highly imperative code, using functional constructs where appropriate. Being a functional language of course makes Haskell much more powerful and expressive, but it has lots of more advantages like an amazing concurrency system. =) Note: 'Iterate' would be a type, a class or a module. Functions (and type variables) _must_ be written in lower-case in Haskell. Greets, Ertugrul. -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/ From mwinter at brocku.ca Tue May 19 15:04:10 2009 From: mwinter at brocku.ca (mwinter@brocku.ca) Date: Tue May 19 14:48:48 2009 Subject: [Haskell-cafe] Gtk2Hs + Sourceview on Windows Message-ID: <4A12CA6A.26943.13E72B4@mwinter.brocku.ca> Hi, I have ghc 6.10.1 and gtk2hs 0.10.0 installed on my windows vista computer. Both were installed using the installer on the webpages. I am able to use gtk, glade etc but not sourceview or cairo. If I compile the examples in the gtk2hs example folder, I get "not in scope" error messages for functions from those library components. In a forum I found that those have to be enabled using ./configure --enable-sourceview (similar for cairo). But my windows installation does not seem to have a script configure or a similar program. What am I supposed to do? Thanks, Michael ---------------------------------------------------------------------------------------------- Michael Winter Brock University Associate Professor 500 Glenridge Avenue Department of Computer Science St. Catharine, ON, L2S 3 A1 Phone: +1 905 688 5550 ext 3355 Fax: +1 905 688 3255 --------------------------------------------------------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090519/42da7280/attachment.html From tomahawkins at gmail.com Tue May 19 17:11:02 2009 From: tomahawkins at gmail.com (Tom Hawkins) Date: Tue May 19 16:55:45 2009 Subject: [Haskell-cafe] ANN: atom 0.0.4 Message-ID: <594c1e830905191411t141e31d5o343d0ef793cc414a@mail.gmail.com> This new version of atom adds an array datatype (A a), which has helped us shrink and speed up the embedded code in our application. Enjoy! http://hackage.haskell.org/cgi-bin/hackage-scripts/package/atom -Tom From patperry at stanford.edu Tue May 19 18:02:53 2009 From: patperry at stanford.edu (Patrick Perry) Date: Tue May 19 17:47:39 2009 Subject: [Haskell-cafe] fast Eucl. dist. - Haskell vs C Message-ID: <916933CD-29D0-4FDB-957C-068D6E5BCA13@stanford.edu> Hi Kenneth, I wrote a benchmark similar to yours using the haskell blas library I wrote (latest version is on github at http://github.com/patperry/blas/tree/master , an older version is on hackage). The pure Haskell implementation is not very good, and the problem seems to be repeated boxing/unboxing of doubles. It may be possible to avoid this by writing a custom "fold" function for Vectors, but I haven't tried it. Using a vectorized subtraction function along with the BLAS1 "dnrm2" function, I was able to get performance about 2.8-5.4x worse than C. This isn't great, but it's not terrible, either. I didn't have the performance problems you ran in to using the FFI. My benchmark includes: distVectors1: a native implementation using foldl' and zipWith distVectors2: a vectorize implementation, defined as @distVectors2 x y = norm2 (x-y)@ distVectors3: a custom loop in haskell distVectors4: an FFI call to C All 4 functions use the "Vector" type, provided by the "blas" package. I compiled with "-O -fexcess-preceision" and ran timings for vectors of size 10, 100, and 1000. Here are the results: Macintosh-62:~/Code/blas/examples (euclidean)$ ./Euclidean 10 n: 10 * distVectors1: ..................... 1.366ns per iteration / 732029.06 per second. * distVectors2: ..................... 1.286ns per iteration / 777734.02 per second. * distVectors3: ...................... 0.950ns per iteration / 1052847.93 per second. * distVectors4: ....................... 0.452ns per iteration / 2213752.56 per second. Macintosh-62:~/Code/blas/examples (euclidean)$ ./Euclidean 100 n: 100 * distVectors1: .................. 12.496ns per iteration / 80025.79 per second. * distVectors2: .................... 2.149ns per iteration / 465311.61 per second. * distVectors3: .................. 8.728ns per iteration / 114572.53 per second. * distVectors4: ...................... 0.597ns per iteration / 1675765.65 per second. Macintosh-62:~/Code/blas/examples (euclidean)$ ./Euclidean 1000 n: 1000 * distVectors1: .............. 125.920ns per iteration / 7941.52 per second. * distVectors2: .................. 10.677ns per iteration / 93661.99 per second. * distVectors3: ............... 85.533ns per iteration / 11691.42 per second. * distVectors4: .................... 1.962ns per iteration / 509668.17 per second. The "distVectors2" function is computing the norm in a more numerically-stable way. It is also allocating a temporary array to store x-y. I haven't looked over your benchmarking code too thoroughly, but parts of it seem suspect to me. Namely, you are using "mapM" instead of "mapM_". Also, it seems like you are including GC times in your benchmarks. Attached is my code. You will need the latest "blas" from github to compile it. You also might want to look into hmatrix. I have very little time for haskell code right now (I'm trying to finish my Ph.D. in the next month). This summer I plan to work more on this stuff, and I'll probably make a release in July. Patrick -------------- next part -------------- A non-text attachment was scrubbed... Name: Euclidean.hs Type: application/octet-stream Size: 1938 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090519/f17de0c6/Euclidean.obj -------------- next part -------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: dist.c Type: application/octet-stream Size: 248 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090519/f17de0c6/dist.obj -------------- next part -------------- From masahiro.sakai at gmail.com Tue May 19 19:23:04 2009 From: masahiro.sakai at gmail.com (Masahiro Sakai) Date: Tue May 19 19:08:24 2009 Subject: [Haskell-cafe] Free theorems for dependent types? In-Reply-To: <5e0214850905171210i22183345w99b6a395da234236@mail.gmail.com> References: <5e0214850905171210i22183345w99b6a395da234236@mail.gmail.com> Message-ID: <20090520.082304.220815033.sakai@tom.sfc.keio.ac.jp> From: Eugene Kirpichov Date: Sun, 17 May 2009 23:10:12 +0400 > Is there any research on applying free theorems / parametricity to > type systems more complex than System F; namely, Fomega, or calculus > of constructions and alike? You may be interested in this: "The Theory of Parametricity in Lambda Cube" by Takeuti Izumi http://www.m.is.sci.toho-u.ac.jp/~takeuti/abs-e.html#cube -- Masahiro Sakai From nowgate at yahoo.com Tue May 19 19:25:57 2009 From: nowgate at yahoo.com (michael rice) Date: Tue May 19 19:10:39 2009 Subject: [Haskell-cafe] showing a user defined type Message-ID: <293450.30887.qm@web31104.mail.mud.yahoo.com> Hi Ryan, I'm afraid you've lost me. Maybe if you showed how this would be used in ML I would get the picture. Michael --- On Tue, 5/19/09, Ryan Ingram wrote: From: Ryan Ingram Subject: Re: [Haskell-cafe] showing a user defined type To: "michael rice" Cc: "Brandon S. Allbery KF8NH" , haskell-cafe@haskell.org Date: Tuesday, May 19, 2009, 2:40 PM On Tue, May 19, 2009 at 7:07 AM, michael rice wrote: > A little further along in "The Little MLer" the ints function is replaced by > other functions like primes and fibs, which also return Links: > > fun primes(n) > ? = if is_prime(n+1) > ?then Link(n+1,primes) > ?else primes(n+1) > > fun fibs(n)(m) > ? = Link(n+m,fibs(m)) > > which are passed to chain_item: > > fun chain_item(n,Link(i,f)) > ? = if eq_int(n,1) > ? then i > ? else chain_item(n-1,f(i)) > > which can be called to request the nth (12th) prime number beginning at 1. > > - chain_item(12,primes(1)); > GC #0.0.0.1.3.61:?? (1 ms) > val it = 37 : int > - > > So I guess the answer to your question about whether the function is ever > called with a different value may be, yes. Actually, it's not calling it with another value; notice that chain_item calls f(i), with i coming directly from the chain. Consider this alternate definition: (I'm not sure the syntax is exactly right, but you get the idea) datatype chain = ? Link of (int * ( unit -> chain )) fun intsFrom(n) = fun unit => (n, intsFrom (n+1)) fun ints(n) = intsFrom n () Now you *can't* call the function embedded in the link with another value. fun chain_item(n,Link(i,f)) ? = if eq_int(n,1) ? then i ? else chain_item(n-1,f unit) And this type for "chain" is almost the same as [Int] in Haskell, due to laziness. ? -- ryan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090519/8415da8e/attachment.html From briqueabraque at yahoo.com Tue May 19 20:28:55 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Tue May 19 20:13:53 2009 Subject: [Haskell-cafe] Haskell programmers in =?iso-8859-1?q?S=E3o_Carlos_-_SP_-_Brazil?= =?iso-8859-1?q?=3F?= Message-ID: Anybody else around here? Best, Maur?cio From z_axis at 163.com Tue May 19 20:40:15 2009 From: z_axis at 163.com (z_axis@163.com) Date: Tue May 19 20:24:08 2009 Subject: [Haskell-cafe] How i use GHC.Word.Word8 wit Int ? Message-ID: <4A13516F.1090006@163.com> Hi, friends rollDice :: Word8 -> IO Word8 rollDice n = do bracket (openFile "/dev/random" ReadMode) (hClose) (\hd -> do v <- fmap B.unpack (B.hGet hd 1) let v1 = Data.List.head v return $ (v1 `mod` n) + 1) ..... blueIdx <- rollDice $ length [1..33] Couldn't match expected type `Word8' against inferred type `Int' In the second argument of `($)', namely `length yesBlue I know "length [1..33]" is Int not Word8, but Word8 is enough here. Sincerely! From felipe.lessa at gmail.com Tue May 19 20:46:29 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Tue May 19 20:31:23 2009 Subject: [Haskell-cafe] How i use GHC.Word.Word8 wit Int ? In-Reply-To: <4A13516F.1090006@163.com> References: <4A13516F.1090006@163.com> Message-ID: <20090520004629.GA2765@kira.casa> On Wed, May 20, 2009 at 08:40:15AM +0800, z_axis@163.com wrote: > I know "length [1..33]" is Int not Word8, but Word8 is enough here. Just saying '33' is enough here. :) -- Felipe. From paravinicius at yahoo.com.br Tue May 19 22:07:54 2009 From: paravinicius at yahoo.com.br (Diego Souza) Date: Tue May 19 21:54:57 2009 Subject: [Haskell-cafe] Haskell =?utf-8?Q?progr?= =?utf-8?Q?ammers_in_S=C3=A3o?= Carlos - SP - Brazil? In-Reply-To: References: Message-ID: <20090520020754.GA4007@mephisto.bitforest.org> Not exactly S?o Carlos: S?o Paulo - SP. On Tue, May 19, 2009 at 09:28:55PM -0300, Maur??cio wrote: > Anybody else around here? > > Best, > Maur?cio > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- ~dsouza yahoo!im: paravinicius gpg key fingerprint: 71B8 CE21 3A6E F894 5B1B 9ECE F88E 067F E891 651E From florbitous at gmail.com Tue May 19 22:16:29 2009 From: florbitous at gmail.com (Bernie Pope) Date: Tue May 19 22:01:11 2009 Subject: [Haskell-cafe] How i use GHC.Word.Word8 wit Int ? In-Reply-To: <4A13516F.1090006@163.com> References: <4A13516F.1090006@163.com> Message-ID: <4d8ad03a0905191916g5bbf2bedy50688b41578915f3@mail.gmail.com> 2009/5/20 z_axis@163.com : > Hi, friends > > rollDice :: Word8 -> IO Word8 > rollDice n = do > ? bracket (openFile "/dev/random" ReadMode) (hClose) > ? ? ? (\hd -> do v <- ?fmap B.unpack (B.hGet hd 1) > ? ? ? ? ? ? ? ? ?let v1 = ?Data.List.head v > ? ? ? ? ? ? ? ? ?return $ (v1 `mod` n) + 1) > ..... > blueIdx <- rollDice $ length [1..33] > > Couldn't match expected type `Word8' against inferred type `Int' > ? In the second argument of `($)', namely `length yesBlue > > I know "length [1..33]" is Int not Word8, but Word8 is enough here. > Sincerely! You can use fromIntegral to convert Integral types to other numeric types: fromIntegral :: (Integral a, Num b) => a -> b Prelude Data.Word> (fromIntegral (3 :: Int)) :: Word8 3 Watch out for overflow. Cheers, Bernie. From allbery at ece.cmu.edu Tue May 19 22:19:16 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue May 19 22:04:10 2009 Subject: [Haskell-cafe] How to use Data.ByteString ? In-Reply-To: References: <6247530.99671242709661054.JavaMail.coremail@app176.163.com> <5B36B7A8-86F0-4400-AA9A-A1ABD3B0C58C@ece.cmu.edu> Message-ID: <823278E5-2C66-42E4-B2A2-C331BBC77660@ece.cmu.edu> On May 19, 2009, at 10:20 , Chadda? Fouch? wrote: > On Tue, May 19, 2009 at 8:46 AM, Brandon S. Allbery KF8NH > wrote: >> On May 19, 2009, at 01:42 , Jason Dagit wrote: >>> I've often seen this bit of scary code in VB: >>> Dim i as Integer = 5 >>> If i = "5" Then >>> ' Do something, because 5 = "5" >>> End If >> >> Sure, that works in Perl too. > > That's because in numeric context Perl convert strings into numbers, > so even 5 == "5 coffees" would be true... But 5 eq "5 coffees" > wouldn't since eq force a string context and 5 is converted to "5" If you use == instead of eq then it will emit a warning and then find them equal. This is something of a common logic error in Perl. -- 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/20090519/232ccf9f/PGP.bin From johannes.laire at gmail.com Tue May 19 22:32:58 2009 From: johannes.laire at gmail.com (Johannes Laire) Date: Tue May 19 22:17:39 2009 Subject: [Haskell-cafe] How i use GHC.Word.Word8 wit Int ? In-Reply-To: <4A13516F.1090006@163.com> References: <4A13516F.1090006@163.com> Message-ID: <5f271a760905191932j344158a2gd1f41081f4521850@mail.gmail.com> On Wed, May 20, 2009 at 3:40 AM, z_axis@163.com wrote: > Hi, friends > > rollDice :: Word8 -> IO Word8 > rollDice n = do > ? bracket (openFile "/dev/random" ReadMode) (hClose) > ? ? ? (\hd -> do v <- ?fmap B.unpack (B.hGet hd 1) > ? ? ? ? ? ? ? ? ?let v1 = ?Data.List.head v > ? ? ? ? ? ? ? ? ?return $ (v1 `mod` n) + 1) > ..... > blueIdx <- rollDice $ length [1..33] > > Couldn't match expected type `Word8' against inferred type `Int' > ? In the second argument of `($)', namely `length yesBlue > > I know "length [1..33]" is Int not Word8, but Word8 is enough here. > Sincerely! Word8 is an instance of Num, so you could use Data.List.genericLength, which has the type: genericLength :: Num i => [b] -> i http://haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html#26 -- Johannes Laire From lee.duhem at gmail.com Tue May 19 22:50:02 2009 From: lee.duhem at gmail.com (Lee Duhem) Date: Tue May 19 22:34:43 2009 Subject: [Haskell-cafe] How i use GHC.Word.Word8 wit Int ? In-Reply-To: <4d8ad03a0905191943t4807b9cej5a9e9605f75b7d06@mail.gmail.com> References: <4A13516F.1090006@163.com> <4d8ad03a0905191916g5bbf2bedy50688b41578915f3@mail.gmail.com> <4d8ad03a0905191937u3d519cbhe2604545b9edf25b@mail.gmail.com> <4d8ad03a0905191943t4807b9cej5a9e9605f75b7d06@mail.gmail.com> Message-ID: 2009/5/20 Bernie Pope : > Oh right. I didn't see your proposal (did it get sent to the list?). Yes, I just push the Replay button, not the > Sorry for the confusion. It's my fault, sorry. lee From mdmkolbe at gmail.com Tue May 19 23:20:53 2009 From: mdmkolbe at gmail.com (Michael D. Adams) Date: Tue May 19 23:05:34 2009 Subject: [Haskell-cafe] Performance Problem with Typeable In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C337FBFCCAE0@EA-EXMSG-C334.europe.corp.microsoft.com> References: <638ABD0A29C8884A91BC5FB5C349B1C337FBFCCAE0@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: I've opened a ticket for this (http://hackage.haskell.org/trac/ghc/ticket/3245), but someone else will have to do the investigation into the problem. Michael D. Adams On Thu, May 14, 2009 at 10:59 AM, Simon Peyton-Jones wrote: > Interesting. ?Would anyone care to make a Trac ticket for this (with "perf bug" as ?the ticket kind), and (if at all possible) do some investigation to see what is going on? > > Many thanks > > Simon From mg.eastman at gmail.com Wed May 20 00:02:17 2009 From: mg.eastman at gmail.com (Matthew Eastman) Date: Tue May 19 23:47:02 2009 Subject: [Haskell-cafe] Tree traversal / stack overflow Message-ID: <236D329B-E3E0-4D5B-83A0-972D596B839A@gmail.com> Hi, I've been writing some code to calculate the stretch factor of a tree of points. What it means is that for every node in a tree (lets call it 'pivot'), I have to traverse the same tree (lets call each node 'current') and sum d_t(pivot, current) / d(pivot, current) for each node, where d_t is the tree path distance between two nodes and d is the Euclidean distance. What I've been doing is traversing the tree, pivoting up each node into the root position, and calculating the stretch factor for each new tree. ex. +===+ +===+ +===+ | 1 | | 2 | | 3 | +===+ .---+===+----. +===+ / / | | \ \ +---+ +---+ +---+ +---+ +---+ +---+ | 2 | ---> | 3 | | 4 | | 5 | | 1 | ---> | 2 | etc. .+---+. +---+ +---+ +---+ +---+ .+---+. / | \ / | \ +---+ +---+ +---+ +---+ +---+ +---+ | 3 | | 4 | | 5 | | 4 | | 5 | | 1 | +---+ +---+ +---+ +---+ +---+ +---+ The code I have right now works great on point sets of size ~10,000, but when I go up much higher things start to go wrong. I start hitting stack overflows, so I increased the stack size. For ~100,000 points though, running the code with +RTS -sstderr -K128m it chugged along for over an hour and then died with a stack overflow. The stats said it spent 50 seconds MUT time and 5300 seconds (almost 90 minutes!) GC time, which seems odd. The performance has been really good for lower numbers of points, but the professor I'm working for wants to handle over a million points later on. I've only been writing Haskell for a year, and I'm not quite sure how to rewrite this so that it won't blow the stack, since I'm pretty sure this kind of tree traversal can't be done with tail calls (I would love to proved wrong, though!). Any help would be appreciated. Thanks, Matt module ASF ( averageStretchFactor ) where import Data.Tree import Data.Foldable (foldr') type Point = (Double,Double) square :: Double -> Double square x = x * x dist :: Point -> Point -> Double dist (x1,y1) (x2,y2) = sqrt (square (x2 - x1) + square (y2 - y1)) add :: Tree a -> Tree a -> Tree a add (Node p sts) t = Node p (t:sts) -- Calculate the average stretch factor of a tree of size n. It's the sum of -- the average stretch factor of each node in the tree, divided by n choose 2 -- (the number of possible pairs of points in in a tree of size n) averageStretchFactor :: Tree Point -> Double -> Double averageStretchFactor tree n = stretchRotations tree / (n * (n - 1) / 2) -- Calculate the stretch factor of a tree. -- The stretch of two points is the tree path distance between the two points -- divided by the euclidean distance between the two points. The stretch factor -- of a tree is the sum of the stretches between the root and every other node -- in the tree. stretchFactor :: Tree Point -> Double stretchFactor (Node point sts) = stretch 0 point sts where stretch _ _ [] = 0 stretch d p ((Node p' sts'):ts) = pd / ed + stretch pd p' sts' + stretch d p ts where pd = d + dist p p' -- path distance ed = dist point p' -- euclidean distance -- Calculate the stretch factor of every point by pulling up each node in the -- tree to the root position. Note that the overall structure of the tree -- doesn't change, we're essentially just traversing the tree and calculating -- the stretch factor of each node by pretending we're at the root. stretchRotations :: Tree Point -> Double stretchRotations tree = rotate tree [] where rotate tree@(Node p sts) path = stretchFactor (foldr' add tree path) + pivot [] sts path p pivot _ [] _ _ = 0 pivot ls (r:rs) path p = rotate r (Node p (ls ++ rs) : path) + pivot (r:ls) rs path p ./main 10000 +RTS -sstderr -K128m ASF = 22.441 1,298,891,896 bytes allocated in the heap 20,191,904 bytes copied during GC 3,107,116 bytes maximum residency (7 sample(s)) 47,480 bytes maximum slop 8 MB total memory in use (0 MB lost due to fragmentation) Generation 0: 2471 collections, 0 parallel, 0.06s, 0.07s elapsed Generation 1: 7 collections, 0 parallel, 0.03s, 0.03s elapsed INIT time 0.00s ( 0.00s elapsed) MUT time 13.05s ( 13.18s elapsed) GC time 0.09s ( 0.11s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 13.14s ( 13.29s elapsed) %GC time 0.7% (0.8% elapsed) Alloc rate 99,506,082 bytes per MUT second Productivity 99.3% of total user, 98.2% of total elapsed ./main 100000 +RTS -sstderr -K128m Stack space overflow: current size 128000000 bytes. Use `+RTS -Ksize' to increase it. 33,097,322,168 bytes allocated in the heap 3,004,248,280 bytes copied during GC 704,391,196 bytes maximum residency (29 sample(s)) 67,420,196 bytes maximum slop 1731 MB total memory in use (14 MB lost due to fragmentation) Generation 0: 62561 collections, 0 parallel, 5364.16s, 5619.83s elapsed Generation 1: 29 collections, 0 parallel, 4.50s, 48.73s elapsed INIT time 0.00s ( 0.00s elapsed) MUT time 49.85s ( 78.94s elapsed) GC time 5368.66s (5668.56s elapsed) EXIT time 0.00s ( 7.88s elapsed) Total time 5418.51s (5747.56s elapsed) %GC time 99.1% (98.6% elapsed) Alloc rate 663,930,946 bytes per MUT second Productivity 0.9% of total user, 0.9% of total elapsed From ekirpichov at gmail.com Wed May 20 02:08:06 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Wed May 20 01:52:47 2009 Subject: [Haskell-cafe] Free theorems for dependent types? In-Reply-To: References: <5e0214850905171210i22183345w99b6a395da234236@mail.gmail.com> <20090517204102.2fda2218@greenrd.org> <5e0214850905171248n563c0832r93f76dce83a1d9d3@mail.gmail.com> Message-ID: <5e0214850905192308y7432ccdtcd6b35c53b66912a@mail.gmail.com> Thanks for the thorough response. I've found Barras&Bernardo's work (at least, slides) about ICC*, I'll have a look at it. Could you provide with names of works by Altenkirch/Morris/Oury/you? The unordered pair example was especially interesting, since I am somewhat concerned with which operations do not break parametricity for *unordered sets* (as opposed to lists) - turns out, not too many. 2009/5/18 Conor McBride : > Hi > > Questions of parametricity in dependent types are made more > complex by the way in which the "Pi-type" > > ?(x : S) -> T > > corresponds to universal quantification. It's good to think > of this type as a very large product, tupling up individual > T's for each possible x you can distinguish by observation. > "For all x" here means "For each individual x". > > By contrast, your typical universally quantified type > > ?forall x. t > > gives you fantastic guarantees of ignorance about x! It's > really a kind of intersection. "For all x" here means > "For a minimally understood x" --- your program should work > even when x is replaced by a cardboard cutout rather than > an actual whatever-it-is, and this guarantees the > uniformity of operation which free theorems exploit. > I'm reminded of the Douglas Adams line "We demand rigidly > defined areas of doubt and uncertainty.". > > In the dependent case, how much uniformity you get depends > on what observations are permitted on the domain. So what's > needed, to get more theorems out, is a richer language of > controlled ignorance. There are useful developments: > > ?(1) Barras and Bernardo have been working on a dependent > ? ?type system which has both of the above foralls, but > ? ?distinguishes them. As you would hope, the uniform > ? ?forall, its lambda, and application get erased between > ? ?typechecking and execution. We should be hopeful for > ? ?parametricity results as a consequence. > > ?(2) Altenkirch, Morris, Oury, and I have found a way > ? ?(two, in fact, and there's the rub) to deliver > ? ?quotient structures, which should allow us to specify > ? ?more precisely which observations are available on a > ? ?given set. Hopefully, this will facilitate parametric > ? ?reasoning --- if you can only test this, you're bound > ? ?to respect that, etc. My favourite example is the > ? ?recursion principle on *unordered* pairs of numbers > ? ?(N*N/2). > > ? ?uRec : > ? ?(P : N*N/2 -> Set) -> > ? ?((y : N) -> P (Zero, y)) -> > ? ?((xy : N*N/2) -> P xy -> P (map Suc xy)) -> > ? ?(xy : N*N/2) -> P xy > > ? ?Given an unordered pair of natural numbers, either > ? ?one is Zero or both are Suc, right? You can define > ? ?some of our favourite operators this way. > > ? ?add ?= uRec (\ _ -> N) (\ y -> y) (\ _ -> Suc . Suc) > ? ?max ?= uRec (\ _ -> N) (\ y -> y) (\ _ -> Suc) > ? ?min ?= uRec (\ _ -> N) (\ y -> y) (\ _ -> id) > ? ?(==) = uRec (\ _ -> Bool) isZero (\ _ -> id) > > ? ?I leave multiplication as an exercise. > > ? ?The fact that these operators are commutative is > ? ?baked into their type. > > To sum up, the fact that dependent types are good at > reflection makes them bad at parametricity, but there's > plenty of work in progress aimed at the kind of information > hiding which parametricity can then exploit. > > There are good reasons to be optimistic here. > > All the best > > Conor > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From ekirpichov at gmail.com Wed May 20 02:12:00 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Wed May 20 01:56:43 2009 Subject: [Haskell-cafe] Free theorems for dependent types? In-Reply-To: <20090520.082304.220815033.sakai@tom.sfc.keio.ac.jp> References: <5e0214850905171210i22183345w99b6a395da234236@mail.gmail.com> <20090520.082304.220815033.sakai@tom.sfc.keio.ac.jp> Message-ID: <5e0214850905192312p67e847a1ua5db249b68a08184@mail.gmail.com> Thanks, at least the title looks like exactly what I've been looking for, however I cannot quickly appreciate the notation-heavy contents: I definitely will as soon as possible. 2009/5/20 Masahiro Sakai : > From: Eugene Kirpichov > Date: Sun, 17 May 2009 23:10:12 +0400 > >> Is there any research on applying free theorems / parametricity to >> type systems more complex than System F; namely, Fomega, or calculus >> of constructions and alike? > > You may be interested in this: > "The Theory of Parametricity in Lambda Cube" by Takeuti Izumi > http://www.m.is.sci.toho-u.ac.jp/~takeuti/abs-e.html#cube > > -- Masahiro Sakai > _______________________________________________ > 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 david.waern at gmail.com Wed May 20 03:42:19 2009 From: david.waern at gmail.com (David Waern) Date: Wed May 20 03:27:00 2009 Subject: [Haskell-cafe] Problem with haddock importing definition In-Reply-To: References: Message-ID: 2009/5/15 Maur?cio : > Hi, > > I have a situation like this: module A imports R (a newtype > declaration) from module B, and lists it in its (module A) > export list. > > Documentation for R is included by haddock in documentation > for module A, as I want. However, if my package exposes only > module A, documentation for R desapears. Hi Mauricio, sorry for the late reply. When you say documentation disappears, do you mean that R is still listed, but its comments are not shown, or is R completely absent from the documentation? Thanks, David From ross at soi.city.ac.uk Wed May 20 03:50:16 2009 From: ross at soi.city.ac.uk (Ross Paterson) Date: Wed May 20 03:34:57 2009 Subject: [Haskell-cafe] Problem with haddock importing definition In-Reply-To: References: Message-ID: <20090520075016.GA5108@soi.city.ac.uk> On Wed, May 20, 2009 at 09:42:19AM +0200, David Waern wrote: > 2009/5/15 Maur?cio : > > I have a situation like this: module A imports R (a newtype > > declaration) from module B, and lists it in its (module A) > > export list. > > > > Documentation for R is included by haddock in documentation > > for module A, as I want. However, if my package exposes only > > module A, documentation for R desapears. > > When you say documentation disappears, do you mean that R is still > listed, but its comments are not shown, or is R completely absent from > the documentation? See http://trac.haskell.org/haddock/ticket/107 He just needs to include B in the other-modules list, so that cabal will pass it to haddock (and setup sdist). From ryani.spam at gmail.com Wed May 20 04:12:36 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed May 20 03:57:16 2009 Subject: [Haskell-cafe] showing a user defined type In-Reply-To: <293450.30887.qm@web31104.mail.mud.yahoo.com> References: <293450.30887.qm@web31104.mail.mud.yahoo.com> Message-ID: <2f9b2d30905200112h37854b37j203a410d0b0b5e62@mail.gmail.com> (Apologies for my mutilation of ML syntax, I don't completely know the language) Consider the ML type int list, and this function to build one: broken_repeat :: int -> int list broken_repeat n = Cons(n, broken_repeat(n)) This function is recursive, and doesn't terminate; it tries to build an infinite list of ints and your computer runs out of heap and/or stack trying to evaluate it. But the "chain" type doesn't have this problem; you can see it as an int list that gets evaluated "on demand": repeat :: int -> chain repeat(n) = Link(n, repeat) always1 :: int -> chain always1(_) = Link(1, always1) chain_take :: int * chain -> int list chain_take (0,_) = Nil chain_take (n,Link(i,f)) = Cons(n, chain_take(n-1, f(i))) But, nothing in the "chain" type stops you from passing a different value to the function in the link: weird_take :: int * int * chain -> int list weird_take (0,_,_) = Nil weird_take (n,v,Link(i,f)) = Cons(i, weird_take(n-1,v,f(v))) Now, it's possible that chain_take returns the same list for two different "chain" inputs, but weird_take might return different lists depending on how f is implemented. For example: chain_take(5, repeat(1)) = [1,1,1,1,1] chain_take(5, always1(1) = [1,1,1,1,1] weird_take(5, 2, repeat(1)) = [1,2,2,2,2] weird_take(5, 2, always1(1)) = [1,1,1,1,1] One way to fix this is to embed the "state" of the chain in the closure itself. So, in ML, the type unit -> X is commonly called a "thunk"; it can be used to delay computation until later, until it's demanded, just like any lazy value in Haskell. f :: unit -> Int f () = 1 This f isn't very useful; it's basically the same as "1". But consider this type: datatype stream = Stream of (int * (unit -> stream)) stream1 () = Stream(1, stream1) stream_take :: int*stream -> int list stream_take(0,_) = Nil stream_take(n,Stream(i,f)) = Cons(i, stream_take(n-1, f())) Now there is no way to pass a different value like we did in weird_take; there's only (). The difference is that the state gets embedded in the closure for the thunk: stream_ints :: int -> (unit -> stream) stream_ints = fun n => fun () => Stream(n, stream_ints(n+1)) What you are doing here is encoding laziness; the Haskell version of this type: > data Stream = Stream !Int Stream -- !Int means the Int value is strict > stream1 = Stream 1 stream1 > stream_ints n = Stream n (stream_ints(n+1)) > stream_take :: Int -> Stream -> [Int] > stream_take 0 _ = [] > stream_take n (Stream x xs) = x : stream_take (n-1) xs No extra (\() -> ...) thunk is required, due to laziness :) -- ryan On Tue, May 19, 2009 at 4:25 PM, michael rice wrote: > Hi Ryan, > > I'm afraid you've lost me. Maybe if you showed how this would be used in ML > I would get the picture. > > Michael > > --- On Tue, 5/19/09, Ryan Ingram wrote: > > From: Ryan Ingram > Subject: Re: [Haskell-cafe] showing a user defined type > To: "michael rice" > Cc: "Brandon S. Allbery KF8NH" , > haskell-cafe@haskell.org > Date: Tuesday, May 19, 2009, 2:40 PM > > On Tue, May 19, 2009 at 7:07 AM, michael rice wrote: >> A little further along in "The Little MLer" the ints function is replaced >> by >> other functions like primes and fibs, which also return Links: >> >> fun primes(n) >> ? = if is_prime(n+1) >> ?then Link(n+1,primes) >> ?else primes(n+1) >> >> fun fibs(n)(m) >> ? = Link(n+m,fibs(m)) >> >> which are passed to chain_item: >> >> fun chain_item(n,Link(i,f)) >> ? = if eq_int(n,1) >> ? then i >> ? else chain_item(n-1,f(i)) >> >> which can be called to request the nth (12th) prime number beginning at 1. >> >> - chain_item(12,primes(1)); >> GC #0.0.0.1.3.61:?? (1 ms) >> val it = 37 : int >> - >> >> So I guess the answer to your question about whether the function is ever >> called with a different value may be, yes. > > Actually, it's not calling it with another value; notice that > chain_item calls f(i), with i coming directly from the chain. > Consider this alternate definition: > (I'm not sure the syntax is exactly right, but you get the idea) > > datatype chain = > ? Link of (int * ( unit -> chain )) > > fun intsFrom(n) = fun unit => (n, intsFrom (n+1)) > fun ints(n) = intsFrom n () > > Now you *can't* call the function embedded in the link with another value. > > fun chain_item(n,Link(i,f)) > ? = if eq_int(n,1) > ? then i > ? else chain_item(n-1,f unit) > > And this type for "chain" is almost the same as [Int] in Haskell, due > to laziness. > > ? -- ryan > > From david.waern at gmail.com Wed May 20 04:43:41 2009 From: david.waern at gmail.com (David Waern) Date: Wed May 20 04:28:22 2009 Subject: [Haskell-cafe] Problem with haddock importing definition In-Reply-To: <20090520075016.GA5108@soi.city.ac.uk> References: <20090520075016.GA5108@soi.city.ac.uk> Message-ID: 2009/5/20 Ross Paterson : > On Wed, May 20, 2009 at 09:42:19AM +0200, David Waern wrote: >> 2009/5/15 Maur?cio : >> > I have a situation like this: module A imports R (a newtype >> > declaration) from module B, and lists it in its (module A) >> > export list. >> > >> > Documentation for R is included by haddock in documentation >> > for module A, as I want. However, if my package exposes only >> > module A, documentation for R desapears. >> >> When you say documentation disappears, do you mean that R is still >> listed, but its comments are not shown, or is R completely absent from >> the documentation? > > See http://trac.haskell.org/haddock/ticket/107 > > He just needs to include B in the other-modules list, so that cabal will > pass it to haddock (and setup sdist). Yes, that is a solution that he can use. I would still like to know the answer to my question though, since I think we can improve Haddock here. Haddock is given a list of modules on the command line, for which it should create documentation pages. Before Haddock used GHC, it could not do dependency analysis, so you had to give it both the modules you wanted pages for, and their dependencies. Nowadays we do dependency analysis, since we have to typecheck all modules. But we still only do documentation-processing for the given modules (I think). This could explain why F appears in the documentation, but without comments, when only module A is specified on the command line (assuming this is indeed the problem). In that case we should enhance Haddock so that it processes all modules but only creates documentation pages for the specified modules. David From conor at strictlypositive.org Wed May 20 05:07:38 2009 From: conor at strictlypositive.org (Conor McBride) Date: Wed May 20 04:52:24 2009 Subject: [Haskell-cafe] Free theorems for dependent types? In-Reply-To: <5e0214850905192308y7432ccdtcd6b35c53b66912a@mail.gmail.com> References: <5e0214850905171210i22183345w99b6a395da234236@mail.gmail.com> <20090517204102.2fda2218@greenrd.org> <5e0214850905171248n563c0832r93f76dce83a1d9d3@mail.gmail.com> <5e0214850905192308y7432ccdtcd6b35c53b66912a@mail.gmail.com> Message-ID: Hi On 20 May 2009, at 07:08, Eugene Kirpichov wrote: > Thanks for the thorough response. > > I've found Barras&Bernardo's work (at least, slides) about ICC*, I'll > have a look at it. > Could you provide with names of works by Altenkirch/Morris/Oury/you? > The unordered pair example was especially interesting, since I am > somewhat concerned with which operations do not break parametricity > for *unordered sets* (as opposed to lists) - turns out, not too many. Unordered sets or bags? Both are interesting, but hiding multiplicity makes sets tricky. Anyway, the news on publications is not so good. There's a paper "Observational Equality, Now!" by Altenkirch, McB, Swierstra which describes more or less how we handle observational equalities in general, but the specific instantiation of that pattern to quotients is more recent. An older paper "Constructing Polymorphic Programs with Quotient Types" by Abbott, Altenkirch, McB, Ghani extends container theory to things which are fuzzy about position (bags, cycles, etc), so may have some relevance. One formulation of quotients in Epigram 2, by the aforementioned Altenkirch, Morris, McB, Oury, are sadly documented only by the source code of the implementation, which you can find here http://www.e-pig.org/darcs/epigram/src/Quotient.lhs if you're curious. We knocked that up in about half an hour one afternoon shortly before the money ran out. The basic idea is terribly simple. A quotient is an abstract type X/f wrapping a carrier set X which has a notion of normal form given by f : X -> Y, for some Y. (e.g. f might be even, and Y Bool, giving arithmetic modulo 2). Equality on X/f is just equality at Y of whatever f gives on the packed C values. You can almost unpack X/f freely, gaining access to the element of the carrier, applying any (possibly dependent) function g you like to it -- just as long as you can prove that forall x x'. f x == f x' -> g x == g x' Any such g on X readily lifts to X/f. This to design and redesign an interface of quotient-respecting functions and then work compositionally. Amusingly, under certain circumstances, the idea of quotient by an equivalence fits this picture: given R : X -> X -> Prop, just take Y, above, to be X -> Prop (a predicate describing an equivalence class; predicates are equal by mutual inclusion). That allows you permutative quotients which don't admit a more concrete normal form, like general unordered pairs. Of course, if you do have an order on the data, you can just take f to be sort! Sorry for lack of writings, for which this status dump is poor compensation. Things aren't very applied yet, but the machinery for restricting observation in exchange for guarantees is on its way. We'll see what the summer brings. All the best Conor From leledumbo_cool at yahoo.co.id Wed May 20 05:48:07 2009 From: leledumbo_cool at yahoo.co.id (leledumbo) Date: Wed May 20 05:32:47 2009 Subject: [Haskell-cafe] Expression parsing problem In-Reply-To: <6f9f8f4a0905190523k429d6522je227f2130e69385d@mail.gmail.com> References: <23610457.post@talk.nabble.com> <63AF3FEB-1553-4511-B848-6B0C538ED39E@cs.york.ac.uk> <23611617.post@talk.nabble.com> <6f9f8f4a0905190523k429d6522je227f2130e69385d@mail.gmail.com> Message-ID: <23632282.post@talk.nabble.com> Haha... yes, thanks. It was a mistake, I thought I did it too fast. -- View this message in context: http://www.nabble.com/Expression-parsing-problem-tp23610457p23632282.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From spoon at killersmurf.com Wed May 20 07:46:06 2009 From: spoon at killersmurf.com (spoon@killersmurf.com) Date: Wed May 20 07:30:42 2009 Subject: [Haskell-cafe] How i use GHC.Word.Word8 wit Int ? Message-ID: <20090520114606.GA7774@killersmurf.com> While just writing 33 instead of length [1..33] saves an awful lot of bother, the function you'd probably want in similar circumstances is `fromIntegral` See the Prelude. Also, you can use Data.ByteString.head instead of unpack and then Data.List.head rollDice :: Word8 -> IO Word8 rollDice n = do bracket (openFile "/dev/random" ReadMode) hClose (\hd -> do v <- fmap B.head $ B.hGet hd 1 return $ (v `mod` n) + 1) From lemming at henning-thielemann.de Wed May 20 09:12:14 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed May 20 08:57:15 2009 Subject: [Haskell-cafe] HaL4: Haskell-Treffen in Halle/Saale, 12. Juni 2009 - Programm und Anmeldung Message-ID: Kindly excuse the German noise, please ... Liebe Haskell-Freunde! Das Programm fuer unser Haskell-Treffen steht jetzt so gut wie fest und man kann sich online anmelden. --------------------------------------------- HaL4 : Haskell - Tutorial + Workshop + Party am Freitag, dem 12. Juni 2009, in Halle/Saale --------------------------------------------- Das traditionsreiche HaL-Treffen bietet eine gute Mischung von Haskell-bezogenen Themen aus Forschung, Anwendung und Lehre mit vielen M?glichkeiten zu Diskussion und Unterhaltung bei der anschlie?enden Party. Der Workshop wird in diesem Jahr erg?nzt durch Tutorien f?r Haskell-Ein- und Umsteiger. Diesmal findet das Treffen in Halle/Saale im Institut f?r Informatik der Martin-Luther-Universit?t Halle-Wittenberg statt. Wir bieten: 10 Uhr: Entwurfsmuster vom Kopf auf die Fuesse gestellt: data, fold und laziness statt Kompositum, Visitor, Iterator. Johannes Waldmann, HTWK Leipzig. 11 Uhr: CAL/openquark: (openquark.org) Haskell + Java => CAL, eine praktische Einfuehrung (Eclipse als CAL-IDE, Excel lesen, typsicheres SQL = LINQ fuer Java?) Alf Richter, iba Consulting, Leipzig 12 Uhr: Wie man das Semikolon ueberlaedt: Code-Strukturierung und -Wiederverwendung durch Monaden 15 Uhr: Hayoo! Haskell API Search Timo Huebel, FH Wedel 16 Uhr: Haskell als reine Spezifikationssprache Baltasar Trancon y Widemann, Universit Bayreuth 17 Uhr: Funktional-logische Programmierung mit Curry Jan Christiansen, Universitaet Kiel 19 - 22 Uhr: Grillparty Wir freuen uns auf rege Teilnahme sowie spannende Vortr?ge mit hei?en Diskussionen und bitten um Anmeldung bis zum 31. Mai. Weitere Informationen auf ?http://www.iba-cg.de/hal4.html Beste Gruesse Henning Thielemann From briqueabraque at yahoo.com Wed May 20 09:25:08 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=EDcio?=) Date: Wed May 20 09:10:09 2009 Subject: [Haskell-cafe] Re: Problem with haddock importing definition In-Reply-To: References: <20090520075016.GA5108@soi.city.ac.uk> Message-ID: >>> When you say documentation disappears, do you mean that R is still >>> listed, but its comments are not shown, or is R completely absent from >>> the documentation? >> See http://trac.haskell.org/haddock/ticket/107 >> He just needs to include B in the other-modules list, so that cabal will >> pass it to haddock (and setup sdist). > I would still like to know the answer to my question though, since I > think we can improve Haddock here. R is completely absent from documentation. I did include a working example with .cabal file in that ticket, maybe that can help. (Just to note, my problem was solved by 'other-modules'.) Thanks, Maur?cio From asandroq at gmail.com Wed May 20 09:56:25 2009 From: asandroq at gmail.com (Alex Queiroz) Date: Wed May 20 09:41:07 2009 Subject: =?UTF-8?Q?Re=3A_=5BHaskell=2Dcafe=5D_Haskell_programmers_in_S=C3=A3o_Carlo?= =?UTF-8?Q?s_=2D_SP_=2D_Brazil=3F?= In-Reply-To: <20090520020754.GA4007@mephisto.bitforest.org> References: <20090520020754.GA4007@mephisto.bitforest.org> Message-ID: <54e12800905200656p7f50e0f1i7a223e430a3fd6bd@mail.gmail.com> Hallo, On 5/20/09, Diego Souza wrote: > Not exactly S?o Carlos: S?o Paulo - SP. > Me too, Sao Paulo - SP. Cheers, -- -alex http://www.ventonegro.org/ From david.waern at gmail.com Wed May 20 10:04:38 2009 From: david.waern at gmail.com (David Waern) Date: Wed May 20 09:49:19 2009 Subject: [Haskell-cafe] Re: Problem with haddock importing definition In-Reply-To: References: <20090520075016.GA5108@soi.city.ac.uk> Message-ID: 2009/5/20 Maur?cio : >> I would still like to know the answer to my question though, since I >> think we can improve Haddock here. > > R is completely absent from documentation. OK. That's strange. I thought that Haddock would at least show R but without a link. > I did include a working example with .cabal > file in that ticket, maybe that can help. > > (Just to note, my problem was solved by > 'other-modules'.) I saw that - thanks. Couldn't investigate it yet since I'm at work :-) David From nowgate at yahoo.com Wed May 20 12:41:24 2009 From: nowgate at yahoo.com (michael rice) Date: Wed May 20 12:26:04 2009 Subject: [Haskell-cafe] showing a user defined type Message-ID: <692679.84259.qm@web31107.mail.mud.yahoo.com> OK, I think I understand. You were explaining how ML could be made to emulate Haskell laziness using streams, ala Scheme type delayed evaluation, so it's kind of like you were explaining a question I hadn't quite asked yet, which maybe explains my puzzlement, I hope. Also, though my understanding of both Haskell and ML syntax is still rudimentary, I did catch an error in your definition of chain_take: the first arg of the cons should be i rather than n. I'm still going through your code and may have further questions. Thanks for your input. Michael --- On Wed, 5/20/09, Ryan Ingram wrote: From: Ryan Ingram Subject: Re: [Haskell-cafe] showing a user defined type To: "michael rice" Cc: "Brandon S. Allbery KF8NH" , haskell-cafe@haskell.org Date: Wednesday, May 20, 2009, 4:12 AM (Apologies for my mutilation of ML syntax, I don't completely know the language) Consider the ML type int list, and this function to build one: broken_repeat :: int -> int list broken_repeat n = Cons(n, broken_repeat(n)) This function is recursive, and doesn't terminate; it tries to build an infinite list of ints and your computer runs out of heap and/or stack trying to evaluate it. But the "chain" type doesn't have this problem; you can see it as an int list that gets evaluated "on demand": repeat :: int -> chain repeat(n) = Link(n, repeat) always1 :: int -> chain always1(_) = Link(1, always1) chain_take :: int * chain -> int list chain_take (0,_) = Nil chain_take (n,Link(i,f)) = Cons(n, chain_take(n-1, f(i))) But, nothing in the "chain" type stops you from passing a different value to the function in the link: weird_take :: int * int * chain -> int list weird_take (0,_,_) = Nil weird_take (n,v,Link(i,f)) = Cons(i, weird_take(n-1,v,f(v))) Now, it's possible that chain_take returns the same list for two different "chain" inputs, but weird_take might return different lists depending on how f is implemented.? For example: ? ? chain_take(5, repeat(1)) = [1,1,1,1,1] ? ? chain_take(5, always1(1) = [1,1,1,1,1] ? ? weird_take(5, 2, repeat(1)) = [1,2,2,2,2] ? ? weird_take(5, 2, always1(1)) = [1,1,1,1,1] One way to fix this is to embed the "state" of the chain in the closure itself. So, in ML, the type ???unit -> X is commonly called a "thunk"; it can be used to delay computation until later, until it's demanded, just like any lazy value in Haskell. f :: unit -> Int f () = 1 This f isn't very useful; it's basically the same as "1".? But consider this type: datatype stream = Stream of (int * (unit -> stream)) stream1 () = Stream(1, stream1) stream_take :: int*stream -> int list stream_take(0,_) = Nil stream_take(n,Stream(i,f)) = Cons(i, stream_take(n-1, f())) Now there is no way to pass a different value like we did in weird_take; there's only (). The difference is that the state gets embedded in the closure for the thunk: stream_ints :: int -> (unit -> stream) stream_ints = fun n => fun () => Stream(n, stream_ints(n+1)) What you are doing here is encoding laziness; the Haskell version of this type: > data Stream = Stream !Int Stream -- !Int means the Int value is strict > stream1 = Stream 1 stream1 > stream_ints n = Stream n (stream_ints(n+1)) > stream_take :: Int -> Stream -> [Int] > stream_take 0 _ = [] > stream_take n (Stream x xs) = x : stream_take (n-1) xs No extra (\() -> ...) thunk is required, due to laziness :) ? -- ryan On Tue, May 19, 2009 at 4:25 PM, michael rice wrote: > Hi Ryan, > > I'm afraid you've lost me. Maybe if you showed how this would be used in ML > I would get the picture. > > Michael > > --- On Tue, 5/19/09, Ryan Ingram wrote: > > From: Ryan Ingram > Subject: Re: [Haskell-cafe] showing a user defined type > To: "michael rice" > Cc: "Brandon S. Allbery KF8NH" , > haskell-cafe@haskell.org > Date: Tuesday, May 19, 2009, 2:40 PM > > On Tue, May 19, 2009 at 7:07 AM, michael rice wrote: >> A little further along in "The Little MLer" the ints function is replaced >> by >> other functions like primes and fibs, which also return Links: >> >> fun primes(n) >> ? = if is_prime(n+1) >> ?then Link(n+1,primes) >> ?else primes(n+1) >> >> fun fibs(n)(m) >> ? = Link(n+m,fibs(m)) >> >> which are passed to chain_item: >> >> fun chain_item(n,Link(i,f)) >> ? = if eq_int(n,1) >> ? then i >> ? else chain_item(n-1,f(i)) >> >> which can be called to request the nth (12th) prime number beginning at 1. >> >> - chain_item(12,primes(1)); >> GC #0.0.0.1.3.61:?? (1 ms) >> val it = 37 : int >> - >> >> So I guess the answer to your question about whether the function is ever >> called with a different value may be, yes. > > Actually, it's not calling it with another value; notice that > chain_item calls f(i), with i coming directly from the chain. > Consider this alternate definition: > (I'm not sure the syntax is exactly right, but you get the idea) > > datatype chain = > ? Link of (int * ( unit -> chain )) > > fun intsFrom(n) = fun unit => (n, intsFrom (n+1)) > fun ints(n) = intsFrom n () > > Now you *can't* call the function embedded in the link with another value. > > fun chain_item(n,Link(i,f)) > ? = if eq_int(n,1) > ? then i > ? else chain_item(n-1,f unit) > > And this type for "chain" is almost the same as [Int] in Haskell, due > to laziness. > > ? -- ryan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090520/4469f579/attachment.html From dave at zednenem.com Wed May 20 13:47:30 2009 From: dave at zednenem.com (David Menendez) Date: Wed May 20 13:32:08 2009 Subject: [Haskell-cafe] Free theorems for dependent types? In-Reply-To: <2f9b2d30905172052s3f4402d2v113d44ae65c3bdc7@mail.gmail.com> References: <5e0214850905171210i22183345w99b6a395da234236@mail.gmail.com> <4A10CD3A.2090806@gmail.com> <2f9b2d30905172052s3f4402d2v113d44ae65c3bdc7@mail.gmail.com> Message-ID: <49a77b7a0905201047o3c4705b2ne299c37e4114317a@mail.gmail.com> On Sun, May 17, 2009 at 11:52 PM, Ryan Ingram wrote: > Free theorem's are theorems about functions that rely only on parametricity. > > For example, consider any function f with the type > ? forall a. a -> a > > >From its type, I can tell you directly that this theorem holds: > ?forall g :: A -> B, x :: A, > ? ? ?f (g ?x) = g (f x) > > (Note that the f on the left is B -> B, the f on the right is A -> A). Note also that the theorem only holds in a strict language (i.e., not Haskell). data A = A deriving Show data B = B deriving Show f :: a -> a f = const undefined g :: A -> B g = const B *Main> f (g A) *** Exception: Prelude.undefined *Main> g (f A) B -- Dave Menendez From ekirpichov at gmail.com Wed May 20 13:49:40 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Wed May 20 13:34:20 2009 Subject: [Haskell-cafe] Free theorems for dependent types? In-Reply-To: <49a77b7a0905201047o3c4705b2ne299c37e4114317a@mail.gmail.com> References: <5e0214850905171210i22183345w99b6a395da234236@mail.gmail.com> <4A10CD3A.2090806@gmail.com> <2f9b2d30905172052s3f4402d2v113d44ae65c3bdc7@mail.gmail.com> <49a77b7a0905201047o3c4705b2ne299c37e4114317a@mail.gmail.com> Message-ID: <5e0214850905201049q3132d11cp12c8de9c24da096f@mail.gmail.com> Or in a language without bottoms. 2009/5/20 David Menendez : > On Sun, May 17, 2009 at 11:52 PM, Ryan Ingram wrote: >> Free theorem's are theorems about functions that rely only on parametricity. >> >> For example, consider any function f with the type >> ? forall a. a -> a >> >> >From its type, I can tell you directly that this theorem holds: >> ?forall g :: A -> B, x :: A, >> ? ? ?f (g ?x) = g (f x) >> >> (Note that the f on the left is B -> B, the f on the right is A -> A). > > Note also that the theorem only holds in a strict language (i.e., not Haskell). > > data A = A deriving Show > data B = B deriving Show > > f :: a -> a > f = const undefined > > g :: A -> B > g = const B > > *Main> f (g A) > *** Exception: Prelude.undefined > *Main> g (f A) > B > > -- > Dave Menendez > > _______________________________________________ > 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 ryani.spam at gmail.com Wed May 20 14:21:44 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed May 20 14:06:48 2009 Subject: [Haskell-cafe] showing a user defined type In-Reply-To: <692679.84259.qm@web31107.mail.mud.yahoo.com> References: <692679.84259.qm@web31107.mail.mud.yahoo.com> Message-ID: <2f9b2d30905201121h7c015db0q3c3a377c13cb3b56@mail.gmail.com> Actually, I was saying that "chain" already emulates laziness, just in a somewhat unsafe way, as demonstrated by weird_take. In Haskell you'd probably just write > ints :: Int -> [Int] > ints n = [n..] and be done with it. -- ryan On Wed, May 20, 2009 at 9:41 AM, michael rice wrote: > OK, I think I understand. You were explaining how ML could be made to > emulate Haskell laziness using streams, ala Scheme type delayed evaluation, > so it's kind of like you were explaining a question I hadn't quite asked > yet, which maybe explains my puzzlement, I hope. > > Also, though my understanding of both Haskell and ML syntax is still > rudimentary, I did catch an error in your definition of chain_take: the > first arg of the cons should be i rather than n. > > I'm still going through your code and may have further questions. > > Thanks for your input. > > Michael > > > --- On Wed, 5/20/09, Ryan Ingram wrote: > > From: Ryan Ingram > Subject: Re: [Haskell-cafe] showing a user defined type > To: "michael rice" > Cc: "Brandon S. Allbery KF8NH" , > haskell-cafe@haskell.org > Date: Wednesday, May 20, 2009, 4:12 AM > > (Apologies for my mutilation of ML syntax, I don't completely know the > language) > > Consider the ML type int list, and this function to build one: > > broken_repeat :: int -> int list > broken_repeat n = Cons(n, broken_repeat(n)) > > This function is recursive, and doesn't terminate; it tries to build > an infinite list of ints and your computer runs out of heap and/or > stack trying to evaluate it. > > But the "chain" type doesn't have this problem; you can see it as an > int list that gets evaluated "on demand": > > repeat :: int -> chain > repeat(n) = Link(n, repeat) > > always1 :: int -> chain > always1(_) = Link(1, always1) > > chain_take :: int * chain -> int list > chain_take (0,_) = Nil > chain_take (n,Link(i,f)) = Cons(n, chain_take(n-1, f(i))) > > But, nothing in the "chain" type stops you from passing a different > value to the function in the link: > > weird_take :: int * int * chain -> int list > weird_take (0,_,_) = Nil > weird_take (n,v,Link(i,f)) = Cons(i, weird_take(n-1,v,f(v))) > > Now, it's possible that chain_take returns the same list for two > different "chain" inputs, but weird_take might return different lists > depending on how f is implemented.? For example: > ? ? chain_take(5, repeat(1)) = [1,1,1,1,1] > ? ? chain_take(5, always1(1) = [1,1,1,1,1] > > ? ? weird_take(5, 2, repeat(1)) = [1,2,2,2,2] > ? ? weird_take(5, 2, always1(1)) = [1,1,1,1,1] > > One way to fix this is to embed the "state" of the chain in the closure > itself. > > So, in ML, the type > ???unit -> X > is commonly called a "thunk"; it can be used to delay computation > until later, until it's demanded, just like any lazy value in Haskell. > > f :: unit -> Int > f () = 1 > > This f isn't very useful; it's basically the same as "1".? But > consider this type: > > datatype stream = Stream of (int * (unit -> stream)) > > stream1 () = Stream(1, stream1) > > stream_take :: int*stream -> int list > stream_take(0,_) = Nil > stream_take(n,Stream(i,f)) = Cons(i, stream_take(n-1, f())) > > Now there is no way to pass a different value like we did in > weird_take; there's only (). > > The difference is that the state gets embedded in the closure for the thunk: > > stream_ints :: int -> (unit -> stream) > stream_ints = fun n => fun () => Stream(n, stream_ints(n+1)) > > What you are doing here is encoding laziness; the Haskell version of this > type: > >> data Stream = Stream !Int Stream -- !Int means the Int value is strict >> stream1 = Stream 1 stream1 >> stream_ints n = Stream n (stream_ints(n+1)) > >> stream_take :: Int -> Stream -> [Int] >> stream_take 0 _ = [] >> stream_take n (Stream x xs) = x : stream_take (n-1) xs > > No extra (\() -> ...) thunk is required, due to laziness :) > > ? -- ryan > > On Tue, May 19, 2009 at 4:25 PM, michael rice wrote: >> Hi Ryan, >> >> I'm afraid you've lost me. Maybe if you showed how this would be used in >> ML >> I would get the picture. >> >> Michael >> >> --- On Tue, 5/19/09, Ryan Ingram wrote: >> >> From: Ryan Ingram >> Subject: Re: [Haskell-cafe] showing a user defined type >> To: "michael rice" >> Cc: "Brandon S. Allbery KF8NH" , >> haskell-cafe@haskell.org >> Date: Tuesday, May 19, 2009, 2:40 PM >> >> On Tue, May 19, 2009 at 7:07 AM, michael rice wrote: >>> A little further along in "The Little MLer" the ints function is replaced >>> by >>> other functions like primes and fibs, which also return Links: >>> >>> fun primes(n) >>> ? = if is_prime(n+1) >>> ?then Link(n+1,primes) >>> ?else primes(n+1) >>> >>> fun fibs(n)(m) >>> ? = Link(n+m,fibs(m)) >>> >>> which are passed to chain_item: >>> >>> fun chain_item(n,Link(i,f)) >>> ? = if eq_int(n,1) >>> ? then i >>> ? else chain_item(n-1,f(i)) >>> >>> which can be called to request the nth (12th) prime number beginning at >>> 1. >>> >>> - chain_item(12,primes(1)); >>> GC #0.0.0.1.3.61:?? (1 ms) >>> val it = 37 : int >>> - >>> >>> So I guess the answer to your question about whether the function is ever >>> called with a different value may be, yes. >> >> Actually, it's not calling it with another value; notice that >> chain_item calls f(i), with i coming directly from the chain. >> Consider this alternate definition: >> (I'm not sure the syntax is exactly right, but you get the idea) >> >> datatype chain = >> ? Link of (int * ( unit -> chain )) >> >> fun intsFrom(n) = fun unit => (n, intsFrom (n+1)) >> fun ints(n) = intsFrom n () >> >> Now you *can't* call the function embedded in the link with another value. >> >> fun chain_item(n,Link(i,f)) >> ? = if eq_int(n,1) >> ? then i >> ? else chain_item(n-1,f unit) >> >> And this type for "chain" is almost the same as [Int] in Haskell, due >> to laziness. >> >> ? -- ryan >> >> > > From mg.eastman at gmail.com Wed May 20 15:03:21 2009 From: mg.eastman at gmail.com (Matthew Eastman) Date: Wed May 20 14:48:00 2009 Subject: [Haskell-cafe] Re: Tree traversal / stack overflow In-Reply-To: <236D329B-E3E0-4D5B-83A0-972D596B839A@gmail.com> References: <236D329B-E3E0-4D5B-83A0-972D596B839A@gmail.com> Message-ID: <0C89E19A-5C02-4961-8BFB-92189374C03D@gmail.com> Turns out I was building the trees wrong, ended up getting a structure that looked like a linked list (each tree only had 1 child) so the depth of the recursion was way higher than it should've been. Crisis averted! Still seemed odd that the garbage collector ran for so much of the time, so I checked and there's a ticket in GHC trac about it: http://hackage.haskell.org/trac/ghc/ticket/2236 . On 20-May-09, at 12:02 AM, Matthew Eastman wrote: > ... > > The code I have right now works great on point sets of size ~10,000, > but when I go up much higher things start to go wrong. I start > hitting stack overflows, so I increased the stack size. For ~100,000 > points though, running the code with +RTS -sstderr -K128m it chugged > along for over an hour and then died with a stack overflow. The > stats said it spent 50 seconds MUT time and 5300 seconds (almost 90 > minutes!) GC time, which seems odd. > > ... From mpm at alumni.caltech.edu Wed May 20 18:54:58 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Wed May 20 18:39:58 2009 Subject: [Haskell-cafe] the problem of design by negation Message-ID: <4A148A42.9030205@alumni.caltech.edu> This is not directly related to Haskell, but it's a thought that occurred to me after exposure to the Haskell community. I've spent most of the past 15 years doing scientific programming. The lead software architect and software managers are using good software engineering practice, though (this is *scientific* programming, not *programming by scientists*, ha ha). But, there is a particular culture in my company that has become more obvious to me by contrast to the Haskell community. I call it "design by negation." When asked to justify his design, the lead software architect explains everything that *wouldn't* work. "We couldn't have a unique key for every entry because blah blah blah. We couldn't use a garbage collector because blah blah. We couldn't write a sugar layer because then you have to document it separately blah blah." So the chosen design seems to be the only thing left after eliminating everything you can't do. I want to aspire to "positive design." I want to list the goals, and think of design as making clever choices that meet all the goals. I don't mean to suggest that design is never constrained. It often is. But it's a mindset I'm talking about. I don't like this mindset of design by negation. -Mike From garious at gmail.com Wed May 20 20:13:15 2009 From: garious at gmail.com (Greg Fitzgerald) Date: Wed May 20 19:58:14 2009 Subject: [Haskell-cafe] the problem of design by negation In-Reply-To: <4A148A42.9030205@alumni.caltech.edu> References: <4A148A42.9030205@alumni.caltech.edu> Message-ID: <1f3dc80d0905201713k1fd77b66kb7bafa5873d21380@mail.gmail.com> On Wed, May 20, 2009 at 3:54 PM, Michael Mossey wrote: > I want to aspire to "positive design." I want to list the goals, and think > of design as making clever choices that meet all the goals. Design by Thomas the Tank Engine? From nowgate at yahoo.com Wed May 20 21:34:07 2009 From: nowgate at yahoo.com (michael rice) Date: Wed May 20 21:18:46 2009 Subject: [Haskell-cafe] showing a user defined type Message-ID: <507847.13485.qm@web31108.mail.mud.yahoo.com> Thanks for the extra patience. What does "unsafe" mean? From my perspective, you had a perfectly good chain_take function fun chain_take(0,_) = nil |?? chain_take(n,Link(i,f)) = i :: chain_take(n-1,f(i)) - chain_take(5,always1(6)); val it = [1,1,1,1,1] : int list Putting aside weird_chain_take for now, what, if anything, is unsafe about chain_take? Michael --- On Wed, 5/20/09, Ryan Ingram wrote: From: Ryan Ingram Subject: Re: [Haskell-cafe] showing a user defined type To: "michael rice" Cc: "Brandon S. Allbery KF8NH" , haskell-cafe@haskell.org Date: Wednesday, May 20, 2009, 2:21 PM Actually, I was saying that "chain" already emulates laziness, just in a somewhat unsafe way, as demonstrated by weird_take.? In Haskell you'd probably just write > ints :: Int -> [Int] > ints n = [n..] and be done with it. ? -- ryan On Wed, May 20, 2009 at 9:41 AM, michael rice wrote: > OK, I think I understand. You were explaining how ML could be made to > emulate Haskell laziness using streams, ala Scheme type delayed evaluation, > so it's kind of like you were explaining a question I hadn't quite asked > yet, which maybe explains my puzzlement, I hope. > > Also, though my understanding of both Haskell and ML syntax is still > rudimentary, I did catch an error in your definition of chain_take: the > first arg of the cons should be i rather than n. > > I'm still going through your code and may have further questions. > > Thanks for your input. > > Michael > > > --- On Wed, 5/20/09, Ryan Ingram wrote: > > From: Ryan Ingram > Subject: Re: [Haskell-cafe] showing a user defined type > To: "michael rice" > Cc: "Brandon S. Allbery KF8NH" , > haskell-cafe@haskell.org > Date: Wednesday, May 20, 2009, 4:12 AM > > (Apologies for my mutilation of ML syntax, I don't completely know the > language) > > Consider the ML type int list, and this function to build one: > > broken_repeat :: int -> int list > broken_repeat n = Cons(n, broken_repeat(n)) > > This function is recursive, and doesn't terminate; it tries to build > an infinite list of ints and your computer runs out of heap and/or > stack trying to evaluate it. > > But the "chain" type doesn't have this problem; you can see it as an > int list that gets evaluated "on demand": > > repeat :: int -> chain > repeat(n) = Link(n, repeat) > > always1 :: int -> chain > always1(_) = Link(1, always1) > > chain_take :: int * chain -> int list > chain_take (0,_) = Nil > chain_take (n,Link(i,f)) = Cons(n, chain_take(n-1, f(i))) > > But, nothing in the "chain" type stops you from passing a different > value to the function in the link: > > weird_take :: int * int * chain -> int list > weird_take (0,_,_) = Nil > weird_take (n,v,Link(i,f)) = Cons(i, weird_take(n-1,v,f(v))) > > Now, it's possible that chain_take returns the same list for two > different "chain" inputs, but weird_take might return different lists > depending on how f is implemented.? For example: > ? ? chain_take(5, repeat(1)) = [1,1,1,1,1] > ? ? chain_take(5, always1(1) = [1,1,1,1,1] > > ? ? weird_take(5, 2, repeat(1)) = [1,2,2,2,2] > ? ? weird_take(5, 2, always1(1)) = [1,1,1,1,1] > > One way to fix this is to embed the "state" of the chain in the closure > itself. > > So, in ML, the type > ???unit -> X > is commonly called a "thunk"; it can be used to delay computation > until later, until it's demanded, just like any lazy value in Haskell. > > f :: unit -> Int > f () = 1 > > This f isn't very useful; it's basically the same as "1".? But > consider this type: > > datatype stream = Stream of (int * (unit -> stream)) > > stream1 () = Stream(1, stream1) > > stream_take :: int*stream -> int list > stream_take(0,_) = Nil > stream_take(n,Stream(i,f)) = Cons(i, stream_take(n-1, f())) > > Now there is no way to pass a different value like we did in > weird_take; there's only (). > > The difference is that the state gets embedded in the closure for the thunk: > > stream_ints :: int -> (unit -> stream) > stream_ints = fun n => fun () => Stream(n, stream_ints(n+1)) > > What you are doing here is encoding laziness; the Haskell version of this > type: > >> data Stream = Stream !Int Stream -- !Int means the Int value is strict >> stream1 = Stream 1 stream1 >> stream_ints n = Stream n (stream_ints(n+1)) > >> stream_take :: Int -> Stream -> [Int] >> stream_take 0 _ = [] >> stream_take n (Stream x xs) = x : stream_take (n-1) xs > > No extra (\() -> ...) thunk is required, due to laziness :) > > ? -- ryan > > On Tue, May 19, 2009 at 4:25 PM, michael rice wrote: >> Hi Ryan, >> >> I'm afraid you've lost me. Maybe if you showed how this would be used in >> ML >> I would get the picture. >> >> Michael >> >> --- On Tue, 5/19/09, Ryan Ingram wrote: >> >> From: Ryan Ingram >> Subject: Re: [Haskell-cafe] showing a user defined type >> To: "michael rice" >> Cc: "Brandon S. Allbery KF8NH" , >> haskell-cafe@haskell.org >> Date: Tuesday, May 19, 2009, 2:40 PM >> >> On Tue, May 19, 2009 at 7:07 AM, michael rice wrote: >>> A little further along in "The Little MLer" the ints function is replaced >>> by >>> other functions like primes and fibs, which also return Links: >>> >>> fun primes(n) >>> ? = if is_prime(n+1) >>> ?then Link(n+1,primes) >>> ?else primes(n+1) >>> >>> fun fibs(n)(m) >>> ? = Link(n+m,fibs(m)) >>> >>> which are passed to chain_item: >>> >>> fun chain_item(n,Link(i,f)) >>> ? = if eq_int(n,1) >>> ? then i >>> ? else chain_item(n-1,f(i)) >>> >>> which can be called to request the nth (12th) prime number beginning at >>> 1. >>> >>> - chain_item(12,primes(1)); >>> GC #0.0.0.1.3.61:?? (1 ms) >>> val it = 37 : int >>> - >>> >>> So I guess the answer to your question about whether the function is ever >>> called with a different value may be, yes. >> >> Actually, it's not calling it with another value; notice that >> chain_item calls f(i), with i coming directly from the chain. >> Consider this alternate definition: >> (I'm not sure the syntax is exactly right, but you get the idea) >> >> datatype chain = >> ? Link of (int * ( unit -> chain )) >> >> fun intsFrom(n) = fun unit => (n, intsFrom (n+1)) >> fun ints(n) = intsFrom n () >> >> Now you *can't* call the function embedded in the link with another value. >> >> fun chain_item(n,Link(i,f)) >> ? = if eq_int(n,1) >> ? then i >> ? else chain_item(n-1,f unit) >> >> And this type for "chain" is almost the same as [Int] in Haskell, due >> to laziness. >> >> ? -- ryan >> >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090520/37bf6592/attachment.html From ryani.spam at gmail.com Thu May 21 01:14:06 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu May 21 00:58:44 2009 Subject: [Haskell-cafe] showing a user defined type In-Reply-To: <507847.13485.qm@web31108.mail.mud.yahoo.com> References: <507847.13485.qm@web31108.mail.mud.yahoo.com> Message-ID: <2f9b2d30905202214l5686683cwaebb763a20f3d9f9@mail.gmail.com> The "unsafe" is that it's possible to write weird_chain_take; nothing is wrong with chain_take, the unsafeness is that the data structure admits things that aren't really chains based on passing odd arguments to "f". That said, my "Stream" definition wastes time constructing thunks; building closures isn't free. The Haskell stream fusion library solves this problem like this: data Step s a = Yield a s | Skip s | Done data Stream a = forall s. MkStream !s (s -> Step s a) -- "s" is hidden by the forall, the type of the constructor: -- MkStream :: forall a s. s -> (s -> Step s a) -> Stream a Now, the function inside the stream is packaged with an existential "state" type which is opaque from outside the stream: stream_view :: Stream a -> Maybe (a, Stream a) stream_view (MkStream st next) = case next st of Done -> Nothing Skip new_st -> stream_view (MkStream new_st next) Yield a new_st -> Just (a, MkStream new_st next) Notice that you no longer have to construct function closures: the "advance" function stays the same: ints_stream :: Int -> Stream Int ints_stream n0 = Stream n0 (\n -> Yield n (n+1)) The state type in ints_stream is still Int, but there's no way to make use of that information to "leak" the state representation. Pretty cool! :) A side discussion: why Skip? Consider implementing filter on streams without Skip: broken_filter_stream :: (a -> Bool) -> Stream a -> Stream a broken_filter_stream p (MkStream st next) = MkStream st go where go st = case next st of Done -> Done Yield a new_st -> if (p a) then (Yield a new_st) else (go new_st) But this version is recursive. It turns out if you can make all your stream functions non-recursive, the optimizer can do some crazy awesome things with them that it can't do on recursive versions. With Skip, it's easy to solve this problem: filter_stream :: (a -> Bool) -> Stream a -> Stream a filter_stream p (MkStream st next) = MkStream st go where go st = case next st of Done -> Done Skip new_st -> Skip new_st Yield a new_st -> if (p a) then (Yield a new_st) else (Skip new_st) -- ryan On Wed, May 20, 2009 at 6:34 PM, michael rice wrote: > Thanks for the extra patience. > > What does "unsafe" mean? From my perspective, you had a perfectly good > chain_take function > > fun chain_take(0,_) = nil > |?? chain_take(n,Link(i,f)) = i :: chain_take(n-1,f(i)) > > - chain_take(5,always1(6)); > val it = [1,1,1,1,1] : int list > > Putting aside weird_chain_take for now, what, if anything, is unsafe about > chain_take? > > Michael > > --- On Wed, 5/20/09, Ryan Ingram wrote: > > From: Ryan Ingram > Subject: Re: [Haskell-cafe] showing a user defined type > To: "michael rice" > Cc: "Brandon S. Allbery KF8NH" , > haskell-cafe@haskell.org > Date: Wednesday, May 20, 2009, 2:21 PM > > Actually, I was saying that "chain" already emulates laziness, just in > a somewhat unsafe way, as demonstrated by weird_take.? In Haskell > you'd probably just write > >> ints :: Int -> [Int] >> ints n = [n..] > > and be done with it. > > ? -- ryan > > On Wed, May 20, 2009 at 9:41 AM, michael rice wrote: >> OK, I think I understand. You were explaining how ML could be made to >> emulate Haskell laziness using streams, ala Scheme type delayed >> evaluation, >> so it's kind of like you were explaining a question I hadn't quite asked >> yet, which maybe explains my puzzlement, I hope. >> >> Also, though my understanding of both Haskell and ML syntax is still >> rudimentary, I did catch an error in your definition of chain_take: the >> first arg of the cons should be i rather than n. >> >> I'm still going through your code and may have further questions. >> >> Thanks for your input. >> >> Michael >> >> >> --- On Wed, 5/20/09, Ryan Ingram wrote: >> >> From: Ryan Ingram >> Subject: Re: [Haskell-cafe] showing a user defined type >> To: "michael rice" >> Cc: "Brandon S. Allbery KF8NH" , >> haskell-cafe@haskell.org >> Date: Wednesday, May 20, 2009, 4:12 AM >> >> (Apologies for my mutilation of ML syntax, I don't completely know the >> language) >> >> Consider the ML type int list, and this function to build one: >> >> broken_repeat :: int -> int list >> broken_repeat n = Cons(n, broken_repeat(n)) >> >> This function is recursive, and doesn't terminate; it tries to build >> an infinite list of ints and your computer runs out of heap and/or >> stack trying to evaluate it. >> >> But the "chain" type doesn't have this problem; you can see it as an >> int list that gets evaluated "on demand": >> >> repeat :: int -> chain >> repeat(n) = Link(n, repeat) >> >> always1 :: int -> chain >> always1(_) = Link(1, always1) >> >> chain_take :: int * chain -> int list >> chain_take (0,_) = Nil >> chain_take (n,Link(i,f)) = Cons(n, chain_take(n-1, f(i))) >> >> But, nothing in the "chain" type stops you from passing a different >> value to the function in the link: >> >> weird_take :: int * int * chain -> int list >> weird_take (0,_,_) = Nil >> weird_take (n,v,Link(i,f)) = Cons(i, weird_take(n-1,v,f(v))) >> >> Now, it's possible that chain_take returns the same list for two >> different "chain" inputs, but weird_take might return different lists >> depending on how f is implemented.? For example: >> ? ? chain_take(5, repeat(1)) = [1,1,1,1,1] >> ? ? chain_take(5, always1(1) = [1,1,1,1,1] >> >> ? ? weird_take(5, 2, repeat(1)) = [1,2,2,2,2] >> ? ? weird_take(5, 2, always1(1)) = [1,1,1,1,1] >> >> One way to fix this is to embed the "state" of the chain in the closure >> itself. >> >> So, in ML, the type >> ???unit -> X >> is commonly called a "thunk"; it can be used to delay computation >> until later, until it's demanded, just like any lazy value in Haskell. >> >> f :: unit -> Int >> f () = 1 >> >> This f isn't very useful; it's basically the same as "1".? But >> consider this type: >> >> datatype stream = Stream of (int * (unit -> stream)) >> >> stream1 () = Stream(1, stream1) >> >> stream_take :: int*stream -> int list >> stream_take(0,_) = Nil >> stream_take(n,Stream(i,f)) = Cons(i, stream_take(n-1, f())) >> >> Now there is no way to pass a different value like we did in >> weird_take; there's only (). >> >> The difference is that the state gets embedded in the closure for the >> thunk: >> >> stream_ints :: int -> (unit -> stream) >> stream_ints = fun n => fun () => Stream(n, stream_ints(n+1)) >> >> What you are doing here is encoding laziness; the Haskell version of this >> type: >> >>> data Stream = Stream !Int Stream -- !Int means the Int value is strict >>> stream1 = Stream 1 stream1 >>> stream_ints n = Stream n (stream_ints(n+1)) >> >>> stream_take :: Int -> Stream -> [Int] >>> stream_take 0 _ = [] >>> stream_take n (Stream x xs) = x : stream_take (n-1) xs >> >> No extra (\() -> ...) thunk is required, due to laziness :) >> >> ? -- ryan >> >> On Tue, May 19, 2009 at 4:25 PM, michael rice wrote: >>> Hi Ryan, >>> >>> I'm afraid you've lost me. Maybe if you showed how this would be used in >>> ML >>> I would get the picture. >>> >>> Michael >>> >>> --- On Tue, 5/19/09, Ryan Ingram wrote: >>> >>> From: Ryan Ingram >>> Subject: Re: [Haskell-cafe] showing a user defined type >>> To: "michael rice" >>> Cc: "Brandon S. Allbery KF8NH" , >>> haskell-cafe@haskell.org >>> Date: Tuesday, May 19, 2009, 2:40 PM >>> >>> On Tue, May 19, 2009 at 7:07 AM, michael rice wrote: >>>> A little further along in "The Little MLer" the ints function is >>>> replaced >>>> by >>>> other functions like primes and fibs, which also return Links: >>>> >>>> fun primes(n) >>>> ? = if is_prime(n+1) >>>> ?then Link(n+1,primes) >>>> ?else primes(n+1) >>>> >>>> fun fibs(n)(m) >>>> ? = Link(n+m,fibs(m)) >>>> >>>> which are passed to chain_item: >>>> >>>> fun chain_item(n,Link(i,f)) >>>> ? = if eq_int(n,1) >>>> ? then i >>>> ? else chain_item(n-1,f(i)) >>>> >>>> which can be called to request the nth (12th) prime number beginning at >>>> 1. >>>> >>>> - chain_item(12,primes(1)); >>>> GC #0.0.0.1.3.61:?? (1 ms) >>>> val it = 37 : int >>>> - >>>> >>>> So I guess the answer to your question about whether the function is >>>> ever >>>> called with a different value may be, yes. >>> >>> Actually, it's not calling it with another value; notice that >>> chain_item calls f(i), with i coming directly from the chain. >>> Consider this alternate definition: >>> (I'm not sure the syntax is exactly right, but you get the idea) >>> >>> datatype chain = >>> ? Link of (int * ( unit -> chain )) >>> >>> fun intsFrom(n) = fun unit => (n, intsFrom (n+1)) >>> fun ints(n) = intsFrom n () >>> >>> Now you *can't* call the function embedded in the link with another >>> value. >>> >>> fun chain_item(n,Link(i,f)) >>> ? = if eq_int(n,1) >>> ? then i >>> ? else chain_item(n-1,f unit) >>> >>> And this type for "chain" is almost the same as [Int] in Haskell, due >>> to laziness. >>> >>> ? -- ryan >>> >>> >> >> > > From magnus at therning.org Thu May 21 01:23:33 2009 From: magnus at therning.org (Magnus Therning) Date: Thu May 21 01:08:19 2009 Subject: [Haskell-cafe] the problem of design by negation In-Reply-To: <4A148A42.9030205@alumni.caltech.edu> References: <4A148A42.9030205@alumni.caltech.edu> Message-ID: <4A14E555.1020109@therning.org> Michael Mossey wrote: > This is not directly related to Haskell, but it's a thought that > occurred to me after exposure to the Haskell community. > > I've spent most of the past 15 years doing scientific programming. The > lead software architect and software managers are using good software > engineering practice, though (this is *scientific* programming, not > *programming by scientists*, ha ha). But, there is a particular culture > in my company that has become more obvious to me by contrast to the > Haskell community. > > I call it "design by negation." When asked to justify his design, the > lead software architect explains everything that *wouldn't* work. "We > couldn't have a unique key for every entry because blah blah blah. We > couldn't use a garbage collector because blah blah. We couldn't write a > sugar layer because then you have to document it separately blah blah." > So the chosen design seems to be the only thing left after eliminating > everything you can't do. > > I want to aspire to "positive design." I want to list the goals, and > think of design as making clever choices that meet all the goals. > > I don't mean to suggest that design is never constrained. It often is. > But it's a mindset I'm talking about. I don't like this mindset of > design by negation. Design is always constrained, and arguably every choice that is made should be justified, that includes explaining why a particular solution was discarded. I can understand your frustration with the "negative attitude", I'm just trying to say that I've most often been in the opposite position; no one can answer why several, often much simpler, designs weren't good enough. Often there is not even any record of any decisions having been made at all, which to me suggests that no one really thought about the problem at all before implementing a solution. In short, I wouldn't mind seeing a bit more negative attitude in the place where I work :-) /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090521/5bce0395/signature.bin From z_axis at 163.com Thu May 21 02:10:17 2009 From: z_axis at 163.com (z_axis@163.com) Date: Thu May 21 01:53:49 2009 Subject: [Haskell-cafe] what's the definition of "satisfy" and "" ? Message-ID: <4A14F049.7010505@163.com> I cannot understand the following code very well as i donot know the definition of "satisfy" and "". -- | Case-insensitive variant of Parsec's 'char' function. caseChar :: Char -> GenParser Char a Char caseChar c = satisfy (\x -> toUpper x == toUpper c) -- | Case-insensitive variant of Parsec's 'string' function. caseString :: String -> GenParser Char a () caseString cs = mapM_ caseChar cs cs Would somebody mind to explain the code in detail ? Sincerely! From lee.duhem at gmail.com Thu May 21 02:27:21 2009 From: lee.duhem at gmail.com (Lee Duhem) Date: Thu May 21 02:11:59 2009 Subject: [Haskell-cafe] what's the definition of "satisfy" and "" ? In-Reply-To: <4A14F049.7010505@163.com> References: <4A14F049.7010505@163.com> Message-ID: On Thu, May 21, 2009 at 2:10 PM, z_axis@163.com wrote: > I cannot understand the following code very well as i donot know the > definition of "satisfy" and "". Did you check out the document of parsec? You can find definitions for 'satisty' and '' in Text.ParserCombinators.Parsec.Char and Text.ParserCombinators.Prim, respectively. lee From es at ertes.de Thu May 21 02:55:37 2009 From: es at ertes.de (Ertugrul Soeylemez) Date: Thu May 21 02:40:31 2009 Subject: [Haskell-cafe] Re: what's the definition of "satisfy" and "" ? References: <4A14F049.7010505@163.com> Message-ID: <20090521085537.171f01d6@tritium.xx> "z_axis@163.com" wrote: > I cannot understand the following code very well as i donot know the > definition of "satisfy" and "". Yes. Just look at the Parsec documentation, preferably Parsec 3, because Parsec versions prior to 3 were not well documented. > -- | Case-insensitive variant of Parsec's 'char' function. > caseChar :: Char -> GenParser Char a Char > caseChar c = satisfy (\x -> toUpper x == toUpper c) > > -- | Case-insensitive variant of Parsec's 'string' function. > caseString :: String -> GenParser Char a () > caseString cs = mapM_ caseChar cs cs This code looks incorrect to me. It should read: caseString :: String -> GenParser Char a () caseString cs = Parsec.try (mapM_ caseChar cs) cs Greets, Ertugrul. -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/ From loupgaroublond at gmail.com Thu May 21 03:13:48 2009 From: loupgaroublond at gmail.com (Yaakov Nemoy) Date: Thu May 21 02:58:26 2009 Subject: [Haskell-cafe] Haskell philosophy question In-Reply-To: <5ae4f2ba0905162332q6d8563ebpee6a2a00ad362f49@mail.gmail.com> References: <5ae4f2ba0905162332q6d8563ebpee6a2a00ad362f49@mail.gmail.com> Message-ID: <7f692fec0905210013s5e4e0668h4fc62b808c4099e8@mail.gmail.com> 2009/5/17 Vasili I. Galchin : > Hello, > > ???? I am confused between Haskell as delineated in the Haskell Report VS > ghc "pragmas" which extend Haskell beyond the Haskell Report. I am sure I am > not the first to ask. Caveat: on my part, I am not against > innovation/extensions, but I don't like to see language "bloat". This is not > a negative/pegorative statement .... just a challenging one. Let's say that pragmas strong type your code. With the Haskell Report, you can parse a string into a certain block of code which does some kind of functionality. With these, you will get a different type that does prett ymuch the same thing. But these advanced types can also handle certain other tricks too. The philosophy is to use the pragmas then, as declarations so you know which parser to use, etc... It also lets people pass around blocks of data and know what to do with it, rather than relying on simple version numbers. Languages do pick up features all the time. If you're looking for a different perspective, it lets us strictly sort the extensions rather than relying on vague notions such as version number, 'from __future__ import *' (from python) or any of the other weird things you get when there are multiple revisions of a single language spec. In essence it's not that the language is any more bloated than what is normal, or you would still be using KR C to get your work done, because you were afraid of bloat. -Yaakov Nemoy From noel.kalman at googlemail.com Thu May 21 03:40:49 2009 From: noel.kalman at googlemail.com (Kalman Noel) Date: Thu May 21 03:25:30 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: References: Message-ID: <4A150581.5010605@googlemail.com> Joe Fredette schrieb: > 3-4 slides imply 3-4 topics, so the question is what are the 3-4 biggest > topics in haskell? I would think they would be: > > * Purity/Referential Transparency > * Lazy Evaluation > * Strong Typing + Type Classes > * Monads If the goal is to be able to talk about different examples of Haskell code in the rest of the presentation, the big topic I'd choose would be called ?How function definitions look like in Haskell?. Kalman From lionel at gamr7.com Thu May 21 03:55:14 2009 From: lionel at gamr7.com (Lionel Barret de Nazaris) Date: Thu May 21 03:40:06 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: <4A150581.5010605@googlemail.com> References: <4A150581.5010605@googlemail.com> Message-ID: <4A1508E2.4080307@gamr7.com> On 21/05/2009 09:40, Kalman Noel wrote: > Joe Fredette schrieb: > >> 3-4 slides imply 3-4 topics, so the question is what are the 3-4 biggest >> topics in haskell? I would think they would be: >> >> * Purity/Referential Transparency >> * Lazy Evaluation >> * Strong Typing + Type Classes >> * Monads >> > > If the goal is to be able to talk about different examples of Haskell > code in the rest of the presentation, the big topic I'd choose would be > called ?How function definitions look like in Haskell?. > > Kalman > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > My bet : - type system without the type classes but with comparision with usual (c++) type systems. - function definitions, with a hint at pattern matching - lazyness. (see the searching a maybe list on the begineer list, it is a very good example). - advanced topic : monads, type classes, etc -> just to say they are here and describe what they allow (state, exception), etc. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090521/bf6ffef5/attachment.html From ttencate at gmail.com Thu May 21 04:56:51 2009 From: ttencate at gmail.com (Thomas ten Cate) Date: Thu May 21 04:41:29 2009 Subject: [Haskell-cafe] the problem of design by negation In-Reply-To: <4A148A42.9030205@alumni.caltech.edu> References: <4A148A42.9030205@alumni.caltech.edu> Message-ID: On Thu, May 21, 2009 at 00:54, Michael Mossey wrote: > I call it "design by negation." When asked to justify his design, the lead > software architect explains everything that *wouldn't* work. "We couldn't > have a unique key for every entry because blah blah blah. We couldn't use a > garbage collector because blah blah. We couldn't write a sugar layer because > then you have to document it separately blah blah." So the chosen design > seems to be the only thing left after eliminating everything you can't do. > > I want to aspire to "positive design." I want to list the goals, and think > of design as making clever choices that meet all the goals. I think there is often a good "default" solution which is so obvious that experienced software architects won't even bother to mention. This is the case for both examples that you mention (unique keys in a database, garbage collection). They then go on to give reasons why the "default" solution would not work in their case. Thomas From spoon at killersmurf.com Thu May 21 05:36:40 2009 From: spoon at killersmurf.com (spoon@killersmurf.com) Date: Thu May 21 05:21:14 2009 Subject: [Haskell-cafe] ANN: EsotericBot 0.0.1 Message-ID: <20090521093640.GA8927@killersmurf.com> Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/esotericbot See the homepage for online copy of README and example configuration file: http://www.killersmurf.com/projects/esotericbot Esotericbot is a sophisticated, lightweight IRC bot, written in Haskell. Esotericbot launches sub-processes to respond to commands issued by users over IRC. Why would you use esotericbot? For lambdabot-4.2.2.1: spoon@utensil:~/esotericbot$ ps e v PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND 23433 pts/3 Sl+ 0:00 0 8228 84855 33476 1.6 lambdabot 15040 pts/5 S+ 0:00 0 2171 28804 3292 0.1 ./esotericbot I'm not insinuating that lambdabot sucks in any way, ( for lambdabot is most excellent ) however, my hope is that esotericbot could attain equal functionality through plugins, whilst maintaining its small memory footprint. Esotericbot is small, designed to run on a server with limited memory - typically running at under 5mb of private memory. Features: * Advanced memory and time management options, utilizing POSIX resource management. For example, the memory used by all child processes, can be limited - commands be queued until the memory usage has dropped. * Privileged channel operator commands ( Currently, can be disabled and enabled by channel operators, without kicking. ) * Easy to add new plugins. A C library is included to make writing new plugins/adapting programs in C easy. * Set up through a configuration file. * Multiple channels. * Multi-threaded * Lightweight, typically running at under 5mb of private memory. Cons: * POSIX memory management, process forking, and chroot means that Esotericbot is POSIX only. * Esotericbot is, due to the libraries and extensions used, restricted to being compiled by the Glorious Glasgow Haskell Compiler. From gwern0 at gmail.com Thu May 21 09:12:14 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Thu May 21 08:56:50 2009 Subject: [Haskell-cafe] ANN: EsotericBot 0.0.1 In-Reply-To: <20090521093640.GA8927@killersmurf.com> References: <20090521093640.GA8927@killersmurf.com> Message-ID: On Thu, May 21, 2009 at 5:36 AM, wrote: > Hackage: > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/esotericbot > > See the homepage for online copy of README and example configuration > file: > http://www.killersmurf.com/projects/esotericbot > > Esotericbot is a sophisticated, lightweight IRC bot, written in Haskell. > > Esotericbot launches sub-processes to respond to commands issued by > users over IRC. > > Why would you use esotericbot? > > For lambdabot-4.2.2.1: > > spoon@utensil:~/esotericbot$ ps e v > ?PID TTY ? ? ?STAT ? TIME ?MAJFL ? TRS ? DRS ? RSS %MEM COMMAND > 23433 pts/3 ? ?Sl+ ? ?0:00 ? ? ?0 ?8228 84855 33476 ?1.6 lambdabot > 15040 pts/5 ? ?S+ ? ? 0:00 ? ? ?0 ?2171 28804 ?3292 ?0.1 ./esotericbot > > I'm not insinuating that lambdabot sucks in any way, ( for lambdabot is > most excellent ) however, my hope is that esotericbot could attain equal > functionality through plugins, whilst maintaining its small memory footprint. > > Esotericbot is small, designed to run on a server with > limited memory - typically running at under 5mb of private memory. > Features: > > * Advanced memory and time management options, utilizing POSIX resource > management. > For example, the memory used by all child processes, can be limited - > commands be queued until the memory usage has dropped. > > * Privileged channel operator commands ( Currently, can be disabled and > enabled by channel operators, without kicking. ) > > * Easy to add new plugins. ?A C library is included to make writing new > plugins/adapting programs in C easy. > > * Set up through a configuration file. > > * Multiple channels. > > * Multi-threaded > > * Lightweight, typically running at under 5mb of private memory. > > Cons: > > * POSIX memory management, process forking, and chroot means that > Esotericbot is POSIX only. > > * Esotericbot is, due to the libraries and extensions used, restricted > to being compiled by the Glorious Glasgow Haskell Compiler. Hm, no 'quotes' or Haskell evaluation functionality? I guess this isn't a lambdabot killer yet! -- gwern From lee.duhem at gmail.com Thu May 21 10:05:40 2009 From: lee.duhem at gmail.com (Lee Duhem) Date: Thu May 21 09:50:16 2009 Subject: [Haskell-cafe] what's the definition of "satisfy" and "" ? In-Reply-To: <200905211848094537606@163.com> References: <4A14F049.7010505@163.com> <200905211848094537606@163.com> Message-ID: On Thu, May 21, 2009 at 6:48 PM, z_axis wrote: > Sorry! I am a haskell newbie.?? then i will have a look at > Text.ParserCombinators.Parsec.Char Don't forget to CC your reply to the list, so other people on the thread will see your reply. lee From allbery at ece.cmu.edu Thu May 21 12:57:58 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu May 21 12:42:52 2009 Subject: [Haskell-cafe] Haskell philosophy question In-Reply-To: <7f692fec0905210013s5e4e0668h4fc62b808c4099e8@mail.gmail.com> References: <5ae4f2ba0905162332q6d8563ebpee6a2a00ad362f49@mail.gmail.com> <7f692fec0905210013s5e4e0668h4fc62b808c4099e8@mail.gmail.com> Message-ID: <0F88D4D0-105F-4490-978F-12B47890EE61@ece.cmu.edu> On May 21, 2009, at 03:13 , Yaakov Nemoy wrote: > you would still be using KR C to get your work done, because you were > afraid of bloat. Actually you'd still be using BCPL. :) -- 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/20090521/b99a4e9f/PGP.bin From allbery at ece.cmu.edu Thu May 21 12:59:27 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu May 21 12:44:06 2009 Subject: [Haskell-cafe] Haskell in 3 Slides In-Reply-To: <4A150581.5010605@googlemail.com> References: <4A150581.5010605@googlemail.com> Message-ID: <489E7428-9E64-4516-91F0-219CF5530AE1@ece.cmu.edu> On May 21, 2009, at 03:40 , Kalman Noel wrote: > If the goal is to be able to talk about different examples of Haskell > code in the rest of the presentation, the big topic I'd choose would > be > called ?How function definitions look like in Haskell?. That would be (or lead directly to) referential transparency. -- 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/20090521/6ab2e1fc/PGP.bin From tom at lokhorst.eu Thu May 21 14:55:43 2009 From: tom at lokhorst.eu (Tom Lokhorst) Date: Thu May 21 14:40:40 2009 Subject: [Haskell-cafe] ANN: feed2twitter 0.2 & hackage2twitter 0.2.1 Message-ID: <317ca7670905211155r71a97dddn3d233301a969e5f6@mail.gmail.com> To all the cool kids using the Twitter (and to anyone else): I'm happy to announce the first release of feed2twitter. Build on top of the excellent feed and hs-twitter packages, feed2twitter sends posts from a news feed to Twitter. The hackage2twitter executable is build on top of the feed2twitter library. It `tweets' the releases of new Hackage-packages. In the 3 days it has been running, it has already posted 70+ releases: http://twitter.com/Hackage - Tom Lokhorst http://hackage.haskell.org/cgi-bin/hackage-scripts/package/feed2twitter http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hackage2twitter From vanenkj at gmail.com Thu May 21 14:59:26 2009 From: vanenkj at gmail.com (John Van Enk) Date: Thu May 21 14:44:05 2009 Subject: [Haskell-cafe] ANN: feed2twitter 0.2 & hackage2twitter 0.2.1 In-Reply-To: <317ca7670905211155r71a97dddn3d233301a969e5f6@mail.gmail.com> References: <317ca7670905211155r71a97dddn3d233301a969e5f6@mail.gmail.com> Message-ID: A bit off topic, but what's the chance we can get the Hackage RSS feed to include some more information about the package? I'd like to see at least the description, but it might be nice to see things like dependencies and home pages. /jve On Thu, May 21, 2009 at 2:55 PM, Tom Lokhorst wrote: > To all the cool kids using the Twitter (and to anyone else): > > I'm happy to announce the first release of feed2twitter. > Build on top of the excellent feed and hs-twitter packages, > feed2twitter sends posts from a news feed to Twitter. > > The hackage2twitter executable is build on top of the feed2twitter > library. It `tweets' the releases of new Hackage-packages. > In the 3 days it has been running, it has already posted 70+ releases: > http://twitter.com/Hackage > > - Tom Lokhorst > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/feed2twitter > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hackage2twitter > _______________________________________________ > 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/20090521/32b329c9/attachment.html From gwern0 at gmail.com Thu May 21 15:07:02 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Thu May 21 14:51:38 2009 Subject: [Haskell-cafe] ANN: feed2twitter 0.2 & hackage2twitter 0.2.1 In-Reply-To: References: <317ca7670905211155r71a97dddn3d233301a969e5f6@mail.gmail.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Thu, May 21, 2009 at 2:59 PM, John Van Enk wrote: > A bit off topic, but what's the chance we can get the Hackage RSS feed to > include some more information about the package? I'd like to see at least > the description, but it might be nice to see things like dependencies and > home pages. > > /jve > On Thu, May 21, 2009 at 2:55 PM, Tom Lokhorst wrote: >> >> To all the cool kids using the Twitter (and to anyone else): >> >> I'm happy to announce the first release of feed2twitter. >> Build on top of the excellent feed and hs-twitter packages, >> feed2twitter sends posts from a news feed to Twitter. >> >> The hackage2twitter executable is build on top of the feed2twitter >> library. It `tweets' the releases of new Hackage-packages. >> In the 3 days it has been running, it has already posted 70+ releases: >> http://twitter.com/Hackage >> >> - Tom Lokhorst >> >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/feed2twitter >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hackage2twitter >> _______________________________________________ >> 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 > > Someone coding it? The repo for Hackage is: http://code.haskell.org/hackage-server The relevant file seems to be: Distribution/Server/Pages/Recent.hs - -- gwern -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAkoVplEACgkQvpDo5Pfl1oI3SACglwKSDOyVMnO7XM8xNMEWs3fW 7k8An2p77xOiM+/phCJ5oq00odgqjlbw =Bn8E -----END PGP SIGNATURE----- From tom at lokhorst.eu Thu May 21 15:10:23 2009 From: tom at lokhorst.eu (Tom Lokhorst) Date: Thu May 21 14:55:20 2009 Subject: [Haskell-cafe] ANN: feed2twitter 0.2 & hackage2twitter 0.2.1 In-Reply-To: References: <317ca7670905211155r71a97dddn3d233301a969e5f6@mail.gmail.com> Message-ID: <317ca7670905211210o7549f801h2fc279074fd326a7@mail.gmail.com> Oh, and while we're talking off topic. I don't know who's in charge of this, but I think it would be nice to have urls like: http://hackage.haskell.org/feed2twitter It would allow me to type in a url from memory instead of having to copy-paste it. As well as not requiring a url-shortener on Twitter. This could be done with something like Apache's mod-rewrite. - Tom On Thu, May 21, 2009 at 8:59 PM, John Van Enk wrote: > A bit off topic, but what's the chance we can get the Hackage RSS feed to > include some more information about the package? I'd like to see at least > the description, but it might be nice to see things like dependencies and > home pages. > > /jve > On Thu, May 21, 2009 at 2:55 PM, Tom Lokhorst wrote: >> >> To all the cool kids using the Twitter (and to anyone else): >> >> I'm happy to announce the first release of feed2twitter. >> Build on top of the excellent feed and hs-twitter packages, >> feed2twitter sends posts from a news feed to Twitter. >> >> The hackage2twitter executable is build on top of the feed2twitter >> library. It `tweets' the releases of new Hackage-packages. >> In the 3 days it has been running, it has already posted 70+ releases: >> http://twitter.com/Hackage >> >> - Tom Lokhorst >> >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/feed2twitter >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hackage2twitter >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > -- > /jve > From josh.weissbock at gmail.com Thu May 21 15:11:48 2009 From: josh.weissbock at gmail.com (jrw4) Date: Thu May 21 14:56:24 2009 Subject: [Haskell-cafe] Function Returning Type? Message-ID: <23658819.post@talk.nabble.com> I wrote this function as I am just learning Haskell. What it does is it generates a list of all rational numbers between 0 and 1, but I only have it show the first 20. rationals n :: Integer -> String rationals n = (putStr . unlines . map show) (take n (nub [x % y | y <- [1..], x <- [1..y], x < y])) Now my problem is the type declaration, the first line. I get the error "Invalid type signature". I googled this error and I was not able to find out why it is giving it to me. I have also tried: rationals n :: Integer -> [Ratio] but it gives me the same error. Please someone point me in the right direction. Thanks. -- View this message in context: http://www.nabble.com/Function-Returning-Type--tp23658819p23658819.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From vanenkj at gmail.com Thu May 21 15:12:50 2009 From: vanenkj at gmail.com (John Van Enk) Date: Thu May 21 14:57:26 2009 Subject: [Haskell-cafe] ANN: feed2twitter 0.2 & hackage2twitter 0.2.1 In-Reply-To: <317ca7670905211210o7549f801h2fc279074fd326a7@mail.gmail.com> References: <317ca7670905211155r71a97dddn3d233301a969e5f6@mail.gmail.com> <317ca7670905211210o7549f801h2fc279074fd326a7@mail.gmail.com> Message-ID: Hmm, or even: http://hackage.haskell.org/?p=feed2twitter On Thu, May 21, 2009 at 3:10 PM, Tom Lokhorst wrote: > Oh, and while we're talking off topic. > I don't know who's in charge of this, but I think it would be nice to > have urls like: http://hackage.haskell.org/feed2twitter > > It would allow me to type in a url from memory instead of having to > copy-paste it. As well as not requiring a url-shortener on Twitter. > This could be done with something like Apache's mod-rewrite. > > - Tom > > On Thu, May 21, 2009 at 8:59 PM, John Van Enk wrote: > > A bit off topic, but what's the chance we can get the Hackage RSS feed to > > include some more information about the package? I'd like to see at least > > the description, but it might be nice to see things like dependencies and > > home pages. > > > > /jve > > On Thu, May 21, 2009 at 2:55 PM, Tom Lokhorst wrote: > >> > >> To all the cool kids using the Twitter (and to anyone else): > >> > >> I'm happy to announce the first release of feed2twitter. > >> Build on top of the excellent feed and hs-twitter packages, > >> feed2twitter sends posts from a news feed to Twitter. > >> > >> The hackage2twitter executable is build on top of the feed2twitter > >> library. It `tweets' the releases of new Hackage-packages. > >> In the 3 days it has been running, it has already posted 70+ releases: > >> http://twitter.com/Hackage > >> > >> - Tom Lokhorst > >> > >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/feed2twitter > >> > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hackage2twitter > >> _______________________________________________ > >> 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/20090521/03e05395/attachment.html From arnaud.payement at gmail.com Thu May 21 15:15:16 2009 From: arnaud.payement at gmail.com (Arnaud Payement) Date: Thu May 21 15:00:12 2009 Subject: [Haskell-cafe] The Computer Language Benchmarks Game: pidigits Message-ID: <93CD502BE7974AFAA73139A6B225F50E@ArnaudDesktop> Hi all, I recently decided to rewrite the pidigits benchmark of the debian shootout (shootout.alioth.debian.org) as toy project. However, it seems that on my machine, the code seems to be more performant than both the current entry and the proposed replacement (see http://www.haskell.org/haskellwiki/Shootout/Pidigits) for the same number of lines. Do you think it might be worth submitting my entry? Here is my code,: {-# OPTIONS -O2 -optc-O3 #-} -- -- The Great Computer Language Shootout -- http://shootout.alioth.debian.org/ -- by Arnaud Payement -- import System data F = F Integer Integer Integer Integer extract s@(F k n a d) = ((n*3+a) `div` d, (n*4+a) `div` d, s) update (F k n a d) = F (k+1) (n*k) ((a+n*2)*y) (d*y) where y = 2*k+1 next state = let (u, v, s'@(F k n a d)) = extract (update state) in if (n > a || (u /= v)) then next s' else (show u, F k (n*10) ((a-d*u)*10) d) digits = ("", (F 1 1 0 1)):[next state | state <- map snd digits] pr (d:t) k n | k > n = putStr "" | k `mod` 10 /= 0 = putStr d >> pr t (k+1) n | otherwise = putStrLn (d ++ "\t:" ++ show k) >> pr t (k+1) n main = pr (map fst (tail digits)) 1 . read . head =<< getArgs Best, Arnaud -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090521/7ccabe9c/attachment.html From jochem at functor.nl Thu May 21 15:15:33 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Thu May 21 15:00:20 2009 Subject: [Haskell-cafe] Function Returning Type? In-Reply-To: <23658819.post@talk.nabble.com> References: <23658819.post@talk.nabble.com> Message-ID: <4A15A855.1020408@functor.nl> jrw4 wrote: > I wrote this function as I am just learning Haskell. What it does is it > generates a list of all rational numbers between 0 and 1, but I only have it > show the first 20. > > rationals n :: Integer -> String > rationals n = (putStr . unlines . map show) (take n (nub [x % y | y <- > [1..], x <- [1..y], x < y])) > > Now my problem is the type declaration, the first line. I get the error > "Invalid type signature". I googled this error and I was not able to find > out why it is giving it to me. I have also tried: > > rationals n :: Integer -> [Ratio] > > but it gives me the same error. > > Please someone point me in the right direction. Thanks. Just rationals :: Integer -> String suffices. (Without the argument 'n'.) This makes sense, since "rationals" has type Integer. "rationals n" has type String. (But you still cannot declare that in toplevel that way.) Regards, -- Jochem Berndsen | jochem@functor.nl GPG: 0xE6FABFAB From jochem at functor.nl Thu May 21 15:26:03 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Thu May 21 15:10:49 2009 Subject: [Haskell-cafe] Function Returning Type? In-Reply-To: <4A15A855.1020408@functor.nl> References: <23658819.post@talk.nabble.com> <4A15A855.1020408@functor.nl> Message-ID: <4A15AACB.3070509@functor.nl> Jochem Berndsen wrote: > This makes sense, since "rationals" has type Integer I meant "Integer -> String" obviously. Regards, -- Jochem Berndsen | jochem@functor.nl GPG: 0xE6FABFAB From jgoerzen at complete.org Thu May 21 15:28:22 2009 From: jgoerzen at complete.org (John Goerzen) Date: Thu May 21 15:13:02 2009 Subject: [Haskell-cafe] ANN: feed2twitter 0.2 & hackage2twitter 0.2.1 In-Reply-To: <317ca7670905211210o7549f801h2fc279074fd326a7@mail.gmail.com> References: <317ca7670905211155r71a97dddn3d233301a969e5f6@mail.gmail.com> <317ca7670905211210o7549f801h2fc279074fd326a7@mail.gmail.com> Message-ID: <20090521192822.GA11522@hustlerturf.com> On Thu, May 21, 2009 at 09:10:23PM +0200, Tom Lokhorst wrote: > Oh, and while we're talking off topic. > I don't know who's in charge of this, but I think it would be nice to > have urls like: http://hackage.haskell.org/feed2twitter YES! Also a /package/doc link. So we could have a static link that would always go the latest version of the API docs for a given package. -- John > > It would allow me to type in a url from memory instead of having to > copy-paste it. As well as not requiring a url-shortener on Twitter. > This could be done with something like Apache's mod-rewrite. > > - Tom > > On Thu, May 21, 2009 at 8:59 PM, John Van Enk wrote: > > A bit off topic, but what's the chance we can get the Hackage RSS feed to > > include some more information about the package? I'd like to see at least > > the description, but it might be nice to see things like dependencies and > > home pages. > > > > /jve > > On Thu, May 21, 2009 at 2:55 PM, Tom Lokhorst wrote: > >> > >> To all the cool kids using the Twitter (and to anyone else): > >> > >> I'm happy to announce the first release of feed2twitter. > >> Build on top of the excellent feed and hs-twitter packages, > >> feed2twitter sends posts from a news feed to Twitter. > >> > >> The hackage2twitter executable is build on top of the feed2twitter > >> library. It `tweets' the releases of new Hackage-packages. > >> In the 3 days it has been running, it has already posted 70+ releases: > >> http://twitter.com/Hackage > >> > >> - Tom Lokhorst > >> > >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/feed2twitter > >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hackage2twitter > >> _______________________________________________ > >> Haskell-Cafe mailing list > >> Haskell-Cafe@haskell.org > >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > > > -- > > /jve > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dons at galois.com Thu May 21 15:36:47 2009 From: dons at galois.com (Don Stewart) Date: Thu May 21 15:22:53 2009 Subject: [Haskell-cafe] ANN: feed2twitter 0.2 & hackage2twitter 0.2.1 In-Reply-To: References: <317ca7670905211155r71a97dddn3d233301a969e5f6@mail.gmail.com> Message-ID: <20090521193647.GC5819@whirlpool.galois.com> vanenkj: > A bit off topic, but what's the chance we can get the Hackage RSS feed to > include some more information about the package? I'd like to see at least the > description, but it might be nice to see things like dependencies and home > pages. what you really want is a way to query hackage programmatically. From dons at galois.com Thu May 21 15:37:22 2009 From: dons at galois.com (Don Stewart) Date: Thu May 21 15:23:27 2009 Subject: [Haskell-cafe] The Computer Language Benchmarks Game: pidigits In-Reply-To: <93CD502BE7974AFAA73139A6B225F50E@ArnaudDesktop> References: <93CD502BE7974AFAA73139A6B225F50E@ArnaudDesktop> Message-ID: <20090521193722.GD5819@whirlpool.galois.com> arnaud.payement: > Hi all, > > I recently decided to rewrite the pidigits benchmark of the debian shootout > (shootout.alioth.debian.org) as toy project. > However, it seems that on my machine, the code seems to be more performant than > both the current entry and the proposed replacement (see http://www.haskell.org > /haskellwiki/Shootout/Pidigits) for the same number of lines. > Do you think it might be worth submitting my entry? Here is my code,: If it is faster, and correct, please submit it From stefan at cs.uu.nl Thu May 21 15:52:00 2009 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Thu May 21 15:36:38 2009 Subject: [Haskell-cafe] Function Returning Type? In-Reply-To: <4A15AACB.3070509@functor.nl> References: <23658819.post@talk.nabble.com> <4A15A855.1020408@functor.nl> <4A15AACB.3070509@functor.nl> Message-ID: <6CD257A9-C13D-4D3D-8491-B9AB2FDE646A@cs.uu.nl> Jochem, >>> rationals n = (putStr . unlines . map show) (take n (nub [x % y | >>> y <- >>> [1..], x <- [1..y], x < y])) >> rationals n :: Integer -> [Ratio] > I meant "Integer -> String" obviously. Er... what about rationals :: Int -> IO () ? ;-) To the original poster: next time, just leave the function definition without the signature and query GHCi for the correct type: Prelude> :m + List Prelude List> :m + Ratio Prelude List Ratio> let rationals n = (putStr . unlines . map show) \ (take n (nub [x % y | y <- [1..], x <- [1..y], x < y])) Prelude List Ratio> :t rationals rationals :: Int -> IO () Cheers, Stefan From tom.davie at gmail.com Thu May 21 16:15:08 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Thu May 21 16:00:12 2009 Subject: [Haskell-cafe] Function Returning Type? In-Reply-To: <6CD257A9-C13D-4D3D-8491-B9AB2FDE646A@cs.uu.nl> References: <23658819.post@talk.nabble.com> <4A15A855.1020408@functor.nl> <4A15AACB.3070509@functor.nl> <6CD257A9-C13D-4D3D-8491-B9AB2FDE646A@cs.uu.nl> Message-ID: <195F98A0-41A6-44A3-A230-3E96FAD3F2B3@gmail.com> Op 21 May 2009, om 21:52 heeft Stefan Holdermans het volgende geschreven: > Jochem, > >>>> rationals n = (putStr . unlines . map show) (take n (nub [x % y | >>>> y <- >>>> [1..], x <- [1..y], x < y])) > >>> rationals n :: Integer -> [Ratio] > >> I meant "Integer -> String" obviously. > > Er... what about > > rationals :: Int -> IO () Of note here though, the original type Integer -> String is more desirable ? the Int/Integer part doesn't matter so much, what matters is the IO type ? we can no longer pass the value that rationals generates into another function, because it printed it and dumped it. Lets fix the function instead: rationals :: Int -> [Rational] rationals n = take n $ nub [x % y | y <- [1..], x <- 1..], x < y] showLines :: Show a => [a] -> String showLines = unlines . map show rationalsS :: Int -> String rationalsS = showLines . rationals Now we can chose to use the actual rationals we got out of the function, we can chose to use the string we get back, we can reuse our function for showing multiple showable values, and we can print any of these if we chose :). Bob From mwassell at bigpond.net.au Thu May 21 16:27:34 2009 From: mwassell at bigpond.net.au (Mark Wassell) Date: Thu May 21 16:12:22 2009 Subject: [Haskell-cafe] Function Returning Type? In-Reply-To: <6CD257A9-C13D-4D3D-8491-B9AB2FDE646A@cs.uu.nl> References: <23658819.post@talk.nabble.com> <4A15A855.1020408@functor.nl> <4A15AACB.3070509@functor.nl> <6CD257A9-C13D-4D3D-8491-B9AB2FDE646A@cs.uu.nl> Message-ID: <4A15B936.5020704@bigpond.net.au> > > To the original poster: next time, just leave the function definition > without the signature and query GHCi for the correct type: Remember that the type checker is your friend; let it work for you :) Mark From fernandohsanches at gmail.com Thu May 21 16:34:15 2009 From: fernandohsanches at gmail.com (Fernando Henrique Sanches) Date: Thu May 21 16:18:52 2009 Subject: =?ISO-8859-1?Q?Re=3A_=5BHaskell=2Dcafe=5D_Haskell_programmers_in_S=E3o_Carlo?= =?ISO-8859-1?Q?s_=2D_SP_=2D_Brazil=3F?= In-Reply-To: References: Message-ID: <174c72ef0905211334g129a3c01l74c3108d66448e91@mail.gmail.com> S?o Caetano, SP, Brazil - right next to S?o Paulo. UFABC Student. Fernando Henrique Sanches 2009/5/19 Maur??cio > Anybody else around here? > > Best, > Maur?cio > > _______________________________________________ > 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/20090521/f57d76f2/attachment.html From byorgey at seas.upenn.edu Thu May 21 17:39:08 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Thu May 21 17:22:44 2009 Subject: [Haskell-cafe] ANN: Haskell Hackathon in Philadelphia Message-ID: <20090521213908.GA30134@seas.upenn.edu> Hi all! We are in the early stages of planning a Haskell hackathon/get together, Hac ?, to be held this summer at the University of Pennsylvania, in Philadelphia. Right now we're looking at two possible dates: June 19-21 or July 24-26 If you might be interested in attending, please add your name on the wiki page: http://www.haskell.org/haskellwiki/Hac_%CF%86 You can also note whether either of those dates absolutely doesn't work for you. (If you don't have an account on the wiki, you can email Ashley Yakeley for an account [1], or feel free to just respond to this email.) Expect more details (such as a nailed-down date) soon, once we have gauged the level of interest. Hope to see you in Philadelphia! Brent (byorgey) Daniel Wagner (dmwit) [1] http://haskell.org/haskellwiki/HaskellWiki:New_accounts From jgoerzen at complete.org Thu May 21 17:53:26 2009 From: jgoerzen at complete.org (John Goerzen) Date: Thu May 21 17:38:04 2009 Subject: [Haskell-cafe] Introducing Instances in GHC point releases In-Reply-To: <20090515065337.GA356@whirlpool.galois.com> References: <20090515065337.GA356@whirlpool.galois.com> Message-ID: <4A15CD56.20505@complete.org> So this is annoying (CCing -cafe) I need NominalDiffTime and UTCTime to have Typeable instances. In 6.10.1, they didn't ship with them out of the box, so I added them. Apparently, in 6.10.3, they DO ship with those instances out of the box. Annoyingly, that means that my code breaks on 6.10.3. Even more annoyingly, __GLASGOW_HASKELL__ is still 610, so I can't even work around this via cpphs. There appears to be no way to make code that requires those Typeable instances work with both 6.10.1 and 6.10.3. Yet another reason to avoid API incompatibilities in point releases. Does anybody have an idea on the best way to handle this? -- John Don Stewart wrote: > convertible appears broken with 6.10.3. Any thoughts? > > Writing new package config file... done. > Downloading convertible-1.0.1... > Configuring convertible-1.0.1... > Preprocessing library convertible-1.0.1... > Preprocessing executables for convertible-1.0.1... > Building convertible-1.0.1... > [1 of 8] Compiling Data.Convertible.Base ( Data/Convertible/Base.hs, dist/build/Data/Convertible/Base.o ) > [2 of 8] Compiling Data.Convertible.Utils ( Data/Convertible/Utils.hs, dist/build/Data/Convertible/Utils.o ) > [3 of 8] Compiling Data.Convertible.Instances.Map ( Data/Convertible/Instances/Map.hs, dist/build/Data/Convertible/Instances/Map.o ) > [4 of 8] Compiling Data.Convertible.Instances.Num ( Data/Convertible/Instances/Num.hs, dist/build/Data/Convertible/Instances/Num.o ) > [5 of 8] Compiling Data.Convertible.Instances.C ( Data/Convertible/Instances/C.hs, dist/build/Data/Convertible/Instances/C.o ) > [6 of 8] Compiling Data.Convertible.Instances.Time ( Data/Convertible/Instances/Time.hs, dist/build/Data/Convertible/Instances/Time.o ) > > Data/Convertible/Instances/Time.hs:61:9: > Duplicate instance declarations: > instance Typeable NominalDiffTime > -- Defined at Data/Convertible/Instances/Time.hs:61:9-32 > instance Typeable NominalDiffTime > -- Defined in time-1.1.3:Data.Time.Clock.UTC > > Data/Convertible/Instances/Time.hs:64:9: > Duplicate instance declarations: > instance Typeable UTCTime > -- Defined at Data/Convertible/Instances/Time.hs:64:9-24 > instance Typeable UTCTime > -- Defined in time-1.1.3:Data.Time.Clock.UTC > cabal: Error: some packages failed to install: > HDBC-2.1.0 depends on convertible-1.0.1 which failed to install. > convertible-1.0.1 failed during the building phase. The exception was: > > From alexander.dunlap at gmail.com Thu May 21 18:22:08 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Thu May 21 18:07:46 2009 Subject: [Haskell-cafe] Introducing Instances in GHC point releases In-Reply-To: <4A15CD56.20505@complete.org> References: <20090515065337.GA356@whirlpool.galois.com> <4A15CD56.20505@complete.org> Message-ID: <57526e770905211522k2041f7cdoc4b96f893335c2f0@mail.gmail.com> Since those types come out of the time library, and that library's version *has* been bumped (I assume), couldn't you use Cabal to condition on the version of the time library to determine whether or not to have CPP set a -DTYPEABLE_IN_TIME flag, and then #ifdef out your versions of the instances? I suppose a nice compiler extension would be "recessive instances" which would take effect only if they did not overlap with another instance. Probably a lot of corner cases involving multiple recessive instances to work out, though. Alex On Thu, May 21, 2009 at 2:53 PM, John Goerzen wrote: > So this is annoying (CCing -cafe) > > I need NominalDiffTime and UTCTime to have Typeable instances. ?In > 6.10.1, they didn't ship with them out of the box, so I added them. > Apparently, in 6.10.3, they DO ship with those instances out of the box. > > Annoyingly, that means that my code breaks on 6.10.3. > > Even more annoyingly, __GLASGOW_HASKELL__ is still 610, so I can't even > work around this via cpphs. ?There appears to be no way to make code > that requires those Typeable instances work with both 6.10.1 and 6.10.3. > > Yet another reason to avoid API incompatibilities in point releases. > > Does anybody have an idea on the best way to handle this? > > -- John > > Don Stewart wrote: >> convertible appears broken with 6.10.3. Any thoughts? >> >> ? ? Writing new package config file... done. >> ? ? Downloading convertible-1.0.1... >> ? ? Configuring convertible-1.0.1... >> ? ? Preprocessing library convertible-1.0.1... >> ? ? Preprocessing executables for convertible-1.0.1... >> ? ? Building convertible-1.0.1... >> ? ? [1 of 8] Compiling Data.Convertible.Base ( Data/Convertible/Base.hs, dist/build/Data/Convertible/Base.o ) >> ? ? [2 of 8] Compiling Data.Convertible.Utils ( Data/Convertible/Utils.hs, dist/build/Data/Convertible/Utils.o ) >> ? ? [3 of 8] Compiling Data.Convertible.Instances.Map ( Data/Convertible/Instances/Map.hs, dist/build/Data/Convertible/Instances/Map.o ) >> ? ? [4 of 8] Compiling Data.Convertible.Instances.Num ( Data/Convertible/Instances/Num.hs, dist/build/Data/Convertible/Instances/Num.o ) >> ? ? [5 of 8] Compiling Data.Convertible.Instances.C ( Data/Convertible/Instances/C.hs, dist/build/Data/Convertible/Instances/C.o ) >> ? ? [6 of 8] Compiling Data.Convertible.Instances.Time ( Data/Convertible/Instances/Time.hs, dist/build/Data/Convertible/Instances/Time.o ) >> >> ? ? Data/Convertible/Instances/Time.hs:61:9: >> ? ? ? ? Duplicate instance declarations: >> ? ? ? ? ? instance Typeable NominalDiffTime >> ? ? ? ? ? ? -- Defined at Data/Convertible/Instances/Time.hs:61:9-32 >> ? ? ? ? ? instance Typeable NominalDiffTime >> ? ? ? ? ? ? -- Defined in time-1.1.3:Data.Time.Clock.UTC >> >> ? ? Data/Convertible/Instances/Time.hs:64:9: >> ? ? ? ? Duplicate instance declarations: >> ? ? ? ? ? instance Typeable UTCTime >> ? ? ? ? ? ? -- Defined at Data/Convertible/Instances/Time.hs:64:9-24 >> ? ? ? ? ? instance Typeable UTCTime >> ? ? ? ? ? ? -- Defined in time-1.1.3:Data.Time.Clock.UTC >> ? ? cabal: Error: some packages failed to install: >> ? ? HDBC-2.1.0 depends on convertible-1.0.1 which failed to install. >> ? ? convertible-1.0.1 failed during the building phase. The exception was: >> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From duncan at well-typed.com Thu May 21 06:40:29 2009 From: duncan at well-typed.com (Duncan Coutts) Date: Thu May 21 18:08:57 2009 Subject: [Haskell-cafe] ghc ./configure stalls on docbook DTD In-Reply-To: <4A1141D8.8070505@gmail.com> References: <4A0B1304.7060401@gmail.com> <4A1141D8.8070505@gmail.com> Message-ID: <1242902429.20307.53.camel@localhost> On Mon, 2009-05-18 at 12:09 +0100, Simon Marlow wrote: > I have the following complaint from Roman in my inbox, which I think is > about the same thing: > > > one big nuisance when building ghc is that configure tries to connect > > to the internet. The culprit is the FP_GEN_DOCBOOK_XML macro in > > aclocal.m4 which is used when checking for DocBook DTD. It generates > > an XML file which references http://www.oasis-open.org/docbook/xml/4.2 > > /docbookx.dtd and then runs xmllint which, naturally, wants to load > > the dtd. Depending on the quality of my internet connection and on > > the availability of oasis-open.org this check sometimes (infrequently > > but very annoyingly) takes up to a 2 or 3 minutes for me. Given that > > the DTD in question can be freely copied, why not redistribute it > > with ghc? > > > Another www reference is in FP_GEN_FO (to > > http://www.w3.org/1999/XSL/Format) but that never seems to bite me. > > I know almost but not quite exactly nothing about how to find DTDs. But > I do recall that Duncan mentioned to me recently that there's a much > better way to do this - Duncan? Oh, yes, use --nonet to both xmllint and xsltproc. That's what we do for the Cabal user guide which is still using xml docbook, along with: I expect the uri "-//OASIS//DTD DocBook XML V4.2//EN" is required so that it can match the uri in the local catalog. Duncan From duncan.coutts at worc.ox.ac.uk Thu May 21 18:34:22 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu May 21 18:29:38 2009 Subject: [Haskell-cafe] Introducing Instances in GHC point releases In-Reply-To: <57526e770905211522k2041f7cdoc4b96f893335c2f0@mail.gmail.com> References: <20090515065337.GA356@whirlpool.galois.com> <4A15CD56.20505@complete.org> <57526e770905211522k2041f7cdoc4b96f893335c2f0@mail.gmail.com> Message-ID: <1242945262.20307.61.camel@localhost> On Thu, 2009-05-21 at 15:22 -0700, Alexander Dunlap wrote: > Since those types come out of the time library, and that library's > version *has* been bumped (I assume), couldn't you use Cabal to > condition on the version of the time library to determine whether or > not to have CPP set a -DTYPEABLE_IN_TIME flag, and then #ifdef out > your versions of the instances? I was about to suggest this: #if MIN_VERSION_time(1,1,2) ... #endif because Cabal 1.6+ generates these cpp macros for you. Note that relying on the value of __GLASGOW_HASKELL__ would be wrong because the version of the time library is not directly related to the version of ghc. However, I note that all the recent versions of time are 1.1.2.x which means it didn't bump the API version when it added the instances. The PVP says: A.B is known as the major version number, and C the minor version number. When a package is updated, the following rules govern how the version number must change relative to the previous version: 1. If any entity was removed, or the types of any entities or the definitions of datatypes or classes were changed, or instances were added or removed, then the new A.B must be greater than the previous A.B. Duncan From vigalchin at gmail.com Thu May 21 19:13:06 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Thu May 21 18:57:40 2009 Subject: [Haskell-cafe] HUnit Message-ID: <5ae4f2ba0905211613o839f69ft701beab5ff365f5f@mail.gmail.com> Hello, I have some code with several test cases that use HUnit. I added hunit as one of my cabal dependencies but cabal complained with: Setup: At least the following dependencies are missing: hutil -any What am I doing incorrectly? Thanks, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090521/451aeb14/attachment.html From dons at galois.com Thu May 21 19:20:23 2009 From: dons at galois.com (Don Stewart) Date: Thu May 21 19:06:49 2009 Subject: [Haskell-cafe] HUnit In-Reply-To: <5ae4f2ba0905211613o839f69ft701beab5ff365f5f@mail.gmail.com> References: <5ae4f2ba0905211613o839f69ft701beab5ff365f5f@mail.gmail.com> Message-ID: <20090521232023.GO5994@whirlpool.galois.com> vigalchin: > Hello, > > I have some code with several test cases that use HUnit. I added hunit as > one of my cabal dependencies but cabal complained with: > > Setup: At least the following dependencies are missing: > hutil -any ^^^^^ Typo. -- Don From jason.dusek at gmail.com Thu May 21 22:13:32 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Thu May 21 21:58:10 2009 Subject: [Haskell-cafe] generic filter through MonadPlus Message-ID: <42784f260905211913o1033d5ecg43e4362c1ab160d9@mail.gmail.com> It seems reasonable that filter should be generic. The underlying container need only support some kind of traversal, a zero element and a concatenation that eliminates zeroes. A `Monad` provides traversal via `join` and `fmap`; the remaining qualities are satisfied by `MonadPlus`. I've put together an implementation of `filter` for `MonadPlus` that works well enough for lists (though it presents somewhat greater obstacles to efficient compilation). I'm not sure whether `filter` is important enough to warrant its own generics package -- it's one of many collection operations that need to be generified. I'd like to know what folks think about the use of `MonadPlus` in this case. -- Jason Dusek |...an implementation of `filter`...| http://github.com/jsnx/genfil/blob/246026b975ec13587186681b7b346ae1e440d0c9/Data/Filter.hs From jgoerzen at complete.org Thu May 21 22:30:24 2009 From: jgoerzen at complete.org (John Goerzen) Date: Thu May 21 22:15:04 2009 Subject: [Haskell-cafe] Introducing Instances in GHC point releases In-Reply-To: <1242945262.20307.61.camel@localhost> References: <20090515065337.GA356@whirlpool.galois.com> <4A15CD56.20505@complete.org> <57526e770905211522k2041f7cdoc4b96f893335c2f0@mail.gmail.com> <1242945262.20307.61.camel@localhost> Message-ID: <4A160E40.8090404@complete.org> Duncan Coutts wrote: > On Thu, 2009-05-21 at 15:22 -0700, Alexander Dunlap wrote: >> Since those types come out of the time library, and that library's >> version *has* been bumped (I assume), couldn't you use Cabal to >> condition on the version of the time library to determine whether or >> not to have CPP set a -DTYPEABLE_IN_TIME flag, and then #ifdef out >> your versions of the instances? > > I was about to suggest this: > > #if MIN_VERSION_time(1,1,2) > ... > #endif That would be slick. I'll give that a whirl. What version of Cabal does GHC 6.8 come from, and where can I read about the above feature? I imagine I may have to wrap the above in a __GLASGOW_HASKELL__ test for GHC 6.8 or something. Though if *cabal* and not GHC generates it, isn't that a bit hurting to my portability? (Can't just ghc --make with it, or ghci on it directly anymore, etc.) May be a needed tradeoff though. > > because Cabal 1.6+ generates these cpp macros for you. Note that relying > on the value of __GLASGOW_HASKELL__ would be wrong because the version > of the time library is not directly related to the version of ghc. Yeah, but when you've got nothing else to go on, it sometimes works in a pinch. > However, I note that all the recent versions of time are 1.1.2.x which > means it didn't bump the API version when it added the instances. Ashley, I'll forgive you this time ;-) I guess my larger point is just a plea to the community: please be really careful about what you do to GHC in point releases. This is not the first issue that has screwed me in the GHC 6.10.x point releases. GHC (and the community) used to be really good about this. Is there something causing a regression here, or is it my imagination? From dons at galois.com Thu May 21 22:43:41 2009 From: dons at galois.com (Don Stewart) Date: Thu May 21 22:29:56 2009 Subject: [Haskell-cafe] Introducing Instances in GHC point releases In-Reply-To: <4A160E40.8090404@complete.org> References: <20090515065337.GA356@whirlpool.galois.com> <4A15CD56.20505@complete.org> <57526e770905211522k2041f7cdoc4b96f893335c2f0@mail.gmail.com> <1242945262.20307.61.camel@localhost> <4A160E40.8090404@complete.org> Message-ID: <20090522024341.GS5994@whirlpool.galois.com> > I guess my larger point is just a plea to the community: please be > really careful about what you do to GHC in point releases. This is not > the first issue that has screwed me in the GHC 6.10.x point releases. I hope that the Haskell Platform will solve a lot of these issues. Clear, planned releases. Careful attention to versioning. And GHC can stop shipping custom lib variants, and instead just take the latest platform bundle. From mblazevic at stilo.com Thu May 21 22:59:51 2009 From: mblazevic at stilo.com (=?utf-8?B?TWFyaW8gQmxhxb5ldmnEhw==?=) Date: Thu May 21 22:44:25 2009 Subject: [Haskell-cafe] A problem with par and modules boundaries... Message-ID: <.1242961191@magma.ca> I'll cut to the chase. The short program below works perfectly: when I compile it with -O2 -threaded and run with +RTS -N2 command-line options, I get a nearly 50% real-time improvement: $ time ./primes-test +RTS -N2 5001 real 0m9.307s user 0m16.581s sys 0m0.200s However, if I move the `parallelize' definition into another module and import that module, the performance is completely lost: $ time ./primes-test +RTS -N2 5001 real 0m15.282s user 0m15.165s sys 0m0.080s I'm confused. I know that `par` must be able work across modules boundaries, because Control.Parallel.Strategies is a module and presumably it works. What am I doing wrong? > module Main where > > import Control.Parallel > import Data.List (find) > import Data.Maybe (maybe) > > --import Parallelizable > parallelize a b = a `par` (b `pseq` (a, b)) > > test :: Integer -> Integer -> Integer > test n1 n2 = let (p1, p2) = parallelize > (product $ factors $ product [1..n1]) > (product $ factors $ product [1..n2]) > in p2 `div` p1 > > factors n = maybe [n] (\k-> (k : factors (n `div` k))) > (find (\k-> n `mod` k == 0) [2 .. n - 1]) > > main = print (test 5000 5001) From vigalchin at gmail.com Thu May 21 23:52:21 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Thu May 21 23:36:57 2009 Subject: [Haskell-cafe] HUnit In-Reply-To: <20090521232023.GO5994@whirlpool.galois.com> References: <5ae4f2ba0905211613o839f69ft701beab5ff365f5f@mail.gmail.com> <20090521232023.GO5994@whirlpool.galois.com> Message-ID: <5ae4f2ba0905212052w304d437bt4728a279ab266641@mail.gmail.com> my bad ... what about: vigalchin@ubuntu:~/FTP/Haskell/Swish-0.2.1$ cabal configure Configuring swish-0.2.1... cabal: At least the following dependencies are missing: hunit -any On Thu, May 21, 2009 at 6:20 PM, Don Stewart wrote: > vigalchin: > > Hello, > > > > I have some code with several test cases that use HUnit. I added > hunit as > > one of my cabal dependencies but cabal complained with: > > > > Setup: At least the following dependencies are missing: > > hutil -any > ^^^^^ > > Typo. > > -- Don > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090521/26fce015/attachment.html From keithshep at gmail.com Thu May 21 23:54:37 2009 From: keithshep at gmail.com (Keith Sheppard) Date: Thu May 21 23:39:14 2009 Subject: [Haskell-cafe] Re: ANN: TxtSushi 0.1 In-Reply-To: <92e42b740905170807w7693d6c1s6d178f3f7d624dbb@mail.gmail.com> References: <92e42b740905170807w7693d6c1s6d178f3f7d624dbb@mail.gmail.com> Message-ID: <92e42b740905212054k2b72ef9dk3cc66ed62173530c@mail.gmail.com> Hello, I just released TxtSushi 0.2 with the following updates: 1) Improved type coercion. Some of the rules I was using before did not make sense. At some point I will document what the rules are. 2) Added some extra functions/operators including a regex matcher. Here is the full list: SUBSTRING, UPPER, LOWER, TRIM, *, /, +, - (binary and unary), =, <> (not equal test), <, <=, >, >=, AND, OR, || (string concatination), =~ (regex matching) I expect updates to be pretty frequent (at least pre-1.0) so in order to avoid spamming you all with my announcements I'll just announce major updates from now on and if you want to follow progress more closely I'll post all updates to this feed. http://blog.keithsheppard.name/feeds/posts/default/-/TxtSushi Thanks, Keith On Sun, May 17, 2009 at 11:07 AM, Keith Sheppard wrote: > Hello Haskell Cafe > > I have released the first version of TxtSushi which is a collection of > command line utils (written in haskell of course) for processing > tab-delimited and CSV files. It includes a util for doing SQL SELECTs > on flat files. This is my first haskell project and feedback of all > kinds is appreciated. > > Home Page: http://www.keithsheppard.name/txt-sushi > Darcs Repository: http://patch-tag.com/r/txt-sushi/home > Issue Tracking: http://code.google.com/p/txt-sushi > > I would like to say thanks to the haskell-beginners contributors, the > author of "Learn you a Haskell" and the author of the parsec library > all of which were very helpful. > > Regards > Keith > From alexander.dunlap at gmail.com Fri May 22 00:07:34 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Thu May 21 23:53:20 2009 Subject: [Haskell-cafe] HUnit In-Reply-To: <5ae4f2ba0905212052w304d437bt4728a279ab266641@mail.gmail.com> References: <5ae4f2ba0905211613o839f69ft701beab5ff365f5f@mail.gmail.com> <20090521232023.GO5994@whirlpool.galois.com> <5ae4f2ba0905212052w304d437bt4728a279ab266641@mail.gmail.com> Message-ID: <57526e770905212107s736fdff5j83f5119754de7c3a@mail.gmail.com> I believe you need to capitalize it correctly: HUnit. Alex On Thu, May 21, 2009 at 8:52 PM, Vasili I. Galchin wrote: > my bad ... what about: > > vigalchin@ubuntu:~/FTP/Haskell/Swish-0.2.1$ cabal configure > Configuring swish-0.2.1... > cabal: At least the following dependencies are missing: > hunit -any > > > On Thu, May 21, 2009 at 6:20 PM, Don Stewart wrote: >> >> vigalchin: >> > Hello, >> > >> > ? ? I have some code with several test cases that use HUnit. I added >> > hunit as >> > one of my cabal dependencies but cabal complained with: >> > >> > Setup: At least the following dependencies are missing: >> > hutil -any >> ?^^^^^ >> >> Typo. >> >> -- Don > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From conal at conal.net Fri May 22 01:53:28 2009 From: conal at conal.net (Conal Elliott) Date: Fri May 22 01:38:25 2009 Subject: [Haskell-cafe] the problem of design by negation In-Reply-To: <4A148A42.9030205@alumni.caltech.edu> References: <4A148A42.9030205@alumni.caltech.edu> Message-ID: Hi Michael, I'm going to hazard a guess. Please let me know how accurate it is. When asked to justify his design, the lead software architect explains > everything that *wouldn't* work. "We couldn't have a unique key for every > entry because blah blah blah. We couldn't use a garbage collector because > blah blah. We couldn't write a sugar layer because then you have to document > it separately blah blah." So the chosen design seems to be the only thing > left after eliminating everything you can't do. > My guess is that your software architect is making flimsy arguments. It's usually very difficult to prove that something *wouldn't* work. In my experience, people make blanket statements about what cannot work, when the truth is that they just don't know how and don't have the imagination or will even to entertain the possibility of ways that they can't yet see. Instead of using logic and evidence, these people bolster their claims (often mistakenly called "arguments") by putting across confident language ("obviously", "clearly", "without a doubt"), body posture, facial expression, and voice tone. When someone is on solid ground, these bravado tactics are unnecessary. (I think of "obviously", etc as words that are useful only when inaccurate. See http://conal.net/blog/posts/fostering-creativity-by-relinquishing-the-obvious/.) One flimsy argument I often hear is "It wouldn't work because how ...", or "because what ...". As if a question were an argument. I call this rather popular tactic "proof by ignorance" or "proof by lack of imagination". I don't know where people get the idea that this sort of thing is rational. If I'm ever tempted to give it any weight, I think of Arthur Hoppe's proof of the existence of God: "If there's no God, then who pops up the next kleenex?" Some of my favorite quotes on this dynamic: "Doubt is not a pleasant condition, but certainty is absurd." - Voltaire "They are ill discoverers that think there is no land, when they can see nothing but sea." - Francis Bacon "To be positive: To be mistaken at the top of one's voice." Ambrose Bierce "The greatest obstacle to discovering the shape of the earth, the continents, and the oceans was not ignorance but the illusion of knowledge." - Daniel J. Boorstin One thing you may try is to ask the architect for evidence and/or logical proof of his claims that something cannot work. As much as you can, ask from a place of curiosity and even awe. After all, existence can often be proved by demonstrating an example, while non-existence proofs tend to be much more profound. And stick to your open-minded disbelief until you really see evidence or logical rigor. If the architect gets flustered and embarrassed, he may well go on the attack. After all, bravado signals weak ego, which can quickly become a cornered animal. So pay attention to his stress level, and help his salvage his ego, by suggesting he let you know more about the evidence and/or logic when he's worked it out. Be careful to stay in your integrity, neither going along with someone's forcefulness, nor representing yourself as having more grounds for confidence than you really do. Whether or not my guess is accurate or my advice relevant, good luck! I'd love to hear how this situation develops. - Conal On Wed, May 20, 2009 at 3:54 PM, Michael Mossey wrote: > This is not directly related to Haskell, but it's a thought that occurred > to me after exposure to the Haskell community. > > I've spent most of the past 15 years doing scientific programming. The lead > software architect and software managers are using good software engineering > practice, though (this is *scientific* programming, not *programming by > scientists*, ha ha). But, there is a particular culture in my company that > has become more obvious to me by contrast to the Haskell community. > > I call it "design by negation." When asked to justify his design, the lead > software architect explains everything that *wouldn't* work. "We couldn't > have a unique key for every entry because blah blah blah. We couldn't use a > garbage collector because blah blah. We couldn't write a sugar layer because > then you have to document it separately blah blah." So the chosen design > seems to be the only thing left after eliminating everything you can't do. > > I want to aspire to "positive design." I want to list the goals, and think > of design as making clever choices that meet all the goals. > > I don't mean to suggest that design is never constrained. It often is. But > it's a mindset I'm talking about. I don't like this mindset of design by > negation. > > -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/20090522/90050904/attachment-0001.html From dagit at codersbase.com Fri May 22 02:04:36 2009 From: dagit at codersbase.com (Jason Dagit) Date: Fri May 22 01:49:10 2009 Subject: [Haskell-cafe] the problem of design by negation In-Reply-To: References: <4A148A42.9030205@alumni.caltech.edu> Message-ID: On Thu, May 21, 2009 at 10:53 PM, Conal Elliott wrote: > > One thing you may try is to ask the architect for evidence and/or logical > proof of his claims that something cannot work.? As much as you can, ask > from a place of curiosity and even awe.? After all, existence can often be > proved by demonstrating an example, while non-existence proofs tend to be > much more profound.? And stick to your open-minded disbelief until you > really see evidence or logical rigor.? If the architect gets flustered and > embarrassed, he may well go on the attack.? After all, bravado signals weak > ego, which can quickly become a cornered animal.? So pay attention to his > stress level, and help his salvage his ego, by suggesting he let you know > more about the evidence and/or logic when he's worked it out.? Be careful to > stay in your integrity, neither going along with someone's forcefulness, nor > representing yourself as having more grounds for confidence than you really > do. > Thanks Conal for that sagely advice. I recently asked my local conversation expert how to deal with passive aggressive people/managers, and he gave similar advice. He said that when someone is dragging their feet or providing excuses, change the conversation into one about problem solving. Instead of continuing to make the request, ask what it would take for the request to be possible. I think your advice is exactly that, just in a slightly different context. Also, in the times when the speaker understands the problem better than myself, I tend to learn something new about the problem domain that, whether it is a show stopper or not, is a significant issue to address. Thanks, Jason From magnus at therning.org Fri May 22 02:33:49 2009 From: magnus at therning.org (Magnus Therning) Date: Fri May 22 02:18:25 2009 Subject: Putting unit tests in cabal files (Was Re: [Haskell-cafe] HUnit) Message-ID: On Fri, May 22, 2009 at 12:13 AM, Vasili I. Galchin wrote: > Hello, > > ??? I have some code with several test cases that use HUnit. I added hunit > as one of my cabal dependencies but cabal complained with: > > Setup: At least the following dependencies are missing: > hutil -any > > What am I doing incorrectly? Would you mind posting your .cabal file too? The reson I'm asking is that I've so far _never_ put any information about unit tests or quickcheck tests in my .cabal file, simply because I don't want the executables to be picked up by automatic package converters such as cabal2arch. Instead I have a makefile for building my test programs. If you have some way of keeping information about building of tests in your .cabal I'd be very interested in seeing it. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From conal at conal.net Fri May 22 02:34:03 2009 From: conal at conal.net (Conal Elliott) Date: Fri May 22 02:19:30 2009 Subject: [Haskell-cafe] the problem of design by negation In-Reply-To: References: <4A148A42.9030205@alumni.caltech.edu> Message-ID: > > One flimsy argument I often hear is "It wouldn't work because how ...", or > "because what ...". As if a question were an argument. I call this rather > popular tactic "proof by ignorance" or "proof by lack of imagination". > [...] I just remembered another popular variation on this bogus "argument". If you question someone's claim of impossibility (or "the only possibility"), they may retort: "Well, then how would you do it?" The Game here is that if you don't have an answer, the other guy is right! I don't know why people perpetrate and fall for this game. One response I like is to affirm the question. "Yeah, how indeed! Anyone have some creative ideas? Who wants to brainstorm?" I gather that some people are terribly uncomfortable without certainty. If you take away their certainty, they demand an immediate replacement! These folks will suck the creativity out of a room if they can, because creativity requires curiosity, and curiosity requires willingness not to know. - Conal On Thu, May 21, 2009 at 10:53 PM, Conal Elliott wrote: > Hi Michael, > > I'm going to hazard a guess. Please let me know how accurate it is. > > When asked to justify his design, the lead software architect explains >> everything that *wouldn't* work. "We couldn't have a unique key for every >> entry because blah blah blah. We couldn't use a garbage collector because >> blah blah. We couldn't write a sugar layer because then you have to document >> it separately blah blah." So the chosen design seems to be the only thing >> left after eliminating everything you can't do. >> > > My guess is that your software architect is making flimsy arguments. It's > usually very difficult to prove that something *wouldn't* work. In my > experience, people make blanket statements about what cannot work, when the > truth is that they just don't know how and don't have the imagination or > will even to entertain the possibility of ways that they can't yet see. > Instead of using logic and evidence, these people bolster their claims > (often mistakenly called "arguments") by putting across confident language > ("obviously", "clearly", "without a doubt"), body posture, facial > expression, and voice tone. When someone is on solid ground, these bravado > tactics are unnecessary. (I think of "obviously", etc as words that are > useful only when inaccurate. See > http://conal.net/blog/posts/fostering-creativity-by-relinquishing-the-obvious/.) > > One flimsy argument I often hear is "It wouldn't work because how ...", or > "because what ...". As if a question were an argument. I call this rather > popular tactic "proof by ignorance" or "proof by lack of imagination". I > don't know where people get the idea that this sort of thing is rational. > If I'm ever tempted to give it any weight, I think of Arthur Hoppe's proof > of the existence of God: "If there's no God, then who pops up the next > kleenex?" > > Some of my favorite quotes on this dynamic: > > "Doubt is not a pleasant condition, but certainty is absurd." - > Voltaire > > "They are ill discoverers that think there is no land, when they can > see nothing but sea." - Francis Bacon > > "To be positive: To be mistaken at the top of one's voice." Ambrose > Bierce > > "The greatest obstacle to discovering the shape of the earth, the > continents, and the oceans was not ignorance but the illusion of knowledge." > - Daniel J. Boorstin > > > One thing you may try is to ask the architect for evidence and/or logical > proof of his claims that something cannot work. As much as you can, ask > from a place of curiosity and even awe. After all, existence can often be > proved by demonstrating an example, while non-existence proofs tend to be > much more profound. And stick to your open-minded disbelief until you > really see evidence or logical rigor. If the architect gets flustered and > embarrassed, he may well go on the attack. After all, bravado signals weak > ego, which can quickly become a cornered animal. So pay attention to his > stress level, and help his salvage his ego, by suggesting he let you know > more about the evidence and/or logic when he's worked it out. Be careful to > stay in your integrity, neither going along with someone's forcefulness, nor > representing yourself as having more grounds for confidence than you really > do. > > > Whether or not my guess is accurate or my advice relevant, good luck! I'd > love to hear how this situation develops. > > - Conal > > > > On Wed, May 20, 2009 at 3:54 PM, Michael Mossey wrote: > >> This is not directly related to Haskell, but it's a thought that occurred >> to me after exposure to the Haskell community. >> >> I've spent most of the past 15 years doing scientific programming. The >> lead software architect and software managers are using good software >> engineering practice, though (this is *scientific* programming, not >> *programming by scientists*, ha ha). But, there is a particular culture in >> my company that has become more obvious to me by contrast to the Haskell >> community. >> >> I call it "design by negation." When asked to justify his design, the lead >> software architect explains everything that *wouldn't* work. "We couldn't >> have a unique key for every entry because blah blah blah. We couldn't use a >> garbage collector because blah blah. We couldn't write a sugar layer because >> then you have to document it separately blah blah." So the chosen design >> seems to be the only thing left after eliminating everything you can't do. >> >> I want to aspire to "positive design." I want to list the goals, and think >> of design as making clever choices that meet all the goals. >> >> I don't mean to suggest that design is never constrained. It often is. But >> it's a mindset I'm talking about. I don't like this mindset of design by >> negation. >> >> -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/20090522/0937d42e/attachment.html From conal at conal.net Fri May 22 02:41:36 2009 From: conal at conal.net (Conal Elliott) Date: Fri May 22 02:26:31 2009 Subject: [Haskell-cafe] the problem of design by negation In-Reply-To: References: <4A148A42.9030205@alumni.caltech.edu> Message-ID: > > Instead of continuing to > make the request, ask what it would take for the request to be > possible. > Thanks, Jason. I like this shift. It moves the dynamic away from a tightly confined yes/no (and often win/lose) to an expansive *how*. It welcomes collaboration in finding something better than either yes or no to the original request, in that both/all parties' needs can be addressed, not just one. - Conal On Thu, May 21, 2009 at 11:04 PM, Jason Dagit wrote: > On Thu, May 21, 2009 at 10:53 PM, Conal Elliott wrote: > > > > > One thing you may try is to ask the architect for evidence and/or logical > > proof of his claims that something cannot work. As much as you can, ask > > from a place of curiosity and even awe. After all, existence can often > be > > proved by demonstrating an example, while non-existence proofs tend to be > > much more profound. And stick to your open-minded disbelief until you > > really see evidence or logical rigor. If the architect gets flustered > and > > embarrassed, he may well go on the attack. After all, bravado signals > weak > > ego, which can quickly become a cornered animal. So pay attention to his > > stress level, and help his salvage his ego, by suggesting he let you know > > more about the evidence and/or logic when he's worked it out. Be careful > to > > stay in your integrity, neither going along with someone's forcefulness, > nor > > representing yourself as having more grounds for confidence than you > really > > do. > > > > Thanks Conal for that sagely advice. > > I recently asked my local conversation expert how to deal with passive > aggressive people/managers, and he gave similar advice. He said that > when someone is dragging their feet or providing excuses, change the > conversation into one about problem solving. Instead of continuing to > make the request, ask what it would take for the request to be > possible. I think your advice is exactly that, just in a slightly > different context. > > Also, in the times when the speaker understands the problem better > than myself, I tend to learn something new about the problem domain > that, whether it is a show stopper or not, is a significant issue to > address. > > Thanks, > Jason > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090522/ee100c43/attachment.html From mpm at alumni.caltech.edu Fri May 22 03:35:34 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Fri May 22 03:20:23 2009 Subject: [Haskell-cafe] the problem of design by negation In-Reply-To: References: <4A148A42.9030205@alumni.caltech.edu> Message-ID: <4A1655C6.6060309@alumni.caltech.edu> Conal Elliott wrote: > Hi Michael, > > I'm going to hazard a guess. Please let me know how accurate it is. Conal, I think you described this situation well. You must know this kind of person---I'm sure there's more than one in the world! > > When asked to justify his design, the lead software architect explains > everything that *wouldn't* work. "We couldn't have a unique key for > every entry because blah blah blah. We couldn't use a garbage collector > because blah blah. We couldn't write a sugar layer because then you have > to document it separately blah blah." So the chosen design seems to be > the only thing left after eliminating everything you can't do. > > > My guess is that your software architect is making flimsy arguments. > It's usually very difficult to prove that something *wouldn't* work. In > my experience, people make blanket statements about what cannot work, > when the truth is that they just don't know how and don't have the > imagination or will even to entertain the possibility of ways that they > can't yet see. Yes, that's the impression I get from this guy. His personality causes him to derive absolute rules or blanket statements from experience, instead of a more gentle kind of wisdom. The more experience he gets, the more he's full of constraining rules. So I really did mean to say that his design is the ONLY thing possible after eliminating everything that won't fit with his rules. > Instead of using logic and evidence, these people bolster their claims > (often mistakenly called "arguments") by putting across confident > language ("obviously", "clearly", "without a doubt"), body posture, > facial expression, and voice tone. When someone is on solid ground, > these bravado tactics are unnecessary. You got it---the guy is great at winning debates because he is very confident and can so quickly poke holes (what *seem* to be holes) in any other position. Moreover, his confidence is why he is lead software architect... managers are impressed by alpha males and tend to be alpha males themselves. > > Some of my favorite quotes on this dynamic: > > "Doubt is not a pleasant condition, but certainty is absurd." - Voltaire > > > "They are ill discoverers that think there is no land, when they can see > nothing but sea." - Francis Bacon > > "To be positive: To be mistaken at the top of one's voice." Ambrose > Bierce > > "The greatest obstacle to discovering the shape of the earth, the > continents, and the oceans was not ignorance but the illusion of > knowledge." - Daniel J. Boorstin Good quotes. I was trying to get across this idea of imagination, creativity, finding solutions in unlikely places. Here's another one: "The whole trouble with the world is that fools and fanatics are always so certain of themselves, and wiser people, always so full of doubts." - Bertrand Russell > > One thing you may try is to ask the architect for evidence > and/or logical proof of his claims that something cannot work. As much > as you can, ask from a place of curiosity and even awe. After all, > existence can often be proved by demonstrating an example, while > non-existence proofs tend to be much more profound. And stick to your > open-minded disbelief until you really see evidence or logical rigor. > If the architect gets flustered and embarrassed, he may well go on the > attack. After all, bravado signals weak ego, which can quickly become a > cornered animal. So pay attention to his stress level, and help his > salvage his ego, by suggesting he let you know more about the evidence > and/or logic when he's worked it out. Be careful to stay in your > integrity, neither going along with someone's forcefulness, nor > representing yourself as having more grounds for confidence than you > really do. That's good advice. I'm not sure how well this situation can work because I'm one of these people who is "full of doubts," which I regard as ultimately a positive trait, but it makes me poor at debate. (I know you are not suggesting I "debate" him, but he wants to turn everything into a debate, and it takes a very level-headed outgoing person to keep up with him.) The best result from this experience is that I can improve my *own* design process. For example, I'm working on a personal project related to music, and after a few weeks of design, I realized that my thinking had turned into design by negation. I felt unhappy with every choice, and started to think of the design as the unhappy, but least unhappy, compromise. This is probably an old habit of mine. So I want to shift my thinking, by listing goals for the design, and finding ways to meet all of them. Win-win instead of lose-lose. Based on a previous reply, I think some people think this sounds like vapid cheerleading, but I think you would agree with me that life (and software) always offers more possibilities when we engage our imagination with hope and energy, not giving up too soon, being willing to sit with problems for a time without a definite conclusion. Thanks, Mike From duncan.coutts at worc.ox.ac.uk Fri May 22 04:49:53 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri May 22 04:34:41 2009 Subject: [Haskell-cafe] Introducing Instances in GHC point releases In-Reply-To: <4A160E40.8090404@complete.org> References: <20090515065337.GA356@whirlpool.galois.com> <4A15CD56.20505@complete.org> <57526e770905211522k2041f7cdoc4b96f893335c2f0@mail.gmail.com> <1242945262.20307.61.camel@localhost> <4A160E40.8090404@complete.org> Message-ID: <1242982193.20307.76.camel@localhost> On Thu, 2009-05-21 at 21:30 -0500, John Goerzen wrote: > Duncan Coutts wrote: > > On Thu, 2009-05-21 at 15:22 -0700, Alexander Dunlap wrote: > >> Since those types come out of the time library, and that library's > >> version *has* been bumped (I assume), couldn't you use Cabal to > >> condition on the version of the time library to determine whether or > >> not to have CPP set a -DTYPEABLE_IN_TIME flag, and then #ifdef out > >> your versions of the instances? > > > > I was about to suggest this: > > > > #if MIN_VERSION_time(1,1,2) > > ... > > #endif > > That would be slick. I'll give that a whirl. What version of Cabal > does GHC 6.8 come from, 1.2.x > and where can I read about the above feature? The user guide, section "Creating a package", subsection "Conditional compilation": http://haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#cpp > I imagine I may have to wrap the above in a __GLASGOW_HASKELL__ test for > GHC 6.8 or something. Again, there's no direct relationship between the version of ghc and the version of Cabal (though there is some correlation). > Though if *cabal* and not GHC generates it, isn't that a bit hurting to > my portability? (Can't just ghc --make with it, or ghci on it directly > anymore, etc.) True. People have been asking for a way to get cabal to invoke ghci with all the right flags, which is a reasonable idea. > > because Cabal 1.6+ generates these cpp macros for you. Note that relying > > on the value of __GLASGOW_HASKELL__ would be wrong because the version > > of the time library is not directly related to the version of ghc. > > Yeah, but when you've got nothing else to go on, it sometimes works in a > pinch. Aye, it's ok for the people you don't upgrade things separately, and those people are less likely to be able to work out how to fix things. > I guess my larger point is just a plea to the community: please be > really careful about what you do to GHC in point releases. This is not > the first issue that has screwed me in the GHC 6.10.x point releases. > > GHC (and the community) used to be really good about this. Is there > something causing a regression here, or is it my imagination? Yes, we're loosening the connection between ghc and the non-core packages, so that package maintainers make releases rather than the ghc maintainers doing so. What we're currently missing is a PVP checker: a tool to compare APIs of package versions and check that it is following the PVP. Ideally, we will have packages opt-in to follow the PVP for those packages that do opt-in we have the PVP enforced on hackage using the checker tool. Since the HP is almost certainly going to require packages to follow the PVP then this should eliminate this class of mistakes. But it does need the tool, and nobody is working on that at the moment. Duncan From nccb2 at kent.ac.uk Fri May 22 05:15:21 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Fri May 22 04:59:47 2009 Subject: [Haskell-cafe] Introducing Instances in GHC point releases In-Reply-To: <1242982193.20307.76.camel@localhost> References: <20090515065337.GA356@whirlpool.galois.com> <4A15CD56.20505@complete.org> <57526e770905211522k2041f7cdoc4b96f893335c2f0@mail.gmail.com> <1242945262.20307.61.camel@localhost> <4A160E40.8090404@complete.org> <1242982193.20307.76.camel@localhost> Message-ID: <4A166D29.1050308@kent.ac.uk> Duncan Coutts wrote: > What we're currently missing is a PVP checker: a tool to compare APIs of > package versions and check that it is following the PVP. Ideally, we > will have packages opt-in to follow the PVP for those packages that do > opt-in we have the PVP enforced on hackage using the checker tool. Since > the HP is almost certainly going to require packages to follow the PVP > then this should eliminate this class of mistakes. But it does need the > tool, and nobody is working on that at the moment. > Recently, I wanted to compare two branches of one of my libraries to see what API changes I had made. My low-tech solution was to do a two-line hack on haddock so that it sorts the modules before generating Hoogle documentation, and then to compare (with diff) the two hoogle documentation files between the branches. The Hoogle format just seems to be a list of definitions with types, classes and instances -- so it seems to fit the bill. I imagine it's not foolproof, but perhaps this could be a quick fix, at least as a heuristic for a package maintainer ("hoogle-diff suggests you may have altered something, please check before continuing to upload")? Thanks, Neil. From schlepptop at henning-thielemann.de Fri May 22 08:04:20 2009 From: schlepptop at henning-thielemann.de (Henning Thielemann) Date: Fri May 22 07:48:04 2009 Subject: [Haskell-cafe] Introducing Instances in GHC point releases In-Reply-To: <4A15CD56.20505@complete.org> References: <20090515065337.GA356@whirlpool.galois.com> <4A15CD56.20505@complete.org> Message-ID: <4A1694C4.6060903@henning-thielemann.de> John Goerzen schrieb: > So this is annoying (CCing -cafe) > > I need NominalDiffTime and UTCTime to have Typeable instances. In > 6.10.1, they didn't ship with them out of the box, so I added them. > Apparently, in 6.10.3, they DO ship with those instances out of the box. > > Annoyingly, that means that my code breaks on 6.10.3. After having conflicting instances several times with some types in the past, I came to the conclusion that I should never define orphan instances. Can you restrict your package to 6.10.3 where an "official" instance is available? http://www.haskell.org/haskellwiki/Orphan_instance From daniel.is.fischer at web.de Fri May 22 08:04:58 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri May 22 07:50:09 2009 Subject: [Haskell-cafe] A problem with par and modules boundaries... In-Reply-To: <.1242961191@magma.ca> References: <.1242961191@magma.ca> Message-ID: <200905221404.59102.daniel.is.fischer@web.de> Am Freitag 22 Mai 2009 04:59:51 schrieb Mario Bla?evi?: > I'll cut to the chase. The short program below works perfectly: when I > compile it with -O2 -threaded and run with +RTS -N2 command-line options, I > get a nearly 50% real-time improvement: > > $ time ./primes-test +RTS -N2 > 5001 > > real 0m9.307s > user 0m16.581s > sys 0m0.200s > > However, if I move the `parallelize' definition into another module and > import that module, the performance is completely lost: > > $ time ./primes-test +RTS -N2 > 5001 > > real 0m15.282s > user 0m15.165s > sys 0m0.080s > > I'm confused. I know that `par` must be able work across modules > boundaries, because Control.Parallel.Strategies is a module and presumably > it works. What am I doing wrong? > You forgot {-# INLINE parallelize #-} For me, that works. > > module Main where > > > > import Control.Parallel > > import Data.List (find) > > import Data.Maybe (maybe) > > > > --import Parallelizable > > parallelize a b = a `par` (b `pseq` (a, b)) > > > > test :: Integer -> Integer -> Integer > > test n1 n2 = let (p1, p2) = parallelize > > (product $ factors $ product [1..n1]) > > (product $ factors $ product [1..n2]) > > in p2 `div` p1 > > > > factors n = maybe [n] (\k-> (k : factors (n `div` k))) > > (find (\k-> n `mod` k == 0) [2 .. n - 1]) > > > > main = print (test 5000 5001) From schlepptop at henning-thielemann.de Fri May 22 08:08:22 2009 From: schlepptop at henning-thielemann.de (Henning Thielemann) Date: Fri May 22 07:52:30 2009 Subject: Putting unit tests in cabal files (Was Re: [Haskell-cafe] HUnit) In-Reply-To: References: Message-ID: <4A1695B6.3070703@henning-thielemann.de> Magnus Therning schrieb: > On Fri, May 22, 2009 at 12:13 AM, Vasili I. Galchin wrote: >> Hello, >> >> I have some code with several test cases that use HUnit. I added hunit >> as one of my cabal dependencies but cabal complained with: >> >> Setup: At least the following dependencies are missing: >> hutil -any >> >> What am I doing incorrectly? > > Would you mind posting your .cabal file too? > > The reson I'm asking is that I've so far _never_ put any information > about unit tests or quickcheck tests in my .cabal file, simply because > I don't want the executables to be picked up by automatic package > converters such as cabal2arch. Instead I have a makefile for building > my test programs. > > If you have some way of keeping information about building of tests in > your .cabal I'd be very interested in seeing it. I define and use Cabal flag buildTests and use Executable test If flag(buildTests) Build-Depends: HUnit Else Buildable: False From dons at galois.com Fri May 22 08:30:15 2009 From: dons at galois.com (Don Stewart) Date: Fri May 22 08:16:19 2009 Subject: [Haskell-cafe] A problem with par and modules boundaries... In-Reply-To: <200905221404.59102.daniel.is.fischer@web.de> References: <.1242961191@magma.ca> <200905221404.59102.daniel.is.fischer@web.de> Message-ID: <20090522123015.GT5994@whirlpool.galois.com> Answer recorded at: http://haskell.org/haskellwiki/Performance/Parallel daniel.is.fischer: > Am Freitag 22 Mai 2009 04:59:51 schrieb Mario Bla?evi?: > > I'll cut to the chase. The short program below works perfectly: when I > > compile it with -O2 -threaded and run with +RTS -N2 command-line options, I > > get a nearly 50% real-time improvement: > > > > $ time ./primes-test +RTS -N2 > > 5001 > > > > real 0m9.307s > > user 0m16.581s > > sys 0m0.200s > > > > However, if I move the `parallelize' definition into another module and > > import that module, the performance is completely lost: > > > > $ time ./primes-test +RTS -N2 > > 5001 > > > > real 0m15.282s > > user 0m15.165s > > sys 0m0.080s > > > > I'm confused. I know that `par` must be able work across modules > > boundaries, because Control.Parallel.Strategies is a module and presumably > > it works. What am I doing wrong? > > > > You forgot > > {-# INLINE parallelize #-} > > For me, that works. > > > > module Main where > > > > > > import Control.Parallel > > > import Data.List (find) > > > import Data.Maybe (maybe) > > > > > > --import Parallelizable > > > parallelize a b = a `par` (b `pseq` (a, b)) > > > > > > test :: Integer -> Integer -> Integer > > > test n1 n2 = let (p1, p2) = parallelize > > > (product $ factors $ product [1..n1]) > > > (product $ factors $ product [1..n2]) > > > in p2 `div` p1 > > > > > > factors n = maybe [n] (\k-> (k : factors (n `div` k))) > > > (find (\k-> n `mod` k == 0) [2 .. n - 1]) > > > > > > main = print (test 5000 5001) > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dons at galois.com Fri May 22 08:35:02 2009 From: dons at galois.com (Don Stewart) Date: Fri May 22 08:21:19 2009 Subject: [Haskell-cafe] Introducing Instances in GHC point releases In-Reply-To: <1242982193.20307.76.camel@localhost> References: <20090515065337.GA356@whirlpool.galois.com> <4A15CD56.20505@complete.org> <57526e770905211522k2041f7cdoc4b96f893335c2f0@mail.gmail.com> <1242945262.20307.61.camel@localhost> <4A160E40.8090404@complete.org> <1242982193.20307.76.camel@localhost> Message-ID: <20090522123502.GU5994@whirlpool.galois.com> duncan.coutts: > What we're currently missing is a PVP checker: a tool to compare APIs of > package versions and check that it is following the PVP. Ideally, we > will have packages opt-in to follow the PVP for those packages that do > opt-in we have the PVP enforced on hackage using the checker tool. Since > the HP is almost certainly going to require packages to follow the PVP > then this should eliminate this class of mistakes. But it does need the > tool, and nobody is working on that at the moment. If I recall correct, CosmicRay wrote just such a thing (or similar to it) a while ago. John? -- Don From jgoerzen at complete.org Fri May 22 08:55:29 2009 From: jgoerzen at complete.org (John Goerzen) Date: Fri May 22 08:40:09 2009 Subject: [Haskell-cafe] Introducing Instances in GHC point releases In-Reply-To: <20090522123502.GU5994@whirlpool.galois.com> References: <20090515065337.GA356@whirlpool.galois.com> <4A15CD56.20505@complete.org> <57526e770905211522k2041f7cdoc4b96f893335c2f0@mail.gmail.com> <1242945262.20307.61.camel@localhost> <4A160E40.8090404@complete.org> <1242982193.20307.76.camel@localhost> <20090522123502.GU5994@whirlpool.galois.com> Message-ID: <4A16A0C1.9030505@complete.org> Don Stewart wrote: > duncan.coutts: >> What we're currently missing is a PVP checker: a tool to compare APIs of >> package versions and check that it is following the PVP. Ideally, we >> will have packages opt-in to follow the PVP for those packages that do >> opt-in we have the PVP enforced on hackage using the checker tool. Since >> the HP is almost certainly going to require packages to follow the PVP >> then this should eliminate this class of mistakes. But it does need the >> tool, and nobody is working on that at the moment. > > If I recall correct, CosmicRay wrote just such a thing (or similar to > it) a while ago. > > John? Nope, that wasn't me. Maybe the other John? > > -- Don > From mblazevic at stilo.com Fri May 22 09:11:32 2009 From: mblazevic at stilo.com (Mario Blazevic) Date: Fri May 22 08:56:09 2009 Subject: [Haskell-cafe] A problem with par and modules boundaries... In-Reply-To: <200905221404.59102.daniel.is.fischer@web.de> References: <.1242961191@magma.ca> <200905221404.59102.daniel.is.fischer@web.de> Message-ID: <4A16A484.9080304@stilo.com> Daniel Fischer wrote: > Am Freitag 22 Mai 2009 04:59:51 schrieb Mario Bla?evi?: >> ... >> I'm confused. I know that `par` must be able work across modules >> boundaries, because Control.Parallel.Strategies is a module and presumably >> it works. What am I doing wrong? >> > > You forgot > > {-# INLINE parallelize #-} > > For me, that works. That's great, thank you. I am still baffled, though. Must every exported function that uses `par' be INLINEd? Does every exported caller of such a function need the same treatment? Is `par' really a macro, rather than a function? >>> module Main where >>> >>> import Control.Parallel >>> import Data.List (find) >>> import Data.Maybe (maybe) >>> >>> --import Parallelizable >>> parallelize a b = a `par` (b `pseq` (a, b)) >>> >>> test :: Integer -> Integer -> Integer >>> test n1 n2 = let (p1, p2) = parallelize >>> (product $ factors $ product [1..n1]) >>> (product $ factors $ product [1..n2]) >>> in p2 `div` p1 >>> >>> factors n = maybe [n] (\k-> (k : factors (n `div` k))) >>> (find (\k-> n `mod` k == 0) [2 .. n - 1]) >>> >>> main = print (test 5000 5001) > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Mario Blazevic mblazevic@stilo.com Stilo Corporation This message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure, copying, or distribution is strictly prohibited. If you are not the intended recipient(s) please contact the sender by reply email and destroy all copies of the original message and any attachments. From jgoerzen at complete.org Fri May 22 09:26:21 2009 From: jgoerzen at complete.org (John Goerzen) Date: Fri May 22 09:10:56 2009 Subject: [Haskell-cafe] Introducing Instances in GHC point releases In-Reply-To: <4A1694C4.6060903@henning-thielemann.de> References: <20090515065337.GA356@whirlpool.galois.com> <4A15CD56.20505@complete.org> <4A1694C4.6060903@henning-thielemann.de> Message-ID: <4A16A7FD.3080105@complete.org> Henning Thielemann wrote: > John Goerzen schrieb: >> So this is annoying (CCing -cafe) >> >> I need NominalDiffTime and UTCTime to have Typeable instances. In >> 6.10.1, they didn't ship with them out of the box, so I added them. >> Apparently, in 6.10.3, they DO ship with those instances out of the box. >> >> Annoyingly, that means that my code breaks on 6.10.3. > > After having conflicting instances several times with some types in the > past, I came to the conclusion that I should never define orphan > instances. Can you restrict your package to 6.10.3 where an "official" > instance is available? > > http://www.haskell.org/haskellwiki/Orphan_instance > I didn't care about presenting the instance to people using my library, but the instance was necessary within the library itself, and led to the compilation error. -- John From magnus at therning.org Fri May 22 10:23:30 2009 From: magnus at therning.org (Magnus Therning) Date: Fri May 22 10:08:05 2009 Subject: Putting unit tests in cabal files (Was Re: [Haskell-cafe] HUnit) In-Reply-To: <4A1695B6.3070703@henning-thielemann.de> References: <4A1695B6.3070703@henning-thielemann.de> Message-ID: On Fri, May 22, 2009 at 1:08 PM, Henning Thielemann wrote: > Magnus Therning schrieb: >> On Fri, May 22, 2009 at 12:13 AM, Vasili I. Galchin wrote: >>> Hello, >>> >>> ? ? I have some code with several test cases that use HUnit. I added hunit >>> as one of my cabal dependencies but cabal complained with: >>> >>> Setup: At least the following dependencies are missing: >>> hutil -any >>> >>> What am I doing incorrectly? >> >> Would you mind posting your .cabal file too? >> >> The reson I'm asking is that I've so far _never_ put any information >> about unit tests or quickcheck tests in my .cabal file, simply because >> I don't want the executables to be picked up by automatic package >> converters such as cabal2arch. ?Instead I have a makefile for building >> my test programs. >> >> If you have some way of keeping information about building of tests in >> your .cabal I'd be very interested in seeing it. > > I define and use Cabal flag buildTests and use > > Executable test > ?If flag(buildTests) > ? ?Build-Depends: HUnit > ?Else > ? ?Buildable: False Ah, didn't think of that, I've only ever tried if flag(buildTests) executable but then cabal complains loudly about the if statement's location. Now I can try to take this a bit further to see if I can get rid of that ugly makefile altogether. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From wrwills at gmail.com Fri May 22 10:26:13 2009 From: wrwills at gmail.com (Robert Wills) Date: Fri May 22 10:10:47 2009 Subject: [Haskell-cafe] haskellnet In-Reply-To: <404396ef0905140637w45018f36m3d2f69c2b1e16650@mail.gmail.com> References: <404396ef0905140637w45018f36m3d2f69c2b1e16650@mail.gmail.com> Message-ID: I tried contacting Jun Mukai at the email address given in the package but I haven't heard a reply. Just to get this out of the way I've put my darcs repository with the changes I've made up on my website. It should build and install with: darcs get http://www.dicta.org.uk/website/website/haskellnet cabal configure cabal build cabal install I've added some examples of using smtp, pop3 and imap to the examples directory. They seem to work against the mail servers that I have access to. I've also removed some modules from haskellnet which are now covered elswhere in hackage: eg. http, browser, json I'll put in a request to get a username on hackage so I can upload it-- unless anyone has any objections. -Rob On Thu, May 14, 2009 at 2:37 PM, Neil Mitchell wrote: > Hi > > Email the original author, if you can. Ideally work with them to > upload a working version to hackage. If they're not interested > hopefully they'll make you the new maintainer. If you can't contact > them, just upload a new version anyway - as long as it's done for the > benefit of the community and not with malicious intent, everyone is > happy. > > And please do make sure you upload something working, I imagine this > will be very useful to lots of people! > > Thanks for your efforts > > Neil > > On Thu, May 14, 2009 at 12:51 PM, Robert Wills wrote: >> Hello, >> >> Yesterday I found myself wanting to clear out a spam-ridden pop >> account without downloading all the messages. Rather than just using >> Python's poplib, I thought I might look for a haskell solution and >> came across Haskellnet: >> http://darcs.haskell.org/SoC/haskellnet/ >> >> I ended up spending much of the afternoon getting it to compile and >> much of last night trying to get the pop library to actually work (the >> 'strip' method produced exceptions). ?It was a good learning >> experience (this was helpful: >> http://donsbot.wordpress.com/2007/11/14/no-more-exceptions-debugging-haskell-code-with-ghci/). >> >> I'm writing here because I'm wondering whether it would be worthwhile >> putting it up on hackage? From searching this list, there seem to have >> been a few times when people have stumbled across it but got >> frustrated when it didn't compile. ?If so, what's the protocol? Is the >> original author, Jun Mukai, still around? >> >> Thanks, >> Rob >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From daniel.is.fischer at web.de Fri May 22 10:34:18 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri May 22 10:19:29 2009 Subject: [Haskell-cafe] A problem with par and modules boundaries... In-Reply-To: <4A16A484.9080304@stilo.com> References: <.1242961191@magma.ca> <200905221404.59102.daniel.is.fischer@web.de> <4A16A484.9080304@stilo.com> Message-ID: <200905221634.19133.daniel.is.fischer@web.de> Am Freitag 22 Mai 2009 15:11:32 schrieb Mario Blazevic: > Daniel Fischer wrote: > > Am Freitag 22 Mai 2009 04:59:51 schrieb Mario Bla?evi?: > >> ... > >> I'm confused. I know that `par` must be able work across modules > >> boundaries, because Control.Parallel.Strategies is a module and > >> presumably it works. What am I doing wrong? > > > > You forgot > > > > {-# INLINE parallelize #-} > > > > For me, that works. > > That's great, thank you. I am still baffled, though. Must every > exported function that uses `par' be INLINEd? Does every exported caller > of such a function need the same treatment? Is `par' really a macro, > rather than a function? I'm not an expert in either parallelism/concurrency or GHC, so my interpretation may be wrong. The functions par and pseq are defined in GHC.Conc: ============================================================ -- Nota Bene: 'pseq' used to be 'seq' -- but 'seq' is now defined in PrelGHC -- -- "pseq" is defined a bit weirdly (see below) -- -- The reason for the strange "lazy" call is that -- it fools the compiler into thinking that pseq and par are non-strict in -- their second argument (even if it inlines pseq at the call site). -- If it thinks pseq is strict in "y", then it often evaluates -- "y" before "x", which is totally wrong. {-# INLINE pseq #-} pseq :: a -> b -> b pseq x y = x `seq` lazy y {-# INLINE par #-} par :: a -> b -> b par x y = case (par# x) of { _ -> lazy y } ============================================================ As far as I understand, par doesn't guarantee that both arguments are evaluated in parallel, it's just a suggestion to the compiler, and if whatever heuristics the compiler uses say it may be favourable to do it in parallel, it will produce code to calculate it in parallel (given appropriate compile- and run-time flags), otherwise it produces purely sequential code. With parallelize in a separate module, when compiling that, the compiler has no way to see whether parallelizing the computation may be beneficial, so doesn't produce (potentially) parallel code. At the use site, in the other module, it doesn't see the 'par', so has no reason to even consider producing parallel code. If parallelize is defined in the module where it's used, it will be inlined anyway since it is small, so the compiler sees the 'par' (actually par#) when compiling the use site and can employ the heuristics to decide whether to produce parallel code. If you place an INLINE pragma near the definition of parallelize, it will be inlined when compiling the importing module, so again the compiler sees the opportunity to parallelize. So, if I got it right (or nearly right), yes, every exported function that uses par should be INLINEd [1], and have a simple enough body that it will indeed be inlined. The same holds for callers of such functions, if the compiler can't see at the definition that parallelism is good, let the function be inlined so that it may be spotted at the call site. [1] Well, I suppose for function x = (expensive1 `par` expensive2) `seq` x and such, if expensive1/2 are defined in the same module, it may not be necessary. From jwlato at gmail.com Fri May 22 10:51:18 2009 From: jwlato at gmail.com (John Lato) Date: Fri May 22 10:35:51 2009 Subject: [Haskell-cafe] Re: A problem with par and modules boundaries... Message-ID: <9979e72e0905220751j4d867415s42131d79f0cfc475@mail.gmail.com> Hi Mario, It looks like the parallelize function is getting inlined when it's in the same file, but not when it's in a separate file. Adding a {-# INLINE parallelize #-} pragma to the module with parallelize recovers all the performance for me. You could probably see exactly what's happening in more detail by going through the Core output. John Lato > Message: 23 > Date: Thu, 21 May 2009 22:59:51 -0400 > From: Mario Bla?evi? > Subject: [Haskell-cafe] A problem with par and modules boundaries... > To: > Message-ID: <.1242961191@magma.ca> > Content-Type: text/plain; charset="utf-8" > > I'll cut to the chase. The short program below works perfectly: when I compile it > with -O2 -threaded and run with +RTS -N2 command-line options, I get a nearly 50% > real-time improvement: > > $ time ./primes-test +RTS -N2 > 5001 > > real ? ?0m9.307s > user ? ?0m16.581s > sys ? ? 0m0.200s > > However, if I move the `parallelize' definition into another module and import > that module, the performance is completely lost: > > $ time ./primes-test +RTS -N2 > 5001 > > real ? ?0m15.282s > user ? ?0m15.165s > sys ? ? 0m0.080s > > I'm confused. I know that `par` must be able work across modules boundaries, > because Control.Parallel.Strategies is a module and presumably it works. What am > I doing wrong? > > >> module Main where >> >> import Control.Parallel >> import Data.List (find) >> import Data.Maybe (maybe) >> >> --import Parallelizable >> parallelize a b = a `par` (b `pseq` (a, b)) >> >> test :: Integer -> Integer -> Integer >> test n1 n2 = let (p1, p2) = parallelize >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?(product $ factors $ product [1..n1]) >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?(product $ factors $ product [1..n2]) >> ? ? ? ? ? ? ?in p2 `div` p1 >> >> factors n = maybe [n] (\k-> (k : factors (n `div` k))) >> ? ? ? ? ? ? ? ? ? (find (\k-> n `mod` k == 0) [2 .. n - 1]) >> >> main = print (test 5000 5001) > From sebf at informatik.uni-kiel.de Fri May 22 11:01:49 2009 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Fri May 22 10:46:30 2009 Subject: [Haskell-cafe] generic filter through MonadPlus In-Reply-To: <42784f260905211913o1033d5ecg43e4362c1ab160d9@mail.gmail.com> References: <42784f260905211913o1033d5ecg43e4362c1ab160d9@mail.gmail.com> Message-ID: On May 22, 2009, at 4:13 AM, Jason Dusek wrote: > I'd like to know what folks think about the use of `MonadPlus` in > this case. The |guard| function is almost |filter|: > import Control.Monad ( MonadPlus, guard ) > > filter :: MonadPlus m => (a -> Bool) -> m a -> m a > filter p m = do a <- m > guard (p a) > return a Cheers, Sebastian -- Underestimating the novelty of the future is a time-honored tradition. (D.G.) -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 163 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090522/7d184c1b/PGP.bin From igloo at earth.li Fri May 22 11:20:55 2009 From: igloo at earth.li (Ian Lynagh) Date: Fri May 22 11:05:29 2009 Subject: [Haskell-cafe] community.haskell.org and code.haskell.org problems In-Reply-To: <404396ef0905180338v1477ec54r1cff5214eed5b10d@mail.gmail.com> References: <404396ef0905180338v1477ec54r1cff5214eed5b10d@mail.gmail.com> Message-ID: <20090522152055.GA31125@matrix.chaos.earth.li> On Mon, May 18, 2009 at 11:38:09AM +0100, Neil Mitchell wrote: > > Is there a reason for the poor reliability of these servers? We do have a plan to move community to a beefier machine with more reliable hosting. There are a few details to sort out first, and then we "just" need to find the time to do it. Thanks Ian From igloo at earth.li Fri May 22 12:14:49 2009 From: igloo at earth.li (Ian Lynagh) Date: Fri May 22 11:59:22 2009 Subject: [Haskell-cafe] Introducing Instances in GHC point releases In-Reply-To: <4A160E40.8090404@complete.org> References: <20090515065337.GA356@whirlpool.galois.com> <4A15CD56.20505@complete.org> <57526e770905211522k2041f7cdoc4b96f893335c2f0@mail.gmail.com> <1242945262.20307.61.camel@localhost> <4A160E40.8090404@complete.org> Message-ID: <20090522161449.GB31125@matrix.chaos.earth.li> Hi John, On Thu, May 21, 2009 at 09:30:24PM -0500, John Goerzen wrote: > > I guess my larger point is just a plea to the community: please be > really careful about what you do to GHC in point releases. We are careful about what goes into the official GHC release. However, ever since GHC 6.6 (when extralibs were first separated out), we have not made any guarantees about whether point releases come with the same, or a compatible, version; we just take what's in the darcs repo at the time of the release. Anyway, this will be a non-issue in 6.12, when there are no extralibs, and the Haskell Platform takes over the role. Thanks Ian From briqueabraque at yahoo.com Fri May 22 14:32:47 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=EDcio?=) Date: Fri May 22 14:17:43 2009 Subject: [Haskell-cafe] haddock could be a pretty-printer? Message-ID: Hi, The new version of haddock makes use of GHC parser. How much of effort would take to make haddock generate pretty-print of the source code itself, including haddock documentation (although probably loosing other comments)? Maybe even an html version that documentation could point to? Thanks, Maur?cio From andrewcoppin at btinternet.com Fri May 22 14:42:51 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri May 22 14:27:21 2009 Subject: [Haskell-cafe] Data.Binary suboptimal instance Message-ID: <4A16F22B.3010503@btinternet.com> So lately I've been working on a little program to generate trippy graphics. (Indeed, some of you may remember it from a few years back...) Anyway, getting to the point, I just restructured my program. As part of the restructuring, I got rid of all the jiggery-pokery with Data.Array.Storable and so forth and decided to use Data.Binary. My first problem was quite simple. I want to write a program that reads an item from the input file, processes it, writes it to the output file, and repeats until the input file is empty. Data.Binary doesn't appear to provide any obvious way to do this. You can't be in the Get and Put monads simultaneously, and I can't figure out how to interleave them. In the end, I ended up with something like xs <- decodeFile f1 encodeFile f2 (map f xs) Unfortunately, it looks like this doesn't do what I want. Serialised lists have their length prepended to them, which means that encodeFile is going to have to generate the *entire* list in memory so it can count how big it is, before it can output a single byte to disk. (!) This is particularly annoying since the output list will be exactly the same size as the input one, and the very first thing decodeFile is doing is reading in that size figure. Maybe there's a way around this glitch, and I just haven't thought of it yet. But you'd think that wanting to lazily process data from an input file and write it into an output file would be an extremely common use-case. Given that, I'm not seeing an obvious way to handle it. Anyway, that's one small problem, but I can live with it. There's another, much bigger problem though, and that's really what I wanted to talk about... As we all know, Data.Binary is *built* for speed. So imagine my shock when my newly adjusted program now based around this library turned out to be massively slower, and the files it produced were drastically larger. It didn't take me that long to dig up the problem. The problem seems to boil down to this: The Binary instance for Double (and Float, by the way) is... well I guess you could argue it's very portable, but efficient it isn't. As we all know, an IEEE-754 double-precision floating-point number occupies 64 bits; 1 sign bit, 11 exponent bits, and 52 mantissa bits (implicitly 53). I had assumed that the Binary instance for Double would simply write these bits to disk, requiring approximately 0 computational power, and exactly 64 bits of disk space. I was wrong. ...what it *actually* does is convert the 64-bit Double into a 32-bit exponent and an arbitrary-precision integer part. (!) It appears to do this by floating-point arithmetic rather than just low-level bit shuffling. Looking up how arbitrary-precision integers are serialised, I see that there's an 8-bit "flag" indicating whether the integer fits into 32 bits, and if it doesn't, there's an 8-bit sign value, followed by a serialised list of bytes. So, in other words, a 32-bit length value, followed by the bytes themselves. To summarise, when I ask for a 64-bit Double to be serialised, I get this: 32-bit exponent. 8-bit flag (probably always "1") 8-bit sign (either "0" or "1") 32-bit size (probably always "8") 64-bit mantissa That's 144 bits in total, i.e., 225% larger than the original Double. (Let's not even go into how much computer power it takes to construct all this data before it's written to disk...) So, that's why my files balooned in size, and why my program slowed to a crawl. But how do I fix this? Well, my solution was simple, brutal, and probably *highly* non-portable. It begins with Unsafe.Coerce (that's never a good thing!) Put simply, if you take your 64-bit Double and unsafeCoerce it into a Word64 and then ask Data.Binary to serialise that, it writes it straight to disk without screwing around with it first. The result ought to be portable to any architecture that uses IEEE-754 arithmetic natively. (Anybody know of an arch this *doesn't* apply to?) But sure, if you wanted to do this on some other architecture with a different native float format, you'd have to write some trixy code to handle it. (And then add conditional compilation for it.) Is there any danger that there might be some kind of improvement to the Double instance in the next version of Data.Binary? END. From david.waern at gmail.com Fri May 22 14:49:16 2009 From: david.waern at gmail.com (David Waern) Date: Fri May 22 14:33:58 2009 Subject: [Haskell-cafe] haddock could be a pretty-printer? In-Reply-To: References: Message-ID: 2009/5/22 Maur?cio : > Hi, > > The new version of haddock makes use of GHC > parser. How much of effort would take to make > haddock generate pretty-print of the source > code itself, including haddock documentation > (although probably loosing other comments)? > Maybe even an html version that documentation > could point to? You can use hscolour to output source code in HTML form and Haddock can generate links to it if you use the --source-* flags. Most documentation on Hackage seems to make use of this. Is this what you want or is there some reason why you want the code to be pretty-printed? David From lemming at henning-thielemann.de Fri May 22 15:34:50 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri May 22 15:19:25 2009 Subject: [Haskell-cafe] Data.Binary suboptimal instance In-Reply-To: <4A16F22B.3010503@btinternet.com> References: <4A16F22B.3010503@btinternet.com> Message-ID: On Fri, 22 May 2009, Andrew Coppin wrote: > So lately I've been working on a little program to generate trippy graphics. > (Indeed, some of you may remember it from a few years back...) Anyway, > getting to the point, I just restructured my program. As part of the > restructuring, I got rid of all the jiggery-pokery with Data.Array.Storable > and so forth and decided to use Data.Binary. > > My first problem was quite simple. I want to write a program that reads an > item from the input file, processes it, writes it to the output file, and > repeats until the input file is empty. Data.Binary doesn't appear to provide > any obvious way to do this. You can't be in the Get and Put monads > simultaneously, and I can't figure out how to interleave them. You can! - It's again time to point out that Put shouldn't be a monad, but a monoid. But as it is, Put is a Writer monad on top of the Builder monoid. Better use that Builder monoid directly. From andrewcoppin at btinternet.com Fri May 22 16:23:04 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri May 22 16:07:34 2009 Subject: [Haskell-cafe] Data.Binary suboptimal instance In-Reply-To: References: <4A16F22B.3010503@btinternet.com> Message-ID: <4A1709A8.8040306@btinternet.com> Henning Thielemann wrote: > > On Fri, 22 May 2009, Andrew Coppin wrote: > >> My first problem was quite simple. I want to write a program that >> reads an item from the input file, processes it, writes it to the >> output file, and repeats until the input file is empty. Data.Binary >> doesn't appear to provide any obvious way to do this. You can't be in >> the Get and Put monads simultaneously, and I can't figure out how to >> interleave them. > > You can! - It's again time to point out that Put shouldn't be a monad, > but a monoid. But as it is, Put is a Writer monad on top of the > Builder monoid. Better use that Builder monoid directly. Aaaahhhahaha.... Nice. Thanks for the tip. :-D From briqueabraque at yahoo.com Fri May 22 16:47:14 2009 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=EDcio?=) Date: Fri May 22 16:31:55 2009 Subject: [Haskell-cafe] Re: haddock could be a pretty-printer? In-Reply-To: References: Message-ID: >> The new version of haddock makes use of GHC parser. How much >> of effort would take to make haddock generate pretty-print >> of the source code itself, (...) > (...) Is this what you want or is there some reason why you > want the code to be pretty-printed? I usually have to resort to braces or bad indenting to get code to parse, but I like to give it good presentation before publishing. I used to pretty-print my code using haskell-src-exts with great result, but that kills documentation. Best, Maur?cio From alexey.skladnoy at gmail.com Fri May 22 17:36:24 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Fri May 22 17:18:10 2009 Subject: [Haskell-cafe] Data.Binary suboptimal instance In-Reply-To: References: <4A16F22B.3010503@btinternet.com> Message-ID: <200905230136.24824.alexey.skladnoy@gmail.com> On Friday 22 May 2009 23:34:50 Henning Thielemann wrote: > > So lately I've been working on a little program to generate trippy > > graphics. (Indeed, some of you may remember it from a few years back...) > > Anyway, getting to the point, I just restructured my program. As part of > > the restructuring, I got rid of all the jiggery-pokery with > > Data.Array.Storable and so forth and decided to use Data.Binary. > > > > My first problem was quite simple. I want to write a program that reads > > an item from the input file, processes it, writes it to the output file, > > and repeats until the input file is empty. Data.Binary doesn't appear to > > provide any obvious way to do this. You can't be in the Get and Put > > monads simultaneously, and I can't figure out how to interleave them. > > You can! - It's again time to point out that Put shouldn't be a monad, but > a monoid. But as it is, Put is a Writer monad on top of the Builder > monoid. Better use that Builder monoid directly. Could you elaborate? I didn't quite understand. Anyway I had similar problem and simply wrote few functions. They encode/decode values of same type element by element. It's lazy enough so code could be written in following style: > process :: [Foo] -> [Bar] > > foo = readFile name > >>= writeFile out . encodeStream . process . decodeProcess There is a code. It is fast and worked for me without a problem. > -- | Decode records in repetition > decodeStream :: Binary a => ByteString -> [a] > decodeStream = runGet (getStream get) > > -- | Encode list of records as bytestring > encodeStream :: Binary a => [a] -> ByteString > encodeStream = runPut . putStream put > > -- | Read list of values from bytestring until it ends. > getStream :: Get a -> Get [a] > getStream getter = do > empty <- isEmpty > if empty > then return [] > else do x <- getter > xs <- getStream getter > return (x:xs) > > -- | Write list of values. > putStream :: (a -> Put) -> [a] -> Put > putStream f = mapM_ f -- Khudyakov Alexey From aslatter at gmail.com Fri May 22 18:55:17 2009 From: aslatter at gmail.com (Antoine Latter) Date: Fri May 22 18:39:52 2009 Subject: Fwd: [Haskell-cafe] Data.Binary suboptimal instance In-Reply-To: <694519c50905221554x553db924jef2509e1c79aab26@mail.gmail.com> References: <4A16F22B.3010503@btinternet.com> <200905230136.24824.alexey.skladnoy@gmail.com> <694519c50905221554x553db924jef2509e1c79aab26@mail.gmail.com> Message-ID: <694519c50905221555y2beddcb3pf5165254b68becdb@mail.gmail.com> I suppose I should send my reply to the list ... ---------- Forwarded message ---------- From: Antoine Latter Date: Fri, May 22, 2009 at 5:54 PM Subject: Re: [Haskell-cafe] Data.Binary suboptimal instance To: Khudyakov Alexey On Fri, May 22, 2009 at 4:36 PM, Khudyakov Alexey wrote: >> You can! - It's again time to point out that Put shouldn't be a monad, but >> a monoid. But as it is, Put is a Writer monad on top of the Builder >> monoid. Better use that Builder monoid directly. > > Could you elaborate? I didn't quite understand. > > > Anyway I had similar problem and simply wrote few functions. They > encode/decode values of same type element by element. It's lazy enough so code > could be written in following style: > Or you could go for the compromise position, where the list can be part of a complex data structure so you're not relying on EOF to find the end. (warning, I don't have my compiler handy so this may not even typecheck) import Control.Monad import Data.Monoid import Data.Binary.Builder import Data.Binary.Get data ChunkedList a ? ?= Cons [a] (ChunkedList a) -- Non-null list ? ?| Nil chunkSize = 50 fromList :: [a] -> ChunkedList a fromList [] ? ?= Nil fromList xs ? ?= let (front,back) = splitAt chunkSize xs ? ? ?in Cons front (fromList back) toList :: ChunkedList a -> [a] toList Nil = [] toList (Cons front back) = front ++ toList back putList :: (a -> Builder) -> [a] -> Builder putList f xs = putChunkedList (fromList xs) ?where ? putChunkedList Nil ? ?= singleton 0 ? putChunkedList (Cons front back) ? ?= mconcat ? ? ?[ singleton (genericLength front) ? ? ?, mconcat $ map f front ? ? ?, putChunkedList back ? ? ?] getList :: Get a -> Get [a] getList m = toList `liftM` getChunkedList ?where ?getChunkedList = do ? ?cLen <- getWord8 ? ?case cLen of ? ? ?0 -> return Nil ? ? ?_ -> Cons `liftM` replicateM (fromIntegral cLen) m `ap` getChunkedList From bos at serpentine.com Fri May 22 22:14:49 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Fri May 22 21:59:21 2009 Subject: [Haskell-cafe] ANNOUNCE: text 0.2, fast and comprehensive Unicode support using stream fusion Message-ID: I'm pleased to announce the availability of text 0.2, an efficient Unicode text library that uses stream fusion. New and notable in this release is support for lazy, chunked text, so you can process text files far larger than memory using a small footprint. Hackage page: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/text Darcs repo: darcs get http://code.haskell.org/text Report bugs: http://trac.haskell.org/text/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090522/88693b58/attachment.html From vigalchin at gmail.com Sat May 23 01:39:57 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Sat May 23 01:24:28 2009 Subject: [Haskell-cafe] import qualified? Message-ID: <5ae4f2ba0905222239q75964209x4b6920206fadca5d@mail.gmail.com> Hello, I am working with some somewhat legacy code. I understand what "import qualified Blah as B" means but what does "import qualified Blah" mean? Is this a deprecated feature? I saw with user defined module as well as with "import qualified System" for example. REgards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090523/bf5f774d/attachment.html From wren at freegeek.org Sat May 23 01:44:40 2009 From: wren at freegeek.org (wren ng thornton) Date: Sat May 23 01:29:13 2009 Subject: [Haskell-cafe] import qualified? In-Reply-To: <5ae4f2ba0905222239q75964209x4b6920206fadca5d@mail.gmail.com> References: <5ae4f2ba0905222239q75964209x4b6920206fadca5d@mail.gmail.com> Message-ID: <4A178D48.3080901@freegeek.org> Vasili I. Galchin wrote: > Hello, > > I am working with some somewhat legacy code. I understand what "import > qualified Blah as B" means but what does "import qualified Blah" mean? Is > this a deprecated feature? I saw with user defined module as well as with > "import qualified System" for example. It just means that you must qualify the names with the module name (System). It's not deprecated, but most folks use the "import qualified ... as" version instead so that they can give a shorter name instead of using the full module name. -- Live well, ~wren From tanimoto at arizona.edu Sat May 23 01:47:55 2009 From: tanimoto at arizona.edu (Paulo Tanimoto) Date: Sat May 23 01:32:45 2009 Subject: [Haskell-cafe] import qualified? In-Reply-To: <5ae4f2ba0905222239q75964209x4b6920206fadca5d@mail.gmail.com> References: <5ae4f2ba0905222239q75964209x4b6920206fadca5d@mail.gmail.com> Message-ID: On Sat, May 23, 2009 at 12:39 AM, Vasili I. Galchin wrote: > Hello, > > ???? I am working with some somewhat legacy code. I understand what "import > qualified Blah as B" means but what does "import qualified Blah" mean? Is > this a deprecated feature? I saw with user defined module as well as with > "import qualified System" for example. > > REgards, > > Vasili > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > See the report, section 5.3.2: http://www.haskell.org/onlinereport/modules.html Because we tend to have long names now, you will often see people aliasing. But "qualified" by itself has an important role, it's not deprecated. Paulo From vigalchin at gmail.com Sat May 23 02:08:42 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Sat May 23 01:53:15 2009 Subject: [Haskell-cafe] import qualified? In-Reply-To: References: <5ae4f2ba0905222239q75964209x4b6920206fadca5d@mail.gmail.com> Message-ID: <5ae4f2ba0905222308u64e84544te594b00e260af4e4@mail.gmail.com> Hi Paulo, You are teasing me ;^) So what is the "semantics" of "import qualified Blah"? Regards, Vasili On Sat, May 23, 2009 at 12:47 AM, Paulo Tanimoto wrote: > On Sat, May 23, 2009 at 12:39 AM, Vasili I. Galchin > wrote: > > Hello, > > > > I am working with some somewhat legacy code. I understand what > "import > > qualified Blah as B" means but what does "import qualified Blah" mean? Is > > this a deprecated feature? I saw with user defined module as well as with > > "import qualified System" for example. > > > > REgards, > > > > Vasili > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > See the report, section 5.3.2: > http://www.haskell.org/onlinereport/modules.html > > Because we tend to have long names now, you will often see people > aliasing. But "qualified" by itself has an important role, it's not > deprecated. > > Paulo > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090523/0f2b5a60/attachment.html From vigalchin at gmail.com Sat May 23 02:30:53 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Sat May 23 02:15:25 2009 Subject: [Haskell-cafe] MPI ... Globus APIs Message-ID: <5ae4f2ba0905222330wcee5c1cmc1a27524a4dcb2ed@mail.gmail.com> Hello, 1) I think I read before that there some kind of MPI API (bindings) in Haskell. Yes? If so, current state? 2) http://www.globus.org/ Globus bindings? Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090523/29d699b6/attachment.html From vigalchin at gmail.com Sat May 23 02:48:33 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Sat May 23 02:33:04 2009 Subject: [Haskell-cafe] Re: MPI ... Globus APIs In-Reply-To: <5ae4f2ba0905222330wcee5c1cmc1a27524a4dcb2ed@mail.gmail.com> References: <5ae4f2ba0905222330wcee5c1cmc1a27524a4dcb2ed@mail.gmail.com> Message-ID: <5ae4f2ba0905222348o21915248yb36aa49a23ab72ad@mail.gmail.com> so I am fascinated with cool graphics at http://www.globus.org .... check out the black hole 3d from Max Plank Institute and imagine ... "we did it with Haskell bindings to Globus API!!!" On Sat, May 23, 2009 at 1:30 AM, Vasili I. Galchin wrote: > Hello, > > 1) I think I read before that there some kind of MPI API (bindings) in > Haskell. Yes? If so, current state? > > 2) http://www.globus.org/ Globus bindings? > > > Kind regards, > > Vasili > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090523/f9d52a3c/attachment.html From daniel.is.fischer at web.de Sat May 23 05:34:25 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat May 23 05:19:37 2009 Subject: [Haskell-cafe] import qualified? In-Reply-To: <5ae4f2ba0905222308u64e84544te594b00e260af4e4@mail.gmail.com> References: <5ae4f2ba0905222239q75964209x4b6920206fadca5d@mail.gmail.com> <5ae4f2ba0905222308u64e84544te594b00e260af4e4@mail.gmail.com> Message-ID: <200905231134.25732.daniel.is.fischer@web.de> Am Samstag 23 Mai 2009 08:08:42 schrieb Vasili I. Galchin: > Hi Paulo, > > ? ? You are teasing me ;^) So what is the "semantics" of "import qualified > Blah"? > > Regards, > > Vasili The qualified names (Blah.foo, Blah.baz) are in scope, but not the unqualified names foo, baz. If you import qualified Bing.Bong.Blah.Blub as Blub the names of Blub are in scope in the fully qualified form Bing.Bong.Blah.Blub.foo and the shorter Blub.foo without the 'as Blub', only the fully qualified form is in scope. From duncan.coutts at worc.ox.ac.uk Sat May 23 06:40:08 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat May 23 06:24:58 2009 Subject: [Haskell-cafe] A problem with par and modules boundaries... In-Reply-To: <20090522123015.GT5994@whirlpool.galois.com> References: <.1242961191@magma.ca> <200905221404.59102.daniel.is.fischer@web.de> <20090522123015.GT5994@whirlpool.galois.com> Message-ID: <1243075208.20307.108.camel@localhost> On Fri, 2009-05-22 at 05:30 -0700, Don Stewart wrote: > Answer recorded at: > > http://haskell.org/haskellwiki/Performance/Parallel I have to complain, this answer doesn't explain anything. This isn't like straight-line performance, there's no reason as far as I can see that inlining should change the operational behaviour of parallel evaluation, unless there's some mistake in the original such as accidentally relying on an unspecified evaluation order. Now, I tried the example using two versions of ghc and I get different behaviour from what other people are seeing. With the original code, (ie parallelize function in the same module) with ghc-6.10.1 I get no speedup at all from -N2 and with 6.11 I get a very good speedup (though single threaded performance is slightly lower in 6.11) Original code ghc-6.10.1, -N1 -N2 real 0m9.435s 0m9.328s user 0m9.369s 0m9.249s ghc-6.11, -N1 -N2 real 0m10.262s 0m6.117s user 0m10.161s 0m11.093s With the parallelize function moved into another module I get no change whatsoever. Indeed even when I force it *not* to be inlined with {-# NOINLINE parallelize #-} then I still get no change in behaviour (as indeed I expected). So I view this advice to force inlining with great suspicion (at worst it encourages people not to think and to look at it as magic). That said, why it does not get any speedup with ghc-6.10 is also a mystery to me (there's very little GC going on). Don: can we change the advice on the wiki please? It currently makes it look like a known and understood issue. If anything we should suggest using a later ghc version. Duncan From duncan.coutts at worc.ox.ac.uk Sat May 23 07:06:04 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat May 23 06:50:51 2009 Subject: [Haskell-cafe] A problem with par and modules boundaries... In-Reply-To: <200905221634.19133.daniel.is.fischer@web.de> References: <.1242961191@magma.ca> <200905221404.59102.daniel.is.fischer@web.de> <4A16A484.9080304@stilo.com> <200905221634.19133.daniel.is.fischer@web.de> Message-ID: <1243076764.20307.123.camel@localhost> On Fri, 2009-05-22 at 16:34 +0200, Daniel Fischer wrote: > > That's great, thank you. I am still baffled, though. I'm baffled too! I don't see the same behaviour at all (see the other email). > > Must every exported function that uses `par' be INLINEd? Does every > > exported caller of such a function need the same treatment? It really should not be necessary. > > Is `par' really a macro, rather than a function? It's a function. > As far as I understand, par doesn't guarantee that both arguments are > evaluated in parallel, it's just a suggestion to the compiler, and if > whatever heuristics the compiler uses say it may be favourable to do > it in parallel, it will produce code to calculate it in parallel > (given appropriate compile- and run-time flags), otherwise it produces > purely sequential code. > > With parallelize in a separate module, when compiling that, the > compiler has no way to see whether parallelizing the computation may > be beneficial, so doesn't produce (potentially) parallel code. At the > use site, in the other module, it doesn't see the 'par', so has no > reason to even consider producing parallel code. I don't think this is right. As I understand it, par always creates a spark. It has nothing to do with heuristics. Whether the spark actually gets evaluated in parallel depends on the runtime system and whether the spark "fizzles" before it gets a chance to run. Of course when using the single threaded rts then the sparks are never evaluated in parallel. With the threaded rts and given enough CPUs, the rts will try to schedule the sparks onto idle CPUs. This business of getting sparks running on other CPUs has improved significantly since ghc-6.10. The current development version uses a better concurrent queue data structure to manage the spark pool. That's probably the underlying reason for why the example works well in ghc-6.11 but works badly in 6.10. I'm afraid I'm not sure of what exactly is going wrong that means it doesn't work well in 6.10. Generally I'd expect the effect of par to be pretty insensitive to inlining. I'm cc'ing the ghc users list so perhaps we'll get some expert commentary. Duncan From mblazevic at stilo.com Sat May 23 08:13:34 2009 From: mblazevic at stilo.com (=?utf-8?B?TWFyaW8gQmxhxb5ldmnEhw==?=) Date: Sat May 23 07:58:06 2009 Subject: [Haskell-cafe] Re: A problem with par and modules boundaries... Message-ID: <.1243080814@magma.ca> On Fri 22/05/09 10:51 AM , John Lato jwlato@gmail.com sent: > Hi Mario, > > It looks like the parallelize function is getting inlined when it's in > the same file, but not when it's in a separate file. > > Adding a {-# INLINE parallelize #-} pragma to the module with > parallelize recovers all the performance for me. > > You could probably see exactly what's happening in more detail by > going through the Core output. Thank you, this advice helped. The Core output indicates that function `test' evaluates the arguments to `parallelize' before it calls it. In other words, the call to `parallelize' is optimized as a strict function call -- which it is. The problem is that this optimization evaluates the arguments sequentially. Compiling with optimizations turned off regains the parallel execution. I guess I will report this as a GHC bug. Or is it a feature request? From daniel.is.fischer at web.de Sat May 23 08:35:47 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat May 23 08:21:01 2009 Subject: [Haskell-cafe] A problem with par and modules boundaries... In-Reply-To: <1243076764.20307.123.camel@localhost> References: <.1242961191@magma.ca> <200905221634.19133.daniel.is.fischer@web.de> <1243076764.20307.123.camel@localhost> Message-ID: <200905231435.48289.daniel.is.fischer@web.de> Am Samstag 23 Mai 2009 13:06:04 schrieb Duncan Coutts: > On Fri, 2009-05-22 at 16:34 +0200, Daniel Fischer wrote: > > > That's great, thank you. I am still baffled, though. > > I'm baffled too! I don't see the same behaviour at all (see the other > email). > > > > Must every exported function that uses `par' be INLINEd? Does every > > > exported caller of such a function need the same treatment? > > It really should not be necessary. > > > > Is `par' really a macro, rather than a function? > > It's a function. > > > As far as I understand, par doesn't guarantee that both arguments are > > evaluated in parallel, it's just a suggestion to the compiler, and if > > whatever heuristics the compiler uses say it may be favourable to do > > it in parallel, it will produce code to calculate it in parallel > > (given appropriate compile- and run-time flags), otherwise it produces > > purely sequential code. > > > > With parallelize in a separate module, when compiling that, the > > compiler has no way to see whether parallelizing the computation may > > be beneficial, so doesn't produce (potentially) parallel code. At the > > use site, in the other module, it doesn't see the 'par', so has no > > reason to even consider producing parallel code. > > I don't think this is right. As I understand it, par always creates a > spark. It has nothing to do with heuristics. Quite possible. I was only guessing from the fact that sometimes par evaluates things in parallel and sometimes not, plus when thinking what might cause the described behaviour, cross-module inlining came to mind, I tried adding an INLINE pragma and it worked - or so it seemed. Then I threw together an explanation of the observed behaviour. That explanation must be wrong, though, see below. > > Whether the spark actually gets evaluated in parallel depends on the > runtime system and whether the spark "fizzles" before it gets a chance > to run. Of course when using the single threaded rts then the sparks are > never evaluated in parallel. With the threaded rts and given enough > CPUs, the rts will try to schedule the sparks onto idle CPUs. This > business of getting sparks running on other CPUs has improved > significantly since ghc-6.10. The current development version uses a > better concurrent queue data structure to manage the spark pool. That's > probably the underlying reason for why the example works well in > ghc-6.11 but works badly in 6.10. I'm afraid I'm not sure of what > exactly is going wrong that means it doesn't work well in 6.10. I have tried with 6.10.3 and 6.10.1, with parallelize in the same module and in a separate module - with no pragma - with an INLINE pragma - with a NOINLINE pragma 6.10.1 did not parallelize in any of these settings 6.10.3 parallelized in all these settings except "separate module, no pragma". Then I tried a few other settigns with 6.10.3, got parallel evaluation if there's an INLINE or a NOINLINE pragma on parallelize, or the module header of Main is module Main (main) where, not if Main exports all top level definitions and parallelize is neither INLINEd nor NOINLINEd. Weird. > > Generally I'd expect the effect of par to be pretty insensitive to > inlining. I'm cc'ing the ghc users list so perhaps we'll get some expert > commentary. That would be good. > > Duncan > Daniel From daniel.yokomizo at gmail.com Sat May 23 08:51:38 2009 From: daniel.yokomizo at gmail.com (Daniel Yokomizo) Date: Sat May 23 08:36:08 2009 Subject: =?ISO-8859-1?Q?Re=3A_=5BHaskell=2Dcafe=5D_Haskell_programmers_in_S=E3o_Carlo?= =?ISO-8859-1?Q?s_=2D_SP_=2D_Brazil=3F?= In-Reply-To: <174c72ef0905211334g129a3c01l74c3108d66448e91@mail.gmail.com> References: <174c72ef0905211334g129a3c01l74c3108d66448e91@mail.gmail.com> Message-ID: Hey, we have enough people for a S?o Paulo Haskell User Group. Anyone else interested? Best regards, Daniel Yokomizo 2009/5/21 Fernando Henrique Sanches : > S?o Caetano, SP, Brazil - right next to S?o Paulo. UFABC Student. > > Fernando Henrique Sanches > > > 2009/5/19 Maur??cio >> >> Anybody else around here? >> >> Best, >> Maur?cio >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From dons at galois.com Sat May 23 10:58:26 2009 From: dons at galois.com (Don Stewart) Date: Sat May 23 10:44:33 2009 Subject: [Haskell-cafe] A problem with par and modules boundaries... In-Reply-To: <1243075208.20307.108.camel@localhost> References: <.1242961191@magma.ca> <200905221404.59102.daniel.is.fischer@web.de> <20090522123015.GT5994@whirlpool.galois.com> <1243075208.20307.108.camel@localhost> Message-ID: <20090523145826.GA15361@whirlpool.galois.com> duncan.coutts: > On Fri, 2009-05-22 at 05:30 -0700, Don Stewart wrote: > > Answer recorded at: > > > > http://haskell.org/haskellwiki/Performance/Parallel > > I have to complain, this answer doesn't explain anything. This isn't > like straight-line performance, there's no reason as far as I can see > that inlining should change the operational behaviour of parallel > evaluation, unless there's some mistake in the original such as > accidentally relying on an unspecified evaluation order. > > Now, I tried the example using two versions of ghc and I get different > behaviour from what other people are seeing. With the original code, (ie > parallelize function in the same module) with ghc-6.10.1 I get no > speedup at all from -N2 and with 6.11 I get a very good speedup (though > single threaded performance is slightly lower in 6.11) > > Original code > ghc-6.10.1, -N1 -N2 > real 0m9.435s 0m9.328s > user 0m9.369s 0m9.249s > > ghc-6.11, -N1 -N2 > real 0m10.262s 0m6.117s > user 0m10.161s 0m11.093s > > With the parallelize function moved into another module I get no change > whatsoever. Indeed even when I force it *not* to be inlined with {-# > NOINLINE parallelize #-} then I still get no change in behaviour (as > indeed I expected). > > So I view this advice to force inlining with great suspicion (at worst > it encourages people not to think and to look at it as magic). That > said, why it does not get any speedup with ghc-6.10 is also a mystery to > me (there's very little GC going on). > > Don: can we change the advice on the wiki please? It currently makes it > look like a known and understood issue. If anything we should suggest > using a later ghc version. Please do so. Especially if GHC HEAD *does the right thing*. Then the advice should be first: upgrade to GHC HEAD. From lemming at henning-thielemann.de Sat May 23 12:00:25 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat May 23 11:44:01 2009 Subject: [Haskell-cafe] Data.Binary suboptimal instance In-Reply-To: <200905230136.24824.alexey.skladnoy@gmail.com> References: <4A16F22B.3010503@btinternet.com> <200905230136.24824.alexey.skladnoy@gmail.com> Message-ID: <4A181D99.8080508@henning-thielemann.de> Khudyakov Alexey schrieb: > On Friday 22 May 2009 23:34:50 Henning Thielemann wrote: >>> So lately I've been working on a little program to generate trippy >>> graphics. (Indeed, some of you may remember it from a few years back...) >>> Anyway, getting to the point, I just restructured my program. As part of >>> the restructuring, I got rid of all the jiggery-pokery with >>> Data.Array.Storable and so forth and decided to use Data.Binary. >>> >>> My first problem was quite simple. I want to write a program that reads >>> an item from the input file, processes it, writes it to the output file, >>> and repeats until the input file is empty. Data.Binary doesn't appear to >>> provide any obvious way to do this. You can't be in the Get and Put >>> monads simultaneously, and I can't figure out how to interleave them. >> You can! - It's again time to point out that Put shouldn't be a monad, but >> a monoid. But as it is, Put is a Writer monad on top of the Builder >> monoid. Better use that Builder monoid directly. > > Could you elaborate? I didn't quite understand. > > > Anyway I had similar problem and simply wrote few functions. They > encode/decode values of same type element by element. It's lazy enough so code > could be written in following style: > >> process :: [Foo] -> [Bar] >> >> foo = readFile name >> >>= writeFile out . encodeStream . process . decodeProcess > > There is a code. It is fast and worked for me without a problem. > >> -- | Decode records in repetition >> decodeStream :: Binary a => ByteString -> [a] >> decodeStream = runGet (getStream get) >> >> -- | Encode list of records as bytestring >> encodeStream :: Binary a => [a] -> ByteString >> encodeStream = runPut . putStream put I think the list should be avoided at all costs, because it is so slow. I don't know if it is fused away by clever optimizer rules in the binary package. Anyway, you can treat a Builder like a list. Just replace (++) by 'mappend' and [] by 'mempty'. It should work like this: do a <- getWord8 b <- getWord8 return $ Builder.singleton a `mappend` Builder.singleton b From dons at galois.com Sat May 23 12:46:47 2009 From: dons at galois.com (Don Stewart) Date: Sat May 23 12:32:48 2009 Subject: [Haskell-cafe] Re: A problem with par and modules boundaries... In-Reply-To: <.1243080814@magma.ca> References: <.1243080814@magma.ca> Message-ID: <20090523164647.GC15665@whirlpool.galois.com> mblazevic: > > On Fri 22/05/09 10:51 AM , John Lato jwlato@gmail.com sent: > > Hi Mario, > > > > It looks like the parallelize function is getting inlined when it's in > > the same file, but not when it's in a separate file. > > > > Adding a {-# INLINE parallelize #-} pragma to the module with > > parallelize recovers all the performance for me. > > > > You could probably see exactly what's happening in more detail by > > going through the Core output. > > > Thank you, this advice helped. The Core output indicates that function `test' > evaluates the arguments to `parallelize' before it calls it. In other words, the > call to `parallelize' is optimized as a strict function call -- which it is. The > problem is that this optimization evaluates the arguments sequentially. Compiling > with optimizations turned off regains the parallel execution. > > I guess I will report this as a GHC bug. Or is it a feature request? As Duncan suggessted, try with GHC head (grab a snapshot). `par` et al are much improved. -- Don From alexey.skladnoy at gmail.com Sat May 23 12:58:42 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Sat May 23 12:46:17 2009 Subject: Fwd: [Haskell-cafe] Data.Binary suboptimal instance In-Reply-To: <694519c50905221555y2beddcb3pf5165254b68becdb@mail.gmail.com> References: <4A16F22B.3010503@btinternet.com> <694519c50905221554x553db924jef2509e1c79aab26@mail.gmail.com> <694519c50905221555y2beddcb3pf5165254b68becdb@mail.gmail.com> Message-ID: <200905232058.43315.alexey.skladnoy@gmail.com> On Saturday 23 May 2009 02:55:17 Antoine Latter wrote: > Or you could go for the compromise position, where the list can be > part of a complex data structure so you're not relying on EOF to find > the end. > Interesting solution however it does not perform very nice. I wrote microbenchmark > xs :: [Word32] > xs = [1..(10^6)] Writing chunked list of Word32 > B.writeFile "chunked" . toLazyByteString . putList putWord32be $ xs real 0m4.311s user 0m3.272s sys 0m0.096s Reading chunked list of Word32 > print . last . runGet (getList getWord32be) =<< B.readFile "chunked" real 0m0.634s user 0m0.496s sys 0m0.012s Writing stream of Word32 > B.writeFile "stream" . encodeStream $ xs real 0m0.391s user 0m0.252s sys 0m0.020s Reading stream of Word32 > print . (last :: [Word32] -> Word32) . decodeStream =<< B.readFile "stream" real 0m0.376s user 0m0.248s sys 0m0.020s I didn'd do any profiling so I have no idea why writing is so slow. -- Best regard Khudyakov Alexey From alexey.skladnoy at gmail.com Sat May 23 13:03:56 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Sat May 23 12:46:27 2009 Subject: [Haskell-cafe] Data.Binary suboptimal instance In-Reply-To: <4A181D99.8080508@henning-thielemann.de> References: <4A16F22B.3010503@btinternet.com> <200905230136.24824.alexey.skladnoy@gmail.com> <4A181D99.8080508@henning-thielemann.de> Message-ID: <200905232103.57004.alexey.skladnoy@gmail.com> On Saturday 23 May 2009 20:00:25 Henning Thielemann wrote: > I think the list should be avoided at all costs, because it is so slow. > I don't know if it is fused away by clever optimizer rules in the binary > package. Anyway, you can treat a Builder like a list. Just replace (++) > by 'mappend' and [] by 'mempty'. > > It should work like this: > > do a <- getWord8 > b <- getWord8 > return $ Builder.singleton a `mappend` Builder.singleton b > It worked for me pretty well. Profiling shown that in my program {get,put}Stream functions takes less than 1% of execution time. I don't know which tricks ghc used. I think code with list is more clear. Another problem that you can't use existing Binary instances with Builder. -- Best regards Khudyakov Alexey From mblazevic at stilo.com Sat May 23 13:31:25 2009 From: mblazevic at stilo.com (=?utf-8?B?TWFyaW8gQmxhxb5ldmnEhw==?=) Date: Sat May 23 13:15:55 2009 Subject: [Haskell-cafe] Re: A problem with par and modules boundaries... Message-ID: <.1243099885@magma.ca> >>> You could probably see exactly what's happening in >>> more detail by going through the Core output. >> >> Thank you, this advice helped. The Core output indicates >> that function `test' evaluates the arguments to >> `parallelize' before it calls it. In other words, the >> call to `parallelize' is optimized as a strict function >> call -- which it is. The problem is that this >> optimization evaluates the arguments sequentially. >> Compiling with optimizations turned off regains the >> parallel execution. >> >> I guess I will report this as a GHC bug. Or is it a >> feature request? > > As Duncan suggessted, try with GHC head (grab a snapshot). `par` et al > are much improved. I already have, with the snapshot from 21st of April. It behaves the same as 6.8.2, except it runs for twice as long. I'd like to take back a part of what I said before, though: `parallelize' should be strict only in its second argument. Its strictness in the first argument should be the same as with `par`. Even though `parallelize x y' always evaluates both x and y, the following test works fine with optimizations even if `parallelize' is imported: main = putStrLn (snd $ parallelize undefined "Hello, World!") So the function is not strict, and I don't understand why GHC should evaluate the arguments before the call. Does anybody know of a pragma or another way to make a function *non-strict* even if it does always evaluate its argument? In other words, is there a way to selectively disable the strictness optimization? From matthias.goergens at googlemail.com Sat May 23 13:31:42 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Sat May 23 13:16:14 2009 Subject: [Haskell-cafe] ICFP Participation Message-ID: Hello, Please pardon my naive question: Is there a way to sign on for ICFP 09? The homepage (http://www.cs.nott.ac.uk/~gmh/icfp09.html) only seems to mention how to submit papers. Is there a way to attend as a mere participant? Thanks, Matthias. From dons at galois.com Sat May 23 14:15:25 2009 From: dons at galois.com (Don Stewart) Date: Sat May 23 14:01:29 2009 Subject: [Haskell-cafe] ICFP Participation In-Reply-To: References: Message-ID: <20090523181525.GA16092@whirlpool.galois.com> matthias.goergens: > Hello, > > Please pardon my naive question: Is there a way to sign on for ICFP > 09? The homepage (http://www.cs.nott.ac.uk/~gmh/icfp09.html) only > seems to mention how to submit papers. Is there a way to attend as a > mere participant? > Registration will be open soon. -- Don From max.rabkin at gmail.com Sat May 23 14:34:43 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Sat May 23 14:19:33 2009 Subject: [Haskell-cafe] Re: A problem with par and modules boundaries... In-Reply-To: <.1243099885@magma.ca> References: <.1243099885@magma.ca> Message-ID: On Sat, May 23, 2009 at 7:31 PM, Mario Bla?evi? wrote: > Does anybody know of a pragma or another way to make a function *non-strict* even > if it does always evaluate its argument? In other words, is there a way to > selectively disable the strictness optimization? parallelize a b | False = (undefined, undefined) | otherwise = a `par` (b `pseq` (a, b)) might do, unless strictness analysis is smart enough to know that the False guard is always, well, False. --Max From lemming at henning-thielemann.de Sat May 23 15:22:48 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat May 23 15:06:21 2009 Subject: [Haskell-cafe] Data.Binary suboptimal instance In-Reply-To: <200905232103.57004.alexey.skladnoy@gmail.com> References: <4A16F22B.3010503@btinternet.com> <200905230136.24824.alexey.skladnoy@gmail.com> <4A181D99.8080508@henning-thielemann.de> <200905232103.57004.alexey.skladnoy@gmail.com> Message-ID: <4A184D08.6010107@henning-thielemann.de> Khudyakov Alexey schrieb: > On Saturday 23 May 2009 20:00:25 Henning Thielemann wrote: >> I think the list should be avoided at all costs, because it is so slow. >> I don't know if it is fused away by clever optimizer rules in the binary >> package. Anyway, you can treat a Builder like a list. Just replace (++) >> by 'mappend' and [] by 'mempty'. >> >> It should work like this: >> >> do a <- getWord8 >> b <- getWord8 >> return $ Builder.singleton a `mappend` Builder.singleton b >> > > It worked for me pretty well. Profiling shown that in my program > {get,put}Stream functions takes less than 1% of execution time. > I don't know which tricks ghc used. > > I think code with list is more clear. Another problem that you can't use > existing Binary instances with Builder. You can since there is http://hackage.haskell.org/packages/archive/binary/0.5.0.1/doc/html/Data-Binary-Put.html#v%3AexecPut From lemming at henning-thielemann.de Sat May 23 15:23:05 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat May 23 15:07:37 2009 Subject: [Haskell-cafe] Data.Binary suboptimal instance Message-ID: Khudyakov Alexey schrieb: > On Saturday 23 May 2009 02:55:17 Antoine Latter wrote: >> Or you could go for the compromise position, where the list can be >> part of a complex data structure so you're not relying on EOF to find >> the end. >> > Interesting solution however it does not perform very nice. I wrote > microbenchmark > >> xs :: [Word32] >> xs = [1..(10^6)] > > Writing chunked list of Word32 >> B.writeFile "chunked" . toLazyByteString . putList putWord32be $ xs > real 0m4.311s > user 0m3.272s > sys 0m0.096s > > Reading chunked list of Word32 >> print . last . runGet (getList getWord32be) =<< B.readFile "chunked" > real 0m0.634s > user 0m0.496s > sys 0m0.012s > > > Writing stream of Word32 >> B.writeFile "stream" . encodeStream $ xs > real 0m0.391s > user 0m0.252s > sys 0m0.020s > > Reading stream of Word32 >> print . (last :: [Word32] -> Word32) . decodeStream =<< B.readFile "stream" > real 0m0.376s > user 0m0.248s > sys 0m0.020s > > > I didn'd do any profiling so I have no idea why writing is so slow. If you use top-level definition 'xs' the program might cache the list and second write is faster. You may change the order of tests in order check, whether that is the cause. From alexander.dunlap at gmail.com Sat May 23 16:02:15 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Sat May 23 15:53:33 2009 Subject: [Haskell-cafe] Re: Extensible Exceptions and IO In-Reply-To: <20090523160949.GA4149@matrix.chaos.earth.li> References: <57526e770904251118t37c68159k1f8e3e09c5c68374@mail.gmail.com> <20090523160949.GA4149@matrix.chaos.earth.li> Message-ID: <57526e770905231302ref2375ekc7379e0425aba37e@mail.gmail.com> On Sat, May 23, 2009 at 9:09 AM, Ian Lynagh wrote: > On Sat, Apr 25, 2009 at 11:18:43AM -0700, Alexander Dunlap wrote: >> In the extensible exceptions paper[1], which I believe is the guide >> behind the current Control.Exception in GHC 6.10, a SomeIOException >> type is discussed so that it would be possible to use the nice >> interface for IOExceptions. Is this implemented anywhere? In the GHC >> libraries, all I see is the old interface just plugged into a simple >> wrapper, so you have to use guard . isDoesNotExistError (for example) >> with catchJust to catch a certain type of exception. If not, are there >> any plans to implement it? > > I'm not aware of anyone currently working on putting the various core > libs' exceptions into a sensible hierarchy, but it would be great if > someone was to do so! > > I'd suggest that the best way to do this would be initially a > combination of discussions on the mailing list (if anything is > non-obvious) and building a design (and, if appropriate, rationale) on a > wiki page, and ending with a library submissions proposal once you have > a design worked out: > > http://www.haskell.org/haskellwiki/Library_submissions > > > Thanks > Ian > > I'm moving this from the GHC users' mailing list to the haskell-cafe mailing list because I think the discussion probably involves the entire Haskell community. Hi all, We have this new exception hierarchy in GHC base-4 and a lot of new machinery for dealing with it. Other libraries also seem to be springing up to provide alternative methods of dealing with these new exceptions. However, I have found that in most of my programming, the new exception functionality cannot be used to its fullest extent because the exceptions in the core libraries are not part of any sensible "tree" of exceptions, even though having this giant exception tree seems to be one of the premises of the new exception library. For example, there is an ArithException type in Control.Exception which records various arithmetic exceptions. However, there are two problems: (1) in order to fit in with the extensible exceptions theme, the type ought to be called SomeArithException and all of the types of ArithExceptions ought to be sub-exceptions of it, and (2) to my knowledge, this exception type doesn't seem to be thrown by anything in the base libraries. I think the biggest culprit is the IOException type, which also happens to be probably the most commonly-used exception type, since exceptions from IOException cannot really be anticipated and prevented. The current design of IOException is as follows. There is an abstract type called IOException. This can be queried with functions like isDoesNotExistError (which determines if the exception is because a file did not exist). Furthermore, to make an IOException, one has to use the mkIOError function, which takes a value of type IOErrorType, which is again an abstract type. I believe the reason for the abstract types is to allow implementations to extend the range of exceptions. Unfortunately, this has even more problems. For example, the error returned by using readFile on a directory cannot be determined using any Haskell98 function, meaning that code that wants to detect this error cannot be portable to compilers that don't have the new InappropriateType IO exception. The biggest problem with the current design of IOException, however, is that it doesn't play very nicely with the main hierarchy. Like with ArithExceptions, there should be a SomeIOException type. http://www.haskell.org/~simonmar/papers/ext-exceptions.pdf, which was the original paper on extensible exceptions, recommends having a class for IOExceptions that would allow us to get standard information from any specific IOException. I asked the GHC-users mailing list about this and Ian Lynagh recommended starting a discussion about how to put all of the core library exceptions into a sensible hierarchy. I think the goals here ought to be to make our new hierarchy as backward-compatible as possible. In particular, since many programs rely on the isWhateverError functionality, it would be nice to keep these in place. For IOExceptions, I think it would be nice to have a more multi-layered hierarchy than just SomeIOException and its subtypes. For example, I could see a hierarchy for IOExceptions looking something like this: SomeIOException - SomeCouldNotOpenException - AlreadyExists, NoSuchThing, PermissionDenied, InappropriateType - SomeResourceException - ResourceBusy, ResourceExhausted, ResourceVanished etc. I'm not all that familiar with the various exceptions and how they are used, so I'm not really able to propose a complete hierarchy for all the exceptions. I guess the purpose of this email was just to start off a discussion about what our exception hierarchy ought to look like. Thanks for reading this (admittedly long) message. Alex From alexander.dunlap at gmail.com Sat May 23 16:15:02 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Sat May 23 15:59:51 2009 Subject: [Haskell-cafe] Re: A problem with par and modules boundaries... In-Reply-To: References: <.1243099885@magma.ca> Message-ID: <57526e770905231315u209d91b7g3706fdd6e4c39f35@mail.gmail.com> On Sat, May 23, 2009 at 11:34 AM, Max Rabkin wrote: > On Sat, May 23, 2009 at 7:31 PM, Mario Bla?evi? wrote: >> Does anybody know of a pragma or another way to make a function *non-strict* even >> if it does always evaluate its argument? In other words, is there a way to >> selectively disable the strictness optimization? > > parallelize a b | False = (undefined, undefined) > ? ? ? ? ? ? ? ? ? | otherwise = a `par` (b `pseq` (a, b)) > > might do, unless strictness analysis is smart enough to know that the > False guard is always, well, False. > > --Max > _______________________________________________ GHC.Prim.lazy? Alex From matthias.goergens at googlemail.com Sat May 23 16:48:28 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Sat May 23 16:32:58 2009 Subject: [Haskell-cafe] ICFP Participation In-Reply-To: <20090523181525.GA16092@whirlpool.galois.com> References: <20090523181525.GA16092@whirlpool.galois.com> Message-ID: > Registration will be open soon. Thanks. (I could have written an Experience Report about how I am using Haskell at Deutsche Bahn, but that deadlines had already passed.) Matthias. From dons at galois.com Sat May 23 16:49:57 2009 From: dons at galois.com (Don Stewart) Date: Sat May 23 16:35:59 2009 Subject: [Haskell-cafe] ICFP Participation In-Reply-To: References: <20090523181525.GA16092@whirlpool.galois.com> Message-ID: <20090523204957.GE16092@whirlpool.galois.com> matthias.goergens: > > Registration will be open soon. > > Thanks. > > (I could have written an Experience Report about how I am using > Haskell at Deutsche Bahn, but that deadlines had already passed.) You could add a brief abstract to: http://haskell.org/haskellwiki/Haskell_in_industry As a starting point. And apply to give a talk at CUFP (actually, the deadline has passed :/) -- Don From matthias.goergens at googlemail.com Sat May 23 16:57:23 2009 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Sat May 23 16:41:53 2009 Subject: [Haskell-cafe] The Computer Language Benchmarks Game: pidigits In-Reply-To: <20090521193722.GD5819@whirlpool.galois.com> References: <93CD502BE7974AFAA73139A6B225F50E@ArnaudDesktop> <20090521193722.GD5819@whirlpool.galois.com> Message-ID: Hi, By the way: Would it be considered good style to include QuickTest properties into the pidigit submission? Matthias. From jeremy at n-heptane.com Sat May 23 17:01:08 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Sat May 23 16:45:39 2009 Subject: [Haskell-cafe] ICFP Participation In-Reply-To: References: Message-ID: <87hbzbmt4b.wl%jeremy@n-heptane.com> At Sat, 23 May 2009 19:31:42 +0200, Matthias G?rgens wrote: > > Hello, > > Please pardon my naive question: Is there a way to sign on for ICFP > 09? The homepage (http://www.cs.nott.ac.uk/~gmh/icfp09.html) only > seems to mention how to submit papers. Is there a way to attend as a > mere participant? I believe the ICFP 2009 programming competition this year is going to be to implement the attendee registration page... - jeremy From dons at galois.com Sat May 23 17:16:15 2009 From: dons at galois.com (Don Stewart) Date: Sat May 23 17:02:16 2009 Subject: [Haskell-cafe] The Computer Language Benchmarks Game: pidigits In-Reply-To: References: <93CD502BE7974AFAA73139A6B225F50E@ArnaudDesktop> <20090521193722.GD5819@whirlpool.galois.com> Message-ID: <20090523211615.GF16092@whirlpool.galois.com> matthias.goergens: > Hi, > > By the way: Would it be considered good style to include QuickTest > properties into the pidigit submission? > Not in the submission, no. From mxcantor at gmail.com Sat May 23 17:19:36 2009 From: mxcantor at gmail.com (Max Cantor) Date: Sat May 23 17:04:11 2009 Subject: [Haskell-cafe] Pattern match question in HAXML code In-Reply-To: <0C2D3FB3-BE82-47A8-AAE6-502F00BF761A@gmail.com> References: <57526e770904251118t37c68159k1f8e3e09c5c68374@mail.gmail.com> <20090523160949.GA4149@matrix.chaos.earth.li> <57526e770905231302ref2375ekc7379e0425aba37e@mail.gmail.com> <0C2D3FB3-BE82-47A8-AAE6-502F00BF761A@gmail.com> Message-ID: Going through the instances for HTypeable (http://www.haskell.org/HaXml/HaXml/src/Text/XML/HaXml/TypeMapping.html#toHType ) I saw the following instance for Either a b. My question is, why doesn't the pattern match in the where clause always fail? If (Left x) = m does not fail, doesn't that imply that m is a Left x and therefore the (Right y) = m should fail? thanks, max instance (HTypeable a, HTypeable b) => HTypeable (Either a b) where toHType m = Defined "Either" [hx, hy] [ Constr "Left" [hx] [hx] {-Nothing-} , Constr "Right" [hy] [hy] {-Nothing-}] where (Left x) = m (Right y) = m hx = toHType x hy = toHType y From byorgey at seas.upenn.edu Sat May 23 17:27:04 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat May 23 17:10:35 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 119 - May 23, 2009 Message-ID: <20090523212704.GA19247@seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090523 Issue 119 - May 23, 2009 --------------------------------------------------------------------------- Welcome to issue 119 of HWN, a newsletter covering developments in the [1]Haskell community. Announcements GHC porting works again. Ian Lynagh [2]announced that the [3]instructions for porting GHC to a new architecture now work again with the HEAD. If you get stuck when trying to do a port, feel free to ask on cvs-ghc at haskell.org or in #ghc on freenode. 6.10.4 plans. Ian Lynagh [4]announced plans for a 6.10.4 bugfix release of GHC. If you know of any bugs that you think should be looked into for 6.10.4, please let the development team know. The Timber compiler 1.0.3. Johan Nordlander [5]announced the release of version 1.0.3 of the Timber compiler. Timber is a modern language for building event-driven systems, based around the notion of reactive objects. It is also a purely functional language derived from Haskell, although with a strict evaluation semantics. 1.0.3 is a bug fix release, paving the way for future feature releases. mathlink-2.0.0.3. Tracy Wadleigh [6]announced the release of [7]mathlink, a library for writing Mathematica packages in Haskell. One simply writes some functions of type (MLGet a, MLPut b) => a -> IO b and provides a package specification in a simple DSL; the result is a program that exposes functions that can be called from Mathematica. text 0.2, fast and comprehensive Unicode support using stream fusion. Bryan O'Sullivan [8]announced the availability of [9]text 0.2, an efficient Unicode text library that uses stream fusion. New and notable in this release is support for lazy, chunked text, so you can process text files far larger than memory using a small footprint. Haskell Hackathon in Philadelphia. Brent Yorgey [10]announced Hac phi, a Haskell hackathon to be held in Philadelphia in July. Check out the [11]wiki page and add your name if you are interested in attending! More details to follow soon. feed2twitter 0.2 & hackage2twitter 0.2.1. Tom Lokhorst [12]announced the first release of [13]feed2twitter, a library for sending posts from a news feed to Twitter. EsotericBot 0.0.1. spoon [14]announced the release of [15]Esotericbot, a sophisticated, lightweight IRC bot, written in Haskell. atom 0.0.4. Tom Hawkins [16]announced a new release of [17]atom; this version adds an array datatype (A a). Hieroglyph-2.21 and buster, buster-gtk, and buster-network-2.0. Jeff Heard [18]announced new releases of [19]Hieroglyph, [20]buster, [21]buster-gtk, and [22]buster-network, with tons of changes; read Jeff's original announcement for details. TxtSushi 0.1. Keith Sheppard [23]announced the first version of [24]TxtSushi, a collection of command line utilities for processing tab-delimited and CSV files. It includes a utility for doing SQL SELECTs on flat files. Discussion Should exhaustiveness testing be on by default? Don Stewart started a [25]discussion, prompted by a [26]recent blog post, on whether coverage checking should be on by default, and other issues relating to compiler warnings and coding style. Proposal on the platform API policy question. Duncan Coutts [27]proposed a general policy for Haskell Platform release cycles and versioning, based on input from previous discussions. the problem of design by negation. Michael Mossey began a [28]discussion on software design philosophies. "Design by negation" considered harmful? Haskell in 3 Slides. John Van Enk [29]asked for ideas on a 3 to 4 slide introduction to Haskell. What do YOU think should be on those slides? Blog noise [30]Haskell news from the [31]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Bryan O'Sullivan: [32]Streaming Unicode support for Haskell: text 0.2. * Alex McLean: [33]Haskell hack. Music generation in Haskell. * Well-Typed.Com: [34]Building plugins as Haskell shared libs. A sneak preview of building Haskell shared libraries on Linux. * LHC Team: [35]New release: LHC 0.8. * Mark Wassell: [36]Grapefruit And Glade. * Conal Elliott: [37]The C language is purely functional. * >>> Will Donnelly: [38]Haskell: A Pretty Nice Language. * FP-Syd: [39]Sydney FP Group: FP-Syd #14.. * Dan Piponi (sigfpe): [40]Trace Diagrams with Monads. Quotes of the Week * roconnor: Damn it, I don't know how to make this as slow as python. * koeien: Let's register it [monomorphismrestriction.com] to prevent it from being used ;) * Elly: Rule 1 of malloc is the same as rule 1 of air travel: "Attempt at all costs to keep your number of landings equal to your number of takeoffs." * monochrom: I was trying to design a sensible language... then I downloaded ghc. * conal: The C ADT is implemented simply as String (or char *, for you type theorists, using a notation from Kleene) * Will Donnelly: monads are okay after a bit (though I'm still a little suspicious of them) About the Haskell Weekly News New editions are posted to [41]the Haskell mailing list as well as to [42]the Haskell Sequence and [43]Planet Haskell. [44]RSS is also available, and headlines appear on [45]haskell.org. To help create new editions of this newsletter, please see the information on [46]how to contribute. Send stories to byorgey at cis dot upenn dot edu. The darcs repository is available at darcs get [47]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://article.gmane.org/gmane.comp.lang.haskell.glasgow.user/16984 3. http://hackage.haskell.org/trac/ghc/wiki/Building/Porting 4. http://article.gmane.org/gmane.comp.lang.haskell.glasgow.user/16972 5. http://article.gmane.org/gmane.comp.lang.haskell.general/17200 6. http://article.gmane.org/gmane.comp.lang.haskell.general/17197 7. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/mathlink 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/58862 9. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/text 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/58817 11. http://www.haskell.org/haskellwiki/Hac_%CF%86 12. http://article.gmane.org/gmane.comp.lang.haskell.cafe/58801 13. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/feed2twitter 14. http://article.gmane.org/gmane.comp.lang.haskell.cafe/58796 15. http://www.killersmurf.com/projects/esotericbot 16. http://article.gmane.org/gmane.comp.lang.haskell.cafe/58752 17. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/atom 18. http://article.gmane.org/gmane.comp.lang.haskell.cafe/58683 19. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Hieroglyph 20. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/buster 21. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/buster-gtk 22. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/buster%2Dnetwork 23. http://article.gmane.org/gmane.comp.lang.haskell.cafe/58635 24. http://www.keithsheppard.name/txt-sushi 25. http://thread.gmane.org/gmane.comp.lang.haskell.glasgow.user/16926 26. http://ocaml.janestreet.com/?q=node/64 27. http://thread.gmane.org/gmane.comp.lang.haskell.libraries/11145 28. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/58784 29. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/58664 30. http://planet.haskell.org/ 31. http://haskell.org/haskellwiki/Blog_articles 32. http://www.serpentine.com/blog/2009/05/22/streaming-unicode-support-for-haskell-text-02/ 33. http://yaxu.org/haskell-hack/ 34. http://blog.well-typed.com/2009/05/buildings-plugins-as-haskell-shared-libs/ 35. http://lhc-compiler.blogspot.com/2009/05/new-release-lhc-08.html 36. http://www.poundstone.org/blog/?p=231 37. http://conal.net/blog/posts/the-c-language-is-purely-functional/ 38. http://willdonnelly.wordpress.com/2009/05/19/haskell-a-pretty-nice-language/ 39. http://www.mega-nerd.com/erikd/Blog/FP-Syd/fp-syd-14.html 40. http://blog.sigfpe.com/2009/05/trace-diagrams-with-monads.html 41. http://www.haskell.org/mailman/listinfo/haskell 42. http://sequence.complete.org/ 43. http://planet.haskell.org/ 44. http://sequence.complete.org/node/feed 45. http://haskell.org/ 46. http://haskell.org/haskellwiki/HWN 47. http://code.haskell.org/~byorgey/code/hwn/ From arnaud.payement at gmail.com Sat May 23 17:33:54 2009 From: arnaud.payement at gmail.com (Arnaud Payement) Date: Sat May 23 17:18:43 2009 Subject: [Haskell-cafe] The Computer Language Benchmarks Game: pidigits In-Reply-To: <20090523211615.GF16092@whirlpool.galois.com> References: <93CD502BE7974AFAA73139A6B225F50E@ArnaudDesktop> <20090521193722.GD5819@whirlpool.galois.com> <20090523211615.GF16092@whirlpool.galois.com> Message-ID: <37C445B338714D7FAB34EA48B5E9F47F@ArnaudDesktop> By the way, I did submit my solution. It improved the score a bit but it is still very memory hungry. ----- Original Message ----- From: "Don Stewart" To: "Matthias G?rgens" Cc: "Arnaud Payement" ; Sent: Saturday, May 23, 2009 10:16 PM Subject: Re: [Haskell-cafe] The Computer Language Benchmarks Game: pidigits > matthias.goergens: >> Hi, >> >> By the way: Would it be considered good style to include QuickTest >> properties into the pidigit submission? >> > > Not in the submission, no. From dons at galois.com Sat May 23 17:37:57 2009 From: dons at galois.com (Don Stewart) Date: Sat May 23 17:23:59 2009 Subject: [Haskell-cafe] The Computer Language Benchmarks Game: pidigits In-Reply-To: <37C445B338714D7FAB34EA48B5E9F47F@ArnaudDesktop> References: <93CD502BE7974AFAA73139A6B225F50E@ArnaudDesktop> <20090521193722.GD5819@whirlpool.galois.com> <20090523211615.GF16092@whirlpool.galois.com> <37C445B338714D7FAB34EA48B5E9F47F@ArnaudDesktop> Message-ID: <20090523213757.GH16092@whirlpool.galois.com> That's fixed in GHC 6.10.2 + though, IIRC. arnaud.payement: > By the way, I did submit my solution. It improved the score a bit but it > is still very memory hungry. > > > ----- Original Message ----- From: "Don Stewart" > To: "Matthias G?rgens" > Cc: "Arnaud Payement" ; > > Sent: Saturday, May 23, 2009 10:16 PM > Subject: Re: [Haskell-cafe] The Computer Language Benchmarks Game: pidigits > > >> matthias.goergens: >>> Hi, >>> >>> By the way: Would it be considered good style to include QuickTest >>> properties into the pidigit submission? >>> >> >> Not in the submission, no. > From miguelimo38 at yandex.ru Sat May 23 17:43:15 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Sat May 23 17:27:49 2009 Subject: [Haskell-cafe] Pattern match question in HAXML code In-Reply-To: References: <57526e770904251118t37c68159k1f8e3e09c5c68374@mail.gmail.com> <20090523160949.GA4149@matrix.chaos.earth.li> <57526e770905231302ref2375ekc7379e0425aba37e@mail.gmail.com> <0C2D3FB3-BE82-47A8-AAE6-502F00BF761A@gmail.com> Message-ID: <65F7D780-64A1-4F10-84F4-76C0797D5231@yandex.ru> On 24 May 2009, at 01:19, Max Cantor wrote: > Going through the instances for HTypeable (http://www.haskell.org/HaXml/HaXml/src/Text/XML/HaXml/TypeMapping.html#toHType > ) I saw the following instance for Either a b. > > My question is, why doesn't the pattern match in the where clause > always fail? If (Left x) = m does not fail, doesn't that imply that > m is a Left x and therefore the (Right y) = m should fail? It does; at least one of x and y is (_|_). However, toHType function doesn't really need it's argument; all that is needed is the type of an argument. Therefore, toHType is quite happy to receive (_|_) as an argument - so, hx and hy are well-defined. > > > thanks, max > > > > instance (HTypeable a, HTypeable b) => HTypeable (Either a b) where > toHType m = Defined "Either" [hx, hy] > [ Constr "Left" [hx] [hx] {-Nothing-} > , Constr "Right" [hy] [hy] {-Nothing-}] > where (Left x) = m > (Right y) = m > hx = toHType x > hy = toHType y > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From duncan.coutts at worc.ox.ac.uk Sat May 23 14:51:41 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat May 23 18:27:25 2009 Subject: [Haskell-cafe] Re: A problem with par and modules boundaries... In-Reply-To: <1243103576.20307.167.camel@localhost> References: <1243103576.20307.167.camel@localhost> Message-ID: <1243104701.20307.180.camel@localhost> On Sat, 2009-05-23 at 13:31 -0400, Mario Bla?evi? wrote: > >>> You could probably see exactly what's happening in > >>> more detail by going through the Core output. > >> > >> Thank you, this advice helped. The Core output indicates > >> that function `test' evaluates the arguments to > >> `parallelize' before it calls it. In other words, the > >> call to `parallelize' is optimized as a strict function > >> call -- which it is. The problem is that this > >> optimization evaluates the arguments sequentially. > >> Compiling with optimizations turned off regains the > >> parallel execution. > >> > >> I guess I will report this as a GHC bug. Or is it a > >> feature request? > > > > As Duncan suggessted, try with GHC head (grab a snapshot). `par` et al > > are much improved. > > I already have, with the snapshot from 21st of April. It behaves the same > as 6.8.2, except it runs for twice as long. > > I'd like to take back a part of what I said before, though: `parallelize' should > be strict only in its second argument. parallelize a b = a `par` (b `pseq` (a, b)) GHC infers that strictness of parallelize. It thinks that it is lazy in both args (you can check this yourself using ghc --show-iface). That's because the definitions of par and pseq use the function 'lazy': -- The reason for the strange "lazy" call is that it fools -- the compiler into thinking that pseq and par are non-strict in -- their second argument (even if it inlines pseq at the call site). -- If it thinks pseq is strict in "y", then it often evaluates -- "y" before "x", which is totally wrong. pseq x y = x `seq` lazy y par x y = case (par# x) of { _ -> lazy y } So GHC thinks that par is lazy in both arguments, while it thinks pseq is strict in the first and lazy in the second. > Its strictness in the first argument should be the same as with `par`. Yes, which it is. > Even though `parallelize x y' always evaluates both x and y, Be careful about what you mean. Yes, it starts the evaluation of x in parallel with y, but that does not mean it is strict in x, as you notice with your example of undefined below. > the following test works fine with optimizations even if `parallelize' > is imported: > > main = putStrLn (snd $ parallelize undefined "Hello, World!") > > So the function is not strict, and I don't understand why GHC should evaluate the > arguments before the call. Right, it's lazy in the first and strict in the second argument. As far as I can see we have no evidence that is is evaluating anything before the call. > Does anybody know of a pragma or another way to make a function *non-strict* even > if it does always evaluate its argument? In other words, is there a way to > selectively disable the strictness optimization? Yes, which is what pseq and par already do. If there's a bug, we need to reproduce it and report it. I cannot reproduce it. Duncan From mblazevic at stilo.com Sat May 23 18:56:25 2009 From: mblazevic at stilo.com (=?utf-8?B?TWFyaW8gQmxhxb5ldmnEhw==?=) Date: Sat May 23 18:40:54 2009 Subject: [Haskell-cafe] Re: A problem with par and modules boundaries... Message-ID: <.1243119385@magma.ca> On Sat 23/05/09 4:15 PM , Alexander Dunlap alexander.dunlap@gmail.com sent: >>> Does anybody know of a pragma or another way to make a >>> function *non-strict* even if it does always evaluate its >>> argument? In other words, is there a way to >>> selectively disable the strictness optimization? >> >> parallelize a b | False = (undefined, undefined) >> ? ? ? ? ? ? ? ? | otherwise = a `par` (b `pseq` (a, b)) >> >> might do, unless strictness analysis is smart enough to >> know that the False guard is always, well, False. >> _______________________________________________ > > GHC.Prim.lazy? It's GHC.Exts.lazy nowadays, and it doesn't have any effect. Neither does the `| False' guard. The only way I found to disable the eager argument evaluation is to pass them in as functions: > parallelize :: Num t => (t -> a) -> (t -> b) -> (a, b) > parallelize a b = let a' = a 1 > b' = b 1 > in (a' `par` (b' `pseq` (a', b'))) Then it can be imported and called like this: > test n1 n2 = let (p1, p2) = parallelize > (\n0-> product $ factors $ product [n0..n1]) > (\n0-> product $ factors $ product [n0..n2]) This solution is incredibly fragile. If the declared type of parallelize is modified by replacing t by Integer, the evaluation becomes eager again. Also, the argument functions can't simply take () for argument which would make this solution reasonable. If this is all the strictness optimizer's fault, I'm awed by how difficult it is to trick it into not doing its job. From brian at lorf.org Sat May 23 19:23:46 2009 From: brian at lorf.org (brian@lorf.org) Date: Sat May 23 19:08:26 2009 Subject: [Haskell-cafe] hackage version scheme survey Message-ID: <20090523232346.GL16279@doses> It's not good to specify open version ranges in cabal build-depends like foo >= 1.1 because the foo maintainer will eventually release 2.0, containing API-breaking changes, and the build will fail. If you depend on foo 1.1, you can specify == 1.*, no problem. But if you depend on a package that uses a version scheme like 1.2.3 or 1.2.3.4, it's not clear (at least to me) where the major/minor division is. I did a survey of version schemes in 'cabal list': 484 packages use a.b. 630 packages use a.b.c. 180 packages use a.b.c.d. The rest: two packages use just one field for their versions; one uses five; one uses six. Maybe most of the a.b people are thinking major.minor, and most of the a.b.c people are thinking breaking.feature.implementation like the "rational" RubyGems scheme described in http://rubygems.org/read/chapter/7#page24 , but I don't know. It makes it hard to describe dependencies. Will there be a standard versioning scheme sometime? From david.waern at gmail.com Sat May 23 19:28:39 2009 From: david.waern at gmail.com (David Waern) Date: Sat May 23 19:13:09 2009 Subject: [Haskell-cafe] hackage version scheme survey In-Reply-To: <20090523232346.GL16279@doses> References: <20090523232346.GL16279@doses> Message-ID: 2009/5/24 : > Maybe most of the a.b people are thinking major.minor, and most of the > a.b.c people are thinking breaking.feature.implementation like the > "rational" RubyGems scheme described in > http://rubygems.org/read/chapter/7#page24 , but I don't know. It makes > it hard to describe dependencies. Will there be a standard versioning > scheme sometime? We have one already: http://www.haskell.org/haskellwiki/Package_versioning_policy David From david.waern at gmail.com Sat May 23 19:32:57 2009 From: david.waern at gmail.com (David Waern) Date: Sat May 23 19:17:27 2009 Subject: [Haskell-cafe] Re: haddock could be a pretty-printer? In-Reply-To: References: Message-ID: 2009/5/22 Maur?cio : >>> The new version of haddock makes use of GHC parser. How much >>> of effort would take to make haddock generate pretty-print >>> of the source code itself, (...) > >> (...) Is this what you want or is there some reason why you >> want the code to be pretty-printed? > > I usually have to resort to braces or bad indenting to get > code to parse, but I like to give it good presentation before > publishing. > > I used to pretty-print my code using haskell-src-exts with > great result, but that kills documentation. I think the plan is to extend haskell-src-exts to retain comments. But if you want something that works now, you could use the GHC API. It has support for getting the token stream of a module, which contains the comments as tokens. Using Haddock to do this is not a good idea, better use the GHC API directly. David From simon at joyful.com Sat May 23 20:18:47 2009 From: simon at joyful.com (Simon Michael) Date: Sat May 23 20:03:18 2009 Subject: [Haskell-cafe] ANN: hledger 0.5 released Message-ID: I'm pleased to announce the hledger 0.5 release on hackage. hledger is a (mostly) text-mode double-entry accounting tool that generates precise activity and balance reports from a plain text journal file. It is a partial clone, in haskell, of John Wiegley's excellent ledger. hledger implements a subset of ledger's commands and options, and also provides some new ones. For basic use you can use hledger and ledger pretty much interchangeably on the same data files. For screenshots, live demo, docs etc. see http://hledger.org . Release notes are at http://hledger.org/NEWS , and below. To install: cabal install hledger [-fvty] [-fhapps]. I'd like to hear feedback, especially if you are having trouble getting started. Happy tracking! - Simon (sm on #ledger) 2009/05/23 hledger 0.5 released ------------------------------- Changes: * the vty flag is disabled by default again, to ease installation on windows * use ledger 3 terminology: a ledger contains transactions which contain postings * new "add" command prompts for transactions interactively and adds them to the ledger * new "convert" command transforms bank CSV exports to ledger format, with rule-based cleanup * new "histogram" command shows transaction counts per day or other reporting interval * most commands now work properly with UTF8-encoded text (Sergey Astanin) * invoking as "hours" is now less different: it just uses your timelog, not your ledger * --quarterly/-Q option summarises by quarter * --uncleared/-U option looks only at uncleared transactions * be more accurate about checking balanced amounts, don't rely on display precision * enforce balancing for bracketed virtual postings * fix bug in eliding of posting amounts * don't show trailing spaces on amountless postings * parse null input as an empty ledger * don't treat comments as part of transaction descriptions * require some postings in ledger transactions * require a non-empty description in ledger transactions * don't fail when matching an empty pattern, as in "not:" * make the web server handle the null path * code, api and documentation updates * add a contributor agreement/list Release contributors: * Simon Michael * Sergey Astanin Release stats: * Days since last release: 51 * Committers: 2 * Commits: 101 * Lines of non-test code: 2795 * Known errors: 0 * Tests: 76 * Performance: || hledger-0.4 | hledger-0.5 | ledger =========================++=============+=============+======= -f sample.ledger balance || 0.01 | 0.01 | 0.06 -f 1000.ledger balance || 1.33 | 1.46 | 0.53 -f 10000.ledger balance || 15.28 | 16.35 | 4.67 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090523/5d11cb82/attachment.html From dons at galois.com Sat May 23 20:26:59 2009 From: dons at galois.com (Don Stewart) Date: Sat May 23 20:13:03 2009 Subject: [Haskell-cafe] hackage version scheme survey In-Reply-To: <20090523232346.GL16279@doses> References: <20090523232346.GL16279@doses> Message-ID: <20090524002659.GB17739@whirlpool.galois.com> brian: > Maybe most of the a.b people are thinking major.minor, and most of the > a.b.c people are thinking breaking.feature.implementation like the > "rational" RubyGems scheme described in > http://rubygems.org/read/chapter/7#page24 , but I don't know. It makes > it hard to describe dependencies. Will there be a standard versioning > scheme sometime? http://haskell.org/haskellwiki/Package_versioning_policy ? From mblazevic at stilo.com Sat May 23 20:42:11 2009 From: mblazevic at stilo.com (=?utf-8?B?TWFyaW8gQmxhxb5ldmnEhw==?=) Date: Sat May 23 20:26:43 2009 Subject: [Haskell-cafe] Re: A problem with par and modules boundaries... Message-ID: <.1243125731@magma.ca> On Sat 23/05/09 2:51 PM , Duncan Coutts duncan.coutts@worc.ox.ac.uk sent: > On Sat, 2009-05-23 at 13:31 -0400, Mario Bla?evi? wrote: > ... >> So the function is not strict, and I don't understand >> why GHC should evaluate the arguments before the call. > > Right, it's lazy in the first and strict in the second argument. As far > as I can see we have no evidence that is is evaluating anything before > the call. When I look at the Core definition of `test', it begins with \ (n1axl::integer:GHCziIntegerziInternals.Integer) (n2axn::integer:GHCziIntegerziInternals.Integer) -> %let as1sU :: integer:GHCziIntegerziInternals.Integer = base:DataziList.prod1 (main:Main.factors2 (base:DataziList.prod1 (base:GHCziNum.upzulist main:Main.lvl main:Main.lvl n1axl) base:DataziList.lvl1)) base:DataziList.lvl1 %in %case integer:GHCziIntegerziInternals.Integer (ghczmprim:GHCziPrim.parzh @ integer:GHCziIntegerziInternals.Integer as1sU) %of (dsapq::ghczmprim:GHCziPrim.Intzh) To my untrained eyes, this looks like it's evaluating > product $ factors $ product [1..n1]) which is the first argument to `parallelize'. I assume that %case in Core evaluates the argument to WHNF, just like case in Haskell. Then again, I could be completely misinterpreting what Core is, because I can't find any call to `parallelize' before or after that. It appears to be inlined in Core, regardless of whether the pragma > {-# INLINE parallelize #-} is there or not. Actually, I can't see any effect of that pragma in the core files whatsoever, but it certainly has effect on run time. >> Does anybody know of a pragma or another way to make a >> function *non-strict* even if it does always evaluate its argument? >> In other words, is there a way to selectively disable the strictness >> optimization? > > Yes, which is what pseq and par already do. > > If there's a bug, we need to reproduce it and report it. I cannot > reproduce it. If you mean that you can't reproduce anything that's contrary to the specification, that's not saying much: there are practically no guarantees on what `par' is supposed to accomplish. If you mean you can't reproduce anything you wouldn't expect, pray explain what is going on, because everybody else seems to be surprised. Or do you mean to say that *your* installation of GHC behaves the same when the function `parallelize' is defined in the same module and when it's imported? From brian at lorf.org Sat May 23 20:57:18 2009 From: brian at lorf.org (brian@lorf.org) Date: Sat May 23 20:41:59 2009 Subject: [Haskell-cafe] hackage version scheme survey In-Reply-To: <20090524002659.GB17739@whirlpool.galois.com> References: <20090523232346.GL16279@doses> <20090524002659.GB17739@whirlpool.galois.com> Message-ID: <20090524005718.GM16279@doses> On Saturday, 23.05.09 at 17:26, Don Stewart wrote: > http://haskell.org/haskellwiki/Package_versioning_policy ? That helps a lot. I should have found that. But putting the policy on a web page doesn't seem to be working; there are a lot of non-compliant packages. I guess I'm surprised thah 'cabal check' doesn't complain about it and HDB doesn't reject them. From wren at freegeek.org Sat May 23 21:10:42 2009 From: wren at freegeek.org (wren ng thornton) Date: Sat May 23 20:55:11 2009 Subject: [Haskell-cafe] hackage version scheme survey In-Reply-To: <20090524005718.GM16279@doses> References: <20090523232346.GL16279@doses> <20090524002659.GB17739@whirlpool.galois.com> <20090524005718.GM16279@doses> Message-ID: <4A189E92.7090206@freegeek.org> brian@lorf.org wrote: > On Saturday, 23.05.09 at 17:26, Don Stewart wrote: > > http://haskell.org/haskellwiki/Package_versioning_policy ? > > That helps a lot. I should have found that. But putting the policy on a > web page doesn't seem to be working; there are a lot of non-compliant > packages. I guess I'm surprised thah 'cabal check' doesn't complain > about it and HDB doesn't reject them. I hear they're looking for someone to write a program to check for API changes in order to detect and enforce the policy :) Care to help? -- Live well, ~wren From brian at lorf.org Sat May 23 21:33:27 2009 From: brian at lorf.org (Brian Lewis) Date: Sat May 23 21:18:08 2009 Subject: [Haskell-cafe] hackage version scheme survey In-Reply-To: <4A189E92.7090206@freegeek.org> References: <20090523232346.GL16279@doses> <20090524002659.GB17739@whirlpool.galois.com> <20090524005718.GM16279@doses> <4A189E92.7090206@freegeek.org> Message-ID: <20090524013327.GA30284@doses> On Saturday, 23.05.09 at 21:10, wren ng thornton wrote: > I hear they're looking for someone to write a program to check for API > changes in order to detect and enforce the policy :) Care to help? Yeah, I'm looking into it. From deb at pudlak.name Sun May 24 04:15:44 2009 From: deb at pudlak.name (Petr Pudlak) Date: Sun May 24 04:00:15 2009 Subject: [Haskell-cafe] Haskell type system and the lambda cube Message-ID: <20090524081544.GA13457@pudlak.name> Hi, I'm trying to get some better understanding of the theoretical foundations behind Haskell. I wonder, where exactly does Haskell type system fit within the lambda cube? I guess it could also vary depending on what extensions are turned on. Thanks, Petr From ekirpichov at gmail.com Sun May 24 04:18:40 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sun May 24 04:03:13 2009 Subject: [Haskell-cafe] Haskell type system and the lambda cube In-Reply-To: <20090524081544.GA13457@pudlak.name> References: <20090524081544.GA13457@pudlak.name> Message-ID: <5e0214850905240118p2ae9d6d9w345273508b1b7981@mail.gmail.com> Haskell has terms depending on types (polymorphic terms) and types depending on types (type families?), but no dependent types. 2009/5/24 Petr Pudlak : > Hi, I'm trying to get some better understanding of the theoretical foundations > behind Haskell. I wonder, where exactly does Haskell type system fit within the > lambda cube? > I guess it could also vary depending on what extensions are turned on. > > ? ?Thanks, Petr > _______________________________________________ > 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 deb at pudlak.name Sun May 24 04:39:50 2009 From: deb at pudlak.name (Petr Pudlak) Date: Sun May 24 04:24:21 2009 Subject: [Haskell-cafe] Haskell type system and the lambda cube In-Reply-To: <5e0214850905240118p2ae9d6d9w345273508b1b7981@mail.gmail.com> References: <20090524081544.GA13457@pudlak.name> <5e0214850905240118p2ae9d6d9w345273508b1b7981@mail.gmail.com> Message-ID: <20090524083950.GA27329@pudlak.name> On Sun, May 24, 2009 at 12:18:40PM +0400, Eugene Kirpichov wrote: > Haskell has terms depending on types (polymorphic terms) and types > depending on types (type families?), but no dependent types. But how about undecidability? I'd say that lambda2 or lambda-omega have undecidable type checking, whereas Haskell's Hindley-Milner type system is decidable. From this I get that Haskell's type system can't be one of the vertices of the cube. (BWT, will some future version of Haskell consider including some kind of dependent types?) Petr > > 2009/5/24 Petr Pudlak : > > Hi, I'm trying to get some better understanding of the theoretical foundations > > behind Haskell. I wonder, where exactly does Haskell type system fit within the > > lambda cube? > > I guess it could also vary depending on what extensions are turned on. > > > > ? ?Thanks, Petr > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru From ekirpichov at gmail.com Sun May 24 05:31:33 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sun May 24 05:1