From prstanley at ntlworld.com Sat Dec 1 01:18:31 2007 From: prstanley at ntlworld.com (PR Stanley) Date: Sat Dec 1 01:14:24 2007 Subject: [Haskell-cafe] Editorial error or something meaningful? Message-ID: <7.0.1.0.0.20071201061602.01b98380@ntlworld.com> Hi taken from ch.8.3 in the Hutton book: "Whereas return v always succeeds, the dual parser failure always fails regardless of the contents of the input string:" The dual parser failure? Cheers, Paul From lrpalmer at gmail.com Sat Dec 1 02:06:39 2007 From: lrpalmer at gmail.com (Luke Palmer) Date: Sat Dec 1 02:02:21 2007 Subject: [Haskell-cafe] Design of a Physics Interface In-Reply-To: <475063E4.8040200@imageworks.com> References: <7ca3f0160711300623j1cefcac3k7c013f14a21ebeae@mail.gmail.com> <475063E4.8040200@imageworks.com> Message-ID: <7ca3f0160711302306k75b4ac99ga6c240b0a47e573d@mail.gmail.com> On Nov 30, 2007 7:26 PM, Dan Weston wrote: > There seems to be three salient benefits of using arrows, as I read the > Abstract and Introduction of Benjamin Lerner, "Arrow Laws and Efficiency > in Yampa", 2003, > http://zoo.cs.yale.edu/classes/cs490/03-04a/benjamin.lerner/ > > 1) The discipline of using arrows assists in avoiding space-leaks > "The reasons underlying this...primarily stemmed from the > availability of signals as first-class values." > [the "ugly pain" you experience up front saves you > chronic pain later. Self-discipline is the key to a happy life.] I experienced the chronic pain in my initial comonadic implementation of FRP. It was pretty, but ran in quaadratic time :-(. To be clear, I am not abandoning arrows in FRP. I am abandoning using an arrow to represent *each* object in favor of moving objects into the value level rather than the signal level. i.e. the following dies: ball :: Position -> Velocity -> SF PhysIn PhysOut ... In favor of game = proc () -> do rec world <- integrate initWorld -< trajectory world ... I have an idea for an external solution though that I'm going to play with now. I'll report on how it goes :-) Luke From jon.fairbairn at cl.cam.ac.uk Sat Dec 1 05:34:48 2007 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Sat Dec 1 05:30:39 2007 Subject: [Haskell-cafe] Re: Editorial error or something meaningful? References: <7.0.1.0.0.20071201061602.01b98380@ntlworld.com> Message-ID: PR Stanley writes: > Hi > taken from ch.8.3 in the Hutton book: > "Whereas return v always succeeds, the dual parser failure > always fails regardless of the contents of the input > string:" > The dual parser failure? It's a question of how you parse the phrase "dual parser failure". The name of the parser is "failure" and it is the dual (roughly meaning "opposite") of the parser "return". -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From daniel.is.fischer at web.de Sat Dec 1 06:47:39 2007 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Dec 1 06:42:48 2007 Subject: [Haskell-cafe] Editorial error or something meaningful? In-Reply-To: <7.0.1.0.0.20071201061602.01b98380@ntlworld.com> References: <7.0.1.0.0.20071201061602.01b98380@ntlworld.com> Message-ID: <200712011247.39251.daniel.is.fischer@web.de> Am Samstag, 1. Dezember 2007 07:18 schrieb PR Stanley: > Hi > taken from ch.8.3 in the Hutton book: > "Whereas return v always succeeds, the dual parser failure always > fails regardless of the contents of the input string:" > The dual parser failure? > Cheers, > Paul > The dual parser, "failure", probably. Cheers, Daniel From dav.vire+haskell at gmail.com Sat Dec 1 07:37:56 2007 From: dav.vire+haskell at gmail.com (david48) Date: Sat Dec 1 07:33:39 2007 Subject: [Haskell-cafe] Re: Categories list in French (off-topic?) In-Reply-To: References: <47500ECF.7050001@cern.ch> Message-ID: <4c88418c0712010437p39be4edl96d87629a86c532a@mail.gmail.com> On Nov 30, 2007 9:13 PM, Maur??cio wrote: > Nice tip. Do you know of a free news server > that allows read and post for that group? http://groups.google.com/group/fr.sci.maths/topics?lnk=gschg From claus.reinke at talk21.com Sat Dec 1 09:36:56 2007 From: claus.reinke at talk21.com (Claus Reinke) Date: Sat Dec 1 09:32:43 2007 Subject: [Haskell-cafe] trouble building "unix-2.2.0.0" on cygwin References: <5ae4f2ba0711301828v1496c1d0le0c0eaa4887a561e@mail.gmail.com> Message-ID: <00c001c83427$a0a4e870$63408351@cr3lt> hi, with the large number of "just chatting" messages on haskell-cafe, it is all too easy to miss problem reports here. you might have a better chance asking on more specific lists, eg. for ghc use, or library issues http://www.haskell.org/mailman/listinfo/glasgow-haskell-users http://www.haskell.org/mailman/listinfo/libraries > 0) All work being done on cygwin. Version 6.8.1 of ghc. the standard build of ghc uses cygwin tools to build a no-cygwin ghc. in particular, ghc is not linked with the posix-emulation libraries of cygwin, nor does it use cygwin's compiler or linker. so, unless you've made a non-standard cygwin-linked ghc, the unix package is unlikely to build with that ghc. do you really need the unix package? a lot of general functionality is available in platform-independent haskell libraries, and some of the unix-package functionality is available in unix compatibility packages. > 1) I ran "runhaskell Setup.lhs configure" and did a "tail -f config.log" > in order to follow the config process. > > 2) Next I did the build "runhaskell Setup.lhs build" but there were > many include files referenced in HsUnix.h that couldn't be found, e.g. > sys/times.h, sys/resources.h, sys/wait.h, .... > > 3) I went back through the file config.log and all of the so-called > missing include files had supposedly been found during the config process. > > 4) Next I went to c:/cygwin/usr/include/sys and found all of the > so-called missing include files. > > I am trying to get my confidence level up with respect to the > config/build/install (and along with darcs and haddock) process up high so I > can make a significant contribution to the Haskell effort. please .. any > help will be appreciated. it is quite possible to work with a no-cygwin ghc in a cygwin environment. the environment supplies the build tools that some haskell packages and tools need for configuration and build, then the no-cygwin ghc produces a no-cygwin executable (which can be run from cygwin, or as any other windows-only program). that is indeed the default setup for ghc development on windows, so darcs, haddock, etc. should work in it, apart from a few rough edges. helping to smooth those edges, where things that should work don't quite work on windows, would be a significant contribution, imho. ideally, all haskell tools should work on windows entirely without non-windows tools, and while that is not likely in the near future, many of them already do, and reducing unix-dependencies helps to make haskell easier to use for windows users (just as avoiding windows-dependencies ensures that unix users are not excluded!-). claus From prstanley at ntlworld.com Sat Dec 1 10:13:32 2007 From: prstanley at ntlworld.com (PR Stanley) Date: Sat Dec 1 10:09:29 2007 Subject: [Haskell-cafe] Sequencing Parsers: a Simple Example Message-ID: <7.0.1.0.0.20071201150159.01b4f110@ntlworld.com> Hi (>>=) :: Parser a -> Parser b -> Parser b p >>= f = \inp -> case p inp of [] -> [] [(v, out)] -> parse (f v) out based on a lot of guesswork, after the mess created by the OCR, I managed to get the above example to work syntactically but is it semantically correct? Thanks, Paul From andrewcoppin at btinternet.com Sat Dec 1 10:28:47 2007 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Dec 1 10:24:20 2007 Subject: [Haskell-cafe] An unusual prime number generator... Message-ID: <47517DAF.4070102@btinternet.com> Hi guys. I just wrote this prime number generator. It's... unusual. It seems to go increadibly fast though. Indeed, I asked it to write the first 1,000,000 prime numbers to a text file, and scanning the bit array seemed to take longer than constructing the bit array! Odd... Anyway, for your amusement: module Primes2 (compute_primes) where import Data.Word import Data.Array.IO seive :: IOUArray Word32 Bool -> Word32 -> Word32 -> IO () seive grid size p = mapM_ (\n -> writeArray grid n False) [p, 2*p .. size] next_prime :: IOUArray Word32 Bool -> IO Word32 next_prime grid = work grid 2 where work grid n = do p <- readArray grid n if p then return n else work grid (n+1) copy :: Word32 -> IOUArray Word32 Bool -> Word32 -> IO (IOUArray Word32 Bool) copy p grid size = do let size' = size * p grid' <- newArray (1,size') False mapM_ (\n -> do b <- readArray grid n if b then mapM_ (\x -> writeArray grid' (n + size*x) True) [0..p-1] else return () ) [1..size] return grid' init_grid :: IO (IOUArray Word32 Bool) init_grid = do grid <- newArray (1,6) False writeArray grid 1 True writeArray grid 5 True return grid compute_primes :: Word32 -> IO [Word32] compute_primes n = do g0 <- init_grid ps <- work n g0 6 return (2:3:ps) where work top grid size | size >= top = do p <- next_prime grid putStrLn $ "Found prime: " ++ show p if p > top then return [p] else do seive grid size p ps <- work top grid size return (p:ps) | otherwise = do p <- next_prime grid putStrLn $ "Seiving prime: " ++ show p let size' = p*size grid' <- copy p grid size seive grid' size' p ps <- work top grid' size' return (p:ps) -- Debug... show_grid :: IOUArray Word32 Bool -> IO () show_grid grid = do (b0,b1) <- getBounds grid mapM_ (\n -> do x <- readArray grid n; if x then putChar '-' else putChar '#') [b0..b1] putStrLn ":" From shachaf at gmail.com Sat Dec 1 11:30:50 2007 From: shachaf at gmail.com (Shachaf Ben-Kiki) Date: Sat Dec 1 11:26:31 2007 Subject: [Haskell-cafe] Sequencing Parsers: a Simple Example In-Reply-To: <7.0.1.0.0.20071201150159.01b4f110@ntlworld.com> References: <7.0.1.0.0.20071201150159.01b4f110@ntlworld.com> Message-ID: <20594c670712010830x527c2b20q7eeebc695a1a6cbb@mail.gmail.com> > Hi > (>>=) :: Parser a -> Parser b -> Parser b > p >>= f = \inp -> > case p inp of > [] -> [] > [(v, out)] -> parse (f v) out > based on a lot of guesswork, after the mess created by the OCR, I > managed to get the above example to work syntactically but is it > semantically correct? > Thanks, Paul You probably want: (>>=) :: Parser a -> (a -> Parser b) -> Parser b p >>= f = \inp -> case parse p inp of [] -> [] [(v,out)] -> parse (f v) out Assuming that you're following Graham Hutton's book. Note that this definition won't actually compile; you probably need a Monad instance and a newtype to get this to work properly (see http://www.cs.nott.ac.uk/~gmh/Parsing.lhs for a working version of the same code). Shachaf From prstanley at ntlworld.com Sat Dec 1 12:02:30 2007 From: prstanley at ntlworld.com (PR Stanley) Date: Sat Dec 1 11:58:07 2007 Subject: [Haskell-cafe] Sequencing Parsers: a Simple Example In-Reply-To: <20594c670712010830x527c2b20q7eeebc695a1a6cbb@mail.gmail.co m> References: <7.0.1.0.0.20071201150159.01b4f110@ntlworld.com> <20594c670712010830x527c2b20q7eeebc695a1a6cbb@mail.gmail.com> Message-ID: <7.0.1.0.0.20071201165638.01b44df0@ntlworld.com> > > PRS: (>>=) :: Parser a -> Parser b -> Parser b > > p >>= f = \inp -> > > case p inp of > > [] -> [] > > [(v, out)] -> parse (f v) out > >You probably want: > >(>>=) :: Parser a -> (a -> Parser b) -> Parser b >p >>= f = \inp -> case parse p inp of > [] -> [] > [(v,out)] -> parse (f v) out > >Assuming that you're following Graham Hutton's book. > >Note that this definition won't actually compile; you probably need a >Monad instance and a newtype to get this to work properly (see >http://www.cs.nott.ac.uk/~gmh/Parsing.lhs for a working version of the >same code). PRS: That explains it then. [(v, out)] -> parse (f v) out caused a type mismatch. Cheers, Paul From hthiel.char at zonnet.nl Sat Dec 1 14:26:05 2007 From: hthiel.char at zonnet.nl (Hans van Thiel) Date: Sat Dec 1 14:22:45 2007 Subject: [Haskell-cafe] ANN: Teach Yourself Gtk2Hs in 21 Hours Message-ID: <1196537165.5970.36.camel@localhost.localdomain> Hello All, The Gtk2Hs basics tutorial, based on the Tony Gale and Ian Main GTK+2.0 tutorial, is now available for review and comment. The TOC: 1. Introduction 2. Getting Started 3. Packing 3.1 Packing Widgets 3.2 Packing Demonstration Program 3.3 Packing Using Tables 4. Miscellaneous Widgets 4.1 The Button Widget 4.2 Adjustments, Scale and Range 4.3 Labels 4.4 Arrows and Tooltips 4.5 Dialogs, Stock Items and Progress Bars 4.6 Text Entries and Status Bars 4.7 Spin Buttons 5. Aggregated Widgets 5.1 Calendar 5.2 File Selection 5.3 Font and Color Selection 5.4 Notebook 6 Supporting Widgets 6.1 Scrolled Windows 6.2 Event Boxes and Button Boxes 6.3 The Layout Container 6.4 Paned Windows and Aspect Frames 7. Action Based Widgets 7.1 Menus and Toolbars 7.2 Popup Menus, Radio Actions and Toggle Actions This covers about half of Gtk2Hs (guesstimate) but (hopefully) most of what's needed for the run of the mill GUI. It's available or will be on http://darcs.haskell.org/gtk2hs/docs/tutorial/Tutorial_Port/ http://j-van-thiel.speedlinq.nl/gtk2hs/index.html Thanks to Alex Tarkovsky it's in XHTML and well structured for easy maintenance and adaptation. I hope a Gtk2Hs basics tutorial will help to popularize this large, powerful and sophisticated gui library for Haskell. Needless to say, please don't hesitate to comment and report errors. Regards, Hans van Thiel From prstanley at ntlworld.com Sat Dec 1 21:43:39 2007 From: prstanley at ntlworld.com (PR Stanley) Date: Sat Dec 1 21:39:24 2007 Subject: [Haskell-cafe] Illegal type def Message-ID: <7.0.1.0.0.20071202023849.01b448e8@ntlworld.com> Hi > type assoc k v = [(k, v)] works beautifully and everything makes sense. > type Assoc v = (Ord k) => [(k, v)] This doesn't work. Is there any wayof defining k as an element of type Ordinal. I could redefine k by putting Char or Int in its place. Why can't I be more general? Thanks, Paul From philip.weaver at gmail.com Sat Dec 1 22:03:39 2007 From: philip.weaver at gmail.com (Philip Weaver) Date: Sat Dec 1 21:59:20 2007 Subject: [Haskell-cafe] Illegal type def In-Reply-To: <7.0.1.0.0.20071202023849.01b448e8@ntlworld.com> References: <7.0.1.0.0.20071202023849.01b448e8@ntlworld.com> Message-ID: Should work with glasgow extensions (-fglasgow-exts). - Phil On Dec 1, 2007 6:43 PM, PR Stanley wrote: > Hi > > type assoc k v = [(k, v)] > > works beautifully and everything makes sense. > > > type Assoc v = (Ord k) => [(k, v)] > > This doesn't work. Is there any wayof defining k as an element of > type Ordinal. I could redefine k by putting Char or Int in its place. > Why can't I be more general? > Thanks, > Paul > > _______________________________________________ > 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/20071201/55aa72eb/attachment.htm From allbery at ece.cmu.edu Sat Dec 1 22:03:42 2007 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat Dec 1 21:59:26 2007 Subject: [Haskell-cafe] Illegal type def In-Reply-To: <7.0.1.0.0.20071202023849.01b448e8@ntlworld.com> References: <7.0.1.0.0.20071202023849.01b448e8@ntlworld.com> Message-ID: <5DEF7DEA-EBC4-4803-99ED-85B8C6DAED0B@ece.cmu.edu> On Dec 1, 2007, at 21:43 , PR Stanley wrote: > Hi > > type assoc k v = [(k, v)] > > works beautifully and everything makes sense. > > > type Assoc v = (Ord k) => [(k, v)] > > This doesn't work. Is there any wayof defining k as an element of > type Ordinal. I could redefine k by putting Char or Int in its > place. Why can't I be more general? Think of a type declaration as a macro which is expanded where it is used. With parentheses around it and any unresolved references "forall"ed, because it has no idea what to do with them at declaration time. So, if you use -fglasgow-exts, you could make the above type declaration. But when you use it: foo :: Assoc Int -> Assoc Int translates as foo :: (forall k. (Ord k) => [(k,Int)]) -> (forall k. (Ord k) => [(k,Int)]) This is almost certainly *not* what you want; the two "k"s are independent. It could be argued that GHC should be smarter about it... but formalizing what that means is difficult (and subject to disagreements). -- 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 cakoose at yahoo.com Sat Dec 1 22:11:46 2007 From: cakoose at yahoo.com (Kannan Goundan) Date: Sat Dec 1 22:10:46 2007 Subject: [Haskell-cafe] Modelling a mutable variable store Message-ID: I'm implementing an interpreter for the lambda calculus augmented with mutable variables. I'm having problems doing the mutable state stuff in Haskell. Here's what I have so far: type Expr = ... terms in the language ... type Value = ... values in the language ... type Ident = String type VarId = String type Env = Map Ident Target data Target = TValue Value | TVar VarId -- idents might refer to values or vars in the store. type Store = Map VarId (Maybe Value) -- Using "Maybe" because vars start out uninitialized. eval :: (Env, Store, Expr) -> (Store, Value) -- The Store is threaded through the evaluator. One problem is that the link between an identifier and it's entry in the store is via VarIds, which are just strings. For example, if I see the identifier "x", I first look it up in the Env, and if it is a "TVar", I then look it up in the store. I'd like to get something stronger (in Java, I would use a pointer). Another problem is that entries in my Store never get garbage collected. Again, if I were using pointers in Java, this wouldn't be an issue. There's also the issue of finding a more elegant way of threading the Store through my evaluator, but I'm not concerned too much about that at this point. I can probably define a state-carrying monad like Parsec. My real concerns are the first two issues. Thanks. - Kannan From derek.a.elkins at gmail.com Sat Dec 1 22:22:53 2007 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sat Dec 1 22:18:42 2007 Subject: [Haskell-cafe] Modelling a mutable variable store In-Reply-To: References: Message-ID: <1196565773.5630.0.camel@derek-laptop> On Sun, 2007-12-02 at 03:11 +0000, Kannan Goundan wrote: > I'm implementing an interpreter for the lambda calculus augmented with > mutable variables. I'm having problems doing the mutable state stuff in > Haskell. Here's what I have so far: > > type Expr = ... terms in the language ... > type Value = ... values in the language ... > type Ident = String > type VarId = String > > type Env = Map Ident Target > data Target = TValue Value | TVar VarId > -- idents might refer to values or vars in the store. > > type Store = Map VarId (Maybe Value) > -- Using "Maybe" because vars start out uninitialized. > > eval :: (Env, Store, Expr) -> (Store, Value) > -- The Store is threaded through the evaluator. > > One problem is that the link between an identifier and it's entry in the > store is via VarIds, which are just strings. For example, if I see the > identifier "x", I first look it up in the Env, and if it is a "TVar", I > then look it up in the store. I'd like to get something stronger (in > Java, I would use a pointer). > > Another problem is that entries in my Store never get garbage collected. > Again, if I were using pointers in Java, this wouldn't be an issue. > > There's also the issue of finding a more elegant way of threading the > Store through my evaluator, but I'm not concerned too much about that at > this point. I can probably define a state-carrying monad like Parsec. > My real concerns are the first two issues. Use ST. First-class state isn't too great unless you specifically want that. From greenrd at greenrd.org Sat Dec 1 22:29:28 2007 From: greenrd at greenrd.org (Robin Green) Date: Sat Dec 1 22:25:09 2007 Subject: [Haskell-cafe] Modelling a mutable variable store In-Reply-To: <1196565773.5630.0.camel@derek-laptop> References: <1196565773.5630.0.camel@derek-laptop> Message-ID: <20071202032928.5ff23045@greenrd.ucd.ie> On Sat, 01 Dec 2007 21:22:53 -0600 Derek Elkins wrote: > > There's also the issue of finding a more elegant way of threading > > the Store through my evaluator, but I'm not concerned too much > > about that at this point. I can probably define a state-carrying > > monad like Parsec. My real concerns are the first two issues. > > Use ST. First-class state isn't too great unless you specifically > want that. Or use IO - that way you can use a Hashtable for looking up identifiers. Although, better still is to convert variable references into Ints, instead of using a Hashtable. -- Robin From derek.a.elkins at gmail.com Sat Dec 1 22:42:57 2007 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sat Dec 1 22:38:47 2007 Subject: [Haskell-cafe] Modelling a mutable variable store In-Reply-To: <20071202032928.5ff23045@greenrd.ucd.ie> References: <1196565773.5630.0.camel@derek-laptop> <20071202032928.5ff23045@greenrd.ucd.ie> Message-ID: <1196566977.5630.3.camel@derek-laptop> On Sun, 2007-12-02 at 03:29 +0000, Robin Green wrote: > On Sat, 01 Dec 2007 21:22:53 -0600 > Derek Elkins wrote: > > > > There's also the issue of finding a more elegant way of threading > > > the Store through my evaluator, but I'm not concerned too much > > > about that at this point. I can probably define a state-carrying > > > monad like Parsec. My real concerns are the first two issues. > > > > Use ST. First-class state isn't too great unless you specifically > > want that. > > Or use IO - that way you can use a Hashtable for looking up > identifiers. Although, better still is to convert variable > references into Ints, instead of using a Hashtable. >From what I hear, Data.HashTable is impressively inefficient to the extent that you're better off using Data.Map solely for performance (not to mention it being pure.) From cakoose at yahoo.com Sat Dec 1 22:54:05 2007 From: cakoose at yahoo.com (Kannan Goundan) Date: Sat Dec 1 22:50:00 2007 Subject: [Haskell-cafe] Re: Modelling a mutable variable store References: <1196565773.5630.0.camel@derek-laptop> Message-ID: On Sat, 01 Dec 2007 21:22:53 -0600, Derek Elkins wrote: > Use ST. First-class state isn't too great unless you specifically want > that. I did try using ST but ran into a problem because its type variable (s) ended up invading all of my types. -- Target needs 's' because of the STRef data Target s = TValue Value | TVar (STRef s (Maybe Value)) -- Env needs 's' because Target needs 's' type Env s = Map Ident (Target s) -- Value needs 's' because closures are values and closures -- have an Env. data Value s = VUnit | VClosure (Env s) Ident Expr The main thing I didn't like was that 'Value' had a type parameter. I didn't follow the ST option much past this point. But maybe there's a better way to use ST? Will existential types help me? - Kannan From stefanor at cox.net Sat Dec 1 23:48:51 2007 From: stefanor at cox.net (Stefan O'Rear) Date: Sat Dec 1 23:44:37 2007 Subject: [Haskell-cafe] Re: Modelling a mutable variable store In-Reply-To: References: <1196565773.5630.0.camel@derek-laptop> Message-ID: <20071202044851.GA4273@localhost.localdomain> On Sun, Dec 02, 2007 at 03:54:05AM +0000, Kannan Goundan wrote: > On Sat, 01 Dec 2007 21:22:53 -0600, Derek Elkins wrote: > > > Use ST. First-class state isn't too great unless you specifically want > > that. > > I did try using ST but ran into a problem because its type variable (s) > ended up invading all of my types. That's just ST ugliness, the price you have to pay for a pure runST. If you're doing almost everything in ST, it can be cleaner just to use IORefs. Stefan -------------- 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/20071201/39834dd7/attachment.bin From tomasz.zielonka at gmail.com Sat Dec 1 23:45:48 2007 From: tomasz.zielonka at gmail.com (Tomasz Zielonka) Date: Sun Dec 2 00:41:32 2007 Subject: [Haskell-cafe] Haskell interface file (.hi) format? In-Reply-To: <404396ef0711300055s4845f60do89da578c178e7800@mail.gmail.com> References: <20071129164514.0e98f425@Eridanus.javasnob.homelinux.net> <034101c832ee$70bb7dc0$fb097ad5@cr3lt> <87ve7kjfey.fsf@nmd9999.imr.no> <404396ef0711300055s4845f60do89da578c178e7800@mail.gmail.com> Message-ID: <20071202044548.GA29564@lambda> On Fri, Nov 30, 2007 at 08:55:51AM +0000, Neil Mitchell wrote: > Hi > > > Prelude> :b Control.Concurrent.MVar > > module 'Control.Concurrent.MVar' is not interpreted > > :b now defaults to :breakpoint, you want :browse That's a questionable decision, IMO: - it changes behavior - I expect :browse to be used more often, so it deserves the sort :b version (:bro is not that short) On the other hand, this change can have an (unintended?) feature advertising effect ;-) Best regards Tomasz From stefanor at cox.net Sun Dec 2 01:01:13 2007 From: stefanor at cox.net (Stefan O'Rear) Date: Sun Dec 2 00:57:02 2007 Subject: [Haskell-cafe] Haskell interface file (.hi) format? In-Reply-To: <20071202044548.GA29564@lambda> References: <20071129164514.0e98f425@Eridanus.javasnob.homelinux.net> <034101c832ee$70bb7dc0$fb097ad5@cr3lt> <87ve7kjfey.fsf@nmd9999.imr.no> <404396ef0711300055s4845f60do89da578c178e7800@mail.gmail.com> <20071202044548.GA29564@lambda> Message-ID: <20071202060113.GA4409@localhost.localdomain> On Sun, Dec 02, 2007 at 05:45:48AM +0100, Tomasz Zielonka wrote: > On Fri, Nov 30, 2007 at 08:55:51AM +0000, Neil Mitchell wrote: > > Hi > > > > > Prelude> :b Control.Concurrent.MVar > > > module 'Control.Concurrent.MVar' is not interpreted > > > > :b now defaults to :breakpoint, you want :browse > > That's a questionable decision, IMO: > - it changes behavior > - I expect :browse to be used more often, so it deserves the sort > :b version (:bro is not that short) > > On the other hand, this change can have an (unintended?) feature > advertising effect ;-) It's not a decision at all. :b is the first command starting with b, which was browse yesterday, is breakpoint today, and tomorrow will be something you've never heard of. It's inherently fragile, and shouldn't be relied on in scripts - and if :b does anything funny, spell out the command! (There is a case to be made for explicitly defining short forms of commands - but that is not what :b is, and making this case should only be done in a new thread.) Stefan -------------- 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/20071201/6cbb344e/attachment.bin From tomasz.zielonka at gmail.com Sun Dec 2 00:16:29 2007 From: tomasz.zielonka at gmail.com (Tomasz Zielonka) Date: Sun Dec 2 01:12:11 2007 Subject: [Haskell-cafe] Haskell interface file (.hi) format? In-Reply-To: <20071202060113.GA4409@localhost.localdomain> References: <20071129164514.0e98f425@Eridanus.javasnob.homelinux.net> <034101c832ee$70bb7dc0$fb097ad5@cr3lt> <87ve7kjfey.fsf@nmd9999.imr.no> <404396ef0711300055s4845f60do89da578c178e7800@mail.gmail.com> <20071202044548.GA29564@lambda> <20071202060113.GA4409@localhost.localdomain> Message-ID: <20071202051629.GA31432@lambda> On Sat, Dec 01, 2007 at 10:01:13PM -0800, Stefan O'Rear wrote: > On Sun, Dec 02, 2007 at 05:45:48AM +0100, Tomasz Zielonka wrote: > > That's a questionable decision, IMO: > > - it changes behavior > > - I expect :browse to be used more often, so it deserves the sort > > :b version (:bro is not that short) > > > > On the other hand, this change can have an (unintended?) feature > > advertising effect ;-) > > It's not a decision at all. :b is the first command starting with b, > which was browse yesterday, is breakpoint today, and tomorrow will be > something you've never heard of. I haven't thought about it this way. OK, so _this_ is the questionable decision: allowing the ambiguous shortcut. > It's inherently fragile, and shouldn't be relied on in scripts I am only relying on it in my brain's procedural memory and I guess it's going to fix itself eventually ;-) Best regards Tomasz From mdmenzel at ucalgary.ca Sun Dec 2 03:19:29 2007 From: mdmenzel at ucalgary.ca (Mike Menzel) Date: Sun Dec 2 03:15:12 2007 Subject: [Haskell-cafe] Happy parsing wierdness Message-ID: <47526A91.8010907@ucalgary.ca> Hi, I'm using the Happy parser, and I've threaded a Success/Failure monad-like thing through it so that if the parse succeeds, Success AST (AST is the datatype I want to turn my tokens into) is returned and if it fails, Fail String is returned (in a similar manner to how such threading is described in the Happy Documentation). That is, data SorF a = Succeed a | Fail String. Now, if the input is valid, I get the correct result (namely Success AST). If invalid input is given (ie the wrong token is encountered), happyError is triggered correctly, and and a Fail String is returned. However, if incomplete info is given (let's say a rule is expecting two tokens, and only one is read before the end of input), the parser generated by happy throws error("Reading EOF"). I have defined happyError on both the empty list of tokens, and the non-empty list as returning a Fail String. I'm stumped as to why I get this error. Any advice? Best, Mike. From ebaste at gmail.com Sun Dec 2 03:43:15 2007 From: ebaste at gmail.com (Eduardo Basterrechea) Date: Sun Dec 2 03:38:56 2007 Subject: [Haskell-cafe] ANN: Teach Yourself Gtk2Hs in 21 Hours In-Reply-To: <1196537165.5970.36.camel@localhost.localdomain> References: <1196537165.5970.36.camel@localhost.localdomain> Message-ID: <1260aa310712020043l14a29c70xd55f7151b92a125c@mail.gmail.com> For me it's a great notice! Thanx for the work. I try to learn with it so if I have some sugestions I'll send you. If you want to translate to spanish, I may do the work. Regards Eduardo 2007/12/1, Hans van Thiel : > > Hello All, > > The Gtk2Hs basics tutorial, based on the Tony Gale and Ian Main GTK+2.0 > tutorial, is now available for review and comment. The TOC: > > 1. Introduction > 2. Getting Started > 3. Packing > 3.1 Packing Widgets > 3.2 Packing Demonstration Program > 3.3 Packing Using Tables > 4. Miscellaneous Widgets > 4.1 The Button Widget > 4.2 Adjustments, Scale and Range > 4.3 Labels > 4.4 Arrows and Tooltips > 4.5 Dialogs, Stock Items and Progress Bars > 4.6 Text Entries and Status Bars > 4.7 Spin Buttons > 5. Aggregated Widgets > 5.1 Calendar > 5.2 File Selection > 5.3 Font and Color Selection > 5.4 Notebook > 6 Supporting Widgets > 6.1 Scrolled Windows > 6.2 Event Boxes and Button Boxes > 6.3 The Layout Container > 6.4 Paned Windows and Aspect Frames > 7. Action Based Widgets > 7.1 Menus and Toolbars > 7.2 Popup Menus, Radio Actions and Toggle Actions > > This covers about half of Gtk2Hs (guesstimate) but (hopefully) most of > what's needed for the run of the mill GUI. It's available or will be on > > http://darcs.haskell.org/gtk2hs/docs/tutorial/Tutorial_Port/ > > http://j-van-thiel.speedlinq.nl/gtk2hs/index.html > > Thanks to Alex Tarkovsky it's in XHTML and well structured for easy > maintenance and adaptation. I hope a Gtk2Hs basics tutorial will help to > popularize this large, powerful and sophisticated gui library for > Haskell. Needless to say, please don't hesitate to comment and report > errors. > > Regards, > > Hans van Thiel > > _______________________________________________ > 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/20071202/7e435590/attachment.htm From felipe.lessa at gmail.com Sun Dec 2 06:40:54 2007 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sun Dec 2 06:36:36 2007 Subject: [Haskell-cafe] ANN: Teach Yourself Gtk2Hs in 21 Hours In-Reply-To: <1196537165.5970.36.camel@localhost.localdomain> References: <1196537165.5970.36.camel@localhost.localdomain> Message-ID: Nice work! As a feedback, I think it would be nice to have colored sintax, at least for the bigger examples. Cheers, -- Felipe. From andrewcoppin at btinternet.com Sun Dec 2 06:55:44 2007 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Dec 2 06:51:13 2007 Subject: [Haskell-cafe] Array copying In-Reply-To: <47517DAF.4070102@btinternet.com> References: <47517DAF.4070102@btinternet.com> Message-ID: <47529D40.60001@btinternet.com> Andrew Coppin wrote: > copy :: Word32 -> IOUArray Word32 Bool -> Word32 -> IO (IOUArray > Word32 Bool) > copy p grid size = do > let size' = size * p > grid' <- newArray (1,size') False > > mapM_ > (\n -> do > b <- readArray grid n > if b > then mapM_ (\x -> writeArray grid' (n + size*x) True) [0..p-1] > else return () > ) > [1..size] > > return grid' Actually, thinking about this... for most kinds of arrays (whether boxed or unboxed, mutable or immutable) there's probably a more efficient way to copy the data then this. Maybe we should add something to the various array APIs to allow efficient copying of arrays / large chunks of arrays? (In the case of an unboxed array of bits, you can probably copy whole 32-bit or 64-bit words with a few machine instructions, for example.) From haskell at list.mightyreason.com Sun Dec 2 07:01:56 2007 From: haskell at list.mightyreason.com (ChrisK) Date: Sun Dec 2 06:57:47 2007 Subject: [Haskell-cafe] Re: Array copying In-Reply-To: <47529D40.60001@btinternet.com> References: <47517DAF.4070102@btinternet.com> <47529D40.60001@btinternet.com> Message-ID: <47529EB4.6070909@list.mightyreason.com> Andrew Coppin wrote: > Andrew Coppin wrote: >> copy :: Word32 -> IOUArray Word32 Bool -> Word32 -> IO (IOUArray >> Word32 Bool) >> copy p grid size = do >> let size' = size * p >> grid' <- newArray (1,size') False >> >> mapM_ >> (\n -> do >> b <- readArray grid n >> if b >> then mapM_ (\x -> writeArray grid' (n + size*x) True) [0..p-1] >> else return () >> ) >> [1..size] >> >> return grid' > > Actually, thinking about this... for most kinds of arrays (whether boxed > or unboxed, mutable or immutable) there's probably a more efficient way > to copy the data then this. Maybe we should add something to the various > array APIs to allow efficient copying of arrays / large chunks of arrays? > > (In the case of an unboxed array of bits, you can probably copy whole > 32-bit or 64-bit words with a few machine instructions, for example.) For GHC 6.6 I created > foreign import ccall unsafe "memcpy" > memcpy :: MutableByteArray# RealWorld -> MutableByteArray# RealWorld -> Int# -> IO () > {-# INLINE copySTU #-} > copySTU :: (Show i,Ix i,MArray (STUArray s) e (ST s)) => STUArray s i e -> STUArray s i e -> ST s () > copySTU (STUArray _ _ msource) (STUArray _ _ mdest) = > -- do b1 <- getBounds s1 > -- b2 <- getBounds s2 > -- when (b1/=b2) (error ("\n\nWTF copySTU: "++show (b1,b2))) > ST $ \s1# -> > case sizeofMutableByteArray# msource of { n# -> > case unsafeCoerce# memcpy mdest msource n# s1# of { (# s2#, () #) -> > (# s2#, () #) }} To allow efficient copying of STUArrays. From andrewcoppin at btinternet.com Sun Dec 2 09:23:58 2007 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Dec 2 09:19:27 2007 Subject: [Haskell-cafe] Re: Array copying In-Reply-To: <47529EB4.6070909@list.mightyreason.com> References: <47517DAF.4070102@btinternet.com> <47529D40.60001@btinternet.com> <47529EB4.6070909@list.mightyreason.com> Message-ID: <4752BFFE.1050108@btinternet.com> ChrisK wrote: > For GHC 6.6 I created > > >> foreign import ccall unsafe "memcpy" >> memcpy :: MutableByteArray# RealWorld -> MutableByteArray# RealWorld -> Int# -> IO () >> > > >> {-# INLINE copySTU #-} >> copySTU :: (Show i,Ix i,MArray (STUArray s) e (ST s)) => STUArray s i e -> STUArray s i e -> ST s () >> copySTU (STUArray _ _ msource) (STUArray _ _ mdest) = >> -- do b1 <- getBounds s1 >> -- b2 <- getBounds s2 >> -- when (b1/=b2) (error ("\n\nWTF copySTU: "++show (b1,b2))) >> ST $ \s1# -> >> case sizeofMutableByteArray# msource of { n# -> >> case unsafeCoerce# memcpy mdest msource n# s1# of { (# s2#, () #) -> >> (# s2#, () #) }} >> > > To allow efficient copying of STUArrays. > So... that copies the entire array into another array of the same size? (I'm having a lot of trouble understanding the code...) From duncan.coutts at worc.ox.ac.uk Sun Dec 2 15:43:52 2007 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Dec 2 15:35:16 2007 Subject: [Haskell-cafe] ANN: Teach Yourself Gtk2Hs in 21 Hours In-Reply-To: References: <1196537165.5970.36.camel@localhost.localdomain> Message-ID: <1196628232.5660.38.camel@localhost> On Sun, 2007-12-02 at 09:40 -0200, Felipe Lessa wrote: > Nice work! As a feedback, I think it would be nice to have colored > sintax, at least for the bigger examples. If you want to do this, we can probably do so by adapting the existing tool we have to colouring Haskell code to work over html files. Duncan From sk at k-hornz.de Sun Dec 2 16:06:35 2007 From: sk at k-hornz.de (Stefan Kersten) Date: Sun Dec 2 16:02:32 2007 Subject: [Haskell-cafe] c2hs and cabal Message-ID: hi, i'm looking for a way to integrate c2hs (single .chs file) in a cabal build setup; can anybody give me some hints? thanks, From rl at cse.unsw.edu.au Sun Dec 2 16:33:42 2007 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Sun Dec 2 16:29:42 2007 Subject: [Haskell-cafe] fast Array operations: foldl, drop In-Reply-To: <20071201035659.GB25004@scytale.galois.com> References: <474F04A2.4090308@serpentine.com> <87abowkwd5.fsf@nmd9999.imr.no> <20071201035659.GB25004@scytale.galois.com> Message-ID: <475324B6.2060004@cse.unsw.edu.au> Don Stewart wrote: > > I forgot to mention this early, but possibly you could use the ndp array > library. There are some people using its UArr type for (non parallel) > strict arrays, that support map/fold/zip et al. > > http://darcs.haskell.org/packages/ndp/ > > This blog post recently, > > http://sequence.complete.org/node/371 > > shows at least one non-developer is using it :) > > Roman, what do you think -- are the unlifted, non-parallel arrays usably `beta'? Yes, they definitely are. UArr uses stream fusion, BTW, so things should fuse sometimes. On a more general note, we plan to put a generally usable UArr-like layer underneath the current standard array types eventually. This would provide all interesting operations as well as fusion. It might take a while (i.e., months) until I get around to doing it, though. Roman From esessoms at mac.com Sun Dec 2 16:34:35 2007 From: esessoms at mac.com (Eric Sessoms) Date: Sun Dec 2 16:30:35 2007 Subject: [Haskell-cafe] c2hs and cabal In-Reply-To: References: Message-ID: <475324EB.5060003@mac.com> Just add Build-Tools: c2hs And cabal will take it from there. Stefan Kersten wrote: > hi, > > i'm looking for a way to integrate c2hs (single .chs file) in a cabal > build setup; can anybody give me some hints? > > thanks, > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From dons at galois.com Sun Dec 2 16:37:04 2007 From: dons at galois.com (Don Stewart) Date: Sun Dec 2 16:32:58 2007 Subject: [Haskell-cafe] fast Array operations: foldl, drop In-Reply-To: <475324B6.2060004@cse.unsw.edu.au> References: <474F04A2.4090308@serpentine.com> <87abowkwd5.fsf@nmd9999.imr.no> <20071201035659.GB25004@scytale.galois.com> <475324B6.2060004@cse.unsw.edu.au> Message-ID: <20071202213704.GA13435@scytale.galois.com> rl: > Don Stewart wrote: > > > >I forgot to mention this early, but possibly you could use the ndp array > >library. There are some people using its UArr type for (non parallel) > >strict arrays, that support map/fold/zip et al. > > > > http://darcs.haskell.org/packages/ndp/ > > > >This blog post recently, > > > > http://sequence.complete.org/node/371 > > > >shows at least one non-developer is using it :) > > > >Roman, what do you think -- are the unlifted, non-parallel arrays usably > >`beta'? > > Yes, they definitely are. UArr uses stream fusion, BTW, so things should > fuse sometimes. > > On a more general note, we plan to put a generally usable UArr-like > layer underneath the current standard array types eventually. This would > provide all interesting operations as well as fusion. It might take a > while (i.e., months) until I get around to doing it, though. Would it be possible to separate out the UArr modules from the larger ndp project (which needs ghc head and type families). I.e. just one smaller package for fast, fusable arrays we can work on? -- Don From rl at cse.unsw.edu.au Sun Dec 2 16:46:34 2007 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Sun Dec 2 16:42:40 2007 Subject: [Haskell-cafe] fast Array operations: foldl, drop In-Reply-To: <20071202213704.GA13435@scytale.galois.com> References: <474F04A2.4090308@serpentine.com> <87abowkwd5.fsf@nmd9999.imr.no> <20071201035659.GB25004@scytale.galois.com> <475324B6.2060004@cse.unsw.edu.au> <20071202213704.GA13435@scytale.galois.com> Message-ID: <475327BA.1000109@cse.unsw.edu.au> Don Stewart wrote: > rl: >> Don Stewart wrote: >>> I forgot to mention this early, but possibly you could use the ndp array >>> library. There are some people using its UArr type for (non parallel) >>> strict arrays, that support map/fold/zip et al. >>> >>> http://darcs.haskell.org/packages/ndp/ >>> >>> This blog post recently, >>> >>> http://sequence.complete.org/node/371 >>> >>> shows at least one non-developer is using it :) >>> >>> Roman, what do you think -- are the unlifted, non-parallel arrays usably >>> `beta'? >> Yes, they definitely are. UArr uses stream fusion, BTW, so things should >> fuse sometimes. >> >> On a more general note, we plan to put a generally usable UArr-like >> layer underneath the current standard array types eventually. This would >> provide all interesting operations as well as fusion. It might take a >> while (i.e., months) until I get around to doing it, though. > > Would it be possible to separate out the UArr modules from the larger > ndp project (which needs ghc head and type families). I.e. just one > smaller package for fast, fusable arrays we can work on? UArr is a type family, too! That said, it would definitely be possible to put it into a separate package. The interface needs some work, though, since it is very "backendish" at the moment. The problem is that I don't really have time for this at the moment. If anyone volunteers to do this I'll help, of course. Roman From briqueabraque at yahoo.com Sun Dec 2 21:21:09 2007 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Sun Dec 2 21:17:14 2007 Subject: [Haskell-cafe] Peg solitaire in Haskell - anyone interested? Message-ID: Hi, I've just finished a command line application that solves peg solitaire. It does that by building a database of (possible ^ solvable) boards, and you can walk through them from the beggining of the game to the end. It always shows all movements you can do where you are guaranteed to finish with just one peg. Today, it's messy. So I would like to know if people are interested on that. If at least five people say they would REALLY like to play with that program, I will make it into a nice gtk2hs application and release it on the net. If not, I'll keep it like it is and use for my pleasure only. Thanks, Maur?cio From dons at galois.com Sun Dec 2 21:41:23 2007 From: dons at galois.com (Don Stewart) Date: Sun Dec 2 21:37:08 2007 Subject: [Haskell-cafe] Re: Haskell-Cafe Digest, Vol 51, Issue 180 In-Reply-To: <41246B74-71C6-444C-8877-5DD51CAD39F4@citycampus.com> References: <20071128191439.11A73324371@www.haskell.org> <41246B74-71C6-444C-8877-5DD51CAD39F4@citycampus.com> Message-ID: <20071203024123.GG13662@scytale.galois.com> emmanuel.delaborde: > >> > >>I'm trying to build diverse packages from Hackage with ghc 6.8.1, > >>they usually fail to build because of missing language extensions. > >> > >>Sometimes I am unable to determine the proper name of the extension > >>missing in .cabal > >>I tend to slap {- #OPTIONS -fglasgow-exts #-} at the top of the > >>troublesome file. > >>It works, but out of curiosity, what is the downside of such an > >>approach ? (bigger executables ?) > > > >Can you list which packages failed to build out of the box? > > > > -- Don > > > > > Well I'd say none of the packages I've tried, build out of the box, > that include : > > haskelldb > haskelldb-hdbc > haskelldb-hdbc-sqlite3 > HDBC > HDBC-sqlite3 > > Agreed some of these compile right after tweeking the build-depends: > and extensions: lines in the .cabal file > (apart from the pesky PatternSignatures which require a LANGUAGE > pragma in the source file) > > haskelldb-hdbc-sqlite3 is the one that I couldn't get past... > > I didn't bother with hsql-mysql-1.7 since Duncan Coutts mentioned it > required significant work (and I cannot do much) Please contact the maintainers of these larger database bindings to get them updated for the new release. (Its possible the authors haven't yet attempted the update, that its hard, or they just forgot). -- Don From vigalchin at gmail.com Sun Dec 2 23:49:13 2007 From: vigalchin at gmail.com (Galchin Vasili) Date: Sun Dec 2 23:44:51 2007 Subject: [Haskell-cafe] who develops and maintains the Unix package? Message-ID: <5ae4f2ba0712022049lf850757y9eb06be57a6adfbc@mail.gmail.com> Hello, I am starting to get in the groove related to runhaskell -- config/builds on top of cygwin (I haven't had time to carve up hard drive and install Linux). In any case, I really want to get the Unix package to build on cgywin (as advertised at http://hackage.haskell.org/cgi-bin/hackage-scripts/package/unix-2.2.0.0). When i do "runhaskell Setup.lhs configure" things seem to go fine, .log fine is clean, and pertinent cygwin include files like times.h are found, but when i do a "runhaskell Setup.lhs build" then the include files that are allegedly found during the configure "probe" cannot be found. ???? 1) During the "runhaskell Setup.lhs build" step, what human readable file is used and contains paths to the cygwin Posix include file directories? 2) thatis foloowing is a better approach for me .. => 2) Somebody obviously put " (except under Cygwin)". Can you point at who made this claim and why? Kind regards, Vasya -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071202/9d3748fe/attachment.htm From catamorphism at gmail.com Sun Dec 2 23:53:14 2007 From: catamorphism at gmail.com (Tim Chevalier) Date: Sun Dec 2 23:48:52 2007 Subject: [Haskell-cafe] who develops and maintains the Unix package? In-Reply-To: <5ae4f2ba0712022049lf850757y9eb06be57a6adfbc@mail.gmail.com> References: <5ae4f2ba0712022049lf850757y9eb06be57a6adfbc@mail.gmail.com> Message-ID: <4683d9370712022053mad7e6bem8abeee45b1db5b38@mail.gmail.com> On 12/2/07, Galchin Vasili wrote: > Hello, > > I am starting to get in the groove related to runhaskell -- > config/builds on top of cygwin (I haven't had time to carve up hard drive > and install Linux). > > In any case, I really want to get the Unix package to build on > cgywin (as advertised at > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/unix-2.2.0.0). > When i do "runhaskell Setup.lhs configure" > things seem to go fine, .log fine is clean, and pertinent cygwin include > files like times.h are found, but when i do a "runhaskell Setup.lhs build" > then the include files that are allegedly found during the configure > "probe" cannot be found. ???? > > > 1) During the "runhaskell Setup.lhs build" step, what human readable > file > is used and contains paths to the cygwin Posix include file > directories? 2) thatis foloowing is a better approach for me .. => > > 2) Somebody obviously put " (except under Cygwin)". Can you point at > who made this claim and why? > When in doubt, email libraries@haskell.org with library questions (indeed, the Hackage page for the unix package lists libraries@ as the maintainer.) It doesn't surprise me that the unix package wouldn't work on Cygwin. Cheers, Tim -- Tim Chevalier * catamorphism.org * Often in error, never in doubt "Are you aware that rushing toward a goal is a sublimated death wish? It's no coincidence we call them 'deadlines'." -- Tom Robbins From vigalchin at gmail.com Mon Dec 3 00:19:23 2007 From: vigalchin at gmail.com (Galchin Vasili) Date: Mon Dec 3 00:15:00 2007 Subject: [Haskell-cafe] Re: who develops and maintains the Unix package? In-Reply-To: <5ae4f2ba0712022049lf850757y9eb06be57a6adfbc@mail.gmail.com> References: <5ae4f2ba0712022049lf850757y9eb06be57a6adfbc@mail.gmail.com> Message-ID: <5ae4f2ba0712022119p1e5d1730l93632396d1501a5f@mail.gmail.com> On Dec 2, 2007 10:49 PM, Galchin Vasili wrote: > Hello, > > I am starting to get in the groove related to runhaskell -- > config/builds on top of cygwin (I haven't had time to carve up hard drive > and install Linux). > > In any case, I really want to get the Unix package to build on > cgywin (as advertised at > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/unix-2.2.0.0). > When i do "runhaskell Setup.lhs configure" > things seem to go fine, .log fine is clean, and pertinent cygwin include > files like times.h are found, but when i do a "runhaskell Setup.lhs build" > then the include files that are allegedly found during the configure > "probe" cannot be found. ???? > > 1) During the "runhaskell Setup.lhs build" step, what human readable > file > is used and contains paths to the cygwin Posix include file > directories? 2) thatis foloowing is a better approach for me .. => > > 2) Somebody obviously put " (except under Cygwin)". Can you point at > who made this claim and why? > > > Kind regards, Vasya > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071202/8f7cba19/attachment.htm From prstanley at ntlworld.com Mon Dec 3 00:20:35 2007 From: prstanley at ntlworld.com (PR Stanley) Date: Mon Dec 3 00:16:14 2007 Subject: [Haskell-cafe] Possible Improvements Message-ID: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> Hi data Tree = Leaf Int | Node Tree Int Tree occurs :: Int -> Tree -> Bool occurs m (Leaf n) = m == n occurs m (Node l n r) = m == n || occurs m l || occurs m r It works but I'd like to know if it can be improved in any way. Thanks, Paul From dons at galois.com Mon Dec 3 00:23:30 2007 From: dons at galois.com (Don Stewart) Date: Mon Dec 3 00:19:08 2007 Subject: [Haskell-cafe] Possible Improvements In-Reply-To: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> References: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> Message-ID: <20071203052330.GM13662@scytale.galois.com> prstanley: > Hi > data Tree = Leaf Int | Node Tree Int Tree > > occurs :: Int -> Tree -> Bool > occurs m (Leaf n) = m == n > occurs m (Node l n r) = m == n || occurs m l || occurs m r > > It works but I'd like to know if it can be improved in any way. You could probably get away with: data Tree = Leaf !Int | Node Tree !Int Tree but that's a minor issue. I don't see anything wrong this this code -- isn't that what you'd hope to write? -- Don From stefanor at cox.net Mon Dec 3 00:26:02 2007 From: stefanor at cox.net (Stefan O'Rear) Date: Mon Dec 3 00:21:42 2007 Subject: [Haskell-cafe] Possible Improvements In-Reply-To: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> References: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> Message-ID: <20071203052602.GA4076@localhost.localdomain> On Mon, Dec 03, 2007 at 05:20:35AM +0000, PR Stanley wrote: > Hi > data Tree = Leaf Int | Node Tree Int Tree > > occurs :: Int -> Tree -> Bool > occurs m (Leaf n) = m == n > occurs m (Node l n r) = m == n || occurs m l || occurs m r > > It works but I'd like to know if it can be improved in any way. > Thanks, Paul Note that occurs checks elements in pre-order; so it can be factored into preorder and elem, where elem is defined in the Prelude: preorder (Leaf n) = [n] preorder (Node l n r) = n : preorder l ++ preorder r occurs x = elem x . preorder --- Also, Tree can be made to work on any type of value as a type constructor: data Tree k = Leaf k | Node (Tree k) k (Tree k) -- definitions of preorder and occurs are the same as before Stefan -------------- 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/20071202/038b2a35/attachment.bin From catamorphism at gmail.com Mon Dec 3 00:35:29 2007 From: catamorphism at gmail.com (Tim Chevalier) Date: Mon Dec 3 00:31:07 2007 Subject: [Haskell-cafe] Possible Improvements In-Reply-To: <20071203052330.GM13662@scytale.galois.com> References: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> <20071203052330.GM13662@scytale.galois.com> Message-ID: <4683d9370712022135o5bf75cd1x3cbbf6567382813e@mail.gmail.com> On 12/2/07, Don Stewart wrote: > prstanley: > > Hi > > data Tree = Leaf Int | Node Tree Int Tree > > > > occurs :: Int -> Tree -> Bool > > occurs m (Leaf n) = m == n > > occurs m (Node l n r) = m == n || occurs m l || occurs m r > > > > It works but I'd like to know if it can be improved in any way. > > You could probably get away with: > > data Tree = Leaf !Int | Node Tree !Int Tree > > but that's a minor issue. > IMO, there's no reason to even think about putting in the strictness annotations unless you've identified this datatype as part of a performance bottleneck in production code. Otherwise, there's no need to clutter your code and your mind with them :-) Cheers, Tim -- Tim Chevalier * catamorphism.org * Often in error, never in doubt "Base eight is just like base ten, really... if you're missing two fingers." -- Tom Lehrer From dons at galois.com Mon Dec 3 00:54:05 2007 From: dons at galois.com (Don Stewart) Date: Mon Dec 3 00:49:47 2007 Subject: [Haskell-cafe] Possible Improvements In-Reply-To: <4683d9370712022135o5bf75cd1x3cbbf6567382813e@mail.gmail.com> References: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> <20071203052330.GM13662@scytale.galois.com> <4683d9370712022135o5bf75cd1x3cbbf6567382813e@mail.gmail.com> Message-ID: <20071203055405.GN13662@scytale.galois.com> catamorphism: > On 12/2/07, Don Stewart wrote: > > prstanley: > > > Hi > > > data Tree = Leaf Int | Node Tree Int Tree > > > > > > occurs :: Int -> Tree -> Bool > > > occurs m (Leaf n) = m == n > > > occurs m (Node l n r) = m == n || occurs m l || occurs m r > > > > > > It works but I'd like to know if it can be improved in any way. > > > > You could probably get away with: > > > > data Tree = Leaf !Int | Node Tree !Int Tree > > > > but that's a minor issue. > > > > IMO, there's no reason to even think about putting in the strictness > annotations unless you've identified this datatype as part of a > performance bottleneck in production code. Otherwise, there's no need > to clutter your code and your mind with them :-) Very true ("a minor issue"). However, *rarely* do you want lazines in the atomic types (Int,Char,Word,Integer, et al) A little test: main = do n <- getArgs >>= readIO . head let t = make (n*2) n print (check t) make :: Int -> Int -> Tree make i 0 = Node (Leaf 0) i (Leaf 0) make i d = Node (make (i2-1) d2) i (make i2 d2) where i2 = 2*i d2 = d-1 check :: Tree -> Int check (Leaf _) = 0 check (Node l i r) = i + check l - check r Fully lazy: data Tree = Leaf Int | Node Tree Int Tree $ time ./A 25 49 ./A 25 18.20s user 0.04s system 99% cpu 18.257 total ^^^^^^ 3556K heap use. Strict in the elements, lazy in the spine: data Tree = Leaf !Int | Node Tree !Int Tree $ time ./A 25 49 ./A 25 14.41s user 0.03s system 99% cpu 14.442 total ^^^^^^ 3056K heap use. You'll be hard pressed to do better in C here. Finally, strict in the spine and elements: data Tree = Leaf !Int | Node !Tree !Int !Tree $ time ./A 25 A: out of memory (requested 1048576 bytes) ./A 25 11.46s user 2.60s system 97% cpu 14.379 total 657M heap use ^^^^ Lesson: * Full strictness == teh suckness. * Mixed lazy and strict == flexible and efficient data types. Makes me wonder why Map is strict in the spine, data Map k a = Tip | Bin {-# UNPACK #-} !Size !k a !(Map k a) !(Map k a) Anyone know? Cheers, Don From nanothief at gmail.com Mon Dec 3 01:05:49 2007 From: nanothief at gmail.com (nanothief) Date: Mon Dec 3 01:01:26 2007 Subject: [Haskell-cafe] doing builds using cygwin on Windows ....help In-Reply-To: <5ae4f2ba0711291157u5ab9d189v8494c2cf4e789f30@mail.gmail.com> References: <5ae4f2ba0711291157u5ab9d189v8494c2cf4e789f30@mail.gmail.com> Message-ID: <14124405.post@talk.nabble.com> VasiliIGalchin wrote: > > > " .. however, I don't see in which file PATH can be set. Any help? I > really > want to get my Haskell build environment set up and cranking away. > Unless I misunderstood what you want, you can add a path to the PATH variable by adding the line: export PATH="$PATH:/path/to/folder" to the ~/.bashrc file (and also possibly the ~/.bash_profile file). I've also tried to build haskell with cygwin, but didn't have any luck. Could you describe how you managed to do it? -- View this message in context: http://www.nabble.com/doing-builds-using-cygwin-on-Windows-....help-tf4899597.html#a14124405 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From dons at galois.com Mon Dec 3 01:10:27 2007 From: dons at galois.com (Don Stewart) Date: Mon Dec 3 01:06:13 2007 Subject: [Haskell-cafe] Possible Improvements In-Reply-To: <20071203055405.GN13662@scytale.galois.com> References: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> <20071203052330.GM13662@scytale.galois.com> <4683d9370712022135o5bf75cd1x3cbbf6567382813e@mail.gmail.com> <20071203055405.GN13662@scytale.galois.com> Message-ID: <20071203061027.GA14502@scytale.galois.com> > Fully lazy: > > data Tree = Leaf Int | Node Tree Int Tree > > $ time ./A 25 > 49 > ./A 25 18.20s user 0.04s system 99% cpu 18.257 total > ^^^^^^ > 3556K heap use. > > Strict in the elements, lazy in the spine: > > data Tree = Leaf !Int | Node Tree !Int Tree > > $ time ./A 25 > 49 > ./A 25 14.41s user 0.03s system 99% cpu 14.442 total > ^^^^^^ > 3056K heap use. And, oh, element strict, with -funbox-strict-fields, $ time ./A 25 49 ./A 25 12.25s user 0.01s system 99% cpu 12.346 total -- Don From tomasz.zielonka at gmail.com Mon Dec 3 00:28:31 2007 From: tomasz.zielonka at gmail.com (Tomasz Zielonka) Date: Mon Dec 3 01:24:06 2007 Subject: [Haskell-cafe] Possible Improvements In-Reply-To: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> References: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> Message-ID: <20071203052831.GA10105@lambda> On Mon, Dec 03, 2007 at 05:20:35AM +0000, PR Stanley wrote: > Hi > data Tree = Leaf Int | Node Tree Int Tree > > occurs :: Int -> Tree -> Bool > occurs m (Leaf n) = m == n > occurs m (Node l n r) = m == n || occurs m l || occurs m r > > It works but I'd like to know if it can be improved in any way. > Thanks, Paul I'm not sure this will count as improvement, but you can build the same kinds of trees with a simpler datatype: data Tree = Empty | Node Tree Int Tree This way there is only one constructor with the Int value, which can simplify other code a bit. Best regards Tomasz From dons at galois.com Mon Dec 3 01:31:37 2007 From: dons at galois.com (Don Stewart) Date: Mon Dec 3 01:27:21 2007 Subject: [Haskell-cafe] Possible Improvements In-Reply-To: <20071203055405.GN13662@scytale.galois.com> References: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> <20071203052330.GM13662@scytale.galois.com> <4683d9370712022135o5bf75cd1x3cbbf6567382813e@mail.gmail.com> <20071203055405.GN13662@scytale.galois.com> Message-ID: <20071203063137.GA14530@scytale.galois.com> dons: > > * Full strictness == teh suckness. > * Mixed lazy and strict == flexible and efficient data types. > > Makes me wonder why Map is strict in the spine, > > data Map k a = Tip > | Bin {-# UNPACK #-} !Size !k a !(Map k a) !(Map k a) > Spencer points out that being sized-balanced, subtree sizes must be computed on insertion, so may as well make the structure spine strict anyway. -- Don From derek.a.elkins at gmail.com Mon Dec 3 01:45:51 2007 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Mon Dec 3 01:41:39 2007 Subject: [Haskell-cafe] Possible Improvements In-Reply-To: <20071203055405.GN13662@scytale.galois.com> References: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> <20071203052330.GM13662@scytale.galois.com> <4683d9370712022135o5bf75cd1x3cbbf6567382813e@mail.gmail.com> <20071203055405.GN13662@scytale.galois.com> Message-ID: <1196664351.5471.13.camel@derek-laptop> On Sun, 2007-12-02 at 21:54 -0800, Don Stewart wrote: > catamorphism: > > On 12/2/07, Don Stewart wrote: > > > prstanley: > > > > Hi > > > > data Tree = Leaf Int | Node Tree Int Tree > > > > > > > > occurs :: Int -> Tree -> Bool > > > > occurs m (Leaf n) = m == n > > > > occurs m (Node l n r) = m == n || occurs m l || occurs m r > > > > > > > > It works but I'd like to know if it can be improved in any way. > > > > > > You could probably get away with: > > > > > > data Tree = Leaf !Int | Node Tree !Int Tree > > > > > > but that's a minor issue. > > > > > > > IMO, there's no reason to even think about putting in the strictness > > annotations unless you've identified this datatype as part of a > > performance bottleneck in production code. Otherwise, there's no need > > to clutter your code and your mind with them :-) > > Very true ("a minor issue"). I agree that (in this context, beginning learning Haskell) it is a somewhat minor issue. But I disagree that this is something you should ignore until it becomes a problem and I do think that it should be part of learning Haskell. Properly using strictness is an important part of using Haskell. It makes the difference between code that stack overflows and code that doesn't, code that takes 100 seconds and code that takes 10, code that uses 3MB of RAM and code that uses 600. At least the first of these is not, in my mind, the difference between "optimized" and "unoptimized", but rather the difference between correct and incorrect. Writing better code at the beginning is much easier than trying to figure out what the problem is later. Furthermore, writing better code is not more difficult. In this case it merely means adding two characters. Of late, the "rules of thumb" for this sort of thing are becoming more widely known. Such things need to be "instinctively" part of how you write code, much like writing code tail-recursively or not using (++) left associatively. It's not that you should immediately know that this is better, but (more strongly) that you should not even think of the worse ways to begin with in many cases. From aneumann at inf.fu-berlin.de Mon Dec 3 02:13:57 2007 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Mon Dec 3 02:09:45 2007 Subject: [Haskell-cafe] Trees Message-ID: <467915C1-11AF-4B0F-A008-DACE1E84CC6E@inf.fu-berlin.de> Good morning, as an exercise for my Algorithms and Programming course I have to program a couple of simple functions over trees. Until now everything we did in Java could be done in Haskell (usually much nicer too) using the naive > data Tree a = Leaf a | Node a [Tree a] But now the assignments require more than a simple top-down traversal. For example: given a tree t and two nodes u,v, find the first common ancestor. In Java this is really simple, because each node has a "parent" reference. That way I only need to follow those references until I find the first common ancestor. This should take something like O(log n) in the average case. In Haskell however the best way I've come up with so far is doing a BFS and looking for the last common node in the paths to u and v. This is neither fast, nor particularly elegant. So how would you smart guys do it? With a Zipper? It would be nice if there was an elegant solution without monads. --Adrian -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 186 bytes Desc: Signierter Teil der Nachricht Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20071203/8c38bada/PGP.bin From dons at galois.com Mon Dec 3 02:23:38 2007 From: dons at galois.com (Don Stewart) Date: Mon Dec 3 02:19:22 2007 Subject: [Haskell-cafe] Trees In-Reply-To: <467915C1-11AF-4B0F-A008-DACE1E84CC6E@inf.fu-berlin.de> References: <467915C1-11AF-4B0F-A008-DACE1E84CC6E@inf.fu-berlin.de> Message-ID: <20071203072338.GA14542@scytale.galois.com> aneumann: > Good morning, > > as an exercise for my Algorithms and Programming course I have to > program a couple of simple functions over trees. Until now everything > we did in Java could be done in Haskell (usually much nicer too) > using the naive > > > data Tree a = Leaf a | Node a [Tree a] > > But now the assignments require more than a simple top-down > traversal. For example: given a tree t and two nodes u,v, find the > first common ancestor. > In Java this is really simple, because each node has a "parent" > reference. That way I only need to follow those references until I > find the first common ancestor. This should take something like O(log > n) in the average case. > > In Haskell however the best way I've come up with so far is doing a > BFS and looking for the last common node in the paths to u and v. > This is neither fast, nor particularly elegant. > So how would you smart guys do it? With a Zipper? It would be nice if > there was an elegant solution without monads. > For a cursor, with O(1) access to parents, a zipper of a Tree is really quite nice, and fast. I'd start there. (Huet's original zipper paper is straightforward to translate from ML, and we have zippers on the wikibook now). -- Don From vigalchin at gmail.com Mon Dec 3 02:30:13 2007 From: vigalchin at gmail.com (Galchin Vasili) Date: Mon Dec 3 02:25:53 2007 Subject: [Haskell-cafe] more info on building the Unix package on cygwin Message-ID: <5ae4f2ba0712022330q5785720cy2b3bbccc282b38ba@mail.gmail.com> Hello, I put an ugly kludge(on my laptop) in the unix.cabal file For the includes-dir "attribute" I explicited specified the path to the cygwin include directory. The Unix package build gets farther and then gets errors. At this point, it appears that the cygwin sys/types.h has a "bug" .. id_t is not defined but id_t is referenced by sys/resources.h/(getpriority/setpriority). Please see see http://www.opengroup.org/onlinepubs/000095399/functions/setpriority.html for getpriority function signature. In any case, I want compare the Linux sys/types.h include. To summarize: 1) I am just learning about the .cabal file format from the Cabal .pdf. In any case, it appears that for the case of cygwin that unix.cabal is deficient. 2) It also appears that the cygwin sys/types.h failed to defined id_t which is needed by sys/resources.h which in turn is needed by System/Posix/DynamicLinker/Module.hsc (error at line 57 where HsUnix.h is refd .. and in HsUnix.h at line # 38 sys/resource.h is referenced.) I can provide a stderr "log". Kind regards, Vasya -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071203/dcf3fb42/attachment.htm From stefanor at cox.net Mon Dec 3 02:31:28 2007 From: stefanor at cox.net (Stefan O'Rear) Date: Mon Dec 3 02:27:08 2007 Subject: [Haskell-cafe] Trees In-Reply-To: <467915C1-11AF-4B0F-A008-DACE1E84CC6E@inf.fu-berlin.de> References: <467915C1-11AF-4B0F-A008-DACE1E84CC6E@inf.fu-berlin.de> Message-ID: <20071203073128.GA4695@localhost.localdomain> On Mon, Dec 03, 2007 at 08:13:57AM +0100, Adrian Neumann wrote: > Good morning, > > as an exercise for my Algorithms and Programming course I have to program a > couple of simple functions over trees. Until now everything we did in Java > could be done in Haskell (usually much nicer too) using the naive > > > data Tree a = Leaf a | Node a [Tree a] > > But now the assignments require more than a simple top-down traversal. For > example: given a tree t and two nodes u,v, find the first common ancestor. > In Java this is really simple, because each node has a "parent" reference. > That way I only need to follow those references until I find the first > common ancestor. This should take something like O(log n) in the average > case. > > In Haskell however the best way I've come up with so far is doing a BFS and > looking for the last common node in the paths to u and v. This is neither > fast, nor particularly elegant. > So how would you smart guys do it? With a Zipper? It would be nice if there > was an elegant solution without monads. It should be noted that this is a question of style, not language, and the Java solution translates to Haskell: data Tree a = Node { idn:: Int, val:: a, parent:: Maybe (Tree a), children:: [Tree a] } You can make this efficiently mutable, but only at the cost of making it ephemeral, a natural property of Java's data structures but frowned on in our culture. Stefan -------------- 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/20071202/3ab6d20d/attachment.bin From johan.tibell at gmail.com Mon Dec 3 03:43:16 2007 From: johan.tibell at gmail.com (Johan Tibell) Date: Mon Dec 3 03:38:53 2007 Subject: [Haskell-cafe] Possible Improvements In-Reply-To: <1196664351.5471.13.camel@derek-laptop> References: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> <20071203052330.GM13662@scytale.galois.com> <4683d9370712022135o5bf75cd1x3cbbf6567382813e@mail.gmail.com> <20071203055405.GN13662@scytale.galois.com> <1196664351.5471.13.camel@derek-laptop> Message-ID: <90889fe70712030043g3c104b9bpfd3f221734441afa@mail.gmail.com> > I agree that (in this context, beginning learning Haskell) it is a > somewhat minor issue. But I disagree that this is something you should > ignore until it becomes a problem and I do think that it should be part > of learning Haskell. Properly using strictness is an important part of > using Haskell. It makes the difference between code that stack > overflows and code that doesn't, code that takes 100 seconds and code > that takes 10, code that uses 3MB of RAM and code that uses 600. At > least the first of these is not, in my mind, the difference between > "optimized" and "unoptimized", but rather the difference between correct > and incorrect. Writing better code at the beginning is much easier than > trying to figure out what the problem is later. Furthermore, writing > better code is not more difficult. In this case it merely means adding > two characters. Of late, the "rules of thumb" for this sort of thing > are becoming more widely known. Such things need to be "instinctively" > part of how you write code, much like writing code tail-recursively or > not using (++) left associatively. It's not that you should immediately > know that this is better, but (more strongly) that you should not even > think of the worse ways to begin with in many cases. It would be great if someone could exemplify these "rules of thumb", e.g. "Primitive types such as Int should be strict unless in the three canonical examples X, Y and Z." My strictness radar is still quite poor and I feel I can't make informed decisions on when I need to make something more strict or lazy. -- Johan From apfelmus at quantentunnel.de Mon Dec 3 03:40:17 2007 From: apfelmus at quantentunnel.de (apfelmus) Date: Mon Dec 3 03:42:00 2007 Subject: [Haskell-cafe] Re: Trees In-Reply-To: <467915C1-11AF-4B0F-A008-DACE1E84CC6E@inf.fu-berlin.de> References: <467915C1-11AF-4B0F-A008-DACE1E84CC6E@inf.fu-berlin.de> Message-ID: Adrian Neumann wrote: > > > data Tree a = Leaf a | Node a [Tree a] > > But now the assignments require more than a simple top-down traversal. > For example: given a tree t and two nodes u,v, find the first common > ancestor. Well, this problem doesn't make much sense in Haskell. How do you specify the subtrees u and v in the first place? Regards, apfelmus From apfelmus at quantentunnel.de Mon Dec 3 03:46:26 2007 From: apfelmus at quantentunnel.de (apfelmus) Date: Mon Dec 3 03:46:11 2007 Subject: [Haskell-cafe] Re: Possible Improvements In-Reply-To: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> References: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> Message-ID: PR Stanley wrote: > > data Tree = Leaf Int | Node Tree Int Tree > > occurs :: Int -> Tree -> Bool > occurs m (Leaf n) = m == n > occurs m (Node l n r) = m == n || occurs m l || occurs m r > > It works but I'd like to know if it can be improved in any way. That's entirely fine. The logical or || doesn't evaluate it's second argument occurs m r if the first argument occurs m l turns out to be already True. In other words, thanks to lazy evaluation, the search stops if m has been found in the left subtree, it won't search the right subtree anymore. Regards, apfelmus From prstanley at ntlworld.com Mon Dec 3 03:52:04 2007 From: prstanley at ntlworld.com (PR Stanley) Date: Mon Dec 3 03:47:42 2007 Subject: [Haskell-cafe] Possible Improvements In-Reply-To: <90889fe70712030043g3c104b9bpfd3f221734441afa@mail.gmail.co m> References: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> <20071203052330.GM13662@scytale.galois.com> <4683d9370712022135o5bf75cd1x3cbbf6567382813e@mail.gmail.com> <20071203055405.GN13662@scytale.galois.com> <1196664351.5471.13.camel@derek-laptop> <90889fe70712030043g3c104b9bpfd3f221734441afa@mail.gmail.com> Message-ID: <7.0.1.0.0.20071203084843.01b4da60@ntlworld.com> That's a very good point. Yes, let's have some detailed explanations accompanied by some good examples. Cheers, Paul At 08:43 03/12/2007, you wrote: > > I agree that (in this context, beginning learning Haskell) it is a > > somewhat minor issue. But I disagree that this is something you should > > ignore until it becomes a problem and I do think that it should be part > > of learning Haskell. Properly using strictness is an important part of > > using Haskell. It makes the difference between code that stack > > overflows and code that doesn't, code that takes 100 seconds and code > > that takes 10, code that uses 3MB of RAM and code that uses 600. At > > least the first of these is not, in my mind, the difference between > > "optimized" and "unoptimized", but rather the difference between correct > > and incorrect. Writing better code at the beginning is much easier than > > trying to figure out what the problem is later. Furthermore, writing > > better code is not more difficult. In this case it merely means adding > > two characters. Of late, the "rules of thumb" for this sort of thing > > are becoming more widely known. Such things need to be "instinctively" > > part of how you write code, much like writing code tail-recursively or > > not using (++) left associatively. It's not that you should immediately > > know that this is better, but (more strongly) that you should not even > > think of the worse ways to begin with in many cases. > >It would be great if someone could exemplify these "rules of thumb", >e.g. "Primitive types such as Int should be strict unless in the three >canonical examples X, Y and Z." My strictness radar is still quite >poor and I feel I can't make informed decisions on when I need to make >something more strict or lazy. > >-- Johan >_______________________________________________ >Haskell-Cafe mailing list >Haskell-Cafe@haskell.org >http://www.haskell.org/mailman/listinfo/haskell-cafe From apfelmus at quantentunnel.de Mon Dec 3 03:48:35 2007 From: apfelmus at quantentunnel.de (apfelmus) Date: Mon Dec 3 03:56:05 2007 Subject: [Haskell-cafe] Re: New slogan for haskell.org In-Reply-To: <20071129233133.GB3757@localhost.localdomain> References: <5A07D519-2CAC-4BCF-BB6B-7B0B567C6578@gmail.com> <003B73C1-C3CB-4466-A4EF-C9345177DD77@gmail.com> <49a77b7a0711270644t563a33c8ybb7f7f685300ff77@mail.gmail.com> <474DA287.9080606@cern.ch> <20071129233133.GB3757@localhost.localdomain> Message-ID: Stefan O'Rear wrote: > > In my C programming, I've taken to using gdb as a REPL: Ah, that's a nice trick, thanks! I wish I there had been a gdb on MacOS 8.5 back then ;) Regards, apfelmus From prstanley at ntlworld.com Mon Dec 3 04:16:07 2007 From: prstanley at ntlworld.com (PR Stanley) Date: Mon Dec 3 04:11:39 2007 Subject: [Haskell-cafe] Monads Message-ID: <7.0.1.0.0.20071203091321.01b15f80@ntlworld.com> Hi Does the list consider http://en.wikibooks.org/w/index.php?title=Haskell/Understanding_monads&oldid=933545 a reliable tutorial on monads and, if not, could you recommend an onlien alternative please? Thanks, Paul From bulat.ziganshin at gmail.com Mon Dec 3 04:18:07 2007 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Dec 3 04:14:29 2007 Subject: [Haskell-cafe] Possible Improvements In-Reply-To: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> References: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> Message-ID: <1433087232.20071203121807@gmail.com> Hello PR, Monday, December 3, 2007, 8:20:35 AM, you wrote: > occurs m (Node l n r) = m == n || occurs m l || occurs m r in terms of style, i can prefer occurs m (Node l n r) = or [m==n, occurs m l, occurs m r] -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From radoslawg at gmail.com Mon Dec 3 04:21:58 2007 From: radoslawg at gmail.com (=?UTF-8?Q?Rados=C5=82aw_Grzanka?=) Date: Mon Dec 3 04:17:35 2007 Subject: [Haskell-cafe] Monads In-Reply-To: <7.0.1.0.0.20071203091321.01b15f80@ntlworld.com> References: <7.0.1.0.0.20071203091321.01b15f80@ntlworld.com> Message-ID: <9d55dbaf0712030121u457969feu90a68faa3df065d2@mail.gmail.com> Hi, 2007/12/3, PR Stanley : > Hi > Does the list consider > http://en.wikibooks.org/w/index.php?title=Haskell/Understanding_monads&oldid=933545 > a reliable tutorial on monads and, if not, could you recommend an > onlien alternative please? I really enjoyed "All about Monads" by Jeff Newbern http://www.haskell.org/all_about_monads/html/index.html Cheers, Radek. -- Codeside: http://codeside.org/ Przedszkole Miejskie nr 86 w Lodzi: http://www.pm86.pl/ From ketil+haskell at ii.uib.no Mon Dec 3 04:48:33 2007 From: ketil+haskell at ii.uib.no (Ketil Malde) Date: Mon Dec 3 04:44:10 2007 Subject: [Haskell-cafe] Possible Improvements In-Reply-To: <90889fe70712030043g3c104b9bpfd3f221734441afa@mail.gmail.com> (Johan Tibell's message of "Mon\, 3 Dec 2007 09\:43\:16 +0100") References: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> <20071203052330.GM13662@scytale.galois.com> <4683d9370712022135o5bf75cd1x3cbbf6567382813e@mail.gmail.com> <20071203055405.GN13662@scytale.galois.com> <1196664351.5471.13.camel@derek-laptop> <90889fe70712030043g3c104b9bpfd3f221734441afa@mail.gmail.com> Message-ID: <87myssglce.fsf@nmd9999.imr.no> "Johan Tibell" writes: > It would be great if someone could exemplify these "rules of thumb", > e.g. "Primitive types such as Int should be strict unless in the three > canonical examples X, Y and Z." My strictness radar is still quite > poor and I feel I can't make informed decisions on when I need to make > something more strict or lazy. I find that I often need to add strictness when: left thumb) parsing [Char] into something more compact, i.e. almost all cases. right thumb) storing data into maps, especially when the values are produced by multiple updates - i.e. doing word frequency counts. -k -- If I haven't seen further, it is by standing in the footprints of giants From reinier.lamers at phil.uu.nl Mon Dec 3 05:19:57 2007 From: reinier.lamers at phil.uu.nl (Reinier Lamers) Date: Mon Dec 3 05:15:33 2007 Subject: [Haskell-cafe] Re: Array copying In-Reply-To: <47529EB4.6070909@list.mightyreason.com> References: <47517DAF.4070102@btinternet.com> <47529D40.60001@btinternet.com> <47529EB4.6070909@list.mightyreason.com> Message-ID: <4753D84D.5080607@phil.uu.nl> ChrisK wrote: >For GHC 6.6 I created > > > >>foreign import ccall unsafe "memcpy" >> memcpy :: MutableByteArray# RealWorld -> MutableByteArray# RealWorld -> Int# -> IO () >> >> > > > >>{-# INLINE copySTU #-} >>copySTU :: (Show i,Ix i,MArray (STUArray s) e (ST s)) => STUArray s i e -> STUArray s i e -> ST s () >>copySTU (STUArray _ _ msource) (STUArray _ _ mdest) = >>-- do b1 <- getBounds s1 >>-- b2 <- getBounds s2 >>-- when (b1/=b2) (error ("\n\nWTF copySTU: "++show (b1,b2))) >> ST $ \s1# -> >> case sizeofMutableByteArray# msource of { n# -> >> case unsafeCoerce# memcpy mdest msource n# s1# of { (# s2#, () #) -> >> (# s2#, () #) }} >> >> > >To allow efficient copying of STUArrays. > > How does this guarantee that it doesn't overflow the buffer of the destination array? Reinier From dons at galois.com Mon Dec 3 05:20:19 2007 From: dons at galois.com (Don Stewart) Date: Mon Dec 3 05:16:01 2007 Subject: [Haskell-cafe] Parallelise now! Was: Re: Possible Improvements In-Reply-To: <20071203055405.GN13662@scytale.galois.com> References: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> <20071203052330.GM13662@scytale.galois.com> <4683d9370712022135o5bf75cd1x3cbbf6567382813e@mail.gmail.com> <20071203055405.GN13662@scytale.galois.com> Message-ID: <20071203102019.GA14902@scytale.galois.com> dons: > Strict in the elements, lazy in the spine: > > data Tree = Leaf !Int | Node Tree !Int Tree > > $ time ./A 25 > 49 > ./A 25 14.41s user 0.03s system 99% cpu 14.442 total > ^^^^^^ > 3056K heap use. And, finally, we can get a little speedup again over the basic element-strict, -funboxed-strict-fields tree by parallelising some of the traversals. Nothing great, but I didn't try very hard: Serial code: {-# OPTIONS -O2 -funbox-strict-fields #-} import System.Environment data Tree = Leaf !Int | Node Tree !Int Tree main = do n <- getArgs >>= readIO . head let t = make (n*2) n print (check t) make :: Int -> Int -> Tree make i 0 = Node (Leaf 0) i (Leaf 0) make i d = Node (make (i2-1) d2) i (make i2 d2) where i2 = 2*i d2 = d-1 check :: Tree -> Int check (Leaf _) = 0 check (Node l i r) = i + check l - check r Running: $ time ./A 28 55 ./A 28 24.39s user 0.03s system 99% cpu 24.424 total Ok. Now, parallelise that recursive call in 'check': check :: Tree -> Int check (Leaf _) = 0 check (Node l i r) = lp `par` (rp `pseq` i + lp - rp) -- <-- where lp = check l rp = check r Super-simple strategy -- will register too many sparks, but what the heh... $ time ./B 28 +RTS -N2 55 ./B 28 +RTS -N2 31.81s user 0.14s system 147% cpu 21.700 total Pretty good for a naive strategy, and only one branch, on one line had to be modified. Control.Parallel, yay! -- Don From dons at galois.com Mon Dec 3 05:27:49 2007 From: dons at galois.com (Don Stewart) Date: Mon Dec 3 05:23:38 2007 Subject: [Haskell-cafe] A tale of three shootout entries In-Reply-To: References: <646EDB19-2A9B-45B9-8043-2C1CBD5533E1@gmail.com> <474C2C8E.1040702@millstream.com> <474C6B65.9080904@millstream.com> <475056D5.3080904@millstream.com> Message-ID: <20071203102749.GA14921@scytale.galois.com> s.clover: > Was this with tossing the partial sums code into the optimised bangs > program? Weird. I wonder if profiling will help explain why? In any case, > If nobody comes up with any other tweaks, I'll probably submit the > optimised bangs version to the shootout this weekend. > Please go ahead and submit. :) and remember to upload also to our wiki, so we have a permanent record of the attempt, http://haskell.org/haskellwiki/Shootout Note down any ideas you have. -- Don From rahn at ira.uka.de Mon Dec 3 05:44:35 2007 From: rahn at ira.uka.de (Mirko Rahn) Date: Mon Dec 3 05:40:28 2007 Subject: [Haskell-cafe] Re: Optimizing cellular automata evaluation (round 2) In-Reply-To: References: Message-ID: > http://hpaste.org/4151#a1 It is interesting, that the naive implementation import Data.List (tails) neighbours :: Int -> [a] -> [[a]] neighbours w = rotL . take w . map (take 3) . tails . cycle rotL :: [a] -> [a] rotL xs = last xs : init xs type Rule a = [a] -> a step :: Int -> Rule a -> [a] -> [a] step w f = map f . neighbours w rule110 :: Rule Char rule110 " " = ' ' rule110 "X " = ' ' rule110 "XXX" = ' ' rule110 _ = 'X' main = let f = step 149 rule110 init = replicate 148 ' ' ++ "X" in mapM_ putStrLn $ take 10000 $ iterate f init is only 3 times slower than your quite complex, hard to follow and hard to debug implementation. As always, I prefer to write most code in Haskell, quick, easy, nice, reasonable fast, ... If speed matters, I switch to some lower level language, as you did staying inside Haskell. /BR, Mirko Rahn From tom.davie at gmail.com Mon Dec 3 06:09:21 2007 From: tom.davie at gmail.com (Thomas Davie) Date: Mon Dec 3 06:05:02 2007 Subject: [Haskell-cafe] Re: Trees In-Reply-To: References: <467915C1-11AF-4B0F-A008-DACE1E84CC6E@inf.fu-berlin.de> Message-ID: One could alway store a node's depth at each node -- then you must search for u and v, creating a list of what nodes you found at each depth, and finally, simply compare the lists -- O(n) in the depth of u and v. Bob On 3 Dec 2007, at 08:40, apfelmus wrote: > Adrian Neumann wrote: >> > data Tree a = Leaf a | Node a [Tree a] >> But now the assignments require more than a simple top-down >> traversal. For example: given a tree t and two nodes u,v, find the >> first common ancestor. > > Well, this problem doesn't make much sense in Haskell. How do you > specify the subtrees u and v in the first place? > > > Regards, > apfelmus > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From apfelmus at quantentunnel.de Mon Dec 3 06:22:20 2007 From: apfelmus at quantentunnel.de (apfelmus) Date: Mon Dec 3 06:18:14 2007 Subject: [Haskell-cafe] Re: Trees In-Reply-To: References: <467915C1-11AF-4B0F-A008-DACE1E84CC6E@inf.fu-berlin.de> Message-ID: Thomas Davie wrote: > apfelmus wrote >> Well, this problem doesn't make much sense in Haskell. >> How do you specify the subtrees u and v in the first place? > > One could alway store a node's depth at each node -- then you must > search for u and v, creating a list of what nodes you found at each > depth, and finally, simply compare the lists -- O(n) in the depth of u > and v. Huh? I mean, are u and v node labels of type a? Or are they subtrees? In any case, they aren't "pointers" into the tree. In the case of node labels, a breath first search will take O(number of nodes of depth <= min (depth u) (depth v)) steps which is O(size of the tree) in the worst case. Regards, apfelmus From john at repetae.net Mon Dec 3 06:42:04 2007 From: john at repetae.net (John Meacham) Date: Mon Dec 3 06:37:40 2007 Subject: [Haskell-cafe] ARM back end? In-Reply-To: <1f3dc80d0711021330t5510e77fgad4b23c5a5d07617@mail.gmail.com> References: <1f3dc80d0711021330t5510e77fgad4b23c5a5d07617@mail.gmail.com> Message-ID: <20071203114203.GA23475@momenergy.repetae.net> On Fri, Nov 02, 2007 at 01:30:44PM -0700, Greg Fitzgerald wrote: > Anybody know of an ARM back end for any of the Haskell compilers? jhc can compile to the arm as well. This was tested by compiling a simple program for the iPhone. :) John -- John Meacham - ?repetae.net?john? From prstanley at ntlworld.com Mon Dec 3 06:55:14 2007 From: prstanley at ntlworld.com (PR Stanley) Date: Mon Dec 3 06:50:43 2007 Subject: [Haskell-cafe] do Message-ID: <7.0.1.0.0.20071203115053.01b15618@ntlworld.com> Hi I've probably asked about the do construct, if that's the right label. Unfortunately I'm still not quite sure of its role and more specifically its syntax. Something to do with generators perhaps? A description plus some examples would be most gratefully received. Thanks, Paul From hanzhupeng at gmail.com Mon Dec 3 07:39:22 2007 From: hanzhupeng at gmail.com (Albert Lee) Date: Mon Dec 3 07:35:01 2007 Subject: [Haskell-cafe] I'm translating to Chinese Message-ID: <7dc437b10712030439w3582ccc9hde2929d39510f0de@mail.gmail.com> I have been confussed by monad for a long time. and I can't stand for it any more. so I start to translate the tutorial to my mother language Chinese. My English is not good enough, so this work is only for my own study~ I know there are some other Chinese fellow in this list, wish it would be helpful. I will work for one chapter everyday. the address is: http://www.kamang.net From peter.padawitz at udo.edu Mon Dec 3 07:43:14 2007 From: peter.padawitz at udo.edu (Peter Padawitz) Date: Mon Dec 3 07:38:58 2007 Subject: [Haskell-cafe] type class question Message-ID: <4753F9E2.6090500@udo.edu> What is wrong here? ghci tries (and fails) to deduce certain types for the comp functions that I did not expect. |type Block = [Command] data Command = Skip | Assign String IntE | Cond BoolE Block Block | Loop BoolE Block data IntE = IntE Int | Var String | Sub IntE IntE | Sum [IntE] | Prod [IntE] data BoolE = BoolE Bool | Greater IntE IntE | Not BoolE class Java block command intE boolE where block_ :: [command] -> block skip :: command assign :: String -> intE -> command cond :: boolE -> block -> block -> command loop :: boolE -> block -> command intE_ :: Int -> intE var :: String -> intE sub :: intE -> intE -> intE sum_ :: [intE] -> intE prod :: [intE] -> intE boolE_ :: Bool -> boolE greater :: intE -> intE -> boolE not_ :: boolE -> boolE compBlock :: Block -> block compBlock = block_ . map compCommand compCommand :: Command -> command compCommand Skip = skip compCommand (Assign x e) = assign x (compIntE e) compCommand (Cond be c c') = cond (compBoolE be) (compCommand c) (compCommand c') compCommand (Loop be c) = loop (compBoolE be) (compCommand c)-} compIntE :: IntE -> intE compIntE (IntE i) = intE_ i compIntE (Var x) = var x compIntE (Sub e e') = sub (compIntE e) (compIntE e') compIntE (Sum es) = sum_ (map compIntE es) compIntE (Prod es) = prod (map compIntE es) compBoolE :: BoolE -> boolE compBoolE (BoolE b) = boolE_ b compBoolE (Greater e e') = greater (compIntE e) (compIntE e') compBoolE (Not be) = not_ (compBoolE be) | -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071203/b797ca5b/attachment.htm From radoslawg at gmail.com Mon Dec 3 07:49:24 2007 From: radoslawg at gmail.com (=?UTF-8?Q?Rados=C5=82aw_Grzanka?=) Date: Mon Dec 3 07:45:01 2007 Subject: [Haskell-cafe] I'm translating to Chinese In-Reply-To: <7dc437b10712030439w3582ccc9hde2929d39510f0de@mail.gmail.com> References: <7dc437b10712030439w3582ccc9hde2929d39510f0de@mail.gmail.com> Message-ID: <9d55dbaf0712030449t77fe3e32v7157f2748568bfb3@mail.gmail.com> 2007/12/3, Albert Lee : > I have been confussed by monad for a long time. and I can't stand for > it any more. so I start to translate the tutorial > to my mother language Chinese. > My English is not good enough, so this work is only for my own study~ > I know there are some other Chinese fellow in this list, wish it would > be helpful. > I will work for one chapter everyday. I will hijack somewhat this thread. If anybody is interested in helping translation of "All About Monads" into Polish for (slowly) emerging http://haskell.pl/ *) website then contact me. Thanks, Radek. *) http://haskell.pl/ is not ready by any means. I'm configuring drupal and I'm gathering some initial content. If anybody is interested then dop me a line. -- Codeside: http://codeside.org/ Przedszkole Miejskie nr 86 w Lodzi: http://www.pm86.pl/ From simonmarhaskell at gmail.com Mon Dec 3 08:02:09 2007 From: simonmarhaskell at gmail.com (Simon Marlow) Date: Mon Dec 3 07:57:49 2007 Subject: [Haskell-cafe] Re: A tale of three shootout entries In-Reply-To: References: <646EDB19-2A9B-45B9-8043-2C1CBD5533E1@gmail.com> <474C2C8E.1040702@millstream.com> <474C6B65.9080904@millstream.com> <20071127191736.GA25301@scytale.galois.com> Message-ID: <4753FE51.9010205@microsoft.com> Simon Peyton-Jones wrote: > | There may well have been changes to the strictness analyser that make > | some of the bangs (or most) unnecessary now. Also, its very likely > | I didn't check all combinations of strict and lazy arguments for the > | optimal evaluation strategy :) > | > | If it seems to be running consitently faster (and producing better Core > | code), by all means submit. I don't think this is a ghc bug or anything > | like that though: just overuse of bangs, leading to unnecessary work. > > You might think that unnecessary bangs shouldn't lead to unnecessary work -- if GHC knows it's strict *and* you bang the argument, it should still only be evaluated once. But it can happen. Consider > > f !xs = length xs > > Even though 'length' will evaluate its argument, f nevertheless evaluates it too. Bangs say "evaluate it now", like seq, because we may be trying to control space usage. In this particular case it's silly, because the *first* thing length does is evaluate its argument, but that's not true of every strict function. > > That's why I say it'd be good to have well-characterised examples. It *may* be something like what I describe. Or it may be a silly omission somewhere. A little addition to what Simon mentioned above: while it is definitely true that adding unnecessary bangs can cause a slowdown, the slowdown should be much less with 6.8.1 because in the common case each evaluation will be an inline test rather than an out-of-line indirect jump and return. So, with 6.8.x, you should feel more free to sprinkle those bangs... Cheers, Simon From simonmarhaskell at gmail.com Mon Dec 3 08:10:50 2007 From: simonmarhaskell at gmail.com (Simon Marlow) Date: Mon Dec 3 08:06:30 2007 Subject: [Haskell-cafe] Re: Waiting for thread to finish In-Reply-To: <548d2f9d0711271747p4d3e3cecv354279059120691d@mail.gmail.com> References: <548d2f9d0711271634j6df5ecd7x5a50214e9b340e28@mail.gmail.com> <548d2f9d0711271646n5e74cc25x5334802c8f7375b4@mail.gmail.com> <200711271854.03246.sjanssen@cse.unl.edu> <548d2f9d0711271706p671d464fu47d9f44654c821f9@mail.gmail.com> <1196213454.7854.1223590119@webmail.messagingengine.com> <548d2f9d0711271747p4d3e3cecv354279059120691d@mail.gmail.com> Message-ID: <4754005A.3050406@microsoft.com> Brad Clow wrote: > On Nov 28, 2007 11:30 AM, Matthew Brecknell wrote: >> Even with threads, results are evaluated only when they are needed (or >> when forced by a strictness annotation). So the thread that needs a >> result (or forces it) first will be the one to evaluate it. > > So does GHC implement some sychronisation given that a mutation is > occuring under the covers, ie. the thunk is being replaced by the > result? Yes, see http://haskell.org/~simonmar/bib/multiproc05_abstract.html we use lock-free synchronisation, with a slight possibility that two threads might evaluate the same thunk. But since they'll produce the same result, nothing goes wrong. Cheers, Simon From dbueno at gmail.com Mon Dec 3 09:00:15 2007 From: dbueno at gmail.com (Denis Bueno) Date: Mon Dec 3 08:55:51 2007 Subject: [Haskell-cafe] do In-Reply-To: <7.0.1.0.0.20071203115053.01b15618@ntlworld.com> References: <7.0.1.0.0.20071203115053.01b15618@ntlworld.com> Message-ID: <6dbd4d000712030600s59868d88j6a5d675da7316174@mail.gmail.com> On Dec 3, 2007 6:55 AM, PR Stanley wrote: > Hi > I've probably asked about the do construct, if that's the right > label. Unfortunately I'm still not quite sure of its role and more > specifically its syntax. Something to do with generators perhaps? A > description plus some examples would be most gratefully received. Probably one should understand how to use monads before worrying about the do-notation. Here are some references: http://haskell.org/haskellwiki/Books_and_tutorials#Using_monads http://en.wikibooks.org/wiki/Haskell/Understanding_monads Section 2.5 of http://haskell.org/haskellwiki/Learning_Haskell Hope this helps. -- Denis From cgibbard at gmail.com Mon Dec 3 09:25:06 2007 From: cgibbard at gmail.com (Cale Gibbard) Date: Mon Dec 3 09:20:43 2007 Subject: [Haskell-cafe] do In-Reply-To: <7.0.1.0.0.20071203115053.01b15618@ntlworld.com> References: <7.0.1.0.0.20071203115053.01b15618@ntlworld.com> Message-ID: <89ca3d1f0712030625ua0d23dek2b6cebd508505d66@mail.gmail.com> There are a few rules by which do-syntax is translated into a chain of bind (>>=) operations: They are, (approximately): do { x } = x do { x ; } = x >> do { } do { v <- x ; } = x >>= \v -> do { } do { let { } ; } = let in do { } The meaning of >>= depends on which monad you're using. I've written a high-level overview about monads, including a section about do-notation here: http://haskell.org/haskellwiki/Monads_as_computation I've also written http://haskell.org/haskellwiki/Monads_as_containers which I've found is an approach which is often fairly useful for those starting out. If you're just interested in how IO is handled in Haskell, I can offer a quick blurb about how we think about that here, which I recommend regardless since it's short: http://haskell.org/haskellwiki/Introduction_to_IO - Cale On 03/12/2007, PR Stanley wrote: > Hi > I've probably asked about the do construct, if that's the right > label. Unfortunately I'm still not quite sure of its role and more > specifically its syntax. Something to do with generators perhaps? A > description plus some examples would be most gratefully received. > Thanks, Paul > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From haskell at list.mightyreason.com Mon Dec 3 09:39:31 2007 From: haskell at list.mightyreason.com (ChrisK) Date: Mon Dec 3 09:36:28 2007 Subject: [Haskell-cafe] Re: Array copying In-Reply-To: <4753D84D.5080607@phil.uu.nl> References: <47517DAF.4070102@btinternet.com> <47529D40.60001@btinternet.com> <47529EB4.6070909@list.mightyreason.com> <4753D84D.5080607@phil.uu.nl> Message-ID: <47541523.1050804@list.mightyreason.com> Reinier Lamers wrote: > ChrisK wrote: > >> For GHC 6.6 I created >> >> >> >>> foreign import ccall unsafe "memcpy" >>> memcpy :: MutableByteArray# RealWorld -> MutableByteArray# >>> RealWorld -> Int# -> IO () >>> >> >> >> >>> {-# INLINE copySTU #-} >>> copySTU :: (Show i,Ix i,MArray (STUArray s) e (ST s)) => STUArray s i >>> e -> STUArray s i e -> ST s () >>> copySTU (STUArray _ _ msource) (STUArray _ _ mdest) = >>> -- do b1 <- getBounds s1 >>> -- b2 <- getBounds s2 >>> -- when (b1/=b2) (error ("\n\nWTF copySTU: "++show (b1,b2))) >>> ST $ \s1# -> >>> case sizeofMutableByteArray# msource of { n# -> >>> case unsafeCoerce# memcpy mdest msource n# s1# of { (# s2#, () #) -> >>> (# s2#, () #) }} >>> >> >> To allow efficient copying of STUArrays. >> >> > How does this guarantee that it doesn't overflow the buffer of the > destination array? As is, the above is a very unsafe operation. The check is commented out. You can uncomment the code above that says: > do b1 <- getBounds s1 > b2 <- getBounds s2 > when (b1/=b2) (error ("\n\nWTF copySTU: "++show (b1,b2))) Which checks the high-level boundary matches, not just the actual length. I only have a single size of STUArray haning around, so I use the unsafe and fast version. -- Chris From gale at sefer.org Mon Dec 3 09:56:02 2007 From: gale at sefer.org (Yitzchak Gale) Date: Mon Dec 3 09:51:40 2007 Subject: [Haskell-cafe] Trees In-Reply-To: <20071203073128.GA4695@localhost.localdomain> References: <467915C1-11AF-4B0F-A008-DACE1E84CC6E@inf.fu-berlin.de> <20071203073128.GA4695@localhost.localdomain> Message-ID: <2608b8a80712030656n4fc4db2tdca4bb52e90db3c@mail.gmail.com> Adrian Neumann wrote: >> > data Tree a = Leaf a | Node a [Tree a] >> example: given a tree t and two nodes u,v, find the >> first common ancestor. In Java this is really simple, >> because each node has a "parent" reference... >> In Haskell however the best way I've come up with so >> far is doing a BFS and looking for the last common >> node in the paths to u and v. Stefan O'Rear wrote: > the Java solution translates to Haskell: > data Tree a = Node { idn:: Int, val:: a, parent:: Maybe (Tree a), children:: [Tree a] } > You can make this efficiently mutable... That looks like a tying-the-knot approach. It is interesting, but I don't see how it is similar to the Java. You still need to search for u and v somehow. And as for making it mutable, you can forget it; your fingers will quickly become weary from untying and retying all of those knots. Perhaps you meant: data Node a = Node { idn:: Int, val:: a, parent:: Maybe Int, children:: [Int] } type Tree a = Data.IntMap (Node a) -Yitz From haskell at list.mightyreason.com Mon Dec 3 09:56:17 2007 From: haskell at list.mightyreason.com (ChrisK) Date: Mon Dec 3 09:53:00 2007 Subject: [Haskell-cafe] Re: Array copying In-Reply-To: <4752BFFE.1050108@btinternet.com> References: <47517DAF.4070102@btinternet.com> <47529D40.60001@btinternet.com> <47529EB4.6070909@list.mightyreason.com> <4752BFFE.1050108@btinternet.com> Message-ID: <47541911.9030008@list.mightyreason.com> Andrew Coppin wrote: > ChrisK wrote: >> For GHC 6.6 I created >> >> >>> foreign import ccall unsafe "memcpy" >>> memcpy :: MutableByteArray# RealWorld -> MutableByteArray# >>> RealWorld -> Int# -> IO () >>> >> >> >>> {-# INLINE copySTU #-} >>> copySTU :: (Show i,Ix i,MArray (STUArray s) e (ST s)) => STUArray s i >>> e -> STUArray s i e -> ST s () >>> copySTU (STUArray _ _ msource) (STUArray _ _ mdest) = >>> -- do b1 <- getBounds s1 >>> -- b2 <- getBounds s2 >>> -- when (b1/=b2) (error ("\n\nWTF copySTU: "++show (b1,b2))) >>> ST $ \s1# -> >>> case sizeofMutableByteArray# msource of { n# -> >>> case unsafeCoerce# memcpy mdest msource n# s1# of { (# s2#, () #) -> >>> (# s2#, () #) }} >>> >> >> To allow efficient copying of STUArrays. >> > > So... that copies the entire array into another array of the same size? > (I'm having a lot of trouble understanding the code...) Yes, that is what it does. The "STUArray" data type has the STUArray constructor which I import and pattern match against. The imports are: > import Data.Array.Base(unsafeRead,unsafeWrite,STUArray(..)) > import GHC.Prim(MutableByteArray#,RealWorld,Int#,sizeofMutableByteArray#,unsafeCoerce#) in 6.6.1 this is defined as > data STUArray s i a = STUArray !i !i (MutableByteArray# s) in 6.8.1 this is defined as > data STUArray s i a = STUArray !i !i !Int (MutableByteArray# s) I use sizeofMutableByteArray# to get the source size, n#. I have lost track of how unsafeCoerce# and s1# are being used...oops. It is similar to data-dependency tricks used inside Data.Array.Base, though. -- Chris From haskell at brecknell.org Mon Dec 3 10:36:48 2007 From: haskell at brecknell.org (Matthew Brecknell) Date: Mon Dec 3 10:32:27 2007 Subject: [Haskell-cafe] Trees In-Reply-To: <2608b8a80712030656n4fc4db2tdca4bb52e90db3c@mail.gmail.com> References: <467915C1-11AF-4B0F-A008-DACE1E84CC6E@inf.fu-berlin.de> <20071203073128.GA4695@localhost.localdomain> <2608b8a80712030656n4fc4db2tdca4bb52e90db3c@mail.gmail.com> Message-ID: <1196696208.6288.1224522265@webmail.messagingengine.com> Adrian Neumann: > > data Tree a = Leaf a | Node a [Tree a] > example: given a tree t and two nodes u,v, find the > first common ancestor. The following solves what I think is a generalisation of this problem. That is, given a tree and a predicate on its elements, return the smallest subtree containing all nodes satisfying the predicate, or Nothing if none satisfy it. > import Data.Maybe > > data Tree a = Node a [Tree a] > > lub :: (a -> Bool) -> Tree a -> Maybe (Tree a) > lub p (Node a s) > | p a = Just (Node a s) > | otherwise = case mapMaybe (lub p) s of > [] -> Nothing > [t] -> Just t > _ -> Just (Node a s) If I understand the original problem correctly, then the appropriate predicate would just be (flip elem [u,v]). From thrakatak at hotmail.com Mon Dec 3 12:18:18 2007 From: thrakatak at hotmail.com (Carlo Vivari) Date: Mon Dec 3 12:13:55 2007 Subject: [Haskell-cafe] foild function for expressions Message-ID: <14119002.post@talk.nabble.com> Hi! I'm a begginer in haskell and I have a problem with an exercise, I expect someone could help me: In one hand I have a declaration of an algebra data, like this: data AlgExp a = AlgExp { litI :: Int -> a, litB :: Bool -> a, add :: a -> a -> a, and :: a -> a -> a, ifte :: a -> a -> a -> a} (being ifte an 'ifthenelse' expresion...) What I want to do is to write a fold function for expressions, something like this: foldExp :: AlgExp a -> Exp -> a foldExp alg (LitI i) = litI alg i foldExp alg (LitB i) = litB alg i foldExp alg (add exp1 exp2) = ?????? foldExp alg (and exp1 exp2) = ?????? foldExp alg (ifte exp1 exp2 exp3) = ?????? ..ETC the fact is that I have no idea of what to do with the other expresions (add, and, and ifte)... I really don' t understand how to do this... It's clear that a fold function should colapse in one valour, but how can I espress it in the terms of the exercise? For further information about the problem after this, it's suposed that I have to rewrite some functions for expresions but in terms of foldexp (the one I should write before) Thank you very much!!!! -- View this message in context: http://www.nabble.com/foild-function-for-expressions-tf4932877.html#a14119002 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From mboes at tweag.net Mon Dec 3 12:24:10 2007 From: mboes at tweag.net (Mathieu Boespflug) Date: Mon Dec 3 12:19:48 2007 Subject: [Haskell-cafe] ARM back end? In-Reply-To: <14d615330711021419i42d43b91n41960cc479ccf2c5@mail.gmail.com> References: <1f3dc80d0711021330t5510e77fgad4b23c5a5d07617@mail.gmail.com> <14d615330711021419i42d43b91n41960cc479ccf2c5@mail.gmail.com> Message-ID: <63c0799b0712030924q518d05cco98293f3ce9f321d9@mail.gmail.com> On Nov 2, 2007 10:19 PM, nornagon wrote: > On 03/11/2007, Greg Fitzgerald wrote: > > Anybody know of an ARM back end for any of the Haskell compilers? > > > > If there's an arm-eabi port somewhere, I might be able to get Haskell > code running on the Nintendo DS... https://garage.maemo.org/projects/hugs/ Runs on my Nokia N800 which is arm-eabi based. Mathieu From ndmitchell at gmail.com Mon Dec 3 12:33:46 2007 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon Dec 3 12:29:22 2007 Subject: [Haskell-cafe] Nofib modifications Message-ID: <404396ef0712030933x64e2bf8ve25996c148a3cb57@mail.gmail.com> Hi, Some of the nofib suite are messed up by Yhc/nhc because of the monomorphism restriction. Take imaginary/bernouilli as an example: powers = [2..] : map (zipWith (*) (head powers)) powers Hugs and GHC both see powers :: [[Integer]] and a CAF. Yhc (and nhc) both see powers :: (Enum a, Num a) => [[a]] and no CAF. This completely destroys the performance in Yhc/nhc. Since this is not so much a performance aspect but a compiler bug, based on a feature whose future in Haskell' is as yet unclear, perhaps it would be wise to patch nofib to include an explicit type signature where this matters. I am happy to send in a patch (or just apply it) - but I have no idea who "maintains" the suite. I've CC'd those people who make substantial use of the nofib suite. Thanks Neil From simonpj at microsoft.com Mon Dec 3 12:43:01 2007 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Mon Dec 3 12:38:40 2007 Subject: [Haskell-cafe] Nofib modifications In-Reply-To: <404396ef0712030933x64e2bf8ve25996c148a3cb57@mail.gmail.com> References: <404396ef0712030933x64e2bf8ve25996c148a3cb57@mail.gmail.com> Message-ID: By all means apply a patch, I think. Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Neil Mitchell | Sent: 03 December 2007 17:34 | To: Haskell Cafe | Cc: Simon Marlow; Malcolm Wallace; Duncan Coutts | Subject: [Haskell-cafe] Nofib modifications | | Hi, | | Some of the nofib suite are messed up by Yhc/nhc because of the | monomorphism restriction. Take imaginary/bernouilli as an example: | | powers = [2..] : map (zipWith (*) (head powers)) powers | | Hugs and GHC both see powers :: [[Integer]] and a CAF. | | Yhc (and nhc) both see powers :: (Enum a, Num a) => [[a]] and no CAF. | | This completely destroys the performance in Yhc/nhc. Since this is not | so much a performance aspect but a compiler bug, based on a feature | whose future in Haskell' is as yet unclear, perhaps it would be wise | to patch nofib to include an explicit type signature where this | matters. I am happy to send in a patch (or just apply it) - but I have | no idea who "maintains" the suite. I've CC'd those people who make | substantial use of the nofib suite. | | Thanks | | Neil | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe From kalman.noel at bluebottle.com Mon Dec 3 12:43:00 2007 From: kalman.noel at bluebottle.com (Kalman Noel) Date: Mon Dec 3 12:38:45 2007 Subject: [Haskell-cafe] foild function for expressions In-Reply-To: <14119002.post@talk.nabble.com> References: <14119002.post@talk.nabble.com> Message-ID: <200712031743.lB3Hh76g001824@mi0.bluebottle.com> Carlo Vivari wrote: > data AlgExp a = AlgExp > { litI :: Int -> a, > litB :: Bool -> a, > add :: a -> a -> a, > and :: a -> a -> a, > ifte :: a -> a -> a -> a} You're confusing sum and product types. That is, you're using a product type, but you probably need a sum type, like this: data Exp1 = LitI Int | LitB Bool | Add Exp1 Exp1 | And Exp1 Exp1 | IfThenElse Exp1 Exp1 Exp1 But in this case, using GADTs (beware: not Haskell 98, but a very popular extension) makes for a more elegant solution. Note the strong types, disallowing e. g. the addition of a number to a boolean value: data Exp2 a where LitI :: Int -> Exp2 Int LitB :: Bool -> Exp2 Bool Add :: Exp2 Int -> Exp2 Int -> Exp2 Int And :: Exp2 Bool -> Exp2 Bool -> Exp2 Bool IfThenElse :: Exp2 Bool -> Exp2 a -> Exp2 a -> Exp2 a Kalman ---------------------------------------------------------------------- Get a free email address with REAL anti-spam protection. http://www.bluebottle.com/tag/1 From derek.a.elkins at gmail.com Mon Dec 3 12:48:10 2007 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Mon Dec 3 12:43:56 2007 Subject: [Haskell-cafe] Trees In-Reply-To: <2608b8a80712030656n4fc4db2tdca4bb52e90db3c@mail.gmail.com> References: <467915C1-11AF-4B0F-A008-DACE1E84CC6E@inf.fu-berlin.de> <20071203073128.GA4695@localhost.localdomain> <2608b8a80712030656n4fc4db2tdca4bb52e90db3c@mail.gmail.com> Message-ID: <1196704090.5527.1.camel@derek-laptop> On Mon, 2007-12-03 at 16:56 +0200, Yitzchak Gale wrote: > Adrian Neumann wrote: > >> > data Tree a = Leaf a | Node a [Tree a] > >> example: given a tree t and two nodes u,v, find the > >> first common ancestor. In Java this is really simple, > >> because each node has a "parent" reference... > >> In Haskell however the best way I've come up with so > >> far is doing a BFS and looking for the last common > >> node in the paths to u and v. > > Stefan O'Rear wrote: > > the Java solution translates to Haskell: > > data Tree a = Node { idn:: Int, val:: a, parent:: Maybe (Tree a), children:: [Tree a] } > > You can make this efficiently mutable... > > That looks like a tying-the-knot approach. It is interesting, > but I don't see how it is similar to the Java. You still > need to search for u and v somehow. And as for making > it mutable, you can forget it; your fingers will quickly > become weary from untying and retying all of those knots. If made mutable, there's nothing stopping it from being exactly like the Java approach. It should be no more finger tiring than Java (but then we -are- talking about Java...) From derek.a.elkins at gmail.com Mon Dec 3 13:04:52 2007 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Mon Dec 3 13:00:46 2007 Subject: [Haskell-cafe] Possible Improvements In-Reply-To: <87myssglce.fsf@nmd9999.imr.no> References: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> <20071203052330.GM13662@scytale.galois.com> <4683d9370712022135o5bf75cd1x3cbbf6567382813e@mail.gmail.com> <20071203055405.GN13662@scytale.galois.com> <1196664351.5471.13.camel@derek-laptop> <90889fe70712030043g3c104b9bpfd3f221734441afa@mail.gmail.com> <87myssglce.fsf@nmd9999.imr.no> Message-ID: <1196705092.5527.18.camel@derek-laptop> On Mon, 2007-12-03 at 10:48 +0100, Ketil Malde wrote: > "Johan Tibell" writes: > > > It would be great if someone could exemplify these "rules of thumb", > > e.g. "Primitive types such as Int should be strict unless in the three > > canonical examples X, Y and Z." My strictness radar is still quite > > poor and I feel I can't make informed decisions on when I need to make > > something more strict or lazy. > > I find that I often need to add strictness when: > > left thumb) parsing [Char] into something more compact, i.e. almost > all cases. > right thumb) storing data into maps, especially when the values are produced by > multiple updates - i.e. doing word frequency counts. Indeed, this generalizes fairly well. In general when going from a "large" structure (especially recursive types or arrays) to a "small" one (especially base types or small non-recursive types e.g. a vector type) you want strictness. Cale Gibbard argues that this is the only case where strictness is desirable. In the other three cases, "small" to "large", "large" to "large" and "small" to "small" either laziness is preferable or there is not a big difference between them. http://www.haskell.org/haskellwiki/Stack_overflow gives some advice on how to choose strictness for avoiding stack overflows. On that page you can see the above rule in action in, for example, the difference between concat :: [[a]] -> [a] and sum :: Num a => [a] -> a. The techniques sidebar on the Performance page, http://www.haskell.org/haskellwiki/Performance also contains some bits of advice. For example, the widely known advice about making accumulating parameters strict. This is related to Ketil's "right rule of thumb." Oftentimes the best way to get good behaviour is to use strict (in the appropriate places) data constructors. This will often eliminate most or all of the need for (other) strictness annotations. For example, one way of solving the issue with the scanl code on the Stack Overflow wiki page is by using a head strict list type (which, incidentally, Clean has native support for.) In fact, I suspect most of the time a head strict list type is either comparable or what is desired (though certainly not all of the time). From olivier.boudry at gmail.com Mon Dec 3 13:18:58 2007 From: olivier.boudry at gmail.com (Olivier Boudry) Date: Mon Dec 3 13:14:36 2007 Subject: [Haskell-cafe] Parsing unstructured data In-Reply-To: <47536103.1040106@hotpop.com> References: <47536103.1040106@hotpop.com> Message-ID: On 12/2/07, Steven Fodstad wrote: > > Sorry for not responding earlier. The haskell-cafe list is hard to keep > up with. > > The process of finding geographic (lat/long) coordinates from a text > address is called geocoding. Obviously extracting the parts of an > address is part of that, so you might find better results looking for > geocoding, rather than the more general and more difficult topic of > extracting structure from unstructured data. Unfortunately, I don't > have any references at hand on that part of geocoding. > Hi Steven, The idea of using the geocoding approach seems appealing. I already thought of using geocoding for address validation (after the parsing) but not of looking at how geocoding tools parse addresses. But I'm not sure geocoding tools would be suitable to handle my addresses. I used a few geocoding tools and usually you have to provide the address in a very specific format if you want it to be recognized. Also most of the time it work quite well for US addresses but not for other countries addresses. I need to recognize very specific parts of an address. More than what a geocoding tools will require. Like dock #, doors, suite #, contact person, etc... I'm currently using the ZipFourCE web service from BCCSoftware for validating my addresses against the USPS address database. This tool is built for parsing and correcting addresses but I just use it for validation as it's not "smart enough" to parse them or maybe they are just too scrambled for the parsing to be automated using an out of the box tool. ;-) Thanks for your input, Olivier. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071203/c1185ab3/attachment-0001.htm From newsham at lava.net Mon Dec 3 13:25:24 2007 From: newsham at lava.net (Tim Newsham) Date: Mon Dec 3 13:21:01 2007 Subject: [Haskell-cafe] do In-Reply-To: <6dbd4d000712030600s59868d88j6a5d675da7316174@mail.gmail.com> References: <7.0.1.0.0.20071203115053.01b15618@ntlworld.com> <6dbd4d000712030600s59868d88j6a5d675da7316174@mail.gmail.com> Message-ID: > Probably one should understand how to use monads before worrying about > the do-notation. Here are some references: I don't totally agree. You can teach monads to beginners just fine using the do-notation. Unsuprisingly its very much like teaching monads using bind. You describe a two line do-block as the basic building block for combining two actions into a single action: do { result1 <- act1 expr involving result1 building an act } show that you can nest them (expr can be another do block) do { result1 <- act1 do { result2 <- act2 expr involving result1 and result2 building an act } } and how the do-notation doesn't require you to start a new do-block for nesting of do's and let's do { result1 <- act1 let val1 <- expr resulting in a pure value result2 <- act2 expr involving result1 and result2 building an act } Then you can describe pattern matching and fail... I've had debates about what should be taught, and obviously not everyone agrees, but at the least, its possible and reasonable and understandable to teach do-notation first. > Denis Tim Newsham http://www.thenewsh.com/~newsham/ From tomahawkins at gmail.com Mon Dec 3 13:54:04 2007 From: tomahawkins at gmail.com (Tom Hawkins) Date: Mon Dec 3 13:49:42 2007 Subject: [Haskell-cafe] ANN: atom 2007.12 Message-ID: <594c1e830712031054r5ab632c0hcf99ba3d1ec4a420@mail.gmail.com> Hello, Atom is a language embedded in Haskell for describing reactive software, primarily for realtime control applications. Based on conditional term rewriting, an atom description is composed of a set of state transition rules. The name "atom" comes from the atomic behavior of rules: if a rule is selected to fire, all its transitions occur or none at all. A hallmark of the language, rule atomicity greatly simplifies design reasoning. This release of atom is a major redirection. Atom is no longer a hardware description language (I changed jobs. I'm now in software.). Much of the frontend language and backend generators have changed, though rule scheduling remains nearly the same. On the frontend, atom's Signal datatypes have been replaced with Terms and Vars, which leverage Haskell's GADTs. The 4 supported Term and Var types include Bool, Int, Float, and Double. At the backend, atom generates C and Simulink models. The Verilog and VHDL generators have been dropped, but they may reappear in the future. Enjoy! http://funhdl.org/ darcs get http://funhdl.org/darcs/atom -Tom From pocm at soton.ac.uk Mon Dec 3 14:07:20 2007 From: pocm at soton.ac.uk (Paulo J. Matos) Date: Mon Dec 3 14:02:56 2007 Subject: [Haskell-cafe] [Announce] FPSIG @ Southampton Message-ID: <11b141710712031107s76ebedb1h4c4ae6dd50169e88@mail.gmail.com> Hello all, Just to let you all know I'm leading a Special Interest Group in the University of Southampton, UK which is studying Haskell. I've put up a blog which I'll try to regularly update _at least_ with our meetings summary, exercises and code. We welcome any suggestions/comments/etc either via my email or as comments in the blog. I've added the group to the Haskell Wiki User Groups (I hope there's no problem). Cheers, -- Paulo Jorge Matos - pocm at soton.ac.uk http://www.personal.soton.ac.uk/pocm PhD Student @ ECS University of Southampton, UK From andrewcoppin at btinternet.com Mon Dec 3 13:55:36 2007 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Dec 3 14:18:27 2007 Subject: [Haskell-cafe] Possible Improvements In-Reply-To: <90889fe70712030043g3c104b9bpfd3f221734441afa@mail.gmail.com> References: <7.0.1.0.0.20071203051129.01b16300@ntlworld.com> <20071203052330.GM13662@scytale.galois.com> <4683d9370712022135o5bf75cd1x3cbbf6567382813e@mail.gmail.com> <20071203055405.GN13662@scytale.galois.com> <1196664351.5471.13.camel@derek-laptop> <90889fe70712030043g3c104b9bpfd3f221734441afa@mail.gmail.com> Message-ID: <47545128.8030208@btinternet.com> Johan Tibell wrote: > It would be great if someone could exemplify these "rules of thumb", > e.g. "Primitive types such as Int should be strict unless in the three > canonical examples X, Y and Z." My strictness radar is still quite > poor and I feel I can't make informed decisions on when I need to make > something more strict or lazy. > +1 When I first learned Haskell, lazyness sounded like a great idea, and I was somewhat puzzled as to why you would ever want to turn such a thing off. Fortunately (?!) after lots of experiments with the lambda calculus and other such things, I quickly realised that reducing large subexpression can sometimes be a big win. But I couldn't find much on the Wiki that explains all this stuff, and it would probably be quite useful to have! Of course, now we need somebody to *write* the thing... From andrewcoppin at btinternet.com Mon Dec 3 14:01:28 2007 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Dec 3 14:24:48 2007 Subject: [Haskell-cafe] A tale of three shootout entries In-Reply-To: <20071203102749.GA14921@scytale.galois.com> References: <646EDB19-2A9B-45B9-8043-2C1CBD5533E1@gmail.com> <474C2C8E.1040702@millstream.com> <474C6B65.9080904@millstream.com> <475056D5.3080904@millstream.com> <20071203102749.GA14921@scytale.galois.com> Message-ID: <47545288.7030601@btinternet.com> Don Stewart wrote: > Please go ahead and submit. :) and remember to upload also to our wiki, > so we have a permanent record of the attempt